@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.
Files changed (77) hide show
  1. package/build/api/gist.d.ts.map +1 -1
  2. package/build/api/gist.js +34 -0
  3. package/build/api/index.d.ts.map +1 -1
  4. package/build/api/index.js +18 -0
  5. package/build/api/pin.d.ts.map +1 -1
  6. package/build/api/pin.js +17 -0
  7. package/build/api/top-langs.d.ts.map +1 -1
  8. package/build/api/top-langs.js +36 -4
  9. package/build/api/wakatime.d.ts.map +1 -1
  10. package/build/api/wakatime.js +34 -0
  11. package/build/calculateRank.d.ts +12 -11
  12. package/build/calculateRank.d.ts.map +1 -1
  13. package/build/calculateRank.js +18 -18
  14. package/build/cards/repo.d.ts.map +1 -1
  15. package/build/cards/repo.js +29 -20
  16. package/build/cards/stats.d.ts +4 -2
  17. package/build/cards/stats.d.ts.map +1 -1
  18. package/build/cards/stats.js +21 -8
  19. package/build/cards/top-languages.d.ts.map +1 -1
  20. package/build/cards/top-languages.js +39 -11
  21. package/build/cards/wakatime.d.ts.map +1 -1
  22. package/build/cards/wakatime.js +29 -8
  23. package/build/common/Card.d.ts +9 -3
  24. package/build/common/Card.d.ts.map +1 -1
  25. package/build/common/Card.js +47 -19
  26. package/build/common/color.d.ts +42 -8
  27. package/build/common/color.d.ts.map +1 -1
  28. package/build/common/color.js +62 -13
  29. package/build/common/html.js +1 -1
  30. package/build/common/http.d.ts +13 -4
  31. package/build/common/http.d.ts.map +1 -1
  32. package/build/common/http.js +3 -3
  33. package/build/common/languageColors.json +9 -1
  34. package/build/common/ops.d.ts +30 -29
  35. package/build/common/ops.d.ts.map +1 -1
  36. package/build/common/ops.js +32 -37
  37. package/build/common/render.d.ts +115 -111
  38. package/build/common/render.d.ts.map +1 -1
  39. package/build/common/render.js +138 -87
  40. package/build/common/retryer.d.ts +14 -6
  41. package/build/common/retryer.d.ts.map +1 -1
  42. package/build/common/retryer.js +1 -0
  43. package/build/fetchers/gist.d.ts +6 -21
  44. package/build/fetchers/gist.d.ts.map +1 -1
  45. package/build/fetchers/gist.js +30 -35
  46. package/build/fetchers/repo.js +1 -1
  47. package/build/fetchers/stats.d.ts.map +1 -1
  48. package/build/fetchers/stats.js +0 -1
  49. package/build/fetchers/types.d.ts +126 -0
  50. package/build/fetchers/types.d.ts.map +1 -0
  51. package/build/fetchers/types.js +1 -0
  52. package/package.json +4 -4
  53. package/src/_emoji-name-map.d.ts +10 -0
  54. package/src/api/gist.js +36 -0
  55. package/src/api/index.js +19 -0
  56. package/src/api/pin.js +18 -0
  57. package/src/api/top-langs.js +38 -4
  58. package/src/api/wakatime.js +36 -0
  59. package/src/{calculateRank.js → calculateRank.ts} +29 -19
  60. package/src/cards/repo.js +30 -20
  61. package/src/cards/stats.js +22 -8
  62. package/src/cards/top-languages.js +49 -11
  63. package/src/cards/wakatime.js +33 -8
  64. package/src/common/Card.ts +51 -16
  65. package/src/common/color.ts +85 -22
  66. package/src/common/html.ts +1 -1
  67. package/src/common/http.ts +31 -0
  68. package/src/common/languageColors.json +9 -1
  69. package/src/common/{ops.js → ops.ts} +48 -50
  70. package/src/common/{render.js → render.ts} +208 -96
  71. package/src/common/retryer.ts +18 -10
  72. package/src/fetchers/gist.ts +136 -0
  73. package/src/fetchers/repo.js +1 -1
  74. package/src/fetchers/stats.js +0 -1
  75. package/src/common/http.js +0 -19
  76. package/src/fetchers/gist.js +0 -112
  77. /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#": "#178600",
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",
@@ -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 {string | boolean} value The value to parse.
5
- * @returns {boolean | undefined } The parsed value.
4
+ * @param value The value to parse.
5
+ * @returns The parsed value.
6
6
  */
