@stats-forge/github-stats-forge-core 0.0.2 → 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.
Files changed (208) hide show
  1. package/README.md +0 -10
  2. package/build/api/api-result.d.ts +6 -7
  3. package/build/api/api-result.d.ts.map +1 -1
  4. package/build/api/api-result.js +4 -5
  5. package/build/api/gist.d.ts +3 -10
  6. package/build/api/gist.d.ts.map +1 -1
  7. package/build/api/gist.js +4 -11
  8. package/build/api/index.d.ts +12 -12
  9. package/build/api/params.d.ts +11 -8
  10. package/build/api/params.d.ts.map +1 -1
  11. package/build/api/params.js +16 -14
  12. package/build/api/pin.d.ts +3 -19
  13. package/build/api/pin.d.ts.map +1 -1
  14. package/build/api/pin.js +6 -22
  15. package/build/api/stats.d.ts +10 -4
  16. package/build/api/stats.d.ts.map +1 -1
  17. package/build/api/stats.js +6 -32
  18. package/build/api/top-langs.d.ts +12 -6
  19. package/build/api/top-langs.d.ts.map +1 -1
  20. package/build/api/top-langs.js +6 -26
  21. package/build/api/wakatime.d.ts +13 -5
  22. package/build/api/wakatime.d.ts.map +1 -1
  23. package/build/api/wakatime.js +4 -21
  24. package/build/calculateRank.d.ts +0 -9
  25. package/build/calculateRank.d.ts.map +1 -1
  26. package/build/calculateRank.js +12 -17
  27. package/build/cards/gist.d.ts +2 -4
  28. package/build/cards/gist.d.ts.map +1 -1
  29. package/build/cards/gist.js +27 -36
  30. package/build/cards/options.d.ts +1 -1
  31. package/build/cards/repo.d.ts +2 -4
  32. package/build/cards/repo.d.ts.map +1 -1
  33. package/build/cards/repo.js +61 -93
  34. package/build/cards/stats.d.ts +3 -8
  35. package/build/cards/stats.d.ts.map +1 -1
  36. package/build/cards/stats.js +119 -165
  37. package/build/cards/top-languages.d.ts +5 -31
  38. package/build/cards/top-languages.d.ts.map +1 -1
  39. package/build/cards/top-languages.js +176 -384
  40. package/build/cards/wakatime.d.ts +4 -6
  41. package/build/cards/wakatime.d.ts.map +1 -1
  42. package/build/cards/wakatime.js +118 -185
  43. package/build/common/Card.d.ts +14 -62
  44. package/build/common/Card.d.ts.map +1 -1
  45. package/build/common/Card.js +97 -199
  46. package/build/common/I18n.d.ts +0 -6
  47. package/build/common/I18n.d.ts.map +1 -1
  48. package/build/common/I18n.js +3 -6
  49. package/build/common/color.d.ts +4 -17
  50. package/build/common/color.d.ts.map +1 -1
  51. package/build/common/color.js +67 -49
  52. package/build/common/config.d.ts +4 -14
  53. package/build/common/config.d.ts.map +1 -1
  54. package/build/common/config.js +3 -16
  55. package/build/common/constants.d.ts +4 -2
  56. package/build/common/constants.d.ts.map +1 -1
  57. package/build/common/constants.js +3 -1
  58. package/build/common/date.d.ts +0 -2
  59. package/build/common/date.d.ts.map +1 -1
  60. package/build/common/date.js +0 -2
  61. package/build/common/emojiMap.d.ts +8 -0
  62. package/build/common/emojiMap.d.ts.map +1 -0
  63. package/build/common/emojiMap.js +10 -0
  64. package/build/common/emojiMap.json +1915 -0
  65. package/build/common/error.d.ts +1 -10
  66. package/build/common/error.d.ts.map +1 -1
  67. package/build/common/error.js +1 -10
  68. package/build/common/fmt.d.ts +3 -15
  69. package/build/common/fmt.d.ts.map +1 -1
  70. package/build/common/fmt.js +7 -35
  71. package/build/common/http.d.ts +2 -7
  72. package/build/common/http.d.ts.map +1 -1
  73. package/build/common/http.js +8 -17
  74. package/build/common/icons.d.ts +18 -20
  75. package/build/common/icons.d.ts.map +1 -1
  76. package/build/common/icons.js +103 -67
  77. package/build/common/languageColors.d.ts +0 -1
  78. package/build/common/languageColors.d.ts.map +1 -1
  79. package/build/common/languageColors.js +1 -4
  80. package/build/common/languageColors.json +18 -2
  81. package/build/common/ops.d.ts +3 -14
  82. package/build/common/ops.d.ts.map +1 -1
  83. package/build/common/ops.js +19 -30
  84. package/build/common/render.d.ts +28 -82
  85. package/build/common/render.d.ts.map +1 -1
  86. package/build/common/render.js +175 -211
  87. package/build/common/retryer.d.ts +2 -7
  88. package/build/common/retryer.d.ts.map +1 -1
  89. package/build/common/retryer.js +4 -11
  90. package/build/fetchers/gist.d.ts +2 -5
  91. package/build/fetchers/gist.d.ts.map +1 -1
  92. package/build/fetchers/gist.js +1 -5
  93. package/build/fetchers/index.d.ts +12 -12
  94. package/build/fetchers/repo.d.ts +2 -11
  95. package/build/fetchers/repo.d.ts.map +1 -1
  96. package/build/fetchers/repo.js +20 -33
  97. package/build/fetchers/stats.d.ts +2 -32
  98. package/build/fetchers/stats.d.ts.map +1 -1
  99. package/build/fetchers/stats.js +27 -86
  100. package/build/fetchers/top-languages.d.ts +2 -9
  101. package/build/fetchers/top-languages.d.ts.map +1 -1
  102. package/build/fetchers/top-languages.js +15 -31
  103. package/build/fetchers/types.d.ts +1 -1
  104. package/build/fetchers/wakatime.d.ts +2 -6
  105. package/build/fetchers/wakatime.d.ts.map +1 -1
  106. package/build/fetchers/wakatime.js +1 -5
  107. package/build/graphql/contributionsDocument.d.ts +3 -3
  108. package/build/graphql/contributionsDocument.d.ts.map +1 -1
  109. package/build/graphql/contributionsDocument.js +0 -1
  110. package/build/graphql/generated/gist.d.ts +1 -1
  111. package/build/graphql/generated/repo.d.ts +1 -1
  112. package/build/graphql/generated/stats.d.ts +3 -3
  113. package/build/graphql/generated/top-languages.d.ts +2 -2
  114. package/build/graphql/graphqlDocument.d.ts +0 -1
  115. package/build/graphql/graphqlDocument.d.ts.map +1 -1
  116. package/build/graphql/graphqlDocument.js +0 -1
  117. package/build/graphql/reposContributedToDocument.d.ts +4 -5
  118. package/build/graphql/reposContributedToDocument.d.ts.map +1 -1
  119. package/build/graphql/reposContributedToDocument.js +0 -2
  120. package/build/markup/css.d.ts +35 -0
  121. package/build/markup/css.d.ts.map +1 -0
  122. package/build/markup/css.js +64 -0
  123. package/build/markup/element.d.ts +41 -0
  124. package/build/markup/element.d.ts.map +1 -0
  125. package/build/markup/element.js +127 -0
  126. package/build/markup/html.d.ts +13 -0
  127. package/build/markup/html.d.ts.map +1 -0
  128. package/build/markup/html.js +27 -0
  129. package/build/markup/index.d.ts +9 -0
  130. package/build/markup/index.d.ts.map +1 -0
  131. package/build/markup/index.js +6 -0
  132. package/build/markup/serialize.d.ts +16 -0
  133. package/build/markup/serialize.d.ts.map +1 -0
  134. package/build/markup/serialize.js +17 -0
  135. package/build/themes/index.d.ts +332 -333
  136. package/build/themes/index.d.ts.map +1 -1
  137. package/build/themes/index.js +1 -1
  138. package/build/translations.d.ts +2 -6
  139. package/build/translations.d.ts.map +1 -1
  140. package/build/translations.js +621 -628
  141. package/package.json +17 -26
  142. package/src/api/api-result.ts +10 -9
  143. package/src/api/gist.ts +11 -18
  144. package/src/api/index.ts +12 -12
  145. package/src/api/params.ts +27 -21
  146. package/src/api/pin.ts +13 -28
  147. package/src/api/stats.ts +13 -39
  148. package/src/api/top-langs.ts +13 -33
  149. package/src/api/wakatime.ts +11 -28
  150. package/src/calculateRank.ts +12 -23
  151. package/src/cards/gist.ts +40 -43
  152. package/src/cards/options.ts +1 -1
  153. package/src/cards/repo.ts +97 -107
  154. package/src/cards/stats.ts +165 -184
  155. package/src/cards/top-languages.ts +297 -413
  156. package/src/cards/wakatime.ts +193 -221
  157. package/src/common/Card.ts +165 -217
  158. package/src/common/I18n.ts +3 -6
  159. package/src/common/color.ts +80 -57
  160. package/src/common/config.ts +5 -18
  161. package/src/common/constants.ts +5 -2
  162. package/src/common/date.ts +0 -2
  163. package/src/common/emojiMap.json +1915 -0
  164. package/src/common/emojiMap.ts +13 -0
  165. package/src/common/error.ts +2 -11
  166. package/src/common/fmt.ts +7 -44
  167. package/src/common/http.ts +9 -15
  168. package/src/common/icons.ts +117 -42
  169. package/src/common/languageColors.json +18 -2
  170. package/src/common/languageColors.ts +1 -4
  171. package/src/common/ops.ts +26 -34
  172. package/src/common/render.ts +279 -232
  173. package/src/common/retryer.ts +8 -15
  174. package/src/fetchers/gist.ts +8 -12
  175. package/src/fetchers/index.ts +12 -12
  176. package/src/fetchers/repo.ts +27 -40
  177. package/src/fetchers/stats.ts +44 -102
  178. package/src/fetchers/top-languages.ts +26 -40
  179. package/src/fetchers/types.ts +1 -1
  180. package/src/fetchers/wakatime.ts +5 -9
  181. package/src/graphql/contributionsDocument.ts +7 -5
  182. package/src/graphql/generated/gist.ts +1 -1
  183. package/src/graphql/generated/repo.ts +1 -1
  184. package/src/graphql/generated/stats.ts +2 -2
  185. package/src/graphql/generated/top-languages.ts +2 -2
  186. package/src/graphql/graphqlDocument.ts +0 -1
  187. package/src/graphql/reposContributedToDocument.ts +6 -7
  188. package/src/markup/css.ts +118 -0
  189. package/src/markup/element.ts +246 -0
  190. package/src/markup/html.ts +34 -0
  191. package/src/markup/index.ts +9 -0
  192. package/src/markup/serialize.ts +27 -0
  193. package/src/themes/index.ts +1 -1
  194. package/src/translations.ts +622 -629
  195. package/build/cards/index.d.ts +0 -11
  196. package/build/cards/index.d.ts.map +0 -1
  197. package/build/cards/index.js +0 -7
  198. package/build/common/html.d.ts +0 -8
  199. package/build/common/html.d.ts.map +0 -1
  200. package/build/common/html.js +0 -14
  201. package/build/index.d.ts +0 -15
  202. package/build/index.d.ts.map +0 -1
  203. package/build/index.js +0 -10
  204. package/src/_emoji-name-map.d.ts +0 -10
  205. package/src/_github-username-regex.d.ts +0 -4
  206. package/src/cards/index.ts +0 -21
  207. package/src/common/html.ts +0 -17
  208. package/src/index.ts +0 -18
