@stats-organization/github-readme-stats-core 2.1.5 → 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 +9 -41
- package/build/api/index.d.ts +3 -8
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +23 -45
- package/build/api/pin.d.ts +2 -7
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +9 -41
- 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 +11 -55
- package/build/api/wakatime.d.ts +2 -7
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +9 -41
- 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 +58 -60
- package/build/cards/stats.d.ts +29 -46
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +113 -181
- 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 +174 -200
- package/build/cards/wakatime.d.ts +21 -11
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +73 -111
- package/build/common/Card.d.ts +34 -13
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +73 -40
- package/build/common/I18n.d.ts +4 -2
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/color.d.ts +60 -18
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +102 -5
- 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/http.d.ts +25 -2
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +26 -3
- 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 +1 -0
- package/build/common/ops.d.ts +3 -10
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +3 -15
- package/build/common/render.d.ts +43 -6
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +77 -11
- package/build/common/retryer.d.ts +3 -2
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +1 -0
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +8 -39
- package/build/fetchers/repo.d.ts +12 -11
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +26 -67
- package/build/fetchers/stats.d.ts +24 -17
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +302 -183
- 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 +24 -20
- package/build/fetchers/types.d.ts.map +1 -1
- 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 +13 -7
- package/src/_github-username-regex.d.ts +4 -0
- package/src/api/gist.js +10 -46
- package/src/api/index.js +30 -51
- package/src/api/pin.js +10 -46
- package/src/api/top-langs.js +13 -60
- package/src/api/wakatime.js +10 -46
- package/src/cards/common-options.ts +13 -0
- package/src/cards/{gist.js → gist.ts} +37 -37
- package/src/cards/{repo.js → repo.ts} +86 -68
- package/src/cards/{stats.js → stats.ts} +168 -219
- package/src/cards/{top-languages.js → top-languages.ts} +309 -265
- package/src/cards/{wakatime.js → wakatime.ts} +136 -130
- package/src/common/Card.ts +94 -49
- package/src/common/I18n.ts +6 -2
- package/src/common/color.ts +163 -14
- package/src/common/config.ts +22 -29
- package/src/common/constants.ts +3 -1
- package/src/common/date.ts +45 -0
- package/src/common/http.ts +43 -3
- package/src/common/icons.ts +1 -0
- package/src/common/languageColors.json +1 -0
- package/src/common/languageColors.ts +19 -0
- package/src/common/ops.ts +8 -18
- package/src/common/render.ts +114 -14
- package/src/common/retryer.ts +6 -5
- package/src/fetchers/gist.ts +15 -72
- 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.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/fetchers/repo.js +0 -161
- package/src/fetchers/stats.js +0 -473
- package/src/fetchers/top-languages.js +0 -175
- package/src/themes/README.md +0 -229
package/build/api/wakatime.js
CHANGED
|
@@ -1,19 +1,14 @@
|
|
|
1
1
|
import { renderWakatimeCard } from "../cards/wakatime.js";
|
|
2
|
-
import {
|
|
2
|
+
import { findInvalidColorParam, pickColorParams } from "../common/color.js";
|
|
3
3
|
import { MissingParamError, retrieveSecondaryMessage, } from "../common/error.js";
|
|
4
4
|
import { parseArray, parseBoolean } from "../common/ops.js";
|
|
5
5
|
import { renderError } from "../common/render.js";
|
|
6
6
|
import { fetchWakatimeStats } from "../fetchers/wakatime.js";
|
|
7
7
|
import { isLocaleAvailable } from "../translations.js";
|
|
8
8
|
// @ts-ignore
|
|
9
|
-
export default async ({ username,
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
icon_color,
|
|
13
|
-
text_color,
|
|
14
|
-
bg_color,
|
|
15
|
-
border_color,
|
|
16
|
-
});
|
|
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);
|
|
17
12
|
if (invalidColorInput) {
|
|
18
13
|
return {
|
|
19
14
|
status: "error - permanent",
|
|
@@ -29,13 +24,7 @@ export default async ({ username, title_color, icon_color, hide_border, card_wid
|
|
|
29
24
|
content: renderError({
|
|
30
25
|
message: "Something went wrong",
|
|
31
26
|
secondaryMessage: "Language not found",
|
|
32
|
-
renderOptions:
|
|
33
|
-
title_color,
|
|
34
|
-
text_color,
|
|
35
|
-
bg_color,
|
|
36
|
-
border_color,
|
|
37
|
-
theme,
|
|
38
|
-
},
|
|
27
|
+
renderOptions: colorParams,
|
|
39
28
|
}),
|
|
40
29
|
};
|
|
41
30
|
}
|
|
@@ -46,13 +35,7 @@ export default async ({ username, title_color, icon_color, hide_border, card_wid
|
|
|
46
35
|
content: renderError({
|
|
47
36
|
message: "Something went wrong",
|
|
48
37
|
secondaryMessage: "Username contains unsafe characters",
|
|
49
|
-
renderOptions:
|
|
50
|
-
title_color,
|
|
51
|
-
text_color,
|
|
52
|
-
bg_color,
|
|
53
|
-
border_color,
|
|
54
|
-
theme,
|
|
55
|
-
},
|
|
38
|
+
renderOptions: colorParams,
|
|
56
39
|
}),
|
|
57
40
|
};
|
|
58
41
|
}
|
|
@@ -61,20 +44,15 @@ export default async ({ username, title_color, icon_color, hide_border, card_wid
|
|
|
61
44
|
return {
|
|
62
45
|
status: "success",
|
|
63
46
|
content: renderWakatimeCard(stats, {
|
|
47
|
+
...colorParams,
|
|
64
48
|
custom_title,
|
|
65
49
|
hide_title: parseBoolean(hide_title),
|
|
66
50
|
hide_border: parseBoolean(hide_border),
|
|
67
51
|
card_width: parseInt(card_width, 10),
|
|
68
52
|
hide: parseArray(hide),
|
|
69
53
|
line_height,
|
|
70
|
-
title_color,
|
|
71
|
-
icon_color,
|
|
72
|
-
text_color,
|
|
73
|
-
bg_color,
|
|
74
|
-
theme,
|
|
75
54
|
hide_progress,
|
|
76
55
|
border_radius,
|
|
77
|
-
border_color,
|
|
78
56
|
locale: locale ? locale.toLowerCase() : null,
|
|
79
57
|
layout,
|
|
80
58
|
langs_count,
|
|
@@ -91,11 +69,7 @@ export default async ({ username, title_color, icon_color, hide_border, card_wid
|
|
|
91
69
|
message: err.message,
|
|
92
70
|
secondaryMessage: retrieveSecondaryMessage(err),
|
|
93
71
|
renderOptions: {
|
|
94
|
-
|
|
95
|
-
text_color,
|
|
96
|
-
bg_color,
|
|
97
|
-
border_color,
|
|
98
|
-
theme,
|
|
72
|
+
...colorParams,
|
|
99
73
|
show_repo_link: !(err instanceof MissingParamError),
|
|
100
74
|
},
|
|
101
75
|
}),
|
|
@@ -105,13 +79,7 @@ export default async ({ username, title_color, icon_color, hide_border, card_wid
|
|
|
105
79
|
status: "error - temporary",
|
|
106
80
|
content: renderError({
|
|
107
81
|
message: "An unknown error occurred",
|
|
108
|
-
renderOptions:
|
|
109
|
-
title_color,
|
|
110
|
-
text_color,
|
|
111
|
-
bg_color,
|
|
112
|
-
border_color,
|
|
113
|
-
theme,
|
|
114
|
-
},
|
|
82
|
+
renderOptions: colorParams,
|
|
115
83
|
}),
|
|
116
84
|
};
|
|
117
85
|
}
|
|
@@ -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"}
|
package/build/cards/repo.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
1
|
import { Card } from "../common/Card.js";
|
|
2
2
|
import { I18n } from "../common/I18n.js";
|
|
3
|
-
import {
|
|
3
|
+
import { getLightDarkColors } from "../common/color.js";
|
|
4
4
|
import { kFormatter, wrapTextMultiline } from "../common/fmt.js";
|
|
5
5
|
import { encodeHTML } from "../common/html.js";
|
|
6
6
|
import { icons } from "../common/icons.js";
|
|
7
7
|
import { buildSearchFilter, clampValue, parseEmojis } from "../common/ops.js";
|
|
8
|
-
import { countWrappedLines, createLanguageNode, flexLayout, iconWithLabel, measureText, wrappedTextNode, wrappedTextStyles, } from "../common/render.js";
|
|
8
|
+
import { countWrappedLines, createLanguageNode, createTextNode, flexLayout, iconWithLabel, measureText, wrappedTextNode, wrappedTextStyles, } from "../common/render.js";
|
|
9
9
|
import { repoCardLocales } from "../translations.js";
|
|
10
|
-
import { createTextNode } from "./stats.js";
|
|
11
10
|
const ICON_SIZE = 16;
|
|
12
11
|
const CARD_DEFAULT_WIDTH = 400;
|
|
13
12
|
const X_OFFSET = 25;
|
|
@@ -17,46 +16,38 @@ const DESCRIPTION_MAX_LINES = 3;
|
|
|
17
16
|
/**
|
|
18
17
|
* Retrieves the repository description and wraps it to fit the card width.
|
|
19
18
|
*
|
|
20
|
-
* @param
|
|
21
|
-
* @param
|
|
22
|
-
* @returns
|
|
19
|
+
* @param label The repository description.
|
|
20
|
+
* @param xOffset Horizontal offset of the badge.
|
|
21
|
+
* @returns Wrapped repo description SVG object.
|
|
23
22
|
*/
|
|
24
|
-
const getBadgeSVG = (label,
|
|
25
|
-
if (!isPrefixedHexColor(textColor)) {
|
|
26
|
-
throw new Error(`Invalid text color: "${textColor}"`);
|
|
27
|
-
}
|
|
23
|
+
const getBadgeSVG = (label, xOffset = 0) => {
|
|
28
24
|
if (!Number.isFinite(xOffset)) {
|
|
29
25
|
throw new Error(`Invalid xOffset: "${xOffset}"`);
|
|
30
26
|
}
|
|
31
27
|
return `
|
|
32
28
|
<g data-testid="badge" class="badge" transform="translate(${320 + xOffset}, -18)">
|
|
33
|
-
<rect stroke
|
|
29
|
+
<rect stroke-width="1" width="70" height="20" x="-12" y="-14" ry="10" rx="10"></rect>
|
|
34
30
|
<text
|
|
35
31
|
x="23" y="-5"
|
|
36
32
|
alignment-baseline="central"
|
|
37
33
|
dominant-baseline="central"
|
|
38
34
|
text-anchor="middle"
|
|
39
|
-
fill="${textColor}"
|
|
40
35
|
>
|
|
41
36
|
${encodeHTML(label)}
|
|
42
37
|
</text>
|
|
43
38
|
</g>
|
|
44
39
|
`;
|
|
45
40
|
};
|
|
46
|
-
/**
|
|
47
|
-
* @typedef {import("../fetchers/types").RepositoryData} RepositoryData Repository data.
|
|
48
|
-
* @typedef {import("./types").RepoCardOptions} RepoCardOptions Repo card options.
|
|
49
|
-
*/
|
|
50
41
|
/**
|
|
51
42
|
* Renders repository card details.
|
|
52
43
|
*
|
|
53
|
-
* @param
|
|
54
|
-
* @param
|
|
55
|
-
* @returns
|
|
44
|
+
* @param repo Repository data.
|
|
45
|
+
* @param options Card options.
|
|
46
|
+
* @returns Repository card SVG object.
|
|
56
47
|
*/
|
|
57
48
|
const renderRepoCard = (repo, options = {}) => {
|
|
58
|
-
const { name, nameWithOwner, description, primaryLanguage, isArchived, isTemplate,
|
|
59
|
-
const { hide_border = false,
|
|
49
|
+
const { name, nameWithOwner, description, primaryLanguage, isArchived, isTemplate, stargazerCount, forkCount, totalPRsAuthored, totalPRsCommented, totalPRsReviewed, totalIssuesAuthored, totalIssuesCommented, } = repo;
|
|
50
|
+
const { hide_border = false, card_width_input, show_owner = false, browser_rendering = false, show = [], show_icons = true, number_format = "short", text_bold = false, line_height = 22, username, theme = "default_repocard", border_radius, locale, description_lines_count, } = options;
|
|
60
51
|
const card_width = card_width_input && !isNaN(card_width_input)
|
|
61
52
|
? card_width_input
|
|
62
53
|
: show.length >= 2
|
|
@@ -66,11 +57,11 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
66
57
|
locale,
|
|
67
58
|
translations: repoCardLocales,
|
|
68
59
|
});
|
|
69
|
-
|
|
70
|
-
const encodedUsername = encodeURIComponent(username);
|
|
60
|
+
const repoFilter = encodeURIComponent(buildSearchFilter([nameWithOwner], []));
|
|
61
|
+
const encodedUsername = encodeURIComponent(username ?? "");
|
|
71
62
|
const STATS = {};
|
|
72
63
|
if (show.includes("prs_authored")) {
|
|
73
|
-
STATS
|
|
64
|
+
STATS["prs_authored"] = {
|
|
74
65
|
icon: icons.prs,
|
|
75
66
|
label: i18n.t("repocard.prs-authored"),
|
|
76
67
|
value: totalPRsAuthored,
|
|
@@ -79,7 +70,7 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
79
70
|
};
|
|
80
71
|
}
|
|
81
72
|
if (show.includes("prs_commented")) {
|
|
82
|
-
STATS
|
|
73
|
+
STATS["prs_commented"] = {
|
|
83
74
|
icon: icons.comments,
|
|
84
75
|
label: i18n.t("repocard.prs-commented"),
|
|
85
76
|
value: totalPRsCommented,
|
|
@@ -88,7 +79,7 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
88
79
|
};
|
|
89
80
|
}
|
|
90
81
|
if (show.includes("prs_reviewed")) {
|
|
91
|
-
STATS
|
|
82
|
+
STATS["prs_reviewed"] = {
|
|
92
83
|
icon: icons.reviews,
|
|
93
84
|
label: i18n.t("repocard.prs-reviewed"),
|
|
94
85
|
value: totalPRsReviewed,
|
|
@@ -97,7 +88,7 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
97
88
|
};
|
|
98
89
|
}
|
|
99
90
|
if (show.includes("issues_authored")) {
|
|
100
|
-
STATS
|
|
91
|
+
STATS["issues_authored"] = {
|
|
101
92
|
icon: icons.issues,
|
|
102
93
|
label: i18n.t("repocard.issues-authored"),
|
|
103
94
|
value: totalIssuesAuthored,
|
|
@@ -106,7 +97,7 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
106
97
|
};
|
|
107
98
|
}
|
|
108
99
|
if (show.includes("issues_commented")) {
|
|
109
|
-
STATS
|
|
100
|
+
STATS["issues_commented"] = {
|
|
110
101
|
icon: icons.discussions_started,
|
|
111
102
|
label: i18n.t("repocard.issues-commented"),
|
|
112
103
|
value: totalIssuesCommented,
|
|
@@ -114,20 +105,20 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
114
105
|
link: `https://github.com/search?q=${repoFilter}commenter%3A${encodedUsername}+-author%3A${encodedUsername}&type=issues`,
|
|
115
106
|
};
|
|
116
107
|
}
|
|
117
|
-
const statItems = Object.
|
|
108
|
+
const statItems = Object.values(STATS).map((stat, index) =>
|
|
118
109
|
// create the text nodes, and pass index so that we can calculate the line spacing
|
|
119
110
|
createTextNode({
|
|
120
|
-
icon:
|
|
121
|
-
label:
|
|
122
|
-
value:
|
|
123
|
-
id:
|
|
124
|
-
unitSymbol:
|
|
111
|
+
icon: stat.icon,
|
|
112
|
+
label: stat.label,
|
|
113
|
+
value: stat.value ?? 0,
|
|
114
|
+
id: stat.id,
|
|
115
|
+
unitSymbol: stat.unitSymbol,
|
|
125
116
|
index,
|
|
126
117
|
showIcons: show_icons,
|
|
127
118
|
shiftValuePos: 14.01,
|
|
128
119
|
bold: text_bold,
|
|
129
120
|
numberFormat: number_format,
|
|
130
|
-
link:
|
|
121
|
+
link: stat.link,
|
|
131
122
|
labelXOffset: 23,
|
|
132
123
|
}));
|
|
133
124
|
const extraLHeight = parseInt(String(line_height), 10);
|
|
@@ -137,7 +128,8 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
137
128
|
const langColor = (primaryLanguage && primaryLanguage.color) || "#333";
|
|
138
129
|
const desc = parseEmojis(description || "No description provided");
|
|
139
130
|
const descriptionBoxWidth = card_width - 2 * X_OFFSET;
|
|
140
|
-
let descriptionLinesCount
|
|
131
|
+
let descriptionLinesCount;
|
|
132
|
+
let descriptionSvg;
|
|
141
133
|
if (browser_rendering) {
|
|
142
134
|
// The browser performs the actual text wrapping inside the foreignObject;
|
|
143
135
|
// we only estimate the line count server-side so the SVG can reserve enough
|
|
@@ -178,19 +170,11 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
178
170
|
const height = (descriptionLinesCount > 1 ? 120 : 110) +
|
|
179
171
|
descriptionLinesCount * lineHeight +
|
|
180
172
|
extraHeight;
|
|
181
|
-
|
|
182
|
-
const colors = getCardColors({
|
|
183
|
-
title_color,
|
|
184
|
-
icon_color,
|
|
185
|
-
text_color,
|
|
186
|
-
bg_color,
|
|
187
|
-
border_color,
|
|
188
|
-
theme,
|
|
189
|
-
});
|
|
173
|
+
const { lightColors, darkColors } = getLightDarkColors({ ...options, theme });
|
|
190
174
|
const svgLanguage = primaryLanguage
|
|
191
175
|
? createLanguageNode(langName, langColor)
|
|
192
176
|
: "";
|
|
193
|
-
const totalStars = kFormatter(
|
|
177
|
+
const totalStars = kFormatter(stargazerCount);
|
|
194
178
|
const totalForks = kFormatter(forkCount);
|
|
195
179
|
const svgStars = iconWithLabel(icons.star, totalStars, "stargazers", ICON_SIZE);
|
|
196
180
|
const svgForks = iconWithLabel(icons.fork, totalForks, "forkcount", ICON_SIZE);
|
|
@@ -203,7 +187,7 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
203
187
|
],
|
|
204
188
|
gap: 25,
|
|
205
189
|
}).join("");
|
|
206
|
-
|
|
190
|
+
const extraRows = [];
|
|
207
191
|
for (let i = 0; i < statItems.length; i += 2) {
|
|
208
192
|
extraRows.push(flexLayout({
|
|
209
193
|
items: statItems.slice(i, i + 2),
|
|
@@ -226,21 +210,23 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
226
210
|
width: card_width,
|
|
227
211
|
height,
|
|
228
212
|
border_radius,
|
|
229
|
-
colors,
|
|
213
|
+
colors: { light: lightColors, dark: darkColors },
|
|
230
214
|
});
|
|
231
215
|
card.disableAnimations();
|
|
232
216
|
card.setHideBorder(hide_border);
|
|
233
217
|
card.setHideTitle(false);
|
|
234
|
-
card.setCSS(
|
|
218
|
+
card.setCSS({
|
|
219
|
+
light: `
|
|
235
220
|
.description {
|
|
236
|
-
font: 400 ${DESCRIPTION_FONT_SIZE}px 'Segoe UI', Ubuntu, Sans-Serif;fill: ${
|
|
237
|
-
${browser_rendering ? wrappedTextStyles(
|
|
221
|
+
font: 400 ${DESCRIPTION_FONT_SIZE}px 'Segoe UI', Ubuntu, Sans-Serif;fill: ${lightColors.textColor};
|
|
222
|
+
${browser_rendering ? wrappedTextStyles(lightColors.textColor) : ""}
|
|
238
223
|
}
|
|
239
|
-
.gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${
|
|
224
|
+
.gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${lightColors.textColor} }
|
|
240
225
|
.badge { font: 600 11px 'Segoe UI', Ubuntu, Sans-Serif; }
|
|
241
|
-
.badge rect { opacity: 0.2 }
|
|
226
|
+
.badge rect { opacity: 0.2; stroke: ${lightColors.textColor} }
|
|
227
|
+
.badge text { fill: ${lightColors.textColor} }
|
|
242
228
|
|
|
243
|
-
.stat { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${
|
|
229
|
+
.stat { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${lightColors.textColor} }
|
|
244
230
|
.stagger {
|
|
245
231
|
opacity: 0;
|
|
246
232
|
animation: fadeInAnimation 0.3s ease-in-out forwards;
|
|
@@ -248,17 +234,29 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
248
234
|
.not_bold { font-weight: 400 }
|
|
249
235
|
.bold { font-weight: 700 }
|
|
250
236
|
.icon {
|
|
251
|
-
fill: ${
|
|
237
|
+
fill: ${lightColors.iconColor};
|
|
252
238
|
display: block;
|
|
253
239
|
}
|
|
254
|
-
|
|
240
|
+
`,
|
|
241
|
+
dark: darkColors
|
|
242
|
+
? `
|
|
243
|
+
.description {
|
|
244
|
+
fill: ${darkColors.textColor};
|
|
245
|
+
${browser_rendering ? wrappedTextStyles(darkColors.textColor) : ""}
|
|
246
|
+
}
|
|
247
|
+
.gray { fill: ${darkColors.textColor} }
|
|
248
|
+
.badge rect { stroke: ${darkColors.textColor} }
|
|
249
|
+
.badge text { fill: ${darkColors.textColor} }
|
|
250
|
+
.stat { fill: ${darkColors.textColor} }
|
|
251
|
+
.icon { fill: ${darkColors.iconColor}; }
|
|
252
|
+
`
|
|
253
|
+
: null,
|
|
254
|
+
});
|
|
255
255
|
return card.render(`
|
|
256
256
|
${isTemplate
|
|
257
|
-
?
|
|
258
|
-
getBadgeSVG(i18n.t("repocard.template"), colors.textColor, card_width - CARD_DEFAULT_WIDTH)
|
|
257
|
+
? getBadgeSVG(i18n.t("repocard.template"), card_width - CARD_DEFAULT_WIDTH)
|
|
259
258
|
: isArchived
|
|
260
|
-
?
|
|
261
|
-
getBadgeSVG(i18n.t("repocard.archived"), colors.textColor, card_width - CARD_DEFAULT_WIDTH)
|
|
259
|
+
? getBadgeSVG(i18n.t("repocard.archived"), card_width - CARD_DEFAULT_WIDTH)
|
|
262
260
|
: ""}
|
|
263
261
|
|
|
264
262
|
${descriptionSvg}
|
package/build/cards/stats.d.ts
CHANGED
|
@@ -1,51 +1,34 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
1
|
+
import type { StatsData } from "../fetchers/types.js";
|
|
2
|
+
import type { CommonOptions } from "./common-options.js";
|
|
3
|
+
type RankIcon = "default" | "github" | "percentile";
|
|
4
|
+
interface StatCardOptions extends CommonOptions {
|
|
5
|
+
hide: Array<string>;
|
|
6
|
+
show_icons: boolean;
|
|
7
|
+
hide_title: boolean;
|
|
8
|
+
card_width: number;
|
|
9
|
+
hide_rank: boolean;
|
|
10
|
+
include_all_commits: boolean;
|
|
11
|
+
commits_year: number;
|
|
12
|
+
line_height: number | string;
|
|
13
|
+
custom_title: string;
|
|
14
|
+
disable_animations: boolean;
|
|
15
|
+
number_format: string;
|
|
16
|
+
number_precision: number;
|
|
17
|
+
ring_color: string;
|
|
18
|
+
text_bold: boolean;
|
|
19
|
+
rank_icon: RankIcon;
|
|
20
|
+
show: Array<string>;
|
|
21
|
+
}
|
|
7
22
|
/**
|
|
8
23
|
* Renders the stats card.
|
|
9
24
|
*
|
|
10
|
-
* @param
|
|
11
|
-
* @param
|
|
12
|
-
* @
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
* Create a stats card text item.
|
|
17
|
-
*
|
|
18
|
-
* The caller must ensure that the passed `icon` and `link` are properly sanitized!
|
|
19
|
-
*
|
|
20
|
-
* @param {object} params Object that contains the createTextNode parameters.
|
|
21
|
-
* @param {string} params.icon The sanitized icon to display.
|
|
22
|
-
* @param {string} params.label The label to display.
|
|
23
|
-
* @param {number} params.value The value to display.
|
|
24
|
-
* @param {string} params.id The id of the stat.
|
|
25
|
-
* @param {string=} params.unitSymbol The unit symbol of the stat.
|
|
26
|
-
* @param {number} params.index The index of the stat.
|
|
27
|
-
* @param {boolean} params.showIcons Whether to show icons.
|
|
28
|
-
* @param {number} params.shiftValuePos Number of pixels the value has to be shifted to the right.
|
|
29
|
-
* @param {boolean} params.bold Whether to bold the label.
|
|
30
|
-
* @param {string} params.numberFormat The format of numbers on card.
|
|
31
|
-
* @param {number=} params.numberPrecision The precision of numbers on card.
|
|
32
|
-
* @param {string} params.link Sanitized url to link to.
|
|
33
|
-
* @param {number} params.labelXOffset horizontal offset for label.
|
|
34
|
-
* @returns {string} The stats card text item SVG object.
|
|
25
|
+
* @param stats The stats data.
|
|
26
|
+
* @param options The card options.
|
|
27
|
+
* @param username GitHub username, used to build stat search links.
|
|
28
|
+
* @param repo Repositories to scope the search links to.
|
|
29
|
+
* @param owner Owners to scope the search links to.
|
|
30
|
+
* @returns The stats card SVG object.
|
|
35
31
|
*/
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
label: string;
|
|
39
|
-
value: number;
|
|
40
|
-
id: string;
|
|
41
|
-
unitSymbol?: string | undefined;
|
|
42
|
-
index: number;
|
|
43
|
-
showIcons: boolean;
|
|
44
|
-
shiftValuePos: number;
|
|
45
|
-
bold: boolean;
|
|
46
|
-
numberFormat: string;
|
|
47
|
-
numberPrecision?: number | undefined;
|
|
48
|
-
link: string;
|
|
49
|
-
labelXOffset: number;
|
|
50
|
-
}): string;
|
|
32
|
+
declare const renderStatsCard: (stats: StatsData, options?: Partial<StatCardOptions>, username?: string, repo?: Array<string>, owner?: Array<string>) => string;
|
|
33
|
+
export { renderStatsCard };
|
|
51
34
|
//# sourceMappingURL=stats.d.ts.map
|