7
- export function parseBoolean(value: string | boolean): boolean | undefined;
7
+ declare const parseBoolean: (value: string | boolean) => boolean | undefined;
8
8
  /**
9
9
  * Parse string to array of strings.
10
10
  *
11
- * @param {string} str The string to parse.
12
- * @returns {string[]} The array of strings.
11
+ * @param str The string to parse.
12
+ * @returns The array of strings.
13
13
  */
14
- export function parseArray(str: string): string[];
14
+ declare const parseArray: (str: string) => Array<string>;
15
15
  /**
16
16
  * Clamp the given number between the given range.
17
17
  *
18
- * @param {number} number The number to clamp.
19
- * @param {number} min The minimum value.
20
- * @param {number} max The maximum value.
21
- * @returns {number} The clamped number.
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
- export function clampValue(number: number, min: number, max: number): number;
23
+ declare const clampValue: (number: string | number, min: number, max: number) => number;
24
24
  /**
25
25
  * Lowercase and trim string.
26
26
  *
27
- * @param {string} name String to lowercase and trim.
28
- * @returns {string} Lowercased and trimmed string.
27
+ * @param name String to lowercase and trim.
28
+ * @returns Lowercased and trimmed string.
29
29
  */
30
- export function lowercaseTrim(name: string): string;
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 {Array<T>} arr Array of languages.
36
- * @param {number} perChunk Number of languages per column.
37
- * @returns {Array<T>} Array of languages split in two columns.
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
- export function chunkArray<T>(arr: Array<T>, perChunk: number): Array<T>;
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 {string} str String to parse emoji from.
44
- * @returns {string} String with emoji parsed.
43
+ * @param str String to parse emoji from.
44
+ * @returns String with emoji parsed.
45
45
  */
46
- export function parseEmojis(str: string): string;
46
+ declare const parseEmojis: (str: string) => string;
47
47
  /**
48
48
  * Get diff in minutes between two dates.
49
49
  *
50
- * @param {Date} d1 First date.
51
- * @param {Date} d2 Second date.
52
- * @returns {number} Number of minutes between the two dates.
50
+ * @param d1 First date.
51
+ * @param d2 Second date.
52
+ * @returns Number of minutes between the two dates.
53
53
  */
54
- export function dateDiff(d1: Date, d2: Date): number;
54
+ declare const dateDiff: (d1: Date, d2: Date) => number;
55
55
  /**
56
56
  * Parse owner affiliations.
57
57
  *
58
- * @param {string[]} affiliations input affiliations to be parsed.
59
- * @returns {string[]} Parsed affiliations.
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
- export function parseOwnerAffiliations(affiliations: string[]): string[];
64
- export function buildSearchFilter(repos?: any[], owners?: any[]): string;
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.js"],"names":[],"mappings":"AAKA;;;;;GAKG;AACH,oCAHW,MAAM,GAAG,OAAO,GACd,OAAO,GAAG,SAAS,CAe/B;AAED;;;;;GAKG;AACH,gCAHW,MAAM,GACJ,MAAM,EAAE,CAOpB;AAED;;;;;;;GAOG;AACH,mCALW,MAA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G;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"}
@@ -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 {string | boolean} value The value to parse.
8
- * @returns {boolean | undefined } The parsed value.
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 {string} str The string to parse.
28
- * @returns {string[]} The array of strings.
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 {number} number The number to clamp.
40
- * @param {number} min The minimum value.
41
- * @param {number} max The maximum value.
42
- * @returns {number} The clamped number.
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
- // @ts-ignore
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 {string} name String to lowercase and trim.
55
- * @returns {string} Lowercased and trimmed string.
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 {Array<T>} arr Array of languages.
63
- * @param {number} perChunk Number of languages per column.
64
- * @returns {Array<T>} Array of languages split in two columns.
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
- if (!resultArray[chunkIndex]) {
70
- // @ts-ignore
71
- resultArray[chunkIndex] = []; // start a new chunk
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 {string} str String to parse emoji from.
82
- * @returns {string} String with emoji parsed.
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 {Date} d1 First date.
96
- * @param {Date} d2 Second date.
97
- * @returns {number} Number of minutes between the two dates.
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 {string[]} affiliations input affiliations to be parsed.
109
- * @returns {string[]} Parsed affiliations.
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
- affiliations && affiliations.length > 0
119
- ? affiliations.map((affiliation) => affiliation.toUpperCase())
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 (affiliations.some((affiliation) => !OWNER_AFFILIATIONS.includes(affiliation))) {
117
+ if (normalized.some((affiliation) => !OWNER_AFFILIATIONS.includes(affiliation))) {
123
118
  throw new CustomError("Invalid query parameter", CustomError.INVALID_AFFILIATION);
124
119
  }
125
- return affiliations;
120
+ return normalized;
126
121
  };
127
122
  const buildSearchFilter = (repos = [], owners = []) => {
128
- let repoFilter = Array.isArray(repos) && repos.length > 0
123
+ const repoFilter = Array.isArray(repos) && repos.length > 0
129
124
  ? repos.map((r) => `repo:${r} `).join("")
130
125
  : "";
131
- let orgFilter = Array.isArray(owners) && owners.length > 0
126
+ const orgFilter = Array.isArray(owners) && owners.length > 0
132
127
  ? owners.map((o) => `owner:${o} `).join("")
133
128
  : "";
134
129
  return repoFilter + orgFilter;
@@ -1,52 +1,44 @@
1
1
  /**
2
- * Renders error message on the card.
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 {object} args Function arguments.
5
- * @param {string} args.message Main error message.
6
- * @param {string} [args.secondaryMessage=""] The secondary error message.
7
- * @param {object} [args.renderOptions={}] Render options.
8
- * @param {string=} args.renderOptions.title_color Card title color.
9
- * @param {string=} args.renderOptions.text_color Card text color.
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
- export function renderError({ message, secondaryMessage, renderOptions, }: {
17
- message: string;
18
- secondaryMessage?: string | undefined;
19
- renderOptions?: {
20
- title_color?: string | undefined;
21
- text_color?: string | undefined;
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 {string} langName Language name.
32
- * @param {string} langColor Language color.
33
- * @returns {string} Language display SVG object.
23
+ * @param langName Language name.
24
+ * @param langColor Language color.
25
+ * @returns Language display SVG object.
34
26
  */
