@stats-forge/github-stats-forge-core 0.0.2 → 0.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 (249) 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/contributed-to.d.ts +23 -0
  6. package/build/api/contributed-to.d.ts.map +1 -0
  7. package/build/api/contributed-to.js +43 -0
  8. package/build/api/gist.d.ts +8 -22
  9. package/build/api/gist.d.ts.map +1 -1
  10. package/build/api/gist.js +14 -36
  11. package/build/api/handler.d.ts +16 -0
  12. package/build/api/handler.d.ts.map +1 -0
  13. package/build/api/handler.js +29 -0
  14. package/build/api/index.d.ts +13 -12
  15. package/build/api/index.d.ts.map +1 -1
  16. package/build/api/index.js +1 -0
  17. package/build/api/params.d.ts +21 -12
  18. package/build/api/params.d.ts.map +1 -1
  19. package/build/api/params.js +41 -19
  20. package/build/api/pin.d.ts +11 -31
  21. package/build/api/pin.d.ts.map +1 -1
  22. package/build/api/pin.js +35 -63
  23. package/build/api/stats.d.ts +15 -16
  24. package/build/api/stats.d.ts.map +1 -1
  25. package/build/api/stats.js +60 -99
  26. package/build/api/top-langs.d.ts +13 -18
  27. package/build/api/top-langs.d.ts.map +1 -1
  28. package/build/api/top-langs.js +35 -72
  29. package/build/api/wakatime.d.ts +11 -17
  30. package/build/api/wakatime.d.ts.map +1 -1
  31. package/build/api/wakatime.js +27 -64
  32. package/build/calculateRank.d.ts +0 -9
  33. package/build/calculateRank.d.ts.map +1 -1
  34. package/build/calculateRank.js +12 -17
  35. package/build/cards/contributed-to.d.ts +19 -0
  36. package/build/cards/contributed-to.d.ts.map +1 -0
  37. package/build/cards/contributed-to.js +242 -0
  38. package/build/cards/gist.d.ts +3 -4
  39. package/build/cards/gist.d.ts.map +1 -1
  40. package/build/cards/gist.js +38 -43
  41. package/build/cards/options.d.ts +1 -1
  42. package/build/cards/repo.d.ts +14 -5
  43. package/build/cards/repo.d.ts.map +1 -1
  44. package/build/cards/repo.js +93 -103
  45. package/build/cards/stats.d.ts +18 -11
  46. package/build/cards/stats.d.ts.map +1 -1
  47. package/build/cards/stats.js +191 -222
  48. package/build/cards/top-languages.d.ts +18 -33
  49. package/build/cards/top-languages.d.ts.map +1 -1
  50. package/build/cards/top-languages.js +196 -387
  51. package/build/cards/wakatime.d.ts +17 -8
  52. package/build/cards/wakatime.d.ts.map +1 -1
  53. package/build/cards/wakatime.js +133 -187
  54. package/build/common/Card.d.ts +20 -59
  55. package/build/common/Card.d.ts.map +1 -1
  56. package/build/common/Card.js +131 -198
  57. package/build/common/I18n.d.ts +1 -7
  58. package/build/common/I18n.d.ts.map +1 -1
  59. package/build/common/I18n.js +7 -8
  60. package/build/common/brand.d.ts +76 -0
  61. package/build/common/brand.d.ts.map +1 -0
  62. package/build/common/brand.js +73 -0
  63. package/build/common/color.d.ts +4 -17
  64. package/build/common/color.d.ts.map +1 -1
  65. package/build/common/color.js +67 -49
  66. package/build/common/config.d.ts +4 -14
  67. package/build/common/config.d.ts.map +1 -1
  68. package/build/common/config.js +3 -16
  69. package/build/common/constants.d.ts +6 -2
  70. package/build/common/constants.d.ts.map +1 -1
  71. package/build/common/constants.js +5 -1
  72. package/build/common/date.d.ts +50 -5
  73. package/build/common/date.d.ts.map +1 -1
  74. package/build/common/date.js +104 -4
  75. package/build/common/emojiMap.d.ts +8 -0
  76. package/build/common/emojiMap.d.ts.map +1 -0
  77. package/build/common/emojiMap.js +10 -0
  78. package/build/common/emojiMap.json +1915 -0
  79. package/build/common/error.d.ts +1 -10
  80. package/build/common/error.d.ts.map +1 -1
  81. package/build/common/error.js +1 -10
  82. package/build/common/fmt.d.ts +3 -15
  83. package/build/common/fmt.d.ts.map +1 -1
  84. package/build/common/fmt.js +7 -35
  85. package/build/common/http.d.ts +2 -7
  86. package/build/common/http.d.ts.map +1 -1
  87. package/build/common/http.js +8 -17
  88. package/build/common/icons.d.ts +20 -20
  89. package/build/common/icons.d.ts.map +1 -1
  90. package/build/common/icons.js +108 -67
  91. package/build/common/languageColors.d.ts +0 -1
  92. package/build/common/languageColors.d.ts.map +1 -1
  93. package/build/common/languageColors.js +1 -4
  94. package/build/common/languageColors.json +18 -2
  95. package/build/common/ops.d.ts +11 -17
  96. package/build/common/ops.d.ts.map +1 -1
  97. package/build/common/ops.js +22 -39
  98. package/build/common/render.d.ts +34 -82
  99. package/build/common/render.d.ts.map +1 -1
  100. package/build/common/render.js +225 -259
  101. package/build/common/retryer.d.ts +2 -7
  102. package/build/common/retryer.d.ts.map +1 -1
  103. package/build/common/retryer.js +4 -11
  104. package/build/fetchers/contributed-to.d.ts +62 -0
  105. package/build/fetchers/contributed-to.d.ts.map +1 -0
  106. package/build/fetchers/contributed-to.js +184 -0
  107. package/build/fetchers/gist.d.ts +2 -5
  108. package/build/fetchers/gist.d.ts.map +1 -1
  109. package/build/fetchers/gist.js +1 -5
  110. package/build/fetchers/graphql-error.d.ts +13 -0
  111. package/build/fetchers/graphql-error.d.ts.map +1 -0
  112. package/build/fetchers/graphql-error.js +29 -0
  113. package/build/fetchers/index.d.ts +13 -12
  114. package/build/fetchers/index.d.ts.map +1 -1
  115. package/build/fetchers/index.js +1 -0
  116. package/build/fetchers/repo.d.ts +2 -11
  117. package/build/fetchers/repo.d.ts.map +1 -1
  118. package/build/fetchers/repo.js +20 -33
  119. package/build/fetchers/stats.d.ts +16 -40
  120. package/build/fetchers/stats.d.ts.map +1 -1
  121. package/build/fetchers/stats.js +89 -271
  122. package/build/fetchers/top-languages.d.ts +2 -9
  123. package/build/fetchers/top-languages.d.ts.map +1 -1
  124. package/build/fetchers/top-languages.js +16 -47
  125. package/build/fetchers/types.d.ts +25 -1
  126. package/build/fetchers/types.d.ts.map +1 -1
  127. package/build/fetchers/wakatime.d.ts +2 -6
  128. package/build/fetchers/wakatime.d.ts.map +1 -1
  129. package/build/fetchers/wakatime.js +1 -5
  130. package/build/graphql/contributionsCollection.d.ts +9 -0
  131. package/build/graphql/contributionsCollection.d.ts.map +1 -0
  132. package/build/graphql/contributionsCollection.js +12 -0
  133. package/build/graphql/contributionsDocument.d.ts +6 -6
  134. package/build/graphql/contributionsDocument.d.ts.map +1 -1
  135. package/build/graphql/contributionsDocument.js +8 -16
  136. package/build/graphql/generated/contributed-to.d.ts +22 -0
  137. package/build/graphql/generated/contributed-to.d.ts.map +1 -0
  138. package/build/graphql/generated/contributed-to.js +11 -0
  139. package/build/graphql/generated/gist.d.ts +1 -1
  140. package/build/graphql/generated/repo.d.ts +1 -1
  141. package/build/graphql/generated/stats.d.ts +16 -4
  142. package/build/graphql/generated/stats.d.ts.map +1 -1
  143. package/build/graphql/generated/stats.js +2 -2
  144. package/build/graphql/generated/top-languages.d.ts +2 -2
  145. package/build/graphql/graphqlDocument.d.ts +1 -2
  146. package/build/graphql/graphqlDocument.d.ts.map +1 -1
  147. package/build/graphql/graphqlDocument.js +0 -1
  148. package/build/graphql/reposContributedToDocument.d.ts +4 -5
  149. package/build/graphql/reposContributedToDocument.d.ts.map +1 -1
  150. package/build/graphql/reposContributedToDocument.js +11 -7
  151. package/build/markup/css.d.ts +35 -0
  152. package/build/markup/css.d.ts.map +1 -0
  153. package/build/markup/css.js +64 -0
  154. package/build/markup/element.d.ts +41 -0
  155. package/build/markup/element.d.ts.map +1 -0
  156. package/build/markup/element.js +127 -0
  157. package/build/markup/html.d.ts +13 -0
  158. package/build/markup/html.d.ts.map +1 -0
  159. package/build/markup/html.js +27 -0
  160. package/build/markup/index.d.ts +9 -0
  161. package/build/markup/index.d.ts.map +1 -0
  162. package/build/markup/index.js +6 -0
  163. package/build/markup/serialize.d.ts +16 -0
  164. package/build/markup/serialize.d.ts.map +1 -0
  165. package/build/markup/serialize.js +17 -0
  166. package/build/themes/index.d.ts +332 -333
  167. package/build/themes/index.d.ts.map +1 -1
  168. package/build/themes/index.js +1 -1
  169. package/build/translations.d.ts +66 -7
  170. package/build/translations.d.ts.map +1 -1
  171. package/build/translations.js +686 -629
  172. package/package.json +17 -26
  173. package/src/api/api-result.ts +10 -9
  174. package/src/api/contributed-to.ts +84 -0
  175. package/src/api/gist.ts +22 -46
  176. package/src/api/handler.ts +42 -0
  177. package/src/api/index.ts +13 -12
  178. package/src/api/params.ts +74 -29
  179. package/src/api/pin.ts +38 -65
  180. package/src/api/stats.ts +81 -118
  181. package/src/api/top-langs.ts +38 -80
  182. package/src/api/wakatime.ts +35 -73
  183. package/src/calculateRank.ts +12 -23
  184. package/src/cards/contributed-to.ts +373 -0
  185. package/src/cards/gist.ts +55 -49
  186. package/src/cards/options.ts +1 -1
  187. package/src/cards/repo.ts +134 -120
  188. package/src/cards/stats.ts +262 -252
  189. package/src/cards/top-languages.ts +315 -422
  190. package/src/cards/wakatime.ts +207 -225
  191. package/src/common/Card.ts +207 -214
  192. package/src/common/I18n.ts +7 -8
  193. package/src/common/brand.ts +109 -0
  194. package/src/common/color.ts +80 -57
  195. package/src/common/config.ts +5 -18
  196. package/src/common/constants.ts +8 -2
  197. package/src/common/date.ts +135 -5
  198. package/src/common/emojiMap.json +1915 -0
  199. package/src/common/emojiMap.ts +13 -0
  200. package/src/common/error.ts +2 -11
  201. package/src/common/fmt.ts +7 -44
  202. package/src/common/http.ts +9 -15
  203. package/src/common/icons.ts +122 -42
  204. package/src/common/languageColors.json +18 -2
  205. package/src/common/languageColors.ts +1 -4
  206. package/src/common/ops.ts +31 -48
  207. package/src/common/render.ts +334 -284
  208. package/src/common/retryer.ts +8 -15
  209. package/src/fetchers/contributed-to.ts +271 -0
  210. package/src/fetchers/gist.ts +8 -12
  211. package/src/fetchers/graphql-error.ts +36 -0
  212. package/src/fetchers/index.ts +15 -12
  213. package/src/fetchers/repo.ts +27 -40
  214. package/src/fetchers/stats.ts +157 -366
  215. package/src/fetchers/top-languages.ts +27 -55
  216. package/src/fetchers/types.ts +27 -1
  217. package/src/fetchers/wakatime.ts +5 -9
  218. package/src/graphql/contributionsCollection.ts +18 -0
  219. package/src/graphql/contributionsDocument.ts +14 -19
  220. package/src/graphql/generated/contributed-to.ts +25 -0
  221. package/src/graphql/generated/gist.ts +1 -1
  222. package/src/graphql/generated/repo.ts +1 -1
  223. package/src/graphql/generated/stats.ts +21 -8
  224. package/src/graphql/generated/top-languages.ts +2 -2
  225. package/src/graphql/graphqlDocument.ts +1 -2
  226. package/src/graphql/queries/contributed-to.graphql +8 -0
  227. package/src/graphql/queries/stats.graphql +14 -2
  228. package/src/graphql/reposContributedToDocument.ts +16 -15
  229. package/src/markup/css.ts +118 -0
  230. package/src/markup/element.ts +246 -0
  231. package/src/markup/html.ts +34 -0
  232. package/src/markup/index.ts +9 -0
  233. package/src/markup/serialize.ts +27 -0
  234. package/src/themes/index.ts +1 -1
  235. package/src/translations.ts +699 -629
  236. package/build/cards/index.d.ts +0 -11
  237. package/build/cards/index.d.ts.map +0 -1
  238. package/build/cards/index.js +0 -7
  239. package/build/common/html.d.ts +0 -8
  240. package/build/common/html.d.ts.map +0 -1
  241. package/build/common/html.js +0 -14
  242. package/build/index.d.ts +0 -15
  243. package/build/index.d.ts.map +0 -1
  244. package/build/index.js +0 -10
  245. package/src/_emoji-name-map.d.ts +0 -10
  246. package/src/_github-username-regex.d.ts +0 -4
  247. package/src/cards/index.ts +0 -21
  248. package/src/common/html.ts +0 -17
  249. package/src/index.ts +0 -18
