@stacksjs/browser 0.70.87 → 0.70.88
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/package.json +3 -3
- package/dist/auto-init.d.ts +0 -7
- package/dist/auto-init.js +0 -61
- package/dist/composables/auth/useGithub.d.ts +0 -12
- package/dist/composables/auth/useGithub.js +0 -41
- package/dist/composables/index.d.ts +0 -140
- package/dist/composables/index.js +0 -110
- package/dist/composables/useApi.d.ts +0 -56
- package/dist/composables/useApi.js +0 -66
- package/dist/composables/useAuth.d.ts +0 -6
- package/dist/composables/useAuth.js +0 -127
- package/dist/composables/useFetch.d.ts +0 -1
- package/dist/composables/useFetch.js +0 -1
- package/dist/index.d.ts +0 -32
- package/dist/index.js +0 -16
- package/dist/model-loader.d.ts +0 -84
- package/dist/model-loader.js +0 -61
- package/dist/types/dashboard.d.ts +0 -69
- package/dist/types/dashboard.js +0 -3
- package/dist/utils/base.d.ts +0 -7
- package/dist/utils/base.js +0 -4
- package/dist/utils/billable.d.ts +0 -7
- package/dist/utils/billable.js +0 -72
- package/dist/utils/date.d.ts +0 -2
- package/dist/utils/date.js +0 -2
- package/dist/utils/debounce.d.ts +0 -5
- package/dist/utils/debounce.js +0 -43
- package/dist/utils/fetch.d.ts +0 -33
- package/dist/utils/fetch.js +0 -94
- package/dist/utils/function.d.ts +0 -18
- package/dist/utils/function.js +0 -7
- package/dist/utils/guards.d.ts +0 -28
- package/dist/utils/guards.js +0 -12
- package/dist/utils/index.d.ts +0 -17
- package/dist/utils/index.js +0 -17
- package/dist/utils/lazy.d.ts +0 -6
- package/dist/utils/lazy.js +0 -9
- package/dist/utils/math.d.ts +0 -20
- package/dist/utils/math.js +0 -23
- package/dist/utils/plans.d.ts +0 -2
- package/dist/utils/plans.js +0 -135
- package/dist/utils/promise.d.ts +0 -49
- package/dist/utils/promise.js +0 -55
- package/dist/utils/random.d.ts +0 -10
- package/dist/utils/random.js +0 -67
- package/dist/utils/regex.d.ts +0 -38
- package/dist/utils/regex.js +0 -29
- package/dist/utils/retry.d.ts +0 -10
- package/dist/utils/retry.js +0 -28
- package/dist/utils/sleep.d.ts +0 -35
- package/dist/utils/sleep.js +0 -59
- package/dist/utils/throttle.d.ts +0 -20
- package/dist/utils/throttle.js +0 -18
- package/dist/utils/vendors.d.ts +0 -29
- package/dist/utils/vendors.js +0 -37
package/dist/utils/math.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export const clamp = (n, min, max) => Math.min(max, Math.max(min, n));
|
|
2
|
-
export function rand(min, max) {
|
|
3
|
-
min = Math.ceil(min);
|
|
4
|
-
max = Math.floor(max);
|
|
5
|
-
return Math.floor(Math.random() * (max - min + 1)) + min;
|
|
6
|
-
}
|
|
7
|
-
export {
|
|
8
|
-
and,
|
|
9
|
-
logicNot,
|
|
10
|
-
logicOr,
|
|
11
|
-
or,
|
|
12
|
-
useAbs,
|
|
13
|
-
useAverage,
|
|
14
|
-
useCeil,
|
|
15
|
-
useClamp,
|
|
16
|
-
useFloor,
|
|
17
|
-
useMax,
|
|
18
|
-
useMin,
|
|
19
|
-
usePrecision,
|
|
20
|
-
useRound,
|
|
21
|
-
useSum,
|
|
22
|
-
useTrunc
|
|
23
|
-
} from "@stacksjs/composables";
|
package/dist/utils/plans.d.ts
DELETED
package/dist/utils/plans.js
DELETED
|
@@ -1,135 +0,0 @@
|
|
|
1
|
-
export const saas = {
|
|
2
|
-
plans: [
|
|
3
|
-
{
|
|
4
|
-
productName: "Stacks Hobby",
|
|
5
|
-
description: "All the Stacks features.",
|
|
6
|
-
pricing: [
|
|
7
|
-
{
|
|
8
|
-
key: "stacks_hobby_early_monthly",
|
|
9
|
-
price: 1900,
|
|
10
|
-
interval: "month",
|
|
11
|
-
currency: "usd"
|
|
12
|
-
},
|
|
13
|
-
{
|
|
14
|
-
key: "stacks_hobby_launch_monthly",
|
|
15
|
-
price: 2900,
|
|
16
|
-
interval: "month",
|
|
17
|
-
currency: "usd"
|
|
18
|
-
},
|
|
19
|
-
{
|
|
20
|
-
key: "stacks_hobby_monthly",
|
|
21
|
-
price: 3900,
|
|
22
|
-
interval: "month",
|
|
23
|
-
currency: "usd"
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
key: "stacks_hobby_yearly",
|
|
27
|
-
price: 37900,
|
|
28
|
-
interval: "year",
|
|
29
|
-
currency: "usd"
|
|
30
|
-
}
|
|
31
|
-
],
|
|
32
|
-
metadata: {
|
|
33
|
-
createdBy: "admin",
|
|
34
|
-
version: "1.0.0"
|
|
35
|
-
}
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
productName: "Stacks Pro",
|
|
39
|
-
description: "All the Stacks features, including being able to invite team members.",
|
|
40
|
-
pricing: [
|
|
41
|
-
{
|
|
42
|
-
key: "stacks_pro_early_monthly",
|
|
43
|
-
price: 3900,
|
|
44
|
-
interval: "month",
|
|
45
|
-
currency: "usd"
|
|
46
|
-
},
|
|
47
|
-
{
|
|
48
|
-
key: "stacks_pro_monthly",
|
|
49
|
-
price: 5900,
|
|
50
|
-
interval: "month",
|
|
51
|
-
currency: "usd"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
key: "stacks_pro_yearly",
|
|
55
|
-
price: 57900,
|
|
56
|
-
interval: "year",
|
|
57
|
-
currency: "usd"
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
key: "stacks_pro_early_yearly",
|
|
61
|
-
price: 39000,
|
|
62
|
-
interval: "year",
|
|
63
|
-
currency: "usd"
|
|
64
|
-
}
|
|
65
|
-
],
|
|
66
|
-
metadata: {
|
|
67
|
-
createdBy: "admin",
|
|
68
|
-
version: "1.0.0"
|
|
69
|
-
}
|
|
70
|
-
},
|
|
71
|
-
{
|
|
72
|
-
productName: "Stacks Lifetime",
|
|
73
|
-
description: "One-time lifetime access to all Stacks features.",
|
|
74
|
-
pricing: [
|
|
75
|
-
{
|
|
76
|
-
key: "stacks_hobby_early_lifetime",
|
|
77
|
-
price: 17900,
|
|
78
|
-
currency: "usd"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
key: "stacks_hobby_launch_lifetime",
|
|
82
|
-
price: 27900,
|
|
83
|
-
currency: "usd"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
key: "stacks_hobby_lifetime",
|
|
87
|
-
price: 47900,
|
|
88
|
-
currency: "usd"
|
|
89
|
-
},
|
|
90
|
-
{
|
|
91
|
-
key: "stacks_pro_early_lifetime",
|
|
92
|
-
price: 27900,
|
|
93
|
-
currency: "usd"
|
|
94
|
-
},
|
|
95
|
-
{
|
|
96
|
-
key: "stacks_pro_launch_lifetime",
|
|
97
|
-
price: 37900,
|
|
98
|
-
currency: "usd"
|
|
99
|
-
},
|
|
100
|
-
{
|
|
101
|
-
key: "stacks_pro_lifetime",
|
|
102
|
-
price: 74900,
|
|
103
|
-
currency: "usd"
|
|
104
|
-
}
|
|
105
|
-
],
|
|
106
|
-
metadata: {
|
|
107
|
-
createdBy: "admin",
|
|
108
|
-
version: "1.0.0"
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
],
|
|
112
|
-
webhook: {
|
|
113
|
-
endpoint: "your-webhook-endpoint",
|
|
114
|
-
secret: "your-webhook-secret"
|
|
115
|
-
},
|
|
116
|
-
currencies: ["usd"],
|
|
117
|
-
coupons: [],
|
|
118
|
-
products: [
|
|
119
|
-
{
|
|
120
|
-
name: "Stacks Hobby",
|
|
121
|
-
description: "All the Stacks features.",
|
|
122
|
-
images: ["image-url"]
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
name: "Stacks Pro",
|
|
126
|
-
description: "All the Stacks features, including team invites.",
|
|
127
|
-
images: ["image-url"]
|
|
128
|
-
},
|
|
129
|
-
{
|
|
130
|
-
name: "Stacks Lifetime",
|
|
131
|
-
description: "Lifetime access to Stacks features.",
|
|
132
|
-
images: ["image-url"]
|
|
133
|
-
}
|
|
134
|
-
]
|
|
135
|
-
};
|
package/dist/utils/promise.d.ts
DELETED
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Create singleton promise function.
|
|
3
|
-
*
|
|
4
|
-
* @category Promise
|
|
5
|
-
*/
|
|
6
|
-
export declare function createSingletonPromise<T>(fn: () => Promise<T>): SingletonPromiseReturn<T>;
|
|
7
|
-
/**
|
|
8
|
-
* Create a promise lock.
|
|
9
|
-
*
|
|
10
|
-
* @category Promise
|
|
11
|
-
* @example
|
|
12
|
-
* ```
|
|
13
|
-
* const lock = createPromiseLock()
|
|
14
|
-
*
|
|
15
|
-
* lock.run(async () => {
|
|
16
|
-
* await doSomething()
|
|
17
|
-
* })
|
|
18
|
-
*
|
|
19
|
-
* // in anther context:
|
|
20
|
-
* await lock.wait() // it will wait all tasking finished
|
|
21
|
-
* ```
|
|
22
|
-
*/
|
|
23
|
-
export declare function createPromiseLock(): void;
|
|
24
|
-
/**
|
|
25
|
-
* Return a Promise with `resolve` and `reject` methods
|
|
26
|
-
*
|
|
27
|
-
* @category Promise
|
|
28
|
-
* @example
|
|
29
|
-
* ```
|
|
30
|
-
* const promise = createControlledPromise()
|
|
31
|
-
*
|
|
32
|
-
* await promise
|
|
33
|
-
*
|
|
34
|
-
* // in anther context:
|
|
35
|
-
* promise.resolve(data)
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare function createControlledPromise<T>(): ControlledPromise<T>;
|
|
39
|
-
export declare interface SingletonPromiseReturn<T> {
|
|
40
|
-
(): Promise<T>
|
|
41
|
-
reset: () => Promise<void>
|
|
42
|
-
}
|
|
43
|
-
/**
|
|
44
|
-
* Promise with `resolve` and `reject` methods of itself
|
|
45
|
-
*/
|
|
46
|
-
export declare interface ControlledPromise<T = void> extends Promise<T> {
|
|
47
|
-
resolve: (value: T | PromiseLike<T>) => void
|
|
48
|
-
reject: (reason?: any) => void
|
|
49
|
-
}
|
package/dist/utils/promise.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
export function createSingletonPromise(fn) {
|
|
2
|
-
let _promise;
|
|
3
|
-
function wrapper() {
|
|
4
|
-
if (!_promise)
|
|
5
|
-
_promise = fn();
|
|
6
|
-
return _promise;
|
|
7
|
-
}
|
|
8
|
-
wrapper.reset = async () => {
|
|
9
|
-
const _prev = _promise;
|
|
10
|
-
_promise = void 0;
|
|
11
|
-
if (_prev)
|
|
12
|
-
await _prev;
|
|
13
|
-
};
|
|
14
|
-
return wrapper;
|
|
15
|
-
}
|
|
16
|
-
export function createPromiseLock() {
|
|
17
|
-
let currentPromise = Promise.resolve();
|
|
18
|
-
const queue = [];
|
|
19
|
-
return {
|
|
20
|
-
async run(fn) {
|
|
21
|
-
const taskPromise = (async () => {
|
|
22
|
-
await currentPromise;
|
|
23
|
-
return fn();
|
|
24
|
-
})();
|
|
25
|
-
queue.push(taskPromise);
|
|
26
|
-
currentPromise = taskPromise.catch(() => {}).finally(() => {
|
|
27
|
-
const index = queue.indexOf(taskPromise);
|
|
28
|
-
if (index > -1)
|
|
29
|
-
queue.splice(index, 1);
|
|
30
|
-
});
|
|
31
|
-
return taskPromise;
|
|
32
|
-
},
|
|
33
|
-
async wait() {
|
|
34
|
-
while (queue.length > 0)
|
|
35
|
-
await Promise.all(queue);
|
|
36
|
-
},
|
|
37
|
-
isWaiting() {
|
|
38
|
-
return queue.length > 0;
|
|
39
|
-
},
|
|
40
|
-
clear() {
|
|
41
|
-
queue.length = 0;
|
|
42
|
-
currentPromise = Promise.resolve();
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
}
|
|
46
|
-
export function createControlledPromise() {
|
|
47
|
-
let resolve, reject;
|
|
48
|
-
const promise = new Promise((_resolve, _reject) => {
|
|
49
|
-
resolve = _resolve;
|
|
50
|
-
reject = _reject;
|
|
51
|
-
});
|
|
52
|
-
promise.resolve = resolve;
|
|
53
|
-
promise.reject = reject;
|
|
54
|
-
return promise;
|
|
55
|
-
}
|
package/dist/utils/random.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
declare function customRandom(alphabet: string, defaultSize: number, getRandom: (bytes: number) => Uint8Array): void;
|
|
2
|
-
declare function customAlphabet(alphabet: string, size?: number): (size?: number) => string;
|
|
3
|
-
declare function randomNonSecure(size?: number): string;
|
|
4
|
-
declare function random(size?: number): string;
|
|
5
|
-
export {
|
|
6
|
-
customAlphabet,
|
|
7
|
-
customRandom,
|
|
8
|
-
random,
|
|
9
|
-
randomNonSecure,
|
|
10
|
-
};
|
package/dist/utils/random.js
DELETED
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
const POOL_SIZE_MULTIPLIER = 128;
|
|
2
|
-
let pool = null, poolOffset = 0;
|
|
3
|
-
const urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
4
|
-
function fillPool(bytes) {
|
|
5
|
-
if (!pool || pool.length < bytes) {
|
|
6
|
-
pool = new Uint8Array(bytes * POOL_SIZE_MULTIPLIER);
|
|
7
|
-
globalThis.crypto.getRandomValues(pool);
|
|
8
|
-
poolOffset = 0;
|
|
9
|
-
} else if (poolOffset + bytes > pool.length) {
|
|
10
|
-
globalThis.crypto.getRandomValues(pool);
|
|
11
|
-
poolOffset = 0;
|
|
12
|
-
}
|
|
13
|
-
poolOffset += bytes;
|
|
14
|
-
}
|
|
15
|
-
function randomPool(bytes) {
|
|
16
|
-
fillPool(bytes |= 0);
|
|
17
|
-
if (!pool)
|
|
18
|
-
throw Error("Pool is not initialized");
|
|
19
|
-
return pool.subarray(poolOffset - bytes, poolOffset);
|
|
20
|
-
}
|
|
21
|
-
function customRandom(alphabet, defaultSize, getRandom) {
|
|
22
|
-
const mask = (2 << 31 - Math.clz32(alphabet.length - 1 | 1)) - 1, step = Math.ceil(1.6 * mask * defaultSize / alphabet.length);
|
|
23
|
-
return (size = defaultSize) => {
|
|
24
|
-
let id = "";
|
|
25
|
-
while (!0) {
|
|
26
|
-
const bytes = getRandom(step);
|
|
27
|
-
let i = step;
|
|
28
|
-
while (i--) {
|
|
29
|
-
const byte = bytes[i];
|
|
30
|
-
if (byte === void 0)
|
|
31
|
-
continue;
|
|
32
|
-
id += alphabet[byte & mask] || "";
|
|
33
|
-
if (id.length >= size)
|
|
34
|
-
return id;
|
|
35
|
-
}
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
}
|
|
39
|
-
function customAlphabet(alphabet, size = 21) {
|
|
40
|
-
return customRandom(alphabet, size, randomPool);
|
|
41
|
-
}
|
|
42
|
-
function randomNonSecure(size = 21) {
|
|
43
|
-
let id = "", i = size | 0;
|
|
44
|
-
while (i--)
|
|
45
|
-
id += urlAlphabet[Math.random() * 64 | 0];
|
|
46
|
-
return id;
|
|
47
|
-
}
|
|
48
|
-
function random(size = 21) {
|
|
49
|
-
fillPool(size |= 0);
|
|
50
|
-
if (!pool)
|
|
51
|
-
return "";
|
|
52
|
-
let id = "";
|
|
53
|
-
for (let i = poolOffset - size;i < poolOffset; i++) {
|
|
54
|
-
const byte = pool[i];
|
|
55
|
-
if (byte === void 0)
|
|
56
|
-
continue;
|
|
57
|
-
id += urlAlphabet[byte & 63];
|
|
58
|
-
}
|
|
59
|
-
return id;
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export {
|
|
63
|
-
customAlphabet,
|
|
64
|
-
customRandom,
|
|
65
|
-
random,
|
|
66
|
-
randomNonSecure
|
|
67
|
-
};
|
package/dist/utils/regex.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
Flag,
|
|
3
|
-
Input,
|
|
4
|
-
MagicRegExp,
|
|
5
|
-
MagicRegExpMatchArray,
|
|
6
|
-
MapToStringCapturedBy,
|
|
7
|
-
StringCapturedBy,
|
|
8
|
-
} from 'magic-regexp';
|
|
9
|
-
// export function caseInsensitive(pattern: string): RegExp {
|
|
10
|
-
// return new RegExp(pattern, 'i')
|
|
11
|
-
// }
|
|
12
|
-
export declare function createRegExp(pattern: string, options?: { flags?: string }): RegExp;
|
|
13
|
-
export {
|
|
14
|
-
anyOf,
|
|
15
|
-
carriageReturn,
|
|
16
|
-
caseInsensitive,
|
|
17
|
-
char,
|
|
18
|
-
charIn,
|
|
19
|
-
charNotIn,
|
|
20
|
-
digit,
|
|
21
|
-
dotAll,
|
|
22
|
-
exactly,
|
|
23
|
-
global,
|
|
24
|
-
letter,
|
|
25
|
-
linefeed,
|
|
26
|
-
maybe,
|
|
27
|
-
multiline,
|
|
28
|
-
not,
|
|
29
|
-
oneOrMore,
|
|
30
|
-
sticky,
|
|
31
|
-
tab,
|
|
32
|
-
unicode,
|
|
33
|
-
whitespace,
|
|
34
|
-
withIndices,
|
|
35
|
-
word,
|
|
36
|
-
wordBoundary,
|
|
37
|
-
wordChar,
|
|
38
|
-
} from 'magic-regexp';
|
package/dist/utils/regex.js
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
anyOf,
|
|
3
|
-
carriageReturn,
|
|
4
|
-
caseInsensitive,
|
|
5
|
-
char,
|
|
6
|
-
charIn,
|
|
7
|
-
charNotIn,
|
|
8
|
-
digit,
|
|
9
|
-
dotAll,
|
|
10
|
-
exactly,
|
|
11
|
-
global,
|
|
12
|
-
letter,
|
|
13
|
-
linefeed,
|
|
14
|
-
maybe,
|
|
15
|
-
multiline,
|
|
16
|
-
not,
|
|
17
|
-
oneOrMore,
|
|
18
|
-
sticky,
|
|
19
|
-
tab,
|
|
20
|
-
unicode,
|
|
21
|
-
whitespace,
|
|
22
|
-
withIndices,
|
|
23
|
-
word,
|
|
24
|
-
wordBoundary,
|
|
25
|
-
wordChar
|
|
26
|
-
} from "magic-regexp";
|
|
27
|
-
export function createRegExp(pattern, options = {}) {
|
|
28
|
-
return new RegExp(pattern, options.flags);
|
|
29
|
-
}
|
package/dist/utils/retry.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
// Replace the generic Function type with a more specific function type
|
|
2
|
-
export declare function retry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
|
|
3
|
-
export declare function calculateDelay(attemptCount: number, initialDelay: number, backoffFactor: number, jitter?: boolean): number;
|
|
4
|
-
// Define a more specific RetryOptions interface
|
|
5
|
-
export declare interface RetryOptions {
|
|
6
|
-
retries?: number
|
|
7
|
-
initialDelay?: number
|
|
8
|
-
backoffFactor?: number
|
|
9
|
-
jitter?: boolean
|
|
10
|
-
}
|
package/dist/utils/retry.js
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export function retry(fn, options = {}) {
|
|
2
|
-
const { retries = 3, initialDelay = 1000, backoffFactor = 2, jitter = !0 } = options;
|
|
3
|
-
return new Promise((resolve, reject) => {
|
|
4
|
-
let attemptCount = 0;
|
|
5
|
-
const attempt = async () => {
|
|
6
|
-
try {
|
|
7
|
-
resolve(await fn());
|
|
8
|
-
} catch (err) {
|
|
9
|
-
if (attemptCount >= retries)
|
|
10
|
-
reject(err);
|
|
11
|
-
else {
|
|
12
|
-
const delay = calculateDelay(attemptCount, initialDelay, backoffFactor, jitter);
|
|
13
|
-
setTimeout(() => attempt(), delay);
|
|
14
|
-
attemptCount++;
|
|
15
|
-
}
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
attempt();
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
export function calculateDelay(attemptCount, initialDelay, backoffFactor, jitter) {
|
|
22
|
-
let delay = initialDelay * backoffFactor ** attemptCount;
|
|
23
|
-
if (jitter) {
|
|
24
|
-
const random = Math.random(), jitterValue = delay * 0.3;
|
|
25
|
-
delay = delay + jitterValue * (random - 0.5) * 2;
|
|
26
|
-
}
|
|
27
|
-
return delay;
|
|
28
|
-
}
|
package/dist/utils/sleep.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Pauses execution for a specified number of milliseconds.
|
|
3
|
-
* @param ms The number of milliseconds to pause execution.
|
|
4
|
-
* @returns A promise that resolves after the specified delay.
|
|
5
|
-
*/
|
|
6
|
-
export declare function sleep(ms: number): Promise<void>;
|
|
7
|
-
/**
|
|
8
|
-
* Pauses execution for a specified number of milliseconds.
|
|
9
|
-
* @param ms The number of milliseconds to pause execution.
|
|
10
|
-
* @returns A promise that resolves after the specified delay.
|
|
11
|
-
*/
|
|
12
|
-
export declare function wait(ms: number): Promise<void>;
|
|
13
|
-
/**
|
|
14
|
-
* Pauses execution for a specified number of milliseconds.
|
|
15
|
-
* @param ms The number of milliseconds to pause execution.
|
|
16
|
-
* @returns A promise that resolves after the specified delay.
|
|
17
|
-
*/
|
|
18
|
-
export declare function delay(ms: number): Promise<void>;
|
|
19
|
-
/**
|
|
20
|
-
* Pauses execution until a specified condition is met.
|
|
21
|
-
*/
|
|
22
|
-
export declare function waitUntil(condition: () => boolean, options?: WaitOptions): Promise<void>;
|
|
23
|
-
/**
|
|
24
|
-
* Pauses execution while a specified condition is met.
|
|
25
|
-
*/
|
|
26
|
-
export declare function waitWhile(condition: () => boolean, options?: WaitOptions): Promise<void>;
|
|
27
|
-
export type NonNegativeInteger<T extends number> = number extends T
|
|
28
|
-
? never
|
|
29
|
-
: `${T}` extends `-${string}` | `${string}.${string}`
|
|
30
|
-
? never
|
|
31
|
-
: T;
|
|
32
|
-
export type WaitOptions = number | {
|
|
33
|
-
interval?: number
|
|
34
|
-
timeout?: number
|
|
35
|
-
}
|
package/dist/utils/sleep.js
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
export function sleep(ms) {
|
|
2
|
-
if (ms < 0 || !Number.isInteger(ms))
|
|
3
|
-
throw Error("sleep() requires a non-negative integer");
|
|
4
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
5
|
-
}
|
|
6
|
-
export function wait(ms) {
|
|
7
|
-
if (ms < 0 || !Number.isInteger(ms))
|
|
8
|
-
throw Error("wait() requires a non-negative integer");
|
|
9
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
10
|
-
}
|
|
11
|
-
export function delay(ms) {
|
|
12
|
-
if (ms < 0 || !Number.isInteger(ms))
|
|
13
|
-
throw Error("delay() requires a non-negative integer");
|
|
14
|
-
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
15
|
-
}
|
|
16
|
-
export function waitUntil(condition, options = {}) {
|
|
17
|
-
return new Promise((resolve) => {
|
|
18
|
-
const { interval, timeout } = normalizeOptions(options);
|
|
19
|
-
if (condition()) {
|
|
20
|
-
resolve();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
const check = () => {
|
|
24
|
-
if (condition())
|
|
25
|
-
resolve();
|
|
26
|
-
else
|
|
27
|
-
setTimeout(check, interval);
|
|
28
|
-
};
|
|
29
|
-
if (timeout)
|
|
30
|
-
setTimeout(resolve, timeout);
|
|
31
|
-
check();
|
|
32
|
-
});
|
|
33
|
-
}
|
|
34
|
-
function normalizeOptions(options) {
|
|
35
|
-
if (typeof options === "number")
|
|
36
|
-
return { interval: options, timeout: 0 };
|
|
37
|
-
return {
|
|
38
|
-
interval: options.interval ?? 100,
|
|
39
|
-
timeout: options.timeout ?? 0
|
|
40
|
-
};
|
|
41
|
-
}
|
|
42
|
-
export function waitWhile(condition, options = {}) {
|
|
43
|
-
return new Promise((resolve) => {
|
|
44
|
-
const { interval = 100, timeout = 0 } = options;
|
|
45
|
-
if (!condition()) {
|
|
46
|
-
resolve();
|
|
47
|
-
return;
|
|
48
|
-
}
|
|
49
|
-
const check = () => {
|
|
50
|
-
if (!condition())
|
|
51
|
-
resolve();
|
|
52
|
-
else
|
|
53
|
-
setTimeout(check, interval);
|
|
54
|
-
};
|
|
55
|
-
if (timeout)
|
|
56
|
-
setTimeout(resolve, timeout);
|
|
57
|
-
check();
|
|
58
|
-
});
|
|
59
|
-
}
|
package/dist/utils/throttle.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Throttle a function.
|
|
3
|
-
*
|
|
4
|
-
* @param {Function} fn - The function to throttle.
|
|
5
|
-
* @param {number} [wait] - The time to wait between function calls.
|
|
6
|
-
* @returns {Function} - A new function that throttles the calls to the original function.
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* ```ts
|
|
10
|
-
* // logs window dimensions at most every 250ms
|
|
11
|
-
* window.addEventListener(
|
|
12
|
-
* "resize",
|
|
13
|
-
* throttle(function (evt) {
|
|
14
|
-
* console.log(window.innerWidth)
|
|
15
|
-
* console.log(window.innerHeight)
|
|
16
|
-
* }, 250)
|
|
17
|
-
* )
|
|
18
|
-
* ```
|
|
19
|
-
*/
|
|
20
|
-
export declare function throttle<T extends (...args: any[]) => any>(fn: T, wait?: number): (...args: Parameters<T>) => void;
|
package/dist/utils/throttle.js
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export function throttle(fn, wait = 300) {
|
|
2
|
-
let inThrottle, lastFn, lastTime;
|
|
3
|
-
return function(...args) {
|
|
4
|
-
if (!inThrottle) {
|
|
5
|
-
fn.apply(this, args);
|
|
6
|
-
lastTime = Date.now();
|
|
7
|
-
inThrottle = !0;
|
|
8
|
-
} else {
|
|
9
|
-
clearTimeout(lastFn);
|
|
10
|
-
lastFn = setTimeout(() => {
|
|
11
|
-
if (Date.now() - lastTime >= wait) {
|
|
12
|
-
fn.apply(this, args);
|
|
13
|
-
lastTime = Date.now();
|
|
14
|
-
}
|
|
15
|
-
}, Math.max(wait - (Date.now() - lastTime), 0));
|
|
16
|
-
}
|
|
17
|
-
};
|
|
18
|
-
}
|
package/dist/utils/vendors.d.ts
DELETED
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
export type {
|
|
2
|
-
HeadConfig as HeadObject,
|
|
3
|
-
HeadConfig as HeadObjectPlain,
|
|
4
|
-
} from '@stacksjs/stx';
|
|
5
|
-
export declare function readableSize(bytes: number, options?: ReadableSizeOptions): string;
|
|
6
|
-
export declare interface ReadableSizeOptions {
|
|
7
|
-
precision?: number
|
|
8
|
-
binary?: boolean
|
|
9
|
-
space?: boolean
|
|
10
|
-
locale?: string
|
|
11
|
-
minimumFractionDigits?: number
|
|
12
|
-
maximumFractionDigits?: number
|
|
13
|
-
}
|
|
14
|
-
// Re-export composables from @stacksjs/composables
|
|
15
|
-
export {
|
|
16
|
-
useDark,
|
|
17
|
-
useDateFormat,
|
|
18
|
-
useFetch,
|
|
19
|
-
useNow,
|
|
20
|
-
useOnline,
|
|
21
|
-
usePreferredDark,
|
|
22
|
-
useStorage,
|
|
23
|
-
useToggle,
|
|
24
|
-
} from '@stacksjs/composables';
|
|
25
|
-
export {
|
|
26
|
-
useHead as createHead,
|
|
27
|
-
useHead as Head,
|
|
28
|
-
renderHead as renderHeadToString,
|
|
29
|
-
} from '@stacksjs/stx';
|
package/dist/utils/vendors.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
export {
|
|
2
|
-
useDark,
|
|
3
|
-
useDateFormat,
|
|
4
|
-
useFetch,
|
|
5
|
-
useNow,
|
|
6
|
-
useOnline,
|
|
7
|
-
usePreferredDark,
|
|
8
|
-
useStorage,
|
|
9
|
-
useToggle
|
|
10
|
-
} from "@stacksjs/composables";
|
|
11
|
-
export {
|
|
12
|
-
useHead as createHead,
|
|
13
|
-
useHead as Head,
|
|
14
|
-
renderHead as renderHeadToString
|
|
15
|
-
} from "@stacksjs/stx";
|
|
16
|
-
const DECIMAL_UNITS = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], BINARY_UNITS = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
17
|
-
export function readableSize(bytes, options = {}) {
|
|
18
|
-
const {
|
|
19
|
-
precision = 1,
|
|
20
|
-
binary = !1,
|
|
21
|
-
space = !0,
|
|
22
|
-
locale = "en-US",
|
|
23
|
-
minimumFractionDigits = 0,
|
|
24
|
-
maximumFractionDigits = precision
|
|
25
|
-
} = options;
|
|
26
|
-
if (!Number.isFinite(bytes))
|
|
27
|
-
throw TypeError(`Expected a finite number, got ${typeof bytes}: ${bytes}`);
|
|
28
|
-
const isNegative = bytes < 0, prefix = isNegative ? "-" : "";
|
|
29
|
-
if (isNegative)
|
|
30
|
-
bytes = -bytes;
|
|
31
|
-
if (bytes < 1) {
|
|
32
|
-
const numberString = bytes.toLocaleString(locale, { minimumFractionDigits, maximumFractionDigits });
|
|
33
|
-
return `${prefix}${numberString}${space ? " " : ""}B`;
|
|
34
|
-
}
|
|
35
|
-
const base = binary ? 1024 : 1000, units = binary ? BINARY_UNITS : DECIMAL_UNITS, exponent = Math.min(Math.floor(Math.log(bytes) / Math.log(base)), units.length - 1), numberString = (bytes / base ** exponent).toLocaleString(locale, { minimumFractionDigits, maximumFractionDigits });
|
|
36
|
-
return `${prefix}${numberString}${space ? " " : ""}${units[exponent]}`;
|
|
37
|
-
}
|