@stacksjs/utils 0.70.88 → 0.70.90
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/bytes.d.ts +42 -0
- package/dist/bytes.js +55 -0
- package/dist/clean.d.ts +1 -0
- package/dist/clean.js +13 -0
- package/dist/colors.d.ts +146 -0
- package/dist/colors.js +100 -0
- package/dist/config.d.ts +23 -0
- package/dist/config.js +23 -0
- package/dist/debounce.d.ts +29 -0
- package/dist/debounce.js +77 -0
- package/dist/detect.d.ts +35 -0
- package/dist/detect.js +65 -0
- package/dist/equal.d.ts +13 -0
- package/dist/equal.js +27 -0
- package/dist/errors.d.ts +65 -0
- package/dist/errors.js +44 -0
- package/dist/export-size.d.ts +2 -0
- package/dist/export-size.js +1 -0
- package/dist/find.d.ts +4 -0
- package/dist/find.js +68 -0
- package/dist/git.d.ts +1 -0
- package/dist/git.js +11 -0
- package/dist/glob.d.ts +1 -0
- package/dist/glob.js +1 -0
- package/dist/hash.d.ts +3 -0
- package/dist/hash.js +36 -0
- package/dist/helpers.d.ts +53 -0
- package/dist/helpers.js +101 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +23 -0
- package/dist/macroable.d.ts +28 -0
- package/dist/macroable.js +121 -0
- package/dist/markdown.d.ts +46 -0
- package/dist/markdown.js +92 -0
- package/dist/merge.d.ts +20 -0
- package/dist/merge.js +51 -0
- package/dist/observer.d.ts +64 -0
- package/dist/observer.js +78 -0
- package/dist/pipeline.d.ts +13 -0
- package/dist/pipeline.js +37 -0
- package/dist/safe-json.d.ts +49 -0
- package/dist/safe-json.js +33 -0
- package/dist/size.d.ts +37 -0
- package/dist/size.js +66 -0
- package/dist/utils.d.ts +2 -0
- package/dist/utils.js +6 -0
- package/dist/versions.d.ts +8 -0
- package/dist/versions.js +19 -0
- package/package.json +11 -11
package/dist/bytes.d.ts
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Format bytes to human-readable string
|
|
3
|
+
*
|
|
4
|
+
* @example
|
|
5
|
+
* ```ts
|
|
6
|
+
* formatBytes(1024) // '1 KB'
|
|
7
|
+
* formatBytes(1024, { binary: true }) // '1 KiB'
|
|
8
|
+
* formatBytes(1234567) // '1.2 MB'
|
|
9
|
+
* formatBytes(1234567, { precision: 2 }) // '1.23 MB'
|
|
10
|
+
* ```
|
|
11
|
+
*/
|
|
12
|
+
export declare function formatBytes(bytes: number, options?: BytesOptions): string;
|
|
13
|
+
/**
|
|
14
|
+
* Parse human-readable byte string to number
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* ```ts
|
|
18
|
+
* parseBytes('1 KB') // 1000
|
|
19
|
+
* parseBytes('1 KiB') // 1024
|
|
20
|
+
* parseBytes('1.5 MB') // 1500000
|
|
21
|
+
* ```
|
|
22
|
+
*/
|
|
23
|
+
export declare function parseBytes(input: string): number;
|
|
24
|
+
/**
|
|
25
|
+
* Compare two byte values
|
|
26
|
+
*/
|
|
27
|
+
export declare function compareBytes(a: number | string, b: number | string): number;
|
|
28
|
+
// Aliases
|
|
29
|
+
export declare const prettyBytes: unknown;
|
|
30
|
+
export declare const readableSize: unknown;
|
|
31
|
+
/**
|
|
32
|
+
* Format bytes to human-readable string (pretty-bytes replacement)
|
|
33
|
+
*/
|
|
34
|
+
export declare interface BytesOptions {
|
|
35
|
+
precision?: number
|
|
36
|
+
binary?: boolean
|
|
37
|
+
space?: boolean
|
|
38
|
+
locale?: string
|
|
39
|
+
minimumFractionDigits?: number
|
|
40
|
+
maximumFractionDigits?: number
|
|
41
|
+
}
|
|
42
|
+
export { formatBytes as default };
|
package/dist/bytes.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
const DECIMAL_UNITS = ["B", "KB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"], BINARY_UNITS = ["B", "KiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"];
|
|
2
|
+
export function formatBytes(bytes, options = {}) {
|
|
3
|
+
const {
|
|
4
|
+
precision = 1,
|
|
5
|
+
binary = !1,
|
|
6
|
+
space = !0,
|
|
7
|
+
locale = "en-US",
|
|
8
|
+
minimumFractionDigits = 0,
|
|
9
|
+
maximumFractionDigits = precision
|
|
10
|
+
} = options;
|
|
11
|
+
if (!Number.isFinite(bytes))
|
|
12
|
+
throw TypeError(`Expected a finite number, got ${typeof bytes}: ${bytes}`);
|
|
13
|
+
const isNegative = bytes < 0, prefix = isNegative ? "-" : "";
|
|
14
|
+
if (isNegative)
|
|
15
|
+
bytes = -bytes;
|
|
16
|
+
if (bytes < 1) {
|
|
17
|
+
const numberString = bytes.toLocaleString(locale, {
|
|
18
|
+
minimumFractionDigits,
|
|
19
|
+
maximumFractionDigits
|
|
20
|
+
});
|
|
21
|
+
return `${prefix}${numberString}${space ? " " : ""}B`;
|
|
22
|
+
}
|
|
23
|
+
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, {
|
|
24
|
+
minimumFractionDigits,
|
|
25
|
+
maximumFractionDigits
|
|
26
|
+
}), unit = units[exponent];
|
|
27
|
+
return `${prefix}${numberString}${space ? " " : ""}${unit}`;
|
|
28
|
+
}
|
|
29
|
+
export function parseBytes(input) {
|
|
30
|
+
const match = input.match(/^(-?[\d.]+)\s*([A-Za-z]+)?$/);
|
|
31
|
+
if (!match)
|
|
32
|
+
throw Error(`Invalid byte string: ${input}`);
|
|
33
|
+
const [, numberStr, unit = "B"] = match;
|
|
34
|
+
if (numberStr === void 0)
|
|
35
|
+
throw Error(`Invalid byte string: ${input}`);
|
|
36
|
+
const number = Number.parseFloat(numberStr);
|
|
37
|
+
if (!Number.isFinite(number))
|
|
38
|
+
throw Error(`Invalid number in byte string: ${numberStr}`);
|
|
39
|
+
const normalizedUnit = unit.toUpperCase(), isBinary = normalizedUnit.endsWith("IB"), base = isBinary ? 1024 : 1000;
|
|
40
|
+
let exponent = 0;
|
|
41
|
+
const units = isBinary ? BINARY_UNITS : DECIMAL_UNITS;
|
|
42
|
+
for (let i = 0;i < units.length; i++)
|
|
43
|
+
if (units[i]?.toUpperCase() === normalizedUnit) {
|
|
44
|
+
exponent = i;
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
return number * base ** exponent;
|
|
48
|
+
}
|
|
49
|
+
export function compareBytes(a, b) {
|
|
50
|
+
const bytesA = typeof a === "string" ? parseBytes(a) : a, bytesB = typeof b === "string" ? parseBytes(b) : b;
|
|
51
|
+
return bytesA - bytesB;
|
|
52
|
+
}
|
|
53
|
+
export const prettyBytes = formatBytes, readableSize = formatBytes;
|
|
54
|
+
|
|
55
|
+
export { formatBytes as default };
|
package/dist/clean.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function cleanProject(): Promise<void>;
|
package/dist/clean.js
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { path as p } from "@stacksjs/path";
|
|
2
|
+
export async function cleanProject() {
|
|
3
|
+
await Bun.$`rm -rf ${p.projectPath("bun.lock")}`;
|
|
4
|
+
await Bun.$`rm -rf ${p.projectPath("yarn.lock")}`;
|
|
5
|
+
await Bun.$`rm -rf ${p.projectPath("node_modules/")}`;
|
|
6
|
+
await Bun.$`rm -rf ${p.frameworkPath("dist")}`;
|
|
7
|
+
await Bun.$`rm -rf ${p.frameworkPath("node_modules")}`;
|
|
8
|
+
await Bun.$`rm -rf ${p.frameworkPath("**/dist")}`;
|
|
9
|
+
await Bun.$`rm -rf ${p.frameworkPath("**/node_modules")}`;
|
|
10
|
+
await Bun.$`rm -rf ${p.frameworkCloudPath("cdk.out/")}`;
|
|
11
|
+
await Bun.$`rm -rf ${p.frameworkCloudPath("cdk.context.json")}`;
|
|
12
|
+
await Bun.$`rm -rf ${p.cloudPath("dist.zip")}`;
|
|
13
|
+
}
|
package/dist/colors.d.ts
ADDED
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
declare function createColorFn(code: string, endCode?: string): ColorFn;
|
|
2
|
+
// Strip colors from text
|
|
3
|
+
export declare function stripColors(text: string): string;
|
|
4
|
+
// Check if colors are supported
|
|
5
|
+
export declare function supportsColor(): boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Terminal colors and formatting (kolorist replacement)
|
|
8
|
+
*
|
|
9
|
+
* Lightweight terminal color library with zero dependencies
|
|
10
|
+
*/
|
|
11
|
+
declare const isColorSupported: unknown;
|
|
12
|
+
declare const colors: {
|
|
13
|
+
reset: unknown;
|
|
14
|
+
black: unknown;
|
|
15
|
+
red: unknown;
|
|
16
|
+
green: unknown;
|
|
17
|
+
yellow: unknown;
|
|
18
|
+
blue: unknown;
|
|
19
|
+
magenta: unknown;
|
|
20
|
+
cyan: unknown;
|
|
21
|
+
white: unknown;
|
|
22
|
+
gray: unknown;
|
|
23
|
+
grey: unknown;
|
|
24
|
+
lightRed: unknown;
|
|
25
|
+
lightGreen: unknown;
|
|
26
|
+
lightYellow: unknown;
|
|
27
|
+
lightBlue: unknown;
|
|
28
|
+
lightMagenta: unknown;
|
|
29
|
+
lightCyan: unknown;
|
|
30
|
+
lightGray: unknown;
|
|
31
|
+
lightGrey: unknown;
|
|
32
|
+
bgBlack: unknown;
|
|
33
|
+
bgRed: unknown;
|
|
34
|
+
bgGreen: unknown;
|
|
35
|
+
bgYellow: unknown;
|
|
36
|
+
bgBlue: unknown;
|
|
37
|
+
bgMagenta: unknown;
|
|
38
|
+
bgCyan: unknown;
|
|
39
|
+
bgWhite: unknown;
|
|
40
|
+
bgLightRed: unknown;
|
|
41
|
+
bgLightGreen: unknown;
|
|
42
|
+
bgLightYellow: unknown;
|
|
43
|
+
bgLightBlue: unknown;
|
|
44
|
+
bgLightMagenta: unknown;
|
|
45
|
+
bgLightCyan: unknown;
|
|
46
|
+
bold: unknown;
|
|
47
|
+
dim: unknown;
|
|
48
|
+
italic: unknown;
|
|
49
|
+
underline: unknown;
|
|
50
|
+
inverse: unknown;
|
|
51
|
+
hidden: unknown;
|
|
52
|
+
strikethrough: unknown
|
|
53
|
+
};
|
|
54
|
+
// Color functions
|
|
55
|
+
export declare const black: unknown;
|
|
56
|
+
export declare const red: unknown;
|
|
57
|
+
export declare const green: unknown;
|
|
58
|
+
export declare const yellow: unknown;
|
|
59
|
+
export declare const blue: unknown;
|
|
60
|
+
export declare const magenta: unknown;
|
|
61
|
+
export declare const cyan: unknown;
|
|
62
|
+
export declare const white: unknown;
|
|
63
|
+
export declare const gray: unknown;
|
|
64
|
+
export declare const grey: unknown;
|
|
65
|
+
// Bright colors
|
|
66
|
+
export declare const lightRed: unknown;
|
|
67
|
+
export declare const lightGreen: unknown;
|
|
68
|
+
export declare const lightYellow: unknown;
|
|
69
|
+
export declare const lightBlue: unknown;
|
|
70
|
+
export declare const lightMagenta: unknown;
|
|
71
|
+
export declare const lightCyan: unknown;
|
|
72
|
+
export declare const lightGray: unknown;
|
|
73
|
+
export declare const lightGrey: unknown;
|
|
74
|
+
// Background colors
|
|
75
|
+
export declare const bgBlack: unknown;
|
|
76
|
+
export declare const bgRed: unknown;
|
|
77
|
+
export declare const bgGreen: unknown;
|
|
78
|
+
export declare const bgYellow: unknown;
|
|
79
|
+
export declare const bgBlue: unknown;
|
|
80
|
+
export declare const bgMagenta: unknown;
|
|
81
|
+
export declare const bgCyan: unknown;
|
|
82
|
+
export declare const bgWhite: unknown;
|
|
83
|
+
// Bright background colors
|
|
84
|
+
export declare const bgLightRed: unknown;
|
|
85
|
+
export declare const bgLightGreen: unknown;
|
|
86
|
+
export declare const bgLightYellow: unknown;
|
|
87
|
+
export declare const bgLightBlue: unknown;
|
|
88
|
+
export declare const bgLightMagenta: unknown;
|
|
89
|
+
export declare const bgLightCyan: unknown;
|
|
90
|
+
// Text formatting
|
|
91
|
+
export declare const bold: unknown;
|
|
92
|
+
export declare const dim: unknown;
|
|
93
|
+
export declare const italic: unknown;
|
|
94
|
+
export declare const underline: unknown;
|
|
95
|
+
export declare const inverse: unknown;
|
|
96
|
+
export declare const hidden: unknown;
|
|
97
|
+
export declare const strikethrough: unknown;
|
|
98
|
+
// Reset
|
|
99
|
+
export declare const reset: unknown;
|
|
100
|
+
declare const __dtsx_default_export__: {
|
|
101
|
+
black: typeof black;
|
|
102
|
+
red: typeof red;
|
|
103
|
+
green: typeof green;
|
|
104
|
+
yellow: typeof yellow;
|
|
105
|
+
blue: typeof blue;
|
|
106
|
+
magenta: typeof magenta;
|
|
107
|
+
cyan: typeof cyan;
|
|
108
|
+
white: typeof white;
|
|
109
|
+
gray: typeof gray;
|
|
110
|
+
grey: typeof grey;
|
|
111
|
+
lightRed: typeof lightRed;
|
|
112
|
+
lightGreen: typeof lightGreen;
|
|
113
|
+
lightYellow: typeof lightYellow;
|
|
114
|
+
lightBlue: typeof lightBlue;
|
|
115
|
+
lightMagenta: typeof lightMagenta;
|
|
116
|
+
lightCyan: typeof lightCyan;
|
|
117
|
+
lightGray: typeof lightGray;
|
|
118
|
+
lightGrey: typeof lightGrey;
|
|
119
|
+
bgBlack: typeof bgBlack;
|
|
120
|
+
bgRed: typeof bgRed;
|
|
121
|
+
bgGreen: typeof bgGreen;
|
|
122
|
+
bgYellow: typeof bgYellow;
|
|
123
|
+
bgBlue: typeof bgBlue;
|
|
124
|
+
bgMagenta: typeof bgMagenta;
|
|
125
|
+
bgCyan: typeof bgCyan;
|
|
126
|
+
bgWhite: typeof bgWhite;
|
|
127
|
+
bgLightRed: typeof bgLightRed;
|
|
128
|
+
bgLightGreen: typeof bgLightGreen;
|
|
129
|
+
bgLightYellow: typeof bgLightYellow;
|
|
130
|
+
bgLightBlue: typeof bgLightBlue;
|
|
131
|
+
bgLightMagenta: typeof bgLightMagenta;
|
|
132
|
+
bgLightCyan: typeof bgLightCyan;
|
|
133
|
+
bold: typeof bold;
|
|
134
|
+
dim: typeof dim;
|
|
135
|
+
italic: typeof italic;
|
|
136
|
+
underline: typeof underline;
|
|
137
|
+
inverse: typeof inverse;
|
|
138
|
+
hidden: typeof hidden;
|
|
139
|
+
strikethrough: typeof strikethrough;
|
|
140
|
+
reset: typeof reset;
|
|
141
|
+
stripColors: typeof stripColors;
|
|
142
|
+
supportsColor: typeof supportsColor
|
|
143
|
+
};
|
|
144
|
+
declare type ColorFn = (_text: string | number) => string;
|
|
145
|
+
// Default export
|
|
146
|
+
export default __dtsx_default_export__;
|
package/dist/colors.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
const isColorSupported = !process.env.NO_COLOR && (process.env.FORCE_COLOR || process.stdout?.isTTY), colors = {
|
|
2
|
+
reset: isColorSupported ? "\x1B[0m" : "",
|
|
3
|
+
black: isColorSupported ? "\x1B[30m" : "",
|
|
4
|
+
red: isColorSupported ? "\x1B[31m" : "",
|
|
5
|
+
green: isColorSupported ? "\x1B[32m" : "",
|
|
6
|
+
yellow: isColorSupported ? "\x1B[33m" : "",
|
|
7
|
+
blue: isColorSupported ? "\x1B[34m" : "",
|
|
8
|
+
magenta: isColorSupported ? "\x1B[35m" : "",
|
|
9
|
+
cyan: isColorSupported ? "\x1B[36m" : "",
|
|
10
|
+
white: isColorSupported ? "\x1B[37m" : "",
|
|
11
|
+
gray: isColorSupported ? "\x1B[90m" : "",
|
|
12
|
+
grey: isColorSupported ? "\x1B[90m" : "",
|
|
13
|
+
lightRed: isColorSupported ? "\x1B[91m" : "",
|
|
14
|
+
lightGreen: isColorSupported ? "\x1B[92m" : "",
|
|
15
|
+
lightYellow: isColorSupported ? "\x1B[93m" : "",
|
|
16
|
+
lightBlue: isColorSupported ? "\x1B[94m" : "",
|
|
17
|
+
lightMagenta: isColorSupported ? "\x1B[95m" : "",
|
|
18
|
+
lightCyan: isColorSupported ? "\x1B[96m" : "",
|
|
19
|
+
lightGray: isColorSupported ? "\x1B[37m" : "",
|
|
20
|
+
lightGrey: isColorSupported ? "\x1B[37m" : "",
|
|
21
|
+
bgBlack: isColorSupported ? "\x1B[40m" : "",
|
|
22
|
+
bgRed: isColorSupported ? "\x1B[41m" : "",
|
|
23
|
+
bgGreen: isColorSupported ? "\x1B[42m" : "",
|
|
24
|
+
bgYellow: isColorSupported ? "\x1B[43m" : "",
|
|
25
|
+
bgBlue: isColorSupported ? "\x1B[44m" : "",
|
|
26
|
+
bgMagenta: isColorSupported ? "\x1B[45m" : "",
|
|
27
|
+
bgCyan: isColorSupported ? "\x1B[46m" : "",
|
|
28
|
+
bgWhite: isColorSupported ? "\x1B[47m" : "",
|
|
29
|
+
bgLightRed: isColorSupported ? "\x1B[101m" : "",
|
|
30
|
+
bgLightGreen: isColorSupported ? "\x1B[102m" : "",
|
|
31
|
+
bgLightYellow: isColorSupported ? "\x1B[103m" : "",
|
|
32
|
+
bgLightBlue: isColorSupported ? "\x1B[104m" : "",
|
|
33
|
+
bgLightMagenta: isColorSupported ? "\x1B[105m" : "",
|
|
34
|
+
bgLightCyan: isColorSupported ? "\x1B[106m" : "",
|
|
35
|
+
bold: isColorSupported ? "\x1B[1m" : "",
|
|
36
|
+
dim: isColorSupported ? "\x1B[2m" : "",
|
|
37
|
+
italic: isColorSupported ? "\x1B[3m" : "",
|
|
38
|
+
underline: isColorSupported ? "\x1B[4m" : "",
|
|
39
|
+
inverse: isColorSupported ? "\x1B[7m" : "",
|
|
40
|
+
hidden: isColorSupported ? "\x1B[8m" : "",
|
|
41
|
+
strikethrough: isColorSupported ? "\x1B[9m" : ""
|
|
42
|
+
};
|
|
43
|
+
function createColorFn(code, endCode = colors.reset) {
|
|
44
|
+
return (text) => {
|
|
45
|
+
if (!isColorSupported)
|
|
46
|
+
return String(text);
|
|
47
|
+
return `${code}${text}${endCode}`;
|
|
48
|
+
};
|
|
49
|
+
}
|
|
50
|
+
export const black = createColorFn(colors.black), red = createColorFn(colors.red), green = createColorFn(colors.green), yellow = createColorFn(colors.yellow), blue = createColorFn(colors.blue), magenta = createColorFn(colors.magenta), cyan = createColorFn(colors.cyan), white = createColorFn(colors.white), gray = createColorFn(colors.gray), grey = gray, lightRed = createColorFn(colors.lightRed), lightGreen = createColorFn(colors.lightGreen), lightYellow = createColorFn(colors.lightYellow), lightBlue = createColorFn(colors.lightBlue), lightMagenta = createColorFn(colors.lightMagenta), lightCyan = createColorFn(colors.lightCyan), lightGray = createColorFn(colors.lightGray), lightGrey = lightGray, bgBlack = createColorFn(colors.bgBlack), bgRed = createColorFn(colors.bgRed), bgGreen = createColorFn(colors.bgGreen), bgYellow = createColorFn(colors.bgYellow), bgBlue = createColorFn(colors.bgBlue), bgMagenta = createColorFn(colors.bgMagenta), bgCyan = createColorFn(colors.bgCyan), bgWhite = createColorFn(colors.bgWhite), bgLightRed = createColorFn(colors.bgLightRed), bgLightGreen = createColorFn(colors.bgLightGreen), bgLightYellow = createColorFn(colors.bgLightYellow), bgLightBlue = createColorFn(colors.bgLightBlue), bgLightMagenta = createColorFn(colors.bgLightMagenta), bgLightCyan = createColorFn(colors.bgLightCyan), bold = createColorFn(colors.bold), dim = createColorFn(colors.dim), italic = createColorFn(colors.italic), underline = createColorFn(colors.underline), inverse = createColorFn(colors.inverse), hidden = createColorFn(colors.hidden), strikethrough = createColorFn(colors.strikethrough), reset = createColorFn(colors.reset, "");
|
|
51
|
+
export function stripColors(text) {
|
|
52
|
+
return text.replace(/\x1B\[\d+m/g, "");
|
|
53
|
+
}
|
|
54
|
+
export function supportsColor() {
|
|
55
|
+
return !!isColorSupported;
|
|
56
|
+
}
|
|
57
|
+
export default {
|
|
58
|
+
black,
|
|
59
|
+
red,
|
|
60
|
+
green,
|
|
61
|
+
yellow,
|
|
62
|
+
blue,
|
|
63
|
+
magenta,
|
|
64
|
+
cyan,
|
|
65
|
+
white,
|
|
66
|
+
gray,
|
|
67
|
+
grey,
|
|
68
|
+
lightRed,
|
|
69
|
+
lightGreen,
|
|
70
|
+
lightYellow,
|
|
71
|
+
lightBlue,
|
|
72
|
+
lightMagenta,
|
|
73
|
+
lightCyan,
|
|
74
|
+
lightGray,
|
|
75
|
+
lightGrey,
|
|
76
|
+
bgBlack,
|
|
77
|
+
bgRed,
|
|
78
|
+
bgGreen,
|
|
79
|
+
bgYellow,
|
|
80
|
+
bgBlue,
|
|
81
|
+
bgMagenta,
|
|
82
|
+
bgCyan,
|
|
83
|
+
bgWhite,
|
|
84
|
+
bgLightRed,
|
|
85
|
+
bgLightGreen,
|
|
86
|
+
bgLightYellow,
|
|
87
|
+
bgLightBlue,
|
|
88
|
+
bgLightMagenta,
|
|
89
|
+
bgLightCyan,
|
|
90
|
+
bold,
|
|
91
|
+
dim,
|
|
92
|
+
italic,
|
|
93
|
+
underline,
|
|
94
|
+
inverse,
|
|
95
|
+
hidden,
|
|
96
|
+
strikethrough,
|
|
97
|
+
reset,
|
|
98
|
+
stripColors,
|
|
99
|
+
supportsColor
|
|
100
|
+
};
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export {
|
|
2
|
+
defineApp,
|
|
3
|
+
defineCache,
|
|
4
|
+
defineCdn,
|
|
5
|
+
defineChat,
|
|
6
|
+
defineCli,
|
|
7
|
+
defineDatabase,
|
|
8
|
+
defineDependencies,
|
|
9
|
+
defineDns,
|
|
10
|
+
defineEmail,
|
|
11
|
+
defineEmailConfig,
|
|
12
|
+
defineGit,
|
|
13
|
+
defineHashing,
|
|
14
|
+
defineLibrary,
|
|
15
|
+
defineNotification,
|
|
16
|
+
definePayment,
|
|
17
|
+
defineQueue,
|
|
18
|
+
defineSearchEngine,
|
|
19
|
+
defineServices,
|
|
20
|
+
defineSms,
|
|
21
|
+
defineFilesystems,
|
|
22
|
+
defineUi,
|
|
23
|
+
} from '@stacksjs/config';
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
export {
|
|
2
|
+
defineApp,
|
|
3
|
+
defineCache,
|
|
4
|
+
defineCdn,
|
|
5
|
+
defineChat,
|
|
6
|
+
defineCli,
|
|
7
|
+
defineDatabase,
|
|
8
|
+
defineDependencies,
|
|
9
|
+
defineDns,
|
|
10
|
+
defineEmail,
|
|
11
|
+
defineEmailConfig,
|
|
12
|
+
defineGit,
|
|
13
|
+
defineHashing,
|
|
14
|
+
defineLibrary,
|
|
15
|
+
defineNotification,
|
|
16
|
+
definePayment,
|
|
17
|
+
defineQueue,
|
|
18
|
+
defineSearchEngine,
|
|
19
|
+
defineServices,
|
|
20
|
+
defineSms,
|
|
21
|
+
defineFilesystems,
|
|
22
|
+
defineUi
|
|
23
|
+
} from "@stacksjs/config";
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Creates a debounced function that delays invoking func until after wait milliseconds
|
|
3
|
+
* have elapsed since the last time the debounced function was invoked.
|
|
4
|
+
*
|
|
5
|
+
* @param fn - The function to debounce
|
|
6
|
+
* @param wait - The number of milliseconds to delay
|
|
7
|
+
* @param options - Options object
|
|
8
|
+
* @returns The debounced function
|
|
9
|
+
*/
|
|
10
|
+
export declare function debounce<T extends (..._args: any[]) => any>(fn: T, wait?: number, options?: DebounceOptions): T & { cancel: () => void; flush: () => void };
|
|
11
|
+
/**
|
|
12
|
+
* Creates a throttled function that only invokes func at most once per every wait milliseconds
|
|
13
|
+
*
|
|
14
|
+
* @param fn - The function to throttle
|
|
15
|
+
* @param wait - The number of milliseconds to throttle
|
|
16
|
+
* @returns The throttled function
|
|
17
|
+
*/
|
|
18
|
+
export declare function throttle<T extends (...args: any[]) => any>(fn: T, wait?: number): T & { cancel: () => void };
|
|
19
|
+
/**
|
|
20
|
+
* Delays execution of a function
|
|
21
|
+
*/
|
|
22
|
+
export declare function delay(ms: number): Promise<void>;
|
|
23
|
+
/**
|
|
24
|
+
* Debounce and throttle utilities (perfect-debounce replacement)
|
|
25
|
+
*/
|
|
26
|
+
export declare interface DebounceOptions {
|
|
27
|
+
leading?: boolean
|
|
28
|
+
trailing?: boolean
|
|
29
|
+
}
|
package/dist/debounce.js
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export function debounce(fn, wait = 0, options = {}) {
|
|
2
|
+
const { leading = !1, trailing = !0 } = options;
|
|
3
|
+
let timeout = null, lastArgs = null, lastThis = null, result;
|
|
4
|
+
const invokeFunc = () => {
|
|
5
|
+
if (lastArgs) {
|
|
6
|
+
result = fn.apply(lastThis, lastArgs);
|
|
7
|
+
lastArgs = null;
|
|
8
|
+
lastThis = null;
|
|
9
|
+
}
|
|
10
|
+
return result;
|
|
11
|
+
}, cancel = () => {
|
|
12
|
+
if (timeout) {
|
|
13
|
+
clearTimeout(timeout);
|
|
14
|
+
timeout = null;
|
|
15
|
+
}
|
|
16
|
+
lastArgs = null;
|
|
17
|
+
lastThis = null;
|
|
18
|
+
}, flush = () => {
|
|
19
|
+
if (timeout) {
|
|
20
|
+
clearTimeout(timeout);
|
|
21
|
+
timeout = null;
|
|
22
|
+
return invokeFunc();
|
|
23
|
+
}
|
|
24
|
+
return result;
|
|
25
|
+
}, debounced = function(...args) {
|
|
26
|
+
lastArgs = args;
|
|
27
|
+
lastThis = this;
|
|
28
|
+
const shouldCallNow = leading && !timeout;
|
|
29
|
+
if (timeout)
|
|
30
|
+
clearTimeout(timeout);
|
|
31
|
+
timeout = setTimeout(() => {
|
|
32
|
+
timeout = null;
|
|
33
|
+
if (trailing && lastArgs)
|
|
34
|
+
invokeFunc();
|
|
35
|
+
}, wait);
|
|
36
|
+
if (shouldCallNow)
|
|
37
|
+
return invokeFunc();
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
debounced.cancel = cancel;
|
|
41
|
+
debounced.flush = flush;
|
|
42
|
+
return debounced;
|
|
43
|
+
}
|
|
44
|
+
export function throttle(fn, wait = 0) {
|
|
45
|
+
let timeout = null, lastRun = 0, lastArgs = null, lastThis = null;
|
|
46
|
+
const invokeFunc = () => {
|
|
47
|
+
if (lastArgs) {
|
|
48
|
+
fn.apply(lastThis, lastArgs);
|
|
49
|
+
lastArgs = null;
|
|
50
|
+
lastThis = null;
|
|
51
|
+
lastRun = Date.now();
|
|
52
|
+
}
|
|
53
|
+
}, cancel = () => {
|
|
54
|
+
if (timeout) {
|
|
55
|
+
clearTimeout(timeout);
|
|
56
|
+
timeout = null;
|
|
57
|
+
}
|
|
58
|
+
lastArgs = null;
|
|
59
|
+
lastThis = null;
|
|
60
|
+
}, throttled = function(...args) {
|
|
61
|
+
lastArgs = args;
|
|
62
|
+
lastThis = this;
|
|
63
|
+
const timeSinceLastRun = Date.now() - lastRun;
|
|
64
|
+
if (timeSinceLastRun >= wait)
|
|
65
|
+
invokeFunc();
|
|
66
|
+
else if (!timeout)
|
|
67
|
+
timeout = setTimeout(() => {
|
|
68
|
+
timeout = null;
|
|
69
|
+
invokeFunc();
|
|
70
|
+
}, wait - timeSinceLastRun);
|
|
71
|
+
};
|
|
72
|
+
throttled.cancel = cancel;
|
|
73
|
+
return throttled;
|
|
74
|
+
}
|
|
75
|
+
export function delay(ms) {
|
|
76
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
77
|
+
}
|
package/dist/detect.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
export declare function detectIndent(text: string): IndentInfo;
|
|
2
|
+
/**
|
|
3
|
+
* Detect newline type in a string
|
|
4
|
+
*
|
|
5
|
+
* @returns '\r\n' (CRLF - Windows), '\n' (LF - Unix), '\r' (CR - old Mac), or null
|
|
6
|
+
*/
|
|
7
|
+
export declare function detectNewline(text: string): '\r\n' | '\n' | '\r' | null;
|
|
8
|
+
/**
|
|
9
|
+
* Detect newline type with graceful fallback
|
|
10
|
+
*/
|
|
11
|
+
export declare function detectNewlineGraceful(text: string, fallback?: '\r\n' | '\n'): '\r\n' | '\n' | '\r';
|
|
12
|
+
/**
|
|
13
|
+
* Normalize newlines in text to specified type
|
|
14
|
+
*/
|
|
15
|
+
export declare function normalizeNewlines(text: string, newline?: '\r\n' | '\n' | '\r'): string;
|
|
16
|
+
/**
|
|
17
|
+
* Count different types of newlines in text
|
|
18
|
+
*/
|
|
19
|
+
export declare function countNewlines(text: string): {
|
|
20
|
+
crlf: number
|
|
21
|
+
lf: number
|
|
22
|
+
cr: number
|
|
23
|
+
total: number
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* Text detection utilities (detect-indent and detect-newline replacements)
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Detect indentation type and amount in a string
|
|
30
|
+
*/
|
|
31
|
+
export declare interface IndentInfo {
|
|
32
|
+
amount: number
|
|
33
|
+
type: 'space' | 'tab' | null
|
|
34
|
+
indent: string
|
|
35
|
+
}
|
package/dist/detect.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
export function detectIndent(text) {
|
|
2
|
+
const lines = text.split(`
|
|
3
|
+
`), indents = [];
|
|
4
|
+
for (const line of lines) {
|
|
5
|
+
if (!line.trim())
|
|
6
|
+
continue;
|
|
7
|
+
const match = line.match(/^(\s+)/);
|
|
8
|
+
if (match && match[1] !== void 0)
|
|
9
|
+
indents.push(match[1]);
|
|
10
|
+
}
|
|
11
|
+
if (indents.length === 0)
|
|
12
|
+
return { amount: 0, type: null, indent: "" };
|
|
13
|
+
const indentCounts = new Map;
|
|
14
|
+
for (const indent of indents)
|
|
15
|
+
indentCounts.set(indent, (indentCounts.get(indent) || 0) + 1);
|
|
16
|
+
let mostCommon = "", maxCount = 0;
|
|
17
|
+
for (const [indent, count] of indentCounts)
|
|
18
|
+
if (count > maxCount) {
|
|
19
|
+
maxCount = count;
|
|
20
|
+
mostCommon = indent;
|
|
21
|
+
}
|
|
22
|
+
if (mostCommon.includes("\t"))
|
|
23
|
+
return {
|
|
24
|
+
amount: mostCommon.length,
|
|
25
|
+
type: "tab",
|
|
26
|
+
indent: mostCommon
|
|
27
|
+
};
|
|
28
|
+
return {
|
|
29
|
+
amount: mostCommon.length,
|
|
30
|
+
type: "space",
|
|
31
|
+
indent: mostCommon
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
export function detectNewline(text) {
|
|
35
|
+
if (!text)
|
|
36
|
+
return null;
|
|
37
|
+
if (text.includes(`\r
|
|
38
|
+
`))
|
|
39
|
+
return `\r
|
|
40
|
+
`;
|
|
41
|
+
if (text.includes(`
|
|
42
|
+
`))
|
|
43
|
+
return `
|
|
44
|
+
`;
|
|
45
|
+
if (text.includes("\r"))
|
|
46
|
+
return "\r";
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
49
|
+
export function detectNewlineGraceful(text, fallback = `
|
|
50
|
+
`) {
|
|
51
|
+
return detectNewline(text) || fallback;
|
|
52
|
+
}
|
|
53
|
+
export function normalizeNewlines(text, newline = `
|
|
54
|
+
`) {
|
|
55
|
+
return text.replace(/\r\n|\r|\n/g, newline);
|
|
56
|
+
}
|
|
57
|
+
export function countNewlines(text) {
|
|
58
|
+
const crlf = (text.match(/\r\n/g) || []).length, cr = (text.match(/\r(?!\n)/g) || []).length, lf = (text.match(/(?<!\r)\n/g) || []).length;
|
|
59
|
+
return {
|
|
60
|
+
crlf,
|
|
61
|
+
lf,
|
|
62
|
+
cr,
|
|
63
|
+
total: crlf + lf + cr
|
|
64
|
+
};
|
|
65
|
+
}
|
package/dist/equal.d.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Deep equality with NaN-safety and cycle detection.
|
|
3
|
+
*
|
|
4
|
+
* - `NaN === NaN` is false in JavaScript, so the previous `Object.is`
|
|
5
|
+
* tail correctly handled that case but only at the leaf — a
|
|
6
|
+
* `[NaN, NaN]` pair compared element-by-element worked, but compound
|
|
7
|
+
* structures relied on the tail. The new shape preserves that.
|
|
8
|
+
* - Circular references used to send isDeepEqual into infinite recursion
|
|
9
|
+
* (`a.self = a; isDeepEqual(a, a)` blew the stack). A WeakSet of
|
|
10
|
+
* already-visited objects breaks the cycle and treats two structurally
|
|
11
|
+
* identical cycles as equal.
|
|
12
|
+
*/
|
|
13
|
+
export declare function isDeepEqual(value1: any, value2: any, seen?: WeakMap<object, object>): boolean;
|
package/dist/equal.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { getTypeName } from "@stacksjs/types";
|
|
2
|
+
export function isDeepEqual(value1, value2, seen = new WeakMap) {
|
|
3
|
+
if (value1 === value2)
|
|
4
|
+
return !0;
|
|
5
|
+
if (typeof value1 === "number" && typeof value2 === "number" && Number.isNaN(value1) && Number.isNaN(value2))
|
|
6
|
+
return !0;
|
|
7
|
+
const type1 = getTypeName(value1), type2 = getTypeName(value2);
|
|
8
|
+
if (type1 !== type2)
|
|
9
|
+
return !1;
|
|
10
|
+
if (value1 && typeof value1 === "object") {
|
|
11
|
+
if (seen.get(value1) === value2)
|
|
12
|
+
return !0;
|
|
13
|
+
seen.set(value1, value2);
|
|
14
|
+
}
|
|
15
|
+
if (type1 === "array") {
|
|
16
|
+
if (value1.length !== value2.length)
|
|
17
|
+
return !1;
|
|
18
|
+
return value1.every((item, i) => isDeepEqual(item, value2[i], seen));
|
|
19
|
+
}
|
|
20
|
+
if (type1 === "object") {
|
|
21
|
+
const keyArr = Object.keys(value1);
|
|
22
|
+
if (keyArr.length !== Object.keys(value2).length)
|
|
23
|
+
return !1;
|
|
24
|
+
return keyArr.every((key) => isDeepEqual(value1[key], value2[key], seen));
|
|
25
|
+
}
|
|
26
|
+
return Object.is(value1, value2);
|
|
27
|
+
}
|