@@ -1,66 +1,50 @@
1
+ import { el, renderMarkup, rule, style } from '../markup/index.js';
1
2
  import { getCardColors, isPrefixedHexColor } from './color.js';
2
3
  import { SECONDARY_ERROR_MESSAGES, TRY_AGAIN_LATER } from './error.js';
3
4
  import { kFormatter } from './fmt.js';
4
- import { encodeHTML } from './html.js';
5
5
  import { clampValue } from './ops.js';
6
6
  /**
7
7
  * Auto layout utility, allows us to layout things vertically or horizontally with
8
8
  * proper gaping.
9
9
  *
10
- * The caller must ensure that the passed `items` are properly sanitized!
11
- *
12
- * @param props Function properties.
13
- * @param props.items Array of sanitized items to layout.
14
- * @param props.gap Gap between items.
15
- * @param props.direction Direction to layout items.
16
- * @param props.sizes Array of sizes for each item.
17
- * @returns Array of items with proper layout.
10
+ * @returns The items, each in the group that positions it.
18
11
  */
19
12
  const flexLayout = ({ items, gap, direction, sizes = [], }) => {
20
13
  if (sizes.some((size) => !Number.isFinite(size))) {
21
14
  throw new Error('flexLayout: `sizes` must contain only numbers');
22
15
  }
16
+ const laidOut = items.filter(Boolean);
17
+ // A lone item is already where it belongs, so it needs no group to move it.
18
+ if (laidOut.length === 1) {
19
+ return laidOut;
20
+ }
23
21
  let lastSize = 0;
24
- // filter() for filtering out empty strings
25
- return items.filter(Boolean).map((item, i) => {
26
- const size = sizes[i] || 0;
27
- let transform = `translate(${lastSize}, 0)`;
28
- if (direction === 'column') {
29
- transform = `translate(0, ${lastSize})`;
30
- }
31
- lastSize += size + gap;
32
- return `<g transform="${transform}">${item}</g>`;
22
+ return laidOut.map((item, i) => {
23
+ const offset = lastSize;
24
+ lastSize += (sizes[i] ?? 0) + gap;
25
+ // The first item never moves, so it gets no transform to carry.
26
+ const transform = offset === 0
27
+ ? undefined
28
+ : direction === 'column'
29
+ ? `translate(0, ${offset})`
30
+ : `translate(${offset}, 0)`;
31
+ return el('g', { transform }, item);
33
32
  });
34
33
  };
35
34
  /**
36
35
  * Creates a node to display the primary programming language of the repository/gist.
37
36
  *
38
- * @param langName Language name.
39
- * @param langColor Language color.
40
37
  * @returns Language display SVG object.
41
38
  */
42
39
  const createLanguageNode = (langName, langColor) => {
43
40
  if (!isPrefixedHexColor(langColor)) {
44
41
  throw new Error(`Invalid language color: "${langColor}"`);
45
42
  }
46
- return `
47
- <g data-testid="primary-lang">
48
- <circle data-testid="lang-color" cx="0" cy="-5" r="6" fill="${langColor}" />
49
- <text data-testid="lang-name" class="gray" x="15">${encodeHTML(langName)}</text>
50
- </g>
51
- `;
43
+ return el('g', { 'data-testid': 'primary-lang' }, el('circle', { 'data-testid': 'lang-color', cx: 0, cy: -5, r: 6, fill: langColor }), el('text', { 'data-testid': 'lang-name', class: 'gray', x: 15 }, langName));
52
44
  };
53
45
  /**
54
46
  * Create a node to indicate progress in percentage along a horizontal line.
55
47
  *
56
- * @param params Object that contains the createProgressNode parameters.
57
- * @param params.x X-axis position.
58
- * @param params.y Y-axis position.
59
- * @param params.width Width of progress bar.
60
- * @param params.color Optional foreground color as an inline fill fallback.
61
- * When omitted, the color must be set via a `.lang-progress` CSS rule.
62
- * @param params.progress Progress value.
63
- * @param params.delay Delay before animation starts.
64
48
  * @returns Progress node.
65
49
  */
66
50
  const createProgressNode = ({ x, y, width, color, progress, delay, }) => {
@@ -68,71 +52,67 @@ const createProgressNode = ({ x, y, width, color, progress, delay, }) => {
68
52
  throw new Error(`Invalid progress color: "${color}"`);
69
53
  }
70
54
  if (!Number.isFinite(width)) {
71
- throw new Error(`Invalid width: "${width}"`);
55
+ throw new TypeError(`Invalid width: "${width}"`);
72
56
  }
73
57
  if (!Number.isFinite(x)) {
74
- throw new Error(`Invalid x: "${x}"`);
58
+ throw new TypeError(`Invalid x: "${x}"`);
75
59
  }
76
60
  if (!Number.isFinite(y)) {
77
- throw new Error(`Invalid y: "${y}"`);
61
+ throw new TypeError(`Invalid y: "${y}"`);
78
62
  }
79
63
  if (!Number.isFinite(delay)) {
80
- throw new Error(`Invalid delay: "${delay}"`);
64
+ throw new TypeError(`Invalid delay: "${delay}"`);
81
65
  }
82
66
  const progressPercentage = clampValue(progress, 2, 100);
83
- return `
84
- <svg width="${width}" x="${x}" y="${y}">
85
- <rect data-testid="progress-background" class="progress-background" rx="5" ry="5" x="0" y="0" width="${width}" height="8"></rect>
86
- <svg data-testid="lang-progress" width="${progressPercentage}%">
87
- <rect
88
- height="8"
89
- ${color === undefined ? '' : `fill="${color}"`}
90
- rx="5" ry="5" x="0" y="0"
91
- class="lang-progress"
92
- style="animation-delay: ${delay}ms;"
93
- />
94
- </svg>
95
- </svg>
96
- `;
67
+ return el('svg', { width, x, y }, el('rect', {
68
+ 'data-testid': 'progress-background',
69
+ class: 'progress-background',
70
+ rx: 5,
71
+ ry: 5,
72
+ x: 0,
73
+ y: 0,
74
+ width,
75
+ height: 8,
76
+ }), el('svg', { 'data-testid': 'lang-progress', width: `${progressPercentage}%` }, el('rect', {
77
+ height: 8,
78
+ fill: color,
79
+ rx: 5,
80
+ ry: 5,
81
+ x: 0,
82
+ y: 0,
83
+ class: 'lang-progress',
84
+ style: `animation-delay: ${delay}ms;`,
85
+ })));
97
86
  };
98
87
  /**
99
88
  * Renders multi-line text via a `foreignObject` so the browser performs
100
89
  * native, font-aware wrapping. Content overflowing `lineCount` lines is
101
90
  * clipped (with an ellipsis on the last visible line) by CSS line-clamp.
102
91
  *
103
- * @param props Function properties.
104
- * @param props.text Text to render (will be HTML-encoded).
105
- * @param props.x X position of the foreignObject.
106
- * @param props.y Y position of the foreignObject.
107
- * @param props.width Width of the wrap box.
108
- * @param props.height Height of the wrap box.
109
- * @param props.lineCount Maximum number of lines to display.
110
- * @param props.className CSS class applied to the inner element.
111
- * @param props.testId Optional test id for the inner element.
112
92
  * @returns foreignObject SVG node.
113
93
  */
114
94
  const wrappedTextNode = ({ text, x, y, width, height, lineCount, className, testId, }) => {
115
95
  if (!Number.isFinite(x)) {
116
- throw new Error(`Invalid x: "${x}"`);
96
+ throw new TypeError(`Invalid x: "${x}"`);
117
97
  }
118
98
  if (!Number.isFinite(y)) {
119
- throw new Error(`Invalid y: "${y}"`);
99
+ throw new TypeError(`Invalid y: "${y}"`);
120
100
  }
121
101
  if (!Number.isFinite(width)) {
122
- throw new Error(`Invalid width: "${width}"`);
102
+ throw new TypeError(`Invalid width: "${width}"`);
123
103
  }
124
104
  if (!Number.isFinite(height)) {
125
- throw new Error(`Invalid height: "${height}"`);
105
+ throw new TypeError(`Invalid height: "${height}"`);
126
106
  }
127
107
  if (!Number.isFinite(lineCount)) {
128
- throw new Error(`Invalid lineCount: "${lineCount}"`);
108
+ throw new TypeError(`Invalid lineCount: "${lineCount}"`);
129
109
  }
130
- const testIdAttr = testId ? ` data-testid="${encodeHTML(testId)}"` : '';
131
- return `
132
- <foreignObject x="${x}" y="${y}" width="${width}" height="${height}">
133
- <div xmlns="http://www.w3.org/1999/xhtml" class="${encodeHTML(className)}" style="--lines: ${lineCount};"${testIdAttr}>${encodeHTML(text)}</div>
134
- </foreignObject>
135
- `;
110
+ return el('foreignObject', { x, y, width, height }, el('div', {
111
+ xmlns: 'http://www.w3.org/1999/xhtml',
112
+ class: className,
113
+ style: `--lines: ${lineCount};`,
114
+ 'data-testid': testId,
115
+ }, text));
136
116
  };
137
117
  /**
138
118
  * CSS rules used to render multi-line text inside a `foreignObject`. Apply this
@@ -140,93 +120,82 @@ const wrappedTextNode = ({ text, x, y, width, height, lineCount, className, test
140
120
  * browser handles wrapping and the line count is taken from the `--lines`
141
121
  * custom property set on the element.
142
122
  *
143
- * @param color Text color (CSS `color` property).
144
- * @returns CSS rules block (without the surrounding selector).
123
+ * @returns The declarations, to merge into the class's own rule.
145
124
  */
146
125
  const wrappedTextStyles = (color) => {
147
126
  if (!isPrefixedHexColor(color)) {
148
127
  throw new Error(`Invalid text color: "${color}"`);
149
128
  }
150
- return `
151
- color: ${color};
152
- margin: 0;
153
- line-height: 1.2;
154
- overflow-wrap: anywhere;
155
- word-break: break-word;
156
- display: -webkit-box;
157
- -webkit-box-orient: vertical;
158
- -webkit-line-clamp: var(--lines);
159
- line-clamp: var(--lines);
160
- overflow: hidden;
161
- text-overflow: ellipsis;
162
- padding-bottom: 0.15em;
163
- `;
129
+ return {
130
+ color,
131
+ margin: 0,
132
+ 'line-height': 1.2,
133
+ 'overflow-wrap': 'anywhere',
134
+ 'word-break': 'break-word',
135
+ display: '-webkit-box',
136
+ '-webkit-box-orient': 'vertical',
137
+ '-webkit-line-clamp': 'var(--lines)',
138
+ 'line-clamp': 'var(--lines)',
139
+ overflow: 'hidden',
140
+ 'text-overflow': 'ellipsis',
141
+ 'padding-bottom': '0.15em',
142
+ };
164
143
  };
165
144
  /**
166
145
  * Creates an icon with label to display repository/gist stats like forks, stars, etc.
146
+ * Draws nothing when the label is not positive.
167
147
  *
168
- * The caller must ensure that the passed `icon` is properly sanitized!
169
- *
170
- * @param icon The sanitized icon to display.
171
- * @param label The label to display.
172
- * @param testid The testid to assign to the label.
173
- * @param iconSize The size of the icon.
174
- * @returns Icon with label SVG object.
148
+ * @returns Icon with label SVG object, or nothing when the label is not positive.
175
149
  */
176
150
  const iconWithLabel = (icon, label, testid, iconSize) => {
177
151
  if (typeof label === 'number' && label <= 0) {
178
- return '';
152
+ return undefined;
179
153
  }
180
154
  if (!Number.isFinite(iconSize)) {
181
- throw new Error(`Invalid iconSize: "${iconSize}"`);
155
+ throw new TypeError(`Invalid iconSize: "${iconSize}"`);
182
156
  }
183
- const iconSvg = `
184
- <svg
185
- class="icon"
186
- y="-12"
187
- viewBox="0 0 16 16"
188
- version="1.1"
189
- width="${iconSize}"
190
- height="${iconSize}"
191
- >
192
- ${icon}
193
- </svg>
194
- `;
195
- const text = `<text data-testid="${encodeHTML(testid)}" class="gray">${encodeHTML(String(label))}</text>`;
196
- return flexLayout({ items: [iconSvg, text], gap: 20 }).join('');
157
+ return flexLayout({
158
+ items: [
159
+ el('svg', {
160
+ class: 'icon',
161
+ y: -12,
162
+ viewBox: '0 0 16 16',
163
+ version: '1.1',
164
+ width: iconSize,
165
+ height: iconSize,
166
+ }, icon),
167
+ el('text', { 'data-testid': testid, class: 'gray' }, String(label)),
168
+ ],
169
+ gap: 20,
170
+ });
197
171
  };
172
+ /**
173
+ * How a stat value is written.
174
+ * Not validated at the boundary: anything but `long` reads as `short`,
175
+ * so an unknown value falls back rather than failing.
176
+ */
177
+ const NUMBER_FORMATS = ['short', 'long'];
198
178
  /**
199
179
  * Create a labelled stat text item
200
180
  * (a label and its value, optionally with an icon and link).
201
181
  * Shared by the stats and repo cards.
202
182
  *
203
- * The caller must ensure that the passed `icon` and `link` are properly sanitized!
183
+ * The caller must ensure that the passed `link` is properly sanitized!
204
184
  *
205
- * @param params Object that contains the createTextNode parameters.
206
- * @param params.icon The sanitized icon to display.
207
- * @param params.label The label to display.
208
- * @param params.value The value to display.
209
- * @param params.id The id of the stat.
210
- * @param params.unitSymbol The unit symbol of the stat.
211
- * @param params.index The index of the stat.
212
- * @param params.showIcons Whether to show icons.
213
- * @param params.shiftValuePos Number of pixels the value has to be shifted to the right.
214
- * @param params.bold Whether to bold the label.
215
- * @param params.numberFormat The format of numbers on card.
216
- * @param params.numberPrecision The precision of numbers on card.
217
- * @param params.link Sanitized url to link to.
218
- * @param params.labelXOffset horizontal offset for label.
219
185
  * @returns The stats card text item SVG object.
220
186
  */
221
- const createTextNode = ({ icon, label, value, id, unitSymbol, index, showIcons, shiftValuePos, bold, numberFormat, numberPrecision, link, labelXOffset = 25, }) => {
187
+ const createTextNode = ({ icon, label, value, id, unitSymbol, index, showIcons, shiftValuePos, valueAnchorX, bold, labelBold = bold, numberFormat, numberPrecision, link, labelXOffset = 25, }) => {
222
188
  if (!Number.isFinite(labelXOffset)) {
223
- throw new Error(`Invalid labelXOffset: "${labelXOffset}"`);
189
+ throw new TypeError(`Invalid labelXOffset: "${labelXOffset}"`);
224
190
  }
225
191
  if (!Number.isFinite(shiftValuePos)) {
226
- throw new Error(`Invalid shiftValuePos: "${shiftValuePos}"`);
192
+ throw new TypeError(`Invalid shiftValuePos: "${shiftValuePos}"`);
227
193
  }
228
194
  if (!Number.isFinite(index)) {
229
- throw new Error(`Invalid index: "${index}"`);
195
+ throw new TypeError(`Invalid index: "${index}"`);
196
+ }
197
+ if (valueAnchorX !== undefined && !Number.isFinite(valueAnchorX)) {
198
+ throw new Error(`Invalid valueAnchorX: "${valueAnchorX}"`);
230
199
  }
231
200
  const precision = numberPrecision !== undefined && Number.isFinite(numberPrecision)
232
201
  ? clampValue(numberPrecision, 0, 2)
@@ -235,49 +204,41 @@ const createTextNode = ({ icon, label, value, id, unitSymbol, index, showIcons,
235
204
  // (always a number here) is abbreviated via kFormatter.
236
205
  const rawValue = numberFormat.toLowerCase() === 'long' || id === 'prs_merged_percentage';
237
206
  const kValue = rawValue || typeof value !== 'number' ? value : kFormatter(value, precision);
238
- const staggerDelay = (index + 3) * 150;
239
- const boldClass = bold ? ' bold' : 'not_bold';
207
+ const staggerDelay = 120 + index * 40;
208
+ const boldClass = bold ? 'bold' : 'not_bold';
209
+ const labelBoldClass = labelBold ? 'bold' : 'not_bold';
240
210
  const valueX = (showIcons ? 140 : 120) + (bold ? 5 : 0) + shiftValuePos;
241
211
  const unit = unitSymbol ? ` ${unitSymbol}` : '';
242
- const labelOffset = showIcons ? `x="${labelXOffset}"` : '';
243
- const iconSvg = showIcons
244
- ? `
245
- <svg data-testid="icon" class="icon" viewBox="0 0 16 16" version="1.1" width="16" height="16">
246
- ${icon}
247
- </svg>
248
- `
249
- : '';
250
- const content = `
251
- ${iconSvg}
252
- <text class="stat ${boldClass}" ${labelOffset} y="12.5">${encodeHTML(label)}:</text>
253
- <text
254
- class="stat ${boldClass}"
255
- x="${valueX}"
256
- y="12.5"
257
- data-testid="${id}"
258
- >${kValue}${unit}</text>`;
259
- const inner = link ? `<a href="${link}">${content}</a>` : content;
260
- return `
261
- <g class="stagger" style="animation-delay: ${staggerDelay}ms" transform="translate(25, 0)">${inner}
262
- </g>
263
- `;
212
+ const content = [
213
+ showIcons &&
214
+ el('svg', {
215
+ 'data-testid': 'icon',
216
+ class: 'icon',
217
+ viewBox: '0 0 16 16',
218
+ version: '1.1',
219
+ width: 16,
220
+ height: 16,
221
+ }, icon),
222
+ el('text', { class: `stat ${labelBoldClass}`, x: showIcons ? labelXOffset : undefined, y: 12.5 }, `${label}:`),
223
+ el('text', {
224
+ class: `stat ${boldClass}`,
225
+ x: valueAnchorX ?? valueX,
226
+ 'text-anchor': valueAnchorX === undefined ? undefined : 'end',
227
+ y: 12.5,
228
+ 'data-testid': id,
229
+ }, `${String(kValue)}${unit}`),
230
+ ];
231
+ return el('g', {
232
+ class: 'stagger',
233
+ style: `animation-delay: ${staggerDelay}ms`,
234
+ transform: 'translate(25, 0)',
235
+ }, link ? el('a', { href: link }, content) : content);
264
236
  };
265
- // Script parameters.
266
237
  const ERROR_CARD_LENGTH = 576.5;
267
- const UPSTREAM_API_ERRORS = [TRY_AGAIN_LATER, SECONDARY_ERROR_MESSAGES.rate_limited];
238
+ const UPSTREAM_API_ERRORS = new Set([TRY_AGAIN_LATER, SECONDARY_ERROR_MESSAGES.rate_limited]);
268
239
  /**
269
240
  * Renders error message on the card.
270
241
  *
271
- * @param args Function arguments.
272
- * @param args.message Main error message.
273
- * @param args.secondaryMessage The secondary error message.
274
- * @param args.renderOptions Render options.
275
- * @param args.renderOptions.title_color Card title color.
276
- * @param args.renderOptions.text_color Card text color.
277
- * @param args.renderOptions.bg_color Card background color.
278
- * @param args.renderOptions.border_color Card border color.
279
- * @param args.renderOptions.theme Card theme.
280
- * @param args.renderOptions.show_repo_link Whether to show repo link or not.
281
242
  * @returns The SVG markup.
282
243
  */
283
244
  const renderError = ({ message, secondaryMessage = '', renderOptions = {}, }) => {
@@ -291,91 +252,85 @@ const renderError = ({ message, secondaryMessage = '', renderOptions = {}, }) =>
291
252
  ring_color: '',
292
253
  theme,
293
254
  });
294
- return `
295
- <svg width="${ERROR_CARD_LENGTH}" height="120" viewBox="0 0 ${ERROR_CARD_LENGTH} 120" fill="${String(bgColor)}" xmlns="http://www.w3.org/2000/svg" role="img" aria-labelledby="titleId descId">
296
- <title id="titleId">${encodeHTML(message)}</title>
297
- <desc id="descId">${encodeHTML(secondaryMessage)}</desc>
298
- <style>
299
- .text { font: 600 16px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${titleColor} }
300
- .small { font: 600 12px 'Segoe UI', Ubuntu, Sans-Serif; fill: ${textColor} }
301
- .gray { fill: #858585 }
302
- </style>
303
- <rect x="0.5" y="0.5" width="${ERROR_CARD_LENGTH - 1}" height="99%" rx="4.5" fill="${String(bgColor)}" stroke="${borderColor}"/>
304
- <text x="25" y="45" class="text">Something went wrong!${UPSTREAM_API_ERRORS.includes(secondaryMessage) || !show_repo_link
255
+ const hint = UPSTREAM_API_ERRORS.has(secondaryMessage) || !show_repo_link
305
256
  ? ''
306
- : ' file an issue at https://tinyurl.com/github-stats'}</text>
307
- <text data-testid="message" x="25" y="55" class="text small">
308
- <tspan x="25" dy="18">${encodeHTML(message)}</tspan>
309
- <tspan x="25" dy="18" class="gray">${encodeHTML(secondaryMessage)}</tspan>
310
- </text>
311
- </svg>
312
- `;
257
+ : ' file an issue at https://tinyurl.com/github-stats';
258
+ return renderMarkup(el('svg', {
259
+ width: ERROR_CARD_LENGTH,
260
+ height: 120,
261
+ viewBox: `0 0 ${ERROR_CARD_LENGTH} 120`,
262
+ fill: String(bgColor),
263
+ xmlns: 'http://www.w3.org/2000/svg',
264
+ role: 'img',
265
+ 'aria-labelledby': 'title-id desc-id',
266
+ }, el('title', { id: 'title-id' }, message), el('desc', { id: 'desc-id' }, secondaryMessage), style(rule('.text', { font: "600 16px 'Segoe UI', Ubuntu, Sans-Serif", fill: titleColor }), rule('.small', { font: "600 12px 'Segoe UI', Ubuntu, Sans-Serif", fill: textColor }), rule('.gray', { fill: '#858585' })), el('rect', {
267
+ x: 0.5,
268
+ y: 0.5,
269
+ width: ERROR_CARD_LENGTH - 1,
270
+ height: '99%',
271
+ rx: 8,
272
+ fill: String(bgColor),
273
+ stroke: borderColor,
274
+ }), el('text', { x: 25, y: 45, class: 'text' }, `Something went wrong!${hint}`), el('text', { 'data-testid': 'message', x: 25, y: 55, class: 'text small' }, el('tspan', { x: 25, dy: 18 }, message), el('tspan', { x: 25, dy: 18, class: 'gray' }, secondaryMessage))));
313
275
  };
276
+ /** Advance of each ASCII code point, as a fraction of the font size. */
277
+ // prettier-ignore
278
+ const CHAR_WIDTHS = [
279
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
280
+ 0, 0, 0, 0, 0, 0, 0, 0.2733333110809326, 0.28499999046325686,
281
+ 0.39166667461395266, 0.5900000095367431, 0.5383333206176758,
282
+ 0.8183333396911621, 0.8, 0.22999999523162842, 0.30166666507720946,
283
+ 0.30166666507720946, 0.41666665077209475, 0.6833333492279052,
284
+ 0.21666667461395264, 0.4, 0.21666667461395264, 0.3900000095367432,
285
+ 0.5383333206176758, 0.5383333206176758, 0.5383333206176758,
286
+ 0.5383333206176758, 0.5383333206176758, 0.5383333206176758,
287
+ 0.5383333206176758, 0.5383333206176758, 0.5383333206176758,
288
+ 0.5383333206176758, 0.21666667461395264, 0.21666667461395264,
289
+ 0.6833333492279052, 0.6833333492279052, 0.6833333492279052,
290
+ 0.4483333110809326, 0.9550000190734863, 0.6449999809265137,
291
+ 0.5733333110809327, 0.6183333396911621, 0.7016666889190674,
292
+ 0.5066666603088379, 0.48833332061767576, 0.6866666793823242,
293
+ 0.7099999904632568, 0.26666667461395266, 0.35666666030883787,
294
+ 0.5800000190734863, 0.4699999809265137, 0.8983333587646485,
295
+ 0.7483333110809326, 0.753333330154419, 0.5599999904632569,
296
+ 0.753333330154419, 0.5983333110809326, 0.5316666603088379,
297
+ 0.5233333110809326, 0.6866666793823242, 0.621666669845581,
298
+ 0.9333333015441895, 0.5900000095367431, 0.553333330154419,
299
+ 0.5699999809265137, 0.30166666507720946, 0.37833333015441895,
300
+ 0.30166666507720946, 0.6833333492279052, 0.41500000953674315,
301
+ 0.26833333969116213, 0.5083333492279053, 0.5883333206176757,
302
+ 0.4616666793823242, 0.5883333206176757, 0.5233333110809326,
303
+ 0.3133333444595337, 0.5883333206176757, 0.5666666507720948,
304
+ 0.24166667461395264, 0.24166667461395264, 0.49666666984558105,
305
+ 0.24166667461395264, 0.8616666793823242, 0.5666666507720948,
306
+ 0.5866666793823242, 0.5883333206176757, 0.5883333206176757,
307
+ 0.3483333349227905, 0.425, 0.33833334445953367, 0.5666666507720948,
308
+ 0.4783333301544189, 0.7233333110809326, 0.45833334922790525,
309
+ 0.4833333492279053, 0.45166668891906736, 0.30166666507720946,
310
+ 0.24000000953674316, 0.30166666507720946, 0.6833333492279052,
311
+ ];
312
+ /** Advance of a code point the table does not cover. */
313
+ const AVERAGE_CHAR_WIDTH = 0.5131403493881227;
314
+ /**
315
+ * Full-width glyphs: U+3000–U+9FFF (CJK symbols and punctuation, Hiragana, Katakana,
316
+ * CJK Unified Ideographs incl. Extension A) plus U+FF00–U+FFEF (halfwidth and fullwidth forms).
317
+ */
318
+ const FULL_WIDTH_PATTERN = /[\u3000-\u9FFF\uFF00-\uFFEF]/;
314
319
  /**
315
320
  * Retrieve text length based on Segoe UI font.
316
321
  *
317
322
  * @see https://stackoverflow.com/a/48172630/10629172
318
- * @param str String to measure.
319
- * @param fontSize Font size.
323
+ *
320
324
  * @returns Text length.
321
325
  */
322
- const measureText = (str, fontSize = 10) => {
323
- // prettier-ignore
324
- const widths = [
325
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
326
- 0, 0, 0, 0, 0, 0, 0, 0.2733333110809326, 0.28499999046325686,
327
- 0.39166667461395266, 0.5900000095367431, 0.5383333206176758,
328
- 0.8183333396911621, 0.8, 0.22999999523162842, 0.30166666507720946,
329
- 0.30166666507720946, 0.41666665077209475, 0.6833333492279052,
330
- 0.21666667461395264, 0.4, 0.21666667461395264, 0.3900000095367432,
331
- 0.5383333206176758, 0.5383333206176758, 0.5383333206176758,
332
- 0.5383333206176758, 0.5383333206176758, 0.5383333206176758,
333
- 0.5383333206176758, 0.5383333206176758, 0.5383333206176758,
334
- 0.5383333206176758, 0.21666667461395264, 0.21666667461395264,
335
- 0.6833333492279052, 0.6833333492279052, 0.6833333492279052,
336
- 0.4483333110809326, 0.9550000190734863, 0.6449999809265137,
337
- 0.5733333110809327, 0.6183333396911621, 0.7016666889190674,
338
- 0.5066666603088379, 0.48833332061767576, 0.6866666793823242,
339
- 0.7099999904632568, 0.26666667461395266, 0.35666666030883787,
340
- 0.5800000190734863, 0.4699999809265137, 0.8983333587646485,
341
- 0.7483333110809326, 0.753333330154419, 0.5599999904632569,
342
- 0.753333330154419, 0.5983333110809326, 0.5316666603088379,
343
- 0.5233333110809326, 0.6866666793823242, 0.621666669845581,
344
- 0.9333333015441895, 0.5900000095367431, 0.553333330154419,
345
- 0.5699999809265137, 0.30166666507720946, 0.37833333015441895,
346
- 0.30166666507720946, 0.6833333492279052, 0.41500000953674315,
347
- 0.26833333969116213, 0.5083333492279053, 0.5883333206176757,
348
- 0.4616666793823242, 0.5883333206176757, 0.5233333110809326,
349
- 0.3133333444595337, 0.5883333206176757, 0.5666666507720948,
350
- 0.24166667461395264, 0.24166667461395264, 0.49666666984558105,
351
- 0.24166667461395264, 0.8616666793823242, 0.5666666507720948,
352
- 0.5866666793823242, 0.5883333206176757, 0.5883333206176757,
353
- 0.3483333349227905, 0.425, 0.33833334445953367, 0.5666666507720948,
354
- 0.4783333301544189, 0.7233333110809326, 0.45833334922790525,
355
- 0.4833333492279053, 0.45166668891906736, 0.30166666507720946,
356
- 0.24000000953674316, 0.30166666507720946, 0.6833333492279052,
357
- ];
358
- const avg = 0.5131403493881227;
359
- // CJK character range: U+3000–U+9FFF (CJK Symbols/Punctuation, Hiragana,
360
- // Katakana, CJK Unified Ideographs incl. Extension A) plus U+FF00–U+FFEF
361
- // (Halfwidth/Fullwidth Forms — fullwidth ASCII, fullwidth punctuation).
362
- const cjkRange = /[\u3000-\u9FFF\uFF00-\uFFEF]/;
363
- return (str
364
- .split('')
365
- .map((c) => {
366
- if (cjkRange.test(c) || c === '\u3000') {
367
- // CJK glyphs and U+3000 IDEOGRAPHIC SPACE are full-width by default;
368
- return 1;
369
- }
370
- if (c.charCodeAt(0) < widths.length) {
371
- return widths[c.charCodeAt(0)] ?? avg;
372
- }
373
- else {
374
- return avg;
375
- }
376
- })
377
- .reduce((cur, acc) => acc + cur) * fontSize);
378
- };
326
+ const measureText = (str, fontSize = 10) => [...str]
327
+ .map((char) => {
328
+ if (FULL_WIDTH_PATTERN.test(char)) {
329
+ return 1;
330
+ }
331
+ return CHAR_WIDTHS[char.codePointAt(0) ?? 0] ?? AVERAGE_CHAR_WIDTH;
332
+ })
333
+ .reduce((total, width) => total + width, 0) * fontSize;
379
334
  /**
380
335
  * Split text into the lines it would wrap to when laid out greedily at the
381
336
  * given font size inside a box of width `maxWidth`. Uses `measureText` so the
@@ -383,9 +338,6 @@ const measureText = (str, fontSize = 10) => {
383
338
  * The browser still does the real wrap inside the foreignObject; this is only
384
339
  * used to size the SVG.
385
340
  *
386
- * @param text Text to split.
387
- * @param fontSize Font size in px (matches `measureText`).
388
- * @param maxWidth Available wrap width in px.
389
341
  * @returns Estimated wrapped lines.
390
342
  */
391
343
  const splitWrappedText = (text, fontSize, maxWidth) => {
@@ -402,13 +354,13 @@ const splitWrappedText = (text, fontSize, maxWidth) => {
402
354
  // Korean Hangul (U+AC00–U+D7AF) is intentionally NOT in the CJK range
403
355
  // because Korean wraps at word boundaries by default in HTML.
404
356
  // ASCII whitespace is collapsed to a single space per CSS `white-space: normal;`
405
- const normalizedText = text.replace(/[\t\n\r ]+/g, ' ');
357
+ const normalizedText = text.replaceAll(/[\t\n\r ]+/g, ' ');
406
358
  const tokens = normalizedText.match(/\s|[\u3000-\u9FFF\uFF00-\uFFEF]|[^\s\u3000-\u9FFF\uFF00-\uFFEF]+/g);
407
359
  if (!tokens) {
408
360
  return [];
409
361
  }
410
362
  const takeFittingSegment = (token, availableWidth) => {
411
- const characters = token.split('');
363
+ const characters = [...token];
412
364
  let segment = '';
413
365
  let width = 0;
414
366
  for (const character of characters) {
@@ -432,7 +384,7 @@ const splitWrappedText = (text, fontSize, maxWidth) => {
432
384
  if (currentWidth === 0) {
433
385
  continue;
434
386
  }
435
- lines[lines.length - 1] = (lines[lines.length - 1] ?? '') + token;
387
+ lines[lines.length - 1] = (lines.at(-1) ?? '') + token;
436
388
  currentWidth += measureText(token, fontSize);
437
389
  continue;
438
390
  }
@@ -440,7 +392,7 @@ const splitWrappedText = (text, fontSize, maxWidth) => {
440
392
  while (remaining) {
441
393
  const w = measureText(remaining, fontSize);
442
394
  if (currentWidth + w <= maxWidth) {
443
- lines[lines.length - 1] = (lines[lines.length - 1] ?? '') + remaining;
395
+ lines[lines.length - 1] = (lines.at(-1) ?? '') + remaining;
444
396
  currentWidth += w;
445
397
  break;
446
398
  }
@@ -451,24 +403,38 @@ const splitWrappedText = (text, fontSize, maxWidth) => {
451
403
  }
452
404
  // An atom wider than the box wraps mid-glyph (overflow-wrap: anywhere).
453
405
  const { segment, width } = takeFittingSegment(remaining, maxWidth);
454
- lines[lines.length - 1] = (lines[lines.length - 1] ?? '') + segment;
406
+ lines[lines.length - 1] = (lines.at(-1) ?? '') + segment;
455
407
  currentWidth = width;
456
408
  remaining = remaining.slice(segment.length);
457
409
  }
458
410
  }
459
411
  return lines.map((line) => line.replace(/[\t\n\r ]+$/, ''));
460
412
  };
413
+ /**
414
+ * Split text over multiple lines based on the card width.
415
+ *
416
+ * @returns Array of lines.
417
+ */
418
+ const wrapTextMultiline = (text, width, fontSize, maxLines = 3) => {
419
+ const wrapped = splitWrappedText(text, fontSize, width);
420
+ const lines = wrapped.map((line) => line.trim()).slice(0, maxLines); // Only consider maxLines lines
421
+ // Add "..." to the last line if the text exceeds maxLines
422
+ if (wrapped.length > maxLines) {
423
+ const lastIndex = maxLines - 1;
424
+ const lastLine = lines[lastIndex];
425
+ if (lastLine !== undefined) {
426
+ lines[lastIndex] = `${lastLine}...`;
427
+ }
428
+ }
429
+ // Remove empty lines if text fits in less than maxLines lines
430
+ const multiLineText = lines.filter(Boolean);
431
+ return multiLineText;
432
+ };
461
433
  /**
462
434
  * Estimate how many lines a string will wrap to when laid out greedily at the
463
435
  * given font size inside a box of width `maxWidth`, capped at `maxLines`.
464
436
  *
465
- * @param text Text to estimate.
466
- * @param fontSize Font size in px (matches `measureText`).
467
- * @param maxWidth Available wrap width in px.
468
- * @param maxLines Cap on the returned line count.
469
437
  * @returns Estimated line count, at least 1, at most `maxLines`.
470
438
  */
471
- const countWrappedLines = (text, fontSize, maxWidth, maxLines) => {
472
- return Math.min(Math.max(1, splitWrappedText(text, fontSize, maxWidth).length), maxLines);
473
- };
474
- export { renderError, createLanguageNode, createProgressNode, createTextNode, iconWithLabel, flexLayout, measureText, splitWrappedText, countWrappedLines, wrappedTextNode, wrappedTextStyles, };
439
+ const countWrappedLines = (text, fontSize, maxWidth, maxLines) => Math.min(Math.max(1, splitWrappedText(text, fontSize, maxWidth).length), maxLines);
440
+ export { NUMBER_FORMATS, renderError, createLanguageNode, createProgressNode, createTextNode, iconWithLabel, flexLayout, measureText, splitWrappedText, wrapTextMultiline, countWrappedLines, wrappedTextNode, wrappedTextStyles, };