@stats-organization/github-readme-stats-core 2.1.4 → 2.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (182) hide show
  1. package/build/api/gist.d.ts +2 -7
  2. package/build/api/gist.d.ts.map +1 -1
  3. package/build/api/gist.js +28 -26
  4. package/build/api/index.d.ts +3 -8
  5. package/build/api/index.d.ts.map +1 -1
  6. package/build/api/index.js +32 -36
  7. package/build/api/pin.d.ts +2 -7
  8. package/build/api/pin.d.ts.map +1 -1
  9. package/build/api/pin.js +18 -33
  10. package/build/api/top-langs.d.ts +2 -7
  11. package/build/api/top-langs.d.ts.map +1 -1
  12. package/build/api/top-langs.js +32 -44
  13. package/build/api/wakatime.d.ts +2 -7
  14. package/build/api/wakatime.d.ts.map +1 -1
  15. package/build/api/wakatime.js +28 -26
  16. package/build/calculateRank.d.ts +12 -11
  17. package/build/calculateRank.d.ts.map +1 -1
  18. package/build/calculateRank.js +18 -18
  19. package/build/cards/common-options.d.ts +13 -0
  20. package/build/cards/common-options.d.ts.map +1 -0
  21. package/build/cards/common-options.js +1 -0
  22. package/build/cards/gist.d.ts +11 -16
  23. package/build/cards/gist.d.ts.map +1 -1
  24. package/build/cards/gist.js +26 -31
  25. package/build/cards/repo.d.ts +19 -16
  26. package/build/cards/repo.d.ts.map +1 -1
  27. package/build/cards/repo.js +79 -72
  28. package/build/cards/stats.d.ts +29 -44
  29. package/build/cards/stats.d.ts.map +1 -1
  30. package/build/cards/stats.js +118 -173
  31. package/build/cards/top-languages.d.ts +81 -77
  32. package/build/cards/top-languages.d.ts.map +1 -1
  33. package/build/cards/top-languages.js +186 -184
  34. package/build/cards/wakatime.d.ts +21 -11
  35. package/build/cards/wakatime.d.ts.map +1 -1
  36. package/build/cards/wakatime.js +92 -109
  37. package/build/common/Card.d.ts +41 -14
  38. package/build/common/Card.d.ts.map +1 -1
  39. package/build/common/Card.js +92 -31
  40. package/build/common/I18n.d.ts +4 -2
  41. package/build/common/I18n.d.ts.map +1 -1
  42. package/build/common/color.d.ts +91 -15
  43. package/build/common/color.d.ts.map +1 -1
  44. package/build/common/color.js +163 -17
  45. package/build/common/config.d.ts +2 -1
  46. package/build/common/config.d.ts.map +1 -1
  47. package/build/common/config.js +16 -26
  48. package/build/common/constants.d.ts +2 -1
  49. package/build/common/constants.d.ts.map +1 -1
  50. package/build/common/date.d.ts +37 -0
  51. package/build/common/date.d.ts.map +1 -0
  52. package/build/common/date.js +31 -0
  53. package/build/common/html.js +1 -1
  54. package/build/common/http.d.ts +37 -5
  55. package/build/common/http.d.ts.map +1 -1
  56. package/build/common/http.js +29 -6
  57. package/build/common/icons.d.ts +1 -0
  58. package/build/common/icons.d.ts.map +1 -1
  59. package/build/common/icons.js +1 -0
  60. package/build/common/languageColors.d.ts +11 -0
  61. package/build/common/languageColors.d.ts.map +1 -0
  62. package/build/common/languageColors.js +15 -0
  63. package/build/common/languageColors.json +10 -1
  64. package/build/common/ops.d.ts +27 -33
  65. package/build/common/ops.d.ts.map +1 -1
  66. package/build/common/ops.js +31 -48
  67. package/build/common/render.d.ts +154 -113
  68. package/build/common/render.d.ts.map +1 -1
  69. package/build/common/render.js +209 -92
  70. package/build/common/retryer.d.ts +15 -6
  71. package/build/common/retryer.d.ts.map +1 -1
  72. package/build/common/retryer.js +2 -0
  73. package/build/fetchers/gist.d.ts +6 -21
  74. package/build/fetchers/gist.d.ts.map +1 -1
  75. package/build/fetchers/gist.js +28 -64
  76. package/build/fetchers/repo.d.ts +12 -11
  77. package/build/fetchers/repo.d.ts.map +1 -1
  78. package/build/fetchers/repo.js +27 -68
  79. package/build/fetchers/stats.d.ts +24 -17
  80. package/build/fetchers/stats.d.ts.map +1 -1
  81. package/build/fetchers/stats.js +302 -184
  82. package/build/fetchers/top-languages.d.ts +10 -15
  83. package/build/fetchers/top-languages.d.ts.map +1 -1
  84. package/build/fetchers/top-languages.js +52 -103
  85. package/build/fetchers/types.d.ts +130 -0
  86. package/build/fetchers/types.d.ts.map +1 -0
  87. package/build/fetchers/types.js +1 -0
  88. package/build/fetchers/wakatime.d.ts +9 -5
  89. package/build/fetchers/wakatime.d.ts.map +1 -1
  90. package/build/fetchers/wakatime.js +8 -4
  91. package/build/graphql/contributionsDocument.d.ts +18 -0
  92. package/build/graphql/contributionsDocument.d.ts.map +1 -0
  93. package/build/graphql/contributionsDocument.js +30 -0
  94. package/build/graphql/generated/common.d.ts +42 -0
  95. package/build/graphql/generated/common.d.ts.map +1 -0
  96. package/build/graphql/generated/common.js +2 -0
  97. package/build/graphql/generated/gist.d.ts +44 -0
  98. package/build/graphql/generated/gist.d.ts.map +1 -0
  99. package/build/graphql/generated/gist.js +27 -0
  100. package/build/graphql/generated/repo.d.ts +67 -0
  101. package/build/graphql/generated/repo.d.ts.map +1 -0
  102. package/build/graphql/generated/repo.js +30 -0
  103. package/build/graphql/generated/stats.d.ts +150 -0
  104. package/build/graphql/generated/stats.d.ts.map +1 -0
  105. package/build/graphql/generated/stats.js +95 -0
  106. package/build/graphql/generated/top-languages.d.ts +54 -0
  107. package/build/graphql/generated/top-languages.d.ts.map +1 -0
  108. package/build/graphql/generated/top-languages.js +27 -0
  109. package/build/graphql/graphqlDocument.d.ts +22 -0
  110. package/build/graphql/graphqlDocument.d.ts.map +1 -0
  111. package/build/graphql/graphqlDocument.js +8 -0
  112. package/build/graphql/reposContributedToDocument.d.ts +27 -0
  113. package/build/graphql/reposContributedToDocument.d.ts.map +1 -0
  114. package/build/graphql/reposContributedToDocument.js +59 -0
  115. package/build/index.d.ts +3 -1
  116. package/build/index.d.ts.map +1 -1
  117. package/build/index.js +2 -1
  118. package/build/themes/index.d.ts +32 -0
  119. package/build/themes/index.d.ts.map +1 -1
  120. package/build/themes/index.js +28 -0
  121. package/build/translations.d.ts +17 -0
  122. package/build/translations.d.ts.map +1 -1
  123. package/build/translations.js +17 -0
  124. package/package.json +14 -8
  125. package/src/_emoji-name-map.d.ts +10 -0
  126. package/src/_github-username-regex.d.ts +4 -0
  127. package/src/api/gist.js +31 -31
  128. package/src/api/index.js +40 -42
  129. package/src/api/pin.js +20 -38
  130. package/src/api/top-langs.js +36 -49
  131. package/src/api/wakatime.js +31 -31
  132. package/src/{calculateRank.js → calculateRank.ts} +29 -19
  133. package/src/cards/common-options.ts +13 -0
  134. package/src/cards/{gist.js → gist.ts} +37 -37
  135. package/src/cards/{repo.js → repo.ts} +107 -79
  136. package/src/cards/{stats.js → stats.ts} +173 -210
  137. package/src/cards/{top-languages.js → top-languages.ts} +325 -243
  138. package/src/cards/{wakatime.js → wakatime.ts} +158 -127
  139. package/src/common/Card.ts +123 -43
  140. package/src/common/I18n.ts +6 -2
  141. package/src/common/color.ts +240 -28
  142. package/src/common/config.ts +22 -29
  143. package/src/common/constants.ts +3 -1
  144. package/src/common/date.ts +45 -0
  145. package/src/common/html.ts +1 -1
  146. package/src/common/http.ts +71 -0
  147. package/src/common/icons.ts +1 -0
  148. package/src/common/languageColors.json +10 -1
  149. package/src/common/languageColors.ts +19 -0
  150. package/src/common/ops.ts +158 -0
  151. package/src/common/render.ts +652 -0
  152. package/src/common/retryer.ts +21 -12
  153. package/src/fetchers/gist.ts +79 -0
  154. package/src/fetchers/repo.ts +114 -0
  155. package/src/fetchers/stats.ts +743 -0
  156. package/src/fetchers/top-languages.ts +135 -0
  157. package/src/fetchers/{types.d.ts → types.ts} +28 -20
  158. package/src/fetchers/{wakatime.js → wakatime.ts} +19 -5
  159. package/src/graphql/contributionsDocument.ts +44 -0
  160. package/src/graphql/generated/common.ts +26 -0
  161. package/src/graphql/generated/gist.ts +59 -0
  162. package/src/graphql/generated/repo.ts +90 -0
  163. package/src/graphql/generated/stats.ts +194 -0
  164. package/src/graphql/generated/top-languages.ts +75 -0
  165. package/src/graphql/graphqlDocument.ts +25 -0
  166. package/src/graphql/queries/gist.graphql +25 -0
  167. package/src/graphql/queries/repo.graphql +28 -0
  168. package/src/graphql/queries/stats.graphql +120 -0
  169. package/src/graphql/queries/top-languages.graphql +34 -0
  170. package/src/graphql/reposContributedToDocument.ts +86 -0
  171. package/src/index.ts +3 -1
  172. package/src/themes/index.ts +33 -0
  173. package/src/translations.ts +17 -0
  174. package/src/cards/types.d.ts +0 -78
  175. package/src/common/http.js +0 -19
  176. package/src/common/ops.js +0 -170
  177. package/src/common/render.js +0 -440
  178. package/src/fetchers/gist.js +0 -112
  179. package/src/fetchers/repo.js +0 -161
  180. package/src/fetchers/stats.js +0 -474
  181. package/src/fetchers/top-languages.js +0 -175
  182. package/src/themes/README.md +0 -229
