@stats-organization/github-readme-stats-core 2.1.3 → 2.1.4
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/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +0 -1
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +0 -1
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +0 -1
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +0 -1
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +0 -1
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +0 -1
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +0 -1
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +0 -1
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +0 -1
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +0 -1
- package/build/common/Card.d.ts +48 -60
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +49 -50
- package/build/common/I18n.d.ts +13 -14
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/I18n.js +13 -12
- package/build/common/color.d.ts +30 -40
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +30 -42
- package/build/common/config.d.ts +18 -2
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +17 -26
- package/build/common/constants.d.ts +2 -2
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +5 -3
- package/build/common/error.d.ts +36 -29
- package/build/common/error.d.ts.map +1 -1
- package/build/common/error.js +14 -10
- package/build/common/fmt.d.ts +14 -13
- package/build/common/fmt.d.ts.map +1 -1
- package/build/common/fmt.js +19 -15
- package/build/common/html.d.ts +2 -4
- package/build/common/html.d.ts.map +1 -1
- package/build/common/html.js +1 -5
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +0 -1
- package/build/common/icons.d.ts +22 -21
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +4 -5
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +0 -1
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +0 -1
- package/build/common/retryer.d.ts +18 -15
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +21 -30
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +0 -1
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +3 -6
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +3 -6
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +0 -1
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +0 -1
- package/build/translations.d.ts +627 -24
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +7 -8
- package/package.json +1 -1
- package/src/api/gist.js +0 -2
- package/src/api/index.js +0 -2
- package/src/api/pin.js +0 -2
- package/src/api/top-langs.js +0 -2
- package/src/api/wakatime.js +0 -2
- package/src/cards/gist.js +0 -2
- package/src/cards/repo.js +0 -2
- package/src/cards/stats.js +0 -2
- package/src/cards/top-languages.js +0 -2
- package/src/cards/wakatime.js +0 -2
- package/src/common/{Card.js → Card.ts} +89 -61
- package/src/common/I18n.ts +49 -0
- package/src/common/{color.js → color.ts} +55 -51
- package/src/common/config.ts +83 -0
- package/src/common/constants.ts +10 -0
- package/src/common/{error.js → error.ts} +20 -14
- package/src/common/{fmt.js → fmt.ts} +27 -19
- package/src/common/{html.js → html.ts} +3 -8
- package/src/common/http.js +0 -2
- package/src/common/{icons.js → icons.ts} +9 -7
- package/src/common/ops.js +0 -2
- package/src/common/render.js +0 -2
- package/src/common/{retryer.js → retryer.ts} +45 -32
- package/src/fetchers/gist.js +0 -2
- package/src/fetchers/repo.js +3 -7
- package/src/fetchers/stats.js +3 -7
- package/src/fetchers/top-languages.js +0 -2
- package/src/fetchers/types.d.ts +1 -1
- package/src/fetchers/wakatime.js +0 -2
- package/src/{translations.js → translations.ts} +14 -10
- package/src/common/I18n.js +0 -42
- package/src/common/config.js +0 -78
- package/src/common/constants.js +0 -9
package/build/common/color.d.ts
CHANGED
|
@@ -1,53 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Retrieves a gradient if color has more than one valid hex codes else a single color.
|
|
3
|
+
*
|
|
4
|
+
* @param color The color to parse.
|
|
5
|
+
* @param fallbackColor The fallback color.
|
|
6
|
+
* @returns The gradient or color.
|
|
7
|
+
*/
|
|
8
|
+
declare const fallbackColor: (color: string | undefined, fallbackColor: string | Array<string>) => string | Array<string>;
|
|
1
9
|
/**
|
|
2
10
|
* Object containing card colors.
|
|
3
11
|
*/
|
|
4
|
-
|
|
12
|
+
interface CardColors {
|
|
5
13
|
titleColor: string;
|
|
6
14
|
iconColor: string;
|
|
7
15
|
textColor: string;
|
|
8
|
-
bgColor: string | string
|
|
16
|
+
bgColor: string | Array<string>;
|
|
9
17
|
borderColor: string;
|
|
10
18
|
ringColor: string;
|
|
11
|
-
}
|
|
12
|
-
/**
|
|
13
|
-
* Retrieves a gradient if color has more than one valid hex codes else a single color.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} color The color to parse.
|
|
16
|
-
* @param {string | string[]} fallbackColor The fallback color.
|
|
17
|
-
* @returns {string | string[]} The gradient or color.
|
|
18
|
-
*/
|
|
19
|
-
export function fallbackColor(color: string, fallbackColor: string | string[]): string | string[];
|
|
20
|
-
/**
|
|
21
|
-
* Object containing card colors.
|
|
22
|
-
* @typedef {{
|
|
23
|
-
* titleColor: string;
|
|
24
|
-
* iconColor: string;
|
|
25
|
-
* textColor: string;
|
|
26
|
-
* bgColor: string | string[];
|
|
27
|
-
* borderColor: string;
|
|
28
|
-
* ringColor: string;
|
|
29
|
-
* }} CardColors
|
|
30
|
-
*/
|
|
19
|
+
}
|
|
31
20
|
/**
|
|
32
21
|
* Returns theme based colors with proper overrides and defaults.
|
|
33
22
|
*
|
|
34
|
-
* @param
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @param
|
|
38
|
-
* @param
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @returns
|
|
23
|
+
* @param props Function arguments.
|
|
24
|
+
* @param props.title_color Card title color.
|
|
25
|
+
* @param props.text_color Card text color.
|
|
26
|
+
* @param props.icon_color Card icon color.
|
|
27
|
+
* @param props.bg_color Card background color.
|
|
28
|
+
* @param props.border_color Card border color.
|
|
29
|
+
* @param props.ring_color Card ring color.
|
|
30
|
+
* @param props.theme Card theme.
|
|
31
|
+
* @returns Card colors.
|
|
43
32
|
*/
|
|
44
|
-
|
|
45
|
-
title_color?: string
|
|
46
|
-
text_color?: string
|
|
47
|
-
icon_color?: string
|
|
48
|
-
bg_color?: string
|
|
49
|
-
border_color?: string
|
|
50
|
-
ring_color?: string
|
|
51
|
-
theme?: string
|
|
52
|
-
})
|
|
33
|
+
declare const getCardColors: ({ title_color, text_color, icon_color, bg_color, border_color, ring_color, theme, }: {
|
|
34
|
+
title_color?: string;
|
|
35
|
+
text_color?: string;
|
|
36
|
+
icon_color?: string;
|
|
37
|
+
bg_color?: string;
|
|
38
|
+
border_color?: string;
|
|
39
|
+
ring_color?: string;
|
|
40
|
+
theme?: string;
|
|
41
|
+
}) => CardColors;
|
|
42
|
+
export { fallbackColor, getCardColors };
|
|
53
43
|
//# sourceMappingURL=color.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/common/color.
|
|
1
|
+
{"version":3,"file":"color.d.ts","sourceRoot":"","sources":["../../src/common/color.ts"],"names":[],"mappings":"AA2BA;;;;;;GAMG;AACH,QAAA,MAAM,aAAa,GACjB,OAAO,MAAM,GAAG,SAAS,EACzB,eAAe,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,KACpC,MAAM,GAAG,KAAK,CAAC,MAAM,CAWvB,CAAC;AAEF;;GAEG;AACH,UAAU,UAAU;IAClB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;IAChC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,aAAa,GAAI,qFAQpB;IACD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,KAAG,UAuDH,CAAC;AAEF,OAAO,EAAE,aAAa,EAAE,aAAa,EAAE,CAAC"}
|
package/build/common/color.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import { themes } from "../themes/index.js";
|
|
3
2
|
/**
|
|
4
3
|
* Checks if a string is a valid hex color.
|
|
5
4
|
*
|
|
6
|
-
* @param
|
|
7
|
-
* @returns
|
|
5
|
+
* @param hexColor String to check.
|
|
6
|
+
* @returns True if the given string is a valid hex color.
|
|
8
7
|
*/
|
|
9
8
|
const isValidHexColor = (hexColor) => {
|
|
10
9
|
return new RegExp(/^([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{3}|[A-Fa-f0-9]{4})$/).test(hexColor);
|
|
@@ -12,8 +11,8 @@ const isValidHexColor = (hexColor) => {
|
|
|
12
11
|
/**
|
|
13
12
|
* Check if the given string is a valid gradient.
|
|
14
13
|
*
|
|
15
|
-
* @param
|
|
16
|
-
* @returns
|
|
14
|
+
* @param colors Array of colors.
|
|
15
|
+
* @returns True if the given string is a valid gradient.
|
|
17
16
|
*/
|
|
18
17
|
const isValidGradient = (colors) => {
|
|
19
18
|
return (colors.length > 2 &&
|
|
@@ -22,60 +21,49 @@ const isValidGradient = (colors) => {
|
|
|
22
21
|
/**
|
|
23
22
|
* Retrieves a gradient if color has more than one valid hex codes else a single color.
|
|
24
23
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @returns
|
|
24
|
+
* @param color The color to parse.
|
|
25
|
+
* @param fallbackColor The fallback color.
|
|
26
|
+
* @returns The gradient or color.
|
|
28
27
|
*/
|
|
29
28
|
const fallbackColor = (color, fallbackColor) => {
|
|
30
|
-
|
|
31
|
-
let colors = color ? color.split(",") : [];
|
|
29
|
+
const colors = color ? color.split(",") : [];
|
|
32
30
|
if (colors.length > 1 && isValidGradient(colors)) {
|
|
33
|
-
|
|
31
|
+
return colors;
|
|
34
32
|
}
|
|
35
|
-
|
|
36
|
-
|
|
33
|
+
if (color !== undefined && isValidHexColor(color)) {
|
|
34
|
+
return `#${color}`;
|
|
35
|
+
}
|
|
36
|
+
return fallbackColor;
|
|
37
37
|
};
|
|
38
|
-
/**
|
|
39
|
-
* Object containing card colors.
|
|
40
|
-
* @typedef {{
|
|
41
|
-
* titleColor: string;
|
|
42
|
-
* iconColor: string;
|
|
43
|
-
* textColor: string;
|
|
44
|
-
* bgColor: string | string[];
|
|
45
|
-
* borderColor: string;
|
|
46
|
-
* ringColor: string;
|
|
47
|
-
* }} CardColors
|
|
48
|
-
*/
|
|
49
38
|
/**
|
|
50
39
|
* Returns theme based colors with proper overrides and defaults.
|
|
51
40
|
*
|
|
52
|
-
* @param
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
* @param
|
|
56
|
-
* @param
|
|
57
|
-
* @param
|
|
58
|
-
* @param
|
|
59
|
-
* @param
|
|
60
|
-
* @returns
|
|
41
|
+
* @param props Function arguments.
|
|
42
|
+
* @param props.title_color Card title color.
|
|
43
|
+
* @param props.text_color Card text color.
|
|
44
|
+
* @param props.icon_color Card icon color.
|
|
45
|
+
* @param props.bg_color Card background color.
|
|
46
|
+
* @param props.border_color Card border color.
|
|
47
|
+
* @param props.ring_color Card ring color.
|
|
48
|
+
* @param props.theme Card theme.
|
|
49
|
+
* @returns Card colors.
|
|
61
50
|
*/
|
|
62
51
|
const getCardColors = ({ title_color, text_color, icon_color, bg_color, border_color, ring_color, theme, }) => {
|
|
63
|
-
const defaultTheme = themes
|
|
64
|
-
const isThemeProvided = theme !==
|
|
65
|
-
|
|
66
|
-
|
|
52
|
+
const defaultTheme = themes.default;
|
|
53
|
+
const isThemeProvided = theme !== undefined && theme in themes;
|
|
54
|
+
const selectedTheme = isThemeProvided
|
|
55
|
+
? themes[theme]
|
|
56
|
+
: defaultTheme;
|
|
67
57
|
const defaultBorderColor = "border_color" in selectedTheme
|
|
68
58
|
? selectedTheme.border_color
|
|
69
|
-
:
|
|
70
|
-
defaultTheme.border_color;
|
|
59
|
+
: defaultTheme.border_color;
|
|
71
60
|
// get the color provided by the user else the theme color
|
|
72
61
|
// finally if both colors are invalid fallback to default theme
|
|
73
62
|
const titleColor = fallbackColor(title_color || selectedTheme.title_color, "#" + defaultTheme.title_color);
|
|
74
63
|
// get the color provided by the user else the theme color
|
|
75
64
|
// finally if both colors are invalid we use the titleColor
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
ring_color || selectedTheme.ring_color, titleColor);
|
|
65
|
+
// NOTE: no built-in theme defines `ring_color`, so it falls back to the title color.
|
|
66
|
+
const ringColor = fallbackColor(ring_color, titleColor);
|
|
79
67
|
const iconColor = fallbackColor(icon_color || selectedTheme.icon_color, "#" + defaultTheme.icon_color);
|
|
80
68
|
const textColor = fallbackColor(text_color || selectedTheme.text_color, "#" + defaultTheme.text_color);
|
|
81
69
|
const bgColor = fallbackColor(bg_color || selectedTheme.bg_color, "#" + defaultTheme.bg_color);
|
package/build/common/config.d.ts
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
type Env = Record<string, string | undefined>;
|
|
2
|
+
interface PersonalAccessToken {
|
|
3
|
+
name: string;
|
|
4
|
+
value: string;
|
|
5
|
+
}
|
|
6
|
+
interface Config {
|
|
7
|
+
whitelist: Array<string> | undefined;
|
|
8
|
+
gistWhitelist: Array<string> | undefined;
|
|
9
|
+
excludeRepositories: Array<string>;
|
|
10
|
+
fetchMultiPageStars: string | undefined;
|
|
11
|
+
pats: Array<PersonalAccessToken>;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* @param env Environment variables used to build the runtime config.
|
|
15
|
+
*/
|
|
16
|
+
export declare const loadConfigFromEnv: (env?: Env) => void;
|
|
17
|
+
export declare const getConfig: () => Config;
|
|
18
|
+
export {};
|
|
3
19
|
//# sourceMappingURL=config.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/common/config.
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/common/config.ts"],"names":[],"mappings":"AAAA,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAE9C,UAAU,mBAAmB;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,MAAM;IACd,SAAS,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACrC,aAAa,EAAE,KAAK,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACzC,mBAAmB,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACnC,mBAAmB,EAAE,MAAM,GAAG,SAAS,CAAC;IACxC,IAAI,EAAE,KAAK,CAAC,mBAAmB,CAAC,CAAC;CAClC;AAkDD;;GAEG;AACH,eAAO,MAAM,iBAAiB,GAAI,MAAK,GAAqB,KAAG,IAY9D,CAAC;AAIF,eAAO,MAAM,SAAS,QAAO,MAAuB,CAAC"}
|
package/build/common/config.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
/**
|
|
3
|
-
* @param
|
|
4
|
-
* @returns
|
|
2
|
+
* @param value Comma-separated string.
|
|
3
|
+
* @returns Parsed string values.
|
|
5
4
|
*/
|
|
6
5
|
const parseCsv = (value) => {
|
|
7
6
|
if (!value) {
|
|
@@ -10,58 +9,50 @@ const parseCsv = (value) => {
|
|
|
10
9
|
return value.split(",");
|
|
11
10
|
};
|
|
12
11
|
/**
|
|
13
|
-
* @param
|
|
14
|
-
* @returns
|
|
12
|
+
* @param env Environment variables to inspect.
|
|
13
|
+
* @returns Personal access tokens found in the environment.
|
|
15
14
|
*/
|
|
16
15
|
const parsePATsFromEnv = (env) => {
|
|
17
16
|
return Object.keys(env)
|
|
18
17
|
.filter((key) => /PAT_\d*$/.exec(key))
|
|
19
18
|
.map((name) => ({
|
|
20
19
|
name,
|
|
21
|
-
value: env[name],
|
|
20
|
+
value: env[name] ?? "",
|
|
22
21
|
}));
|
|
23
22
|
};
|
|
24
23
|
/**
|
|
25
|
-
* @returns
|
|
24
|
+
* @returns `process.env` if available, otherwise `{}`.
|
|
26
25
|
*/
|
|
27
26
|
const getDefaultEnv = () => {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
}
|
|
31
|
-
return {};
|
|
27
|
+
const processEnv = globalThis.process?.env;
|
|
28
|
+
return processEnv ?? {};
|
|
32
29
|
};
|
|
33
30
|
/**
|
|
34
|
-
* @param
|
|
35
|
-
* @returns
|
|
36
|
-
* whitelist: string[] | undefined,
|
|
37
|
-
* gistWhitelist: string[] | undefined,
|
|
38
|
-
* excludeRepositories: string[],
|
|
39
|
-
* fetchMultiPageStars: string | undefined,
|
|
40
|
-
* pats: {name: string, value: string}[],
|
|
41
|
-
* }} Normalized config object with defaults applied.
|
|
31
|
+
* @param config (Partial) config values to normalize.
|
|
32
|
+
* @returns Normalized config object with defaults applied.
|
|
42
33
|
*/
|
|
43
34
|
const normalizeConfig = (config = {}) => {
|
|
44
35
|
return {
|
|
45
36
|
whitelist: config.whitelist,
|
|
46
37
|
gistWhitelist: config.gistWhitelist,
|
|
47
|
-
excludeRepositories: config.excludeRepositories
|
|
38
|
+
excludeRepositories: config.excludeRepositories ?? [],
|
|
48
39
|
fetchMultiPageStars: config.fetchMultiPageStars,
|
|
49
|
-
pats: config.pats
|
|
40
|
+
pats: config.pats ?? [],
|
|
50
41
|
};
|
|
51
42
|
};
|
|
52
43
|
let currentConfig;
|
|
53
44
|
/**
|
|
54
|
-
* @param
|
|
45
|
+
* @param env Environment variables used to build the runtime config.
|
|
55
46
|
*/
|
|
56
47
|
export const loadConfigFromEnv = (env = getDefaultEnv()) => {
|
|
57
|
-
const whitelist = parseCsv(env
|
|
58
|
-
const gistWhitelist = parseCsv(env
|
|
59
|
-
const excludeRepositories = parseCsv(env
|
|
48
|
+
const whitelist = parseCsv(env["WHITELIST"]);
|
|
49
|
+
const gistWhitelist = parseCsv(env["GIST_WHITELIST"]);
|
|
50
|
+
const excludeRepositories = parseCsv(env["EXCLUDE_REPO"]) ?? [];
|
|
60
51
|
currentConfig = normalizeConfig({
|
|
61
52
|
whitelist,
|
|
62
53
|
gistWhitelist,
|
|
63
54
|
excludeRepositories,
|
|
64
|
-
fetchMultiPageStars: env
|
|
55
|
+
fetchMultiPageStars: env["FETCH_MULTI_PAGE_STARS"],
|
|
65
56
|
pats: parsePATsFromEnv(env),
|
|
66
57
|
});
|
|
67
58
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,MAAM,CAIrC,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
/**
|
|
3
2
|
* Valid owner affiliations for GitHub API queries.
|
|
4
|
-
* @type {Array<string>}
|
|
5
3
|
*/
|
|
6
|
-
const OWNER_AFFILIATIONS = [
|
|
4
|
+
const OWNER_AFFILIATIONS = [
|
|
5
|
+
"OWNER",
|
|
6
|
+
"COLLABORATOR",
|
|
7
|
+
"ORGANIZATION_MEMBER",
|
|
8
|
+
];
|
|
7
9
|
export { OWNER_AFFILIATIONS };
|
package/build/common/error.d.ts
CHANGED
|
@@ -1,7 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A general message to ask user to try again later.
|
|
3
|
+
*/
|
|
4
|
+
declare const TRY_AGAIN_LATER = "Please try again later";
|
|
5
|
+
/**
|
|
6
|
+
* A map of error types to secondary error messages.
|
|
7
|
+
*/
|
|
8
|
+
declare const SECONDARY_ERROR_MESSAGES: {
|
|
9
|
+
MAX_RETRY: string;
|
|
10
|
+
NO_TOKENS: string;
|
|
11
|
+
USER_NOT_FOUND: string;
|
|
12
|
+
GRAPHQL_ERROR: string;
|
|
13
|
+
GITHUB_REST_API_ERROR: string;
|
|
14
|
+
WAKATIME_USER_NOT_FOUND: string;
|
|
15
|
+
INVALID_AFFILIATION: string;
|
|
16
|
+
};
|
|
1
17
|
/**
|
|
2
18
|
* Custom error class to handle custom GRS errors.
|
|
3
19
|
*/
|
|
4
|
-
|
|
20
|
+
declare class CustomError extends Error {
|
|
21
|
+
type: string;
|
|
22
|
+
secondaryMessage: string;
|
|
23
|
+
/**
|
|
24
|
+
* Custom error constructor.
|
|
25
|
+
*
|
|
26
|
+
* @param message Error message.
|
|
27
|
+
* @param type Error type.
|
|
28
|
+
*/
|
|
29
|
+
constructor(message: string, type: string);
|
|
5
30
|
static MAX_RETRY: string;
|
|
6
31
|
static NO_TOKENS: string;
|
|
7
32
|
static USER_NOT_FOUND: string;
|
|
@@ -9,45 +34,27 @@ export class CustomError extends Error {
|
|
|
9
34
|
static GITHUB_REST_API_ERROR: string;
|
|
10
35
|
static WAKATIME_ERROR: string;
|
|
11
36
|
static INVALID_AFFILIATION: string;
|
|
12
|
-
/**
|
|
13
|
-
* Custom error constructor.
|
|
14
|
-
*
|
|
15
|
-
* @param {string} message Error message.
|
|
16
|
-
* @param {string} type Error type.
|
|
17
|
-
*/
|
|
18
|
-
constructor(message: string, type: string);
|
|
19
|
-
type: string;
|
|
20
|
-
secondaryMessage: string;
|
|
21
37
|
}
|
|
22
38
|
/**
|
|
23
39
|
* Missing query parameter class.
|
|
24
40
|
*/
|
|
25
|
-
|
|
41
|
+
declare class MissingParamError extends Error {
|
|
42
|
+
missedParams: Array<string>;
|
|
43
|
+
secondaryMessage: string | undefined;
|
|
26
44
|
/**
|
|
27
45
|
* Missing query parameter error constructor.
|
|
28
46
|
*
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
47
|
+
* @param missedParams An array of missing parameters names.
|
|
48
|
+
* @param secondaryMessage Optional secondary message to display.
|
|
31
49
|
*/
|
|
32
|
-
constructor(missedParams: string
|
|
33
|
-
missedParams: string[];
|
|
34
|
-
secondaryMessage: string | undefined;
|
|
50
|
+
constructor(missedParams: Array<string>, secondaryMessage?: string);
|
|
35
51
|
}
|
|
36
|
-
/**
|
|
37
|
-
* @type {Object<string, string>} A map of error types to secondary error messages.
|
|
38
|
-
*/
|
|
39
|
-
export const SECONDARY_ERROR_MESSAGES: {
|
|
40
|
-
[x: string]: string;
|
|
41
|
-
};
|
|
42
|
-
/**
|
|
43
|
-
* @type {string} A general message to ask user to try again later.
|
|
44
|
-
*/
|
|
45
|
-
export const TRY_AGAIN_LATER: string;
|
|
46
52
|
/**
|
|
47
53
|
* Retrieve secondary message from an error object.
|
|
48
54
|
*
|
|
49
|
-
* @param
|
|
50
|
-
* @returns
|
|
55
|
+
* @param err The error object.
|
|
56
|
+
* @returns The secondary message if available, otherwise undefined.
|
|
51
57
|
*/
|
|
52
|
-
|
|
58
|
+
declare const retrieveSecondaryMessage: (err: Error) => string | undefined;
|
|
59
|
+
export { CustomError, MissingParamError, SECONDARY_ERROR_MESSAGES, TRY_AGAIN_LATER, retrieveSecondaryMessage, };
|
|
53
60
|
//# sourceMappingURL=error.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/common/error.
|
|
1
|
+
{"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/common/error.ts"],"names":[],"mappings":"AAEA;;GAEG;AACH,QAAA,MAAM,eAAe,2BAA2B,CAAC;AAEjD;;GAEG;AACH,QAAA,MAAM,wBAAwB;;;;;;;;CAY7B,CAAC;AAEF;;GAEG;AACH,cAAM,WAAY,SAAQ,KAAK;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,gBAAgB,EAAE,MAAM,CAAC;IAEzB;;;;;OAKG;gBACS,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IAQzC,MAAM,CAAC,SAAS,SAAe;IAC/B,MAAM,CAAC,SAAS,SAAe;IAC/B,MAAM,CAAC,cAAc,SAAoB;IACzC,MAAM,CAAC,aAAa,SAAmB;IACvC,MAAM,CAAC,qBAAqB,SAA2B;IACvD,MAAM,CAAC,cAAc,SAAoB;IACzC,MAAM,CAAC,mBAAmB,SAAyB;CACpD;AAED;;GAEG;AACH,cAAM,iBAAkB,SAAQ,KAAK;IACnC,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IAC5B,gBAAgB,EAAE,MAAM,GAAG,SAAS,CAAC;IAErC;;;;;OAKG;gBACS,YAAY,EAAE,KAAK,CAAC,MAAM,CAAC,EAAE,gBAAgB,CAAC,EAAE,MAAM;CAQnE;AAED;;;;;GAKG;AACH,QAAA,MAAM,wBAAwB,GAAI,KAAK,KAAK,KAAG,MAAM,GAAG,SAIvD,CAAC;AAEF,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,wBAAwB,EACxB,eAAe,EACf,wBAAwB,GACzB,CAAC"}
|
package/build/common/error.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import { OWNER_AFFILIATIONS } from "./constants.js";
|
|
3
2
|
/**
|
|
4
|
-
*
|
|
3
|
+
* A general message to ask user to try again later.
|
|
5
4
|
*/
|
|
6
5
|
const TRY_AGAIN_LATER = "Please try again later";
|
|
7
6
|
/**
|
|
8
|
-
*
|
|
7
|
+
* A map of error types to secondary error messages.
|
|
9
8
|
*/
|
|
10
9
|
const SECONDARY_ERROR_MESSAGES = {
|
|
11
10
|
MAX_RETRY: "You can deploy own instance or wait until public will be no longer limited",
|
|
@@ -20,16 +19,19 @@ const SECONDARY_ERROR_MESSAGES = {
|
|
|
20
19
|
* Custom error class to handle custom GRS errors.
|
|
21
20
|
*/
|
|
22
21
|
class CustomError extends Error {
|
|
22
|
+
type;
|
|
23
|
+
secondaryMessage;
|
|
23
24
|
/**
|
|
24
25
|
* Custom error constructor.
|
|
25
26
|
*
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
27
|
+
* @param message Error message.
|
|
28
|
+
* @param type Error type.
|
|
28
29
|
*/
|
|
29
30
|
constructor(message, type) {
|
|
30
31
|
super(message);
|
|
31
32
|
this.type = type;
|
|
32
|
-
this.secondaryMessage =
|
|
33
|
+
this.secondaryMessage =
|
|
34
|
+
SECONDARY_ERROR_MESSAGES[type] ?? type;
|
|
33
35
|
}
|
|
34
36
|
static MAX_RETRY = "MAX_RETRY";
|
|
35
37
|
static NO_TOKENS = "NO_TOKENS";
|
|
@@ -43,11 +45,13 @@ class CustomError extends Error {
|
|
|
43
45
|
* Missing query parameter class.
|
|
44
46
|
*/
|
|
45
47
|
class MissingParamError extends Error {
|
|
48
|
+
missedParams;
|
|
49
|
+
secondaryMessage;
|
|
46
50
|
/**
|
|
47
51
|
* Missing query parameter error constructor.
|
|
48
52
|
*
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
53
|
+
* @param missedParams An array of missing parameters names.
|
|
54
|
+
* @param secondaryMessage Optional secondary message to display.
|
|
51
55
|
*/
|
|
52
56
|
constructor(missedParams, secondaryMessage) {
|
|
53
57
|
const msg = `Missing params ${missedParams
|
|
@@ -61,8 +65,8 @@ class MissingParamError extends Error {
|
|
|
61
65
|
/**
|
|
62
66
|
* Retrieve secondary message from an error object.
|
|
63
67
|
*
|
|
64
|
-
* @param
|
|
65
|
-
* @returns
|
|
68
|
+
* @param err The error object.
|
|
69
|
+
* @returns The secondary message if available, otherwise undefined.
|
|
66
70
|
*/
|
|
67
71
|
const retrieveSecondaryMessage = (err) => {
|
|
68
72
|
return "secondaryMessage" in err && typeof err.secondaryMessage === "string"
|
package/build/common/fmt.d.ts
CHANGED
|
@@ -1,27 +1,28 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Retrieves num with suffix k(thousands) precise to given decimal places.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @returns
|
|
4
|
+
* @param num The number to format.
|
|
5
|
+
* @param precision The number of decimal places to include.
|
|
6
|
+
* @returns The formatted number.
|
|
7
7
|
*/
|
|
8
|
-
|
|
8
|
+
declare const kFormatter: (num: number, precision?: number) => string | number;
|
|
9
9
|
/**
|
|
10
10
|
* Convert bytes to a human-readable string representation.
|
|
11
11
|
*
|
|
12
|
-
* @param
|
|
13
|
-
* @returns
|
|
12
|
+
* @param bytes The number of bytes to convert.
|
|
13
|
+
* @returns The human-readable representation of bytes.
|
|
14
14
|
* @throws {Error} If bytes is negative or too large.
|
|
15
15
|
*/
|
|
16
|
-
|
|
16
|
+
declare const formatBytes: (bytes: number) => string;
|
|
17
17
|
/**
|
|
18
18
|
* Split text over multiple lines based on the card width.
|
|
19
19
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @param
|
|
24
|
-
* @returns
|
|
20
|
+
* @param text Text to split.
|
|
21
|
+
* @param width Available wrap width in px.
|
|
22
|
+
* @param fontSize Font size in px.
|
|
23
|
+
* @param maxLines Maximum number of lines.
|
|
24
|
+
* @returns Array of lines.
|
|
25
25
|
*/
|
|
26
|
-
|
|
26
|
+
declare const wrapTextMultiline: (text: string, width: number, fontSize: number, maxLines?: number) => Array<string>;
|
|
27
|
+
export { kFormatter, formatBytes, wrapTextMultiline };
|
|
27
28
|
//# sourceMappingURL=fmt.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fmt.d.ts","sourceRoot":"","sources":["../../src/common/fmt.
|
|
1
|
+
{"version":3,"file":"fmt.d.ts","sourceRoot":"","sources":["../../src/common/fmt.ts"],"names":[],"mappings":"AAGA;;;;;;GAMG;AACH,QAAA,MAAM,UAAU,GAAI,KAAK,MAAM,EAAE,YAAY,MAAM,KAAG,MAAM,GAAG,MAa9D,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,WAAW,GAAI,OAAO,MAAM,KAAG,MAmBpC,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,iBAAiB,GACrB,MAAM,MAAM,EACZ,OAAO,MAAM,EACb,UAAU,MAAM,EAChB,iBAAY,KACX,KAAK,CAAC,MAAM,CAkBd,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,iBAAiB,EAAE,CAAC"}
|
package/build/common/fmt.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import { encodeHTML } from "./html.js";
|
|
3
2
|
import { splitWrappedText } from "./render.js";
|
|
4
3
|
/**
|
|
5
4
|
* Retrieves num with suffix k(thousands) precise to given decimal places.
|
|
6
5
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @returns
|
|
6
|
+
* @param num The number to format.
|
|
7
|
+
* @param precision The number of decimal places to include.
|
|
8
|
+
* @returns The formatted number.
|
|
10
9
|
*/
|
|
11
10
|
const kFormatter = (num, precision) => {
|
|
12
11
|
const abs = Math.abs(num);
|
|
@@ -17,13 +16,13 @@ const kFormatter = (num, precision) => {
|
|
|
17
16
|
if (abs < 1000) {
|
|
18
17
|
return sign * abs;
|
|
19
18
|
}
|
|
20
|
-
return sign * parseFloat((abs / 1000).toFixed(1))
|
|
19
|
+
return `${sign * parseFloat((abs / 1000).toFixed(1))}k`;
|
|
21
20
|
};
|
|
22
21
|
/**
|
|
23
22
|
* Convert bytes to a human-readable string representation.
|
|
24
23
|
*
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
24
|
+
* @param bytes The number of bytes to convert.
|
|
25
|
+
* @returns The human-readable representation of bytes.
|
|
27
26
|
* @throws {Error} If bytes is negative or too large.
|
|
28
27
|
*/
|
|
29
28
|
const formatBytes = (bytes) => {
|
|
@@ -36,19 +35,20 @@ const formatBytes = (bytes) => {
|
|
|
36
35
|
const sizes = ["B", "KB", "MB", "GB", "TB", "PB", "EB"];
|
|
37
36
|
const base = 1024;
|
|
38
37
|
const i = Math.floor(Math.log(bytes) / Math.log(base));
|
|
39
|
-
|
|
38
|
+
const unit = sizes[i];
|
|
39
|
+
if (unit === undefined) {
|
|
40
40
|
throw new Error("Bytes is too large to convert to a human-readable string");
|
|
41
41
|
}
|
|
42
|
-
return `${(bytes / Math.pow(base, i)).toFixed(1)} ${
|
|
42
|
+
return `${(bytes / Math.pow(base, i)).toFixed(1)} ${unit}`;
|
|
43
43
|
};
|
|
44
44
|
/**
|
|
45
45
|
* Split text over multiple lines based on the card width.
|
|
46
46
|
*
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @param
|
|
50
|
-
* @param
|
|
51
|
-
* @returns
|
|
47
|
+
* @param text Text to split.
|
|
48
|
+
* @param width Available wrap width in px.
|
|
49
|
+
* @param fontSize Font size in px.
|
|
50
|
+
* @param maxLines Maximum number of lines.
|
|
51
|
+
* @returns Array of lines.
|
|
52
52
|
*/
|
|
53
53
|
const wrapTextMultiline = (text, width, fontSize, maxLines = 3) => {
|
|
54
54
|
const wrapped = splitWrappedText(text, fontSize, width);
|
|
@@ -57,7 +57,11 @@ const wrapTextMultiline = (text, width, fontSize, maxLines = 3) => {
|
|
|
57
57
|
.slice(0, maxLines); // Only consider maxLines lines
|
|
58
58
|
// Add "..." to the last line if the text exceeds maxLines
|
|
59
59
|
if (wrapped.length > maxLines) {
|
|
60
|
-
|
|
60
|
+
const lastIndex = maxLines - 1;
|
|
61
|
+
const lastLine = lines[lastIndex];
|
|
62
|
+
if (lastLine !== undefined) {
|
|
63
|
+
lines[lastIndex] = `${lastLine}...`;
|
|
64
|
+
}
|
|
61
65
|
}
|
|
62
66
|
// Remove empty lines if text fits in less than maxLines lines
|
|
63
67
|
const multiLineText = lines.filter(Boolean);
|
package/build/common/html.d.ts
CHANGED
|
@@ -2,9 +2,7 @@
|
|
|
2
2
|
* Encode string as HTML.
|
|
3
3
|
*
|
|
4
4
|
* @see https://stackoverflow.com/a/48073476/10629172
|
|
5
|
-
*
|
|
6
|
-
* @param {string} str String to encode.
|
|
7
|
-
* @returns {string} Encoded string.
|
|
8
5
|
*/
|
|
9
|
-
|
|
6
|
+
declare const encodeHTML: (str: string) => string;
|
|
7
|
+
export { encodeHTML };
|
|
10
8
|
//# sourceMappingURL=html.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/common/html.
|
|
1
|
+
{"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/common/html.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,QAAA,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,MASjC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
|