melonykit 1.20.0 → 1.22.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/dist/browser-bawCTM88.js +115 -0
- package/dist/browser.js +1 -1
- package/dist/{functions-mQlYMSp2.js → functions-DErEdMjE.js} +29 -6
- package/dist/functions.js +1 -1
- package/dist/index.js +17 -25
- package/package.json +3 -3
- package/dist/browser-A1IeCWNV.js +0 -119
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
import { a as e, o as t } from "./functions-DErEdMjE.js";
|
|
2
|
+
import { signal as n } from "@preact/signals";
|
|
3
|
+
import { useEffect as r, useMemo as i } from "preact/hooks";
|
|
4
|
+
// src/browser/_route-to.js
|
|
5
|
+
function a(e, t = !1) {
|
|
6
|
+
t ? history.replaceState(null, "", e) : history.pushState(null, "", e), dispatchEvent(new PopStateEvent("popstate"));
|
|
7
|
+
}
|
|
8
|
+
// src/browser/_use-query.js
|
|
9
|
+
var o = /* @__PURE__ */ new Map(), s = null;
|
|
10
|
+
function c({ endpoint: e, refetchEvent: r } = {}) {
|
|
11
|
+
let a = i(() => {
|
|
12
|
+
let r = n(null), i = n(!1), a = n(null);
|
|
13
|
+
async function o() {
|
|
14
|
+
i.value = !0, a.value = null;
|
|
15
|
+
try {
|
|
16
|
+
let n = await t({
|
|
17
|
+
url: e,
|
|
18
|
+
method: "GET"
|
|
19
|
+
});
|
|
20
|
+
if (!n.success) throw Error("Could not query data.");
|
|
21
|
+
r.value = n.data;
|
|
22
|
+
} catch (e) {
|
|
23
|
+
console.log(e), a.value = e;
|
|
24
|
+
} finally {
|
|
25
|
+
i.value = !1;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
data: r,
|
|
30
|
+
loading: i,
|
|
31
|
+
error: a,
|
|
32
|
+
refetch: o
|
|
33
|
+
};
|
|
34
|
+
}, [e]);
|
|
35
|
+
return u(a, r), a;
|
|
36
|
+
}
|
|
37
|
+
function l({ query: t, variables: r, refetchEvent: a } = {}) {
|
|
38
|
+
let o = JSON.stringify(r ?? null), s = i(() => {
|
|
39
|
+
let r = n(null), i = n(!1), a = n(null);
|
|
40
|
+
async function s() {
|
|
41
|
+
i.value = !0, a.value = null;
|
|
42
|
+
try {
|
|
43
|
+
let n = await e({
|
|
44
|
+
query: t,
|
|
45
|
+
variables: JSON.parse(o)
|
|
46
|
+
});
|
|
47
|
+
if (!n.success) throw Error(n.errors?.[0]?.message ?? "Could not query data.");
|
|
48
|
+
r.value = n.data ?? null;
|
|
49
|
+
} catch (e) {
|
|
50
|
+
console.log(e), a.value = e;
|
|
51
|
+
} finally {
|
|
52
|
+
i.value = !1;
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
return {
|
|
56
|
+
data: r,
|
|
57
|
+
loading: i,
|
|
58
|
+
error: a,
|
|
59
|
+
refetch: s
|
|
60
|
+
};
|
|
61
|
+
}, [t, o]);
|
|
62
|
+
return u(s, a), s;
|
|
63
|
+
}
|
|
64
|
+
function u(e, t) {
|
|
65
|
+
r(() => {
|
|
66
|
+
let n = t ? f(t, e.refetch) : () => {};
|
|
67
|
+
return e.refetch(), n;
|
|
68
|
+
}, [e, t]);
|
|
69
|
+
}
|
|
70
|
+
function d() {
|
|
71
|
+
return s ??= new EventSource("/api/client-events"), s;
|
|
72
|
+
}
|
|
73
|
+
function f(e, t) {
|
|
74
|
+
let n = d();
|
|
75
|
+
if (!o.has(e)) {
|
|
76
|
+
let t = /* @__PURE__ */ new Set(), r = (e) => {
|
|
77
|
+
let n = e.data ? JSON.parse(e.data) : null;
|
|
78
|
+
for (let e of t) e(n);
|
|
79
|
+
};
|
|
80
|
+
o.set(e, {
|
|
81
|
+
callbacks: t,
|
|
82
|
+
handler: r
|
|
83
|
+
}), n.addEventListener(e, r);
|
|
84
|
+
}
|
|
85
|
+
let r = o.get(e);
|
|
86
|
+
return r.callbacks.add(t), () => {
|
|
87
|
+
r.callbacks.delete(t), r.callbacks.size > 0 || (n.removeEventListener(e, r.handler), o.delete(e));
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
// src/browser/_get-client-setting.js
|
|
91
|
+
function p(e, t = null) {
|
|
92
|
+
if (typeof window > "u" || !e) return t;
|
|
93
|
+
try {
|
|
94
|
+
let n = window.localStorage.getItem(m(e));
|
|
95
|
+
return n === null ? t : JSON.parse(n);
|
|
96
|
+
} catch {
|
|
97
|
+
return t;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
function m(e) {
|
|
101
|
+
return `melonykit:${e}`;
|
|
102
|
+
}
|
|
103
|
+
// src/browser/_set-client-setting.js
|
|
104
|
+
function h(e, t) {
|
|
105
|
+
if (typeof window > "u" || !e) return !1;
|
|
106
|
+
try {
|
|
107
|
+
return window.localStorage.setItem(g(e), JSON.stringify(t)), !0;
|
|
108
|
+
} catch {
|
|
109
|
+
return !1;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function g(e) {
|
|
113
|
+
return `melonykit:${e}`;
|
|
114
|
+
}
|
|
115
|
+
export { a, c as i, p as n, l as r, h as t };
|
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as getClientSetting, a as routeTo, t as setClientSetting, r as useGraphqlQuery, i as useQuery } from "./browser-
|
|
1
|
+
export { n as getClientSetting, a as routeTo, t as setClientSetting, r as useGraphqlQuery, i as useQuery } from "./browser-bawCTM88.js";
|
|
@@ -284,8 +284,14 @@ function j(e) {
|
|
|
284
284
|
let t = [...e].sort((e, t) => e - t), n = Math.floor(t.length / 2);
|
|
285
285
|
return t.length % 2 == 0 ? (t[n - 1] + t[n]) / 2 : t[n];
|
|
286
286
|
}
|
|
287
|
+
// src/functions/_parse-boolean.js
|
|
288
|
+
function M(e) {
|
|
289
|
+
if (!t(e)) return e;
|
|
290
|
+
let n = e.trim().toLowerCase();
|
|
291
|
+
return n === "true" || n !== "false" && e;
|
|
292
|
+
}
|
|
287
293
|
// src/functions/_request.js
|
|
288
|
-
async function
|
|
294
|
+
async function N({ url: e, body: t, method: n = "POST", headers: r = {} } = {}) {
|
|
289
295
|
let i = n !== "GET" && t !== void 0 ? JSON.stringify(t) : void 0, a = await fetch(e, {
|
|
290
296
|
method: n,
|
|
291
297
|
headers: {
|
|
@@ -304,27 +310,44 @@ async function M({ url: e, body: t, method: n = "POST", headers: r = {} } = {})
|
|
|
304
310
|
}
|
|
305
311
|
return a.ok || (s.error = s.data ?? /* @__PURE__ */ Error(`Request failed with status ${a.status}.`)), s;
|
|
306
312
|
}
|
|
313
|
+
// src/functions/_request-graphql.js
|
|
314
|
+
async function P({ query: e, variables: t } = {}) {
|
|
315
|
+
let n = await N({
|
|
316
|
+
url: "/api/graphql",
|
|
317
|
+
method: "POST",
|
|
318
|
+
body: {
|
|
319
|
+
query: e,
|
|
320
|
+
variables: t
|
|
321
|
+
}
|
|
322
|
+
}), { data: r, errors: i } = n.data ?? {};
|
|
323
|
+
return {
|
|
324
|
+
...n,
|
|
325
|
+
success: n.success && !i?.length,
|
|
326
|
+
data: r,
|
|
327
|
+
errors: i
|
|
328
|
+
};
|
|
329
|
+
}
|
|
307
330
|
// src/functions/_risk-reward.js
|
|
308
|
-
function
|
|
331
|
+
function F(e = {}) {
|
|
309
332
|
let { entry: t, exit: n, riskRatio: r = 20 } = e ?? {};
|
|
310
333
|
if (!c(t) || t <= 0 || !c(n) || n <= 0 || !c(r) || r <= 0) return null;
|
|
311
334
|
let i = (n - t) / t / (r / 100);
|
|
312
335
|
return Math.round(i * 10) / 10;
|
|
313
336
|
}
|
|
314
337
|
// src/functions/_size.js
|
|
315
|
-
function
|
|
338
|
+
function I(e) {
|
|
316
339
|
return e == null ? 0 : Array.isArray(e) || typeof e == "string" ? e.length : typeof e == "object" || typeof e == "function" ? Object.keys(e).length : 0;
|
|
317
340
|
}
|
|
318
341
|
// src/functions/_slugify.js
|
|
319
|
-
function
|
|
342
|
+
function L(e) {
|
|
320
343
|
return typeof e == "string" ? e.trim().toLowerCase().replace(/ä/g, "ae").replace(/ö/g, "oe").replace(/ü/g, "ue").replace(/ß/g, "ss").replace(/æ/g, "ae").replace(/œ/g, "oe").replace(/ø/g, "o").normalize("NFD").replace(/\p{Diacritic}/gu, "").replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "") : "";
|
|
321
344
|
}
|
|
322
345
|
// src/functions/_to-number.js
|
|
323
|
-
function
|
|
346
|
+
function R(e, t = null) {
|
|
324
347
|
let n = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
|
|
325
348
|
if (!Number.isFinite(n)) return null;
|
|
326
349
|
if (t == null) return n;
|
|
327
350
|
let r = 10 ** t;
|
|
328
351
|
return Math.round(n * r) / r;
|
|
329
352
|
}
|
|
330
|
-
export {
|
|
353
|
+
export { o as C, t as D, n as E, e as O, s as S, i as T, S as _, P as a, l as b, j as c, O as d, D as f, C as g, w as h, F as i, A as l, T as m, L as n, N as o, E as p, I as r, M as s, R as t, k as u, _ as v, a as w, c as x, u as y };
|
package/dist/functions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export {
|
|
1
|
+
export { O as average, E as camelCaseToTitleCase, T as convertHexToRgba, b as createCache, y as darkenHexColor, v as formatDate, w as isArray, _ as isBoolean, C as isEmptyArray, m as isEmptyObject, p as isEmptyString, f as isFloat, S as isFunction, d as isInteger, g as isNil, x as isNumber, h as isObject, D as isString, u as kebabCaseToCamelCase, l as kebabCaseToTitleCase, c as median, s as parseBoolean, o as request, a as requestGraphql, i as riskReward, r as size, n as slugify, t as toNumber } from "./functions-DErEdMjE.js";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { useSignal as e } from "@preact/signals";
|
|
2
2
|
import { Fragment as t, jsx as n, jsxs as r } from "preact/jsx-runtime";
|
|
3
|
-
import {
|
|
3
|
+
import { D as i, n as a, p as o, y as s } from "./functions-DErEdMjE.js";
|
|
4
4
|
import { useEffect as c, useId as l, useRef as u } from "preact/hooks";
|
|
5
|
-
import { n as d, t as f } from "./browser-
|
|
5
|
+
import { n as d, t as f } from "./browser-bawCTM88.js";
|
|
6
6
|
// node_modules/@emotion/sheet/dist/emotion-sheet.esm.js
|
|
7
7
|
function p(e) {
|
|
8
8
|
if (e.sheet) return e.sheet;
|
|
@@ -2016,21 +2016,18 @@ var Tr = xt`
|
|
|
2016
2016
|
height: 2.3rem;
|
|
2017
2017
|
padding: 0 .8rem;
|
|
2018
2018
|
overflow: hidden;
|
|
2019
|
-
border: solid
|
|
2019
|
+
border-bottom: solid 2px transparent;
|
|
2020
2020
|
font-weight: 600;
|
|
2021
2021
|
letter-spacing: 1px;
|
|
2022
2022
|
white-space: nowrap;
|
|
2023
|
-
border-radius:
|
|
2024
|
-
will-change: transform
|
|
2025
|
-
transition: transform .15s ease
|
|
2023
|
+
border-radius: 8px;
|
|
2024
|
+
will-change: transform;
|
|
2025
|
+
transition: transform .15s ease;
|
|
2026
|
+
color: ${A.colors.deepOcean};
|
|
2026
2027
|
font-family: ${A.textFontFamily}, sans-serif;
|
|
2027
2028
|
|
|
2028
|
-
&[is-clickable]:active {
|
|
2029
|
-
transform: translateY(1px);
|
|
2030
|
-
}
|
|
2031
|
-
|
|
2029
|
+
&[is-clickable]:active { transform: translateY(1px); }
|
|
2032
2030
|
&[has-icon] { padding-left: 2rem; }
|
|
2033
|
-
|
|
2034
2031
|
&[is-icon-only] {
|
|
2035
2032
|
width: 2.3rem;
|
|
2036
2033
|
padding: 0;
|
|
@@ -2038,7 +2035,6 @@ var Tr = xt`
|
|
|
2038
2035
|
`,
|
|
2039
2036
|
icon: k`
|
|
2040
2037
|
${A.extends.verticalCenter}
|
|
2041
|
-
|
|
2042
2038
|
display: grid;
|
|
2043
2039
|
width: 1rem;
|
|
2044
2040
|
height: 1rem;
|
|
@@ -2046,18 +2042,14 @@ var Tr = xt`
|
|
|
2046
2042
|
left: .6rem;
|
|
2047
2043
|
`,
|
|
2048
2044
|
primary: k`
|
|
2049
|
-
color: ${A.colors.deepOcean};
|
|
2050
2045
|
border-color: #2baac2;
|
|
2051
2046
|
background-color: ${A.colors.lightBreeze};
|
|
2052
|
-
box-shadow: 0 2px 5px rgb(43 170 194 / 18%);
|
|
2053
2047
|
`,
|
|
2054
2048
|
secondary: k`
|
|
2055
|
-
color: ${A.colors.
|
|
2056
|
-
border-color: ${a(A.colors.tangerineSnack, .2)};
|
|
2049
|
+
border-color: ${s(A.colors.tangerineSnack, .3)};
|
|
2057
2050
|
background-color: ${A.colors.tangerineSnack};
|
|
2058
2051
|
`,
|
|
2059
2052
|
neutral: k`
|
|
2060
|
-
color: ${A.colors.deepOcean};
|
|
2061
2053
|
border-color: ${A.systemColors.border};
|
|
2062
2054
|
background-color: ${A.colors.softPottery};
|
|
2063
2055
|
`,
|
|
@@ -2321,7 +2313,7 @@ function Fr(e, t) {
|
|
|
2321
2313
|
return d(Ir(e), t);
|
|
2322
2314
|
}
|
|
2323
2315
|
function Ir(e) {
|
|
2324
|
-
let t =
|
|
2316
|
+
let t = a(e);
|
|
2325
2317
|
return t ? `accordions:${t}:is-open` : "";
|
|
2326
2318
|
}
|
|
2327
2319
|
var Lr = {
|
|
@@ -2553,15 +2545,15 @@ var Hr = {
|
|
|
2553
2545
|
transition: width .3s ease;
|
|
2554
2546
|
`,
|
|
2555
2547
|
normal: k`
|
|
2556
|
-
border: solid 1px ${
|
|
2548
|
+
border: solid 1px ${s(A.colors.lightBreeze, .3)};
|
|
2557
2549
|
background-color: ${A.colors.lightBreeze};
|
|
2558
2550
|
`,
|
|
2559
2551
|
warn: k`
|
|
2560
|
-
border: solid 1px ${
|
|
2552
|
+
border: solid 1px ${s(A.colors.tangerineSnack, .2)};
|
|
2561
2553
|
background-color: ${A.colors.tangerineSnack};
|
|
2562
2554
|
`,
|
|
2563
2555
|
danger: k`
|
|
2564
|
-
border: solid 1px ${
|
|
2556
|
+
border: solid 1px ${s(A.colors.coralBlush, .3)};
|
|
2565
2557
|
background-color: ${A.colors.coralBlush};
|
|
2566
2558
|
`
|
|
2567
2559
|
};
|
|
@@ -2947,7 +2939,7 @@ var ri = {
|
|
|
2947
2939
|
height: 1rem;
|
|
2948
2940
|
margin-top: -.375rem;
|
|
2949
2941
|
border-radius: 50%;
|
|
2950
|
-
border: solid 1px ${
|
|
2942
|
+
border: solid 1px ${s(A.colors.lightBreeze, .3)};
|
|
2951
2943
|
background-color: ${A.colors.lightBreeze};
|
|
2952
2944
|
transition: transform .15s ease;
|
|
2953
2945
|
}
|
|
@@ -3157,7 +3149,7 @@ var si = xt`
|
|
|
3157
3149
|
--checked-background-color: ${A.colors.lightBreeze};
|
|
3158
3150
|
`,
|
|
3159
3151
|
secondary: k`
|
|
3160
|
-
--checked-border-color: ${
|
|
3152
|
+
--checked-border-color: ${s(A.colors.tangerineSnack, .2)};
|
|
3161
3153
|
--checked-background-color: ${A.colors.tangerineSnack};
|
|
3162
3154
|
`,
|
|
3163
3155
|
input: k`
|
|
@@ -3265,7 +3257,7 @@ var mi = {
|
|
|
3265
3257
|
background-color: ${A.colors.softPottery};
|
|
3266
3258
|
|
|
3267
3259
|
&:before {
|
|
3268
|
-
border-color: ${
|
|
3260
|
+
border-color: ${s(A.colors.lightBreeze, .3)};
|
|
3269
3261
|
background-color: ${A.colors.lightBreeze};
|
|
3270
3262
|
transform: translate(${fi}px, -50%);
|
|
3271
3263
|
}
|
|
@@ -3363,7 +3355,7 @@ function _i({ title: i, actionBar: a, initialOpen: o = !0, children: s }) {
|
|
|
3363
3355
|
}) });
|
|
3364
3356
|
}
|
|
3365
3357
|
function vi(e) {
|
|
3366
|
-
let t =
|
|
3358
|
+
let t = a(e);
|
|
3367
3359
|
return t ? `tag-boxes:${t}:is-open` : "";
|
|
3368
3360
|
}
|
|
3369
3361
|
var yi = {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"author": "Vadim Hermann",
|
|
3
3
|
"name": "melonykit",
|
|
4
|
-
"version": "1.
|
|
4
|
+
"version": "1.22.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"description": "Preact based ui and utility functions toolkit",
|
|
7
7
|
"main": "./dist/index.js",
|
|
@@ -38,12 +38,12 @@
|
|
|
38
38
|
"@codemirror/view": "6.44.2",
|
|
39
39
|
"@emotion/css": "11.13.5",
|
|
40
40
|
"dompurify": "3.5.0",
|
|
41
|
-
"glob": "
|
|
41
|
+
"glob": "15.0.0",
|
|
42
42
|
"graphql": "17.0.2"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
45
|
"@pivanov/vite-plugin-svg-sprite": "3.1.8",
|
|
46
|
-
"@playwright/test": "1.65.
|
|
46
|
+
"@playwright/test": "1.65.2",
|
|
47
47
|
"@preact/preset-vite": "2.10.6",
|
|
48
48
|
"@preact/signals": "2.11.4",
|
|
49
49
|
"@types/node": "26.6.11",
|
package/dist/browser-A1IeCWNV.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { a as e } from "./functions-mQlYMSp2.js";
|
|
2
|
-
import { signal as t } from "@preact/signals";
|
|
3
|
-
import { useEffect as n, useMemo as r } from "preact/hooks";
|
|
4
|
-
// src/browser/_route-to.js
|
|
5
|
-
function i(e, t = !1) {
|
|
6
|
-
t ? history.replaceState(null, "", e) : history.pushState(null, "", e), dispatchEvent(new PopStateEvent("popstate"));
|
|
7
|
-
}
|
|
8
|
-
// src/browser/_use-query.js
|
|
9
|
-
var a = /* @__PURE__ */ new Map(), o = null;
|
|
10
|
-
function s({ endpoint: n, refetchEvent: i } = {}) {
|
|
11
|
-
let a = r(() => {
|
|
12
|
-
let r = t(null), i = t(!1), a = t(null);
|
|
13
|
-
async function o() {
|
|
14
|
-
i.value = !0, a.value = null;
|
|
15
|
-
try {
|
|
16
|
-
let t = await e({
|
|
17
|
-
url: n,
|
|
18
|
-
method: "GET"
|
|
19
|
-
});
|
|
20
|
-
if (!t.success) throw Error("Could not query data.");
|
|
21
|
-
r.value = t.data;
|
|
22
|
-
} catch (e) {
|
|
23
|
-
console.log(e), a.value = e;
|
|
24
|
-
} finally {
|
|
25
|
-
i.value = !1;
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
return {
|
|
29
|
-
data: r,
|
|
30
|
-
loading: i,
|
|
31
|
-
error: a,
|
|
32
|
-
refetch: o
|
|
33
|
-
};
|
|
34
|
-
}, [n]);
|
|
35
|
-
return l(a, i), a;
|
|
36
|
-
}
|
|
37
|
-
function c({ query: n, variables: i, refetchEvent: a } = {}) {
|
|
38
|
-
let o = JSON.stringify(i ?? null), s = r(() => {
|
|
39
|
-
let r = t(null), i = t(!1), a = t(null);
|
|
40
|
-
async function s() {
|
|
41
|
-
i.value = !0, a.value = null;
|
|
42
|
-
try {
|
|
43
|
-
let t = await e({
|
|
44
|
-
url: "/api/graphql",
|
|
45
|
-
method: "POST",
|
|
46
|
-
body: {
|
|
47
|
-
query: n,
|
|
48
|
-
variables: JSON.parse(o)
|
|
49
|
-
}
|
|
50
|
-
}), i = t.data?.errors?.[0];
|
|
51
|
-
if (!t.success || i) throw Error(i?.message ?? "Could not query data.");
|
|
52
|
-
r.value = t.data?.data ?? null;
|
|
53
|
-
} catch (e) {
|
|
54
|
-
console.log(e), a.value = e;
|
|
55
|
-
} finally {
|
|
56
|
-
i.value = !1;
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
data: r,
|
|
61
|
-
loading: i,
|
|
62
|
-
error: a,
|
|
63
|
-
refetch: s
|
|
64
|
-
};
|
|
65
|
-
}, [n, o]);
|
|
66
|
-
return l(s, a), s;
|
|
67
|
-
}
|
|
68
|
-
function l(e, t) {
|
|
69
|
-
n(() => {
|
|
70
|
-
let n = t ? d(t, e.refetch) : () => {};
|
|
71
|
-
return e.refetch(), n;
|
|
72
|
-
}, [e, t]);
|
|
73
|
-
}
|
|
74
|
-
function u() {
|
|
75
|
-
return o ??= new EventSource("/api/client-events"), o;
|
|
76
|
-
}
|
|
77
|
-
function d(e, t) {
|
|
78
|
-
let n = u();
|
|
79
|
-
if (!a.has(e)) {
|
|
80
|
-
let t = /* @__PURE__ */ new Set(), r = (e) => {
|
|
81
|
-
let n = e.data ? JSON.parse(e.data) : null;
|
|
82
|
-
for (let e of t) e(n);
|
|
83
|
-
};
|
|
84
|
-
a.set(e, {
|
|
85
|
-
callbacks: t,
|
|
86
|
-
handler: r
|
|
87
|
-
}), n.addEventListener(e, r);
|
|
88
|
-
}
|
|
89
|
-
let r = a.get(e);
|
|
90
|
-
return r.callbacks.add(t), () => {
|
|
91
|
-
r.callbacks.delete(t), r.callbacks.size > 0 || (n.removeEventListener(e, r.handler), a.delete(e));
|
|
92
|
-
};
|
|
93
|
-
}
|
|
94
|
-
// src/browser/_get-client-setting.js
|
|
95
|
-
function f(e, t = null) {
|
|
96
|
-
if (typeof window > "u" || !e) return t;
|
|
97
|
-
try {
|
|
98
|
-
let n = window.localStorage.getItem(p(e));
|
|
99
|
-
return n === null ? t : JSON.parse(n);
|
|
100
|
-
} catch {
|
|
101
|
-
return t;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
function p(e) {
|
|
105
|
-
return `melonykit:${e}`;
|
|
106
|
-
}
|
|
107
|
-
// src/browser/_set-client-setting.js
|
|
108
|
-
function m(e, t) {
|
|
109
|
-
if (typeof window > "u" || !e) return !1;
|
|
110
|
-
try {
|
|
111
|
-
return window.localStorage.setItem(h(e), JSON.stringify(t)), !0;
|
|
112
|
-
} catch {
|
|
113
|
-
return !1;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
function h(e) {
|
|
117
|
-
return `melonykit:${e}`;
|
|
118
|
-
}
|
|
119
|
-
export { i as a, s as i, f as n, c as r, m as t };
|