@stats-organization/github-readme-stats-core 2.1.4 → 2.2.0
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 +2 -7
- package/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +28 -26
- package/build/api/index.d.ts +3 -8
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +32 -36
- package/build/api/pin.d.ts +2 -7
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +18 -33
- package/build/api/top-langs.d.ts +2 -7
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +32 -44
- package/build/api/wakatime.d.ts +2 -7
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +28 -26
- package/build/calculateRank.d.ts +12 -11
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +18 -18
- package/build/cards/common-options.d.ts +13 -0
- package/build/cards/common-options.d.ts.map +1 -0
- package/build/cards/common-options.js +1 -0
- package/build/cards/gist.d.ts +11 -16
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +26 -31
- package/build/cards/repo.d.ts +19 -16
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +79 -72
- package/build/cards/stats.d.ts +29 -44
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +118 -173
- package/build/cards/top-languages.d.ts +81 -77
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +186 -184
- package/build/cards/wakatime.d.ts +21 -11
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +92 -109
- package/build/common/Card.d.ts +41 -14
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +92 -31
- package/build/common/I18n.d.ts +4 -2
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/color.d.ts +91 -15
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +163 -17
- package/build/common/config.d.ts +2 -1
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +16 -26
- package/build/common/constants.d.ts +2 -1
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/date.d.ts +37 -0
- package/build/common/date.d.ts.map +1 -0
- package/build/common/date.js +31 -0
- package/build/common/html.js +1 -1
- package/build/common/http.d.ts +37 -5
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +29 -6
- package/build/common/icons.d.ts +1 -0
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +1 -0
- package/build/common/languageColors.d.ts +11 -0
- package/build/common/languageColors.d.ts.map +1 -0
- package/build/common/languageColors.js +15 -0
- package/build/common/languageColors.json +10 -1
- package/build/common/ops.d.ts +27 -33
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +31 -48
- package/build/common/render.d.ts +154 -113
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +209 -92
- package/build/common/retryer.d.ts +15 -6
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +2 -0
- package/build/fetchers/gist.d.ts +6 -21
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +28 -64
- package/build/fetchers/repo.d.ts +12 -11
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +27 -68
- package/build/fetchers/stats.d.ts +24 -17
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +302 -184
- package/build/fetchers/top-languages.d.ts +10 -15
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +52 -103
- package/build/fetchers/types.d.ts +130 -0
- package/build/fetchers/types.d.ts.map +1 -0
- package/build/fetchers/types.js +1 -0
- package/build/fetchers/wakatime.d.ts +9 -5
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +8 -4
- package/build/graphql/contributionsDocument.d.ts +18 -0
- package/build/graphql/contributionsDocument.d.ts.map +1 -0
- package/build/graphql/contributionsDocument.js +30 -0
- package/build/graphql/generated/common.d.ts +42 -0
- package/build/graphql/generated/common.d.ts.map +1 -0
- package/build/graphql/generated/common.js +2 -0
- package/build/graphql/generated/gist.d.ts +44 -0
- package/build/graphql/generated/gist.d.ts.map +1 -0
- package/build/graphql/generated/gist.js +27 -0
- package/build/graphql/generated/repo.d.ts +67 -0
- package/build/graphql/generated/repo.d.ts.map +1 -0
- package/build/graphql/generated/repo.js +30 -0
- package/build/graphql/generated/stats.d.ts +150 -0
- package/build/graphql/generated/stats.d.ts.map +1 -0
- package/build/graphql/generated/stats.js +95 -0
- package/build/graphql/generated/top-languages.d.ts +54 -0
- package/build/graphql/generated/top-languages.d.ts.map +1 -0
- package/build/graphql/generated/top-languages.js +27 -0
- package/build/graphql/graphqlDocument.d.ts +22 -0
- package/build/graphql/graphqlDocument.d.ts.map +1 -0
- package/build/graphql/graphqlDocument.js +8 -0
- package/build/graphql/reposContributedToDocument.d.ts +27 -0
- package/build/graphql/reposContributedToDocument.d.ts.map +1 -0
- package/build/graphql/reposContributedToDocument.js +59 -0
- package/build/index.d.ts +3 -1
- package/build/index.d.ts.map +1 -1
- package/build/index.js +2 -1
- package/build/themes/index.d.ts +32 -0
- package/build/themes/index.d.ts.map +1 -1
- package/build/themes/index.js +28 -0
- package/build/translations.d.ts +17 -0
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +17 -0
- package/package.json +14 -8
- package/src/_emoji-name-map.d.ts +10 -0
- package/src/_github-username-regex.d.ts +4 -0
- package/src/api/gist.js +31 -31
- package/src/api/index.js +40 -42
- package/src/api/pin.js +20 -38
- package/src/api/top-langs.js +36 -49
- package/src/api/wakatime.js +31 -31
- package/src/{calculateRank.js → calculateRank.ts} +29 -19
- package/src/cards/common-options.ts +13 -0
- package/src/cards/{gist.js → gist.ts} +37 -37
- package/src/cards/{repo.js → repo.ts} +107 -79
- package/src/cards/{stats.js → stats.ts} +173 -210
- package/src/cards/{top-languages.js → top-languages.ts} +325 -243
- package/src/cards/{wakatime.js → wakatime.ts} +158 -127
- package/src/common/Card.ts +123 -43
- package/src/common/I18n.ts +6 -2
- package/src/common/color.ts +240 -28
- package/src/common/config.ts +22 -29
- package/src/common/constants.ts +3 -1
- package/src/common/date.ts +45 -0
- package/src/common/html.ts +1 -1
- package/src/common/http.ts +71 -0
- package/src/common/icons.ts +1 -0
- package/src/common/languageColors.json +10 -1
- package/src/common/languageColors.ts +19 -0
- package/src/common/ops.ts +158 -0
- package/src/common/render.ts +652 -0
- package/src/common/retryer.ts +21 -12
- package/src/fetchers/gist.ts +79 -0
- package/src/fetchers/repo.ts +114 -0
- package/src/fetchers/stats.ts +743 -0
- package/src/fetchers/top-languages.ts +135 -0
- package/src/fetchers/{types.d.ts → types.ts} +28 -20
- package/src/fetchers/{wakatime.js → wakatime.ts} +19 -5
- package/src/graphql/contributionsDocument.ts +44 -0
- package/src/graphql/generated/common.ts +26 -0
- package/src/graphql/generated/gist.ts +59 -0
- package/src/graphql/generated/repo.ts +90 -0
- package/src/graphql/generated/stats.ts +194 -0
- package/src/graphql/generated/top-languages.ts +75 -0
- package/src/graphql/graphqlDocument.ts +25 -0
- package/src/graphql/queries/gist.graphql +25 -0
- package/src/graphql/queries/repo.graphql +28 -0
- package/src/graphql/queries/stats.graphql +120 -0
- package/src/graphql/queries/top-languages.graphql +34 -0
- package/src/graphql/reposContributedToDocument.ts +86 -0
- package/src/index.ts +3 -1
- package/src/themes/index.ts +33 -0
- package/src/translations.ts +17 -0
- package/src/cards/types.d.ts +0 -78
- package/src/common/http.js +0 -19
- package/src/common/ops.js +0 -170
- package/src/common/render.js +0 -440
- package/src/fetchers/gist.js +0 -112
- package/src/fetchers/repo.js +0 -161
- package/src/fetchers/stats.js +0 -474
- package/src/fetchers/top-languages.js +0 -175
- package/src/themes/README.md +0 -229
package/build/api/wakatime.js
CHANGED
|
@@ -1,24 +1,41 @@
|
|
|
1
1
|
import { renderWakatimeCard } from "../cards/wakatime.js";
|
|
2
|
+
import { findInvalidColorParam, pickColorParams } from "../common/color.js";
|
|
2
3
|
import { MissingParamError, retrieveSecondaryMessage, } from "../common/error.js";
|
|
3
4
|
import { parseArray, parseBoolean } from "../common/ops.js";
|
|
4
5
|
import { renderError } from "../common/render.js";
|
|
5
6
|
import { fetchWakatimeStats } from "../fetchers/wakatime.js";
|
|
6
7
|
import { isLocaleAvailable } from "../translations.js";
|
|
7
8
|
// @ts-ignore
|
|
8
|
-
export default async ({ username,
|
|
9
|
+
export default async ({ username, hide_border, card_width, line_height, hide_title, hide_progress, custom_title, locale, layout, langs_count, hide, api_domain, border_radius, display_format, disable_animations, ...remainingParams }) => {
|
|
10
|
+
const colorParams = pickColorParams(remainingParams);
|
|
11
|
+
const invalidColorInput = findInvalidColorParam(colorParams);
|
|
12
|
+
if (invalidColorInput) {
|
|
13
|
+
return {
|
|
14
|
+
status: "error - permanent",
|
|
15
|
+
content: renderError({
|
|
16
|
+
message: "Something went wrong",
|
|
17
|
+
secondaryMessage: `Invalid color input for parameter "${invalidColorInput}"`,
|
|
18
|
+
}),
|
|
19
|
+
};
|
|
20
|
+
}
|
|
9
21
|
if (locale && !isLocaleAvailable(locale)) {
|
|
10
22
|
return {
|
|
11
23
|
status: "error - permanent",
|
|
12
24
|
content: renderError({
|
|
13
25
|
message: "Something went wrong",
|
|
14
26
|
secondaryMessage: "Language not found",
|
|
15
|
-
renderOptions:
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
27
|
+
renderOptions: colorParams,
|
|
28
|
+
}),
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
const safePattern = /^[-\w/.,]+$/;
|
|
32
|
+
if (username && !safePattern.test(username)) {
|
|
33
|
+
return {
|
|
34
|
+
status: "error - permanent",
|
|
35
|
+
content: renderError({
|
|
36
|
+
message: "Something went wrong",
|
|
37
|
+
secondaryMessage: "Username contains unsafe characters",
|
|
38
|
+
renderOptions: colorParams,
|
|
22
39
|
}),
|
|
23
40
|
};
|
|
24
41
|
}
|
|
@@ -27,20 +44,15 @@ export default async ({ username, title_color, icon_color, hide_border, card_wid
|
|
|
27
44
|
return {
|
|
28
45
|
status: "success",
|
|
29
46
|
content: renderWakatimeCard(stats, {
|
|
47
|
+
...colorParams,
|
|
30
48
|
custom_title,
|
|
31
49
|
hide_title: parseBoolean(hide_title),
|
|
32
50
|
hide_border: parseBoolean(hide_border),
|
|
33
51
|
card_width: parseInt(card_width, 10),
|
|
34
52
|
hide: parseArray(hide),
|
|
35
53
|
line_height,
|
|
36
|
-
title_color,
|
|
37
|
-
icon_color,
|
|
38
|
-
text_color,
|
|
39
|
-
bg_color,
|
|
40
|
-
theme,
|
|
41
54
|
hide_progress,
|
|
42
55
|
border_radius,
|
|
43
|
-
border_color,
|
|
44
56
|
locale: locale ? locale.toLowerCase() : null,
|
|
45
57
|
layout,
|
|
46
58
|
langs_count,
|
|
@@ -57,11 +69,7 @@ export default async ({ username, title_color, icon_color, hide_border, card_wid
|
|
|
57
69
|
message: err.message,
|
|
58
70
|
secondaryMessage: retrieveSecondaryMessage(err),
|
|
59
71
|
renderOptions: {
|
|
60
|
-
|
|
61
|
-
text_color,
|
|
62
|
-
bg_color,
|
|
63
|
-
border_color,
|
|
64
|
-
theme,
|
|
72
|
+
...colorParams,
|
|
65
73
|
show_repo_link: !(err instanceof MissingParamError),
|
|
66
74
|
},
|
|
67
75
|
}),
|
|
@@ -71,13 +79,7 @@ export default async ({ username, title_color, icon_color, hide_border, card_wid
|
|
|
71
79
|
status: "error - temporary",
|
|
72
80
|
content: renderError({
|
|
73
81
|
message: "An unknown error occurred",
|
|
74
|
-
renderOptions:
|
|
75
|
-
title_color,
|
|
76
|
-
text_color,
|
|
77
|
-
bg_color,
|
|
78
|
-
border_color,
|
|
79
|
-
theme,
|
|
80
|
-
},
|
|
82
|
+
renderOptions: colorParams,
|
|
81
83
|
}),
|
|
82
84
|
};
|
|
83
85
|
}
|
package/build/calculateRank.d.ts
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Calculates the users rank.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @param
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @param
|
|
13
|
-
* @returns
|
|
4
|
+
* @param params Parameters on which the user's rank depends.
|
|
5
|
+
* @param params.all_commits Whether `include_all_commits` was used.
|
|
6
|
+
* @param params.commits Number of commits.
|
|
7
|
+
* @param params.prs The number of pull requests.
|
|
8
|
+
* @param params.issues The number of issues.
|
|
9
|
+
* @param params.reviews The number of reviews.
|
|
10
|
+
* @param params.repos Total number of repos (accepted for compatibility, unused in the calculation).
|
|
11
|
+
* @param params.stars The number of stars.
|
|
12
|
+
* @param params.followers The number of followers.
|
|
13
|
+
* @returns The users rank.
|
|
14
14
|
*/
|
|
15
|
-
|
|
15
|
+
declare function calculateRank({ all_commits, commits, prs, issues, reviews, stars, followers, }: {
|
|
16
16
|
all_commits: boolean;
|
|
17
17
|
commits: number;
|
|
18
18
|
prs: number;
|
|
@@ -25,4 +25,5 @@ export function calculateRank({ all_commits, commits, prs, issues, reviews, repo
|
|
|
25
25
|
level: string;
|
|
26
26
|
percentile: number;
|
|
27
27
|
};
|
|
28
|
+
export { calculateRank };
|
|
28
29
|
//# sourceMappingURL=calculateRank.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateRank.d.ts","sourceRoot":"","sources":["../src/calculateRank.
|
|
1
|
+
{"version":3,"file":"calculateRank.d.ts","sourceRoot":"","sources":["../src/calculateRank.ts"],"names":[],"mappings":"AAqBA;;;;;;;;;;;;;GAaG;AACH,iBAAS,aAAa,CAAC,EACrB,WAAW,EACX,OAAO,EACP,GAAG,EACH,MAAM,EACN,OAAO,EACP,KAAK,EACL,SAAS,GACV,EAAE;IACD,WAAW,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;IAChB,GAAG,EAAE,MAAM,CAAC;IACZ,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;CACnB,GAAG;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAyCxC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/build/calculateRank.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Calculates the exponential cdf.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @returns
|
|
4
|
+
* @param x The value.
|
|
5
|
+
* @returns The exponential cdf.
|
|
6
6
|
*/
|
|
7
7
|
function exponential_cdf(x) {
|
|
8
8
|
return 1 - 2 ** -x;
|
|
@@ -10,8 +10,8 @@ function exponential_cdf(x) {
|
|
|
10
10
|
/**
|
|
11
11
|
* Calculates the log normal cdf.
|
|
12
12
|
*
|
|
13
|
-
* @param
|
|
14
|
-
* @returns
|
|
13
|
+
* @param x The value.
|
|
14
|
+
* @returns The log normal cdf.
|
|
15
15
|
*/
|
|
16
16
|
function log_normal_cdf(x) {
|
|
17
17
|
// approximation
|
|
@@ -20,21 +20,18 @@ function log_normal_cdf(x) {
|
|
|
20
20
|
/**
|
|
21
21
|
* Calculates the users rank.
|
|
22
22
|
*
|
|
23
|
-
* @param
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @param
|
|
27
|
-
* @param
|
|
28
|
-
* @param
|
|
29
|
-
* @param
|
|
30
|
-
* @param
|
|
31
|
-
* @param
|
|
32
|
-
* @returns
|
|
23
|
+
* @param params Parameters on which the user's rank depends.
|
|
24
|
+
* @param params.all_commits Whether `include_all_commits` was used.
|
|
25
|
+
* @param params.commits Number of commits.
|
|
26
|
+
* @param params.prs The number of pull requests.
|
|
27
|
+
* @param params.issues The number of issues.
|
|
28
|
+
* @param params.reviews The number of reviews.
|
|
29
|
+
* @param params.repos Total number of repos (accepted for compatibility, unused in the calculation).
|
|
30
|
+
* @param params.stars The number of stars.
|
|
31
|
+
* @param params.followers The number of followers.
|
|
32
|
+
* @returns The users rank.
|
|
33
33
|
*/
|
|
34
|
-
function calculateRank({ all_commits, commits, prs, issues, reviews,
|
|
35
|
-
// eslint-disable-next-line no-unused-vars
|
|
36
|
-
repos, // unused
|
|
37
|
-
stars, followers, }) {
|
|
34
|
+
function calculateRank({ all_commits, commits, prs, issues, reviews, stars, followers, }) {
|
|
38
35
|
const COMMITS_MEDIAN = all_commits ? 1000 : 250, COMMITS_WEIGHT = 2;
|
|
39
36
|
const PRS_MEDIAN = 50, PRS_WEIGHT = 3;
|
|
40
37
|
const ISSUES_MEDIAN = 25, ISSUES_WEIGHT = 1;
|
|
@@ -58,6 +55,9 @@ stars, followers, }) {
|
|
|
58
55
|
FOLLOWERS_WEIGHT * log_normal_cdf(followers / FOLLOWERS_MEDIAN)) /
|
|
59
56
|
TOTAL_WEIGHT;
|
|
60
57
|
const level = LEVELS[THRESHOLDS.findIndex((t) => rank * 100 <= t)];
|
|
58
|
+
if (level === undefined) {
|
|
59
|
+
throw new Error("Unable to determine rank level");
|
|
60
|
+
}
|
|
61
61
|
return { level, percentile: rank * 100 };
|
|
62
62
|
}
|
|
63
63
|
export { calculateRank };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { ThemeName } from "../themes/index.js";
|
|
2
|
+
export interface CommonOptions {
|
|
3
|
+
title_color: string;
|
|
4
|
+
icon_color: string;
|
|
5
|
+
text_color: string;
|
|
6
|
+
bg_color: string;
|
|
7
|
+
theme: ThemeName;
|
|
8
|
+
border_radius: number;
|
|
9
|
+
border_color: string;
|
|
10
|
+
locale: string;
|
|
11
|
+
hide_border: boolean;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=common-options.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common-options.d.ts","sourceRoot":"","sources":["../../src/cards/common-options.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,MAAM,WAAW,aAAa;IAC5B,WAAW,EAAE,MAAM,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,UAAU,EAAE,MAAM,CAAC;IACnB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,SAAS,CAAC;IACjB,aAAa,EAAE,MAAM,CAAC;IACtB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,OAAO,CAAC;CACtB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/build/cards/gist.d.ts
CHANGED
|
@@ -1,21 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
*/
|
|
8
|
-
export type GistData = any;
|
|
9
|
-
/**
|
|
10
|
-
* @typedef {import('./types').GistCardOptions} GistCardOptions Gist card options.
|
|
11
|
-
* @typedef {import('../fetchers/types').GistData} GistData Gist data.
|
|
12
|
-
*/
|
|
1
|
+
import type { GistData } from "../fetchers/types.js";
|
|
2
|
+
import type { CommonOptions } from "./common-options.js";
|
|
3
|
+
interface GistCardOptions extends CommonOptions {
|
|
4
|
+
show_owner: boolean;
|
|
5
|
+
browser_rendering: boolean;
|
|
6
|
+
}
|
|
13
7
|
/**
|
|
14
8
|
* Render gist card.
|
|
15
9
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @returns
|
|
10
|
+
* @param gistData Gist data.
|
|
11
|
+
* @param options Gist card options.
|
|
12
|
+
* @returns Gist card.
|
|
19
13
|
*/
|
|
20
|
-
|
|
14
|
+
declare const renderGistCard: (gistData: GistData, options?: Partial<GistCardOptions>) => string;
|
|
15
|
+
export { renderGistCard };
|
|
21
16
|
//# sourceMappingURL=gist.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gist.d.ts","sourceRoot":"","sources":["../../src/cards/gist.
|
|
1
|
+
{"version":3,"file":"gist.d.ts","sourceRoot":"","sources":["../../src/cards/gist.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAWzD,UAAU,eAAgB,SAAQ,aAAa;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;;;GAMG;AACH,QAAA,MAAM,cAAc,GAClB,UAAU,QAAQ,EAClB,UAAS,OAAO,CAAC,eAAe,CAAM,KACrC,MA0IF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/build/cards/gist.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { default as Card } from "../common/Card.js";
|
|
2
|
-
import {
|
|
2
|
+
import { getLightDarkColors } from "../common/color.js";
|
|
3
3
|
import { kFormatter, wrapTextMultiline } from "../common/fmt.js";
|
|
4
4
|
import { encodeHTML } from "../common/html.js";
|
|
5
5
|
import { icons } from "../common/icons.js";
|
|
6
|
-
import
|
|
6
|
+
import { getLanguageColor } from "../common/languageColors.js";
|
|
7
7
|
import { parseEmojis } from "../common/ops.js";
|
|
8
8
|
import { countWrappedLines, createLanguageNode, flexLayout, iconWithLabel, measureText, wrappedTextNode, wrappedTextStyles, } from "../common/render.js";
|
|
9
9
|
const ICON_SIZE = 16;
|
|
@@ -14,31 +14,21 @@ const DESCRIPTION_BOX_WIDTH = CARD_DEFAULT_WIDTH - 2 * X_OFFSET;
|
|
|
14
14
|
const DESCRIPTION_FONT_SIZE = 13;
|
|
15
15
|
const DESCRIPTION_LINE_HEIGHT_PX = 16;
|
|
16
16
|
const DESCRIPTION_MAX_LINES = 10;
|
|
17
|
-
/**
|
|
18
|
-
* @typedef {import('./types').GistCardOptions} GistCardOptions Gist card options.
|
|
19
|
-
* @typedef {import('../fetchers/types').GistData} GistData Gist data.
|
|
20
|
-
*/
|
|
21
17
|
/**
|
|
22
18
|
* Render gist card.
|
|
23
19
|
*
|
|
24
|
-
* @param
|
|
25
|
-
* @param
|
|
26
|
-
* @returns
|
|
20
|
+
* @param gistData Gist data.
|
|
21
|
+
* @param options Gist card options.
|
|
22
|
+
* @returns Gist card.
|
|
27
23
|
*/
|
|
28
24
|
const renderGistCard = (gistData, options = {}) => {
|
|
29
25
|
const { name, nameWithOwner, description, language, starsCount, forksCount } = gistData;
|
|
30
|
-
const {
|
|
31
|
-
|
|
32
|
-
const {
|
|
33
|
-
title_color,
|
|
34
|
-
icon_color,
|
|
35
|
-
text_color,
|
|
36
|
-
bg_color,
|
|
37
|
-
border_color,
|
|
38
|
-
theme,
|
|
39
|
-
});
|
|
26
|
+
const { theme = "default_repocard", border_radius, show_owner = false, browser_rendering = false, hide_border = false, } = options;
|
|
27
|
+
const { lightColors, darkColors } = getLightDarkColors({ ...options, theme });
|
|
28
|
+
const { textColor, iconColor } = lightColors;
|
|
40
29
|
const desc = parseEmojis(description || "No description provided");
|
|
41
|
-
let descriptionLines
|
|
30
|
+
let descriptionLines;
|
|
31
|
+
let descriptionSvg;
|
|
42
32
|
if (browser_rendering) {
|
|
43
33
|
// The browser performs the actual text wrapping inside the foreignObject;
|
|
44
34
|
// we only estimate the line count server-side so the SVG can reserve enough
|
|
@@ -74,8 +64,7 @@ const renderGistCard = (gistData, options = {}) => {
|
|
|
74
64
|
const svgStars = iconWithLabel(icons.star, totalStars, "starsCount", ICON_SIZE);
|
|
75
65
|
const svgForks = iconWithLabel(icons.fork, totalForks, "forksCount", ICON_SIZE);
|
|
76
66
|
const languageName = language || "Unspecified";
|
|
77
|
-
|
|
78
|
-
const languageColor = languageColors[languageName] || "#858585";
|
|
67
|
+
const languageColor = getLanguageColor(languageName);
|
|
79
68
|
const svgLanguage = createLanguageNode(languageName, languageColor);
|
|
80
69
|
const starAndForkCount = flexLayout({
|
|
81
70
|
items: [svgLanguage, svgStars, svgForks],
|
|
@@ -95,22 +84,28 @@ const renderGistCard = (gistData, options = {}) => {
|
|
|
95
84
|
width: CARD_DEFAULT_WIDTH,
|
|
96
85
|
height,
|
|
97
86
|
border_radius,
|
|
98
|
-
colors: {
|
|
99
|
-
titleColor,
|
|
100
|
-
textColor,
|
|
101
|
-
iconColor,
|
|
102
|
-
bgColor,
|
|
103
|
-
borderColor,
|
|
104
|
-
},
|
|
87
|
+
colors: { light: lightColors, dark: darkColors },
|
|
105
88
|
});
|
|
106
|
-
card.setCSS(
|
|
89
|
+
card.setCSS({
|
|
90
|
+
light: `
|
|
107
91
|
.description {
|
|
108
92
|
font: 400 ${DESCRIPTION_FONT_SIZE}px 'Segoe UI', Ubuntu, Sans-Serif;fill: ${textColor};
|
|
109
93
|
${browser_rendering ? wrappedTextStyles(textColor) : ""}
|
|
110
94
|
}
|
|
111
95
|
.gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
|
|
112
96
|
.icon { fill: ${iconColor} }
|
|
113
|
-
|
|
97
|
+
`,
|
|
98
|
+
dark: darkColors
|
|
99
|
+
? `
|
|
100
|
+
.description {
|
|
101
|
+
fill: ${darkColors.textColor};
|
|
102
|
+
${browser_rendering ? wrappedTextStyles(darkColors.textColor) : ""}
|
|
103
|
+
}
|
|
104
|
+
.gray { fill: ${darkColors.textColor} }
|
|
105
|
+
.icon { fill: ${darkColors.iconColor} }
|
|
106
|
+
`
|
|
107
|
+
: null,
|
|
108
|
+
});
|
|
114
109
|
card.setHideBorder(hide_border);
|
|
115
110
|
return card.render(`
|
|
116
111
|
${descriptionSvg}
|
package/build/cards/repo.d.ts
CHANGED
|
@@ -1,21 +1,24 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
1
|
+
import type { RepositoryData } from "../fetchers/types.js";
|
|
2
|
+
import type { CommonOptions } from "./common-options.js";
|
|
3
|
+
interface RepoCardOptions extends CommonOptions {
|
|
4
|
+
show_owner: boolean;
|
|
5
|
+
browser_rendering: boolean;
|
|
6
|
+
description_lines_count: number;
|
|
7
|
+
card_width_input: number;
|
|
8
|
+
show: Array<string>;
|
|
9
|
+
show_icons: boolean;
|
|
10
|
+
number_format: string;
|
|
11
|
+
text_bold: boolean;
|
|
12
|
+
line_height: number | string;
|
|
13
|
+
username: string;
|
|
14
|
+
}
|
|
13
15
|
/**
|
|
14
16
|
* Renders repository card details.
|
|
15
17
|
*
|
|
16
|
-
* @param
|
|
17
|
-
* @param
|
|
18
|
-
* @returns
|
|
18
|
+
* @param repo Repository data.
|
|
19
|
+
* @param options Card options.
|
|
20
|
+
* @returns Repository card SVG object.
|
|
19
21
|
*/
|
|
20
|
-
|
|
22
|
+
declare const renderRepoCard: (repo: RepositoryData, options?: Partial<RepoCardOptions>) => string;
|
|
23
|
+
export { renderRepoCard };
|
|
21
24
|
//# sourceMappingURL=repo.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/cards/repo.
|
|
1
|
+
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/cards/repo.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAG3D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASzD,UAAU,eAAgB,SAAQ,aAAa;IAC7C,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,uBAAuB,EAAE,MAAM,CAAC;IAChC,gBAAgB,EAAE,MAAM,CAAC;IACzB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AAsCD;;;;;;GAMG;AACH,QAAA,MAAM,cAAc,GAClB,MAAM,cAAc,EACpB,UAAS,OAAO,CAAC,eAAe,CAAM,KACrC,MA4SF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
|