@stats-forge/github-stats-forge-core 0.0.1

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 (211) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +148 -0
  3. package/build/api/api-result.d.ts +44 -0
  4. package/build/api/api-result.d.ts.map +1 -0
  5. package/build/api/api-result.js +33 -0
  6. package/build/api/gist.d.ts +29 -0
  7. package/build/api/gist.d.ts.map +1 -0
  8. package/build/api/gist.js +52 -0
  9. package/build/api/index.d.ts +13 -0
  10. package/build/api/index.d.ts.map +1 -0
  11. package/build/api/index.js +8 -0
  12. package/build/api/params.d.ts +93 -0
  13. package/build/api/params.d.ts.map +1 -0
  14. package/build/api/params.js +145 -0
  15. package/build/api/pin.d.ts +47 -0
  16. package/build/api/pin.d.ts.map +1 -0
  17. package/build/api/pin.js +87 -0
  18. package/build/api/stats.d.ts +42 -0
  19. package/build/api/stats.d.ts.map +1 -0
  20. package/build/api/stats.js +132 -0
  21. package/build/api/top-langs.d.ts +37 -0
  22. package/build/api/top-langs.d.ts.map +1 -0
  23. package/build/api/top-langs.js +101 -0
  24. package/build/api/wakatime.d.ts +34 -0
  25. package/build/api/wakatime.d.ts.map +1 -0
  26. package/build/api/wakatime.js +91 -0
  27. package/build/calculateRank.d.ts +29 -0
  28. package/build/calculateRank.d.ts.map +1 -0
  29. package/build/calculateRank.js +58 -0
  30. package/build/cards/gist.d.ts +16 -0
  31. package/build/cards/gist.d.ts.map +1 -0
  32. package/build/cards/gist.js +119 -0
  33. package/build/cards/index.d.ts +11 -0
  34. package/build/cards/index.d.ts.map +1 -0
  35. package/build/cards/index.js +7 -0
  36. package/build/cards/options.d.ts +19 -0
  37. package/build/cards/options.d.ts.map +1 -0
  38. package/build/cards/options.js +1 -0
  39. package/build/cards/repo.d.ts +25 -0
  40. package/build/cards/repo.d.ts.map +1 -0
  41. package/build/cards/repo.js +276 -0
  42. package/build/cards/stats.d.ts +37 -0
  43. package/build/cards/stats.d.ts.map +1 -0
  44. package/build/cards/stats.js +457 -0
  45. package/build/cards/top-languages.d.ts +153 -0
  46. package/build/cards/top-languages.d.ts.map +1 -0
  47. package/build/cards/top-languages.js +805 -0
  48. package/build/cards/wakatime.d.ts +31 -0
  49. package/build/cards/wakatime.d.ts.map +1 -0
  50. package/build/cards/wakatime.js +376 -0
  51. package/build/common/Card.d.ts +121 -0
  52. package/build/common/Card.d.ts.map +1 -0
  53. package/build/common/Card.js +305 -0
  54. package/build/common/I18n.d.ts +27 -0
  55. package/build/common/I18n.d.ts.map +1 -0
  56. package/build/common/I18n.js +35 -0
  57. package/build/common/color.d.ts +112 -0
  58. package/build/common/color.d.ts.map +1 -0
  59. package/build/common/color.js +188 -0
  60. package/build/common/config.d.ts +53 -0
  61. package/build/common/config.d.ts.map +1 -0
  62. package/build/common/config.js +87 -0
  63. package/build/common/constants.d.ts +7 -0
  64. package/build/common/constants.d.ts.map +1 -0
  65. package/build/common/constants.js +9 -0
  66. package/build/common/date.d.ts +29 -0
  67. package/build/common/date.d.ts.map +1 -0
  68. package/build/common/date.js +23 -0
  69. package/build/common/error.d.ts +87 -0
  70. package/build/common/error.d.ts.map +1 -0
  71. package/build/common/error.js +108 -0
  72. package/build/common/fmt.d.ts +28 -0
  73. package/build/common/fmt.d.ts.map +1 -0
  74. package/build/common/fmt.js +68 -0
  75. package/build/common/html.d.ts +8 -0
  76. package/build/common/html.d.ts.map +1 -0
  77. package/build/common/html.js +14 -0
  78. package/build/common/http.d.ts +53 -0
  79. package/build/common/http.d.ts.map +1 -0
  80. package/build/common/http.js +47 -0
  81. package/build/common/icons.d.ts +28 -0
  82. package/build/common/icons.d.ts.map +1 -0
  83. package/build/common/icons.js +77 -0
  84. package/build/common/languageColors.d.ts +11 -0
  85. package/build/common/languageColors.d.ts.map +1 -0
  86. package/build/common/languageColors.js +15 -0
  87. package/build/common/languageColors.json +678 -0
  88. package/build/common/log.d.ts +9 -0
  89. package/build/common/log.d.ts.map +1 -0
  90. package/build/common/log.js +8 -0
  91. package/build/common/ops.d.ts +59 -0
  92. package/build/common/ops.d.ts.map +1 -0
  93. package/build/common/ops.js +115 -0
  94. package/build/common/render.d.ts +196 -0
  95. package/build/common/render.d.ts.map +1 -0
  96. package/build/common/render.js +474 -0
  97. package/build/common/retryer.d.ts +36 -0
  98. package/build/common/retryer.d.ts.map +1 -0
  99. package/build/common/retryer.js +67 -0
  100. package/build/fetchers/gist.d.ts +15 -0
  101. package/build/fetchers/gist.d.ts.map +1 -0
  102. package/build/fetchers/gist.js +68 -0
  103. package/build/fetchers/index.d.ts +13 -0
  104. package/build/fetchers/index.d.ts.map +1 -0
  105. package/build/fetchers/index.js +10 -0
  106. package/build/fetchers/repo.d.ts +27 -0
  107. package/build/fetchers/repo.d.ts.map +1 -0
  108. package/build/fetchers/repo.js +100 -0
  109. package/build/fetchers/stats.d.ts +74 -0
  110. package/build/fetchers/stats.d.ts.map +1 -0
  111. package/build/fetchers/stats.js +498 -0
  112. package/build/fetchers/top-languages.d.ts +23 -0
  113. package/build/fetchers/top-languages.d.ts.map +1 -0
  114. package/build/fetchers/top-languages.js +89 -0
  115. package/build/fetchers/types.d.ts +130 -0
  116. package/build/fetchers/types.d.ts.map +1 -0
  117. package/build/fetchers/types.js +1 -0
  118. package/build/fetchers/wakatime.d.ts +19 -0
  119. package/build/fetchers/wakatime.d.ts.map +1 -0
  120. package/build/fetchers/wakatime.js +36 -0
  121. package/build/graphql/contributionsDocument.d.ts +18 -0
  122. package/build/graphql/contributionsDocument.d.ts.map +1 -0
  123. package/build/graphql/contributionsDocument.js +30 -0
  124. package/build/graphql/generated/common.d.ts +42 -0
  125. package/build/graphql/generated/common.d.ts.map +1 -0
  126. package/build/graphql/generated/common.js +2 -0
  127. package/build/graphql/generated/gist.d.ts +44 -0
  128. package/build/graphql/generated/gist.d.ts.map +1 -0
  129. package/build/graphql/generated/gist.js +27 -0
  130. package/build/graphql/generated/repo.d.ts +67 -0
  131. package/build/graphql/generated/repo.d.ts.map +1 -0
  132. package/build/graphql/generated/repo.js +30 -0
  133. package/build/graphql/generated/stats.d.ts +150 -0
  134. package/build/graphql/generated/stats.d.ts.map +1 -0
  135. package/build/graphql/generated/stats.js +95 -0
  136. package/build/graphql/generated/top-languages.d.ts +54 -0
  137. package/build/graphql/generated/top-languages.d.ts.map +1 -0
  138. package/build/graphql/generated/top-languages.js +27 -0
  139. package/build/graphql/graphqlDocument.d.ts +22 -0
  140. package/build/graphql/graphqlDocument.d.ts.map +1 -0
  141. package/build/graphql/graphqlDocument.js +8 -0
  142. package/build/graphql/reposContributedToDocument.d.ts +27 -0
  143. package/build/graphql/reposContributedToDocument.d.ts.map +1 -0
  144. package/build/graphql/reposContributedToDocument.js +59 -0
  145. package/build/index.d.ts +15 -0
  146. package/build/index.d.ts.map +1 -0
  147. package/build/index.js +10 -0
  148. package/build/themes/index.d.ts +505 -0
  149. package/build/themes/index.d.ts.map +1 -0
  150. package/build/themes/index.js +505 -0
  151. package/build/translations.d.ts +1153 -0
  152. package/build/translations.d.ts.map +1 -0
  153. package/build/translations.js +1156 -0
  154. package/package.json +114 -0
  155. package/src/_emoji-name-map.d.ts +10 -0
  156. package/src/_github-username-regex.d.ts +4 -0
  157. package/src/api/api-result.ts +69 -0
  158. package/src/api/gist.ts +66 -0
  159. package/src/api/index.ts +16 -0
  160. package/src/api/params.ts +221 -0
  161. package/src/api/pin.ts +126 -0
  162. package/src/api/stats.ts +195 -0
  163. package/src/api/top-langs.ts +150 -0
  164. package/src/api/wakatime.ts +130 -0
  165. package/src/calculateRank.ts +91 -0
  166. package/src/cards/gist.ts +169 -0
  167. package/src/cards/index.ts +21 -0
  168. package/src/cards/options.ts +18 -0
  169. package/src/cards/repo.ts +376 -0
  170. package/src/cards/stats.ts +615 -0
  171. package/src/cards/top-languages.ts +1077 -0
  172. package/src/cards/wakatime.ts +501 -0
  173. package/src/common/Card.ts +364 -0
  174. package/src/common/I18n.ts +51 -0
  175. package/src/common/color.ts +296 -0
  176. package/src/common/config.ts +118 -0
  177. package/src/common/constants.ts +12 -0
  178. package/src/common/date.ts +34 -0
  179. package/src/common/error.ts +163 -0
  180. package/src/common/fmt.ts +86 -0
  181. package/src/common/html.ts +17 -0
  182. package/src/common/http.ts +98 -0
  183. package/src/common/icons.ts +80 -0
  184. package/src/common/languageColors.json +678 -0
  185. package/src/common/languageColors.ts +19 -0
  186. package/src/common/log.ts +12 -0
  187. package/src/common/ops.ts +145 -0
  188. package/src/common/render.ts +641 -0
  189. package/src/common/retryer.ts +111 -0
  190. package/src/fetchers/gist.ts +82 -0
  191. package/src/fetchers/index.ts +25 -0
  192. package/src/fetchers/repo.ts +140 -0
  193. package/src/fetchers/stats.ts +742 -0
  194. package/src/fetchers/top-languages.ts +134 -0
  195. package/src/fetchers/types.ts +136 -0
  196. package/src/fetchers/wakatime.ts +56 -0
  197. package/src/graphql/contributionsDocument.ts +44 -0
  198. package/src/graphql/generated/common.ts +26 -0
  199. package/src/graphql/generated/gist.ts +56 -0
  200. package/src/graphql/generated/repo.ts +79 -0
  201. package/src/graphql/generated/stats.ts +180 -0
  202. package/src/graphql/generated/top-languages.ts +66 -0
  203. package/src/graphql/graphqlDocument.ts +25 -0
  204. package/src/graphql/queries/gist.graphql +25 -0
  205. package/src/graphql/queries/repo.graphql +28 -0
  206. package/src/graphql/queries/stats.graphql +113 -0
  207. package/src/graphql/queries/top-languages.graphql +27 -0
  208. package/src/graphql/reposContributedToDocument.ts +83 -0
  209. package/src/index.ts +18 -0
  210. package/src/themes/index.ts +519 -0
  211. package/src/translations.ts +1169 -0
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Return console instance based on the environment.
3
+ */
4
+ const logger = {
5
+ log: console.log,
6
+ error: console.error,
7
+ };
8
+ export { logger };
@@ -0,0 +1,59 @@
1
+ import type { RepositoryAffiliation } from '../graphql/generated/common.js';
2
+ /**
3
+ * Returns boolean if value is either "true" or "false" else the value as it is.
4
+ *
5
+ * @param value The value to parse; `undefined` when the param was not sent.
6
+ * @returns The parsed value.
7
+ */
8
+ declare const parseBoolean: (value: string | boolean | undefined) => boolean | undefined;
9
+ /**
10
+ * Parse string to array of strings.
11
+ *
12
+ * @param str The string to parse; `undefined` when the param was not sent.
13
+ * @returns The array of strings.
14
+ */
15
+ declare const parseArray: (str: string | undefined) => Array<string>;
16
+ /**
17
+ * Clamp the given number between the given range.
18
+ *
19
+ * @param number The number to clamp.
20
+ * @param min The minimum value.
21
+ * @param max The maximum value.
22
+ * @returns The clamped number.
23
+ */
24
+ declare const clampValue: (number: string | number, min: number, max: number) => number;
25
+ /**
26
+ * Lowercase and trim string.
27
+ *
28
+ * @param name String to lowercase and trim.
29
+ * @returns Lowercased and trimmed string.
30
+ */
31
+ declare const lowercaseTrim: (name: string) => string;
32
+ /**
33
+ * Split array of languages in two columns.
34
+ *
35
+ * @template T Language object.
36
+ * @param arr Array of languages.
37
+ * @param perChunk Number of languages per column.
38
+ * @returns Array of languages split in two columns.
39
+ */
40
+ declare const chunkArray: <T>(arr: Array<T>, perChunk: number) => Array<Array<T>>;
41
+ /**
42
+ * Parse emoji from string.
43
+ *
44
+ * @param str String to parse emoji from.
45
+ * @returns String with emoji parsed.
46
+ */
47
+ declare const parseEmojis: (str: string) => string;
48
+ /**
49
+ * Parse owner affiliations.
50
+ *
51
+ * @param affiliations input affiliations to be parsed.
52
+ * @returns Parsed affiliations.
53
+ *
54
+ * @throws {CardError} If affiliations contains invalid values.
55
+ */
56
+ declare const parseOwnerAffiliations: (affiliations: Array<string>) => Array<RepositoryAffiliation>;
57
+ declare const buildSearchFilter: (repos?: Array<string> | string, owners?: Array<string> | string) => string;
58
+ export { parseBoolean, parseArray, clampValue, lowercaseTrim, chunkArray, parseEmojis, parseOwnerAffiliations, buildSearchFilter, };
59
+ //# sourceMappingURL=ops.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../src/common/ops.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAK5E;;;;;GAKG;AACH,QAAA,MAAM,YAAY,GAAI,OAAO,MAAM,GAAG,OAAO,GAAG,SAAS,KAAG,OAAO,GAAG,SAarE,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,UAAU,GAAI,KAAK,MAAM,GAAG,SAAS,KAAG,KAAK,CAAC,MAAM,CAKzD,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,UAAU,GAAI,QAAQ,MAAM,GAAG,MAAM,EAAE,KAAK,MAAM,EAAE,KAAK,MAAM,KAAG,MAKvE,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,aAAa,GAAI,MAAM,MAAM,KAAG,MAAmC,CAAC;AAE1E;;;;;;;GAOG;AACH,QAAA,MAAM,UAAU,GAAI,CAAC,EAAE,KAAK,KAAK,CAAC,CAAC,CAAC,EAAE,UAAU,MAAM,KAAG,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAQtE,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,WAAW,GAAI,KAAK,MAAM,KAAG,MAOlC,CAAC;AAKF;;;;;;;GAOG;AACH,QAAA,MAAM,sBAAsB,GAAI,cAAc,KAAK,CAAC,MAAM,CAAC,KAAG,KAAK,CAAC,qBAAqB,CAcxF,CAAC;AAEF,QAAA,MAAM,iBAAiB,GACrB,QAAO,KAAK,CAAC,MAAM,CAAC,GAAG,MAAW,EAClC,SAAQ,KAAK,CAAC,MAAM,CAAC,GAAG,MAAW,KAClC,MAMF,CAAC;AAEF,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,sBAAsB,EACtB,iBAAiB,GAClB,CAAC"}
@@ -0,0 +1,115 @@
1
+ import toEmoji from 'emoji-name-map';
2
+ import { OWNER_AFFILIATIONS } from './constants.js';
3
+ import { CardError, INVALID_AFFILIATION } from './error.js';
4
+ /**
5
+ * Returns boolean if value is either "true" or "false" else the value as it is.
6
+ *
7
+ * @param value The value to parse; `undefined` when the param was not sent.
8
+ * @returns The parsed value.
9
+ */
10
+ const parseBoolean = (value) => {
11
+ if (typeof value === 'boolean') {
12
+ return value;
13
+ }
14
+ if (typeof value === 'string') {
15
+ if (value.toLowerCase() === 'true') {
16
+ return true;
17
+ }
18
+ else if (value.toLowerCase() === 'false') {
19
+ return false;
20
+ }
21
+ }
22
+ return undefined;
23
+ };
24
+ /**
25
+ * Parse string to array of strings.
26
+ *
27
+ * @param str The string to parse; `undefined` when the param was not sent.
28
+ * @returns The array of strings.
29
+ */
30
+ const parseArray = (str) => {
31
+ if (!str) {
32
+ return [];
33
+ }
34
+ return str.split(',');
35
+ };
36
+ /**
37
+ * Clamp the given number between the given range.
38
+ *
39
+ * @param number The number to clamp.
40
+ * @param min The minimum value.
41
+ * @param max The maximum value.
42
+ * @returns The clamped number.
43
+ */
44
+ const clampValue = (number, min, max) => {
45
+ if (Number.isNaN(parseInt(String(number), 10))) {
46
+ return min;
47
+ }
48
+ return Math.max(min, Math.min(Number(number), max));
49
+ };
50
+ /**
51
+ * Lowercase and trim string.
52
+ *
53
+ * @param name String to lowercase and trim.
54
+ * @returns Lowercased and trimmed string.
55
+ */
56
+ const lowercaseTrim = (name) => name.toLowerCase().trim();
57
+ /**
58
+ * Split array of languages in two columns.
59
+ *
60
+ * @template T Language object.
61
+ * @param arr Array of languages.
62
+ * @param perChunk Number of languages per column.
63
+ * @returns Array of languages split in two columns.
64
+ */
65
+ const chunkArray = (arr, perChunk) => {
66
+ return arr.reduce((resultArray, item, index) => {
67
+ const chunkIndex = Math.floor(index / perChunk);
68
+ const chunk = resultArray[chunkIndex] ?? [];
69
+ chunk.push(item);
70
+ resultArray[chunkIndex] = chunk;
71
+ return resultArray;
72
+ }, []);
73
+ };
74
+ /**
75
+ * Parse emoji from string.
76
+ *
77
+ * @param str String to parse emoji from.
78
+ * @returns String with emoji parsed.
79
+ */
80
+ const parseEmojis = (str) => {
81
+ if (!str) {
82
+ throw new Error('[parseEmoji]: str argument not provided');
83
+ }
84
+ return str.replace(/:\w+:/gm, (emoji) => {
85
+ return toEmoji.get(emoji) || '';
86
+ });
87
+ };
88
+ const isOwnerAffiliation = (value) => OWNER_AFFILIATIONS.some((affiliation) => affiliation === value);
89
+ /**
90
+ * Parse owner affiliations.
91
+ *
92
+ * @param affiliations input affiliations to be parsed.
93
+ * @returns Parsed affiliations.
94
+ *
95
+ * @throws {CardError} If affiliations contains invalid values.
96
+ */
97
+ const parseOwnerAffiliations = (affiliations) => {
98
+ // Set default value for ownerAffiliations.
99
+ // NOTE: Done here since parseArray() will always return an empty array even nothing
100
+ //was specified.
101
+ const normalized = affiliations.length > 0
102
+ ? affiliations.map((affiliation) => affiliation.toUpperCase())
103
+ : ['OWNER'];
104
+ // Check if ownerAffiliations contains valid values.
105
+ if (!normalized.every(isOwnerAffiliation)) {
106
+ throw CardError.invalidParam('role', INVALID_AFFILIATION);
107
+ }
108
+ return normalized;
109
+ };
110
+ const buildSearchFilter = (repos = [], owners = []) => {
111
+ const repoFilter = Array.isArray(repos) && repos.length > 0 ? repos.map((r) => `repo:${r} `).join('') : '';
112
+ const orgFilter = Array.isArray(owners) && owners.length > 0 ? owners.map((o) => `owner:${o} `).join('') : '';
113
+ return repoFilter + orgFilter;
114
+ };
115
+ export { parseBoolean, parseArray, clampValue, lowercaseTrim, chunkArray, parseEmojis, parseOwnerAffiliations, buildSearchFilter, };
@@ -0,0 +1,196 @@
1
+ /**
2
+ * Auto layout utility, allows us to layout things vertically or horizontally with
3
+ * proper gaping.
4
+ *
5
+ * The caller must ensure that the passed `items` are properly sanitized!
6
+ *
7
+ * @param props Function properties.
8
+ * @param props.items Array of sanitized items to layout.
9
+ * @param props.gap Gap between items.
10
+ * @param props.direction Direction to layout items.
11
+ * @param props.sizes Array of sizes for each item.
12
+ * @returns Array of items with proper layout.
13
+ */
14
+ declare const flexLayout: ({ items, gap, direction, sizes, }: {
15
+ items: Array<string>;
16
+ gap: number;
17
+ direction?: "column" | "row";
18
+ sizes?: Array<number>;
19
+ }) => Array<string>;
20
+ /**
21
+ * Creates a node to display the primary programming language of the repository/gist.
22
+ *
23
+ * @param langName Language name.
24
+ * @param langColor Language color.
25
+ * @returns Language display SVG object.
26
+ */
27
+ declare const createLanguageNode: (langName: string, langColor: string) => string;
28
+ /**
29
+ * Create a node to indicate progress in percentage along a horizontal line.
30
+ *
31
+ * @param params Object that contains the createProgressNode parameters.
32
+ * @param params.x X-axis position.
33
+ * @param params.y Y-axis position.
34
+ * @param params.width Width of progress bar.
35
+ * @param params.color Optional foreground color as an inline fill fallback.
36
+ * When omitted, the color must be set via a `.lang-progress` CSS rule.
37
+ * @param params.progress Progress value.
38
+ * @param params.delay Delay before animation starts.
39
+ * @returns Progress node.
40
+ */
41
+ declare const createProgressNode: ({ x, y, width, color, progress, delay, }: {
42
+ x: number;
43
+ y: number;
44
+ width: number;
45
+ color?: string;
46
+ progress: number;
47
+ delay: number;
48
+ }) => string;
49
+ /**
50
+ * Renders multi-line text via a `foreignObject` so the browser performs
51
+ * native, font-aware wrapping. Content overflowing `lineCount` lines is
52
+ * clipped (with an ellipsis on the last visible line) by CSS line-clamp.
53
+ *
54
+ * @param props Function properties.
55
+ * @param props.text Text to render (will be HTML-encoded).
56
+ * @param props.x X position of the foreignObject.
57
+ * @param props.y Y position of the foreignObject.
58
+ * @param props.width Width of the wrap box.
59
+ * @param props.height Height of the wrap box.
60
+ * @param props.lineCount Maximum number of lines to display.
61
+ * @param props.className CSS class applied to the inner element.
62
+ * @param props.testId Optional test id for the inner element.
63
+ * @returns foreignObject SVG node.
64
+ */
65
+ declare const wrappedTextNode: ({ text, x, y, width, height, lineCount, className, testId, }: {
66
+ text: string;
67
+ x: number;
68
+ y: number;
69
+ width: number;
70
+ height: number;
71
+ lineCount: number;
72
+ className: string;
73
+ testId?: string;
74
+ }) => string;
75
+ /**
76
+ * CSS rules used to render multi-line text inside a `foreignObject`. Apply this
77
+ * to a CSS class (e.g. `.description`) shared with `wrappedTextNode` so the
78
+ * browser handles wrapping and the line count is taken from the `--lines`
79
+ * custom property set on the element.
80
+ *
81
+ * @param color Text color (CSS `color` property).
82
+ * @returns CSS rules block (without the surrounding selector).
83
+ */
84
+ declare const wrappedTextStyles: (color: string) => string;
85
+ /**
86
+ * Creates an icon with label to display repository/gist stats like forks, stars, etc.
87
+ *
88
+ * The caller must ensure that the passed `icon` is properly sanitized!
89
+ *
90
+ * @param icon The sanitized icon to display.
91
+ * @param label The label to display.
92
+ * @param testid The testid to assign to the label.
93
+ * @param iconSize The size of the icon.
94
+ * @returns Icon with label SVG object.
95
+ */
96
+ declare const iconWithLabel: (icon: string, label: number | string, testid: string, iconSize: number) => string;
97
+ /**
98
+ * Create a labelled stat text item
99
+ * (a label and its value, optionally with an icon and link).
100
+ * Shared by the stats and repo cards.
101
+ *
102
+ * The caller must ensure that the passed `icon` and `link` are properly sanitized!
103
+ *
104
+ * @param params Object that contains the createTextNode parameters.
105
+ * @param params.icon The sanitized icon to display.
106
+ * @param params.label The label to display.
107
+ * @param params.value The value to display.
108
+ * @param params.id The id of the stat.
109
+ * @param params.unitSymbol The unit symbol of the stat.
110
+ * @param params.index The index of the stat.
111
+ * @param params.showIcons Whether to show icons.
112
+ * @param params.shiftValuePos Number of pixels the value has to be shifted to the right.
113
+ * @param params.bold Whether to bold the label.
114
+ * @param params.numberFormat The format of numbers on card.
115
+ * @param params.numberPrecision The precision of numbers on card.
116
+ * @param params.link Sanitized url to link to.
117
+ * @param params.labelXOffset horizontal offset for label.
118
+ * @returns The stats card text item SVG object.
119
+ */
120
+ declare const createTextNode: ({ icon, label, value, id, unitSymbol, index, showIcons, shiftValuePos, bold, numberFormat, numberPrecision, link, labelXOffset, }: {
121
+ icon: string;
122
+ label: string;
123
+ value: number | string;
124
+ id: string;
125
+ unitSymbol?: string | undefined;
126
+ index: number;
127
+ showIcons: boolean;
128
+ shiftValuePos: number;
129
+ bold: boolean;
130
+ numberFormat: string;
131
+ numberPrecision?: number | undefined;
132
+ link?: string | undefined;
133
+ labelXOffset?: number;
134
+ }) => string;
135
+ /**
136
+ * Renders error message on the card.
137
+ *
138
+ * @param args Function arguments.
139
+ * @param args.message Main error message.
140
+ * @param args.secondaryMessage The secondary error message.
141
+ * @param args.renderOptions Render options.
142
+ * @param args.renderOptions.title_color Card title color.
143
+ * @param args.renderOptions.text_color Card text color.
144
+ * @param args.renderOptions.bg_color Card background color.
145
+ * @param args.renderOptions.border_color Card border color.
146
+ * @param args.renderOptions.theme Card theme.
147
+ * @param args.renderOptions.show_repo_link Whether to show repo link or not.
148
+ * @returns The SVG markup.
149
+ */
150
+ declare const renderError: ({ message, secondaryMessage, renderOptions, }: {
151
+ message: string;
152
+ secondaryMessage?: string | undefined;
153
+ renderOptions?: {
154
+ title_color?: string | undefined;
155
+ text_color?: string | undefined;
156
+ bg_color?: string | undefined;
157
+ border_color?: string | undefined;
158
+ theme?: string | undefined;
159
+ show_repo_link?: boolean | undefined;
160
+ };
161
+ }) => string;
162
+ /**
163
+ * Retrieve text length based on Segoe UI font.
164
+ *
165
+ * @see https://stackoverflow.com/a/48172630/10629172
166
+ * @param str String to measure.
167
+ * @param fontSize Font size.
168
+ * @returns Text length.
169
+ */
170
+ declare const measureText: (str: string, fontSize?: number) => number;
171
+ /**
172
+ * Split text into the lines it would wrap to when laid out greedily at the
173
+ * given font size inside a box of width `maxWidth`. Uses `measureText` so the
174
+ * estimate reflects actual font metrics rather than a fixed character count.
175
+ * The browser still does the real wrap inside the foreignObject; this is only
176
+ * used to size the SVG.
177
+ *
178
+ * @param text Text to split.
179
+ * @param fontSize Font size in px (matches `measureText`).
180
+ * @param maxWidth Available wrap width in px.
181
+ * @returns Estimated wrapped lines.
182
+ */
183
+ declare const splitWrappedText: (text: string, fontSize: number, maxWidth: number) => Array<string>;
184
+ /**
185
+ * Estimate how many lines a string will wrap to when laid out greedily at the
186
+ * given font size inside a box of width `maxWidth`, capped at `maxLines`.
187
+ *
188
+ * @param text Text to estimate.
189
+ * @param fontSize Font size in px (matches `measureText`).
190
+ * @param maxWidth Available wrap width in px.
191
+ * @param maxLines Cap on the returned line count.
192
+ * @returns Estimated line count, at least 1, at most `maxLines`.
193
+ */
194
+ declare const countWrappedLines: (text: string, fontSize: number, maxWidth: number, maxLines: number) => number;
195
+ export { renderError, createLanguageNode, createProgressNode, createTextNode, iconWithLabel, flexLayout, measureText, splitWrappedText, countWrappedLines, wrappedTextNode, wrappedTextStyles, };
196
+ //# sourceMappingURL=render.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/common/render.ts"],"names":[],"mappings":"AAMA;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,UAAU,GAAI,mCAKjB;IACD,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACrB,GAAG,EAAE,MAAM,CAAC;IACZ,SAAS,CAAC,EAAE,QAAQ,GAAG,KAAK,CAAC;IAC7B,KAAK,CAAC,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;CACvB,KAAG,KAAK,CAAC,MAAM,CAgBf,CAAC;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,kBAAkB,GAAI,UAAU,MAAM,EAAE,WAAW,MAAM,KAAG,MAWjE,CAAC;AAEF;;;;;;;;;;;;GAYG;AACH,QAAA,MAAM,kBAAkB,GAAI,0CAOzB;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;CACf,KAAG,MAiCH,CAAC;AAEF;;;;;;;;;;;;;;;GAeG;AACH,QAAA,MAAM,eAAe,GAAI,8DAStB;IACD,IAAI,EAAE,MAAM,CAAC;IACb,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAA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