solid-tiny-utils 0.7.0 → 0.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.
- package/README.md +9 -9
- package/dist/color/{hex-rgb.d.ts → hex-rgb.d.mts} +5 -3
- package/dist/color/hex-rgb.mjs +62 -0
- package/dist/color/{oklch-rgb.d.ts → oklch-rgb.d.mts} +9 -8
- package/dist/color/oklch-rgb.mjs +101 -0
- package/dist/color/{validation.d.ts → validation.d.mts} +5 -3
- package/dist/color/validation.mjs +35 -0
- package/dist/dom/{css.d.ts → css.d.mts} +6 -4
- package/dist/dom/css.mjs +51 -0
- package/dist/event/create-click-outside.d.mts +9 -0
- package/dist/event/create-click-outside.mjs +33 -0
- package/dist/event/{create-event-listener.d.ts → create-event-listener.d.mts} +7 -6
- package/dist/event/create-event-listener.mjs +34 -0
- package/dist/event/{create-intersection-observer.d.ts → create-intersection-observer.d.mts} +5 -4
- package/dist/event/create-intersection-observer.mjs +29 -0
- package/dist/event/{create-visibility-observer.d.ts → create-visibility-observer.d.mts} +7 -5
- package/dist/event/create-visibility-observer.mjs +46 -0
- package/dist/event/index.d.mts +12 -0
- package/dist/event/index.mjs +15 -0
- package/dist/event/{make-event-listener.d.ts → make-event-listener.d.mts} +8 -7
- package/dist/event/make-event-listener.mjs +35 -0
- package/dist/event/on-motion-end.d.mts +63 -0
- package/dist/event/on-motion-end.mjs +96 -0
- package/dist/fn/create-debounce.d.mts +7 -0
- package/dist/fn/create-debounce.mjs +20 -0
- package/dist/fn/{create-loop-exec.d.ts → create-loop-exec.d.mts} +7 -6
- package/dist/fn/create-loop-exec.mjs +59 -0
- package/dist/fn/create-throttle.d.mts +7 -0
- package/dist/fn/create-throttle.mjs +21 -0
- package/dist/fn/index.d.mts +8 -0
- package/dist/fn/index.mjs +9 -0
- package/dist/index.d.mts +30 -0
- package/dist/index.mjs +27 -0
- package/dist/jsx/{attrs.d.ts → attrs.d.mts} +3 -2
- package/dist/jsx/attrs.mjs +26 -0
- package/dist/reactive/access.d.mts +6 -0
- package/dist/reactive/access.mjs +9 -0
- package/dist/reactive/{create-debounce-watch.d.ts → create-debounce-watch.d.mts} +6 -4
- package/dist/reactive/create-debounce-watch.mjs +15 -0
- package/dist/reactive/{create-watch.d.ts → create-watch.d.mts} +4 -3
- package/dist/reactive/create-watch.mjs +9 -0
- package/dist/reactive/index.d.mts +3 -0
- package/dist/types/{fn.d.ts → fn.d.mts} +3 -2
- package/dist/types/index.d.mts +2 -0
- package/dist/types/{maybe.d.ts → maybe.d.mts} +4 -3
- package/dist/utils/{array.d.ts → array.d.mts} +3 -2
- package/dist/utils/array.mjs +66 -0
- package/dist/utils/async.d.mts +8 -0
- package/dist/utils/async.mjs +17 -0
- package/dist/utils/{is.d.ts → is.d.mts} +3 -2
- package/dist/utils/is.mjs +72 -0
- package/dist/utils/{number.d.ts → number.d.mts} +3 -2
- package/dist/utils/number.mjs +127 -0
- package/dist/utils/{random.d.ts → random.d.mts} +3 -2
- package/dist/utils/random.mjs +33 -0
- package/dist/utils/{str.d.ts → str.d.mts} +4 -3
- package/dist/utils/str.mjs +120 -0
- package/package.json +22 -19
- package/dist/chunk-4L6FK7MF.js +0 -9
- package/dist/chunk-6G7GFZV2.js +0 -93
- package/dist/chunk-6OVLJ45M.js +0 -51
- package/dist/chunk-ACZGS7DG.js +0 -72
- package/dist/chunk-AZAXMGEB.js +0 -0
- package/dist/chunk-BLX3XSA6.js +0 -0
- package/dist/chunk-BT47ISVC.js +0 -36
- package/dist/chunk-EZML2DEC.js +0 -0
- package/dist/chunk-FFBJP5FE.js +0 -0
- package/dist/chunk-II6INKPZ.js +0 -8
- package/dist/chunk-KFLH3AZ6.js +0 -40
- package/dist/chunk-KKFGUHFR.js +0 -8
- package/dist/chunk-KM4Q6THD.js +0 -50
- package/dist/chunk-LEWF7QAQ.js +0 -47
- package/dist/chunk-LUFOWTRW.js +0 -0
- package/dist/chunk-PD6VHMH6.js +0 -26
- package/dist/chunk-QPEF6LHH.js +0 -111
- package/dist/chunk-QQVSG76Z.js +0 -36
- package/dist/chunk-S7U3LZNS.js +0 -23
- package/dist/chunk-SK6Y2YH6.js +0 -0
- package/dist/chunk-TDJLPDJF.js +0 -66
- package/dist/chunk-TGWWPUWD.js +0 -55
- package/dist/chunk-U5LQ2AS5.js +0 -0
- package/dist/chunk-WJHRONQU.js +0 -54
- package/dist/chunk-Y4GYGFIT.js +0 -85
- package/dist/chunk-YK5QQQ43.js +0 -12
- package/dist/chunk-YXRZ2KMJ.js +0 -0
- package/dist/color/hex-rgb.js +0 -15
- package/dist/color/index.d.ts +0 -3
- package/dist/color/index.js +0 -30
- package/dist/color/oklch-rgb.js +0 -15
- package/dist/color/validation.js +0 -18
- package/dist/dom/css.js +0 -19
- package/dist/dom/index.d.ts +0 -2
- package/dist/dom/index.js +0 -20
- package/dist/event/create-click-outside.d.ts +0 -8
- package/dist/event/create-click-outside.js +0 -17
- package/dist/event/create-event-listener.js +0 -17
- package/dist/event/create-intersection-observer.js +0 -16
- package/dist/event/create-visibility-observer.js +0 -16
- package/dist/event/index.d.ts +0 -8
- package/dist/event/index.js +0 -33
- package/dist/event/make-event-listener.js +0 -16
- package/dist/fn/create-debounce.d.ts +0 -6
- package/dist/fn/create-debounce.js +0 -15
- package/dist/fn/create-loop-exec.js +0 -15
- package/dist/fn/create-throttle.d.ts +0 -6
- package/dist/fn/create-throttle.js +0 -15
- package/dist/fn/index.d.ts +0 -9
- package/dist/fn/index.js +0 -21
- package/dist/index.d.ts +0 -27
- package/dist/index.js +0 -166
- package/dist/jsx/attrs.js +0 -6
- package/dist/jsx/index.d.ts +0 -1
- package/dist/jsx/index.js +0 -7
- package/dist/reactive/access.d.ts +0 -6
- package/dist/reactive/access.js +0 -13
- package/dist/reactive/create-debounce-watch.js +0 -15
- package/dist/reactive/create-watch.js +0 -6
- package/dist/reactive/index.d.ts +0 -5
- package/dist/reactive/index.js +0 -21
- package/dist/types/fn.js +0 -1
- package/dist/types/index.d.ts +0 -3
- package/dist/types/index.js +0 -3
- package/dist/types/maybe.js +0 -1
- package/dist/utils/array.js +0 -13
- package/dist/utils/async.d.ts +0 -6
- package/dist/utils/async.js +0 -6
- package/dist/utils/index.d.ts +0 -6
- package/dist/utils/index.js +0 -85
- package/dist/utils/is.js +0 -30
- package/dist/utils/number.js +0 -14
- package/dist/utils/object.d.ts +0 -10
- package/dist/utils/object.js +0 -7
- package/dist/utils/random.js +0 -14
- package/dist/utils/str.js +0 -20
package/dist/chunk-ACZGS7DG.js
DELETED
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
clamp,
|
|
3
|
-
max
|
|
4
|
-
} from "./chunk-PD6VHMH6.js";
|
|
5
|
-
|
|
6
|
-
// src/color/oklch-rgb.ts
|
|
7
|
-
var PI_180 = Math.PI / 180;
|
|
8
|
-
var INV_PI_180 = 180 / Math.PI;
|
|
9
|
-
var linearToSRGB = (x) => x <= 31308e-7 ? 12.92 * x : 1.055 * x ** (1 / 2.4) - 0.055;
|
|
10
|
-
var sRGBToLinear = (x) => x <= 0.04045 ? x / 12.92 : ((x + 0.055) / 1.055) ** 2.4;
|
|
11
|
-
function normalizeHue(hue) {
|
|
12
|
-
return (hue % 360 + 360) % 360;
|
|
13
|
-
}
|
|
14
|
-
function oklchToRgb(oklch) {
|
|
15
|
-
const { l, c, h } = oklch;
|
|
16
|
-
const clampedL = clamp(l, 0, 1);
|
|
17
|
-
const clampedC = max(0, c);
|
|
18
|
-
const normalizedH = normalizeHue(h);
|
|
19
|
-
const a_ = clampedC * Math.cos(normalizedH * PI_180);
|
|
20
|
-
const b_ = clampedC * Math.sin(normalizedH * PI_180);
|
|
21
|
-
const L = clampedL;
|
|
22
|
-
const A = a_;
|
|
23
|
-
const B = b_;
|
|
24
|
-
const l_ = L + 0.3963377774 * A + 0.2158037573 * B;
|
|
25
|
-
const m_ = L - 0.1055613458 * A - 0.0638541728 * B;
|
|
26
|
-
const s_ = L - 0.0894841775 * A - 1.291485548 * B;
|
|
27
|
-
const l3 = l_ ** 3;
|
|
28
|
-
const m3 = m_ ** 3;
|
|
29
|
-
const s3 = s_ ** 3;
|
|
30
|
-
let r = 4.0767416621 * l3 - 3.3077115913 * m3 + 0.2309699292 * s3;
|
|
31
|
-
let g = -1.2684380046 * l3 + 2.6097574011 * m3 - 0.3413193965 * s3;
|
|
32
|
-
let b = -0.0041960863 * l3 - 0.7034186147 * m3 + 1.707614701 * s3;
|
|
33
|
-
r = linearToSRGB(r);
|
|
34
|
-
g = linearToSRGB(g);
|
|
35
|
-
b = linearToSRGB(b);
|
|
36
|
-
return {
|
|
37
|
-
r: Math.round(clamp(r) * 255),
|
|
38
|
-
g: Math.round(clamp(g) * 255),
|
|
39
|
-
b: Math.round(clamp(b) * 255)
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
function rgbToOklch(rgb) {
|
|
43
|
-
const r = clamp(rgb.r, 0, 255);
|
|
44
|
-
const g = clamp(rgb.g, 0, 255);
|
|
45
|
-
const b = clamp(rgb.b, 0, 255);
|
|
46
|
-
const rLinear = sRGBToLinear(r / 255);
|
|
47
|
-
const gLinear = sRGBToLinear(g / 255);
|
|
48
|
-
const bLinear = sRGBToLinear(b / 255);
|
|
49
|
-
const l_ = Math.cbrt(
|
|
50
|
-
0.4122214708 * rLinear + 0.5363325363 * gLinear + 0.0514459929 * bLinear
|
|
51
|
-
);
|
|
52
|
-
const m_ = Math.cbrt(
|
|
53
|
-
0.2119034982 * rLinear + 0.6806995451 * gLinear + 0.1073969566 * bLinear
|
|
54
|
-
);
|
|
55
|
-
const s_ = Math.cbrt(
|
|
56
|
-
0.0883024619 * rLinear + 0.2817188376 * gLinear + 0.6299787005 * bLinear
|
|
57
|
-
);
|
|
58
|
-
const L = 0.2104542553 * l_ + 0.793617785 * m_ - 0.0040720468 * s_;
|
|
59
|
-
const A = 1.9779984951 * l_ - 2.428592205 * m_ + 0.4505937099 * s_;
|
|
60
|
-
const B = 0.0259040371 * l_ + 0.7827717662 * m_ - 0.808675766 * s_;
|
|
61
|
-
const c = Math.sqrt(A * A + B * B);
|
|
62
|
-
let h = Math.atan2(B, A) * INV_PI_180;
|
|
63
|
-
if (h < 0) {
|
|
64
|
-
h += 360;
|
|
65
|
-
}
|
|
66
|
-
return { l: L, c, h };
|
|
67
|
-
}
|
|
68
|
-
|
|
69
|
-
export {
|
|
70
|
-
oklchToRgb,
|
|
71
|
-
rgbToOklch
|
|
72
|
-
};
|
package/dist/chunk-AZAXMGEB.js
DELETED
|
File without changes
|
package/dist/chunk-BLX3XSA6.js
DELETED
|
File without changes
|
package/dist/chunk-BT47ISVC.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isFn
|
|
3
|
-
} from "./chunk-6G7GFZV2.js";
|
|
4
|
-
|
|
5
|
-
// src/utils/array.ts
|
|
6
|
-
var iterate = (count, func, initValue) => {
|
|
7
|
-
let value = initValue;
|
|
8
|
-
for (let i = 1; i <= count; i++) {
|
|
9
|
-
value = func(value, i);
|
|
10
|
-
}
|
|
11
|
-
return value;
|
|
12
|
-
};
|
|
13
|
-
function* range(startOrLength, end, valueOrMapper = (i) => i, step = 1) {
|
|
14
|
-
const mapper = isFn(valueOrMapper) ? valueOrMapper : () => valueOrMapper;
|
|
15
|
-
const start = end ? startOrLength : 0;
|
|
16
|
-
const final = end ?? startOrLength;
|
|
17
|
-
for (let i = start; i <= final; i += step) {
|
|
18
|
-
yield mapper(i);
|
|
19
|
-
if (i + step > final) {
|
|
20
|
-
break;
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
var list = (startOrLength, end, valueOrMapper, step) => {
|
|
25
|
-
return Array.from(range(startOrLength, end, valueOrMapper, step));
|
|
26
|
-
};
|
|
27
|
-
function clearArray(arr) {
|
|
28
|
-
arr.length = 0;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
iterate,
|
|
33
|
-
range,
|
|
34
|
-
list,
|
|
35
|
-
clearArray
|
|
36
|
-
};
|
package/dist/chunk-EZML2DEC.js
DELETED
|
File without changes
|
package/dist/chunk-FFBJP5FE.js
DELETED
|
File without changes
|
package/dist/chunk-II6INKPZ.js
DELETED
package/dist/chunk-KFLH3AZ6.js
DELETED
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isArray
|
|
3
|
-
} from "./chunk-6G7GFZV2.js";
|
|
4
|
-
import {
|
|
5
|
-
clamp,
|
|
6
|
-
toHex
|
|
7
|
-
} from "./chunk-PD6VHMH6.js";
|
|
8
|
-
|
|
9
|
-
// src/color/hex-rgb.ts
|
|
10
|
-
var HEX_PREFIX_REGEX = /^#/;
|
|
11
|
-
var HEX_VALIDATION_REGEX = /^[0-9a-fA-F]{6}$/;
|
|
12
|
-
function hexToRgb(hex) {
|
|
13
|
-
if (!hex || typeof hex !== "string") {
|
|
14
|
-
return null;
|
|
15
|
-
}
|
|
16
|
-
let value = hex.trim().replace(HEX_PREFIX_REGEX, "");
|
|
17
|
-
if (value.length === 3) {
|
|
18
|
-
value = value.split("").map((c) => c + c).join("");
|
|
19
|
-
}
|
|
20
|
-
if (!HEX_VALIDATION_REGEX.test(value)) {
|
|
21
|
-
return null;
|
|
22
|
-
}
|
|
23
|
-
const r = Number.parseInt(value.slice(0, 2), 16);
|
|
24
|
-
const g = Number.parseInt(value.slice(2, 4), 16);
|
|
25
|
-
const b = Number.parseInt(value.slice(4, 6), 16);
|
|
26
|
-
return { r, g, b };
|
|
27
|
-
}
|
|
28
|
-
function rgbToHex(rgb) {
|
|
29
|
-
const c = (v) => Math.round(clamp(v, 0, 255));
|
|
30
|
-
const rgb_ = isArray(rgb) ? rgb : [rgb.r, rgb.g, rgb.b];
|
|
31
|
-
const r = c(rgb_[0]);
|
|
32
|
-
const g = c(rgb_[1]);
|
|
33
|
-
const b = c(rgb_[2]);
|
|
34
|
-
return `#${toHex(r)}${toHex(g)}${toHex(b)}`;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
export {
|
|
38
|
-
hexToRgb,
|
|
39
|
-
rgbToHex
|
|
40
|
-
};
|
package/dist/chunk-KKFGUHFR.js
DELETED
package/dist/chunk-KM4Q6THD.js
DELETED
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
isClient
|
|
3
|
-
} from "./chunk-6G7GFZV2.js";
|
|
4
|
-
|
|
5
|
-
// src/dom/css.ts
|
|
6
|
-
var alreadyInjected = [];
|
|
7
|
-
function mountStyle(style, id, refresh = false) {
|
|
8
|
-
if (!isClient) {
|
|
9
|
-
return;
|
|
10
|
-
}
|
|
11
|
-
if (alreadyInjected.includes(id) && !refresh) {
|
|
12
|
-
return;
|
|
13
|
-
}
|
|
14
|
-
let styleElement = document.querySelector(`style#${id}`);
|
|
15
|
-
if (styleElement) {
|
|
16
|
-
styleElement.innerHTML = style;
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
styleElement = document.createElement("style");
|
|
20
|
-
styleElement.id = id;
|
|
21
|
-
styleElement.innerHTML = style;
|
|
22
|
-
document.head.appendChild(styleElement);
|
|
23
|
-
alreadyInjected.push(id);
|
|
24
|
-
}
|
|
25
|
-
var extractCSSregex = /((?:--)?(?:\w+-?)+)\s*:\s*([^;]*)/g;
|
|
26
|
-
function stringStyleToObject(style) {
|
|
27
|
-
const object = {};
|
|
28
|
-
let match = extractCSSregex.exec(style);
|
|
29
|
-
while (match) {
|
|
30
|
-
if (match[1] && match[2]) {
|
|
31
|
-
object[match[1]] = match[2];
|
|
32
|
-
}
|
|
33
|
-
match = extractCSSregex.exec(style);
|
|
34
|
-
}
|
|
35
|
-
return object;
|
|
36
|
-
}
|
|
37
|
-
function combineStyle(a, b) {
|
|
38
|
-
const bb = typeof b === "string" ? stringStyleToObject(b) : b;
|
|
39
|
-
return { ...a, ...bb };
|
|
40
|
-
}
|
|
41
|
-
function combineClass(defaultClass, ...otherClass) {
|
|
42
|
-
return [defaultClass, ...otherClass].filter(Boolean).join(" ");
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
mountStyle,
|
|
47
|
-
stringStyleToObject,
|
|
48
|
-
combineStyle,
|
|
49
|
-
combineClass
|
|
50
|
-
};
|
package/dist/chunk-LEWF7QAQ.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
noop
|
|
3
|
-
} from "./chunk-QPEF6LHH.js";
|
|
4
|
-
import {
|
|
5
|
-
access
|
|
6
|
-
} from "./chunk-YK5QQQ43.js";
|
|
7
|
-
import {
|
|
8
|
-
createWatch
|
|
9
|
-
} from "./chunk-4L6FK7MF.js";
|
|
10
|
-
import {
|
|
11
|
-
clearArray
|
|
12
|
-
} from "./chunk-BT47ISVC.js";
|
|
13
|
-
|
|
14
|
-
// src/event/create-intersection-observer.ts
|
|
15
|
-
import { onCleanup } from "solid-js";
|
|
16
|
-
import { isServer } from "solid-js/web";
|
|
17
|
-
function createIntersectionObserver(targets, callback, options = {}) {
|
|
18
|
-
if (isServer) {
|
|
19
|
-
return noop;
|
|
20
|
-
}
|
|
21
|
-
const io = new IntersectionObserver(callback, options);
|
|
22
|
-
onCleanup(() => io.disconnect());
|
|
23
|
-
const cleanups = [];
|
|
24
|
-
const cleanup = () => {
|
|
25
|
-
for (const c of cleanups) {
|
|
26
|
-
c();
|
|
27
|
-
}
|
|
28
|
-
clearArray(cleanups);
|
|
29
|
-
};
|
|
30
|
-
createWatch(
|
|
31
|
-
() => targets.map(access),
|
|
32
|
-
(elements) => {
|
|
33
|
-
cleanup();
|
|
34
|
-
for (const element of elements) {
|
|
35
|
-
if (element) {
|
|
36
|
-
io.observe(element);
|
|
37
|
-
cleanups.push(() => io.unobserve(element));
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
return () => io.disconnect();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
export {
|
|
46
|
-
createIntersectionObserver
|
|
47
|
-
};
|
package/dist/chunk-LUFOWTRW.js
DELETED
|
File without changes
|
package/dist/chunk-PD6VHMH6.js
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
// src/utils/number.ts
|
|
2
|
-
function min(...numbers) {
|
|
3
|
-
return Math.min(...numbers);
|
|
4
|
-
}
|
|
5
|
-
function max(...numbers) {
|
|
6
|
-
return Math.max(...numbers);
|
|
7
|
-
}
|
|
8
|
-
function clamp(x, minimum = 0, maximum = 1) {
|
|
9
|
-
return min(maximum, max(minimum, x));
|
|
10
|
-
}
|
|
11
|
-
function inRange(x, minimum = 0, maximum = 1, inclusivity = "[]") {
|
|
12
|
-
const minCheck = inclusivity[0] === "[" ? x >= minimum : x > minimum;
|
|
13
|
-
const maxCheck = inclusivity[1] === "]" ? x <= maximum : x < maximum;
|
|
14
|
-
return minCheck && maxCheck;
|
|
15
|
-
}
|
|
16
|
-
function toHex(x, pad = 2) {
|
|
17
|
-
return x.toString(16).padStart(pad, "0");
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
export {
|
|
21
|
-
min,
|
|
22
|
-
max,
|
|
23
|
-
clamp,
|
|
24
|
-
inRange,
|
|
25
|
-
toHex
|
|
26
|
-
};
|
package/dist/chunk-QPEF6LHH.js
DELETED
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
access
|
|
3
|
-
} from "./chunk-YK5QQQ43.js";
|
|
4
|
-
import {
|
|
5
|
-
createWatch
|
|
6
|
-
} from "./chunk-4L6FK7MF.js";
|
|
7
|
-
import {
|
|
8
|
-
isNumber
|
|
9
|
-
} from "./chunk-6G7GFZV2.js";
|
|
10
|
-
|
|
11
|
-
// src/fn/create-debounce.ts
|
|
12
|
-
import { onCleanup as onCleanup3 } from "solid-js";
|
|
13
|
-
|
|
14
|
-
// src/fn/create-loop-exec.ts
|
|
15
|
-
import { onCleanup } from "solid-js";
|
|
16
|
-
function createLoopExec(fn, delay) {
|
|
17
|
-
let shouldStop = false;
|
|
18
|
-
let isCleanedUp = false;
|
|
19
|
-
let timer;
|
|
20
|
-
const execFn = async () => {
|
|
21
|
-
clearTimeout(timer);
|
|
22
|
-
const d = access(delay);
|
|
23
|
-
if (shouldStop || !isNumber(d) || d < 0) {
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
try {
|
|
27
|
-
await fn();
|
|
28
|
-
} finally {
|
|
29
|
-
timer = setTimeout(() => {
|
|
30
|
-
execFn();
|
|
31
|
-
}, d);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
-
createWatch(
|
|
35
|
-
() => access(delay),
|
|
36
|
-
() => {
|
|
37
|
-
execFn();
|
|
38
|
-
}
|
|
39
|
-
);
|
|
40
|
-
const stop = () => {
|
|
41
|
-
shouldStop = true;
|
|
42
|
-
clearTimeout(timer);
|
|
43
|
-
};
|
|
44
|
-
const start = () => {
|
|
45
|
-
if (isCleanedUp) {
|
|
46
|
-
return;
|
|
47
|
-
}
|
|
48
|
-
shouldStop = false;
|
|
49
|
-
execFn();
|
|
50
|
-
};
|
|
51
|
-
onCleanup(() => {
|
|
52
|
-
isCleanedUp = true;
|
|
53
|
-
stop();
|
|
54
|
-
});
|
|
55
|
-
return {
|
|
56
|
-
stop,
|
|
57
|
-
start
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
// src/fn/create-throttle.ts
|
|
62
|
-
import { onCleanup as onCleanup2 } from "solid-js";
|
|
63
|
-
function createThrottle(callback, delay) {
|
|
64
|
-
let timeoutId;
|
|
65
|
-
onCleanup2(() => {
|
|
66
|
-
clearTimeout(timeoutId);
|
|
67
|
-
});
|
|
68
|
-
const run = (...args) => {
|
|
69
|
-
if (timeoutId) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
timeoutId = setTimeout(() => {
|
|
73
|
-
callback(...args);
|
|
74
|
-
timeoutId = void 0;
|
|
75
|
-
}, access(delay));
|
|
76
|
-
};
|
|
77
|
-
return run;
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
// src/fn/index.ts
|
|
81
|
-
var noop = () => {
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
// src/reactive/create-debounce-watch.ts
|
|
85
|
-
function createDebouncedWatch(targets, fn, opt) {
|
|
86
|
-
const debounceFn = createDebounce(fn, opt?.delay ?? 10);
|
|
87
|
-
createWatch(targets, debounceFn, opt);
|
|
88
|
-
}
|
|
89
|
-
|
|
90
|
-
// src/fn/create-debounce.ts
|
|
91
|
-
function createDebounce(callback, delay) {
|
|
92
|
-
let timeoutId;
|
|
93
|
-
onCleanup3(() => {
|
|
94
|
-
clearTimeout(timeoutId);
|
|
95
|
-
});
|
|
96
|
-
const run = (...args) => {
|
|
97
|
-
clearTimeout(timeoutId);
|
|
98
|
-
timeoutId = setTimeout(() => {
|
|
99
|
-
callback(...args);
|
|
100
|
-
}, access(delay));
|
|
101
|
-
};
|
|
102
|
-
return run;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
export {
|
|
106
|
-
createDebounce,
|
|
107
|
-
createLoopExec,
|
|
108
|
-
createThrottle,
|
|
109
|
-
noop,
|
|
110
|
-
createDebouncedWatch
|
|
111
|
-
};
|
package/dist/chunk-QQVSG76Z.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
iterate
|
|
3
|
-
} from "./chunk-BT47ISVC.js";
|
|
4
|
-
|
|
5
|
-
// src/utils/random.ts
|
|
6
|
-
var random = (min, max) => {
|
|
7
|
-
return Math.floor(Math.random() * (max - min + 1) + min);
|
|
8
|
-
};
|
|
9
|
-
var draw = (array) => {
|
|
10
|
-
const max = array.length;
|
|
11
|
-
if (max === 0) {
|
|
12
|
-
return null;
|
|
13
|
-
}
|
|
14
|
-
const index = random(0, max - 1);
|
|
15
|
-
return array[index];
|
|
16
|
-
};
|
|
17
|
-
var shuffle = (array) => {
|
|
18
|
-
return array.map((a) => ({ rand: Math.random(), value: a })).sort((a, b) => a.rand - b.rand).map((a) => a.value);
|
|
19
|
-
};
|
|
20
|
-
var uid = (length, specials = "") => {
|
|
21
|
-
const characters = `ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789${specials}`;
|
|
22
|
-
return iterate(
|
|
23
|
-
length,
|
|
24
|
-
(acc) => {
|
|
25
|
-
return acc + characters.charAt(random(0, characters.length - 1));
|
|
26
|
-
},
|
|
27
|
-
""
|
|
28
|
-
);
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
export {
|
|
32
|
-
random,
|
|
33
|
-
draw,
|
|
34
|
-
shuffle,
|
|
35
|
-
uid
|
|
36
|
-
};
|
package/dist/chunk-S7U3LZNS.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
hexToRgb
|
|
3
|
-
} from "./chunk-KFLH3AZ6.js";
|
|
4
|
-
import {
|
|
5
|
-
inRange
|
|
6
|
-
} from "./chunk-PD6VHMH6.js";
|
|
7
|
-
|
|
8
|
-
// src/color/validation.ts
|
|
9
|
-
function isValidRGB(rgb) {
|
|
10
|
-
return Object.values(rgb).every((x) => inRange(x, 0, 255));
|
|
11
|
-
}
|
|
12
|
-
function isValidOKLCH(oklch) {
|
|
13
|
-
return inRange(oklch.l) && oklch.c >= 0 && inRange(oklch.h, 0, 360);
|
|
14
|
-
}
|
|
15
|
-
function isValidHex(hex) {
|
|
16
|
-
return hexToRgb(hex) !== null;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
export {
|
|
20
|
-
isValidRGB,
|
|
21
|
-
isValidOKLCH,
|
|
22
|
-
isValidHex
|
|
23
|
-
};
|
package/dist/chunk-SK6Y2YH6.js
DELETED
|
File without changes
|
package/dist/chunk-TDJLPDJF.js
DELETED
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
access
|
|
3
|
-
} from "./chunk-YK5QQQ43.js";
|
|
4
|
-
import {
|
|
5
|
-
createWatch
|
|
6
|
-
} from "./chunk-4L6FK7MF.js";
|
|
7
|
-
import {
|
|
8
|
-
isObject
|
|
9
|
-
} from "./chunk-6G7GFZV2.js";
|
|
10
|
-
|
|
11
|
-
// src/event/create-visibility-observer.ts
|
|
12
|
-
import { createSignal, onCleanup } from "solid-js";
|
|
13
|
-
function createVisibilityObserver(arg1, arg2) {
|
|
14
|
-
let target;
|
|
15
|
-
let options;
|
|
16
|
-
if (arg1 && !isObject(arg1)) {
|
|
17
|
-
target = arg1;
|
|
18
|
-
options = arg2 ?? {};
|
|
19
|
-
} else {
|
|
20
|
-
options = arg1 ?? {};
|
|
21
|
-
}
|
|
22
|
-
const callbacks = /* @__PURE__ */ new WeakMap();
|
|
23
|
-
const io = new IntersectionObserver((entries, instance) => {
|
|
24
|
-
for (const entry of entries) {
|
|
25
|
-
callbacks.get(entry.target)?.(entry, instance);
|
|
26
|
-
}
|
|
27
|
-
}, options);
|
|
28
|
-
onCleanup(() => io.disconnect());
|
|
29
|
-
const addEntry = (el, callback) => {
|
|
30
|
-
io.observe(el);
|
|
31
|
-
callbacks.set(el, callback);
|
|
32
|
-
};
|
|
33
|
-
const removeEntry = (el) => {
|
|
34
|
-
io.unobserve(el);
|
|
35
|
-
callbacks.delete(el);
|
|
36
|
-
};
|
|
37
|
-
const useVisibilityObserverFn = (element) => {
|
|
38
|
-
const [isVisible, setVisible] = createSignal(
|
|
39
|
-
options?.initialValue ?? false
|
|
40
|
-
);
|
|
41
|
-
let prevEl;
|
|
42
|
-
createWatch(
|
|
43
|
-
() => access(element),
|
|
44
|
-
(el) => {
|
|
45
|
-
if (prevEl) {
|
|
46
|
-
removeEntry(prevEl);
|
|
47
|
-
}
|
|
48
|
-
if (el) {
|
|
49
|
-
addEntry(el, (entry) => {
|
|
50
|
-
setVisible(entry.isIntersecting);
|
|
51
|
-
});
|
|
52
|
-
prevEl = el;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
);
|
|
56
|
-
return isVisible;
|
|
57
|
-
};
|
|
58
|
-
if (target) {
|
|
59
|
-
return useVisibilityObserverFn(target);
|
|
60
|
-
}
|
|
61
|
-
return useVisibilityObserverFn;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export {
|
|
65
|
-
createVisibilityObserver
|
|
66
|
-
};
|
package/dist/chunk-TGWWPUWD.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
noop
|
|
3
|
-
} from "./chunk-QPEF6LHH.js";
|
|
4
|
-
import {
|
|
5
|
-
clearArray
|
|
6
|
-
} from "./chunk-BT47ISVC.js";
|
|
7
|
-
import {
|
|
8
|
-
isArray
|
|
9
|
-
} from "./chunk-6G7GFZV2.js";
|
|
10
|
-
|
|
11
|
-
// src/event/make-event-listener.ts
|
|
12
|
-
import { onCleanup } from "solid-js";
|
|
13
|
-
function makeEventListener(...args) {
|
|
14
|
-
let target;
|
|
15
|
-
let events;
|
|
16
|
-
let listeners;
|
|
17
|
-
let options;
|
|
18
|
-
if (typeof args[0] === "string" || isArray(args[0])) {
|
|
19
|
-
[events, listeners, options] = args;
|
|
20
|
-
target = window;
|
|
21
|
-
} else {
|
|
22
|
-
[target, events, listeners, options] = args;
|
|
23
|
-
}
|
|
24
|
-
if (!target) {
|
|
25
|
-
return noop;
|
|
26
|
-
}
|
|
27
|
-
if (!isArray(events)) {
|
|
28
|
-
events = [events];
|
|
29
|
-
}
|
|
30
|
-
if (!isArray(listeners)) {
|
|
31
|
-
listeners = [listeners];
|
|
32
|
-
}
|
|
33
|
-
const cleanups = [];
|
|
34
|
-
const cleanup = () => {
|
|
35
|
-
for (const c of cleanups) {
|
|
36
|
-
c();
|
|
37
|
-
}
|
|
38
|
-
clearArray(cleanups);
|
|
39
|
-
};
|
|
40
|
-
const register = (el, event, listener, opts) => {
|
|
41
|
-
el.addEventListener(event, listener, opts);
|
|
42
|
-
return () => el.removeEventListener(event, listener, opts);
|
|
43
|
-
};
|
|
44
|
-
cleanups.push(
|
|
45
|
-
...events.flatMap(
|
|
46
|
-
(event) => listeners.map((listener) => register(target, event, listener, options))
|
|
47
|
-
)
|
|
48
|
-
);
|
|
49
|
-
onCleanup(cleanup);
|
|
50
|
-
return cleanup;
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export {
|
|
54
|
-
makeEventListener
|
|
55
|
-
};
|
package/dist/chunk-U5LQ2AS5.js
DELETED
|
File without changes
|
package/dist/chunk-WJHRONQU.js
DELETED
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
makeEventListener
|
|
3
|
-
} from "./chunk-TGWWPUWD.js";
|
|
4
|
-
import {
|
|
5
|
-
access
|
|
6
|
-
} from "./chunk-YK5QQQ43.js";
|
|
7
|
-
|
|
8
|
-
// src/event/create-click-outside.ts
|
|
9
|
-
function createClickOutside(target, handler, options) {
|
|
10
|
-
let shouldListen = false;
|
|
11
|
-
const shouldIgnore = (event) => {
|
|
12
|
-
const ignore = (options?.ignore ? options.ignore : []).map(access);
|
|
13
|
-
return ignore.some((el) => {
|
|
14
|
-
return el && (event.target === el || event.composedPath().includes(el));
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
const listener = (e) => {
|
|
18
|
-
const el = access(target);
|
|
19
|
-
if (!el || el === e.target || e.composedPath().includes(el)) {
|
|
20
|
-
return;
|
|
21
|
-
}
|
|
22
|
-
if (e.detail === 0) {
|
|
23
|
-
shouldListen = !shouldIgnore(e);
|
|
24
|
-
}
|
|
25
|
-
if (!shouldListen) {
|
|
26
|
-
shouldListen = true;
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
handler(e);
|
|
30
|
-
};
|
|
31
|
-
const cleanups = [
|
|
32
|
-
makeEventListener("click", listener, { passive: true }),
|
|
33
|
-
makeEventListener(
|
|
34
|
-
"pointerdown",
|
|
35
|
-
(e) => {
|
|
36
|
-
const el = access(target);
|
|
37
|
-
if (el) {
|
|
38
|
-
shouldListen = !(e.composedPath().includes(el) || shouldIgnore(e));
|
|
39
|
-
}
|
|
40
|
-
},
|
|
41
|
-
{ passive: true }
|
|
42
|
-
)
|
|
43
|
-
];
|
|
44
|
-
const stop = () => {
|
|
45
|
-
for (const cleanup of cleanups) {
|
|
46
|
-
cleanup();
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
return stop;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
export {
|
|
53
|
-
createClickOutside
|
|
54
|
-
};
|