@@ -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, safeParam, } from './params.js';
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: safeParam,
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 (err) {
37
+ catch (error) {
58
38
  // A rejected color cannot be used to draw its own error card.
59
- return errorResult(err);
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 (err) {
91
- return errorResult(err, colors);
70
+ catch (error) {
71
+ return errorResult(error, colors);
92
72
  }
93
73
  };
94
74
  /**
@@ -1,7 +1,7 @@
1
1
  import * as z from 'zod/mini';
2
- import type { CardConfig } from '../common/config.js';
3
- import type { ApiResult } from './api-result.js';
4
- import type { ApiQuery } from './params.js';
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<"time" | "percent" | undefined, string | undefined, z.core.$ZodTypeInternals<"time" | "percent" | undefined, string | undefined>>;
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: ((query: WakatimeApiQuery, config: CardConfig) => Promise<ApiResult>) & {
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;AAgFvD;;;GAGG;AACH,eAAO,MAAM,QAAQ,WA1DgB,gBAAgB,UAAU,UAAU,KAAG,OAAO,CAAC,SAAS,CAAC;;;CA6D5F,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"}
@@ -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 (err) {
36
+ catch (error) {
54
37
  // A rejected color cannot be used to draw its own error card.
55
- return errorResult(err);
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 (err) {
81
- return errorResult(err, colors);
63
+ catch (error) {
64
+ return errorResult(error, colors);
82
65
  }
83
66
  };
84
67
  /**
@@ -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":"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,CAoCxC;AAED,OAAO,EAAE,aAAa,EAAE,CAAC"}
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"}
@@ -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, COMMITS_WEIGHT = 2;
36
- const PRS_MEDIAN = 50, PRS_WEIGHT = 3;
37
- const ISSUES_MEDIAN = 25, ISSUES_WEIGHT = 1;
38
- const REVIEWS_MEDIAN = 2, REVIEWS_WEIGHT = 1;
39
- const STARS_MEDIAN = 50, STARS_WEIGHT = 4;
40
- const FOLLOWERS_MEDIAN = 10, FOLLOWERS_WEIGHT = 1;
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'];
@@ -1,5 +1,5 @@
1
- import type { GistData } from '../fetchers/types.js';
2
- import type { CardOptions, CommonCardOptions } from './options.js';
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;AAErD,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;;;;;;GAMG;AACH,QAAA,MAAM,cAAc,GAAI,UAAU,QAAQ,EAAE,UAAS,WAAW,CAAC,eAAe,CAAM,KAAG,MA6HxF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,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"}
@@ -1,11 +1,11 @@
1
- import { default as Card } from '../common/Card.js';
1
+ import { Card } from '../common/Card.js';
2
2
  import { getLightDarkColors } from '../common/color.js';
3
- import { kFormatter, wrapTextMultiline } from '../common/fmt.js';
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
- }).join('');
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
- .description {
89
- font: 400 ${DESCRIPTION_FONT_SIZE}px 'Segoe UI', Ubuntu, Sans-Serif;fill: ${textColor};
90
- ${browser_rendering ? wrappedTextStyles(textColor) : ''}
91
- }
92
- .gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
93
- .icon { fill: ${iconColor} }
94
- `,
95
- dark: ({ textColor, iconColor }) => `
96
- .description {
97
- fill: ${textColor};
98
- ${browser_rendering ? wrappedTextStyles(textColor) : ''}
99
- }
100
- .gray { fill: ${textColor} }
101
- .icon { fill: ${iconColor} }
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
- ${descriptionSvg}
113
-
114
- <g transform="translate(30, ${height - 75})">
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 };
@@ -1,4 +1,4 @@
1
- import type { ColorParams } from '../common/color.js';
1
+ import type { ColorParams } from '../common/color.ts';
2
2
  /**
3
3
  * Options every card accepts.
4
4
  * Cards spread these into `getLightDarkColors`, hence {@link ColorParams}.
@@ -1,5 +1,5 @@
1
- import type { RepositoryData } from '../fetchers/types.js';
2
- import type { CardOptions, CommonCardOptions } from './options.js';
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;AAG3D,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;AAsCD;;;;;;GAMG;AACH,QAAA,MAAM,cAAc,GAClB,MAAM,cAAc,EACpB,UAAS,WAAW,CAAC,eAAe,CAAM,KACzC,MA4RF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,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"}
@@ -1,11 +1,11 @@
1
1
  import { Card } from '../common/Card.js';
2
2
  import { getLightDarkColors } from '../common/color.js';
3
- import { kFormatter, wrapTextMultiline } from '../common/fmt.js';
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 Error(`Invalid xOffset: "${xOffset}"`);
23
+ throw new TypeError(`Invalid xOffset: "${xOffset}"`);
26
24
  }
27
- return `
28
- <g data-testid="badge" class="badge" transform="translate(${320 + xOffset}, -18)">
29
- <rect stroke-width="1" width="70" height="20" x="-12" y="-14" ry="10" rx="10"></rect>
30
- <text
31
- x="23" y="-5"
32
- alignment-baseline="central"
33
- dominant-baseline="central"
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 = (primaryLanguage && primaryLanguage.name) || 'Unspecified';
128
- const langColor = (primaryLanguage && primaryLanguage.color) || '#333';
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
- }).join('');
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
- }).join(''));
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
- .description {
217
- font: 400 ${DESCRIPTION_FONT_SIZE}px 'Segoe UI', Ubuntu, Sans-Serif;fill: ${textColor};
218
- ${browser_rendering ? wrappedTextStyles(textColor) : ''}
219
- }
220
- .gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
221
- .badge { font: 600 11px 'Segoe UI', Ubuntu, Sans-Serif; }
222
- .badge rect { opacity: 0.2; stroke: ${textColor} }
223
- .badge text { fill: ${textColor} }
224
-
225
- .stat { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
226
- .stagger {
227
- opacity: 0;
228
- animation: fadeInAnimation 0.3s ease-in-out forwards;
229
- }
230
- .not_bold { font-weight: 400 }
231
- .bold { font-weight: 700 }
232
- .icon {
233
- fill: ${iconColor};
234
- display: block;
235
- }
236
- `,
237
- dark: ({ textColor, iconColor }) => `
238
- .description {
239
- fill: ${textColor};
240
- ${browser_rendering ? wrappedTextStyles(textColor) : ''}
241
- }
242
- .gray { fill: ${textColor} }
243
- .badge rect { stroke: ${textColor} }
244
- .badge text { fill: ${textColor} }
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
- ${isTemplate
263
- ? getBadgeSVG(i18n.t('repocard.template'), card_width - CARD_DEFAULT_WIDTH)
264
- : isArchived
265
- ? getBadgeSVG(i18n.t('repocard.archived'), card_width - CARD_DEFAULT_WIDTH)
266
- : ''}
267
-
268
- ${descriptionSvg}
269
-
270
- <g transform="translate(30, ${height - 75 - extraHeight})">
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 };
@@ -1,7 +1,7 @@
1
- import type { StatsData } from '../fetchers/types.js';
2
- import type { CardOptions, CommonCardOptions } from './options.js';
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 ["default", "github", "percentile"];
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;