@stats-organization/github-readme-stats-core 2.1.3 → 2.1.5

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 (123) hide show
  1. package/build/api/gist.d.ts.map +1 -1
  2. package/build/api/gist.js +34 -1
  3. package/build/api/index.d.ts.map +1 -1
  4. package/build/api/index.js +18 -1
  5. package/build/api/pin.d.ts.map +1 -1
  6. package/build/api/pin.js +17 -1
  7. package/build/api/top-langs.d.ts.map +1 -1
  8. package/build/api/top-langs.js +36 -5
  9. package/build/api/wakatime.d.ts.map +1 -1
  10. package/build/api/wakatime.js +34 -1
  11. package/build/calculateRank.d.ts +12 -11
  12. package/build/calculateRank.d.ts.map +1 -1
  13. package/build/calculateRank.js +18 -18
  14. package/build/cards/gist.d.ts.map +1 -1
  15. package/build/cards/gist.js +0 -1
  16. package/build/cards/repo.d.ts.map +1 -1
  17. package/build/cards/repo.js +29 -21
  18. package/build/cards/stats.d.ts +4 -2
  19. package/build/cards/stats.d.ts.map +1 -1
  20. package/build/cards/stats.js +21 -9
  21. package/build/cards/top-languages.d.ts.map +1 -1
  22. package/build/cards/top-languages.js +39 -12
  23. package/build/cards/wakatime.d.ts.map +1 -1
  24. package/build/cards/wakatime.js +29 -9
  25. package/build/common/Card.d.ts +54 -60
  26. package/build/common/Card.d.ts.map +1 -1
  27. package/build/common/Card.js +88 -61
  28. package/build/common/I18n.d.ts +13 -14
  29. package/build/common/I18n.d.ts.map +1 -1
  30. package/build/common/I18n.js +13 -12
  31. package/build/common/color.d.ts +56 -32
  32. package/build/common/color.d.ts.map +1 -1
  33. package/build/common/color.js +87 -50
  34. package/build/common/config.d.ts +18 -2
  35. package/build/common/config.d.ts.map +1 -1
  36. package/build/common/config.js +17 -26
  37. package/build/common/constants.d.ts +2 -2
  38. package/build/common/constants.d.ts.map +1 -1
  39. package/build/common/constants.js +5 -3
  40. package/build/common/error.d.ts +36 -29
  41. package/build/common/error.d.ts.map +1 -1
  42. package/build/common/error.js +14 -10
  43. package/build/common/fmt.d.ts +14 -13
  44. package/build/common/fmt.d.ts.map +1 -1
  45. package/build/common/fmt.js +19 -15
  46. package/build/common/html.d.ts +2 -4
  47. package/build/common/html.d.ts.map +1 -1
  48. package/build/common/html.js +2 -6
  49. package/build/common/http.d.ts +13 -4
  50. package/build/common/http.d.ts.map +1 -1
  51. package/build/common/http.js +3 -4
  52. package/build/common/icons.d.ts +22 -21
  53. package/build/common/icons.d.ts.map +1 -1
  54. package/build/common/icons.js +4 -5
  55. package/build/common/languageColors.json +9 -1
  56. package/build/common/ops.d.ts +30 -29
  57. package/build/common/ops.d.ts.map +1 -1
  58. package/build/common/ops.js +32 -38
  59. package/build/common/render.d.ts +115 -111
  60. package/build/common/render.d.ts.map +1 -1
  61. package/build/common/render.js +138 -88
  62. package/build/common/retryer.d.ts +24 -13
  63. package/build/common/retryer.d.ts.map +1 -1
  64. package/build/common/retryer.js +22 -30
  65. package/build/fetchers/gist.d.ts +6 -21
  66. package/build/fetchers/gist.d.ts.map +1 -1
  67. package/build/fetchers/gist.js +30 -36
  68. package/build/fetchers/repo.d.ts.map +1 -1
  69. package/build/fetchers/repo.js +4 -7
  70. package/build/fetchers/stats.d.ts.map +1 -1
  71. package/build/fetchers/stats.js +3 -7
  72. package/build/fetchers/top-languages.d.ts.map +1 -1
  73. package/build/fetchers/top-languages.js +0 -1
  74. package/build/fetchers/types.d.ts +126 -0
  75. package/build/fetchers/types.d.ts.map +1 -0
  76. package/build/fetchers/types.js +1 -0
  77. package/build/fetchers/wakatime.d.ts.map +1 -1
  78. package/build/fetchers/wakatime.js +0 -1
  79. package/build/translations.d.ts +627 -24
  80. package/build/translations.d.ts.map +1 -1
  81. package/build/translations.js +7 -8
  82. package/package.json +4 -4
  83. package/src/_emoji-name-map.d.ts +10 -0
  84. package/src/api/gist.js +36 -2
  85. package/src/api/index.js +19 -2
  86. package/src/api/pin.js +18 -2
  87. package/src/api/top-langs.js +38 -6
  88. package/src/api/wakatime.js +36 -2
  89. package/src/{calculateRank.js → calculateRank.ts} +29 -19
  90. package/src/cards/gist.js +0 -2
  91. package/src/cards/repo.js +30 -22
  92. package/src/cards/stats.js +22 -10
  93. package/src/cards/top-languages.js +49 -13
  94. package/src/cards/wakatime.js +33 -10
  95. package/src/common/Card.ts +338 -0
  96. package/src/common/I18n.ts +49 -0
  97. package/src/common/color.ts +212 -0
  98. package/src/common/config.ts +83 -0
  99. package/src/common/constants.ts +10 -0
  100. package/src/common/{error.js → error.ts} +20 -14
  101. package/src/common/{fmt.js → fmt.ts} +27 -19
  102. package/src/common/{html.js → html.ts} +3 -8
  103. package/src/common/http.ts +31 -0
  104. package/src/common/{icons.js → icons.ts} +9 -7
  105. package/src/common/languageColors.json +9 -1
  106. package/src/common/{ops.js → ops.ts} +48 -52
  107. package/src/common/{render.js → render.ts} +208 -98
  108. package/src/common/retryer.ts +125 -0
  109. package/src/fetchers/gist.ts +136 -0
  110. package/src/fetchers/repo.js +4 -8
  111. package/src/fetchers/stats.js +3 -8
  112. package/src/fetchers/top-languages.js +0 -2
  113. package/src/fetchers/{types.d.ts → types.ts} +1 -1
  114. package/src/fetchers/wakatime.js +0 -2
  115. package/src/{translations.js → translations.ts} +14 -10
  116. package/src/common/Card.js +0 -275
  117. package/src/common/I18n.js +0 -42
  118. package/src/common/color.js +0 -145
  119. package/src/common/config.js +0 -78
  120. package/src/common/constants.js +0 -9
  121. package/src/common/http.js +0 -21
  122. package/src/common/retryer.js +0 -104
  123. package/src/fetchers/gist.js +0 -114
