@stats-forge/github-stats-forge-core 0.0.1 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +0 -10
- package/build/api/api-result.d.ts +6 -7
- package/build/api/api-result.d.ts.map +1 -1
- package/build/api/api-result.js +4 -5
- package/build/api/gist.d.ts +3 -10
- package/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +4 -11
- package/build/api/index.d.ts +12 -12
- package/build/api/params.d.ts +11 -8
- package/build/api/params.d.ts.map +1 -1
- package/build/api/params.js +16 -14
- package/build/api/pin.d.ts +3 -19
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +6 -22
- package/build/api/stats.d.ts +10 -4
- package/build/api/stats.d.ts.map +1 -1
- package/build/api/stats.js +6 -32
- package/build/api/top-langs.d.ts +12 -6
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +6 -26
- package/build/api/wakatime.d.ts +13 -5
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +4 -21
- package/build/calculateRank.d.ts +0 -9
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +12 -17
- package/build/cards/gist.d.ts +2 -4
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +27 -36
- package/build/cards/options.d.ts +1 -1
- package/build/cards/repo.d.ts +2 -4
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +61 -93
- package/build/cards/stats.d.ts +3 -8
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +119 -165
- package/build/cards/top-languages.d.ts +5 -31
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +176 -384
- package/build/cards/wakatime.d.ts +4 -6
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +118 -185
- package/build/common/Card.d.ts +14 -62
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +97 -199
- package/build/common/I18n.d.ts +0 -6
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/I18n.js +3 -6
- package/build/common/color.d.ts +4 -17
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +67 -49
- package/build/common/config.d.ts +4 -14
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +3 -16
- package/build/common/constants.d.ts +4 -2
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +3 -1
- package/build/common/date.d.ts +0 -2
- package/build/common/date.d.ts.map +1 -1
- package/build/common/date.js +0 -2
- package/build/common/emojiMap.d.ts +8 -0
- package/build/common/emojiMap.d.ts.map +1 -0
- package/build/common/emojiMap.js +10 -0
- package/build/common/emojiMap.json +1915 -0
- package/build/common/error.d.ts +1 -10
- package/build/common/error.d.ts.map +1 -1
- package/build/common/error.js +1 -10
- package/build/common/fmt.d.ts +3 -15
- package/build/common/fmt.d.ts.map +1 -1
- package/build/common/fmt.js +7 -35
- package/build/common/http.d.ts +2 -7
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +8 -17
- package/build/common/icons.d.ts +18 -20
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +103 -67
- package/build/common/languageColors.d.ts +0 -1
- package/build/common/languageColors.d.ts.map +1 -1
- package/build/common/languageColors.js +1 -4
- package/build/common/languageColors.json +18 -2
- package/build/common/ops.d.ts +3 -14
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +19 -30
- package/build/common/render.d.ts +28 -82
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +175 -211
- package/build/common/retryer.d.ts +2 -7
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +4 -11
- package/build/fetchers/gist.d.ts +2 -5
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +1 -5
- package/build/fetchers/index.d.ts +12 -12
- package/build/fetchers/repo.d.ts +2 -11
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +20 -33
- package/build/fetchers/stats.d.ts +2 -32
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +27 -86
- package/build/fetchers/top-languages.d.ts +2 -9
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +15 -31
- package/build/fetchers/types.d.ts +1 -1
- package/build/fetchers/wakatime.d.ts +2 -6
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +1 -5
- package/build/graphql/contributionsDocument.d.ts +3 -3
- package/build/graphql/contributionsDocument.d.ts.map +1 -1
- package/build/graphql/contributionsDocument.js +0 -1
- package/build/graphql/generated/gist.d.ts +1 -1
- package/build/graphql/generated/repo.d.ts +1 -1
- package/build/graphql/generated/stats.d.ts +3 -3
- package/build/graphql/generated/top-languages.d.ts +2 -2
- package/build/graphql/graphqlDocument.d.ts +0 -1
- package/build/graphql/graphqlDocument.d.ts.map +1 -1
- package/build/graphql/graphqlDocument.js +0 -1
- package/build/graphql/reposContributedToDocument.d.ts +4 -5
- package/build/graphql/reposContributedToDocument.d.ts.map +1 -1
- package/build/graphql/reposContributedToDocument.js +0 -2
- package/build/markup/css.d.ts +35 -0
- package/build/markup/css.d.ts.map +1 -0
- package/build/markup/css.js +64 -0
- package/build/markup/element.d.ts +41 -0
- package/build/markup/element.d.ts.map +1 -0
- package/build/markup/element.js +127 -0
- package/build/markup/html.d.ts +13 -0
- package/build/markup/html.d.ts.map +1 -0
- package/build/markup/html.js +27 -0
- package/build/markup/index.d.ts +9 -0
- package/build/markup/index.d.ts.map +1 -0
- package/build/markup/index.js +6 -0
- package/build/markup/serialize.d.ts +16 -0
- package/build/markup/serialize.d.ts.map +1 -0
- package/build/markup/serialize.js +17 -0
- package/build/themes/index.d.ts +332 -333
- package/build/themes/index.d.ts.map +1 -1
- package/build/themes/index.js +1 -1
- package/build/translations.d.ts +2 -6
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +621 -628
- package/package.json +17 -26
- package/src/api/api-result.ts +10 -9
- package/src/api/gist.ts +11 -18
- package/src/api/index.ts +12 -12
- package/src/api/params.ts +27 -21
- package/src/api/pin.ts +13 -28
- package/src/api/stats.ts +13 -39
- package/src/api/top-langs.ts +13 -33
- package/src/api/wakatime.ts +11 -28
- package/src/calculateRank.ts +12 -23
- package/src/cards/gist.ts +40 -43
- package/src/cards/options.ts +1 -1
- package/src/cards/repo.ts +97 -107
- package/src/cards/stats.ts +165 -184
- package/src/cards/top-languages.ts +297 -413
- package/src/cards/wakatime.ts +193 -221
- package/src/common/Card.ts +165 -217
- package/src/common/I18n.ts +3 -6
- package/src/common/color.ts +80 -57
- package/src/common/config.ts +5 -18
- package/src/common/constants.ts +5 -2
- package/src/common/date.ts +0 -2
- package/src/common/emojiMap.json +1915 -0
- package/src/common/emojiMap.ts +13 -0
- package/src/common/error.ts +2 -11
- package/src/common/fmt.ts +7 -44
- package/src/common/http.ts +9 -15
- package/src/common/icons.ts +117 -42
- package/src/common/languageColors.json +18 -2
- package/src/common/languageColors.ts +1 -4
- package/src/common/ops.ts +26 -34
- package/src/common/render.ts +279 -232
- package/src/common/retryer.ts +8 -15
- package/src/fetchers/gist.ts +8 -12
- package/src/fetchers/index.ts +12 -12
- package/src/fetchers/repo.ts +27 -40
- package/src/fetchers/stats.ts +44 -102
- package/src/fetchers/top-languages.ts +26 -40
- package/src/fetchers/types.ts +1 -1
- package/src/fetchers/wakatime.ts +5 -9
- package/src/graphql/contributionsDocument.ts +7 -5
- package/src/graphql/generated/gist.ts +1 -1
- package/src/graphql/generated/repo.ts +1 -1
- package/src/graphql/generated/stats.ts +2 -2
- package/src/graphql/generated/top-languages.ts +2 -2
- package/src/graphql/graphqlDocument.ts +0 -1
- package/src/graphql/reposContributedToDocument.ts +6 -7
- package/src/markup/css.ts +118 -0
- package/src/markup/element.ts +246 -0
- package/src/markup/html.ts +34 -0
- package/src/markup/index.ts +9 -0
- package/src/markup/serialize.ts +27 -0
- package/src/themes/index.ts +1 -1
- package/src/translations.ts +622 -629
- package/build/cards/index.d.ts +0 -11
- package/build/cards/index.d.ts.map +0 -1
- package/build/cards/index.js +0 -7
- package/build/common/html.d.ts +0 -8
- package/build/common/html.d.ts.map +0 -1
- package/build/common/html.js +0 -14
- package/build/index.d.ts +0 -15
- package/build/index.d.ts.map +0 -1
- package/build/index.js +0 -10
- package/src/_emoji-name-map.d.ts +0 -10
- package/src/_github-username-regex.d.ts +0 -4
- package/src/cards/index.ts +0 -21
- package/src/common/html.ts +0 -17
- package/src/index.ts +0 -18
package/build/common/color.js
CHANGED
|
@@ -1,34 +1,27 @@
|
|
|
1
1
|
import { isThemeName, themes } from '../themes/index.js';
|
|
2
2
|
/** Matches a 3-, 4-, 6-, or 8-digit hex color with no leading `#`. */
|
|
3
|
-
const HEX_COLOR = /^([A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{3})$/;
|
|
3
|
+
const HEX_COLOR = /^(?<digits>[A-Fa-f0-9]{8}|[A-Fa-f0-9]{6}|[A-Fa-f0-9]{4}|[A-Fa-f0-9]{3})$/;
|
|
4
4
|
/**
|
|
5
5
|
* Checks if a value is a bare hex color, i.e. hex digits with no `#` prefix
|
|
6
6
|
* (`"f00"`, `"ffffff"`). This is the form user-supplied color params and
|
|
7
7
|
* gradient stops arrive in.
|
|
8
8
|
*
|
|
9
|
-
* @param value Value to check.
|
|
10
9
|
* @returns True if the value is a bare hex color.
|
|
11
10
|
*/
|
|
12
|
-
const isBareHexColor = (value) =>
|
|
13
|
-
return typeof value === 'string' && HEX_COLOR.test(value);
|
|
14
|
-
};
|
|
11
|
+
const isBareHexColor = (value) => typeof value === 'string' && HEX_COLOR.test(value);
|
|
15
12
|
/**
|
|
16
13
|
* Checks if a value is a `#`-prefixed hex color (`"#f00"`, `"#ffffff"`). This
|
|
17
14
|
* is the form colors take once resolved by {@link getCardColors}, i.e. right
|
|
18
15
|
* before they are written into the SVG.
|
|
19
16
|
*
|
|
20
|
-
* @param value Value to check.
|
|
21
17
|
* @returns True if the value is a `#`-prefixed hex color.
|
|
22
18
|
*/
|
|
23
|
-
const isPrefixedHexColor = (value) =>
|
|
24
|
-
return typeof value === 'string' && value.startsWith('#') && HEX_COLOR.test(value.slice(1));
|
|
25
|
-
};
|
|
19
|
+
const isPrefixedHexColor = (value) => typeof value === 'string' && value.startsWith('#') && HEX_COLOR.test(value.slice(1));
|
|
26
20
|
/**
|
|
27
21
|
* Checks if the given parts form a valid gradient: a finite numeric angle
|
|
28
22
|
* followed by at least two bare-hex color stops, e.g. `["90", "f00", "0f0"]`.
|
|
29
23
|
* The angle is written into the SVG `gradientTransform="rotate(...)"`.
|
|
30
24
|
*
|
|
31
|
-
* @param parts Gradient parts: `[angle, ...stops]`.
|
|
32
25
|
* @returns True if the parts form a valid gradient.
|
|
33
26
|
*/
|
|
34
27
|
const isValidGradient = (parts) => {
|
|
@@ -37,12 +30,11 @@ const isValidGradient = (parts) => {
|
|
|
37
30
|
angle !== undefined &&
|
|
38
31
|
angle.trim() !== '' &&
|
|
39
32
|
Number.isFinite(Number(angle)) &&
|
|
40
|
-
stops.every(isBareHexColor));
|
|
33
|
+
stops.every((stop) => isBareHexColor(stop)));
|
|
41
34
|
};
|
|
42
35
|
/**
|
|
43
36
|
* Checks if a string is a valid input for a color or gradient.
|
|
44
37
|
*
|
|
45
|
-
* @param color String to check, may be null or undefined.
|
|
46
38
|
* @returns True if the given string is a valid input.
|
|
47
39
|
*/
|
|
48
40
|
const isValidColorInput = (color) => {
|
|
@@ -54,11 +46,9 @@ const isValidColorInput = (color) => {
|
|
|
54
46
|
/**
|
|
55
47
|
* Retrieves a gradient if color has more than one valid hex codes else a single color.
|
|
56
48
|
*
|
|
57
|
-
* @param color The color to parse.
|
|
58
|
-
* @param fallbackColor The fallback color.
|
|
59
49
|
* @returns The gradient or color.
|
|
60
50
|
*/
|
|
61
|
-
const fallbackColor = (color,
|
|
51
|
+
const fallbackColor = (color, fallback) => {
|
|
62
52
|
const colors = color ? color.split(',') : [];
|
|
63
53
|
if (colors.length > 1 && isValidGradient(colors)) {
|
|
64
54
|
return colors;
|
|
@@ -66,7 +56,39 @@ const fallbackColor = (color, fallbackColor) => {
|
|
|
66
56
|
if (color !== undefined && isBareHexColor(color)) {
|
|
67
57
|
return `#${color}`;
|
|
68
58
|
}
|
|
69
|
-
return
|
|
59
|
+
return fallback;
|
|
60
|
+
};
|
|
61
|
+
/** Border a light background gets when neither the user nor the theme names one. */
|
|
62
|
+
const LIGHT_BG_BORDER = '#0000001f';
|
|
63
|
+
/** Border a dark background gets when neither the user nor the theme names one. */
|
|
64
|
+
const DARK_BG_BORDER = '#ffffff26';
|
|
65
|
+
/** Border a see-through background gets: neutral, since the page behind it decides the contrast. */
|
|
66
|
+
const TRANSLUCENT_BG_BORDER = '#8b949e59';
|
|
67
|
+
/**
|
|
68
|
+
* @returns Its `[r, g, b, a]` channels, each on 0–1.
|
|
69
|
+
*/
|
|
70
|
+
const hexChannels = (hex) => {
|
|
71
|
+
const digits = hex.slice(1);
|
|
72
|
+
const expanded = digits.length <= 4 ? [...digits].map((digit) => digit + digit).join('') : digits;
|
|
73
|
+
const channel = (index) => Number.parseInt(expanded.slice(index * 2, index * 2 + 2), 16) / 255;
|
|
74
|
+
return [channel(0), channel(1), channel(2), expanded.length === 8 ? channel(3) : 1];
|
|
75
|
+
};
|
|
76
|
+
/**
|
|
77
|
+
* Derives a border from the background, so a dark card never gets a light hairline.
|
|
78
|
+
*
|
|
79
|
+
* @returns A translucent `#`-prefixed hex border color.
|
|
80
|
+
*/
|
|
81
|
+
const borderColorFor = (bgColor) => {
|
|
82
|
+
// A gradient is judged by its first stop.
|
|
83
|
+
const hex = typeof bgColor === 'string' ? bgColor : `#${bgColor[1] ?? ''}`;
|
|
84
|
+
if (!isPrefixedHexColor(hex)) {
|
|
85
|
+
return LIGHT_BG_BORDER;
|
|
86
|
+
}
|
|
87
|
+
const [r, g, b, a] = hexChannels(hex);
|
|
88
|
+
if (a < 0.5) {
|
|
89
|
+
return TRANSLUCENT_BG_BORDER;
|
|
90
|
+
}
|
|
91
|
+
return 0.2126 * r + 0.7152 * g + 0.0722 * b < 0.5 ? DARK_BG_BORDER : LIGHT_BG_BORDER;
|
|
70
92
|
};
|
|
71
93
|
/**
|
|
72
94
|
* Every color param a card accepts, before any `_light` / `_dark` suffix.
|
|
@@ -88,30 +110,18 @@ const THEME_VARIANTS = ['light', 'dark'];
|
|
|
88
110
|
/**
|
|
89
111
|
* Returns theme based colors with proper overrides and defaults.
|
|
90
112
|
*
|
|
91
|
-
* @param props Function arguments.
|
|
92
|
-
* @param props.title_color Card title color.
|
|
93
|
-
* @param props.text_color Card text color.
|
|
94
|
-
* @param props.icon_color Card icon color.
|
|
95
|
-
* @param props.bg_color Card background color.
|
|
96
|
-
* @param props.border_color Card border color.
|
|
97
|
-
* @param props.ring_color Card ring color.
|
|
98
|
-
* @param props.prog_bar_bg_color Progress bar background color.
|
|
99
|
-
* @param props.theme Card theme.
|
|
100
113
|
* @returns Card colors.
|
|
101
114
|
*/
|
|
102
115
|
const getCardColors = ({ title_color, text_color, icon_color, bg_color, border_color, ring_color, prog_bar_bg_color, theme, }) => {
|
|
103
116
|
const defaultTheme = themes.default;
|
|
104
117
|
const selectedTheme = isThemeName(theme) ? themes[theme] : defaultTheme;
|
|
105
|
-
const
|
|
106
|
-
//
|
|
107
|
-
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
const
|
|
112
|
-
const textColor = fallbackColor(text_color || selectedTheme.text_color, '#' + defaultTheme.text_color);
|
|
113
|
-
const bgColor = fallbackColor(bg_color || selectedTheme.bg_color, '#' + defaultTheme.bg_color);
|
|
114
|
-
const borderColor = fallbackColor(border_color || defaultBorderColor, '#' + defaultBorderColor);
|
|
118
|
+
const themeBorderColor = 'border_color' in selectedTheme ? selectedTheme.border_color : undefined;
|
|
119
|
+
// Each color is the user's, else the selected theme's, else the default theme's.
|
|
120
|
+
const titleColor = fallbackColor(title_color || selectedTheme.title_color, `#${defaultTheme.title_color}`);
|
|
121
|
+
const iconColor = fallbackColor(icon_color || selectedTheme.icon_color, `#${defaultTheme.icon_color}`);
|
|
122
|
+
const textColor = fallbackColor(text_color || selectedTheme.text_color, `#${defaultTheme.text_color}`);
|
|
123
|
+
const bgColor = fallbackColor(bg_color || selectedTheme.bg_color, `#${defaultTheme.bg_color}`);
|
|
124
|
+
const borderColor = fallbackColor(border_color || themeBorderColor, borderColorFor(bgColor));
|
|
115
125
|
// No theme defines `ring_color`, so it falls back to the title color.
|
|
116
126
|
const ringColor = fallbackColor(ring_color, titleColor);
|
|
117
127
|
// No theme defines `prog_bar_bg_color`, so it falls back to "#ddd".
|
|
@@ -122,7 +132,7 @@ const getCardColors = ({ title_color, text_color, icon_color, bg_color, border_c
|
|
|
122
132
|
typeof progBarBgColor !== 'string' ||
|
|
123
133
|
typeof iconColor !== 'string' ||
|
|
124
134
|
typeof borderColor !== 'string') {
|
|
125
|
-
throw new
|
|
135
|
+
throw new TypeError('Unexpected behavior, all colors except background should be string.');
|
|
126
136
|
}
|
|
127
137
|
return {
|
|
128
138
|
titleColor,
|
|
@@ -138,11 +148,23 @@ const getCardColors = ({ title_color, text_color, icon_color, bg_color, border_c
|
|
|
138
148
|
* Returns the light- or dark-mode-specific color params, given a set of
|
|
139
149
|
* raw query params. Also removes the "_light" or "_dark" suffixes.
|
|
140
150
|
*
|
|
141
|
-
* @param params Raw query params with optional `_light` / `_dark` suffixes.
|
|
142
|
-
* @param suffix `"_light"` or `"_dark"`.
|
|
143
151
|
* @returns ColorInput with the suffix stripped, ready for `getCardColors`.
|
|
144
152
|
*/
|
|
145
|
-
const extractLightDarkColors = (params, suffix) =>
|
|
153
|
+
const extractLightDarkColors = (params, suffix) => {
|
|
154
|
+
const colors = {};
|
|
155
|
+
for (const key of BASE_COLOR_KEYS) {
|
|
156
|
+
const value = params[`${key}${suffix}`];
|
|
157
|
+
if (value !== undefined) {
|
|
158
|
+
colors[key] = value;
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return colors;
|
|
162
|
+
};
|
|
163
|
+
/**
|
|
164
|
+
* Every suffixed key, so asking "any per-scheme colors at all?" is one pass over names,
|
|
165
|
+
* not two objects built to be thrown away.
|
|
166
|
+
*/
|
|
167
|
+
const MODE_OVERRIDE_KEYS = THEME_VARIANTS.flatMap((variant) => BASE_COLOR_KEYS.map((key) => `${key}_${variant}`));
|
|
146
168
|
/**
|
|
147
169
|
* Returns resolved colors for both light and dark mode given all input params.
|
|
148
170
|
*
|
|
@@ -154,23 +176,19 @@ const extractLightDarkColors = (params, suffix) => Object.fromEntries(BASE_COLOR
|
|
|
154
176
|
* Anything a mode does not override falls back to the general params,
|
|
155
177
|
* so a partial override such as `bg_color_dark` alone keeps every other color from the base theme.
|
|
156
178
|
*
|
|
157
|
-
* When no `_light` / `_dark` param is provided at all,
|
|
179
|
+
* When no `_light` / `_dark` param is provided at all,
|
|
180
|
+
* `darkColors` is `null` and the caller emits no dark-mode block.
|
|
158
181
|
*
|
|
159
|
-
* @param params Raw query params, containing both general and `_light`/`_dark` suffixed colors and themes.
|
|
160
182
|
* @returns `{ lightColors, darkColors }`, resolved colors for both light and dark mode
|
|
161
183
|
*/
|
|
162
184
|
const getLightDarkColors = (params) => {
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const hasModeOverrides = Object.values(lightOverrides).some((v) => v !== undefined) ||
|
|
166
|
-
Object.values(darkOverrides).some((v) => v !== undefined);
|
|
167
|
-
if (!hasModeOverrides) {
|
|
185
|
+
// The common case is no per-scheme params at all, so it never builds the overrides.
|
|
186
|
+
if (!MODE_OVERRIDE_KEYS.some((key) => params[key] !== undefined)) {
|
|
168
187
|
return { lightColors: getCardColors(params), darkColors: null };
|
|
169
188
|
}
|
|
170
|
-
const defined = (obj) => Object.fromEntries(Object.entries(obj).filter(([, v]) => v !== undefined));
|
|
171
189
|
return {
|
|
172
|
-
lightColors: getCardColors({ ...params, ...
|
|
173
|
-
darkColors: getCardColors({ ...params, ...
|
|
190
|
+
lightColors: getCardColors({ ...params, ...extractLightDarkColors(params, '_light') }),
|
|
191
|
+
darkColors: getCardColors({ ...params, ...extractLightDarkColors(params, '_dark') }),
|
|
174
192
|
};
|
|
175
193
|
};
|
|
176
194
|
const COLOR_PARAM_KEYS = [
|
package/build/common/config.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { FetchLike } from './http.
|
|
1
|
+
import type { FetchLike } from './http.ts';
|
|
2
2
|
type Env = Record<string, string | undefined>;
|
|
3
3
|
interface PersonalAccessToken {
|
|
4
4
|
/** Env variable the token came from — the retryer logs this name, never the value. */
|
|
@@ -32,21 +32,11 @@ export declare class CardConfig {
|
|
|
32
32
|
/** Transport every fetcher sends through; defaults to `globalThis.fetch`. */
|
|
33
33
|
readonly fetch: FetchLike;
|
|
34
34
|
constructor(init?: CardConfigInit);
|
|
35
|
-
/**
|
|
36
|
-
* @param env Environment variables to read — the host passes `process.env` or an equivalent.
|
|
37
|
-
* @returns Config for this deployment.
|
|
38
|
-
*/
|
|
35
|
+
/** @returns Config for this deployment. */
|
|
39
36
|
static fromEnv(env: Env): CardConfig;
|
|
40
|
-
/**
|
|
41
|
-
* @param id Username or gist id being requested.
|
|
42
|
-
* @param kind Which allowlist applies.
|
|
43
|
-
* @returns Whether this deployment serves the id.
|
|
44
|
-
*/
|
|
37
|
+
/** @returns Whether this deployment serves the id. */
|
|
45
38
|
isAllowed(id: string, kind: 'username' | 'gist'): boolean;
|
|
46
|
-
/**
|
|
47
|
-
* @param overrides Fields to replace.
|
|
48
|
-
* @returns A copy with `overrides` applied — how a host swaps in a user's PAT per request.
|
|
49
|
-
*/
|
|
39
|
+
/** @returns A copy with `overrides` applied — how a host swaps in a user's PAT per request. */
|
|
50
40
|
with(overrides: CardConfigInit): CardConfig;
|
|
51
41
|
}
|
|
52
42
|
export type { PersonalAccessToken, CardConfigInit };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/common/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAE9C,UAAU,mBAAmB;IAC3B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qFAAqF;AACrF,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC1C,iBAAiB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACtD,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAClD,mBAAmB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../src/common/config.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,SAAS,CAAC,CAAC;AAE9C,UAAU,mBAAmB;IAC3B,sFAAsF;IACtF,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;CACf;AAED,qFAAqF;AACrF,UAAU,cAAc;IACtB,IAAI,CAAC,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAC1C,iBAAiB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IACtD,aAAa,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAClD,mBAAmB,CAAC,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IAC5C,mBAAmB,CAAC,EAAE,MAAM,CAAC;IAC7B,KAAK,CAAC,EAAE,SAAS,CAAC;CACnB;AA2BD;;;;;GAKG;AACH,qBAAa,UAAU;IACrB,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC,mBAAmB,CAAC,CAAC;IAClD,oEAAoE;IACpE,QAAQ,CAAC,iBAAiB,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAC9D,mEAAmE;IACnE,QAAQ,CAAC,aAAa,EAAE,aAAa,CAAC,MAAM,CAAC,GAAG,SAAS,CAAC;IAC1D,QAAQ,CAAC,mBAAmB,EAAE,aAAa,CAAC,MAAM,CAAC,CAAC;IACpD,mFAAmF;IACnF,QAAQ,CAAC,mBAAmB,EAAE,MAAM,CAAC;IACrC,6EAA6E;IAC7E,QAAQ,CAAC,KAAK,EAAE,SAAS,CAAC;IAE1B,YAAY,IAAI,GAAE,cAAmB,EAOpC;IAED,2CAA2C;IAC3C,MAAM,CAAC,OAAO,CAAC,GAAG,EAAE,GAAG,GAAG,UAAU,CAQnC;IAED,sDAAsD;IACtD,SAAS,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,UAAU,GAAG,MAAM,GAAG,OAAO,CAGxD;IAED,+FAA+F;IAC/F,IAAI,CAAC,SAAS,EAAE,cAAc,GAAG,UAAU,CAU1C;CACF;AAED,YAAY,EAAE,mBAAmB,EAAE,cAAc,EAAE,CAAC"}
|
package/build/common/config.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
1
|
import { defaultFetch } from './http.js';
|
|
2
2
|
/**
|
|
3
|
-
* @param value Comma-separated string.
|
|
4
3
|
* @returns Parsed string values.
|
|
5
4
|
*/
|
|
6
5
|
const parseCsv = (value) => value ? value.split(',') : undefined;
|
|
7
6
|
/**
|
|
8
|
-
* @param value Raw `FETCH_MULTI_PAGE_STARS` value.
|
|
9
7
|
* @returns Page limit: `"true"` means every page, a positive number caps the pages, anything else means one.
|
|
10
8
|
*/
|
|
11
9
|
const parseFetchMultiPageStars = (value) => {
|
|
@@ -16,7 +14,6 @@ const parseFetchMultiPageStars = (value) => {
|
|
|
16
14
|
return limit > 0 ? limit : 1;
|
|
17
15
|
};
|
|
18
16
|
/**
|
|
19
|
-
* @param env Environment variables to inspect.
|
|
20
17
|
* @returns Personal access tokens found in the environment.
|
|
21
18
|
*/
|
|
22
19
|
const parsePATsFromEnv = (env) => Object.keys(env)
|
|
@@ -47,10 +44,7 @@ export class CardConfig {
|
|
|
47
44
|
this.fetchMultiPageStars = init.fetchMultiPageStars ?? 1;
|
|
48
45
|
this.fetch = init.fetch ?? defaultFetch;
|
|
49
46
|
}
|
|
50
|
-
/**
|
|
51
|
-
* @param env Environment variables to read — the host passes `process.env` or an equivalent.
|
|
52
|
-
* @returns Config for this deployment.
|
|
53
|
-
*/
|
|
47
|
+
/** @returns Config for this deployment. */
|
|
54
48
|
static fromEnv(env) {
|
|
55
49
|
return new CardConfig({
|
|
56
50
|
pats: parsePATsFromEnv(env),
|
|
@@ -60,19 +54,12 @@ export class CardConfig {
|
|
|
60
54
|
fetchMultiPageStars: parseFetchMultiPageStars(env['FETCH_MULTI_PAGE_STARS']),
|
|
61
55
|
});
|
|
62
56
|
}
|
|
63
|
-
/**
|
|
64
|
-
* @param id Username or gist id being requested.
|
|
65
|
-
* @param kind Which allowlist applies.
|
|
66
|
-
* @returns Whether this deployment serves the id.
|
|
67
|
-
*/
|
|
57
|
+
/** @returns Whether this deployment serves the id. */
|
|
68
58
|
isAllowed(id, kind) {
|
|
69
59
|
const list = kind === 'gist' ? this.gistAllowlist : this.usernameAllowlist;
|
|
70
60
|
return list === undefined || list.includes(id);
|
|
71
61
|
}
|
|
72
|
-
/**
|
|
73
|
-
* @param overrides Fields to replace.
|
|
74
|
-
* @returns A copy with `overrides` applied — how a host swaps in a user's PAT per request.
|
|
75
|
-
*/
|
|
62
|
+
/** @returns A copy with `overrides` applied — how a host swaps in a user's PAT per request. */
|
|
76
63
|
with(overrides) {
|
|
77
64
|
return new CardConfig({
|
|
78
65
|
pats: this.pats,
|
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
import type { RepositoryAffiliation } from '../graphql/generated/common.
|
|
1
|
+
import type { RepositoryAffiliation } from '../graphql/generated/common.ts';
|
|
2
|
+
/** A GitHub login: alphanumerics and single inner hyphens, 39 characters at most. */
|
|
3
|
+
declare const GITHUB_USERNAME_PATTERN: RegExp;
|
|
2
4
|
/**
|
|
3
5
|
* Valid owner affiliations for GitHub API queries.
|
|
4
6
|
*/
|
|
5
7
|
declare const OWNER_AFFILIATIONS: Array<RepositoryAffiliation>;
|
|
6
|
-
export { OWNER_AFFILIATIONS };
|
|
8
|
+
export { GITHUB_USERNAME_PATTERN, OWNER_AFFILIATIONS };
|
|
7
9
|
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E;;GAEG;AACH,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,qBAAqB,CAIpD,CAAC;AAEF,OAAO,EAAE,kBAAkB,EAAE,CAAC"}
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../src/common/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,gCAAgC,CAAC;AAE5E,qFAAqF;AACrF,QAAA,MAAM,uBAAuB,QAA6C,CAAC;AAE3E;;GAEG;AACH,QAAA,MAAM,kBAAkB,EAAE,KAAK,CAAC,qBAAqB,CAIpD,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,CAAC"}
|
|
@@ -1,3 +1,5 @@
|
|
|
1
|
+
/** A GitHub login: alphanumerics and single inner hyphens, 39 characters at most. */
|
|
2
|
+
const GITHUB_USERNAME_PATTERN = /^[a-z\d](?:[a-z\d]|-(?=[a-z\d])){0,38}$/i;
|
|
1
3
|
/**
|
|
2
4
|
* Valid owner affiliations for GitHub API queries.
|
|
3
5
|
*/
|
|
@@ -6,4 +8,4 @@ const OWNER_AFFILIATIONS = [
|
|
|
6
8
|
'COLLABORATOR',
|
|
7
9
|
'ORGANIZATION_MEMBER',
|
|
8
10
|
];
|
|
9
|
-
export { OWNER_AFFILIATIONS };
|
|
11
|
+
export { GITHUB_USERNAME_PATTERN, OWNER_AFFILIATIONS };
|
package/build/common/date.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ interface GitHubDateRange {
|
|
|
9
9
|
* Format a date as a GitHub `DateTime` scalar.
|
|
10
10
|
* Seconds precision, no milliseconds.
|
|
11
11
|
*
|
|
12
|
-
* @param date Date to format.
|
|
13
12
|
* @returns e.g. `2024-01-01T00:00:00Z`.
|
|
14
13
|
*/
|
|
15
14
|
declare const toGitHubDateTime: (date: Date) => string;
|
|
@@ -20,7 +19,6 @@ declare const toGitHubDateTime: (date: Date) => string;
|
|
|
20
19
|
* GitHub's `contributionsCollection` defaults `to` to one year after `from`,
|
|
21
20
|
* which pulls the next 1st of January into the year.
|
|
22
21
|
*
|
|
23
|
-
* @param year Four-digit year.
|
|
24
22
|
* @returns The range covering it.
|
|
25
23
|
*/
|
|
26
24
|
declare const getGitHubYearRange: (year: number) => GitHubDateRange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/common/date.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,UAAU,eAAe;IACvB,qCAAqC;IACrC,IAAI,EAAE,IAAI,CAAC;IACX,mCAAmC;IACnC,EAAE,EAAE,IAAI,CAAC;CACV;AAED
|
|
1
|
+
{"version":3,"file":"date.d.ts","sourceRoot":"","sources":["../../src/common/date.ts"],"names":[],"mappings":"AAAA,qEAAqE;AACrE,UAAU,eAAe;IACvB,qCAAqC;IACrC,IAAI,EAAE,IAAI,CAAC;IACX,mCAAmC;IACnC,EAAE,EAAE,IAAI,CAAC;CACV;AAED;;;;;GAKG;AACH,QAAA,MAAM,gBAAgB,SAAU,IAAI,KAAG,MAA+C,CAAC;AAEvF;;;;;;;;GAQG;AACH,QAAA,MAAM,kBAAkB,SAAU,MAAM,KAAG,eAGzC,CAAC;AAEH,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,CAAC;AAChD,YAAY,EAAE,eAAe,EAAE,CAAC"}
|
package/build/common/date.js
CHANGED
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Format a date as a GitHub `DateTime` scalar.
|
|
3
3
|
* Seconds precision, no milliseconds.
|
|
4
4
|
*
|
|
5
|
-
* @param date Date to format.
|
|
6
5
|
* @returns e.g. `2024-01-01T00:00:00Z`.
|
|
7
6
|
*/
|
|
8
7
|
const toGitHubDateTime = (date) => `${date.toISOString().slice(0, 19)}Z`;
|
|
@@ -13,7 +12,6 @@ const toGitHubDateTime = (date) => `${date.toISOString().slice(0, 19)}Z`;
|
|
|
13
12
|
* GitHub's `contributionsCollection` defaults `to` to one year after `from`,
|
|
14
13
|
* which pulls the next 1st of January into the year.
|
|
15
14
|
*
|
|
16
|
-
* @param year Four-digit year.
|
|
17
15
|
* @returns The range covering it.
|
|
18
16
|
*/
|
|
19
17
|
const getGitHubYearRange = (year) => ({
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Resolves a GitHub emoji shortcode to its unicode character.
|
|
3
|
+
*
|
|
4
|
+
* @returns The emoji, or `undefined` when GitHub has no such shortcode.
|
|
5
|
+
*/
|
|
6
|
+
declare const getEmoji: (name: string) => string | undefined;
|
|
7
|
+
export { getEmoji };
|
|
8
|
+
//# sourceMappingURL=emojiMap.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"emojiMap.d.ts","sourceRoot":"","sources":["../../src/common/emojiMap.ts"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,QAAA,MAAM,QAAQ,SAAU,MAAM,KAAG,MAAM,GAAG,SAA2B,CAAC;AAEtE,OAAO,EAAE,QAAQ,EAAE,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import emojiMapJson from './emojiMap.json' with { type: 'json' };
|
|
2
|
+
// The generated JSON types has literal keys; index it as a plain lookup table.
|
|
3
|
+
const emojiMap = emojiMapJson;
|
|
4
|
+
/**
|
|
5
|
+
* Resolves a GitHub emoji shortcode to its unicode character.
|
|
6
|
+
*
|
|
7
|
+
* @returns The emoji, or `undefined` when GitHub has no such shortcode.
|
|
8
|
+
*/
|
|
9
|
+
const getEmoji = (name) => emojiMap[name];
|
|
10
|
+
export { getEmoji };
|