35
- export function createLanguageNode(langName: string, langColor: string): string;
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 {Object} params Object that contains the createProgressNode parameters.
40
- * @param {number} params.x X-axis position.
41
- * @param {number} params.y Y-axis position.
42
- * @param {number} params.width Width of progress bar.
43
- * @param {string} params.color Progress color.
44
- * @param {number} params.progress Progress value.
45
- * @param {string} params.progressBarBackgroundColor Progress bar bg color.
46
- * @param {number} params.delay Delay before animation starts.
47
- * @returns {string} Progress node.
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
- export function createProgressNode({ x, y, width, color, progress, progressBarBackgroundColor, delay, }: {
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
- }): string;
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
- * @param {string} icon The icon to display.
62
- * @param {number|string} label The label to display.
63
- * @param {string} testid The testid to assign to the label.
64
- * @param {number} iconSize The size of the icon.
65
- * @returns {string} Icon with label SVG object.
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
- export function iconWithLabel(icon: string, label: number | string, testid: string, iconSize: number): string;
97
+ declare const iconWithLabel: (icon: string, label: number | string, testid: string, iconSize: number) => string;
68
98
  /**
69
- * Auto layout utility, allows us to layout things vertically or horizontally with
70
- * proper gaping.
99
+ * Renders error message on the card.
71
100
  *
72
- * @param {object} props Function properties.
73
- * @param {string[]} props.items Array of items to layout.
74
- * @param {number} props.gap Gap between items.
75
- * @param {"column" | "row"=} props.direction Direction to layout items.
76
- * @param {number[]=} props.sizes Array of sizes for each item.
77
- * @returns {string[]} Array of items with proper layout.
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
- export function flexLayout({ items, gap, direction, sizes }: {
80
- items: string[];
81
- gap: number;
82
- direction?: ("column" | "row") | undefined;
83
- sizes?: number[] | undefined;
84
- }): string[];
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 {string} str String to measure.
90
- * @param {number} fontSize Font size.
91
- * @returns {number} Text length.
129
+ * @param str String to measure.
130
+ * @param fontSize Font size.
131
+ * @returns Text length.
92
132
  */
93
- export function measureText(str: string, fontSize?: number): number;
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 {string} text Text to split.
102
- * @param {number} fontSize Font size in px (matches `measureText`).
103
- * @param {number} maxWidth Available wrap width in px.
104
- * @returns {string[]} Estimated wrapped lines.
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
- export function splitWrappedText(text: string, fontSize: number, maxWidth: number): string[];
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 {string} text Text to estimate.
112
- * @param {number} fontSize Font size in px (matches `measureText`).
113
- * @param {number} maxWidth Available wrap width in px.
114
- * @param {number} maxLines Cap on the returned line count.
115
- * @returns {number} Estimated line count, at least 1, at most `maxLines`.
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
- export function wrappedTextStyles(color: string): string;
154
- import { getCardColors } from "./color.js";
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/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