@stats-organization/github-readme-stats-core 2.1.4 → 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 -0
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +18 -0
- package/build/api/pin.d.ts.map +1 -1
- package/build/api/pin.js +17 -0
- package/build/api/top-langs.d.ts.map +1 -1
- package/build/api/top-langs.js +36 -4
- package/build/api/wakatime.d.ts.map +1 -1
- package/build/api/wakatime.js +34 -0
- package/build/calculateRank.d.ts +12 -11
- package/build/calculateRank.d.ts.map +1 -1
- package/build/calculateRank.js +18 -18
- package/build/cards/repo.d.ts.map +1 -1
- package/build/cards/repo.js +29 -20
- package/build/cards/stats.d.ts +4 -2
- package/build/cards/stats.d.ts.map +1 -1
- package/build/cards/stats.js +21 -8
- package/build/cards/top-languages.d.ts.map +1 -1
- package/build/cards/top-languages.js +39 -11
- package/build/cards/wakatime.d.ts.map +1 -1
- package/build/cards/wakatime.js +29 -8
- package/build/common/Card.d.ts +9 -3
- package/build/common/Card.d.ts.map +1 -1
- package/build/common/Card.js +47 -19
- package/build/common/color.d.ts +42 -8
- package/build/common/color.d.ts.map +1 -1
- package/build/common/color.js +62 -13
- package/build/common/html.js +1 -1
- package/build/common/http.d.ts +13 -4
- package/build/common/http.d.ts.map +1 -1
- package/build/common/http.js +3 -3
- 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 -37
- package/build/common/render.d.ts +115 -111
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +138 -87
- package/build/common/retryer.d.ts +14 -6
- package/build/common/retryer.d.ts.map +1 -1
- package/build/common/retryer.js +1 -0
- package/build/fetchers/gist.d.ts +6 -21
- package/build/fetchers/gist.d.ts.map +1 -1
- package/build/fetchers/gist.js +30 -35
- package/build/fetchers/repo.js +1 -1
- package/build/fetchers/stats.d.ts.map +1 -1
- package/build/fetchers/stats.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/package.json +4 -4
- package/src/_emoji-name-map.d.ts +10 -0
- package/src/api/gist.js +36 -0
- package/src/api/index.js +19 -0
- package/src/api/pin.js +18 -0
- package/src/api/top-langs.js +38 -4
- package/src/api/wakatime.js +36 -0
- package/src/{calculateRank.js → calculateRank.ts} +29 -19
- package/src/cards/repo.js +30 -20
- package/src/cards/stats.js +22 -8
- package/src/cards/top-languages.js +49 -11
- package/src/cards/wakatime.js +33 -8
- package/src/common/Card.ts +51 -16
- package/src/common/color.ts +85 -22
- package/src/common/html.ts +1 -1
- package/src/common/http.ts +31 -0
- package/src/common/languageColors.json +9 -1
- package/src/common/{ops.js → ops.ts} +48 -50
- package/src/common/{render.js → render.ts} +208 -96
- package/src/common/retryer.ts +18 -10
- package/src/fetchers/gist.ts +136 -0
- package/src/fetchers/repo.js +1 -1
- package/src/fetchers/stats.js +0 -1
- package/src/common/http.js +0 -19
- package/src/fetchers/gist.js +0 -112
- /package/src/fetchers/{types.d.ts → types.ts} +0 -0
|
@@ -44,6 +44,7 @@
|
|
|
44
44
|
"Awk": "#c30e9b",
|
|
45
45
|
"B (Formal Method)": "#8aa8c5",
|
|
46
46
|
"B4X": "#00e4ff",
|
|
47
|
+
"BAML": "#a855f7",
|
|
47
48
|
"BASIC": "#ff0000",
|
|
48
49
|
"BQN": "#2b7067",
|
|
49
50
|
"Ballerina": "#FF5000",
|
|
@@ -58,6 +59,7 @@
|
|
|
58
59
|
"Blade": "#f7523f",
|
|
59
60
|
"BlitzBasic": "#00FFAE",
|
|
60
61
|
"BlitzMax": "#cd6400",
|
|
62
|
+
"Blueprint": "#3584E4",
|
|
61
63
|
"Bluespec": "#12223c",
|
|
62
64
|
"Bluespec BH": "#12223c",
|
|
63
65
|
"Boo": "#d4bec1",
|
|
@@ -69,7 +71,7 @@
|
|
|
69
71
|
"Bru": "#F4AA41",
|
|
70
72
|
"BuildStream": "#006bff",
|
|
71
73
|
"C": "#555555",
|
|
72
|
-
"C#": "#
|
|
74
|
+
"C#": "#7355dd",
|
|
73
75
|
"C++": "#f34b7d",
|
|
74
76
|
"C3": "#2563eb",
|
|
75
77
|
"CAP CDS": "#0092d1",
|
|
@@ -227,6 +229,7 @@
|
|
|
227
229
|
"Graphviz (DOT)": "#2596be",
|
|
228
230
|
"Groovy": "#4298b8",
|
|
229
231
|
"Groovy Server Pages": "#4298b8",
|
|
232
|
+
"GtkRC": "#7fe719",
|
|
230
233
|
"HAProxy": "#106da9",
|
|
231
234
|
"HCL": "#844FBA",
|
|
232
235
|
"HIP": "#4F3A4F",
|
|
@@ -416,6 +419,7 @@
|
|
|
416
419
|
"OpenSCAD": "#e5cd45",
|
|
417
420
|
"Option List": "#476732",
|
|
418
421
|
"Org": "#77aa99",
|
|
422
|
+
"OverPy": "#78b355",
|
|
419
423
|
"OverpassQL": "#cce2aa",
|
|
420
424
|
"Oxygene": "#cdd0e3",
|
|
421
425
|
"Oz": "#fab738",
|
|
@@ -445,10 +449,12 @@
|
|
|
445
449
|
"Portugol": "#f8bd00",
|
|
446
450
|
"PostCSS": "#dc3a0c",
|
|
447
451
|
"PostScript": "#da291c",
|
|
452
|
+
"Power Query": "#d38e0d",
|
|
448
453
|
"PowerBuilder": "#8f0f8d",
|
|
449
454
|
"PowerShell": "#012456",
|
|
450
455
|
"Praat": "#c8506d",
|
|
451
456
|
"Prisma": "#0c344b",
|
|
457
|
+
"Pro*C": "#bb8368",
|
|
452
458
|
"Processing": "#0096D8",
|
|
453
459
|
"Procfile": "#3B2F63",
|
|
454
460
|
"Prolog": "#74283c",
|
|
@@ -490,6 +496,7 @@
|
|
|
490
496
|
"Rebol": "#358a5b",
|
|
491
497
|
"Record Jar": "#0673ba",
|
|
492
498
|
"Red": "#f50000",
|
|
499
|
+
"Redscript": "#f44336",
|
|
493
500
|
"Regular Expression": "#009a00",
|
|
494
501
|
"Ren'Py": "#ff7f7f",
|
|
495
502
|
"Rez": "#FFDAB3",
|
|
@@ -659,6 +666,7 @@
|
|
|
659
666
|
"nanorc": "#2d004d",
|
|
660
667
|
"nesC": "#94B0C7",
|
|
661
668
|
"ooc": "#b0b77e",
|
|
669
|
+
"pkg-config": "#2b5e82",
|
|
662
670
|
"q": "#0040cd",
|
|
663
671
|
"reStructuredText": "#141414",
|
|
664
672
|
"sed": "#64b970",
|
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
|
@@ -4,8 +4,8 @@ import { CustomError } from "./error.js";
|
|
|
4
4
|
/**
|
|
5
5
|
* Returns boolean if value is either "true" or "false" else the value as it is.
|
|
6
6
|
*
|
|
7
|
-
* @param
|
|
8
|
-
* @returns
|
|
7
|
+
* @param value The value to parse.
|
|
8
|
+
* @returns The parsed value.
|
|
9
9
|
*/
|
|
10
10
|
const parseBoolean = (value) => {
|
|
11
11
|
if (typeof value === "boolean") {
|
|
@@ -24,8 +24,8 @@ const parseBoolean = (value) => {
|
|
|
24
24
|
/**
|
|
25
25
|
* Parse string to array of strings.
|
|
26
26
|
*
|
|
27
|
-
* @param
|
|
28
|
-
* @returns
|
|
27
|
+
* @param str The string to parse.
|
|
28
|
+
* @returns The array of strings.
|
|
29
29
|
*/
|
|
30
30
|
const parseArray = (str) => {
|
|
31
31
|
if (!str) {
|
|
@@ -36,50 +36,46 @@ const parseArray = (str) => {
|
|
|
36
36
|
/**
|
|
37
37
|
* Clamp the given number between the given range.
|
|
38
38
|
*
|
|
39
|
-
* @param
|
|
40
|
-
* @param
|
|
41
|
-
* @param
|
|
42
|
-
* @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.
|
|
43
43
|
*/
|
|
44
44
|
const clampValue = (number, min, max) => {
|
|
45
|
-
|
|
46
|
-
if (Number.isNaN(parseInt(number, 10))) {
|
|
45
|
+
if (Number.isNaN(parseInt(String(number), 10))) {
|
|
47
46
|
return min;
|
|
48
47
|
}
|
|
49
|
-
return Math.max(min, Math.min(number, max));
|
|
48
|
+
return Math.max(min, Math.min(Number(number), max));
|
|
50
49
|
};
|
|
51
50
|
/**
|
|
52
51
|
* Lowercase and trim string.
|
|
53
52
|
*
|
|
54
|
-
* @param
|
|
55
|
-
* @returns
|
|
53
|
+
* @param name String to lowercase and trim.
|
|
54
|
+
* @returns Lowercased and trimmed string.
|
|
56
55
|
*/
|
|
57
56
|
const lowercaseTrim = (name) => name.toLowerCase().trim();
|
|
58
57
|
/**
|
|
59
58
|
* Split array of languages in two columns.
|
|
60
59
|
*
|
|
61
60
|
* @template T Language object.
|
|
62
|
-
* @param
|
|
63
|
-
* @param
|
|
64
|
-
* @returns
|
|
61
|
+
* @param arr Array of languages.
|
|
62
|
+
* @param perChunk Number of languages per column.
|
|
63
|
+
* @returns Array of languages split in two columns.
|
|
65
64
|
*/
|
|
66
65
|
const chunkArray = (arr, perChunk) => {
|
|
67
66
|
return arr.reduce((resultArray, item, index) => {
|
|
68
67
|
const chunkIndex = Math.floor(index / perChunk);
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
73
|
-
// @ts-ignore
|
|
74
|
-
resultArray[chunkIndex].push(item);
|
|
68
|
+
const chunk = resultArray[chunkIndex] ?? [];
|
|
69
|
+
chunk.push(item);
|
|
70
|
+
resultArray[chunkIndex] = chunk;
|
|
75
71
|
return resultArray;
|
|
76
72
|
}, []);
|
|
77
73
|
};
|
|
78
74
|
/**
|
|
79
75
|
* Parse emoji from string.
|
|
80
76
|
*
|
|
81
|
-
* @param
|
|
82
|
-
* @returns
|
|
77
|
+
* @param str String to parse emoji from.
|
|
78
|
+
* @returns String with emoji parsed.
|
|
83
79
|
*/
|
|
84
80
|
const parseEmojis = (str) => {
|
|
85
81
|
if (!str) {
|
|
@@ -92,9 +88,9 @@ const parseEmojis = (str) => {
|
|
|
92
88
|
/**
|
|
93
89
|
* Get diff in minutes between two dates.
|
|
94
90
|
*
|
|
95
|
-
* @param
|
|
96
|
-
* @param
|
|
97
|
-
* @returns
|
|
91
|
+
* @param d1 First date.
|
|
92
|
+
* @param d2 Second date.
|
|
93
|
+
* @returns Number of minutes between the two dates.
|
|
98
94
|
*/
|
|
99
95
|
const dateDiff = (d1, d2) => {
|
|
100
96
|
const date1 = new Date(d1);
|
|
@@ -105,8 +101,8 @@ const dateDiff = (d1, d2) => {
|
|
|
105
101
|
/**
|
|
106
102
|
* Parse owner affiliations.
|
|
107
103
|
*
|
|
108
|
-
* @param
|
|
109
|
-
* @returns
|
|
104
|
+
* @param affiliations input affiliations to be parsed.
|
|
105
|
+
* @returns Parsed affiliations.
|
|
110
106
|
*
|
|
111
107
|
* @throws {CustomError} If affiliations contains invalid values.
|
|
112
108
|
*/
|
|
@@ -114,21 +110,20 @@ const parseOwnerAffiliations = (affiliations) => {
|
|
|
114
110
|
// Set default value for ownerAffiliations.
|
|
115
111
|
// NOTE: Done here since parseArray() will always return an empty array even nothing
|
|
116
112
|
//was specified.
|
|
117
|
-
affiliations
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
: ["OWNER"];
|
|
113
|
+
const normalized = affiliations.length > 0
|
|
114
|
+
? affiliations.map((affiliation) => affiliation.toUpperCase())
|
|
115
|
+
: ["OWNER"];
|
|
121
116
|
// Check if ownerAffiliations contains valid values.
|
|
122
|
-
if (
|
|
117
|
+
if (normalized.some((affiliation) => !OWNER_AFFILIATIONS.includes(affiliation))) {
|
|
123
118
|
throw new CustomError("Invalid query parameter", CustomError.INVALID_AFFILIATION);
|
|
124
119
|
}
|
|
125
|
-
return
|
|
120
|
+
return normalized;
|
|
126
121
|
};
|
|
127
122
|
const buildSearchFilter = (repos = [], owners = []) => {
|
|
128
|
-
|
|
123
|
+
const repoFilter = Array.isArray(repos) && repos.length > 0
|
|
129
124
|
? repos.map((r) => `repo:${r} `).join("")
|
|
130
125
|
: "";
|
|
131
|
-
|
|
126
|
+
const orgFilter = Array.isArray(owners) && owners.length > 0
|
|
132
127
|
? owners.map((o) => `owner:${o} `).join("")
|
|
133
128
|
: "";
|
|
134
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":["../../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