@@ -1,13 +1,12 @@
1
1
  import { Card } from "../common/Card.js";
2
2
  import { I18n } from "../common/I18n.js";
3
- import { getCardColors } from "../common/color.js";
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,38 +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 {string} label The repository description.
21
- * @param {string} textColor The color of the text.
22
- * @returns {string} Wrapped repo description SVG object.
23
- */
24
- const getBadgeSVG = (label, textColor, xOffset = 0) => `
25
- <g data-testid="badge" class="badge" transform="translate(${320 + xOffset}, -18)">
26
- <rect stroke="${textColor}" stroke-width="1" width="70" height="20" x="-12" y="-14" ry="10" rx="10"></rect>
27
- <text
28
- x="23" y="-5"
29
- alignment-baseline="central"
30
- dominant-baseline="central"
31
- text-anchor="middle"
32
- fill="${textColor}"
33
- >
34
- ${label}
35
- </text>
36
- </g>
37
- `;
38
- /**
39
- * @typedef {import("../fetchers/types").RepositoryData} RepositoryData Repository data.
40
- * @typedef {import("./types").RepoCardOptions} RepoCardOptions Repo card options.
19
+ * @param label The repository description.
20
+ * @param xOffset Horizontal offset of the badge.
21
+ * @returns Wrapped repo description SVG object.
41
22
  */
