@stats-organization/github-readme-stats-core 2.1.3 → 2.1.5
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/build/api/gist.d.ts.map +1 -1
- package/build/api/gist.js +34 -1
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +18 -1
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +17 -1
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +36 -5
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +34 -1
- package/build/calculateRank.d.ts +12 -11
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +18 -18
- package/build/cards/gist.d.ts.map +1 -1
- package/build/cards/gist.js +0 -1
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +29 -21
- package/build/cards/stats.d.ts +4 -2
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +21 -9
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +39 -12
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +29 -9
- package/build/common/Card.d.ts +54 -60
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +88 -61
- package/build/common/I18n.d.ts +13 -14
- package/build/common/I18n.d.ts.map +1 -1
- package/build/common/I18n.js +13 -12
- package/build/common/color.d.ts +56 -32
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +87 -50
- package/build/common/config.d.ts +18 -2
- package/build/common/config.d.ts.map +1 -1
- package/build/common/config.js +17 -26
- package/build/common/constants.d.ts +2 -2
- package/build/common/constants.d.ts.map +1 -1
- package/build/common/constants.js +5 -3
- package/build/common/error.d.ts +36 -29
- package/build/common/error.d.ts.map +1 -1
- package/build/common/error.js +14 -10
- package/build/common/fmt.d.ts +14 -13
- package/build/common/fmt.d.ts.map +1 -1
- package/build/common/fmt.js +19 -15
- package/build/common/html.d.ts +2 -4
- package/build/common/html.d.ts.map +1 -1
- package/build/common/html.js +2 -6
- package/build/common/http.d.ts +13 -4
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +3 -4
- package/build/common/icons.d.ts +22 -21
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +4 -5
- package/build/common/languageColors.json +9 -1
- package/build/common/ops.d.ts +30 -29
- package/build/common/ops.d.ts.map +1 -1
- package/build/common/ops.js +32 -38
- package/build/common/render.d.ts +115 -111
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +138 -88
- package/build/common/retryer.d.ts +24 -13
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +22 -30
- package/build/fetchers/gist.d.ts +6 -21
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +30 -36
- package/build/fetchers/repo.d.ts.map +1 -1
- package/build/fetchers/repo.js +4 -7
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.js +3 -7
- package/build/fetchers/top-languages.d.ts.map +1 -1
- package/build/fetchers/top-languages.js +0 -1
- package/build/fetchers/types.d.ts +126 -0
- package/build/fetchers/types.d.ts.map +1 -0
- package/build/fetchers/types.js +1 -0
- package/build/fetchers/wakatime.d.ts.map +1 -1
- package/build/fetchers/wakatime.js +0 -1
- package/build/translations.d.ts +627 -24
- package/build/translations.d.ts.map +1 -1
- package/build/translations.js +7 -8
- package/package.json +4 -4
- package/src/_emoji-name-map.d.ts +10 -0
- package/src/api/gist.js +36 -2
- package/src/api/index.js +19 -2
- package/src/api/pin.js +18 -2
- package/src/api/top-langs.js +38 -6
- package/src/api/wakatime.js +36 -2
- package/src/{calculateRank.js → calculateRank.ts} +29 -19
- package/src/cards/gist.js +0 -2
- package/src/cards/repo.js +30 -22
- package/src/cards/stats.js +22 -10
- package/src/cards/top-languages.js +49 -13
- package/src/cards/wakatime.js +33 -10
- package/src/common/Card.ts +338 -0
- package/src/common/I18n.ts +49 -0
- package/src/common/color.ts +212 -0
- package/src/common/config.ts +83 -0
- package/src/common/constants.ts +10 -0
- package/src/common/{error.js → error.ts} +20 -14
- package/src/common/{fmt.js → fmt.ts} +27 -19
- package/src/common/{html.js → html.ts} +3 -8
- package/src/common/http.ts +31 -0
- package/src/common/{icons.js → icons.ts} +9 -7
- package/src/common/languageColors.json +9 -1
- package/src/common/{ops.js → ops.ts} +48 -52
- package/src/common/{render.js → render.ts} +208 -98
- package/src/common/retryer.ts +125 -0
- package/src/fetchers/gist.ts +136 -0
- package/src/fetchers/repo.js +4 -8
- package/src/fetchers/stats.js +3 -8
- package/src/fetchers/top-languages.js +0 -2
- package/src/fetchers/{types.d.ts → types.ts} +1 -1
- package/src/fetchers/wakatime.js +0 -2
- package/src/{translations.js → translations.ts} +14 -10
- package/src/common/Card.js +0 -275
- package/src/common/I18n.js +0 -42
- package/src/common/color.js +0 -145
- package/src/common/config.js +0 -78
- package/src/common/constants.js +0 -9
- package/src/common/http.js +0 -21
- package/src/common/retryer.js +0 -104
- package/src/fetchers/gist.js +0 -114
package/build/common/ops.d.ts
CHANGED
|
@@ -1,65 +1,66 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Returns boolean if value is either "true" or "false" else the value as it is.
|
|
3
3
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @returns
|
|
4
|
+
* @param value The value to parse.
|
|
5
|
+
* @returns The parsed value.
|
|
6
6
|
*/
|
|
7
|
-
|
|
7
|
+
declare const parseBoolean: (value: string | boolean) => boolean | undefined;
|
|
8
8
|
/**
|
|
9
9
|
* Parse string to array of strings.
|
|
10
10
|
*
|
|
11
|
-
* @param
|
|
12
|
-
* @returns
|
|
11
|
+
* @param str The string to parse.
|
|
12
|
+
* @returns The array of strings.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
declare const parseArray: (str: string) => Array<string>;
|
|
15
15
|
/**
|
|
16
16
|
* Clamp the given number between the given range.
|
|
17
17
|
*
|
|
18
|
-
* @param
|
|
19
|
-
* @param
|
|
20
|
-
* @param
|
|
21
|
-
* @returns
|
|
18
|
+
* @param number The number to clamp.
|
|
19
|
+
* @param min The minimum value.
|
|
20
|
+
* @param max The maximum value.
|
|
21
|
+
* @returns The clamped number.
|
|
22
22
|
*/
|
|
23
|
-
|
|
23
|
+
declare const clampValue: (number: string | number, min: number, max: number) => number;
|
|
24
24
|
/**
|
|
25
25
|
* Lowercase and trim string.
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @returns
|
|
27
|
+
* @param name String to lowercase and trim.
|
|
28
|
+
* @returns Lowercased and trimmed string.
|
|
29
29
|
*/
|
|
30
|
-
|
|
30
|
+
declare const lowercaseTrim: (name: string) => string;
|
|
31
31
|
/**
|
|
32
32
|
* Split array of languages in two columns.
|
|
33
33
|
*
|
|
34
34
|
* @template T Language object.
|
|
35
|
-
* @param
|
|
36
|
-
* @param
|
|
37
|
-
* @returns
|
|
35
|
+
* @param arr Array of languages.
|
|
36
|
+
* @param perChunk Number of languages per column.
|
|
37
|
+
* @returns Array of languages split in two columns.
|
|
38
38
|
*/
|
|
39
|
-
|
|
39
|
+
declare const chunkArray: <T>(arr: Array<T>, perChunk: number) => Array<Array<T>>;
|
|
40
40
|
/**
|
|
41
41
|
* Parse emoji from string.
|
|
42
42
|
*
|
|
43
|
-
* @param
|
|
44
|
-
* @returns
|
|
43
|
+
* @param str String to parse emoji from.
|
|
44
|
+
* @returns String with emoji parsed.
|
|
45
45
|
*/
|
|
46
|
-
|
|
46
|
+
declare const parseEmojis: (str: string) => string;
|
|
47
47
|
/**
|
|
48
48
|
* Get diff in minutes between two dates.
|
|
49
49
|
*
|
|
50
|
-
* @param
|
|
51
|
-
* @param
|
|
52
|
-
* @returns
|
|
50
|
+
* @param d1 First date.
|
|
51
|
+
* @param d2 Second date.
|
|
52
|
+
* @returns Number of minutes between the two dates.
|
|
53
53
|
*/
|
|
54
|
-
|
|
54
|
+
declare const dateDiff: (d1: Date, d2: Date) => number;
|
|
55
55
|
/**
|
|
56
56
|
* Parse owner affiliations.
|
|
57
57
|
*
|
|
58
|
-
* @param
|
|
59
|
-
* @returns
|
|
58
|
+
* @param affiliations input affiliations to be parsed.
|
|
59
|
+
* @returns Parsed affiliations.
|
|
60
60
|
*
|
|
61
61
|
* @throws {CustomError} If affiliations contains invalid values.
|
|
62
62
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
63
|
+
declare const parseOwnerAffiliations: (affiliations: Array<string>) => Array<string>;
|
|
64
|
+
declare const buildSearchFilter: (repos?: Array<string> | string, owners?: Array<string> | string) => string;
|
|
65
|
+
export { parseBoolean, parseArray, clampValue, lowercaseTrim, chunkArray, parseEmojis, dateDiff, parseOwnerAffiliations, buildSearchFilter, };
|
|
65
66
|
//# sourceMappingURL=ops.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../src/common/ops.
|
|
1
|
+
{"version":3,"file":"ops.d.ts","sourceRoot":"","sources":["../../src/common/ops.ts"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,QAAA,MAAM,YAAY,GAAI,OAAO,MAAM,GAAG,OAAO,KAAG,OAAO,GAAG,SAazD,CAAC;AAEF;;;;;GAKG;AACH,QAAA,MAAM,UAAU,GAAI,KAAK,MAAM,KAAG,KAAK,CAAC,MAAM,CAK7C,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,UAAU,GACd,QAAQ,MAAM,GAAG,MAAM,EACvB,KAAK,MAAM,EACX,KAAK,MAAM,KACV,MAKF,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;AAEF;;;;;;GAMG;AACH,QAAA,MAAM,QAAQ,GAAI,IAAI,IAAI,EAAE,IAAI,IAAI,KAAG,MAKtC,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,sBAAsB,GAAI,cAAc,KAAK,CAAC,MAAM,CAAC,KAAG,KAAK,CAAC,MAAM,CAmBzE,CAAC;AAEF,QAAA,MAAM,iBAAiB,GACrB,QAAO,KAAK,CAAC,MAAM,CAAC,GAAG,MAAW,EAClC,SAAQ,KAAK,CAAC,MAAM,CAAC,GAAG,MAAW,KAClC,MAUF,CAAC;AAEF,OAAO,EACL,YAAY,EACZ,UAAU,EACV,UAAU,EACV,aAAa,EACb,UAAU,EACV,WAAW,EACX,QAAQ,EACR,sBAAsB,EACtB,iBAAiB,GAClB,CAAC"}
|
package/build/common/ops.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
// @ts-check
|
|
2
1
|
import toEmoji from "emoji-name-map";
|
|
3
2
|
import { OWNER_AFFILIATIONS } from "./constants.js";
|
|
4
3
|
import { CustomError } from "./error.js";
|
|
5
4
|
/**
|
|
6
5
|
* Returns boolean if value is either "true" or "false" else the value as it is.
|
|
7
6
|
*
|
|
8
|
-
* @param
|
|
9
|
-
* @returns
|
|
7
|
+
* @param value The value to parse.
|
|
8
|
+
* @returns The parsed value.
|
|
10
9
|
*/
|
|
11
10
|
const parseBoolean = (value) => {
|
|
12
11
|
if (typeof value === "boolean") {
|
|
@@ -25,8 +24,8 @@ const parseBoolean = (value) => {
|
|
|
25
24
|
/**
|
|
26
25
|
* Parse string to array of strings.
|
|
27
26
|
*
|
|
28
|
-
* @param
|
|
29
|
-
* @returns
|
|
27
|
+
* @param str The string to parse.
|
|
28
|
+
* @returns The array of strings.
|
|
30
29
|
*/
|
|
31
30
|
const parseArray = (str) => {
|
|
32
31
|
if (!str) {
|
|
@@ -37,50 +36,46 @@ const parseArray = (str) => {
|
|
|
37
36
|
/**
|
|
38
37
|
* Clamp the given number between the given range.
|
|
39
38
|
*
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @returns
|
|
39
|
+
* @param number The number to clamp.
|
|
40
|
+
* @param min The minimum value.
|
|
41
|
+
* @param max The maximum value.
|
|
42
|
+
* @returns The clamped number.
|
|
44
43
|
*/
|
|
45
44
|
const clampValue = (number, min, max) => {
|
|
46
|
-
|
|
47
|
-
if (Number.isNaN(parseInt(number, 10))) {
|
|
45
|
+
if (Number.isNaN(parseInt(String(number), 10))) {
|
|
48
46
|
return min;
|
|
49
47
|
}
|
|
50
|
-
return Math.max(min, Math.min(number, max));
|
|
48
|
+
return Math.max(min, Math.min(Number(number), max));
|
|
51
49
|
};
|
|
52
50
|
/**
|
|
53
51
|
* Lowercase and trim string.
|
|
54
52
|
*
|
|
55
|
-
* @param
|
|
56
|
-
* @returns
|
|
53
|
+
* @param name String to lowercase and trim.
|
|
54
|
+
* @returns Lowercased and trimmed string.
|
|
57
55
|
*/
|
|
58
56
|
const lowercaseTrim = (name) => name.toLowerCase().trim();
|
|
59
57
|
/**
|
|
60
58
|
* Split array of languages in two columns.
|
|
61
59
|
*
|
|
62
60
|
* @template T Language object.
|
|
63
|
-
* @param
|
|
64
|
-
* @param
|
|
65
|
-
* @returns
|
|
61
|
+
* @param arr Array of languages.
|
|
62
|
+
* @param perChunk Number of languages per column.
|
|
63
|
+
* @returns Array of languages split in two columns.
|
|
66
64
|
*/
|
|
67
65
|
const chunkArray = (arr, perChunk) => {
|
|
68
66
|
return arr.reduce((resultArray, item, index) => {
|
|
69
67
|
const chunkIndex = Math.floor(index / perChunk);
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
}
|
|
74
|
-
// @ts-ignore
|
|
75
|
-
resultArray[chunkIndex].push(item);
|
|
68
|
+
const chunk = resultArray[chunkIndex] ?? [];
|
|
69
|
+
chunk.push(item);
|
|
70
|
+
resultArray[chunkIndex] = chunk;
|
|
76
71
|
return resultArray;
|
|
77
72
|
}, []);
|
|
78
73
|
};
|
|
79
74
|
/**
|
|
80
75
|
* Parse emoji from string.
|
|
81
76
|
*
|
|
82
|
-
* @param
|
|
83
|
-
* @returns
|
|
77
|
+
* @param str String to parse emoji from.
|
|
78
|
+
* @returns String with emoji parsed.
|
|
84
79
|
*/
|
|
85
80
|
const parseEmojis = (str) => {
|
|
86
81
|
if (!str) {
|
|
@@ -93,9 +88,9 @@ const parseEmojis = (str) => {
|
|
|
93
88
|
/**
|
|
94
89
|
* Get diff in minutes between two dates.
|
|
95
90
|
*
|
|
96
|
-
* @param
|
|
97
|
-
* @param
|
|
98
|
-
* @returns
|
|
91
|
+
* @param d1 First date.
|
|
92
|
+
* @param d2 Second date.
|
|
93
|
+
* @returns Number of minutes between the two dates.
|
|
99
94
|
*/
|
|
100
95
|
const dateDiff = (d1, d2) => {
|
|
101
96
|
const date1 = new Date(d1);
|
|
@@ -106,8 +101,8 @@ const dateDiff = (d1, d2) => {
|
|
|
106
101
|
/**
|
|
107
102
|
* Parse owner affiliations.
|
|
108
103
|
*
|
|
109
|
-
* @param
|
|
110
|
-
* @returns
|
|
104
|
+
* @param affiliations input affiliations to be parsed.
|
|
105
|
+
* @returns Parsed affiliations.
|
|
111
106
|
*
|
|
112
107
|
* @throws {CustomError} If affiliations contains invalid values.
|
|
113
108
|
*/
|
|
@@ -115,21 +110,20 @@ const parseOwnerAffiliations = (affiliations) => {
|
|
|
115
110
|
// Set default value for ownerAffiliations.
|
|
116
111
|
// NOTE: Done here since parseArray() will always return an empty array even nothing
|
|
117
112
|
//was specified.
|
|
118
|
-
affiliations
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
: ["OWNER"];
|
|
113
|
+
const normalized = affiliations.length > 0
|
|
114
|
+
? affiliations.map((affiliation) => affiliation.toUpperCase())
|
|
115
|
+
: ["OWNER"];
|
|
122
116
|
// Check if ownerAffiliations contains valid values.
|
|
123
|
-
if (
|
|
117
|
+
if (normalized.some((affiliation) => !OWNER_AFFILIATIONS.includes(affiliation))) {
|
|
124
118
|
throw new CustomError("Invalid query parameter", CustomError.INVALID_AFFILIATION);
|
|
125
119
|
}
|
|
126
|
-
return
|
|
120
|
+
return normalized;
|
|
127
121
|
};
|
|
128
122
|
const buildSearchFilter = (repos = [], owners = []) => {
|
|
129
|
-
|
|
123
|
+
const repoFilter = Array.isArray(repos) && repos.length > 0
|
|
130
124
|
? repos.map((r) => `repo:${r} `).join("")
|
|
131
125
|
: "";
|
|
132
|
-
|
|
126
|
+
const orgFilter = Array.isArray(owners) && owners.length > 0
|
|
133
127
|
? owners.map((o) => `owner:${o} `).join("")
|
|
134
128
|
: "";
|
|
135
129
|
return repoFilter + orgFilter;
|
package/build/common/render.d.ts
CHANGED
|
@@ -1,52 +1,44 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
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!
|
|
3
6
|
*
|
|
4
|
-
* @param
|
|
5
|
-
* @param
|
|
6
|
-
* @param
|
|
7
|
-
* @param
|
|
8
|
-
* @param
|
|
9
|
-
* @
|
|
10
|
-
* @param {string=} args.renderOptions.bg_color Card background color.
|
|
11
|
-
* @param {string=} args.renderOptions.border_color Card border color.
|
|
12
|
-
* @param {Parameters<typeof getCardColors>[0]["theme"]=} args.renderOptions.theme Card theme.
|
|
13
|
-
* @param {boolean=} args.renderOptions.show_repo_link Whether to show repo link or not.
|
|
14
|
-
* @returns {string} The SVG markup.
|
|
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.
|
|
15
13
|
*/
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
bg_color?: string | undefined;
|
|
23
|
-
border_color?: string | undefined;
|
|
24
|
-
theme?: Parameters<typeof getCardColors>[0]["theme"] | undefined;
|
|
25
|
-
show_repo_link?: boolean | undefined;
|
|
26
|
-
} | undefined;
|
|
27
|
-
}): string;
|
|
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>;
|
|
28
20
|
/**
|
|
29
21
|
* Creates a node to display the primary programming language of the repository/gist.
|
|
30
22
|
*
|
|
31
|
-
* @param
|
|
32
|
-
* @param
|
|
33
|
-
* @returns
|
|
23
|
+
* @param langName Language name.
|
|
24
|
+
* @param langColor Language color.
|
|
25
|
+
* @returns Language display SVG object.
|
|
34
26
|
*/
|
|
35
|
-
|
|
27
|
+
declare const createLanguageNode: (langName: string, langColor: string) => string;
|
|
36
28
|
/**
|
|
37
29
|
* Create a node to indicate progress in percentage along a horizontal line.
|
|
38
30
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @param
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
46
|
-
* @param
|
|
47
|
-
* @returns
|
|
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 Progress color.
|
|
36
|
+
* @param params.progress Progress value.
|
|
37
|
+
* @param params.progressBarBackgroundColor Progress bar bg color.
|
|
38
|
+
* @param params.delay Delay before animation starts.
|
|
39
|
+
* @returns Progress node.
|
|
48
40
|
*/
|
|
49
|
-
|
|
41
|
+
declare const createProgressNode: ({ x, y, width, color, progress, progressBarBackgroundColor, delay, }: {
|
|
50
42
|
x: number;
|
|
51
43
|
y: number;
|
|
52
44
|
width: number;
|
|
@@ -54,43 +46,91 @@ export function createProgressNode({ x, y, width, color, progress, progressBarBa
|
|
|
54
46
|
progress: number;
|
|
55
47
|
progressBarBackgroundColor: string;
|
|
56
48
|
delay: number;
|
|
57
|
-
})
|
|
49
|
+
}) => string;
|
|
50
|
+
/**
|
|
51
|
+
* Renders multi-line text via a `foreignObject` so the browser performs
|
|
52
|
+
* native, font-aware wrapping. Content overflowing `lineCount` lines is
|
|
53
|
+
* clipped (with an ellipsis on the last visible line) by CSS line-clamp.
|
|
54
|
+
*
|
|
55
|
+
* @param props Function properties.
|
|
56
|
+
* @param props.text Text to render (will be HTML-encoded).
|
|
57
|
+
* @param props.x X position of the foreignObject.
|
|
58
|
+
* @param props.y Y position of the foreignObject.
|
|
59
|
+
* @param props.width Width of the wrap box.
|
|
60
|
+
* @param props.height Height of the wrap box.
|
|
61
|
+
* @param props.lineCount Maximum number of lines to display.
|
|
62
|
+
* @param props.className CSS class applied to the inner element.
|
|
63
|
+
* @param props.testId Optional test id for the inner element.
|
|
64
|
+
* @returns foreignObject SVG node.
|
|
65
|
+
*/
|
|
66
|
+
declare const wrappedTextNode: ({ text, x, y, width, height, lineCount, className, testId, }: {
|
|
67
|
+
text: string;
|
|
68
|
+
x: number;
|
|
69
|
+
y: number;
|
|
70
|
+
width: number;
|
|
71
|
+
height: number;
|
|
72
|
+
lineCount: number;
|
|
73
|
+
className: string;
|
|
74
|
+
testId?: string;
|
|
75
|
+
}) => string;
|
|
76
|
+
/**
|
|
77
|
+
* CSS rules used to render multi-line text inside a `foreignObject`. Apply this
|
|
78
|
+
* to a CSS class (e.g. `.description`) shared with `wrappedTextNode` so the
|
|
79
|
+
* browser handles wrapping and the line count is taken from the `--lines`
|
|
80
|
+
* custom property set on the element.
|
|
81
|
+
*
|
|
82
|
+
* @param color Text color (CSS `color` property).
|
|
83
|
+
* @returns CSS rules block (without the surrounding selector).
|
|
84
|
+
*/
|
|
85
|
+
declare const wrappedTextStyles: (color: string) => string;
|
|
58
86
|
/**
|
|
59
87
|
* Creates an icon with label to display repository/gist stats like forks, stars, etc.
|
|
60
88
|
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
* @param
|
|
64
|
-
* @param
|
|
65
|
-
* @
|
|
89
|
+
* The caller must ensure that the passed `icon` is properly sanitized!
|
|
90
|
+
*
|
|
91
|
+
* @param icon The sanitized icon to display.
|
|
92
|
+
* @param label The label to display.
|
|
93
|
+
* @param testid The testid to assign to the label.
|
|
94
|
+
* @param iconSize The size of the icon.
|
|
95
|
+
* @returns Icon with label SVG object.
|
|
66
96
|
*/
|
|
67
|
-
|
|
97
|
+
declare const iconWithLabel: (icon: string, label: number | string, testid: string, iconSize: number) => string;
|
|
68
98
|
/**
|
|
69
|
-
*
|
|
70
|
-
* proper gaping.
|
|
99
|
+
* Renders error message on the card.
|
|
71
100
|
*
|
|
72
|
-
* @param
|
|
73
|
-
* @param
|
|
74
|
-
* @param
|
|
75
|
-
* @param
|
|
76
|
-
* @param
|
|
77
|
-
* @
|
|
101
|
+
* @param args Function arguments.
|
|
102
|
+
* @param args.message Main error message.
|
|
103
|
+
* @param args.secondaryMessage The secondary error message.
|
|
104
|
+
* @param args.renderOptions Render options.
|
|
105
|
+
* @param args.renderOptions.title_color Card title color.
|
|
106
|
+
* @param args.renderOptions.text_color Card text color.
|
|
107
|
+
* @param args.renderOptions.bg_color Card background color.
|
|
108
|
+
* @param args.renderOptions.border_color Card border color.
|
|
109
|
+
* @param args.renderOptions.theme Card theme.
|
|
110
|
+
* @param args.renderOptions.show_repo_link Whether to show repo link or not.
|
|
111
|
+
* @returns The SVG markup.
|
|
78
112
|
*/
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
113
|
+
declare const renderError: ({ message, secondaryMessage, renderOptions, }: {
|
|
114
|
+
message: string;
|
|
115
|
+
secondaryMessage?: string;
|
|
116
|
+
renderOptions?: {
|
|
117
|
+
title_color?: string;
|
|
118
|
+
text_color?: string;
|
|
119
|
+
bg_color?: string;
|
|
120
|
+
border_color?: string;
|
|
121
|
+
theme?: string;
|
|
122
|
+
show_repo_link?: boolean;
|
|
123
|
+
};
|
|
124
|
+
}) => string;
|
|
85
125
|
/**
|
|
86
126
|
* Retrieve text length based on Segoe UI font.
|
|
87
127
|
*
|
|
88
128
|
* @see https://stackoverflow.com/a/48172630/10629172
|
|
89
|
-
* @param
|
|
90
|
-
* @param
|
|
91
|
-
* @returns
|
|
129
|
+
* @param str String to measure.
|
|
130
|
+
* @param fontSize Font size.
|
|
131
|
+
* @returns Text length.
|
|
92
132
|
*/
|
|
93
|
-
|
|
133
|
+
declare const measureText: (str: string, fontSize?: number) => number;
|
|
94
134
|
/**
|
|
95
135
|
* Split text into the lines it would wrap to when laid out greedily at the
|
|
96
136
|
* given font size inside a box of width `maxWidth`. Uses `measureText` so the
|
|
@@ -98,58 +138,22 @@ export function measureText(str: string, fontSize?: number): number;
|
|
|
98
138
|
* The browser still does the real wrap inside the foreignObject; this is only
|
|
99
139
|
* used to size the SVG.
|
|
100
140
|
*
|
|
101
|
-
* @param
|
|
102
|
-
* @param
|
|
103
|
-
* @param
|
|
104
|
-
* @returns
|
|
141
|
+
* @param text Text to split.
|
|
142
|
+
* @param fontSize Font size in px (matches `measureText`).
|
|
143
|
+
* @param maxWidth Available wrap width in px.
|
|
144
|
+
* @returns Estimated wrapped lines.
|
|
105
145
|
*/
|
|
106
|
-
|
|
146
|
+
declare const splitWrappedText: (text: string, fontSize: number, maxWidth: number) => Array<string>;
|
|
107
147
|
/**
|
|
108
148
|
* Estimate how many lines a string will wrap to when laid out greedily at the
|
|
109
149
|
* given font size inside a box of width `maxWidth`, capped at `maxLines`.
|
|
110
150
|
*
|
|
111
|
-
* @param
|
|
112
|
-
* @param
|
|
113
|
-
* @param
|
|
114
|
-
* @param
|
|
115
|
-
* @returns
|
|
116
|
-
*/
|
|
117
|
-
export function countWrappedLines(text: string, fontSize: number, maxWidth: number, maxLines: number): number;
|
|
118
|
-
/**
|
|
119
|
-
* Renders multi-line text via a `foreignObject` so the browser performs
|
|
120
|
-
* native, font-aware wrapping. Content overflowing `lineCount` lines is
|
|
121
|
-
* clipped (with an ellipsis on the last visible line) by CSS line-clamp.
|
|
122
|
-
*
|
|
123
|
-
* @param {object} props Function properties.
|
|
124
|
-
* @param {string} props.text Text to render (will be HTML-encoded).
|
|
125
|
-
* @param {number} props.x X position of the foreignObject.
|
|
126
|
-
* @param {number} props.y Y position of the foreignObject.
|
|
127
|
-
* @param {number} props.width Width of the wrap box.
|
|
128
|
-
* @param {number} props.height Height of the wrap box.
|
|
129
|
-
* @param {number} props.lineCount Maximum number of lines to display.
|
|
130
|
-
* @param {string} props.className CSS class applied to the inner element.
|
|
131
|
-
* @param {string=} props.testId Optional test id for the inner element.
|
|
132
|
-
* @returns {string} foreignObject SVG node.
|
|
133
|
-
*/
|
|
134
|
-
export function wrappedTextNode({ text, x, y, width, height, lineCount, className, testId, }: {
|
|
135
|
-
text: string;
|
|
136
|
-
x: number;
|
|
137
|
-
y: number;
|
|
138
|
-
width: number;
|
|
139
|
-
height: number;
|
|
140
|
-
lineCount: number;
|
|
141
|
-
className: string;
|
|
142
|
-
testId?: string | undefined;
|
|
143
|
-
}): string;
|
|
144
|
-
/**
|
|
145
|
-
* CSS rules used to render multi-line text inside a `foreignObject`. Apply this
|
|
146
|
-
* to a CSS class (e.g. `.description`) shared with `wrappedTextNode` so the
|
|
147
|
-
* browser handles wrapping and the line count is taken from the `--lines`
|
|
148
|
-
* custom property set on the element.
|
|
149
|
-
*
|
|
150
|
-
* @param {string} color Text color (CSS `color` property).
|
|
151
|
-
* @returns {string} CSS rules block (without the surrounding selector).
|
|
151
|
+
* @param text Text to estimate.
|
|
152
|
+
* @param fontSize Font size in px (matches `measureText`).
|
|
153
|
+
* @param maxWidth Available wrap width in px.
|
|
154
|
+
* @param maxLines Cap on the returned line count.
|
|
155
|
+
* @returns Estimated line count, at least 1, at most `maxLines`.
|
|
152
156
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
157
|
+
declare const countWrappedLines: (text: string, fontSize: number, maxWidth: number, maxLines: number) => number;
|
|
158
|
+
export { renderError, createLanguageNode, createProgressNode, iconWithLabel, flexLayout, measureText, splitWrappedText, countWrappedLines, wrappedTextNode, wrappedTextStyles, };
|
|
155
159
|
//# sourceMappingURL=render.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/common/render.
|
|
1
|
+
{"version":3,"file":"render.d.ts","sourceRoot":"","sources":["../../src/common/render.ts"],"names":[],"mappings":"AAKA;;;;;;;;;;;;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,sEAQzB;IACD,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,0BAA0B,EAAE,MAAM,CAAC;IACnC,KAAK,EAAE,MAAM,CAAC;CACf,KAAG,MAsCH,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,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,KAAG,MAyBH,CAAC;AAEF;;;;;;;;GAQG;AACH,QAAA,MAAM,iBAAiB,GAAI,OAAO,MAAM,KAAG,MAmB1C,CAAC;AAEF;;;;;;;;;;GAUG;AACH,QAAA,MAAM,aAAa,GACjB,MAAM,MAAM,EACZ,OAAO,MAAM,GAAG,MAAM,EACtB,QAAQ,MAAM,EACd,UAAU,MAAM,KACf,MAuBF,CAAC;AAUF;;;;;;;;;;;;;;GAcG;AACH,QAAA,MAAM,WAAW,GAAI,+CAIlB;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,gBAAgB,CAAC,EAAE,MAAM,CAAC;IAC1B,aAAa,CAAC,EAAE;QACd,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,YAAY,CAAC,EAAE,MAAM,CAAC;QACtB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,cAAc,CAAC,EAAE,OAAO,CAAC;KAC1B,CAAC;CACH,KAAG,MA0CH,CAAC;AAEF;;;;;;;GAOG;AACH,QAAA,MAAM,WAAW,GAAI,KAAK,MAAM,EAAE,iBAAa,KAAG,MA2DjD,CAAC;AAEF;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,gBAAgB,GACpB,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,KAAK,CAAC,MAAM,CAkFd,CAAC;AAEF;;;;;;;;;GASG;AACH,QAAA,MAAM,iBAAiB,GACrB,MAAM,MAAM,EACZ,UAAU,MAAM,EAChB,UAAU,MAAM,EAChB,UAAU,MAAM,KACf,MAKF,CAAC;AAEF,OAAO,EACL,WAAW,EACX,kBAAkB,EAClB,kBAAkB,EAClB,aAAa,EACb,UAAU,EACV,WAAW,EACX,gBAAgB,EAChB,iBAAiB,EACjB,eAAe,EACf,iBAAiB,GAClB,CAAC"}
|