@stats-forge/github-stats-forge-core 0.0.1 → 0.1.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/README.md +0 -10
- package/build/api/api-result.d.ts +6 -7
- package/build/api/api-result.d.ts.map +1 -1
- package/build/api/api-result.js +4 -5
- package/build/api/gist.d.ts +3 -10
- package/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +4 -11
- package/build/api/index.d.ts +12 -12
- package/build/api/params.d.ts +11 -8
- package/build/api/params.d.ts.map +1 -1
- package/build/api/params.js +16 -14
- package/build/api/pin.d.ts +3 -19
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +6 -22
- package/build/api/stats.d.ts +10 -4
- package/build/api/stats.d.ts.map +1 -1
- package/build/api/stats.js +6 -32
- package/build/api/top-langs.d.ts +12 -6
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +6 -26
- package/build/api/wakatime.d.ts +13 -5
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +4 -21
- package/build/calculateRank.d.ts +0 -9
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +12 -17
- package/build/cards/gist.d.ts +2 -4
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +27 -36
- package/build/cards/options.d.ts +1 -1
- package/build/cards/repo.d.ts +2 -4
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +61 -93
- package/build/cards/stats.d.ts +3 -8
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +119 -165
- package/build/cards/top-languages.d.ts +5 -31
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +176 -384
- package/build/cards/wakatime.d.ts +4 -6
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +118 -185
- package/build/common/Card.d.ts +14 -62
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +97 -199
- package/build/common/I18n.d.ts +0 -6
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/I18n.js +3 -6
- package/build/common/color.d.ts +4 -17
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +67 -49
- package/build/common/config.d.ts +4 -14
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +3 -16
- package/build/common/constants.d.ts +4 -2
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +3 -1
- package/build/common/date.d.ts +0 -2
- package/build/common/date.d.ts.map +1 -1
- package/build/common/date.js +0 -2
- package/build/common/emojiMap.d.ts +8 -0
- package/build/common/emojiMap.d.ts.map +1 -0
- package/build/common/emojiMap.js +10 -0
- package/build/common/emojiMap.json +1915 -0
- package/build/common/error.d.ts +1 -10
- package/build/common/error.d.ts.map +1 -1
- package/build/common/error.js +1 -10
- package/build/common/fmt.d.ts +3 -15
- package/build/common/fmt.d.ts.map +1 -1
- package/build/common/fmt.js +7 -35
- package/build/common/http.d.ts +2 -7
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +8 -17
- package/build/common/icons.d.ts +18 -20
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +103 -67
- package/build/common/languageColors.d.ts +0 -1
- package/build/common/languageColors.d.ts.map +1 -1
- package/build/common/languageColors.js +1 -4
- package/build/common/languageColors.json +18 -2
- package/build/common/ops.d.ts +3 -14
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +19 -30
- package/build/common/render.d.ts +28 -82
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +175 -211
- package/build/common/retryer.d.ts +2 -7
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +4 -11
- package/build/fetchers/gist.d.ts +2 -5
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +1 -5
- package/build/fetchers/index.d.ts +12 -12
- package/build/fetchers/repo.d.ts +2 -11
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +20 -33
- package/build/fetchers/stats.d.ts +2 -32
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +27 -86
- package/build/fetchers/top-languages.d.ts +2 -9
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +15 -31
- package/build/fetchers/types.d.ts +1 -1
- package/build/fetchers/wakatime.d.ts +2 -6
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +1 -5
- package/build/graphql/contributionsDocument.d.ts +3 -3
- package/build/graphql/contributionsDocument.d.ts.map +1 -1
- package/build/graphql/contributionsDocument.js +0 -1
- package/build/graphql/generated/gist.d.ts +1 -1
- package/build/graphql/generated/repo.d.ts +1 -1
- package/build/graphql/generated/stats.d.ts +3 -3
- package/build/graphql/generated/top-languages.d.ts +2 -2
- package/build/graphql/graphqlDocument.d.ts +0 -1
- package/build/graphql/graphqlDocument.d.ts.map +1 -1
- package/build/graphql/graphqlDocument.js +0 -1
- package/build/graphql/reposContributedToDocument.d.ts +4 -5
- package/build/graphql/reposContributedToDocument.d.ts.map +1 -1
- package/build/graphql/reposContributedToDocument.js +0 -2
- package/build/markup/css.d.ts +35 -0
- package/build/markup/css.d.ts.map +1 -0
- package/build/markup/css.js +64 -0
- package/build/markup/element.d.ts +41 -0
- package/build/markup/element.d.ts.map +1 -0
- package/build/markup/element.js +127 -0
- package/build/markup/html.d.ts +13 -0
- package/build/markup/html.d.ts.map +1 -0
- package/build/markup/html.js +27 -0
- package/build/markup/index.d.ts +9 -0
- package/build/markup/index.d.ts.map +1 -0
- package/build/markup/index.js +6 -0
- package/build/markup/serialize.d.ts +16 -0
- package/build/markup/serialize.d.ts.map +1 -0
- package/build/markup/serialize.js +17 -0
- package/build/themes/index.d.ts +332 -333
- package/build/themes/index.d.ts.map +1 -1
- package/build/themes/index.js +1 -1
- package/build/translations.d.ts +2 -6
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +621 -628
- package/package.json +17 -26
- package/src/api/api-result.ts +10 -9
- package/src/api/gist.ts +11 -18
- package/src/api/index.ts +12 -12
- package/src/api/params.ts +27 -21
- package/src/api/pin.ts +13 -28
- package/src/api/stats.ts +13 -39
- package/src/api/top-langs.ts +13 -33
- package/src/api/wakatime.ts +11 -28
- package/src/calculateRank.ts +12 -23
- package/src/cards/gist.ts +40 -43
- package/src/cards/options.ts +1 -1
- package/src/cards/repo.ts +97 -107
- package/src/cards/stats.ts +165 -184
- package/src/cards/top-languages.ts +297 -413
- package/src/cards/wakatime.ts +193 -221
- package/src/common/Card.ts +165 -217
- package/src/common/I18n.ts +3 -6
- package/src/common/color.ts +80 -57
- package/src/common/config.ts +5 -18
- package/src/common/constants.ts +5 -2
- package/src/common/date.ts +0 -2
- package/src/common/emojiMap.json +1915 -0
- package/src/common/emojiMap.ts +13 -0
- package/src/common/error.ts +2 -11
- package/src/common/fmt.ts +7 -44
- package/src/common/http.ts +9 -15
- package/src/common/icons.ts +117 -42
- package/src/common/languageColors.json +18 -2
- package/src/common/languageColors.ts +1 -4
- package/src/common/ops.ts +26 -34
- package/src/common/render.ts +279 -232
- package/src/common/retryer.ts +8 -15
- package/src/fetchers/gist.ts +8 -12
- package/src/fetchers/index.ts +12 -12
- package/src/fetchers/repo.ts +27 -40
- package/src/fetchers/stats.ts +44 -102
- package/src/fetchers/top-languages.ts +26 -40
- package/src/fetchers/types.ts +1 -1
- package/src/fetchers/wakatime.ts +5 -9
- package/src/graphql/contributionsDocument.ts +7 -5
- package/src/graphql/generated/gist.ts +1 -1
- package/src/graphql/generated/repo.ts +1 -1
- package/src/graphql/generated/stats.ts +2 -2
- package/src/graphql/generated/top-languages.ts +2 -2
- package/src/graphql/graphqlDocument.ts +0 -1
- package/src/graphql/reposContributedToDocument.ts +6 -7
- package/src/markup/css.ts +118 -0
- package/src/markup/element.ts +246 -0
- package/src/markup/html.ts +34 -0
- package/src/markup/index.ts +9 -0
- package/src/markup/serialize.ts +27 -0
- package/src/themes/index.ts +1 -1
- package/src/translations.ts +622 -629
- package/build/cards/index.d.ts +0 -11
- package/build/cards/index.d.ts.map +0 -1
- package/build/cards/index.js +0 -7
- package/build/common/html.d.ts +0 -8
- package/build/common/html.d.ts.map +0 -1
- package/build/common/html.js +0 -14
- package/build/index.d.ts +0 -15
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -10
- package/src/_emoji-name-map.d.ts +0 -10
- package/src/_github-username-regex.d.ts +0 -4
- package/src/cards/index.ts +0 -21
- package/src/common/html.ts +0 -17
- package/src/index.ts +0 -18
package/build/api/top-langs.js
CHANGED
|
@@ -2,10 +2,10 @@ import * as z from 'zod/mini';
|
|
|
2
2
|
import { TOP_LANG_LAYOUTS, TOP_LANG_STATS_FORMATS, renderTopLanguages, } from '../cards/top-languages.js';
|
|
3
3
|
import { fetchTopLanguages } from '../fetchers/top-languages.js';
|
|
4
4
|
import { errorResult } from './api-result.js';
|
|
5
|
-
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam,
|
|
5
|
+
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, parseColorParams, parseParams, rawParam, usernameParam, } from './params.js';
|
|
6
6
|
/** What the top-languages endpoint accepts, on top of the shared color params. */
|
|
7
7
|
const topLangsQuery = z.object({
|
|
8
|
-
username:
|
|
8
|
+
username: usernameParam,
|
|
9
9
|
hide: listParam,
|
|
10
10
|
hide_title: booleanParam,
|
|
11
11
|
hide_border: booleanParam,
|
|
@@ -27,26 +27,6 @@ const topLangsQuery = z.object({
|
|
|
27
27
|
/**
|
|
28
28
|
* Render the top languages card for a set of query params.
|
|
29
29
|
*
|
|
30
|
-
* @param query Raw query params, plus any of the shared color params.
|
|
31
|
-
* @param query.username GitHub username.
|
|
32
|
-
* @param query.hide Comma-separated languages to hide.
|
|
33
|
-
* @param query.hide_title Whether to hide the card title.
|
|
34
|
-
* @param query.hide_border Whether to hide the card border.
|
|
35
|
-
* @param query.card_width Card width.
|
|
36
|
-
* @param query.layout How the languages are laid out.
|
|
37
|
-
* @param query.langs_count Number of languages to show.
|
|
38
|
-
* @param query.exclude_repo Comma-separated repositories to exclude.
|
|
39
|
-
* @param query.size_weight Weight given to a language's size.
|
|
40
|
-
* @param query.count_weight Weight given to a language's repository count.
|
|
41
|
-
* @param query.custom_title Card title.
|
|
42
|
-
* @param query.locale Language the card is rendered in.
|
|
43
|
-
* @param query.border_radius Card border radius.
|
|
44
|
-
* @param query.role Comma-separated owner affiliations to include.
|
|
45
|
-
* @param query.disable_animations Whether to disable the card animations.
|
|
46
|
-
* @param query.hide_progress Whether to hide the progress bars.
|
|
47
|
-
* @param query.hide_values Whether to hide the language values.
|
|
48
|
-
* @param query.stats_format Whether values are shown as bytes or percentages.
|
|
49
|
-
* @param config Deployment config supplying the PAT pool.
|
|
50
30
|
* @returns The rendered card, or a rendered error.
|
|
51
31
|
*/
|
|
52
32
|
const renderTopLangs = async (query, config) => {
|
|
@@ -54,9 +34,9 @@ const renderTopLangs = async (query, config) => {
|
|
|
54
34
|
try {
|
|
55
35
|
colors = parseColorParams(query);
|
|
56
36
|
}
|
|
57
|
-
catch (
|
|
37
|
+
catch (error) {
|
|
58
38
|
// A rejected color cannot be used to draw its own error card.
|
|
59
|
-
return errorResult(
|
|
39
|
+
return errorResult(error);
|
|
60
40
|
}
|
|
61
41
|
try {
|
|
62
42
|
const { username, hide, hide_title, hide_border, card_width, layout, langs_count, exclude_repo, size_weight, count_weight, custom_title, locale, border_radius, role, disable_animations, hide_progress, hide_values, stats_format, } = parseParams(topLangsQuery, query);
|
|
@@ -87,8 +67,8 @@ const renderTopLangs = async (query, config) => {
|
|
|
87
67
|
}),
|
|
88
68
|
};
|
|
89
69
|
}
|
|
90
|
-
catch (
|
|
91
|
-
return errorResult(
|
|
70
|
+
catch (error) {
|
|
71
|
+
return errorResult(error, colors);
|
|
92
72
|
}
|
|
93
73
|
};
|
|
94
74
|
/**
|
package/build/api/wakatime.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import type { CardConfig } from '../common/config.
|
|
3
|
-
import type { ApiResult } from './api-result.
|
|
4
|
-
import type { ApiQuery } from './params.
|
|
2
|
+
import type { CardConfig } from '../common/config.ts';
|
|
3
|
+
import type { ApiResult } from './api-result.ts';
|
|
4
|
+
import type { ApiQuery } from './params.ts';
|
|
5
5
|
/** What the wakatime endpoint accepts, on top of the shared color params. */
|
|
6
6
|
declare const wakatimeQuery: z.ZodMiniObject<{
|
|
7
7
|
username: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
|
|
@@ -17,16 +17,24 @@ declare const wakatimeQuery: z.ZodMiniObject<{
|
|
|
17
17
|
hide: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string[], string | undefined>>;
|
|
18
18
|
api_domain: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
19
19
|
border_radius: z.ZodMiniType<number | undefined, string | undefined, z.core.$ZodTypeInternals<number | undefined, string | undefined>>;
|
|
20
|
-
display_format: z.ZodMiniType<"
|
|
20
|
+
display_format: z.ZodMiniType<"percent" | "time" | undefined, string | undefined, z.core.$ZodTypeInternals<"percent" | "time" | undefined, string | undefined>>;
|
|
21
21
|
disable_animations: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
22
22
|
}, z.core.$strip>;
|
|
23
23
|
/** The query this endpoint accepts, checked against the schema above. */
|
|
24
24
|
type WakatimeApiQuery = ApiQuery<typeof wakatimeQuery>;
|
|
25
|
+
/**
|
|
26
|
+
* Render the WakaTime card for a set of query params.
|
|
27
|
+
*
|
|
28
|
+
* WakaTime needs no GitHub token, so the config is read only for the transport it carries.
|
|
29
|
+
*
|
|
30
|
+
* @returns The rendered card, or a rendered error.
|
|
31
|
+
*/
|
|
32
|
+
declare const renderWakatime: (query: WakatimeApiQuery, config: CardConfig) => Promise<ApiResult>;
|
|
25
33
|
/**
|
|
26
34
|
* The card, with the values its enum params accept.
|
|
27
35
|
* A UI reads them off the function it calls, e.g. `wakatime.LAYOUTS`.
|
|
28
36
|
*/
|
|
29
|
-
export declare const wakatime:
|
|
37
|
+
export declare const wakatime: typeof renderWakatime & {
|
|
30
38
|
LAYOUTS: readonly ["compact", "normal"];
|
|
31
39
|
DISPLAY_FORMATS: readonly ["time", "percent"];
|
|
32
40
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/api/wakatime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAc5C,6EAA6E;AAC7E,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;iBAgBjB,CAAC;AAEH,yEAAyE;AACzE,KAAK,gBAAgB,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAC;
|
|
1
|
+
{"version":3,"file":"wakatime.d.ts","sourceRoot":"","sources":["../../src/api/wakatime.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAG9B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAGtD,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAEjD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAc5C,6EAA6E;AAC7E,QAAA,MAAM,aAAa;;;;;;;;;;;;;;;;iBAgBjB,CAAC;AAEH,yEAAyE;AACzE,KAAK,gBAAgB,GAAG,QAAQ,CAAC,OAAO,aAAa,CAAC,CAAC;AAEvD;;;;;;GAMG;AACH,QAAA,MAAM,cAAc,UAAiB,gBAAgB,UAAU,UAAU,KAAG,OAAO,CAAC,SAAS,CAoD5F,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ;;;CAGnB,CAAC"}
|
package/build/api/wakatime.js
CHANGED
|
@@ -26,23 +26,6 @@ const wakatimeQuery = z.object({
|
|
|
26
26
|
*
|
|
27
27
|
* WakaTime needs no GitHub token, so the config is read only for the transport it carries.
|
|
28
28
|
*
|
|
29
|
-
* @param query Raw query params, plus any of the shared color params.
|
|
30
|
-
* @param query.username WakaTime username.
|
|
31
|
-
* @param query.hide_border Whether to hide the card border.
|
|
32
|
-
* @param query.card_width Card width.
|
|
33
|
-
* @param query.line_height Line height between the languages.
|
|
34
|
-
* @param query.hide_title Whether to hide the card title.
|
|
35
|
-
* @param query.hide_progress Whether to hide the progress bars.
|
|
36
|
-
* @param query.custom_title Card title.
|
|
37
|
-
* @param query.locale Language the card is rendered in.
|
|
38
|
-
* @param query.layout How the languages are laid out.
|
|
39
|
-
* @param query.langs_count Number of languages to show.
|
|
40
|
-
* @param query.hide Comma-separated languages to hide.
|
|
41
|
-
* @param query.api_domain WakaTime instance the stats are read from.
|
|
42
|
-
* @param query.border_radius Card border radius.
|
|
43
|
-
* @param query.display_format Whether values are shown as time or percentages.
|
|
44
|
-
* @param query.disable_animations Whether to disable the card animations.
|
|
45
|
-
* @param config Deployment config supplying the transport.
|
|
46
29
|
* @returns The rendered card, or a rendered error.
|
|
47
30
|
*/
|
|
48
31
|
const renderWakatime = async (query, config) => {
|
|
@@ -50,9 +33,9 @@ const renderWakatime = async (query, config) => {
|
|
|
50
33
|
try {
|
|
51
34
|
colors = parseColorParams(query);
|
|
52
35
|
}
|
|
53
|
-
catch (
|
|
36
|
+
catch (error) {
|
|
54
37
|
// A rejected color cannot be used to draw its own error card.
|
|
55
|
-
return errorResult(
|
|
38
|
+
return errorResult(error);
|
|
56
39
|
}
|
|
57
40
|
try {
|
|
58
41
|
const { 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, } = parseParams(wakatimeQuery, query);
|
|
@@ -77,8 +60,8 @@ const renderWakatime = async (query, config) => {
|
|
|
77
60
|
}),
|
|
78
61
|
};
|
|
79
62
|
}
|
|
80
|
-
catch (
|
|
81
|
-
return errorResult(
|
|
63
|
+
catch (error) {
|
|
64
|
+
return errorResult(error, colors);
|
|
82
65
|
}
|
|
83
66
|
};
|
|
84
67
|
/**
|
package/build/calculateRank.d.ts
CHANGED
|
@@ -1,15 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Calculates the users rank.
|
|
3
3
|
*
|
|
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
4
|
* @returns The users rank.
|
|
14
5
|
*/
|
|
15
6
|
declare function calculateRank({ all_commits, commits, prs, issues, reviews, stars, followers, }: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"calculateRank.d.ts","sourceRoot":"","sources":["../src/calculateRank.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"calculateRank.d.ts","sourceRoot":"","sources":["../src/calculateRank.ts"],"names":[],"mappings":"AAmBA;;;;GAIG;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,CAoCxC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
|
package/build/calculateRank.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Calculates the exponential cdf.
|
|
3
3
|
*
|
|
4
|
-
* @param x The value.
|
|
5
4
|
* @returns The exponential cdf.
|
|
6
5
|
*/
|
|
7
6
|
function exponential_cdf(x) {
|
|
@@ -10,7 +9,6 @@ function exponential_cdf(x) {
|
|
|
10
9
|
/**
|
|
11
10
|
* Calculates the log normal cdf.
|
|
12
11
|
*
|
|
13
|
-
* @param x The value.
|
|
14
12
|
* @returns The log normal cdf.
|
|
15
13
|
*/
|
|
16
14
|
function log_normal_cdf(x) {
|
|
@@ -20,24 +18,21 @@ function log_normal_cdf(x) {
|
|
|
20
18
|
/**
|
|
21
19
|
* Calculates the users rank.
|
|
22
20
|
*
|
|
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
21
|
* @returns The users rank.
|
|
33
22
|
*/
|
|
34
23
|
function calculateRank({ all_commits, commits, prs, issues, reviews, stars, followers, }) {
|
|
35
|
-
const COMMITS_MEDIAN = all_commits ? 1000 : 250
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const
|
|
40
|
-
const
|
|
24
|
+
const COMMITS_MEDIAN = all_commits ? 1000 : 250;
|
|
25
|
+
const COMMITS_WEIGHT = 2;
|
|
26
|
+
const PRS_MEDIAN = 50;
|
|
27
|
+
const PRS_WEIGHT = 3;
|
|
28
|
+
const ISSUES_MEDIAN = 25;
|
|
29
|
+
const ISSUES_WEIGHT = 1;
|
|
30
|
+
const REVIEWS_MEDIAN = 2;
|
|
31
|
+
const REVIEWS_WEIGHT = 1;
|
|
32
|
+
const STARS_MEDIAN = 50;
|
|
33
|
+
const STARS_WEIGHT = 4;
|
|
34
|
+
const FOLLOWERS_MEDIAN = 10;
|
|
35
|
+
const FOLLOWERS_WEIGHT = 1;
|
|
41
36
|
const TOTAL_WEIGHT = COMMITS_WEIGHT + PRS_WEIGHT + ISSUES_WEIGHT + REVIEWS_WEIGHT + STARS_WEIGHT + FOLLOWERS_WEIGHT;
|
|
42
37
|
const THRESHOLDS = [1, 12.5, 25, 37.5, 50, 62.5, 75, 87.5, 100];
|
|
43
38
|
const LEVELS = ['S', 'A+', 'A', 'A-', 'B+', 'B', 'B-', 'C+', 'C'];
|
package/build/cards/gist.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GistData } from '../fetchers/types.
|
|
2
|
-
import type { CardOptions, CommonCardOptions } from './options.
|
|
1
|
+
import type { GistData } from '../fetchers/types.ts';
|
|
2
|
+
import type { CardOptions, CommonCardOptions } from './options.ts';
|
|
3
3
|
interface GistCardOptions extends CommonCardOptions {
|
|
4
4
|
show_owner: boolean;
|
|
5
5
|
browser_rendering: boolean;
|
|
@@ -7,8 +7,6 @@ interface GistCardOptions extends CommonCardOptions {
|
|
|
7
7
|
/**
|
|
8
8
|
* Render gist card.
|
|
9
9
|
*
|
|
10
|
-
* @param gistData Gist data.
|
|
11
|
-
* @param options Gist card options.
|
|
12
10
|
* @returns Gist card.
|
|
13
11
|
*/
|
|
14
12
|
declare const renderGistCard: (gistData: GistData, options?: CardOptions<GistCardOptions>) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gist.d.ts","sourceRoot":"","sources":["../../src/cards/gist.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"gist.d.ts","sourceRoot":"","sources":["../../src/cards/gist.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAIrD,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAWnE,UAAU,eAAgB,SAAQ,iBAAiB;IACjD,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,QAAA,MAAM,cAAc,aAAc,QAAQ,YAAW,WAAW,CAAC,eAAe,CAAC,KAAQ,MA0HxF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/build/cards/gist.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { Card } from '../common/Card.js';
|
|
2
2
|
import { getLightDarkColors } from '../common/color.js';
|
|
3
|
-
import { kFormatter
|
|
4
|
-
import { encodeHTML } from '../common/html.js';
|
|
3
|
+
import { kFormatter } from '../common/fmt.js';
|
|
5
4
|
import { icons } from '../common/icons.js';
|
|
6
5
|
import { getLanguageColor } from '../common/languageColors.js';
|
|
7
6
|
import { parseEmojis } from '../common/ops.js';
|
|
8
|
-
import { countWrappedLines, createLanguageNode, flexLayout, iconWithLabel, measureText, wrappedTextNode, wrappedTextStyles, } from '../common/render.js';
|
|
7
|
+
import { countWrappedLines, wrapTextMultiline, createLanguageNode, flexLayout, iconWithLabel, measureText, wrappedTextNode, wrappedTextStyles, } from '../common/render.js';
|
|
8
|
+
import { el, rule } from '../markup/index.js';
|
|
9
9
|
const ICON_SIZE = 16;
|
|
10
10
|
const CARD_DEFAULT_WIDTH = 400;
|
|
11
11
|
const X_OFFSET = 25;
|
|
@@ -17,8 +17,6 @@ const DESCRIPTION_MAX_LINES = 10;
|
|
|
17
17
|
/**
|
|
18
18
|
* Render gist card.
|
|
19
19
|
*
|
|
20
|
-
* @param gistData Gist data.
|
|
21
|
-
* @param options Gist card options.
|
|
22
20
|
* @returns Gist card.
|
|
23
21
|
*/
|
|
24
22
|
const renderGistCard = (gistData, options = {}) => {
|
|
@@ -49,12 +47,7 @@ const renderGistCard = (gistData, options = {}) => {
|
|
|
49
47
|
const linesLimit = 10;
|
|
50
48
|
const multiLineDescription = wrapTextMultiline(desc, DESCRIPTION_BOX_WIDTH, DESCRIPTION_FONT_SIZE, linesLimit);
|
|
51
49
|
descriptionLines = multiLineDescription.length;
|
|
52
|
-
descriptionSvg = multiLineDescription
|
|
53
|
-
.map((line) => `<tspan dy="1.2em" x="${X_OFFSET}">${encodeHTML(line)}</tspan>`)
|
|
54
|
-
.join('');
|
|
55
|
-
descriptionSvg = `<text class="description" x="${X_OFFSET}" y="-5">
|
|
56
|
-
${descriptionSvg}
|
|
57
|
-
</text>`;
|
|
50
|
+
descriptionSvg = el('text', { class: 'description', x: X_OFFSET, y: -5 }, multiLineDescription.map((line) => el('tspan', { dy: '1.2em', x: X_OFFSET }, line)));
|
|
58
51
|
}
|
|
59
52
|
const lineHeight = descriptionLines > 3 ? 12 : 10;
|
|
60
53
|
const height = (descriptionLines > 1 ? 120 : 110) + descriptionLines * lineHeight;
|
|
@@ -73,7 +66,7 @@ const renderGistCard = (gistData, options = {}) => {
|
|
|
73
66
|
ICON_SIZE + measureText(`${totalForks}`, 12),
|
|
74
67
|
],
|
|
75
68
|
gap: 25,
|
|
76
|
-
})
|
|
69
|
+
});
|
|
77
70
|
const header = show_owner ? nameWithOwner : name;
|
|
78
71
|
const card = new Card({
|
|
79
72
|
defaultTitle: header.length > HEADER_MAX_LENGTH ? `${header.slice(0, HEADER_MAX_LENGTH)}...` : header,
|
|
@@ -84,22 +77,23 @@ const renderGistCard = (gistData, options = {}) => {
|
|
|
84
77
|
colors: { light: lightColors, dark: darkColors },
|
|
85
78
|
});
|
|
86
79
|
card.setCSS({
|
|
87
|
-
light: ({ textColor, iconColor }) =>
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
80
|
+
light: ({ textColor, iconColor }) => [
|
|
81
|
+
rule('.description', {
|
|
82
|
+
font: `400 ${DESCRIPTION_FONT_SIZE}px 'Segoe UI', Ubuntu, Sans-Serif`,
|
|
83
|
+
fill: textColor,
|
|
84
|
+
...(browser_rendering ? wrappedTextStyles(textColor) : {}),
|
|
85
|
+
}),
|
|
86
|
+
rule('.gray', { font: "400 12px 'Segoe UI', Ubuntu, Sans-Serif", fill: textColor }),
|
|
87
|
+
rule('.icon', { fill: iconColor }),
|
|
88
|
+
],
|
|
89
|
+
dark: ({ textColor, iconColor }) => [
|
|
90
|
+
rule('.description', {
|
|
91
|
+
fill: textColor,
|
|
92
|
+
...(browser_rendering ? wrappedTextStyles(textColor) : {}),
|
|
93
|
+
}),
|
|
94
|
+
rule('.gray', { fill: textColor }),
|
|
95
|
+
rule('.icon', { fill: iconColor }),
|
|
96
|
+
],
|
|
103
97
|
});
|
|
104
98
|
card.setHideBorder(hide_border);
|
|
105
99
|
// `role="img"` hides the inner text from assistive tech, so everything the card
|
|
@@ -108,12 +102,9 @@ const renderGistCard = (gistData, options = {}) => {
|
|
|
108
102
|
title: card.title,
|
|
109
103
|
desc: `${desc}. Language: ${languageName}, Stars: ${totalStars}, Forks: ${totalForks}`,
|
|
110
104
|
});
|
|
111
|
-
return card.render(
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
${starAndForkCount}
|
|
116
|
-
</g>
|
|
117
|
-
`);
|
|
105
|
+
return card.render([
|
|
106
|
+
descriptionSvg,
|
|
107
|
+
el('g', { transform: `translate(30, ${height - 75})` }, starAndForkCount),
|
|
108
|
+
]);
|
|
118
109
|
};
|
|
119
110
|
export { renderGistCard };
|
package/build/cards/options.d.ts
CHANGED
package/build/cards/repo.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { RepositoryData } from '../fetchers/types.
|
|
2
|
-
import type { CardOptions, CommonCardOptions } from './options.
|
|
1
|
+
import type { RepositoryData } from '../fetchers/types.ts';
|
|
2
|
+
import type { CardOptions, CommonCardOptions } from './options.ts';
|
|
3
3
|
interface RepoCardOptions extends CommonCardOptions {
|
|
4
4
|
locale: string;
|
|
5
5
|
show_owner: boolean;
|
|
@@ -16,8 +16,6 @@ interface RepoCardOptions extends CommonCardOptions {
|
|
|
16
16
|
/**
|
|
17
17
|
* Renders repository card details.
|
|
18
18
|
*
|
|
19
|
-
* @param repo Repository data.
|
|
20
|
-
* @param options Card options.
|
|
21
19
|
* @returns Repository card SVG object.
|
|
22
20
|
*/
|
|
23
21
|
declare const renderRepoCard: (repo: RepositoryData, options?: CardOptions<RepoCardOptions>) => string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/cards/repo.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"repo.d.ts","sourceRoot":"","sources":["../../src/cards/repo.ts"],"names":[],"mappings":"AAiBA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAK3D,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AASnE,UAAU,eAAgB,SAAQ,iBAAiB;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,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;AAuCD;;;;GAIG;AACH,QAAA,MAAM,cAAc,SACZ,cAAc,YACX,WAAW,CAAC,eAAe,CAAC,KACpC,MAiRF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
package/build/cards/repo.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { Card } from '../common/Card.js';
|
|
2
2
|
import { getLightDarkColors } from '../common/color.js';
|
|
3
|
-
import { kFormatter
|
|
4
|
-
import { encodeHTML } from '../common/html.js';
|
|
3
|
+
import { kFormatter } from '../common/fmt.js';
|
|
5
4
|
import { I18n } from '../common/I18n.js';
|
|
6
5
|
import { icons } from '../common/icons.js';
|
|
7
6
|
import { buildSearchFilter, clampValue, parseEmojis } from '../common/ops.js';
|
|
8
|
-
import { countWrappedLines, createLanguageNode, createTextNode, flexLayout, iconWithLabel, measureText, wrappedTextNode, wrappedTextStyles, } from '../common/render.js';
|
|
7
|
+
import { countWrappedLines, wrapTextMultiline, createLanguageNode, createTextNode, flexLayout, iconWithLabel, measureText, wrappedTextNode, wrappedTextStyles, } from '../common/render.js';
|
|
8
|
+
import { el, rule } from '../markup/index.js';
|
|
9
9
|
import { repoCardLocales } from '../translations.js';
|
|
10
10
|
const ICON_SIZE = 16;
|
|
11
11
|
const CARD_DEFAULT_WIDTH = 400;
|
|
@@ -16,39 +16,29 @@ const DESCRIPTION_MAX_LINES = 3;
|
|
|
16
16
|
/**
|
|
17
17
|
* Retrieves the repository description and wraps it to fit the card width.
|
|
18
18
|
*
|
|
19
|
-
* @param label The repository description.
|
|
20
|
-
* @param xOffset Horizontal offset of the badge.
|
|
21
19
|
* @returns Wrapped repo description SVG object.
|
|
22
20
|
*/
|
|
23
21
|
const getBadgeSVG = (label, xOffset = 0) => {
|
|
24
22
|
if (!Number.isFinite(xOffset)) {
|
|
25
|
-
throw new
|
|
23
|
+
throw new TypeError(`Invalid xOffset: "${xOffset}"`);
|
|
26
24
|
}
|
|
27
|
-
return `
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
text-anchor="middle"
|
|
35
|
-
>
|
|
36
|
-
${encodeHTML(label)}
|
|
37
|
-
</text>
|
|
38
|
-
</g>
|
|
39
|
-
`;
|
|
25
|
+
return el('g', { 'data-testid': 'badge', class: 'badge', transform: `translate(${320 + xOffset}, -18)` }, el('rect', { 'stroke-width': 1, width: 70, height: 20, x: -12, y: -14, ry: 10, rx: 10 }), el('text', {
|
|
26
|
+
x: 23,
|
|
27
|
+
y: -5,
|
|
28
|
+
'alignment-baseline': 'central',
|
|
29
|
+
'dominant-baseline': 'central',
|
|
30
|
+
'text-anchor': 'middle',
|
|
31
|
+
}, label));
|
|
40
32
|
};
|
|
41
33
|
/**
|
|
42
34
|
* Renders repository card details.
|
|
43
35
|
*
|
|
44
|
-
* @param repo Repository data.
|
|
45
|
-
* @param options Card options.
|
|
46
36
|
* @returns Repository card SVG object.
|
|
47
37
|
*/
|
|
48
38
|
const renderRepoCard = (repo, options = {}) => {
|
|
49
39
|
const { name, nameWithOwner, description, primaryLanguage, isArchived, isTemplate, stargazerCount, forkCount, totalPRsAuthored, totalPRsCommented, totalPRsReviewed, totalIssuesAuthored, totalIssuesCommented, } = repo;
|
|
50
40
|
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;
|
|
51
|
-
const card_width = card_width_input && !isNaN(card_width_input)
|
|
41
|
+
const card_width = card_width_input && !Number.isNaN(card_width_input)
|
|
52
42
|
? card_width_input
|
|
53
43
|
: show.length >= 2
|
|
54
44
|
? CARD_DEFAULT_WIDTH + 30
|
|
@@ -121,11 +111,11 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
121
111
|
link: stat.link,
|
|
122
112
|
labelXOffset: 23,
|
|
123
113
|
}));
|
|
124
|
-
const extraLHeight = parseInt(String(line_height), 10);
|
|
114
|
+
const extraLHeight = Number.parseInt(String(line_height), 10);
|
|
125
115
|
const lineHeight = 10;
|
|
126
116
|
const header = show_owner ? nameWithOwner : name;
|
|
127
|
-
const langName =
|
|
128
|
-
const langColor =
|
|
117
|
+
const langName = primaryLanguage?.name || 'Unspecified';
|
|
118
|
+
const langColor = primaryLanguage?.color || '#333';
|
|
129
119
|
const desc = parseEmojis(description || 'No description provided');
|
|
130
120
|
const descriptionBoxWidth = card_width - 2 * X_OFFSET;
|
|
131
121
|
let descriptionLinesCount;
|
|
@@ -157,19 +147,12 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
157
147
|
descriptionLinesCount = description_lines_count
|
|
158
148
|
? clampValue(description_lines_count, 1, DESCRIPTION_MAX_LINES)
|
|
159
149
|
: multiLineDescription.length;
|
|
160
|
-
descriptionSvg = multiLineDescription
|
|
161
|
-
.map((line) => `<tspan dy="1.2em" x="${X_OFFSET}">${encodeHTML(line)}</tspan>`)
|
|
162
|
-
.join('');
|
|
163
|
-
descriptionSvg = `<text class="description" x="${X_OFFSET}" y="-5">
|
|
164
|
-
${descriptionSvg}
|
|
165
|
-
</text>`;
|
|
150
|
+
descriptionSvg = el('text', { class: 'description', x: X_OFFSET, y: -5 }, multiLineDescription.map((line) => el('tspan', { dy: '1.2em', x: X_OFFSET }, line)));
|
|
166
151
|
}
|
|
167
|
-
const extraHeight = Object.keys(STATS).length
|
|
168
|
-
? -7 + (Math.ceil(statItems.length / 2) + 1) * extraLHeight
|
|
169
|
-
: 0;
|
|
152
|
+
const extraHeight = Object.keys(STATS).length > 0 ? -7 + (Math.ceil(statItems.length / 2) + 1) * extraLHeight : 0;
|
|
170
153
|
const height = (descriptionLinesCount > 1 ? 120 : 110) + descriptionLinesCount * lineHeight + extraHeight;
|
|
171
154
|
const { lightColors, darkColors } = getLightDarkColors({ ...options, theme });
|
|
172
|
-
const svgLanguage = primaryLanguage ? createLanguageNode(langName, langColor) :
|
|
155
|
+
const svgLanguage = primaryLanguage ? createLanguageNode(langName, langColor) : undefined;
|
|
173
156
|
const totalStars = kFormatter(stargazerCount);
|
|
174
157
|
const totalForks = kFormatter(forkCount);
|
|
175
158
|
const svgStars = iconWithLabel(icons.star, totalStars, 'stargazers', ICON_SIZE);
|
|
@@ -182,24 +165,16 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
182
165
|
ICON_SIZE + measureText(`${totalForks}`, 12),
|
|
183
166
|
],
|
|
184
167
|
gap: 25,
|
|
185
|
-
})
|
|
168
|
+
});
|
|
186
169
|
const extraRows = [];
|
|
187
170
|
for (let i = 0; i < statItems.length; i += 2) {
|
|
188
171
|
extraRows.push(flexLayout({
|
|
189
172
|
items: statItems.slice(i, i + 2),
|
|
190
173
|
gap: 210,
|
|
191
174
|
direction: 'row',
|
|
192
|
-
})
|
|
175
|
+
}));
|
|
193
176
|
}
|
|
194
|
-
const extraItems = `
|
|
195
|
-
<svg x="0" y="0"><g transform="translate(-3, ${height - 52 - extraHeight})">
|
|
196
|
-
${flexLayout({
|
|
197
|
-
items: extraRows,
|
|
198
|
-
gap: extraLHeight,
|
|
199
|
-
direction: 'column',
|
|
200
|
-
}).join('')}
|
|
201
|
-
</g></svg>
|
|
202
|
-
`;
|
|
177
|
+
const extraItems = el('svg', { x: 0, y: 0 }, el('g', { transform: `translate(-3, ${height - 52 - extraHeight})` }, flexLayout({ items: extraRows, gap: extraLHeight, direction: 'column' })));
|
|
203
178
|
const card = new Card({
|
|
204
179
|
defaultTitle: header.length > 35 ? `${header.slice(0, 35)}...` : header,
|
|
205
180
|
titlePrefixIcon: icons.contribs,
|
|
@@ -212,39 +187,36 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
212
187
|
card.setHideBorder(hide_border);
|
|
213
188
|
card.setHideTitle(false);
|
|
214
189
|
card.setCSS({
|
|
215
|
-
light: ({ textColor, iconColor }) =>
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
.stat { fill: ${textColor} }
|
|
246
|
-
.icon { fill: ${iconColor}; }
|
|
247
|
-
`,
|
|
190
|
+
light: ({ textColor, iconColor }) => [
|
|
191
|
+
rule('.description', {
|
|
192
|
+
font: `400 ${DESCRIPTION_FONT_SIZE}px 'Segoe UI', Ubuntu, Sans-Serif`,
|
|
193
|
+
fill: textColor,
|
|
194
|
+
...(browser_rendering ? wrappedTextStyles(textColor) : {}),
|
|
195
|
+
}),
|
|
196
|
+
rule('.gray', { font: "400 12px 'Segoe UI', Ubuntu, Sans-Serif", fill: textColor }),
|
|
197
|
+
rule('.badge', { font: "600 11px 'Segoe UI', Ubuntu, Sans-Serif" }),
|
|
198
|
+
rule('.badge rect', { opacity: 0.2, stroke: textColor }),
|
|
199
|
+
rule('.badge text', { fill: textColor }),
|
|
200
|
+
rule('.stat', { font: "400 12px 'Segoe UI', Ubuntu, Sans-Serif", fill: textColor }),
|
|
201
|
+
rule('.stagger', {
|
|
202
|
+
opacity: 0,
|
|
203
|
+
animation: 'fadeInAnimation 0.3s ease-in-out forwards',
|
|
204
|
+
}),
|
|
205
|
+
rule('.not_bold', { 'font-weight': 400 }),
|
|
206
|
+
rule('.bold', { 'font-weight': 700 }),
|
|
207
|
+
rule('.icon', { fill: iconColor, display: 'block' }),
|
|
208
|
+
],
|
|
209
|
+
dark: ({ textColor, iconColor }) => [
|
|
210
|
+
rule('.description', {
|
|
211
|
+
fill: textColor,
|
|
212
|
+
...(browser_rendering ? wrappedTextStyles(textColor) : {}),
|
|
213
|
+
}),
|
|
214
|
+
rule('.gray', { fill: textColor }),
|
|
215
|
+
rule('.badge rect', { stroke: textColor }),
|
|
216
|
+
rule('.badge text', { fill: textColor }),
|
|
217
|
+
rule('.stat', { fill: textColor }),
|
|
218
|
+
rule('.icon', { fill: iconColor }),
|
|
219
|
+
],
|
|
248
220
|
});
|
|
249
221
|
const extraStatLabels = Object.values(STATS)
|
|
250
222
|
.map((stat) => `${stat.label}: ${stat.value ?? 0}`)
|
|
@@ -258,19 +230,15 @@ const renderRepoCard = (repo, options = {}) => {
|
|
|
258
230
|
title: card.title,
|
|
259
231
|
desc: [`${desc}.`, primaryLanguage ? langName : '', extraStatLabels].filter(Boolean).join(', '),
|
|
260
232
|
});
|
|
261
|
-
return card.render(
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
${starAndForkCount}
|
|
272
|
-
</g>
|
|
273
|
-
${extraItems}
|
|
274
|
-
`);
|
|
233
|
+
return card.render([
|
|
234
|
+
isTemplate
|
|
235
|
+
? getBadgeSVG(i18n.t('repocard.template'), card_width - CARD_DEFAULT_WIDTH)
|
|
236
|
+
: isArchived
|
|
237
|
+
? getBadgeSVG(i18n.t('repocard.archived'), card_width - CARD_DEFAULT_WIDTH)
|
|
238
|
+
: undefined,
|
|
239
|
+
descriptionSvg,
|
|
240
|
+
el('g', { transform: `translate(30, ${height - 75 - extraHeight})` }, starAndForkCount),
|
|
241
|
+
extraItems,
|
|
242
|
+
]);
|
|
275
243
|
};
|
|
276
244
|
export { renderRepoCard };
|
package/build/cards/stats.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import type { StatsData } from '../fetchers/types.
|
|
2
|
-
import type { CardOptions, CommonCardOptions } from './options.
|
|
1
|
+
import type { StatsData } from '../fetchers/types.ts';
|
|
2
|
+
import type { CardOptions, CommonCardOptions } from './options.ts';
|
|
3
3
|
/** Rank indicators the card can draw; the api validates `rank_icon` against this. */
|
|
4
|
-
declare const RANK_ICONS: readonly [
|
|
4
|
+
declare const RANK_ICONS: readonly ['default', 'github', 'percentile'];
|
|
5
5
|
type RankIcon = (typeof RANK_ICONS)[number];
|
|
6
6
|
interface StatCardOptions extends CommonCardOptions {
|
|
7
7
|
locale: string;
|
|
@@ -25,11 +25,6 @@ interface StatCardOptions extends CommonCardOptions {
|
|
|
25
25
|
/**
|
|
26
26
|
* Renders the stats card.
|
|
27
27
|
*
|
|
28
|
-
* @param stats The stats data.
|
|
29
|
-
* @param options The card options.
|
|
30
|
-
* @param username GitHub username, used to build stat search links.
|
|
31
|
-
* @param repo Repositories to scope the search links to.
|
|
32
|
-
* @param owner Owners to scope the search links to.
|
|
33
28
|
* @returns The stats card SVG object.
|
|
34
29
|
*/
|
|
35
30
|
declare const renderStatsCard: (stats: StatsData, options?: CardOptions<StatCardOptions>, username?: string, repo?: Array<string>, owner?: Array<string>) => string;
|