23
+ const getBadgeSVG = (label, xOffset = 0) => {
24
+ if (!Number.isFinite(xOffset)) {
25
+ throw new Error(`Invalid xOffset: "${xOffset}"`);
26
+ }
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
+ `;
40
+ };
42
41
  /**
43
42
  * Renders repository card details.
44
43
  *
45
- * @param {RepositoryData} repo Repository data.
46
- * @param {Partial<RepoCardOptions>} options Card options.
47
- * @returns {string} Repository card SVG object.
44
+ * @param repo Repository data.
45
+ * @param options Card options.
46
+ * @returns Repository card SVG object.
48
47
  */
49
48
  const renderRepoCard = (repo, options = {}) => {
50
- const { name, nameWithOwner, description, primaryLanguage, isArchived, isTemplate, starCount, forkCount, totalPRsAuthored, totalPRsCommented, totalPRsReviewed, totalIssuesAuthored, totalIssuesCommented, } = repo;
51
- const { hide_border = false, title_color, icon_color, text_color, bg_color, 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, border_color, locale, description_lines_count, } = options;
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;
52
51
  const card_width = card_width_input && !isNaN(card_width_input)
53
52
  ? card_width_input
54
53
  : show.length >= 2
@@ -58,67 +57,68 @@ const renderRepoCard = (repo, options = {}) => {
58
57
  locale,
59
58
  translations: repoCardLocales,
60
59
  });
61
- let repoFilter = encodeURIComponent(buildSearchFilter([nameWithOwner], []));
60
+ const repoFilter = encodeURIComponent(buildSearchFilter([nameWithOwner], []));
61
+ const encodedUsername = encodeURIComponent(username ?? "");
62
62
  const STATS = {};
63
63
  if (show.includes("prs_authored")) {
64
- STATS.prs_authored = {
64
+ STATS["prs_authored"] = {
65
65
  icon: icons.prs,
66
66
  label: i18n.t("repocard.prs-authored"),
67
67
  value: totalPRsAuthored,
68
68
  id: "prs_authored",
69
- link: `https://github.com/search?q=${repoFilter}author%3A${username}&amp;type=pullrequests`,
69
+ link: `https://github.com/search?q=${repoFilter}author%3A${encodedUsername}&amp;type=pullrequests`,
70
70
  };
