@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.
Files changed (103) hide show
  1. package/build/api/gist.d.ts.map +1 -1
  2. package/build/api/gist.js +0 -1
  3. package/build/api/index.d.ts.map +1 -1
  4. package/build/api/index.js +0 -1
  5. package/build/api/pin.d.ts.map +1 -1
  6. package/build/api/pin.js +0 -1
  7. package/build/api/top-langs.d.ts.map +1 -1
  8. package/build/api/top-langs.js +0 -1
  9. package/build/api/wakatime.d.ts.map +1 -1
  10. package/build/api/wakatime.js +0 -1
  11. package/build/cards/gist.d.ts.map +1 -1
  12. package/build/cards/gist.js +0 -1
  13. package/build/cards/repo.d.ts.map +1 -1
  14. package/build/cards/repo.js +0 -1
  15. package/build/cards/stats.d.ts.map +1 -1
  16. package/build/cards/stats.js +0 -1
  17. package/build/cards/top-languages.d.ts.map +1 -1
  18. package/build/cards/top-languages.js +0 -1
  19. package/build/cards/wakatime.d.ts.map +1 -1
  20. package/build/cards/wakatime.js +0 -1
  21. package/build/common/Card.d.ts +48 -60
  22. package/build/common/Card.d.ts.map +1 -1
  23. package/build/common/Card.js +49 -50
  24. package/build/common/I18n.d.ts +13 -14
  25. package/build/common/I18n.d.ts.map +1 -1
  26. package/build/common/I18n.js +13 -12
  27. package/build/common/color.d.ts +30 -40
  28. package/build/common/color.d.ts.map +1 -1
  29. package/build/common/color.js +30 -42
  30. package/build/common/config.d.ts +18 -2
  31. package/build/common/config.d.ts.map +1 -1
  32. package/build/common/config.js +17 -26
  33. package/build/common/constants.d.ts +2 -2
  34. package/build/common/constants.d.ts.map +1 -1
  35. package/build/common/constants.js +5 -3
  36. package/build/common/error.d.ts +36 -29
  37. package/build/common/error.d.ts.map +1 -1
  38. package/build/common/error.js +14 -10
  39. package/build/common/fmt.d.ts +14 -13
  40. package/build/common/fmt.d.ts.map +1 -1
  41. package/build/common/fmt.js +19 -15
  42. package/build/common/html.d.ts +2 -4
  43. package/build/common/html.d.ts.map +1 -1
  44. package/build/common/html.js +1 -5
  45. package/build/common/http.d.ts.map +1 -1
  46. package/build/common/http.js +0 -1
  47. package/build/common/icons.d.ts +22 -21
  48. package/build/common/icons.d.ts.map +1 -1
  49. package/build/common/icons.js +4 -5
  50. package/build/common/ops.d.ts.map +1 -1
  51. package/build/common/ops.js +0 -1
  52. package/build/common/render.d.ts.map +1 -1
  53. package/build/common/render.js +0 -1
  54. package/build/common/retryer.d.ts +18 -15
  55. package/build/common/retryer.d.ts.map +1 -1
  56. package/build/common/retryer.js +21 -30
  57. package/build/fetchers/gist.d.ts.map +1 -1
  58. package/build/fetchers/gist.js +0 -1
  59. package/build/fetchers/repo.d.ts.map +1 -1
  60. package/build/fetchers/repo.js +3 -6
  61. package/build/fetchers/stats.d.ts.map +1 -1
  62. package/build/fetchers/stats.js +3 -6
  63. package/build/fetchers/top-languages.d.ts.map +1 -1
  64. package/build/fetchers/top-languages.js +0 -1
  65. package/build/fetchers/wakatime.d.ts.map +1 -1
  66. package/build/fetchers/wakatime.js +0 -1
  67. package/build/translations.d.ts +627 -24
  68. package/build/translations.d.ts.map +1 -1
  69. package/build/translations.js +7 -8
  70. package/package.json +1 -1
  71. package/src/api/gist.js +0 -2
  72. package/src/api/index.js +0 -2
  73. package/src/api/pin.js +0 -2
  74. package/src/api/top-langs.js +0 -2
  75. package/src/api/wakatime.js +0 -2
  76. package/src/cards/gist.js +0 -2
  77. package/src/cards/repo.js +0 -2
  78. package/src/cards/stats.js +0 -2
  79. package/src/cards/top-languages.js +0 -2
  80. package/src/cards/wakatime.js +0 -2
  81. package/src/common/{Card.js → Card.ts} +89 -61
  82. package/src/common/I18n.ts +49 -0
  83. package/src/common/{color.js → color.ts} +55 -51
  84. package/src/common/config.ts +83 -0
  85. package/src/common/constants.ts +10 -0
  86. package/src/common/{error.js → error.ts} +20 -14
  87. package/src/common/{fmt.js → fmt.ts} +27 -19
  88. package/src/common/{html.js → html.ts} +3 -8
  89. package/src/common/http.js +0 -2
  90. package/src/common/{icons.js → icons.ts} +9 -7
  91. package/src/common/ops.js +0 -2
  92. package/src/common/render.js +0 -2
  93. package/src/common/{retryer.js → retryer.ts} +45 -32
  94. package/src/fetchers/gist.js +0 -2
  95. package/src/fetchers/repo.js +3 -7
  96. package/src/fetchers/stats.js +3 -7
  97. package/src/fetchers/top-languages.js +0 -2
  98. package/src/fetchers/types.d.ts +1 -1
  99. package/src/fetchers/wakatime.js +0 -2
  100. package/src/{translations.js → translations.ts} +14 -10
  101. package/src/common/I18n.js +0 -42
  102. package/src/common/config.js +0 -78
  103. package/src/common/constants.js +0 -9