@@ -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"}
@@ -1,16 +1,12 @@
1
- // @ts-check
2
1
  /**
3
2
  * Encode string as HTML.
4
3
  *
5
4
  * @see https://stackoverflow.com/a/48073476/10629172
6
- *
7
- * @param {string} str String to encode.
8
- * @returns {string} Encoded string.
9
5
  */
10
6
  const encodeHTML = (str) => {
11
7
  return (str
12
- .replace(/[\u00A0-\u9999<>&](?!#)/gim, (i) => {
13
- return "&#" + i.charCodeAt(0) + ";";
8
+ .replace(/[\u00A0-\u9999<>&"'](?!#)/gim, (i) => {
9
+ return `&#${i.charCodeAt(0)};`;
14
10
  })
15
11
  // eslint-disable-next-line no-control-regex
16
12
  .replace(/\u0008/gim, ""));
@@ -1,9 +1,18 @@
1
+ import type { AxiosRequestConfig, AxiosResponse } from "axios";
2
+ /** Body of a GraphQL request sent to the GitHub API. */
3
+ interface GraphQLRequest {
4
+ /** The GraphQL query. */
5
+ query: string;
6
+ /** Variables referenced by the query. */
7
+ variables: Record<string, unknown>;
8
+ }
1
9
  /**
2
10
  * Send GraphQL request to GitHub API.
3
11
  *
4
- * @param {import('axios').AxiosRequestConfig['data']} data Request data.
5
- * @param {import('axios').AxiosRequestConfig['headers']} headers Request headers.
6
- * @returns {Promise<any>} Request response.
12
+ * @param data Request data.
13
+ * @param headers Request headers.
14
+ * @returns Request response.
7
15
  */
8
- export function request(data: import("axios").AxiosRequestConfig["data"], headers: import("axios").AxiosRequestConfig["headers"]): Promise<any>;
16
+ declare const request: (data: GraphQLRequest, headers: NonNullable<AxiosRequestConfig["headers"]>) => Promise<AxiosResponse>;
17
+ export { request };
9
18
  //# sourceMappingURL=http.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/common/http.js"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,8BAJW,OAAO,OAAO,EAAE,kBAAkB,CAAC,MAAM,CAAC,WAC1C,OAAO,OAAO,EAAE,kBAAkB,CAAC,SAAS,CAAC,GAC3C,OAAO,CAAC,GAAG,CAAC,CASxB"}
1
+ {"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../../src/common/http.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,kBAAkB,EAAE,aAAa,EAAE,MAAM,OAAO,CAAC;AAE/D,wDAAwD;AACxD,UAAU,cAAc;IACtB,yBAAyB;IACzB,KAAK,EAAE,MAAM,CAAC;IACd,yCAAyC;IACzC,SAAS,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CACpC;AAED;;;;;;GAMG;AACH,QAAA,MAAM,OAAO,GACX,MAAM,cAAc,EACpB,SAAS,WAAW,CAAC,kBAAkB,CAAC,SAAS,CAAC,CAAC,KAClD,OAAO,CAAC,aAAa,CAOvB,CAAC;AAEF,OAAO,EAAE,OAAO,EAAE,CAAC"}
@@ -1,11 +1,10 @@
1
- // @ts-check
2
1
  import axios from "axios";
3
2
  /**
4
3
  * Send GraphQL request to GitHub API.
5
4
  *
6
- * @param {import('axios').AxiosRequestConfig['data']} data Request data.
7
- * @param {import('axios').AxiosRequestConfig['headers']} headers Request headers.
8
- * @returns {Promise<any>} Request response.
5
+ * @param data Request data.
6
+ * @param headers Request headers.
7
+ * @returns Request response.
9
8
  */
10
9
  const request = (data, headers) => {
11
10
  return axios({
@@ -1,26 +1,27 @@
1
- export namespace icons {
2
- let star: string;
3
- let commits: string;
4
- let prs: string;
5
- let prs_merged: string;
6
- let prs_merged_percentage: string;
7
- let issues: string;
8
- let icon: string;
9
- let contribs: string;
10
- let fork: string;
11
- let reviews: string;
12
- let discussions_started: string;
13
- let discussions_answered: string;
14
- let comments: string;
15
- let gist: string;
16
- }
1
+ declare const icons: {
2
+ star: string;
3
+ commits: string;
4
+ prs: string;
5
+ prs_merged: string;
6
+ prs_merged_percentage: string;
7
+ issues: string;
8
+ icon: string;
9
+ contribs: string;
10
+ fork: string;
11
+ reviews: string;
12
+ discussions_started: string;
13
+ discussions_answered: string;
14
+ comments: string;
15
+ gist: string;
16
+ };
17
17
  /**
18
18
  * Get rank icon
19
19
  *
20
- * @param {string} rankIcon - The rank icon type.
21
- * @param {string} rankLevel - The rank level.
22
- * @param {number} percentile - The rank percentile.
23
- * @returns {string} - The SVG code of the rank icon
20
+ * @param rankIcon - The rank icon type.
21
+ * @param rankLevel - The rank level.
22
+ * @param percentile - The rank percentile.
23
+ * @returns The SVG code of the rank icon
24
24
  */
25
- export function rankIcon(rankIcon: string, rankLevel: string, percentile: number): string;
25
+ declare const rankIcon: (rankIcon: string, rankLevel: string, percentile: number) => string;
26
+ export { icons, rankIcon };
26
27
  //# sourceMappingURL=icons.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/common/icons.js"],"names":[],"mappings":";;;;;;;;;;;;;;;;AA6CA;;;;;;;GAOG;AACH,mCALW,MAAM,aACN,MAAM,cACN,MAAM,GACJ,MAAM,CA2BlB"}
1
+ {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/common/icons.ts"],"names":[],"mappings":"AA0BA,QAAA,MAAM,KAAK;;;;;;;;;;;;;;;CAeV,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,QAAQ,GACZ,UAAU,MAAM,EAChB,WAAW,MAAM,EACjB,YAAY,MAAM,KACjB,MAyBF,CAAC;AAEF,OAAO,EAAE,KAAK,EAAE,QAAQ,EAAE,CAAC"}
@@ -1,4 +1,3 @@
1
- // @ts-check
2
1
  /*
3
2
  The icons in this file are based on https://github.com/primer/octicons which is released under the MIT license:
4
3
 
@@ -43,10 +42,10 @@ const icons = {
43
42
  /**
44
43
  * Get rank icon
45
44
  *
46
- * @param {string} rankIcon - The rank icon type.
47
- * @param {string} rankLevel - The rank level.
48
- * @param {number} percentile - The rank percentile.
49
- * @returns {string} - The SVG code of the rank icon
45
+ * @param rankIcon - The rank icon type.
46
+ * @param rankLevel - The rank level.
47
+ * @param percentile - The rank percentile.
48
+ * @returns The SVG code of the rank icon
50
49
  */
51
50
  const rankIcon = (rankIcon, rankLevel, percentile) => {
52
51
  switch (rankIcon) {
@@ -44,6 +44,7 @@
44
44
  "Awk": "#c30e9b",
45
45
  "B (Formal Method)": "#8aa8c5",
46
46
  "B4X": "#00e4ff",
47
+ "BAML": "#a855f7",
47
48
  "BASIC": "#ff0000",
48
49
  "BQN": "#2b7067",
49
50
  "Ballerina": "#FF5000",
@@ -58,6 +59,7 @@
58
59
  "Blade": "#f7523f",
59
60
  "BlitzBasic": "#00FFAE",
60
61
  "BlitzMax": "#cd6400",
62
+ "Blueprint": "#3584E4",
61
63
  "Bluespec": "#12223c",
62
64
  "Bluespec BH": "#12223c",
63
65
  "Boo": "#d4bec1",
@@ -69,7 +71,7 @@
69
71
  "Bru": "#F4AA41",
70
72
  "BuildStream": "#006bff",
71
73
  "C": "#555555",
72
- "C#": "#178600",
74
+ "C#": "#7355dd",
73
75
  "C++": "#f34b7d",
74
76
  "C3": "#2563eb",
75
77
  "CAP CDS": "#0092d1",
@@ -227,6 +229,7 @@
227
229
  "Graphviz (DOT)": "#2596be",
228
230
  "Groovy": "#4298b8",
229
231
  "Groovy Server Pages": "#4298b8",
232
+ "GtkRC": "#7fe719",
230
233
  "HAProxy": "#106da9",
231
234
  "HCL": "#844FBA",
232
235
  "HIP": "#4F3A4F",
@@ -416,6 +419,7 @@
416
419
  "OpenSCAD": "#e5cd45",
417
420
  "Option List": "#476732",
418
421
  "Org": "#77aa99",
422
+ "OverPy": "#78b355",
419
423
  "OverpassQL": "#cce2aa",
420
424
  "Oxygene": "#cdd0e3",
421
425
  "Oz": "#fab738",
@@ -445,10 +449,12 @@
445
449
  "Portugol": "#f8bd00",
446
450
  "PostCSS": "#dc3a0c",
447
451
  "PostScript": "#da291c",
452
+ "Power Query": "#d38e0d",
448
453
  "PowerBuilder": "#8f0f8d",
449
454
  "PowerShell": "#012456",
450
455
  "Praat": "#c8506d",
451
456
  "Prisma": "#0c344b",
457
+ "Pro*C": "#bb8368",
452
458
  "Processing": "#0096D8",
453
459
  "Procfile": "#3B2F63",
454
460
  "Prolog": "#74283c",
@@ -490,6 +496,7 @@
490
496
  "Rebol": "#358a5b",
491
497
  "Record Jar": "#0673ba",
492
498
  "Red": "#f50000",
499
+ "Redscript": "#f44336",
493
500
  "Regular Expression": "#009a00",
494
501
  "Ren'Py": "#ff7f7f",
495
502
  "Rez": "#FFDAB3",
@@ -659,6 +666,7 @@
659
666
  "nanorc": "#2d004d",
660
667
  "nesC": "#94B0C7",
661
668
  "ooc": "#b0b77e",
669
+ "pkg-config": "#2b5e82",
662
670
  "q": "#0040cd",
663
671
  "reStructuredText": "#141414",
664
672
  "sed": "#64b970",