71
71
  }
72
72
  if (show.includes("prs_commented")) {
73
- STATS.prs_commented = {
73
+ STATS["prs_commented"] = {
74
74
  icon: icons.comments,
75
75
  label: i18n.t("repocard.prs-commented"),
76
76
  value: totalPRsCommented,
77
77
  id: "prs_commented",
78
- link: `https://github.com/search?q=${repoFilter}commenter%3A${username}+-author%3A${username}&amp;type=pullrequests`,
78
+ link: `https://github.com/search?q=${repoFilter}commenter%3A${encodedUsername}+-author%3A${encodedUsername}&amp;type=pullrequests`,
79
79
  };
80
80
  }
81
81
  if (show.includes("prs_reviewed")) {
82
- STATS.prs_reviewed = {
82
+ STATS["prs_reviewed"] = {
83
83
  icon: icons.reviews,
84
84
  label: i18n.t("repocard.prs-reviewed"),
85
85
  value: totalPRsReviewed,
86
86
  id: "prs_reviewed",
87
- link: `https://github.com/search?q=${repoFilter}reviewed-by%3A${username}+-author%3A${username}&amp;type=pullrequests`,
87
+ link: `https://github.com/search?q=${repoFilter}reviewed-by%3A${encodedUsername}+-author%3A${encodedUsername}&amp;type=pullrequests`,
88
88
  };
89
89
  }
90
90
  if (show.includes("issues_authored")) {
91
- STATS.issues_authored = {
91
+ STATS["issues_authored"] = {
92
92
  icon: icons.issues,
93
93
  label: i18n.t("repocard.issues-authored"),
94
94
  value: totalIssuesAuthored,
95
95
  id: "issues_authored",
96
- link: `https://github.com/search?q=${repoFilter}author%3A${username}&amp;type=issues`,
96
+ link: `https://github.com/search?q=${repoFilter}author%3A${encodedUsername}&amp;type=issues`,
97
97
  };
98
98
  }
99
99
  if (show.includes("issues_commented")) {
100
- STATS.issues_commented = {
100
+ STATS["issues_commented"] = {
101
101
  icon: icons.discussions_started,
102
102
  label: i18n.t("repocard.issues-commented"),
103
103
  value: totalIssuesCommented,
104
104
  id: "issues_commented",
105
- link: `https://github.com/search?q=${repoFilter}commenter%3A${username}+-author%3A${username}&amp;type=issues`,
105
+ link: `https://github.com/search?q=${repoFilter}commenter%3A${encodedUsername}+-author%3A${encodedUsername}&amp;type=issues`,
106
106
  };
107
107
  }
108
- const statItems = Object.keys(STATS).map((key, index) =>
108
+ const statItems = Object.values(STATS).map((stat, index) =>
109
109
  // create the text nodes, and pass index so that we can calculate the line spacing
110
110
  createTextNode({
111
- icon: STATS[key].icon,
112
- label: STATS[key].label,
113
- value: STATS[key].value,
114
- id: STATS[key].id,
115
- unitSymbol: STATS[key].unitSymbol,
111
+ icon: stat.icon,
112
+ label: stat.label,
113
+ value: stat.value ?? 0,
114
+ id: stat.id,
115
+ unitSymbol: stat.unitSymbol,
116
116
  index,
117
117
  showIcons: show_icons,
118
118
  shiftValuePos: 14.01,
119
119
  bold: text_bold,
120
120
  numberFormat: number_format,
121
- link: STATS[key].link,
121
+ link: stat.link,
122
122
  labelXOffset: 23,
123
123
  }));
124
124
  const extraLHeight = parseInt(String(line_height), 10);
@@ -128,7 +128,8 @@ const renderRepoCard = (repo, options = {}) => {
128
128
  const langColor = (primaryLanguage && primaryLanguage.color) || "#333";
129
129
  const desc = parseEmojis(description || "No description provided");
130
130
  const descriptionBoxWidth = card_width - 2 * X_OFFSET;
131
- let descriptionLinesCount, descriptionSvg;
131
+ let descriptionLinesCount;
132
+ let descriptionSvg;
132
133
  if (browser_rendering) {
133
134
  // The browser performs the actual text wrapping inside the foreignObject;
134
135
  // we only estimate the line count server-side so the SVG can reserve enough
@@ -169,19 +170,11 @@ const renderRepoCard = (repo, options = {}) => {
169
170
  const height = (descriptionLinesCount > 1 ? 120 : 110) +
170
171
  descriptionLinesCount * lineHeight +
171
172
  extraHeight;
172
- // returns theme based colors with proper overrides and defaults
173
- const colors = getCardColors({
174
- title_color,
175
- icon_color,
176
- text_color,
177
- bg_color,
178
- border_color,
179
- theme,
180
- });
173
+ const { lightColors, darkColors } = getLightDarkColors({ ...options, theme });
181
174
  const svgLanguage = primaryLanguage
182
175
  ? createLanguageNode(langName, langColor)
183
176
  : "";
184
- const totalStars = kFormatter(starCount);
177
+ const totalStars = kFormatter(stargazerCount);
185
178
  const totalForks = kFormatter(forkCount);
186
179
  const svgStars = iconWithLabel(icons.star, totalStars, "stargazers", ICON_SIZE);
187
180
  const svgForks = iconWithLabel(icons.fork, totalForks, "forkcount", ICON_SIZE);
@@ -194,7 +187,7 @@ const renderRepoCard = (repo, options = {}) => {
194
187
  ],
195
188
  gap: 25,
196
189
  }).join("");
197
- let extraRows = [];
190
+ const extraRows = [];
198
191
  for (let i = 0; i < statItems.length; i += 2) {
199
192
  extraRows.push(flexLayout({
200
193
  items: statItems.slice(i, i + 2),
@@ -217,21 +210,23 @@ const renderRepoCard = (repo, options = {}) => {
217
210
  width: card_width,
218
211
  height,
219
212
  border_radius,
220
- colors,
213
+ colors: { light: lightColors, dark: darkColors },
221
214
  });
222
215
  card.disableAnimations();
223
216
  card.setHideBorder(hide_border);
224
217
  card.setHideTitle(false);
225
- card.setCSS(`
218
+ card.setCSS({
219
+ light: `
226
220
  .description {
227
- font: 400 ${DESCRIPTION_FONT_SIZE}px 'Segoe UI', Ubuntu, Sans-Serif;fill: ${colors.textColor};
228
- ${browser_rendering ? wrappedTextStyles(colors.textColor) : ""}
221
+ font: 400 ${DESCRIPTION_FONT_SIZE}px 'Segoe UI', Ubuntu, Sans-Serif;fill: ${lightColors.textColor};
222
+ ${browser_rendering ? wrappedTextStyles(lightColors.textColor) : ""}
229
223
  }
230
- .gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${colors.textColor} }
224
+ .gray { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${lightColors.textColor} }
231
225
  .badge { font: 600 11px 'Segoe UI', Ubuntu, Sans-Serif; }
232
- .badge rect { opacity: 0.2 }
226
+ .badge rect { opacity: 0.2; stroke: ${lightColors.textColor} }
227
+ .badge text { fill: ${lightColors.textColor} }
233
228
 
234
- .stat { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${colors.textColor} }
229
+ .stat { font: 400 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${lightColors.textColor} }
235
230
  .stagger {
236
231
  opacity: 0;
237
232
  animation: fadeInAnimation 0.3s ease-in-out forwards;
@@ -239,17 +234,29 @@ const renderRepoCard = (repo, options = {}) => {
239
234
  .not_bold { font-weight: 400 }
240
235
  .bold { font-weight: 700 }
241
236
  .icon {
242
- fill: ${colors.iconColor};
237
+ fill: ${lightColors.iconColor};
243
238
  display: block;
244
239
  }
245
- `);
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
+ });
246
255
  return card.render(`
247
256
  ${isTemplate
248
- ? // @ts-ignore
249
- getBadgeSVG(i18n.t("repocard.template"), colors.textColor, card_width - CARD_DEFAULT_WIDTH)
257
+ ? getBadgeSVG(i18n.t("repocard.template"), card_width - CARD_DEFAULT_WIDTH)
250
258
  : isArchived
251
- ? // @ts-ignore
252
- getBadgeSVG(i18n.t("repocard.archived"), colors.textColor, card_width - CARD_DEFAULT_WIDTH)
259
+ ? getBadgeSVG(i18n.t("repocard.archived"), card_width - CARD_DEFAULT_WIDTH)
253
260
  : ""}
254
261
 
255
262
  ${descriptionSvg}
@@ -1,49 +1,34 @@
1
- export type StatsData = any;
2
- export type StatCardOptions = any;
3
- /**
4
- * @typedef {import('../fetchers/types').StatsData} StatsData
5
- * @typedef {import('./types').StatCardOptions} StatCardOptions
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 {StatsData} stats The stats data.
11
- * @param {Partial<StatCardOptions>} options The card options.
12
- * @returns {string} The stats card SVG object.
13
- */
14
- export function renderStatsCard(stats: StatsData, options: Partial<StatCardOptions>, username: any, repo?: any[], owner?: any[]): string;
15
- /**
16
- * Create a stats card text item.
17
- *
18
- * @param {object} params Object that contains the createTextNode parameters.
19
- * @param {string} params.icon The icon to display.
20
- * @param {string} params.label The label to display.
21
- * @param {number} params.value The value to display.
22
- * @param {string} params.id The id of the stat.
23
- * @param {string=} params.unitSymbol The unit symbol of the stat.
24
- * @param {number} params.index The index of the stat.
25
- * @param {boolean} params.showIcons Whether to show icons.
26
- * @param {number} params.shiftValuePos Number of pixels the value has to be shifted to the right.
27
- * @param {boolean} params.bold Whether to bold the label.
28
- * @param {string} params.numberFormat The format of numbers on card.
29
- * @param {number=} params.numberPrecision The precision of numbers on card.
30
- * @param {string} params.link Url to link to.
31
- * @param {number} params.labelXOffset horizontal offset for label.
32
- * @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.
33
31
  */
34
- export function createTextNode({ icon, label, value, id, unitSymbol, index, showIcons, shiftValuePos, bold, numberFormat, numberPrecision, link, labelXOffset, }: {
35
- icon: string;
36
- label: string;
37
- value: number;
38
- id: string;
39
- unitSymbol?: string | undefined;
40
- index: number;
41
- showIcons: boolean;
42
- shiftValuePos: number;
43
- bold: boolean;
44
- numberFormat: string;
45
- numberPrecision?: number | undefined;
46
- link: string;
47
- labelXOffset: number;
48
- }): string;
32
+ declare const renderStatsCard: (stats: StatsData, options?: Partial<StatCardOptions>, username?: string, repo?: Array<string>, owner?: Array<string>) => string;
33
+ export { renderStatsCard };
49
34
  //# sourceMappingURL=stats.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/cards/stats.js"],"names":[],"mappings":";;AA4PA;;;GAGG;AAEH;;;;;;GAMG;AACH,uCAJW,SAAS,WACT,OAAO,CAAC,eAAe,CAAC,+CACtB,MAAM,CAsZlB;AAzmBD;;;;;;;;;;;;;;;;;;GAkBG;AACH,kKAfG;IAAuB,IAAI,EAAnB,MAAM;IACS,KAAK,EAApB,MAAM;IACS,KAAK,EAApB,MAAM;IACS,EAAE,EAAjB,MAAM;IACU,UAAU,GAA1B,MAAM,YAAC;IACQ,KAAK,EAApB,MAAM;IACU,SAAS,EAAzB,OAAO;IACQ,aAAa,EAA5B,MAAM;IACU,IAAI,EAApB,OAAO;IACQ,YAAY,EAA3B,MAAM;IACU,eAAe,GAA/B,MAAM,YAAC;IACQ,IAAI,EAAnB,MAAM;IACS,YAAY,EAA3B,MAAM;CACd,GAAU,MAAM,CAuDlB"}
1
+ {"version":3,"file":"stats.d.ts","sourceRoot":"","sources":["../../src/cards/stats.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,sBAAsB,CAAC;AAGtD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AASzD,KAAK,QAAQ,GAAG,SAAS,GAAG,QAAQ,GAAG,YAAY,CAAC;AAEpD,UAAU,eAAgB,SAAQ,aAAa;IAC7C,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,mBAAmB,EAAE,OAAO,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,SAAS,EAAE,QAAQ,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACrB;AAiLD;;;;;;;;;GASG;AACH,QAAA,MAAM,eAAe,GACnB,OAAO,SAAS,EAChB,UAAS,OAAO,CAAC,eAAe,CAAM,EACtC,WAAW,MAAM,EACjB,OAAM,KAAK,CAAC,MAAM,CAAM,EACxB,QAAO,KAAK,CAAC,MAAM,CAAM,KACxB,MAgZF,CAAC;AAEF,OAAO,EAAE,eAAe,EAAE,CAAC"}