@@ -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
- export type CardColors = {
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 {Object} args Function arguments.
35
- * @param {string=} args.title_color Card title color.
36
- * @param {string=} args.text_color Card text color.
37
- * @param {string=} args.icon_color Card icon color.
38
- * @param {string=} args.bg_color Card background color.
39
- * @param {string=} args.border_color Card border color.
40
- * @param {string=} args.ring_color Card ring color.
41
- * @param {string=} args.theme Card theme.
42
- * @returns {CardColors} Card colors.
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
- export function getCardColors({ title_color, text_color, icon_color, bg_color, border_color, ring_color, theme, }: {
45
- title_color?: string | undefined;
46
- text_color?: string | undefined;
47
- icon_color?: string | undefined;
48
- bg_color?: string | undefined;
49
- border_color?: string | undefined;
50
- ring_color?: string | undefined;
51
- theme?: string | undefined;
52
- }): CardColors;
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.js"],"names":[],"mappings":";;;yBAoDa;IACT,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;IAC3B,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CAClB;AA9BJ;;;;;;GAMG;AACH,qCAJW,MAAM,iBACN,MAAM,GAAG,MAAM,EAAE,GACf,MAAM,GAAG,MAAM,EAAE,CAc7B;AAED;;;;;;;;;;GAUG;AAEH;;;;;;;;;;;;GAYG;AACH,mHATG;IAAsB,WAAW,GAAzB,MAAM,YAAC;IACO,UAAU,GAAxB,MAAM,YAAC;IACO,UAAU,GAAxB,MAAM,YAAC;IACO,QAAQ,GAAtB,MAAM,YAAC;IACO,YAAY,GAA1B,MAAM,YAAC;IACO,UAAU,GAAxB,MAAM,YAAC;IACO,KAAK,GAAnB,MAAM,YAAC;CACf,GAAU,UAAU,CAqEtB"}
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"}
@@ -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 {string} hexColor String to check.
7
- * @returns {boolean} True if the given string is a valid hex color.
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 {string[]} colors Array of colors.
16
- * @returns {boolean} True if the given string is a valid gradient.
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 {string} color The color to parse.
26
- * @param {string | string[]} fallbackColor The fallback color.
27
- * @returns {string | string[]} The gradient or color.
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
- let gradient = null;
31
- let colors = color ? color.split(",") : [];
29
+ const colors = color ? color.split(",") : [];
32
30
  if (colors.length > 1 && isValidGradient(colors)) {
33
- gradient = colors;
31
+ return colors;
34
32
  }
35
- return ((gradient ? gradient : isValidHexColor(color) && `#${color}`) ||
36
- fallbackColor);
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 {Object} args Function arguments.
53
- * @param {string=} args.title_color Card title color.
54
- * @param {string=} args.text_color Card text color.
55
- * @param {string=} args.icon_color Card icon color.
56
- * @param {string=} args.bg_color Card background color.
57
- * @param {string=} args.border_color Card border color.
58
- * @param {string=} args.ring_color Card ring color.
59
- * @param {string=} args.theme Card theme.
60
- * @returns {CardColors} Card colors.
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["default"];
64
- const isThemeProvided = theme !== null && theme !== undefined && theme in themes;
65
- // @ts-ignore
66
- const selectedTheme = isThemeProvided ? themes[theme] : defaultTheme;
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
- : // @ts-ignore
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
- const ringColor = fallbackColor(
77
- // @ts-ignore
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);
@@ -1,3 +1,19 @@
1
- export function loadConfigFromEnv(env?: Record<string, string | undefined>): void;
2
- export function getConfig(): any;
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.js"],"names":[],"mappings":"AA6DO,wCAFI,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,QAc5C;AAIM,iCAAqC"}
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"}
@@ -1,7 +1,6 @@
1
- // @ts-check
2
1
  /**
3
- * @param {string | undefined} value Comma-separated string.
4
- * @returns {string[] | undefined} Parsed string values.
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 {Record<string, string | undefined>} env Environment variables to inspect.
14
- * @returns {{name: string, value: string}[]} Personal access tokens found in the environment.
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 {Record<string, string | undefined>} `process.env` if available, otherwise `{}`.
24
+ * @returns `process.env` if available, otherwise `{}`.
26
25
  */
27
26
  const getDefaultEnv = () => {
28
- if (typeof process !== "undefined" && process?.env) {
29
- return process.env;
30
- }
31
- return {};
27
+ const processEnv = globalThis.process?.env;
28
+ return processEnv ?? {};
32
29
  };
33
30
  /**
34
- * @param {Partial<ReturnType<typeof loadConfigFromEnv>>} config (Partial) config values to normalize.
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 {Record<string, string | undefined>} env Environment variables used to build the runtime config.
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.WHITELIST);
58
- const gistWhitelist = parseCsv(env.GIST_WHITELIST);
59
- const excludeRepositories = parseCsv(env.EXCLUDE_REPO) || [];
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.FETCH_MULTI_PAGE_STARS,
55
+ fetchMultiPageStars: env["FETCH_MULTI_PAGE_STARS"],
65
56
  pats: parsePATsFromEnv(env),
66
57
  });
67
58
  };
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Valid owner affiliations for GitHub API queries.
3
- * @type {Array<string>}
4
3
  */
5
- export const OWNER_AFFILIATIONS: Array<string>;
4
+ declare const OWNER_AFFILIATIONS: Array<string>;
5
+ export { OWNER_AFFILIATIONS };
6
6
  //# sourceMappingURL=constants.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.js"],"names":[],"mappings":"AAEA;;;GAGG;AACH,iCAFU,KAAK,CAAC,MAAM,CAAC,CAEqD"}
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 = ["OWNER", "COLLABORATOR", "ORGANIZATION_MEMBER"];
4
+ const OWNER_AFFILIATIONS = [
5
+ "OWNER",
6
+ "COLLABORATOR",
7
+ "ORGANIZATION_MEMBER",
8
+ ];
7
9
  export { OWNER_AFFILIATIONS };
@@ -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
- export class CustomError extends Error {
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
- export class MissingParamError extends Error {
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 {string[]} missedParams An array of missing parameters names.
30
- * @param {string=} secondaryMessage Optional secondary message to display.
47
+ * @param missedParams An array of missing parameters names.
48
+ * @param secondaryMessage Optional secondary message to display.
31
49
  */
32
- constructor(missedParams: string[], secondaryMessage?: string | undefined);
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 {Error} err The error object.
50
- * @returns {string|undefined} The secondary message if available, otherwise undefined.
55
+ * @param err The error object.
56
+ * @returns The secondary message if available, otherwise undefined.
51
57
  */
52
- export function retrieveSecondaryMessage(err: Error): string | undefined;
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.js"],"names":[],"mappings":"AA0BA;;GAEG;AACH;IAaE,yBAA+B;IAC/B,yBAA+B;IAC/B,8BAAyC;IACzC,6BAAuC;IACvC,qCAAuD;IACvD,8BAAyC;IACzC,mCAAmD;IAlBnD;;;;;OAKG;IACH,qBAHW,MAAM,QACN,MAAM,EAMhB;IAFC,aAAgB;IAChB,yBAA8D;CAUjE;AAED;;GAEG;AACH;IACE;;;;;OAKG;IACH,0BAHW,MAAM,EAAE,qBACR,MAAM,YAAC,EASjB;IAFC,uBAAgC;IAChC,qCAAwC;CAE3C;AA5DD;;GAEG;AACH;;EAYE;AApBF;;GAEG;AACH,8BAFU,MAAM,CAEiC;AAgEjD;;;;;GAKG;AACH,8CAHW,KAAK,GACH,MAAM,GAAC,SAAS,CAM5B"}
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"}
@@ -1,11 +1,10 @@
1
- // @ts-check
2
1
  import { OWNER_AFFILIATIONS } from "./constants.js";
3
2
  /**
4
- * @type {string} A general message to ask user to try again later.
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
- * @type {Object<string, string>} A map of error types to secondary error messages.
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 {string} message Error message.
27
- * @param {string} type Error type.
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 = SECONDARY_ERROR_MESSAGES[type] || type;
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 {string[]} missedParams An array of missing parameters names.
50
- * @param {string=} secondaryMessage Optional secondary message to display.
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 {Error} err The error object.
65
- * @returns {string|undefined} The secondary message if available, otherwise undefined.
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"
@@ -1,27 +1,28 @@
1
1
  /**
2
2
  * Retrieves num with suffix k(thousands) precise to given decimal places.
3
3
  *
4
- * @param {number} num The number to format.
5
- * @param {number=} precision The number of decimal places to include.
6
- * @returns {string|number} The formatted number.
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
- export function kFormatter(num: number, precision?: number | undefined): string | number;
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 {number} bytes The number of bytes to convert.
13
- * @returns {string} The human-readable representation of bytes.
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
- export function formatBytes(bytes: number): string;
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 {string} text Text to split.
21
- * @param {number} width Available wrap width in px.
22
- * @param {number} fontSize Font size in px.
23
- * @param {number} maxLines Maximum number of lines.
24
- * @returns {string[]} Array of lines.
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
- export function wrapTextMultiline(text: string, width: number, fontSize: number, maxLines?: number): string[];
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.js"],"names":[],"mappings":"AAKA;;;;;;GAMG;AACH,gCAJW,MAAM,cACN,MAAM,YAAC,GACL,MAAM,GAAC,MAAM,CAezB;AAED;;;;;;GAMG;AACH,mCAJW,MAAM,GACJ,MAAM,CAqBlB;AAED;;;;;;;;GAQG;AACH,wCANW,MAAM,SACN,MAAM,YACN,MAAM,aACN,MAAM,GACJ,MAAM,EAAE,CAgBpB"}
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"}
@@ -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 {number} num The number to format.
8
- * @param {number=} precision The number of decimal places to include.
9
- * @returns {string|number} The formatted number.
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)) + "k";
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 {number} bytes The number of bytes to convert.
26
- * @returns {string} The human-readable representation of bytes.
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
- if (i >= sizes.length) {
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)} ${sizes[i]}`;
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 {string} text Text to split.
48
- * @param {number} width Available wrap width in px.
49
- * @param {number} fontSize Font size in px.
50
- * @param {number} maxLines Maximum number of lines.
51
- * @returns {string[]} Array of lines.
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
- lines[maxLines - 1] += "...";
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);
@@ -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
- export function encodeHTML(str: string): string;
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.js"],"names":[],"mappings":"AAEA;;;;;;;GAOG;AACH,gCAHW,MAAM,GACJ,MAAM,CAWlB"}
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"}