@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.
- package/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +34 -1
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +18 -1
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +17 -1
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +36 -5
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +34 -1
- package/build/calculateRank.d.ts +12 -11
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +18 -18
- 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 +29 -21
- package/build/cards/stats.d.ts +4 -2
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +21 -9
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +39 -12
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +29 -9
- package/build/common/Card.d.ts +54 -60
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +88 -61
- 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 +56 -32
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +87 -50
- 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 +2 -6
- package/build/common/http.d.ts +13 -4
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +3 -4
- 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/languageColors.json +9 -1
- package/build/common/ops.d.ts +30 -29
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +32 -38
- package/build/common/render.d.ts +115 -111
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +138 -88
- package/build/common/retryer.d.ts +24 -13
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +22 -30
- package/build/fetchers/gist.d.ts +6 -21
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +30 -36
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +4 -7
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +3 -7
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +0 -1
- package/build/fetchers/types.d.ts +126 -0
- package/build/fetchers/types.d.ts.map +1 -0
- package/build/fetchers/types.js +1 -0
- 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 +4 -4
- package/src/_emoji-name-map.d.ts +10 -0
- package/src/api/gist.js +36 -2
- package/src/api/index.js +19 -2
- package/src/api/pin.js +18 -2
- package/src/api/top-langs.js +38 -6
- package/src/api/wakatime.js +36 -2
- package/src/{calculateRank.js → calculateRank.ts} +29 -19
- package/src/cards/gist.js +0 -2
- package/src/cards/repo.js +30 -22
- package/src/cards/stats.js +22 -10
- package/src/cards/top-languages.js +49 -13
- package/src/cards/wakatime.js +33 -10
- package/src/common/Card.ts +338 -0
- package/src/common/I18n.ts +49 -0
- package/src/common/color.ts +212 -0
- 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.ts +31 -0
- package/src/common/{icons.js → icons.ts} +9 -7
- package/src/common/languageColors.json +9 -1
- package/src/common/{ops.js → ops.ts} +48 -52
- package/src/common/{render.js → render.ts} +208 -98
- package/src/common/retryer.ts +125 -0
- package/src/fetchers/gist.ts +136 -0
- package/src/fetchers/repo.js +4 -8
- package/src/fetchers/stats.js +3 -8
- package/src/fetchers/top-languages.js +0 -2
- package/src/fetchers/{types.d.ts → types.ts} +1 -1
- package/src/fetchers/wakatime.js +0 -2
- package/src/{translations.js → translations.ts} +14 -10
- package/src/common/Card.js +0 -275
- package/src/common/I18n.js +0 -42
- package/src/common/color.js +0 -145
- package/src/common/config.js +0 -78
- package/src/common/constants.js +0 -9
- package/src/common/http.js +0 -21
- package/src/common/retryer.js +0 -104
- package/src/fetchers/gist.js +0 -114
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"}
|
package/build/common/html.js
CHANGED
|
@@ -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
|
|
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, ""));
|
package/build/common/http.d.ts
CHANGED
|
@@ -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
|
|
5
|
-
* @param
|
|
6
|
-
* @returns
|
|
12
|
+
* @param data Request data.
|
|
13
|
+
* @param headers Request headers.
|
|
14
|
+
* @returns Request response.
|
|
7
15
|
*/
|
|
8
|
-
|
|
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.
|
|
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"}
|
package/build/common/http.js
CHANGED
|
@@ -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
|
|
7
|
-
* @param
|
|
8
|
-
* @returns
|
|
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({
|
package/build/common/icons.d.ts
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
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
|
|
21
|
-
* @param
|
|
22
|
-
* @param
|
|
23
|
-
* @returns
|
|
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
|
-
|
|
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.
|
|
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"}
|
package/build/common/icons.js
CHANGED
|
@@ -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
|
|
47
|
-
* @param
|
|
48
|
-
* @param
|
|
49
|
-
* @returns
|
|
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#": "#
|
|
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",
|