dropcap 1.1.0 → 1.4.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/chunk-5N6O5FSZ.js +53 -0
- package/dist/chunk-5N6O5FSZ.js.map +1 -0
- package/dist/chunk-6X6FFIZN.js +9 -0
- package/dist/chunk-6X6FFIZN.js.map +1 -0
- package/dist/chunk-IEKJYSB2.js +38 -0
- package/dist/chunk-IEKJYSB2.js.map +1 -0
- package/dist/chunk-IL3H2YKT.js +20 -0
- package/dist/chunk-IL3H2YKT.js.map +1 -0
- package/dist/chunk-IQMQQI6W.js +35 -0
- package/dist/chunk-IQMQQI6W.js.map +1 -0
- package/dist/chunk-NIQOLOOJ.js +44 -0
- package/dist/chunk-NIQOLOOJ.js.map +1 -0
- package/dist/chunk-OURJLKNI.js +16 -0
- package/dist/chunk-OURJLKNI.js.map +1 -0
- package/dist/chunk-RXAMNVZW.js +9 -0
- package/dist/chunk-RXAMNVZW.js.map +1 -0
- package/dist/chunk-SDOWUYJK.js +1 -0
- package/dist/chunk-SDOWUYJK.js.map +1 -0
- package/dist/chunk-WBZCJMFI.js +14 -0
- package/dist/chunk-WBZCJMFI.js.map +1 -0
- package/dist/chunk-YPFVC6GE.js +29 -0
- package/dist/chunk-YPFVC6GE.js.map +1 -0
- package/dist/idb/idb.d.ts +45 -0
- package/dist/idb/idb.js +200 -0
- package/dist/idb/idb.js.map +1 -0
- package/dist/types/types.js +1 -0
- package/dist/types/types.js.map +1 -0
- package/dist/utils/utils-color-hash.js +4 -39
- package/dist/utils/utils-color-hash.js.map +1 -0
- package/dist/utils/utils-create-log.js +5 -51
- package/dist/utils/utils-create-log.js.map +1 -0
- package/dist/utils/utils-ensure-array.js +4 -4
- package/dist/utils/utils-ensure-array.js.map +1 -0
- package/dist/utils/utils-is.js +4 -30
- package/dist/utils/utils-is.js.map +1 -0
- package/dist/utils/utils-link.d.ts +3 -0
- package/dist/utils/utils-link.js +8 -0
- package/dist/utils/utils-link.js.map +1 -0
- package/dist/utils/utils-queue.d.ts +1 -1
- package/dist/utils/utils-queue.js +6 -86
- package/dist/utils/utils-queue.js.map +1 -0
- package/dist/utils/utils-safe.js +6 -50
- package/dist/utils/utils-safe.js.map +1 -0
- package/dist/utils/utils-unique.js +4 -11
- package/dist/utils/utils-unique.js.map +1 -0
- package/dist/utils/utils-unit.js +6 -81
- package/dist/utils/utils-unit.js.map +1 -0
- package/dist/utils/utils-wait.js +4 -4
- package/dist/utils/utils-wait.js.map +1 -0
- package/dist/utils/utils.d.ts +1 -0
- package/dist/utils/utils.js +34 -199
- package/dist/utils/utils.js.map +1 -0
- package/package.json +4 -6
- package/src/types/types.ts +0 -5
- package/src/utils/utils-color-hash.ts +0 -55
- package/src/utils/utils-create-log.ts +0 -16
- package/src/utils/utils-ensure-array.ts +0 -3
- package/src/utils/utils-is.ts +0 -32
- package/src/utils/utils-queue.ts +0 -58
- package/src/utils/utils-safe.ts +0 -23
- package/src/utils/utils-unique.ts +0 -11
- package/src/utils/utils-unit.ts +0 -35
- package/src/utils/utils-wait.ts +0 -3
- package/src/utils/utils.ts +0 -13
|
@@ -1,42 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
for (let i = 0; i < str.length; i++) {
|
|
5
|
-
hash = hash * 33 ^ str.charCodeAt(i);
|
|
6
|
-
}
|
|
7
|
-
hash >>>= 0;
|
|
8
|
-
const hue = Math.floor(hash * 0.618033988749895 % 1 * 360);
|
|
9
|
-
const sat = 70;
|
|
10
|
-
let light = 50;
|
|
11
|
-
for (let i = 0; i < 20; i++) {
|
|
12
|
-
const rgb = hsl2rgb(hue, sat, light);
|
|
13
|
-
const l = lum(rgb);
|
|
14
|
-
const cW = contrast(1, l);
|
|
15
|
-
const cB = contrast(0, l);
|
|
16
|
-
if (cW >= 4.5 && cB >= 4.5) break;
|
|
17
|
-
light += cW < cB ? -5 : 5;
|
|
18
|
-
}
|
|
19
|
-
const hex = hsl2rgb(hue, sat, light).map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
20
|
-
return `#${hex}`;
|
|
21
|
-
}
|
|
22
|
-
function hsl2rgb(hh, ss, ll) {
|
|
23
|
-
ss /= 100;
|
|
24
|
-
ll /= 100;
|
|
25
|
-
const k = (n) => (n + hh / 30) % 12;
|
|
26
|
-
const a = ss * Math.min(ll, 1 - ll);
|
|
27
|
-
const f = (n) => ll - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
28
|
-
return [f(0), f(8), f(4)].map((v) => Math.round(v * 255));
|
|
29
|
-
}
|
|
30
|
-
function lum([r, g, b]) {
|
|
31
|
-
const c = (x) => {
|
|
32
|
-
x /= 255;
|
|
33
|
-
return x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
34
|
-
};
|
|
35
|
-
return 0.2126 * c(r) + 0.7152 * c(g) + 0.0722 * c(b);
|
|
36
|
-
}
|
|
37
|
-
function contrast(l1, l2) {
|
|
38
|
-
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
39
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
colorHash
|
|
3
|
+
} from "../chunk-NIQOLOOJ.js";
|
|
40
4
|
export {
|
|
41
5
|
colorHash
|
|
42
6
|
};
|
|
7
|
+
//# sourceMappingURL=utils-color-hash.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,54 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
hash = hash * 33 ^ str.charCodeAt(i);
|
|
6
|
-
}
|
|
7
|
-
hash >>>= 0;
|
|
8
|
-
const hue = Math.floor(hash * 0.618033988749895 % 1 * 360);
|
|
9
|
-
const sat = 70;
|
|
10
|
-
let light = 50;
|
|
11
|
-
for (let i = 0; i < 20; i++) {
|
|
12
|
-
const rgb = hsl2rgb(hue, sat, light);
|
|
13
|
-
const l = lum(rgb);
|
|
14
|
-
const cW = contrast(1, l);
|
|
15
|
-
const cB = contrast(0, l);
|
|
16
|
-
if (cW >= 4.5 && cB >= 4.5) break;
|
|
17
|
-
light += cW < cB ? -5 : 5;
|
|
18
|
-
}
|
|
19
|
-
const hex = hsl2rgb(hue, sat, light).map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
20
|
-
return `#${hex}`;
|
|
21
|
-
}
|
|
22
|
-
function hsl2rgb(hh, ss, ll) {
|
|
23
|
-
ss /= 100;
|
|
24
|
-
ll /= 100;
|
|
25
|
-
const k = (n) => (n + hh / 30) % 12;
|
|
26
|
-
const a = ss * Math.min(ll, 1 - ll);
|
|
27
|
-
const f = (n) => ll - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
28
|
-
return [f(0), f(8), f(4)].map((v) => Math.round(v * 255));
|
|
29
|
-
}
|
|
30
|
-
function lum([r, g, b]) {
|
|
31
|
-
const c = (x) => {
|
|
32
|
-
x /= 255;
|
|
33
|
-
return x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
34
|
-
};
|
|
35
|
-
return 0.2126 * c(r) + 0.7152 * c(g) + 0.0722 * c(b);
|
|
36
|
-
}
|
|
37
|
-
function contrast(l1, l2) {
|
|
38
|
-
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/utils/utils-create-log.ts
|
|
42
|
-
function createLog(name) {
|
|
43
|
-
const color = colorHash(name);
|
|
44
|
-
const log = print.bind(null, "log", name, color);
|
|
45
|
-
log.warn = print.bind(null, "warn", name, color);
|
|
46
|
-
log.error = print.bind(null, "error", name, color);
|
|
47
|
-
return log;
|
|
48
|
-
}
|
|
49
|
-
function print(type, name, color, ...args) {
|
|
50
|
-
console[type](`%c[${name}]`, `color: ${color}`, ...args);
|
|
51
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
createLog
|
|
3
|
+
} from "../chunk-IL3H2YKT.js";
|
|
4
|
+
import "../chunk-NIQOLOOJ.js";
|
|
52
5
|
export {
|
|
53
6
|
createLog
|
|
54
7
|
};
|
|
8
|
+
//# sourceMappingURL=utils-create-log.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/utils-is.js
CHANGED
|
@@ -1,33 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
undefined: (v) => v === void 0,
|
|
5
|
-
boolean: (v) => typeof v === "boolean",
|
|
6
|
-
number: (v) => typeof v === "number",
|
|
7
|
-
string: (v) => typeof v === "string",
|
|
8
|
-
symbol: (v) => typeof v === "symbol",
|
|
9
|
-
function: (v) => typeof v === "function",
|
|
10
|
-
object: (v) => Object.prototype.toString.call(v) === "[object Object]",
|
|
11
|
-
array: (v) => Array.isArray(v),
|
|
12
|
-
set: (v) => v instanceof Set,
|
|
13
|
-
map: (v) => v instanceof Map,
|
|
14
|
-
blob: (v) => v instanceof Blob,
|
|
15
|
-
date: (v) => v instanceof Date,
|
|
16
|
-
error: (v) => v instanceof Error,
|
|
17
|
-
regex: (v) => v instanceof RegExp,
|
|
18
|
-
promise: (v) => v instanceof Promise,
|
|
19
|
-
uint8Array: (v) => v instanceof Uint8Array,
|
|
20
|
-
uint16Array: (v) => v instanceof Uint16Array,
|
|
21
|
-
uint32Array: (v) => v instanceof Uint32Array,
|
|
22
|
-
nan: (v) => Number.isNaN(v),
|
|
23
|
-
numeric: (v) => !is.nan(Number(v)),
|
|
24
|
-
integer: (v) => Number.isInteger(v),
|
|
25
|
-
absent: (v) => v === null || v === void 0,
|
|
26
|
-
present: (v) => !is.absent(v),
|
|
27
|
-
primitive: (v) => v !== Object(v),
|
|
28
|
-
collection: (v) => is.array(v) || is.object(v),
|
|
29
|
-
compound: (v) => v !== null && typeof v === "object"
|
|
30
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
is
|
|
3
|
+
} from "../chunk-IQMQQI6W.js";
|
|
31
4
|
export {
|
|
32
5
|
is
|
|
33
6
|
};
|
|
7
|
+
//# sourceMappingURL=utils-is.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,89 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
number: (v) => typeof v === "number",
|
|
7
|
-
string: (v) => typeof v === "string",
|
|
8
|
-
symbol: (v) => typeof v === "symbol",
|
|
9
|
-
function: (v) => typeof v === "function",
|
|
10
|
-
object: (v) => Object.prototype.toString.call(v) === "[object Object]",
|
|
11
|
-
array: (v) => Array.isArray(v),
|
|
12
|
-
set: (v) => v instanceof Set,
|
|
13
|
-
map: (v) => v instanceof Map,
|
|
14
|
-
blob: (v) => v instanceof Blob,
|
|
15
|
-
date: (v) => v instanceof Date,
|
|
16
|
-
error: (v) => v instanceof Error,
|
|
17
|
-
regex: (v) => v instanceof RegExp,
|
|
18
|
-
promise: (v) => v instanceof Promise,
|
|
19
|
-
uint8Array: (v) => v instanceof Uint8Array,
|
|
20
|
-
uint16Array: (v) => v instanceof Uint16Array,
|
|
21
|
-
uint32Array: (v) => v instanceof Uint32Array,
|
|
22
|
-
nan: (v) => Number.isNaN(v),
|
|
23
|
-
numeric: (v) => !is.nan(Number(v)),
|
|
24
|
-
integer: (v) => Number.isInteger(v),
|
|
25
|
-
absent: (v) => v === null || v === void 0,
|
|
26
|
-
present: (v) => !is.absent(v),
|
|
27
|
-
primitive: (v) => v !== Object(v),
|
|
28
|
-
collection: (v) => is.array(v) || is.object(v),
|
|
29
|
-
compound: (v) => v !== null && typeof v === "object"
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// src/utils/utils-safe.ts
|
|
33
|
-
async function safe(effect) {
|
|
34
|
-
try {
|
|
35
|
-
const result = is.function(effect) ? await effect() : await effect;
|
|
36
|
-
return [result, null];
|
|
37
|
-
} catch (e) {
|
|
38
|
-
const error = e instanceof Error ? e : new Error(String(e));
|
|
39
|
-
return [null, error];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// src/utils/utils-queue.ts
|
|
44
|
-
var Queue = class {
|
|
45
|
-
name;
|
|
46
|
-
tasks = [];
|
|
47
|
-
running = false;
|
|
48
|
-
constructor(name = null) {
|
|
49
|
-
this.name = name;
|
|
50
|
-
}
|
|
51
|
-
async add(fn) {
|
|
52
|
-
const task = { fn, result$: Promise.withResolvers() };
|
|
53
|
-
this.tasks.push(task);
|
|
54
|
-
this.start();
|
|
55
|
-
return await task.result$.promise;
|
|
56
|
-
}
|
|
57
|
-
wrap(fn, thisValue = null) {
|
|
58
|
-
return (async (...args) => {
|
|
59
|
-
return await this.add(() => fn.call(thisValue, ...args));
|
|
60
|
-
});
|
|
61
|
-
}
|
|
62
|
-
async wait() {
|
|
63
|
-
const lastTask = this.tasks.at(-1);
|
|
64
|
-
if (lastTask) await safe(lastTask.result$.promise);
|
|
65
|
-
}
|
|
66
|
-
isEmpty() {
|
|
67
|
-
return this.tasks.length === 0;
|
|
68
|
-
}
|
|
69
|
-
async start() {
|
|
70
|
-
if (this.running) return;
|
|
71
|
-
if (this.isEmpty()) return;
|
|
72
|
-
this.running = true;
|
|
73
|
-
while (this.tasks.length > 0) {
|
|
74
|
-
const task = this.tasks[0];
|
|
75
|
-
if (!task) break;
|
|
76
|
-
const [result, error] = await safe(task.fn);
|
|
77
|
-
this.tasks.shift();
|
|
78
|
-
if (error) {
|
|
79
|
-
task.result$.reject(error);
|
|
80
|
-
} else {
|
|
81
|
-
task.result$.resolve(result);
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
|
-
this.running = false;
|
|
85
|
-
}
|
|
86
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
Queue
|
|
3
|
+
} from "../chunk-5N6O5FSZ.js";
|
|
4
|
+
import "../chunk-YPFVC6GE.js";
|
|
5
|
+
import "../chunk-IQMQQI6W.js";
|
|
87
6
|
export {
|
|
88
7
|
Queue
|
|
89
8
|
};
|
|
9
|
+
//# sourceMappingURL=utils-queue.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/utils-safe.js
CHANGED
|
@@ -1,54 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
number: (v) => typeof v === "number",
|
|
7
|
-
string: (v) => typeof v === "string",
|
|
8
|
-
symbol: (v) => typeof v === "symbol",
|
|
9
|
-
function: (v) => typeof v === "function",
|
|
10
|
-
object: (v) => Object.prototype.toString.call(v) === "[object Object]",
|
|
11
|
-
array: (v) => Array.isArray(v),
|
|
12
|
-
set: (v) => v instanceof Set,
|
|
13
|
-
map: (v) => v instanceof Map,
|
|
14
|
-
blob: (v) => v instanceof Blob,
|
|
15
|
-
date: (v) => v instanceof Date,
|
|
16
|
-
error: (v) => v instanceof Error,
|
|
17
|
-
regex: (v) => v instanceof RegExp,
|
|
18
|
-
promise: (v) => v instanceof Promise,
|
|
19
|
-
uint8Array: (v) => v instanceof Uint8Array,
|
|
20
|
-
uint16Array: (v) => v instanceof Uint16Array,
|
|
21
|
-
uint32Array: (v) => v instanceof Uint32Array,
|
|
22
|
-
nan: (v) => Number.isNaN(v),
|
|
23
|
-
numeric: (v) => !is.nan(Number(v)),
|
|
24
|
-
integer: (v) => Number.isInteger(v),
|
|
25
|
-
absent: (v) => v === null || v === void 0,
|
|
26
|
-
present: (v) => !is.absent(v),
|
|
27
|
-
primitive: (v) => v !== Object(v),
|
|
28
|
-
collection: (v) => is.array(v) || is.object(v),
|
|
29
|
-
compound: (v) => v !== null && typeof v === "object"
|
|
30
|
-
};
|
|
31
|
-
|
|
32
|
-
// src/utils/utils-safe.ts
|
|
33
|
-
async function safe(effect) {
|
|
34
|
-
try {
|
|
35
|
-
const result = is.function(effect) ? await effect() : await effect;
|
|
36
|
-
return [result, null];
|
|
37
|
-
} catch (e) {
|
|
38
|
-
const error = e instanceof Error ? e : new Error(String(e));
|
|
39
|
-
return [null, error];
|
|
40
|
-
}
|
|
41
|
-
}
|
|
42
|
-
function safeSync(effect) {
|
|
43
|
-
try {
|
|
44
|
-
const result = effect();
|
|
45
|
-
return [result, null];
|
|
46
|
-
} catch (e) {
|
|
47
|
-
const error = e instanceof Error ? e : new Error(String(e));
|
|
48
|
-
return [null, error];
|
|
49
|
-
}
|
|
50
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
safe,
|
|
3
|
+
safeSync
|
|
4
|
+
} from "../chunk-YPFVC6GE.js";
|
|
5
|
+
import "../chunk-IQMQQI6W.js";
|
|
51
6
|
export {
|
|
52
7
|
safe,
|
|
53
8
|
safeSync
|
|
54
9
|
};
|
|
10
|
+
//# sourceMappingURL=utils-safe.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
|
@@ -1,14 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const seen = /* @__PURE__ */ new Set();
|
|
5
|
-
return items.filter((item) => {
|
|
6
|
-
const key = keyFn(item);
|
|
7
|
-
if (seen.has(key)) return false;
|
|
8
|
-
seen.add(key);
|
|
9
|
-
return true;
|
|
10
|
-
});
|
|
11
|
-
}
|
|
1
|
+
import {
|
|
2
|
+
unique
|
|
3
|
+
} from "../chunk-OURJLKNI.js";
|
|
12
4
|
export {
|
|
13
5
|
unique
|
|
14
6
|
};
|
|
7
|
+
//# sourceMappingURL=utils-unique.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/utils-unit.js
CHANGED
|
@@ -1,84 +1,9 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
hash >>>= 0;
|
|
8
|
-
const hue = Math.floor(hash * 0.618033988749895 % 1 * 360);
|
|
9
|
-
const sat = 70;
|
|
10
|
-
let light = 50;
|
|
11
|
-
for (let i = 0; i < 20; i++) {
|
|
12
|
-
const rgb = hsl2rgb(hue, sat, light);
|
|
13
|
-
const l = lum(rgb);
|
|
14
|
-
const cW = contrast(1, l);
|
|
15
|
-
const cB = contrast(0, l);
|
|
16
|
-
if (cW >= 4.5 && cB >= 4.5) break;
|
|
17
|
-
light += cW < cB ? -5 : 5;
|
|
18
|
-
}
|
|
19
|
-
const hex = hsl2rgb(hue, sat, light).map((v) => v.toString(16).padStart(2, "0")).join("");
|
|
20
|
-
return `#${hex}`;
|
|
21
|
-
}
|
|
22
|
-
function hsl2rgb(hh, ss, ll) {
|
|
23
|
-
ss /= 100;
|
|
24
|
-
ll /= 100;
|
|
25
|
-
const k = (n) => (n + hh / 30) % 12;
|
|
26
|
-
const a = ss * Math.min(ll, 1 - ll);
|
|
27
|
-
const f = (n) => ll - a * Math.max(-1, Math.min(k(n) - 3, Math.min(9 - k(n), 1)));
|
|
28
|
-
return [f(0), f(8), f(4)].map((v) => Math.round(v * 255));
|
|
29
|
-
}
|
|
30
|
-
function lum([r, g, b]) {
|
|
31
|
-
const c = (x) => {
|
|
32
|
-
x /= 255;
|
|
33
|
-
return x <= 0.03928 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
34
|
-
};
|
|
35
|
-
return 0.2126 * c(r) + 0.7152 * c(g) + 0.0722 * c(b);
|
|
36
|
-
}
|
|
37
|
-
function contrast(l1, l2) {
|
|
38
|
-
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
// src/utils/utils-create-log.ts
|
|
42
|
-
function createLog(name) {
|
|
43
|
-
const color = colorHash(name);
|
|
44
|
-
const log = print.bind(null, "log", name, color);
|
|
45
|
-
log.warn = print.bind(null, "warn", name, color);
|
|
46
|
-
log.error = print.bind(null, "error", name, color);
|
|
47
|
-
return log;
|
|
48
|
-
}
|
|
49
|
-
function print(type, name, color, ...args) {
|
|
50
|
-
console[type](`%c[${name}]`, `color: ${color}`, ...args);
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
// src/utils/utils-unit.ts
|
|
54
|
-
var Unit = class {
|
|
55
|
-
$;
|
|
56
|
-
log = createLog(this.constructor.name);
|
|
57
|
-
#parent = null;
|
|
58
|
-
constructor(parent) {
|
|
59
|
-
this.$ = parent?.$ ?? this;
|
|
60
|
-
this.#parent = parent ?? null;
|
|
61
|
-
}
|
|
62
|
-
closest(Ancestor) {
|
|
63
|
-
let cursor = this.#parent;
|
|
64
|
-
while (cursor) {
|
|
65
|
-
if (cursor instanceof Ancestor) return cursor;
|
|
66
|
-
cursor = cursor.#parent;
|
|
67
|
-
}
|
|
68
|
-
return null;
|
|
69
|
-
}
|
|
70
|
-
never(message) {
|
|
71
|
-
const details = message ? `: ${message}` : "";
|
|
72
|
-
const error = new Error(`[${this.constructor.name}] This should never happen${details}`);
|
|
73
|
-
Error.captureStackTrace(error, this.never);
|
|
74
|
-
return error;
|
|
75
|
-
}
|
|
76
|
-
Error(message) {
|
|
77
|
-
const error = new Error(`[${this.constructor.name}] ${message}`);
|
|
78
|
-
Error.captureStackTrace(error, this.Error);
|
|
79
|
-
return error;
|
|
80
|
-
}
|
|
81
|
-
};
|
|
1
|
+
import {
|
|
2
|
+
Unit
|
|
3
|
+
} from "../chunk-IEKJYSB2.js";
|
|
4
|
+
import "../chunk-IL3H2YKT.js";
|
|
5
|
+
import "../chunk-NIQOLOOJ.js";
|
|
82
6
|
export {
|
|
83
7
|
Unit
|
|
84
8
|
};
|
|
9
|
+
//# sourceMappingURL=utils-unit.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/utils-wait.js
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":[],"sourcesContent":[],"mappings":"","names":[]}
|
package/dist/utils/utils.d.ts
CHANGED