@symbo.ls/utils 3.2.3 → 3.14.0
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/LICENSE +25 -12
- package/README.md +106 -0
- package/array.js +162 -0
- package/cache.js +7 -0
- package/cdn.js +83 -0
- package/component.js +25 -0
- package/cookie.js +71 -0
- package/{src/detectHeight.js → detectHeight.js} +3 -3
- package/dist/cjs/array.js +168 -0
- package/dist/cjs/browser.js +0 -2
- package/dist/cjs/cache.js +26 -0
- package/dist/cjs/cdn.js +85 -0
- package/dist/cjs/component.js +45 -0
- package/dist/cjs/cookie.js +75 -0
- package/dist/cjs/date.js +1 -3
- package/dist/cjs/detectHeight.js +4 -6
- package/dist/cjs/element.js +136 -0
- package/dist/cjs/env.js +43 -0
- package/dist/cjs/events.js +39 -0
- package/dist/cjs/extends.js +434 -0
- package/dist/cjs/fibonacci.js +1 -3
- package/dist/cjs/files.js +1 -3
- package/dist/cjs/function.js +114 -0
- package/dist/cjs/globals.js +30 -0
- package/dist/cjs/if.js +48 -0
- package/dist/cjs/index.js +38 -425
- package/dist/cjs/key.js +38 -0
- package/dist/cjs/keys.js +201 -0
- package/dist/cjs/load.js +5 -7
- package/dist/cjs/log.js +34 -0
- package/dist/cjs/metadata.js +310 -0
- package/dist/cjs/methods.js +599 -0
- package/dist/cjs/node.js +35 -0
- package/dist/cjs/object.js +634 -0
- package/dist/cjs/projectKeys.js +35 -0
- package/dist/cjs/props.js +282 -0
- package/dist/cjs/scaling.js +5 -169
- package/dist/cjs/scope.js +44 -0
- package/dist/cjs/sharedLibraries.js +146 -0
- package/dist/cjs/state.js +173 -0
- package/dist/cjs/string-extra.js +72 -0
- package/dist/cjs/string.js +183 -0
- package/dist/cjs/style.js +1 -3
- package/dist/cjs/tags.js +220 -0
- package/dist/cjs/triggerEvent.js +112 -0
- package/dist/cjs/types.js +74 -0
- package/dist/cjs/update.js +42 -0
- package/dist/esm/array.js +148 -0
- package/dist/esm/browser.js +14 -0
- package/dist/esm/cache.js +6 -0
- package/dist/esm/cdn.js +65 -0
- package/dist/esm/component.js +25 -0
- package/dist/esm/cookie.js +55 -0
- package/dist/esm/date.js +11 -0
- package/dist/esm/detectHeight.js +42 -0
- package/dist/esm/element.js +116 -0
- package/dist/esm/env.js +23 -0
- package/dist/esm/events.js +19 -0
- package/dist/esm/extends.js +414 -0
- package/dist/esm/fibonacci.js +10 -0
- package/dist/esm/files.js +4 -0
- package/dist/esm/function.js +94 -0
- package/dist/esm/globals.js +10 -0
- package/dist/esm/if.js +28 -0
- package/dist/esm/index.js +37 -0
- package/dist/esm/key.js +18 -0
- package/dist/esm/keys.js +181 -0
- package/dist/esm/load.js +151 -0
- package/dist/esm/log.js +14 -0
- package/dist/esm/metadata.js +290 -0
- package/dist/esm/methods.js +569 -0
- package/dist/esm/node.js +15 -0
- package/dist/esm/object.js +621 -0
- package/dist/esm/projectKeys.js +16 -0
- package/dist/esm/props.js +262 -0
- package/dist/esm/scaling.js +15 -0
- package/dist/esm/scope.js +24 -0
- package/dist/esm/sharedLibraries.js +126 -0
- package/dist/esm/state.js +163 -0
- package/dist/esm/string-extra.js +52 -0
- package/dist/esm/string.js +163 -0
- package/dist/esm/style.js +20 -0
- package/dist/esm/tags.js +200 -0
- package/dist/esm/triggerEvent.js +92 -0
- package/dist/esm/types.js +54 -0
- package/dist/esm/update.js +22 -0
- package/dist/iife/index.js +5818 -0
- package/element.js +148 -0
- package/env.js +15 -0
- package/events.js +19 -0
- package/extends.js +519 -0
- package/function.js +145 -0
- package/globals.js +8 -0
- package/if.js +30 -0
- package/index.js +41 -0
- package/key.js +20 -0
- package/keys.js +176 -0
- package/log.js +12 -0
- package/metadata.js +392 -0
- package/methods.js +636 -0
- package/node.js +37 -0
- package/object.js +803 -0
- package/package.json +38 -22
- package/projectKeys.js +30 -0
- package/props.js +327 -0
- package/{src/scaling.js → scaling.js} +1 -1
- package/scope.js +32 -0
- package/sharedLibraries.js +184 -0
- package/state.js +203 -0
- package/{src/index.js → string-extra.js} +11 -17
- package/string.js +206 -0
- package/tags.js +176 -0
- package/triggerEvent.js +102 -0
- package/types.js +55 -0
- package/update.js +27 -0
- package/dist/cjs/package.json +0 -4
- /package/{src/browser.js → browser.js} +0 -0
- /package/{src/date.js → date.js} +0 -0
- /package/{src/fibonacci.js → fibonacci.js} +0 -0
- /package/{src/files.js → files.js} +0 -0
- /package/{src/load.js → load.js} +0 -0
- /package/{src/style.js → style.js} +0 -0
|
@@ -0,0 +1,634 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var object_exports = {};
|
|
20
|
+
__export(object_exports, {
|
|
21
|
+
clone: () => clone,
|
|
22
|
+
createNestedObject: () => createNestedObject,
|
|
23
|
+
createObjectWithoutPrototype: () => createObjectWithoutPrototype,
|
|
24
|
+
deepClone: () => deepClone,
|
|
25
|
+
deepContains: () => deepContains,
|
|
26
|
+
deepDestringifyFunctions: () => deepDestringifyFunctions,
|
|
27
|
+
deepMerge: () => deepMerge,
|
|
28
|
+
deepStringifyFunctions: () => deepStringifyFunctions,
|
|
29
|
+
destringifyGlobalScope: () => destringifyGlobalScope,
|
|
30
|
+
detectInfiniteLoop: () => detectInfiniteLoop,
|
|
31
|
+
excludeKeysFromObject: () => excludeKeysFromObject,
|
|
32
|
+
exec: () => exec,
|
|
33
|
+
getInObjectByPath: () => getInObjectByPath,
|
|
34
|
+
hasFunction: () => hasFunction,
|
|
35
|
+
hasOwnProperty: () => hasOwnProperty,
|
|
36
|
+
isCyclic: () => isCyclic,
|
|
37
|
+
isEmpty: () => isEmpty,
|
|
38
|
+
isEmptyObject: () => isEmptyObject,
|
|
39
|
+
isEqualDeep: () => isEqualDeep,
|
|
40
|
+
makeObjectWithoutPrototype: () => makeObjectWithoutPrototype,
|
|
41
|
+
map: () => map,
|
|
42
|
+
merge: () => merge,
|
|
43
|
+
objectToString: () => objectToString,
|
|
44
|
+
overwrite: () => overwrite,
|
|
45
|
+
overwriteDeep: () => overwriteDeep,
|
|
46
|
+
overwriteShallow: () => overwriteShallow,
|
|
47
|
+
removeFromObject: () => removeFromObject,
|
|
48
|
+
removeNestedKeyByPath: () => removeNestedKeyByPath,
|
|
49
|
+
setInObjectByPath: () => setInObjectByPath,
|
|
50
|
+
stringToObject: () => stringToObject
|
|
51
|
+
});
|
|
52
|
+
module.exports = __toCommonJS(object_exports);
|
|
53
|
+
var import_globals = require("./globals.js");
|
|
54
|
+
var import_types = require("./types.js");
|
|
55
|
+
var import_array = require("./array.js");
|
|
56
|
+
var import_string = require("./string.js");
|
|
57
|
+
var import_node = require("./node.js");
|
|
58
|
+
var import_keys = require("./keys.js");
|
|
59
|
+
const ENV = process.env.NODE_ENV;
|
|
60
|
+
const _startsWithDunder = (e) => e.charCodeAt(0) === 95 && e.charCodeAt(1) === 95;
|
|
61
|
+
const exec = (param, element, state, context) => {
|
|
62
|
+
if ((0, import_types.isFunction)(param)) {
|
|
63
|
+
if (!element) return;
|
|
64
|
+
if (typeof param.call !== "function") return param;
|
|
65
|
+
return param.call(
|
|
66
|
+
element,
|
|
67
|
+
element,
|
|
68
|
+
state || element.state,
|
|
69
|
+
context || element.context
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
if (param != null && element?.context?.plugins && ((0, import_types.isArray)(param) || (0, import_types.isObject)(param) && !(0, import_node.isDOMNode)(param))) {
|
|
73
|
+
const plugins = element.context.plugins;
|
|
74
|
+
for (const plugin of plugins) {
|
|
75
|
+
if (plugin.resolveHandler) {
|
|
76
|
+
const resolved = plugin.resolveHandler(param, element);
|
|
77
|
+
if (typeof resolved === "function") {
|
|
78
|
+
return exec(resolved, element, state, context);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return param;
|
|
84
|
+
};
|
|
85
|
+
const map = (obj, extention, element) => {
|
|
86
|
+
for (const e in extention) {
|
|
87
|
+
obj[e] = exec(extention[e], element);
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
const merge = (element, obj, excludeFrom = []) => {
|
|
91
|
+
const useSet = excludeFrom instanceof Set;
|
|
92
|
+
for (const e in obj) {
|
|
93
|
+
if (!Object.prototype.hasOwnProperty.call(obj, e)) continue;
|
|
94
|
+
if (_startsWithDunder(e)) continue;
|
|
95
|
+
if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
|
|
96
|
+
if (element[e] === void 0) {
|
|
97
|
+
element[e] = obj[e];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return element;
|
|
101
|
+
};
|
|
102
|
+
const deepMerge = (element, extend, excludeFrom = import_keys.METHODS_EXL) => {
|
|
103
|
+
return _deepMerge(element, extend, excludeFrom, null);
|
|
104
|
+
};
|
|
105
|
+
const _deepMerge = (element, extend, excludeFrom, ancestors) => {
|
|
106
|
+
if (element === extend) return element;
|
|
107
|
+
if (ancestors) {
|
|
108
|
+
for (let i = 0; i < ancestors.length; i += 2) {
|
|
109
|
+
if (ancestors[i] === element && ancestors[i + 1] === extend) return element;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
const useSet = excludeFrom instanceof Set;
|
|
113
|
+
for (const e in extend) {
|
|
114
|
+
if (!Object.prototype.hasOwnProperty.call(extend, e)) continue;
|
|
115
|
+
if (_startsWithDunder(e)) continue;
|
|
116
|
+
if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
|
|
117
|
+
const elementProp = element[e];
|
|
118
|
+
const extendProp = extend[e];
|
|
119
|
+
if ((0, import_types.isObjectLike)(elementProp) && (0, import_types.isObjectLike)(extendProp)) {
|
|
120
|
+
const stack = ancestors || [];
|
|
121
|
+
stack.push(element, extend);
|
|
122
|
+
_deepMerge(elementProp, extendProp, excludeFrom, stack);
|
|
123
|
+
stack.length -= 2;
|
|
124
|
+
} else if (elementProp === void 0) {
|
|
125
|
+
element[e] = extendProp;
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
return element;
|
|
129
|
+
};
|
|
130
|
+
const clone = (obj, excludeFrom = []) => {
|
|
131
|
+
const useSet = excludeFrom instanceof Set;
|
|
132
|
+
const o = {};
|
|
133
|
+
for (const prop in obj) {
|
|
134
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue;
|
|
135
|
+
if (_startsWithDunder(prop)) continue;
|
|
136
|
+
if (useSet ? excludeFrom.has(prop) : excludeFrom.includes(prop)) continue;
|
|
137
|
+
o[prop] = obj[prop];
|
|
138
|
+
}
|
|
139
|
+
return o;
|
|
140
|
+
};
|
|
141
|
+
const deepClone = (obj, options = {}) => {
|
|
142
|
+
const {
|
|
143
|
+
exclude = [],
|
|
144
|
+
cleanUndefined = false,
|
|
145
|
+
cleanNull = false,
|
|
146
|
+
window: targetWindow,
|
|
147
|
+
visited = /* @__PURE__ */ new WeakMap(),
|
|
148
|
+
handleExtends = false
|
|
149
|
+
} = options;
|
|
150
|
+
const contentWindow = targetWindow || import_globals.window || globalThis;
|
|
151
|
+
if (!(0, import_types.isObjectLike)(obj) || (0, import_node.isDOMNode)(obj)) {
|
|
152
|
+
return obj;
|
|
153
|
+
}
|
|
154
|
+
if (visited.has(obj)) {
|
|
155
|
+
return visited.get(obj);
|
|
156
|
+
}
|
|
157
|
+
const isArr = (0, import_types.isArray)(obj);
|
|
158
|
+
const clone2 = isArr ? [] : {};
|
|
159
|
+
visited.set(obj, clone2);
|
|
160
|
+
const excludeSet = exclude instanceof Set ? exclude : exclude.length > 3 ? new Set(exclude) : null;
|
|
161
|
+
for (const key in obj) {
|
|
162
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
163
|
+
if (_startsWithDunder(key) || key === "__proto__") continue;
|
|
164
|
+
if (excludeSet ? excludeSet.has(key) : exclude.includes(key)) continue;
|
|
165
|
+
const value = obj[key];
|
|
166
|
+
if (cleanUndefined && value === void 0) continue;
|
|
167
|
+
if (cleanNull && value === null) continue;
|
|
168
|
+
if ((0, import_node.isDOMNode)(value)) {
|
|
169
|
+
clone2[key] = value;
|
|
170
|
+
continue;
|
|
171
|
+
}
|
|
172
|
+
if (handleExtends && key === "extends" && (0, import_types.isArray)(value)) {
|
|
173
|
+
clone2[key] = (0, import_array.unstackArrayOfObjects)(value, exclude);
|
|
174
|
+
continue;
|
|
175
|
+
}
|
|
176
|
+
if ((0, import_types.isFunction)(value)) {
|
|
177
|
+
clone2[key] = value;
|
|
178
|
+
continue;
|
|
179
|
+
}
|
|
180
|
+
if ((0, import_types.isObjectLike)(value)) {
|
|
181
|
+
clone2[key] = deepClone(value, {
|
|
182
|
+
...options,
|
|
183
|
+
visited
|
|
184
|
+
});
|
|
185
|
+
} else {
|
|
186
|
+
clone2[key] = value;
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
return clone2;
|
|
190
|
+
};
|
|
191
|
+
const deepStringifyFunctions = (obj, stringified = {}) => {
|
|
192
|
+
if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
|
|
193
|
+
;
|
|
194
|
+
(obj.__element || obj.parent?.__element).warn(
|
|
195
|
+
"Trying to clone element or state at",
|
|
196
|
+
obj
|
|
197
|
+
);
|
|
198
|
+
obj = obj.parse?.();
|
|
199
|
+
}
|
|
200
|
+
for (const prop in obj) {
|
|
201
|
+
const objProp = obj[prop];
|
|
202
|
+
if ((0, import_types.isFunction)(objProp)) {
|
|
203
|
+
stringified[prop] = objProp.toString();
|
|
204
|
+
} else if ((0, import_types.isObject)(objProp)) {
|
|
205
|
+
stringified[prop] = {};
|
|
206
|
+
deepStringifyFunctions(objProp, stringified[prop]);
|
|
207
|
+
} else if ((0, import_types.isArray)(objProp)) {
|
|
208
|
+
const arr = stringified[prop] = [];
|
|
209
|
+
for (let i = 0; i < objProp.length; i++) {
|
|
210
|
+
const v = objProp[i];
|
|
211
|
+
if ((0, import_types.isObject)(v)) {
|
|
212
|
+
arr[i] = {};
|
|
213
|
+
deepStringifyFunctions(v, arr[i]);
|
|
214
|
+
} else if ((0, import_types.isFunction)(v)) {
|
|
215
|
+
arr[i] = v.toString();
|
|
216
|
+
} else {
|
|
217
|
+
arr[i] = v;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
} else {
|
|
221
|
+
stringified[prop] = objProp;
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return stringified;
|
|
225
|
+
};
|
|
226
|
+
const OBJ_TO_STR_SPECIAL_CHARS = /* @__PURE__ */ new Set([
|
|
227
|
+
"&",
|
|
228
|
+
"*",
|
|
229
|
+
"-",
|
|
230
|
+
":",
|
|
231
|
+
"%",
|
|
232
|
+
"{",
|
|
233
|
+
"}",
|
|
234
|
+
">",
|
|
235
|
+
"<",
|
|
236
|
+
"@",
|
|
237
|
+
".",
|
|
238
|
+
"/",
|
|
239
|
+
"!",
|
|
240
|
+
" "
|
|
241
|
+
]);
|
|
242
|
+
const objectToString = (obj = {}, indent = 0) => {
|
|
243
|
+
if (obj === null || typeof obj !== "object") {
|
|
244
|
+
return String(obj);
|
|
245
|
+
}
|
|
246
|
+
let hasKeys = false;
|
|
247
|
+
for (const _k in obj) {
|
|
248
|
+
hasKeys = true;
|
|
249
|
+
break;
|
|
250
|
+
}
|
|
251
|
+
if (!hasKeys) return "{}";
|
|
252
|
+
const spaces = " ".repeat(indent);
|
|
253
|
+
let str = "{\n";
|
|
254
|
+
for (const key in obj) {
|
|
255
|
+
if (!Object.prototype.hasOwnProperty.call(obj, key)) continue;
|
|
256
|
+
const value = obj[key];
|
|
257
|
+
let keyNeedsQuotes = false;
|
|
258
|
+
for (let i = 0; i < key.length; i++) {
|
|
259
|
+
if (OBJ_TO_STR_SPECIAL_CHARS.has(key[i])) {
|
|
260
|
+
keyNeedsQuotes = true;
|
|
261
|
+
break;
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
const stringedKey = keyNeedsQuotes ? `'${key}'` : key;
|
|
265
|
+
str += `${spaces} ${stringedKey}: `;
|
|
266
|
+
if ((0, import_types.isArray)(value)) {
|
|
267
|
+
str += "[\n";
|
|
268
|
+
for (const element of value) {
|
|
269
|
+
if ((0, import_types.isObjectLike)(element) && element !== null) {
|
|
270
|
+
str += `${spaces} ${objectToString(element, indent + 2)},
|
|
271
|
+
`;
|
|
272
|
+
} else if ((0, import_types.isString)(element)) {
|
|
273
|
+
str += `${spaces} '${element}',
|
|
274
|
+
`;
|
|
275
|
+
} else {
|
|
276
|
+
str += `${spaces} ${element},
|
|
277
|
+
`;
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
str += `${spaces} ]`;
|
|
281
|
+
} else if ((0, import_types.isObjectLike)(value)) {
|
|
282
|
+
str += objectToString(value, indent + 1);
|
|
283
|
+
} else if ((0, import_types.isString)(value)) {
|
|
284
|
+
str += (0, import_string.stringIncludesAny)(value, ["\n", "'"]) ? `\`${value}\`` : `'${value}'`;
|
|
285
|
+
} else {
|
|
286
|
+
str += value;
|
|
287
|
+
}
|
|
288
|
+
str += ",\n";
|
|
289
|
+
}
|
|
290
|
+
str += `${spaces}}`;
|
|
291
|
+
return str;
|
|
292
|
+
};
|
|
293
|
+
const FN_PATTERNS = [
|
|
294
|
+
/^\(\s*\{[^}]*\}\s*\)\s*=>/,
|
|
295
|
+
/^(\([^)]*\)|[^=]*)\s*=>/,
|
|
296
|
+
/^function[\s(]/,
|
|
297
|
+
/^async\s+/,
|
|
298
|
+
/^\(\s*function/,
|
|
299
|
+
/^[a-zA-Z_$][a-zA-Z0-9_$]*\s*=>/
|
|
300
|
+
];
|
|
301
|
+
const RE_JSON_LIKE = /^["[{]/;
|
|
302
|
+
const hasFunction = (str) => {
|
|
303
|
+
if (!str) return false;
|
|
304
|
+
const trimmed = str.trim().replace(/\n\s*/g, " ").trim();
|
|
305
|
+
if (trimmed === "" || trimmed === "{}" || trimmed === "[]") return false;
|
|
306
|
+
const isFn = FN_PATTERNS.some((pattern) => pattern.test(trimmed));
|
|
307
|
+
if (!isFn) return false;
|
|
308
|
+
const firstChar = trimmed.charCodeAt(0);
|
|
309
|
+
const hasArrow = trimmed.includes("=>");
|
|
310
|
+
if (firstChar === 123 && !hasArrow) return false;
|
|
311
|
+
if (firstChar === 91) return false;
|
|
312
|
+
if (RE_JSON_LIKE.test(trimmed) && !hasArrow) return false;
|
|
313
|
+
return true;
|
|
314
|
+
};
|
|
315
|
+
const __globalEval = (src) => (0, eval)(src);
|
|
316
|
+
const deepDestringifyFunctions = (obj, destringified = {}, opts = { window: { eval: __globalEval } }) => {
|
|
317
|
+
for (const prop in obj) {
|
|
318
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue;
|
|
319
|
+
const objProp = obj[prop];
|
|
320
|
+
if ((0, import_types.isString)(objProp)) {
|
|
321
|
+
if (hasFunction(objProp)) {
|
|
322
|
+
try {
|
|
323
|
+
destringified[prop] = opts.window.eval(`(${objProp})`);
|
|
324
|
+
} catch (e) {
|
|
325
|
+
if (e) destringified[prop] = objProp;
|
|
326
|
+
}
|
|
327
|
+
} else {
|
|
328
|
+
destringified[prop] = objProp;
|
|
329
|
+
}
|
|
330
|
+
} else if ((0, import_types.isArray)(objProp)) {
|
|
331
|
+
const arr = destringified[prop] = [];
|
|
332
|
+
for (let i = 0; i < objProp.length; i++) {
|
|
333
|
+
const arrProp = objProp[i];
|
|
334
|
+
if ((0, import_types.isString)(arrProp)) {
|
|
335
|
+
if (hasFunction(arrProp)) {
|
|
336
|
+
try {
|
|
337
|
+
arr.push(opts.window.eval(`(${arrProp})`));
|
|
338
|
+
} catch (e) {
|
|
339
|
+
if (e) arr.push(arrProp);
|
|
340
|
+
}
|
|
341
|
+
} else {
|
|
342
|
+
arr.push(arrProp);
|
|
343
|
+
}
|
|
344
|
+
} else if ((0, import_types.isObject)(arrProp)) {
|
|
345
|
+
arr.push(deepDestringifyFunctions(arrProp));
|
|
346
|
+
} else {
|
|
347
|
+
arr.push(arrProp);
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
} else if ((0, import_types.isObject)(objProp)) {
|
|
351
|
+
destringified[prop] = deepDestringifyFunctions(
|
|
352
|
+
objProp,
|
|
353
|
+
destringified[prop]
|
|
354
|
+
);
|
|
355
|
+
} else {
|
|
356
|
+
destringified[prop] = objProp;
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
return destringified;
|
|
360
|
+
};
|
|
361
|
+
const destringifyGlobalScope = (gs) => {
|
|
362
|
+
if (!gs || typeof gs !== "object") return gs;
|
|
363
|
+
const result = {};
|
|
364
|
+
const fnEntries = [];
|
|
365
|
+
for (const key of Object.keys(gs)) {
|
|
366
|
+
const val = gs[key];
|
|
367
|
+
if ((0, import_types.isString)(val) && hasFunction(val)) {
|
|
368
|
+
fnEntries.push([key, val]);
|
|
369
|
+
} else {
|
|
370
|
+
result[key] = val;
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
for (const [key, fnStr] of fnEntries) {
|
|
374
|
+
try {
|
|
375
|
+
const varDecls = Object.keys(result).map((k) => `var ${k} = __gs__[${JSON.stringify(k)}];`).join("\n");
|
|
376
|
+
result[key] = import_globals.window.eval(
|
|
377
|
+
`(function(__gs__) { ${varDecls}
|
|
378
|
+
return (${fnStr}); })`
|
|
379
|
+
)(result);
|
|
380
|
+
} catch (e) {
|
|
381
|
+
try {
|
|
382
|
+
result[key] = import_globals.window.eval(`(${fnStr})`);
|
|
383
|
+
} catch (_) {
|
|
384
|
+
result[key] = fnStr;
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
}
|
|
388
|
+
return result;
|
|
389
|
+
};
|
|
390
|
+
const stringToObject = (str, opts = { verbose: true }) => {
|
|
391
|
+
try {
|
|
392
|
+
return str ? import_globals.window.eval("(" + str + ")") : {};
|
|
393
|
+
} catch (e) {
|
|
394
|
+
if (opts.verbose) console.warn(e);
|
|
395
|
+
}
|
|
396
|
+
};
|
|
397
|
+
const hasOwnProperty = (o, ...args) => Object.prototype.hasOwnProperty.call(o, ...args);
|
|
398
|
+
const isEmpty = (o) => {
|
|
399
|
+
for (const _ in o) return false;
|
|
400
|
+
return true;
|
|
401
|
+
};
|
|
402
|
+
const isEmptyObject = (o) => (0, import_types.isObject)(o) && isEmpty(o);
|
|
403
|
+
const makeObjectWithoutPrototype = () => /* @__PURE__ */ Object.create(null);
|
|
404
|
+
const overwrite = (element, params, opts = {}) => {
|
|
405
|
+
const excl = opts.exclude || [];
|
|
406
|
+
const allowDunder = opts.preventUnderscore;
|
|
407
|
+
for (const e in params) {
|
|
408
|
+
if (excl.includes(e) || !allowDunder && _startsWithDunder(e)) continue;
|
|
409
|
+
if (params[e] !== void 0) {
|
|
410
|
+
element[e] = params[e];
|
|
411
|
+
}
|
|
412
|
+
}
|
|
413
|
+
return element;
|
|
414
|
+
};
|
|
415
|
+
const overwriteShallow = (obj, params, excludeFrom = []) => {
|
|
416
|
+
const useSet = excludeFrom instanceof Set;
|
|
417
|
+
for (const e in params) {
|
|
418
|
+
if (_startsWithDunder(e)) continue;
|
|
419
|
+
if (useSet ? excludeFrom.has(e) : excludeFrom.includes(e)) continue;
|
|
420
|
+
obj[e] = params[e];
|
|
421
|
+
}
|
|
422
|
+
return obj;
|
|
423
|
+
};
|
|
424
|
+
const overwriteDeep = (obj, params, opts = {}, visited = /* @__PURE__ */ new WeakMap()) => {
|
|
425
|
+
if (!(0, import_types.isObjectLike)(obj) || !(0, import_types.isObjectLike)(params) || (0, import_node.isDOMNode)(obj) || (0, import_node.isDOMNode)(params)) {
|
|
426
|
+
return params;
|
|
427
|
+
}
|
|
428
|
+
if (visited.has(obj)) return visited.get(obj);
|
|
429
|
+
visited.set(obj, obj);
|
|
430
|
+
const excl = opts.exclude;
|
|
431
|
+
const exclSet = excl ? excl instanceof Set ? excl : new Set(excl) : null;
|
|
432
|
+
const forcedExclude = !opts.preventForce;
|
|
433
|
+
for (const e in params) {
|
|
434
|
+
if (!Object.prototype.hasOwnProperty.call(params, e)) continue;
|
|
435
|
+
if (exclSet && exclSet.has(e) || forcedExclude && _startsWithDunder(e))
|
|
436
|
+
continue;
|
|
437
|
+
const objProp = obj[e];
|
|
438
|
+
const paramsProp = params[e];
|
|
439
|
+
if ((0, import_node.isDOMNode)(paramsProp)) {
|
|
440
|
+
obj[e] = paramsProp;
|
|
441
|
+
} else if ((0, import_types.isObjectLike)(objProp) && (0, import_types.isObjectLike)(paramsProp)) {
|
|
442
|
+
obj[e] = overwriteDeep(objProp, paramsProp, opts, visited);
|
|
443
|
+
} else if (paramsProp !== void 0) {
|
|
444
|
+
obj[e] = paramsProp;
|
|
445
|
+
}
|
|
446
|
+
}
|
|
447
|
+
return obj;
|
|
448
|
+
};
|
|
449
|
+
const isEqualDeep = (param, element, visited = /* @__PURE__ */ new Set()) => {
|
|
450
|
+
if (typeof param !== "object" || typeof element !== "object" || param === null || element === null) {
|
|
451
|
+
return param === element;
|
|
452
|
+
}
|
|
453
|
+
if (visited.has(param) || visited.has(element)) {
|
|
454
|
+
return true;
|
|
455
|
+
}
|
|
456
|
+
visited.add(param);
|
|
457
|
+
visited.add(element);
|
|
458
|
+
const keysParam = Object.keys(param);
|
|
459
|
+
const keysElement = Object.keys(element);
|
|
460
|
+
if (keysParam.length !== keysElement.length) {
|
|
461
|
+
return false;
|
|
462
|
+
}
|
|
463
|
+
for (let i = 0; i < keysParam.length; i++) {
|
|
464
|
+
const key = keysParam[i];
|
|
465
|
+
if (!Object.prototype.hasOwnProperty.call(element, key)) {
|
|
466
|
+
return false;
|
|
467
|
+
}
|
|
468
|
+
if (!isEqualDeep(param[key], element[key], visited)) {
|
|
469
|
+
return false;
|
|
470
|
+
}
|
|
471
|
+
}
|
|
472
|
+
return true;
|
|
473
|
+
};
|
|
474
|
+
const DEEP_CONTAINS_IGNORED = /* @__PURE__ */ new Set(["node", "__ref"]);
|
|
475
|
+
const deepContains = (obj1, obj2, ignoredKeys = DEEP_CONTAINS_IGNORED) => {
|
|
476
|
+
if (obj1 === obj2) return true;
|
|
477
|
+
if (!(0, import_types.isObjectLike)(obj1) || !(0, import_types.isObjectLike)(obj2)) return obj1 === obj2;
|
|
478
|
+
if ((0, import_node.isDOMNode)(obj1) || (0, import_node.isDOMNode)(obj2)) return obj1 === obj2;
|
|
479
|
+
const ignored = ignoredKeys instanceof Set ? ignoredKeys : new Set(ignoredKeys);
|
|
480
|
+
const visited = /* @__PURE__ */ new WeakSet();
|
|
481
|
+
function checkContains(target, source) {
|
|
482
|
+
if (visited.has(source)) return true;
|
|
483
|
+
visited.add(source);
|
|
484
|
+
for (const key in source) {
|
|
485
|
+
if (!Object.prototype.hasOwnProperty.call(source, key)) continue;
|
|
486
|
+
if (ignored.has(key)) continue;
|
|
487
|
+
if (!Object.prototype.hasOwnProperty.call(target, key)) return false;
|
|
488
|
+
const sourceValue = source[key];
|
|
489
|
+
const targetValue = target[key];
|
|
490
|
+
if ((0, import_node.isDOMNode)(sourceValue) || (0, import_node.isDOMNode)(targetValue)) {
|
|
491
|
+
if (sourceValue !== targetValue) return false;
|
|
492
|
+
} else if ((0, import_types.isObjectLike)(sourceValue) && (0, import_types.isObjectLike)(targetValue)) {
|
|
493
|
+
if (!checkContains(targetValue, sourceValue)) return false;
|
|
494
|
+
} else if (sourceValue !== targetValue) {
|
|
495
|
+
return false;
|
|
496
|
+
}
|
|
497
|
+
}
|
|
498
|
+
return true;
|
|
499
|
+
}
|
|
500
|
+
return checkContains(obj1, obj2);
|
|
501
|
+
};
|
|
502
|
+
const removeFromObject = (obj, props) => {
|
|
503
|
+
if (props === void 0 || props === null) return obj;
|
|
504
|
+
if ((0, import_types.is)(props)("string", "number")) {
|
|
505
|
+
delete obj[props];
|
|
506
|
+
} else if ((0, import_types.isArray)(props)) {
|
|
507
|
+
for (let i = 0; i < props.length; i++) delete obj[props[i]];
|
|
508
|
+
} else {
|
|
509
|
+
throw new Error(
|
|
510
|
+
"Invalid input: props must be a string or an array of strings"
|
|
511
|
+
);
|
|
512
|
+
}
|
|
513
|
+
return obj;
|
|
514
|
+
};
|
|
515
|
+
const createObjectWithoutPrototype = (obj) => {
|
|
516
|
+
if (obj === null || typeof obj !== "object") {
|
|
517
|
+
return obj;
|
|
518
|
+
}
|
|
519
|
+
const newObj = /* @__PURE__ */ Object.create(null);
|
|
520
|
+
for (const key in obj) {
|
|
521
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
522
|
+
newObj[key] = createObjectWithoutPrototype(obj[key]);
|
|
523
|
+
}
|
|
524
|
+
}
|
|
525
|
+
return newObj;
|
|
526
|
+
};
|
|
527
|
+
const createNestedObject = (arr, lastValue) => {
|
|
528
|
+
if (arr.length === 0) return lastValue;
|
|
529
|
+
const nestedObject = {};
|
|
530
|
+
let current = nestedObject;
|
|
531
|
+
for (let i = 0; i < arr.length; i++) {
|
|
532
|
+
if (i === arr.length - 1 && lastValue) {
|
|
533
|
+
current[arr[i]] = lastValue;
|
|
534
|
+
} else {
|
|
535
|
+
current[arr[i]] = {};
|
|
536
|
+
current = current[arr[i]];
|
|
537
|
+
}
|
|
538
|
+
}
|
|
539
|
+
return nestedObject;
|
|
540
|
+
};
|
|
541
|
+
const removeNestedKeyByPath = (obj, path) => {
|
|
542
|
+
if (!Array.isArray(path)) {
|
|
543
|
+
throw new Error("Path must be an array.");
|
|
544
|
+
}
|
|
545
|
+
let current = obj;
|
|
546
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
547
|
+
if (current[path[i]] === void 0) return;
|
|
548
|
+
current = current[path[i]];
|
|
549
|
+
}
|
|
550
|
+
const lastKey = path[path.length - 1];
|
|
551
|
+
if (current && Object.prototype.hasOwnProperty.call(current, lastKey)) {
|
|
552
|
+
delete current[lastKey];
|
|
553
|
+
}
|
|
554
|
+
};
|
|
555
|
+
const setInObjectByPath = (obj, path, value) => {
|
|
556
|
+
if (!Array.isArray(path)) {
|
|
557
|
+
throw new Error("Path must be an array.");
|
|
558
|
+
}
|
|
559
|
+
let current = obj;
|
|
560
|
+
for (let i = 0; i < path.length - 1; i++) {
|
|
561
|
+
if (!current[path[i]] || typeof current[path[i]] !== "object") {
|
|
562
|
+
current[path[i]] = {};
|
|
563
|
+
}
|
|
564
|
+
current = current[path[i]];
|
|
565
|
+
}
|
|
566
|
+
current[path[path.length - 1]] = value;
|
|
567
|
+
return obj;
|
|
568
|
+
};
|
|
569
|
+
const getInObjectByPath = (obj, path) => {
|
|
570
|
+
if (!Array.isArray(path)) {
|
|
571
|
+
throw new Error("Path must be an array.");
|
|
572
|
+
}
|
|
573
|
+
let current = obj;
|
|
574
|
+
for (let i = 0; i < path.length; i++) {
|
|
575
|
+
if (current === void 0 || current === null) {
|
|
576
|
+
return void 0;
|
|
577
|
+
}
|
|
578
|
+
current = current[path[i]];
|
|
579
|
+
}
|
|
580
|
+
return current;
|
|
581
|
+
};
|
|
582
|
+
const detectInfiniteLoop = (arr) => {
|
|
583
|
+
const maxRepeats = 10;
|
|
584
|
+
let pattern = [];
|
|
585
|
+
let repeatCount = 0;
|
|
586
|
+
for (let i = 0; i < arr.length; i++) {
|
|
587
|
+
if (pattern.length < 2) {
|
|
588
|
+
pattern.push(arr[i]);
|
|
589
|
+
} else {
|
|
590
|
+
if (arr[i] === pattern[i % 2]) {
|
|
591
|
+
repeatCount++;
|
|
592
|
+
} else {
|
|
593
|
+
pattern = [arr[i - 1], arr[i]];
|
|
594
|
+
repeatCount = 1;
|
|
595
|
+
}
|
|
596
|
+
if (repeatCount >= maxRepeats * 2) {
|
|
597
|
+
if (ENV === "test" || ENV === "development") {
|
|
598
|
+
console.warn(
|
|
599
|
+
"Warning: Potential infinite loop detected due to repeated sequence:",
|
|
600
|
+
pattern
|
|
601
|
+
);
|
|
602
|
+
}
|
|
603
|
+
return true;
|
|
604
|
+
}
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
};
|
|
608
|
+
const isCyclic = (obj) => {
|
|
609
|
+
const seen = /* @__PURE__ */ new WeakSet();
|
|
610
|
+
function detect(obj2) {
|
|
611
|
+
if (obj2 && typeof obj2 === "object") {
|
|
612
|
+
if (seen.has(obj2)) return true;
|
|
613
|
+
seen.add(obj2);
|
|
614
|
+
for (const key in obj2) {
|
|
615
|
+
if (Object.prototype.hasOwnProperty.call(obj2, key) && detect(obj2[key])) {
|
|
616
|
+
console.log(obj2, "cycle at " + key);
|
|
617
|
+
return true;
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
return false;
|
|
622
|
+
}
|
|
623
|
+
return detect(obj);
|
|
624
|
+
};
|
|
625
|
+
const excludeKeysFromObject = (obj, excludedKeys) => {
|
|
626
|
+
const excluded = excludedKeys instanceof Set ? excludedKeys : new Set(excludedKeys);
|
|
627
|
+
const result = {};
|
|
628
|
+
for (const key in obj) {
|
|
629
|
+
if (Object.prototype.hasOwnProperty.call(obj, key) && !excluded.has(key)) {
|
|
630
|
+
result[key] = obj[key];
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
return result;
|
|
634
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var projectKeys_exports = {};
|
|
19
|
+
__export(projectKeys_exports, {
|
|
20
|
+
UNIVERSAL_RESERVED_KEYS: () => UNIVERSAL_RESERVED_KEYS,
|
|
21
|
+
isUniversallyReservedKey: () => isUniversallyReservedKey
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(projectKeys_exports);
|
|
24
|
+
const UNIVERSAL_RESERVED_KEYS = /* @__PURE__ */ new Set([
|
|
25
|
+
"__proto__",
|
|
26
|
+
"constructor",
|
|
27
|
+
"prototype",
|
|
28
|
+
"_id",
|
|
29
|
+
"__v",
|
|
30
|
+
"id",
|
|
31
|
+
"createdAt",
|
|
32
|
+
"updatedAt",
|
|
33
|
+
"schema"
|
|
34
|
+
]);
|
|
35
|
+
const isUniversallyReservedKey = (key) => typeof key === "string" && UNIVERSAL_RESERVED_KEYS.has(key);
|