@luna-park/plugin 1.8.0 → 2.0.1

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.
@@ -0,0 +1,85 @@
1
+ // ../utils/dist/index.mjs
2
+ const NPM_CDN_ORIGIN = "https://esm.sh";
3
+ function getNpmCdnUrl(target, externals = []) {
4
+ const url = `${NPM_CDN_ORIGIN}/${target}`;
5
+ return externals.length ? `${url}?external=${externals.join(",")}` : url;
6
+ }
7
+ function cloneDeep(object) {
8
+ if (typeof object !== "object") return object;
9
+ const strategies = [
10
+ () => JSON.parse(JSON.stringify(object)),
11
+ () => structuredClone(object),
12
+ () => safeClone(object)
13
+ ];
14
+ let lastError;
15
+ for (const strategy of strategies) try {
16
+ return strategy();
17
+ } catch (error) {
18
+ lastError = error;
19
+ continue;
20
+ }
21
+ console.error("Failed to deep clone object:", object);
22
+ throw new Error(String(lastError));
23
+ }
24
+ function safeClone(object) {
25
+ const seen = /* @__PURE__ */ new WeakSet();
26
+ return recursiveClone(object);
27
+ function recursiveClone(object) {
28
+ if (typeof object !== "object" || object === null) return object;
29
+ if (seen.has(object)) return { recursive: true };
30
+ seen.add(object);
31
+ if (Array.isArray(object)) return object.map((element) => recursiveClone(element));
32
+ const clone = {};
33
+ for (const [key, descriptor] of Object.entries(Object.getOwnPropertyDescriptors(object))) clone[key] = recursiveClone(descriptor.value);
34
+ return clone;
35
+ }
36
+ }
37
+ function cloneWithFunctions(object) {
38
+ if (Array.isArray(object)) return object.map(cloneWithFunctions);
39
+ if (typeof object !== "object" || object === null) return object;
40
+ const clone = {};
41
+ for (const [key, value] of Object.entries(object)) clone[key] = typeof value === "function" ? value : cloneWithFunctions(value);
42
+ return clone;
43
+ }
44
+ function assertType(_arg) {}
45
+ function objectMap(source, func) {
46
+ if (!source) return {};
47
+ return Object.fromEntries(Object.entries(source).map(([key, value]) => [key, func({
48
+ key,
49
+ value
50
+ })]));
51
+ }
52
+ function objectFilter(source, func) {
53
+ if (!source) return {};
54
+ return Object.fromEntries(Object.entries(source).filter(([key, value]) => func({
55
+ key,
56
+ value
57
+ })));
58
+ }
59
+ function objectFullMap(source, func) {
60
+ if (!source) return {};
61
+ return Object.fromEntries(Object.entries(source).map(([key, value]) => {
62
+ const result = func({
63
+ key,
64
+ value
65
+ });
66
+ return [result.key, result.value];
67
+ }));
68
+ }
69
+ function cleanObject(target) {
70
+ const record = cloneDeep(target);
71
+ for (const key in record) cleanDeep(record, key);
72
+ function cleanDeep(value, key) {
73
+ const child = value[key];
74
+ if (child && typeof child === "object") {
75
+ for (const childKey in child) cleanDeep(child, childKey);
76
+ if (Object.keys(child).length === 0) delete value[key];
77
+ }
78
+ }
79
+ return record;
80
+ }
81
+ function isRawObject(target) {
82
+ if (target !== null && typeof target === "object") return Object.getPrototypeOf(target) === Object.prototype;
83
+ return false;
84
+ }
85
+ export { getNpmCdnUrl as a, objectFullMap as c, cloneWithFunctions as i, objectMap as l, cleanObject as n, isRawObject as o, cloneDeep as r, objectFilter as s, assertType as t };