melonykit 1.7.0 → 1.8.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.
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import { a as e } from "./functions-
|
|
1
|
+
import { a as e } from "./functions-BD3ZVwwW.js";
|
|
2
2
|
import { signal as t } from "@preact/signals";
|
|
3
3
|
import { useEffect as n, useMemo as r } from "preact/hooks";
|
|
4
|
-
|
|
4
|
+
// src/browser/_route-to.js
|
|
5
5
|
function i(e, t = !1) {
|
|
6
6
|
t ? history.replaceState(null, "", e) : history.pushState(null, "", e), dispatchEvent(new PopStateEvent("popstate"));
|
|
7
7
|
}
|
|
8
|
-
|
|
9
|
-
//#region src/browser/_use-query.js
|
|
8
|
+
// src/browser/_use-query.js
|
|
10
9
|
var a = /* @__PURE__ */ new Map(), o = null;
|
|
11
10
|
function s({ endpoint: i, event: a, refreshEvent: o }) {
|
|
12
11
|
let s = r(() => {
|
|
@@ -66,8 +65,7 @@ function l(e, t) {
|
|
|
66
65
|
r.callbacks.delete(t), r.callbacks.size === 0 && (n.removeEventListener(e, r.handler), a.delete(e));
|
|
67
66
|
};
|
|
68
67
|
}
|
|
69
|
-
|
|
70
|
-
//#region src/browser/_get-client-setting.js
|
|
68
|
+
// src/browser/_get-client-setting.js
|
|
71
69
|
function u(e, t = null) {
|
|
72
70
|
if (typeof window > "u" || !e) return t;
|
|
73
71
|
try {
|
|
@@ -80,8 +78,7 @@ function u(e, t = null) {
|
|
|
80
78
|
function d(e) {
|
|
81
79
|
return `melonykit:${e}`;
|
|
82
80
|
}
|
|
83
|
-
|
|
84
|
-
//#region src/browser/_set-client-setting.js
|
|
81
|
+
// src/browser/_set-client-setting.js
|
|
85
82
|
function f(e, t) {
|
|
86
83
|
if (typeof window > "u" || !e) return !1;
|
|
87
84
|
try {
|
|
@@ -93,5 +90,4 @@ function f(e, t) {
|
|
|
93
90
|
function p(e) {
|
|
94
91
|
return `melonykit:${e}`;
|
|
95
92
|
}
|
|
96
|
-
//#endregion
|
|
97
93
|
export { i, u as n, s as r, f as t };
|
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { n as getClientSetting, i as routeTo, t as setClientSetting, r as useQuery } from "./browser-
|
|
1
|
+
export { n as getClientSetting, i as routeTo, t as setClientSetting, r as useQuery } from "./browser-Bu2EkIKI.js";
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
// src/functions/_average.js
|
|
2
2
|
function e(e) {
|
|
3
3
|
if (!Array.isArray(e) || e.length === 0) return null;
|
|
4
4
|
let t = 0, n = 0;
|
|
@@ -9,18 +9,15 @@ function e(e) {
|
|
|
9
9
|
}
|
|
10
10
|
return t;
|
|
11
11
|
}
|
|
12
|
-
|
|
13
|
-
//#region src/functions/checks/_is-string.js
|
|
12
|
+
// src/functions/checks/_is-string.js
|
|
14
13
|
function t(e) {
|
|
15
14
|
return typeof e == "string";
|
|
16
15
|
}
|
|
17
|
-
|
|
18
|
-
//#region src/functions/_camel-case-to-title-case.js
|
|
16
|
+
// src/functions/_camel-case-to-title-case.js
|
|
19
17
|
function n(e) {
|
|
20
18
|
return t(e) ? e.replace(/([a-z\d])([A-Z])/g, "$1 $2").replace(/([A-Z]+)([A-Z][a-z])/g, "$1 $2").split(" ").filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "";
|
|
21
19
|
}
|
|
22
|
-
|
|
23
|
-
//#region src/functions/_parse-hex-color.js
|
|
20
|
+
// src/functions/_parse-hex-color.js
|
|
24
21
|
function r(e) {
|
|
25
22
|
if (typeof e != "string" || !/^#([\da-f]{3}|[\da-f]{6})$/i.test(e)) throw TypeError("hex must be a three- or six-digit hexadecimal color");
|
|
26
23
|
let t = e.slice(1), n = t.length === 3 ? [...t].map((e) => e.repeat(2)).join("") : t;
|
|
@@ -30,36 +27,30 @@ function r(e) {
|
|
|
30
27
|
4
|
|
31
28
|
].map((e) => parseInt(n.slice(e, e + 2), 16));
|
|
32
29
|
}
|
|
33
|
-
|
|
34
|
-
//#region src/functions/_convert-hex-to-rgba.js
|
|
30
|
+
// src/functions/_convert-hex-to-rgba.js
|
|
35
31
|
function i(e, t) {
|
|
36
32
|
let [n, i, a] = r(e);
|
|
37
33
|
if (!Number.isFinite(t)) throw TypeError("alpha must be a finite number");
|
|
38
34
|
if (t < 0 || t > 1) throw RangeError("alpha must be between 0 and 1");
|
|
39
35
|
return `rgba(${n}, ${i}, ${a}, ${t})`;
|
|
40
36
|
}
|
|
41
|
-
|
|
42
|
-
//#region src/functions/checks/_is-array.js
|
|
37
|
+
// src/functions/checks/_is-array.js
|
|
43
38
|
function a(e) {
|
|
44
39
|
return Array.isArray(e);
|
|
45
40
|
}
|
|
46
|
-
|
|
47
|
-
//#region src/functions/checks/_is-empty-array.js
|
|
41
|
+
// src/functions/checks/_is-empty-array.js
|
|
48
42
|
function o(e) {
|
|
49
43
|
return a(e) && e.length === 0;
|
|
50
44
|
}
|
|
51
|
-
|
|
52
|
-
//#region src/functions/checks/_is-function.js
|
|
45
|
+
// src/functions/checks/_is-function.js
|
|
53
46
|
function s(e) {
|
|
54
47
|
return typeof e == "function";
|
|
55
48
|
}
|
|
56
|
-
|
|
57
|
-
//#region src/functions/checks/_is-number.js
|
|
49
|
+
// src/functions/checks/_is-number.js
|
|
58
50
|
function c(e) {
|
|
59
51
|
return typeof e == "number" && Number.isFinite(e);
|
|
60
52
|
}
|
|
61
|
-
|
|
62
|
-
//#region src/functions/_create-cache.js
|
|
53
|
+
// src/functions/_create-cache.js
|
|
63
54
|
function l({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
|
|
64
55
|
let i = /* @__PURE__ */ new Map();
|
|
65
56
|
async function l(t, n) {
|
|
@@ -109,8 +100,7 @@ function l({ onCreate: e, onUpdate: t, onDelete: n, autoCleanup: r } = {}) {
|
|
|
109
100
|
remove: h
|
|
110
101
|
};
|
|
111
102
|
}
|
|
112
|
-
|
|
113
|
-
//#region src/functions/_darken-hex-color.js
|
|
103
|
+
// src/functions/_darken-hex-color.js
|
|
114
104
|
function u(e, t) {
|
|
115
105
|
let n = r(e);
|
|
116
106
|
if (!Number.isFinite(t)) throw TypeError("amount must be a finite number");
|
|
@@ -118,8 +108,7 @@ function u(e, t) {
|
|
|
118
108
|
let i = 1 - t;
|
|
119
109
|
return `#${n.map((e) => Math.round(e * i)).map((e) => e.toString(16).padStart(2, "0")).join("")}`;
|
|
120
110
|
}
|
|
121
|
-
|
|
122
|
-
//#region src/functions/_format-date.js
|
|
111
|
+
// src/functions/_format-date.js
|
|
123
112
|
function d(e) {
|
|
124
113
|
return Object.prototype.toString.call(e) === "[object Date]" && !isNaN(e);
|
|
125
114
|
}
|
|
@@ -252,56 +241,46 @@ var v = (e) => {
|
|
|
252
241
|
let c = /* @__PURE__ */ new Date();
|
|
253
242
|
return c.setDate(c[r + "Date"]() + 1), o[r + "FullYear"]() === e && o[r + "Month"]() === t && o[r + "Date"]() === n ? a ? "Tdy" : "Today" : s[r + "FullYear"]() === e && s[r + "Month"]() === t && s[r + "Date"]() === n ? a ? "Ysd" : "Yesterday" : c[r + "FullYear"]() === e && c[r + "Month"]() === t && c[r + "Date"]() === n ? a ? "Tmw" : "Tomorrow" : i;
|
|
254
243
|
};
|
|
255
|
-
|
|
256
|
-
//#region src/functions/checks/_is-nil.js
|
|
244
|
+
// src/functions/checks/_is-nil.js
|
|
257
245
|
function S(e) {
|
|
258
246
|
return e == null;
|
|
259
247
|
}
|
|
260
|
-
|
|
261
|
-
//#region src/functions/checks/_is-object.js
|
|
248
|
+
// src/functions/checks/_is-object.js
|
|
262
249
|
function C(e) {
|
|
263
250
|
return !S(e) && typeof e == "object" && !a(e);
|
|
264
251
|
}
|
|
265
|
-
|
|
266
|
-
//#region src/functions/checks/_is-empty-object.js
|
|
252
|
+
// src/functions/checks/_is-empty-object.js
|
|
267
253
|
function w(e) {
|
|
268
254
|
return C(e) && Reflect.ownKeys(e).every((t) => !Object.prototype.propertyIsEnumerable.call(e, t));
|
|
269
255
|
}
|
|
270
|
-
|
|
271
|
-
//#region src/functions/checks/_is-empty-string.js
|
|
256
|
+
// src/functions/checks/_is-empty-string.js
|
|
272
257
|
function T(e) {
|
|
273
258
|
return t(e) && e.trim().length === 0;
|
|
274
259
|
}
|
|
275
|
-
|
|
276
|
-
//#region src/functions/checks/_is-float.js
|
|
260
|
+
// src/functions/checks/_is-float.js
|
|
277
261
|
function E(e) {
|
|
278
262
|
return c(e) && !Number.isInteger(e);
|
|
279
263
|
}
|
|
280
|
-
|
|
281
|
-
//#region src/functions/checks/_is-integer.js
|
|
264
|
+
// src/functions/checks/_is-integer.js
|
|
282
265
|
function D(e) {
|
|
283
266
|
return Number.isInteger(e);
|
|
284
267
|
}
|
|
285
|
-
|
|
286
|
-
//#region src/functions/_kebab-case-to-camel-case.js
|
|
268
|
+
// src/functions/_kebab-case-to-camel-case.js
|
|
287
269
|
function O(e) {
|
|
288
270
|
return t(e) ? e.split("-").filter(Boolean).map((e, t) => t === 0 ? e.toLowerCase() : e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join("") : "";
|
|
289
271
|
}
|
|
290
|
-
|
|
291
|
-
//#region src/functions/_kebab-case-to-title-case.js
|
|
272
|
+
// src/functions/_kebab-case-to-title-case.js
|
|
292
273
|
function k(e) {
|
|
293
274
|
return t(e) ? e.split("-").filter(Boolean).map((e) => e.charAt(0).toUpperCase() + e.slice(1).toLowerCase()).join(" ") : "";
|
|
294
275
|
}
|
|
295
|
-
|
|
296
|
-
//#region src/functions/_median.js
|
|
276
|
+
// src/functions/_median.js
|
|
297
277
|
function A(e) {
|
|
298
278
|
if (!Array.isArray(e) || e.length === 0) return null;
|
|
299
279
|
for (let t of e) if (!Number.isFinite(t)) return null;
|
|
300
280
|
let t = [...e].sort((e, t) => e - t), n = Math.floor(t.length / 2);
|
|
301
281
|
return t.length % 2 == 0 ? (t[n - 1] + t[n]) / 2 : t[n];
|
|
302
282
|
}
|
|
303
|
-
|
|
304
|
-
//#region src/functions/_request.js
|
|
283
|
+
// src/functions/_request.js
|
|
305
284
|
async function j({ url: e, body: t, method: n = "POST", headers: r = {} } = {}) {
|
|
306
285
|
let i = n !== "GET" && t !== void 0 ? JSON.stringify(t) : void 0, a = await fetch(e, {
|
|
307
286
|
method: n,
|
|
@@ -321,26 +300,22 @@ async function j({ url: e, body: t, method: n = "POST", headers: r = {} } = {})
|
|
|
321
300
|
}
|
|
322
301
|
return a.ok || (s.error = s.data ?? /* @__PURE__ */ Error(`Request failed with status ${a.status}.`)), s;
|
|
323
302
|
}
|
|
324
|
-
|
|
325
|
-
//#region src/functions/_risk-reward.js
|
|
303
|
+
// src/functions/_risk-reward.js
|
|
326
304
|
function M(e = {}) {
|
|
327
305
|
let { entry: t, exit: n, riskRatio: r = 20 } = e ?? {};
|
|
328
306
|
if (!c(t) || t <= 0 || !c(n) || n <= 0 || !c(r) || r <= 0) return null;
|
|
329
307
|
let i = (n - t) / t / (r / 100);
|
|
330
308
|
return Math.round(i * 10) / 10;
|
|
331
309
|
}
|
|
332
|
-
|
|
333
|
-
//#region src/functions/_size.js
|
|
310
|
+
// src/functions/_size.js
|
|
334
311
|
function N(e) {
|
|
335
312
|
return e == null ? 0 : Array.isArray(e) || typeof e == "string" ? e.length : typeof e == "object" || typeof e == "function" ? Object.keys(e).length : 0;
|
|
336
313
|
}
|
|
337
|
-
|
|
338
|
-
//#region src/functions/_slugify.js
|
|
314
|
+
// src/functions/_slugify.js
|
|
339
315
|
function P(e) {
|
|
340
316
|
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, "") : "";
|
|
341
317
|
}
|
|
342
|
-
|
|
343
|
-
//#region src/functions/_to-number.js
|
|
318
|
+
// src/functions/_to-number.js
|
|
344
319
|
function F(e, t = null) {
|
|
345
320
|
let n = typeof e == "number" ? e : typeof e == "string" && e.trim() !== "" ? Number(e) : NaN;
|
|
346
321
|
if (!Number.isFinite(n)) return null;
|
|
@@ -348,5 +323,4 @@ function F(e, t = null) {
|
|
|
348
323
|
let r = 10 ** t;
|
|
349
324
|
return Math.round(n * r) / r;
|
|
350
325
|
}
|
|
351
|
-
//#endregion
|
|
352
326
|
export { n as C, i as S, e as T, l as _, j as a, o as b, O as c, T as d, w as f, u as g, _ as h, M as i, D as l, S as m, P as n, A as o, C as p, N as r, k as s, F as t, E as u, c as v, t as w, a as x, s as y };
|
package/dist/functions.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { T as average, C as camelCaseToTitleCase, S as convertHexToRgba, _ as createCache, g as darkenHexColor, h as formatDate, x as isArray, b as isEmptyArray, f as isEmptyObject, d as isEmptyString, u as isFloat, y as isFunction, l as isInteger, m as isNil, v as isNumber, p as isObject, w as isString, c as kebabCaseToCamelCase, s as kebabCaseToTitleCase, o as median, a as request, i as riskReward, r as size, n as slugify, t as toNumber } from "./functions-
|
|
1
|
+
export { T as average, C as camelCaseToTitleCase, S as convertHexToRgba, _ as createCache, g as darkenHexColor, h as formatDate, x as isArray, b as isEmptyArray, f as isEmptyObject, d as isEmptyString, u as isFloat, y as isFunction, l as isInteger, m as isNil, v as isNumber, p as isObject, w as isString, c as kebabCaseToCamelCase, s as kebabCaseToTitleCase, o as median, a as request, i as riskReward, r as size, n as slugify, t as toNumber } from "./functions-BD3ZVwwW.js";
|