@stats-forge/github-stats-forge-core 0.2.0 → 0.4.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/build/api/contributed-to.js +1 -1
- package/build/api/gist.js +1 -1
- package/build/api/index.d.ts +1 -0
- package/build/api/index.d.ts.map +1 -1
- package/build/api/index.js +1 -0
- package/build/api/organization.d.ts +29 -0
- package/build/api/organization.d.ts.map +1 -0
- package/build/api/organization.js +53 -0
- package/build/api/params.js +1 -1
- package/build/api/pin.js +1 -1
- package/build/api/stats.js +1 -1
- package/build/api/top-langs.js +1 -1
- package/build/api/wakatime.js +1 -1
- package/build/cards/{contributed-to.d.ts → contributed-to/index.d.ts} +3 -3
- package/build/cards/contributed-to/index.d.ts.map +1 -0
- package/build/cards/{contributed-to.js → contributed-to/index.js} +31 -30
- package/build/cards/contributed-to/locales.d.ts +38 -0
- package/build/cards/contributed-to/locales.d.ts.map +1 -0
- package/build/cards/contributed-to/locales.js +39 -0
- package/build/cards/{gist.d.ts → gist/index.d.ts} +3 -3
- package/build/cards/gist/index.d.ts.map +1 -0
- package/build/cards/{gist.js → gist/index.js} +20 -15
- package/build/cards/gist/locales.d.ts +14 -0
- package/build/cards/gist/locales.d.ts.map +1 -0
- package/build/cards/gist/locales.js +15 -0
- package/build/cards/organization/index.d.ts +36 -0
- package/build/cards/organization/index.d.ts.map +1 -0
- package/build/cards/organization/index.js +225 -0
- package/build/cards/organization/locales.d.ts +47 -0
- package/build/cards/organization/locales.d.ts.map +1 -0
- package/build/cards/organization/locales.js +47 -0
- package/build/cards/{repo.d.ts → repo/index.d.ts} +3 -3
- package/build/cards/repo/index.d.ts.map +1 -0
- package/build/cards/{repo.js → repo/index.js} +20 -23
- package/build/cards/repo/locales.d.ts +129 -0
- package/build/cards/repo/locales.d.ts.map +1 -0
- package/build/cards/repo/locales.js +129 -0
- package/build/cards/{stats.d.ts → stats/index.d.ts} +3 -3
- package/build/cards/stats/index.d.ts.map +1 -0
- package/build/cards/{stats.js → stats/index.js} +38 -42
- package/build/cards/stats/locales.d.ts +621 -0
- package/build/cards/stats/locales.d.ts.map +1 -0
- package/build/cards/stats/locales.js +623 -0
- package/build/cards/{top-languages.d.ts → top-languages/index.d.ts} +3 -3
- package/build/cards/top-languages/index.d.ts.map +1 -0
- package/build/cards/{top-languages.js → top-languages/index.js} +13 -16
- package/build/cards/top-languages/locales.d.ts +103 -0
- package/build/cards/top-languages/locales.d.ts.map +1 -0
- package/build/cards/top-languages/locales.js +103 -0
- package/build/cards/{wakatime.d.ts → wakatime/index.d.ts} +3 -3
- package/build/cards/wakatime/index.d.ts.map +1 -0
- package/build/cards/{wakatime.js → wakatime/index.js} +22 -23
- package/build/cards/wakatime/locales.d.ts +250 -0
- package/build/cards/wakatime/locales.d.ts.map +1 -0
- package/build/cards/wakatime/locales.js +250 -0
- package/build/common/brand.d.ts +1 -0
- package/build/common/brand.d.ts.map +1 -1
- package/build/common/brand.js +1 -0
- package/build/common/error.d.ts +3 -1
- package/build/common/error.d.ts.map +1 -1
- package/build/common/error.js +3 -1
- package/build/common/icons.d.ts +5 -0
- package/build/common/icons.d.ts.map +1 -1
- package/build/common/icons.js +19 -4
- package/build/common/locales.d.ts +59 -0
- package/build/common/locales.d.ts.map +1 -0
- package/build/common/locales.js +59 -0
- package/build/common/localize.d.ts +60 -0
- package/build/common/localize.d.ts.map +1 -0
- package/build/common/localize.js +163 -0
- package/build/common/render.d.ts.map +1 -1
- package/build/common/render.js +9 -3
- package/build/fetchers/index.d.ts +2 -1
- package/build/fetchers/index.d.ts.map +1 -1
- package/build/fetchers/index.js +1 -0
- package/build/fetchers/organization.d.ts +15 -0
- package/build/fetchers/organization.d.ts.map +1 -0
- package/build/fetchers/organization.js +115 -0
- package/build/fetchers/types.d.ts +38 -0
- package/build/fetchers/types.d.ts.map +1 -1
- package/build/graphql/generated/organization.d.ts +88 -0
- package/build/graphql/generated/organization.d.ts.map +1 -0
- package/build/graphql/generated/organization.js +59 -0
- package/package.json +1 -1
- package/src/api/contributed-to.ts +1 -1
- package/src/api/gist.ts +1 -1
- package/src/api/index.ts +1 -0
- package/src/api/organization.ts +90 -0
- package/src/api/params.ts +1 -1
- package/src/api/pin.ts +1 -1
- package/src/api/stats.ts +1 -1
- package/src/api/top-langs.ts +1 -1
- package/src/api/wakatime.ts +1 -1
- package/src/cards/{contributed-to.ts → contributed-to/index.ts} +42 -39
- package/src/cards/contributed-to/locales.ts +41 -0
- package/src/cards/{gist.ts → gist/index.ts} +23 -20
- package/src/cards/gist/locales.ts +17 -0
- package/src/cards/organization/index.ts +358 -0
- package/src/cards/organization/locales.ts +49 -0
- package/src/cards/{repo.ts → repo/index.ts} +23 -26
- package/src/cards/repo/locales.ts +131 -0
- package/src/cards/{stats.ts → stats/index.ts} +48 -56
- package/src/cards/stats/locales.ts +625 -0
- package/src/cards/{top-languages.ts → top-languages/index.ts} +17 -20
- package/src/cards/top-languages/locales.ts +105 -0
- package/src/cards/{wakatime.ts → wakatime/index.ts} +26 -27
- package/src/cards/wakatime/locales.ts +252 -0
- package/src/common/brand.ts +1 -0
- package/src/common/error.ts +4 -0
- package/src/common/icons.ts +20 -4
- package/src/common/locales.ts +61 -0
- package/src/common/localize.ts +251 -0
- package/src/common/render.ts +10 -3
- package/src/fetchers/index.ts +2 -0
- package/src/fetchers/organization.ts +153 -0
- package/src/fetchers/types.ts +36 -0
- package/src/graphql/generated/organization.ts +109 -0
- package/src/graphql/queries/organization.graphql +57 -0
- package/build/cards/contributed-to.d.ts.map +0 -1
- package/build/cards/gist.d.ts.map +0 -1
- package/build/cards/repo.d.ts.map +0 -1
- package/build/cards/stats.d.ts.map +0 -1
- package/build/cards/top-languages.d.ts.map +0 -1
- package/build/cards/wakatime.d.ts.map +0 -1
- package/build/common/I18n.d.ts +0 -21
- package/build/common/I18n.d.ts.map +0 -1
- package/build/common/I18n.js +0 -34
- package/build/translations.d.ts +0 -1212
- package/build/translations.d.ts.map +0 -1
- package/build/translations.js +0 -1213
- package/src/common/I18n.ts +0 -50
- package/src/translations.ts +0 -1239
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import { renderContributedToCard } from '../cards/contributed-to.js';
|
|
2
|
+
import { renderContributedToCard } from '../cards/contributed-to/index.js';
|
|
3
3
|
import { fetchContributedTo } from '../fetchers/contributed-to.js';
|
|
4
4
|
import { cardHandler } from './handler.js';
|
|
5
5
|
import { booleanParam, fromParam, localeParam, looseIntParam, numberParam, ORDERED_RANGE, rawParam, safeListParam, toParam, usernameParam, } from './params.js';
|
package/build/api/gist.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import { renderGistCard } from '../cards/gist.js';
|
|
2
|
+
import { renderGistCard } from '../cards/gist/index.js';
|
|
3
3
|
import { fetchGist } from '../fetchers/gist.js';
|
|
4
4
|
import { cardHandler } from './handler.js';
|
|
5
5
|
import { booleanParam, localeParam, numberParam, safeParam } from './params.js';
|
package/build/api/index.d.ts
CHANGED
package/build/api/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,GAAG,EAAE,MAAM,mBAAmB,CAAC;AACxC,OAAO,EAAE,GAAG,EAAE,MAAM,UAAU,CAAC;AAC/B,OAAO,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AACnC,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC1C,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,YAAY,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAG3D,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC/E,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACnD,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,YAAY,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC"}
|
package/build/api/index.js
CHANGED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
/**
|
|
3
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
4
|
+
* A UI reads them off the function it calls: `org.OPTIONS.show`.
|
|
5
|
+
*/
|
|
6
|
+
export declare const org: ((query: import("./params.ts").ApiQuery<z.ZodMiniObject<{
|
|
7
|
+
org: z.ZodMiniType<string | undefined, string | undefined, z.core.$ZodTypeInternals<string | undefined, string | undefined>>;
|
|
8
|
+
hide: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string[], string | undefined>>;
|
|
9
|
+
show: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string[], string | undefined>>;
|
|
10
|
+
show_icons: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
11
|
+
hide_title: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
12
|
+
hide_border: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
13
|
+
hide_description: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
14
|
+
card_width: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<number | undefined, string | undefined>>;
|
|
15
|
+
line_height: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
16
|
+
custom_title: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
17
|
+
disable_animations: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
18
|
+
number_format: z.ZodMiniOptional<z.ZodMiniString<string>>;
|
|
19
|
+
text_bold: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<boolean | undefined, string | undefined>>;
|
|
20
|
+
locale: z.ZodMiniPipe<z.ZodMiniOptional<z.ZodMiniString<string>>, z.ZodMiniTransform<string | undefined, string | undefined>>;
|
|
21
|
+
border_radius: z.ZodMiniType<number | undefined, string | undefined, z.core.$ZodTypeInternals<number | undefined, string | undefined>>;
|
|
22
|
+
}, z.core.$strip>>, config: import("./index.ts").CardConfig) => Promise<import("./api-result.ts").ApiResult>) & {
|
|
23
|
+
OPTIONS: {
|
|
24
|
+
show: readonly ["releases", "commits", "members", "top_language", "created"];
|
|
25
|
+
hide: readonly ["repos", "stars", "forks", "watchers", "open_issues", "open_prs"];
|
|
26
|
+
number_format: readonly ["short", "long"];
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
//# sourceMappingURL=organization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization.d.ts","sourceRoot":"","sources":["../../src/api/organization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,UAAU,CAAC;AAqF9B;;;GAGG;AACH,eAAO,MAAM,GAAG;;;;;;;;;;;;;;;;;;;;;;CAAwE,CAAC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import * as z from 'zod/mini';
|
|
2
|
+
import { renderOrganizationCard } from '../cards/organization/index.js';
|
|
3
|
+
import { fetchOrganization } from '../fetchers/organization.js';
|
|
4
|
+
import { cardHandler } from './handler.js';
|
|
5
|
+
import { booleanParam, listParam, localeParam, looseIntParam, numberParam, rawParam, usernameParam, } from './params.js';
|
|
6
|
+
/** What the organization endpoint accepts, on top of the shared color params. */
|
|
7
|
+
const orgQuery = z.object({
|
|
8
|
+
org: usernameParam,
|
|
9
|
+
hide: listParam,
|
|
10
|
+
show: listParam,
|
|
11
|
+
show_icons: booleanParam,
|
|
12
|
+
hide_title: booleanParam,
|
|
13
|
+
hide_border: booleanParam,
|
|
14
|
+
hide_description: booleanParam,
|
|
15
|
+
card_width: looseIntParam,
|
|
16
|
+
line_height: rawParam,
|
|
17
|
+
custom_title: rawParam,
|
|
18
|
+
disable_animations: booleanParam,
|
|
19
|
+
number_format: rawParam,
|
|
20
|
+
text_bold: booleanParam,
|
|
21
|
+
locale: localeParam,
|
|
22
|
+
border_radius: numberParam,
|
|
23
|
+
});
|
|
24
|
+
/**
|
|
25
|
+
* Render the organization card for a set of query params.
|
|
26
|
+
*
|
|
27
|
+
* @returns The rendered card, or a rendered error.
|
|
28
|
+
*/
|
|
29
|
+
const renderOrg = cardHandler(orgQuery, async ({ org, hide, show, show_icons, hide_title, hide_border, hide_description, card_width, line_height, custom_title, disable_animations, number_format, text_bold, locale, border_radius, }, colors, config) => {
|
|
30
|
+
const organizationData = await fetchOrganization({ org }, config);
|
|
31
|
+
return renderOrganizationCard(organizationData, {
|
|
32
|
+
...colors,
|
|
33
|
+
hide,
|
|
34
|
+
show,
|
|
35
|
+
show_icons,
|
|
36
|
+
hide_title,
|
|
37
|
+
hide_border,
|
|
38
|
+
hide_description,
|
|
39
|
+
card_width,
|
|
40
|
+
line_height,
|
|
41
|
+
custom_title,
|
|
42
|
+
disable_animations,
|
|
43
|
+
number_format,
|
|
44
|
+
text_bold,
|
|
45
|
+
locale,
|
|
46
|
+
border_radius,
|
|
47
|
+
});
|
|
48
|
+
});
|
|
49
|
+
/**
|
|
50
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
51
|
+
* A UI reads them off the function it calls: `org.OPTIONS.show`.
|
|
52
|
+
*/
|
|
53
|
+
export const org = Object.assign(renderOrg, { OPTIONS: renderOrganizationCard.OPTIONS });
|
package/build/api/params.js
CHANGED
|
@@ -3,8 +3,8 @@ import { COLOR_PARAM_KEYS, THEME_PARAM_KEYS, isValidColorInput } from '../common
|
|
|
3
3
|
import { GITHUB_USERNAME_PATTERN } from '../common/constants.js';
|
|
4
4
|
import { getWidestRange, parseRangeDate } from '../common/date.js';
|
|
5
5
|
import { CardError } from '../common/error.js';
|
|
6
|
+
import { isLocaleAvailable } from '../common/localize.js';
|
|
6
7
|
import { parseArray, parseBoolean } from '../common/ops.js';
|
|
7
|
-
import { isLocaleAvailable } from '../translations.js';
|
|
8
8
|
/**
|
|
9
9
|
* @file The api layer is the trust boundary:
|
|
10
10
|
* a query string arrives as strings, and each endpoint declares what it accepts as a schema over them.
|
package/build/api/pin.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import { renderRepoCard } from '../cards/repo.js';
|
|
2
|
+
import { renderRepoCard } from '../cards/repo/index.js';
|
|
3
3
|
import { fetchRepo } from '../fetchers/repo.js';
|
|
4
4
|
import { cardHandler } from './handler.js';
|
|
5
5
|
import { booleanParam, listParam, localeParam, looseIntParam, numberParam, rawParam, safeParam, usernameParam, } from './params.js';
|
package/build/api/stats.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import { renderStatsCard } from '../cards/stats.js';
|
|
2
|
+
import { renderStatsCard } from '../cards/stats/index.js';
|
|
3
3
|
import { OWNER_AFFILIATIONS } from '../common/constants.js';
|
|
4
4
|
import { fetchStats } from '../fetchers/stats.js';
|
|
5
5
|
import { cardHandler } from './handler.js';
|
package/build/api/top-langs.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import { renderTopLanguages } from '../cards/top-languages.js';
|
|
2
|
+
import { renderTopLanguages } from '../cards/top-languages/index.js';
|
|
3
3
|
import { OWNER_AFFILIATIONS } from '../common/constants.js';
|
|
4
4
|
import { fetchTopLanguages } from '../fetchers/top-languages.js';
|
|
5
5
|
import { cardHandler } from './handler.js';
|
package/build/api/wakatime.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as z from 'zod/mini';
|
|
2
|
-
import { renderWakatimeCard } from '../cards/wakatime.js';
|
|
2
|
+
import { renderWakatimeCard } from '../cards/wakatime/index.js';
|
|
3
3
|
import { fetchWakatimeStats } from '../fetchers/wakatime.js';
|
|
4
4
|
import { cardHandler } from './handler.js';
|
|
5
5
|
import { booleanParam, enumParam, listParam, localeParam, looseIntParam, numberParam, rawParam, safeParam, } from './params.js';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { ContributedToData } from '
|
|
2
|
-
import type { CardOptions, CommonCardOptions } from '
|
|
1
|
+
import type { ContributedToData } from '../../fetchers/types.ts';
|
|
2
|
+
import type { CardOptions, CommonCardOptions } from '../options.ts';
|
|
3
3
|
declare const MIN_CARD_WIDTH = 340;
|
|
4
4
|
interface ContributedToCardOptions extends CommonCardOptions {
|
|
5
5
|
locale: string;
|
|
@@ -16,4 +16,4 @@ interface ContributedToCardOptions extends CommonCardOptions {
|
|
|
16
16
|
*/
|
|
17
17
|
declare const renderContributedToCard: (data: ContributedToData, options?: CardOptions<ContributedToCardOptions>) => string;
|
|
18
18
|
export { renderContributedToCard, MIN_CARD_WIDTH };
|
|
19
|
-
//# sourceMappingURL=
|
|
19
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cards/contributed-to/index.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAmB,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAGlF,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAKpE,QAAA,MAAM,cAAc,MAAM,CAAC;AA8B3B,UAAU,wBAAyB,SAAQ,iBAAiB;IAC1D,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,MAAM,CAAC;IACnB,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,UAAU,EAAE,OAAO,CAAC;CACrB;AAoKD;;;;GAIG;AACH,QAAA,MAAM,uBAAuB,SACrB,iBAAiB,YACd,WAAW,CAAC,wBAAwB,CAAC,KAC7C,MAmJF,CAAC;AAEF,OAAO,EAAE,uBAAuB,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { CARD_ICON, CARD_WIDTH, FONT_SIZE, firefoxFontSize, font } from '
|
|
2
|
-
import { Card } from '
|
|
3
|
-
import { getLightDarkColors } from '
|
|
4
|
-
import { formatYears } from '
|
|
5
|
-
import { kFormatter } from '
|
|
6
|
-
import {
|
|
7
|
-
import { clampValue } from '
|
|
8
|
-
import { createProgressNode, measureText } from '
|
|
9
|
-
import { atRule, el, rule } from '
|
|
10
|
-
import { contributedToCardLocales } from '
|
|
1
|
+
import { CARD_ICON, CARD_WIDTH, FONT_SIZE, firefoxFontSize, font } from '../../common/brand.js';
|
|
2
|
+
import { Card } from '../../common/Card.js';
|
|
3
|
+
import { getLightDarkColors } from '../../common/color.js';
|
|
4
|
+
import { formatYears } from '../../common/date.js';
|
|
5
|
+
import { kFormatter } from '../../common/fmt.js';
|
|
6
|
+
import { localize } from '../../common/localize.js';
|
|
7
|
+
import { clampValue } from '../../common/ops.js';
|
|
8
|
+
import { createProgressNode, measureText } from '../../common/render.js';
|
|
9
|
+
import { atRule, el, rule } from '../../markup/index.js';
|
|
10
|
+
import { contributedToCardLocales } from './locales.js';
|
|
11
11
|
const CARD_DEFAULT_WIDTH = CARD_WIDTH.wide;
|
|
12
12
|
const MIN_CARD_WIDTH = 340;
|
|
13
13
|
/** Padding the card keeps at its edges; matches `Card`'s own `paddingX`. */
|
|
@@ -42,11 +42,9 @@ const BOTTOM_PADDING = 18;
|
|
|
42
42
|
*
|
|
43
43
|
* @returns The default title, which `custom_title` still overrides.
|
|
44
44
|
*/
|
|
45
|
-
const defaultTitleFor = (
|
|
46
|
-
const named =
|
|
47
|
-
return measureText(named, TITLE_FONT_SIZE) <= contentWidth
|
|
48
|
-
? named
|
|
49
|
-
: i18n.t('contributedtocard.title-unnamed');
|
|
45
|
+
const defaultTitleFor = (t, login, contentWidth) => {
|
|
46
|
+
const named = t.title({ login });
|
|
47
|
+
return measureText(named, TITLE_FONT_SIZE) <= contentWidth ? named : t.titleUnnamed();
|
|
50
48
|
};
|
|
51
49
|
/**
|
|
52
50
|
* Shortens a name to fit its column, ending it with an ellipsis when it does not.
|
|
@@ -118,9 +116,11 @@ const createRepoRow = ({ repo, index, maxContributions, years, nameWidth, conten
|
|
|
118
116
|
*
|
|
119
117
|
* @returns The footer text.
|
|
120
118
|
*/
|
|
121
|
-
const footerText = ({
|
|
119
|
+
const footerText = ({ t, shown, totalRepos, years, }) => {
|
|
122
120
|
const parts = [
|
|
123
|
-
|
|
121
|
+
shown < totalRepos
|
|
122
|
+
? t.footerTop({ shown, count: totalRepos })
|
|
123
|
+
: t.footerAll({ count: totalRepos }),
|
|
124
124
|
];
|
|
125
125
|
const [firstYear] = years;
|
|
126
126
|
const lastYear = years.at(-1);
|
|
@@ -155,17 +155,14 @@ const renderContributedToCard = (data, options = {}) => {
|
|
|
155
155
|
contentWidth,
|
|
156
156
|
rowHeight,
|
|
157
157
|
}));
|
|
158
|
-
const
|
|
159
|
-
|
|
160
|
-
translations: contributedToCardLocales({ login, shown: repos.length, totalRepos }),
|
|
161
|
-
});
|
|
162
|
-
const footer = footerText({ i18n, shown: repos.length, totalRepos, years });
|
|
158
|
+
const t = localize(contributedToCardLocales, locale);
|
|
159
|
+
const footer = footerText({ t, shown: repos.length, totalRepos, years });
|
|
163
160
|
const footerY = FIRST_ROW_Y + Math.max(repos.length, 1) * rowHeight + FOOTER_GAP;
|
|
164
161
|
const height = BODY_OFFSET_Y + footerY + BOTTOM_PADDING;
|
|
165
162
|
const { lightColors, darkColors } = getLightDarkColors({ ...options, theme });
|
|
166
163
|
const card = new Card({
|
|
167
164
|
customTitle: custom_title,
|
|
168
|
-
defaultTitle: defaultTitleFor(
|
|
165
|
+
defaultTitle: defaultTitleFor(t, login, contentWidth - TITLE_ICON_COLUMN),
|
|
169
166
|
titlePrefixIcon: CARD_ICON.contributedTo,
|
|
170
167
|
width,
|
|
171
168
|
height,
|
|
@@ -226,17 +223,21 @@ const renderContributedToCard = (data, options = {}) => {
|
|
|
226
223
|
card.setAccessibilityLabel({
|
|
227
224
|
title: card.title,
|
|
228
225
|
desc: [
|
|
229
|
-
...repos.map((repo) =>
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
:
|
|
233
|
-
|
|
234
|
-
|
|
226
|
+
...repos.map((repo) => hide_years
|
|
227
|
+
? t.accessibilityRepo({
|
|
228
|
+
repo: repo.nameWithOwner,
|
|
229
|
+
count: repo.contributions,
|
|
230
|
+
})
|
|
231
|
+
: t.accessibilityRepoYears({
|
|
232
|
+
repo: repo.nameWithOwner,
|
|
233
|
+
count: repo.contributions,
|
|
234
|
+
years: repo.years.join(', '),
|
|
235
|
+
})),
|
|
235
236
|
footer,
|
|
236
237
|
].join('; '),
|
|
237
238
|
});
|
|
238
239
|
return card.render(el('g', { 'data-testid': 'contributed-to-body', transform: `translate(${CARD_PADDING}, 0)` }, repos.length === 0
|
|
239
|
-
? el('text', { class: 'repo-name', 'data-testid': 'no-repos', x: 0, y: FIRST_ROW_Y },
|
|
240
|
+
? el('text', { class: 'repo-name', 'data-testid': 'no-repos', x: 0, y: FIRST_ROW_Y }, t.noContributions())
|
|
240
241
|
: rows, el('text', { class: 'footer', 'data-testid': 'footer', x: 0, y: footerY }, footer)));
|
|
241
242
|
};
|
|
242
243
|
export { renderContributedToCard, MIN_CARD_WIDTH };
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
/** The contributed-to card's labels in the locales they have been translated into. */
|
|
2
|
+
declare const contributedToCardLocales: {
|
|
3
|
+
readonly title: {
|
|
4
|
+
readonly en: "Repositories {login} contributed to";
|
|
5
|
+
};
|
|
6
|
+
readonly titleUnnamed: {
|
|
7
|
+
readonly en: "Repositories contributed to";
|
|
8
|
+
};
|
|
9
|
+
readonly noContributions: {
|
|
10
|
+
readonly en: "No contributions found";
|
|
11
|
+
};
|
|
12
|
+
readonly footerAll: {
|
|
13
|
+
readonly en: {
|
|
14
|
+
readonly one: "{count} repository";
|
|
15
|
+
readonly other: "{count} repositories";
|
|
16
|
+
};
|
|
17
|
+
};
|
|
18
|
+
readonly footerTop: {
|
|
19
|
+
readonly en: {
|
|
20
|
+
readonly one: "top {shown} of {count} repository";
|
|
21
|
+
readonly other: "top {shown} of {count} repositories";
|
|
22
|
+
};
|
|
23
|
+
};
|
|
24
|
+
readonly accessibilityRepo: {
|
|
25
|
+
readonly en: {
|
|
26
|
+
readonly one: "{repo}: {count} contribution";
|
|
27
|
+
readonly other: "{repo}: {count} contributions";
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
readonly accessibilityRepoYears: {
|
|
31
|
+
readonly en: {
|
|
32
|
+
readonly one: "{repo}: {count} contribution, years: {years}";
|
|
33
|
+
readonly other: "{repo}: {count} contributions, years: {years}";
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
};
|
|
37
|
+
export { contributedToCardLocales };
|
|
38
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/cards/contributed-to/locales.ts"],"names":[],"mappings":"AAEA,sFAAsF;AACtF,QAAA,MAAM,wBAAwB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAmC5B,CAAC;AAEH,OAAO,EAAE,wBAAwB,EAAE,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { defineLocales } from '../../common/localize.js';
|
|
2
|
+
/** The contributed-to card's labels in the locales they have been translated into. */
|
|
3
|
+
const contributedToCardLocales = defineLocales({
|
|
4
|
+
title: {
|
|
5
|
+
en: 'Repositories {login} contributed to',
|
|
6
|
+
},
|
|
7
|
+
// Drawn instead of the title above when naming the account overruns the card.
|
|
8
|
+
titleUnnamed: {
|
|
9
|
+
en: 'Repositories contributed to',
|
|
10
|
+
},
|
|
11
|
+
noContributions: {
|
|
12
|
+
en: 'No contributions found',
|
|
13
|
+
},
|
|
14
|
+
footerAll: {
|
|
15
|
+
en: { one: '{count} repository', other: '{count} repositories' },
|
|
16
|
+
},
|
|
17
|
+
footerTop: {
|
|
18
|
+
en: {
|
|
19
|
+
one: 'top {shown} of {count} repository',
|
|
20
|
+
other: 'top {shown} of {count} repositories',
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
// One row of what an assistive reader gets in place of the card, whose inner text
|
|
24
|
+
// `role="img"` hides. The year marks carry information no other element does, so the
|
|
25
|
+
// row naming them is a wording of its own rather than a fragment appended to the other.
|
|
26
|
+
accessibilityRepo: {
|
|
27
|
+
en: {
|
|
28
|
+
one: '{repo}: {count} contribution',
|
|
29
|
+
other: '{repo}: {count} contributions',
|
|
30
|
+
},
|
|
31
|
+
},
|
|
32
|
+
accessibilityRepoYears: {
|
|
33
|
+
en: {
|
|
34
|
+
one: '{repo}: {count} contribution, years: {years}',
|
|
35
|
+
other: '{repo}: {count} contributions, years: {years}',
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
});
|
|
39
|
+
export { contributedToCardLocales };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import type { GistData } from '
|
|
2
|
-
import type { CardOptions, CommonCardOptions } from '
|
|
1
|
+
import type { GistData } from '../../fetchers/types.ts';
|
|
2
|
+
import type { CardOptions, CommonCardOptions } from '../options.ts';
|
|
3
3
|
interface GistCardOptions extends CommonCardOptions {
|
|
4
4
|
locale: string;
|
|
5
5
|
show_owner: boolean;
|
|
@@ -12,4 +12,4 @@ interface GistCardOptions extends CommonCardOptions {
|
|
|
12
12
|
*/
|
|
13
13
|
declare const renderGistCard: (gistData: GistData, options?: CardOptions<GistCardOptions>) => string;
|
|
14
14
|
export { renderGistCard };
|
|
15
|
-
//# sourceMappingURL=
|
|
15
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cards/gist/index.ts"],"names":[],"mappings":"AAkBA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AAapE,UAAU,eAAgB,SAAQ,iBAAiB;IACjD,MAAM,EAAE,MAAM,CAAC;IACf,UAAU,EAAE,OAAO,CAAC;IACpB,iBAAiB,EAAE,OAAO,CAAC;CAC5B;AAED;;;;GAIG;AACH,QAAA,MAAM,cAAc,aAAc,QAAQ,YAAW,WAAW,CAAC,eAAe,CAAC,KAAQ,MAkIxF,CAAC;AAEF,OAAO,EAAE,cAAc,EAAE,CAAC"}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import { CARD_ICON, CARD_WIDTH, FONT_SIZE, font } from '
|
|
2
|
-
import { Card } from '
|
|
3
|
-
import { getLightDarkColors } from '
|
|
4
|
-
import { kFormatter } from '
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import { parseEmojis } from '
|
|
9
|
-
import { countWrappedLines, wrapTextMultiline, createLanguageNode, flexLayout, iconWithLabel, measureText, wrappedTextNode, wrappedTextStyles, } from '
|
|
10
|
-
import { el, rule } from '
|
|
11
|
-
import { gistCardLocales } from '
|
|
1
|
+
import { CARD_ICON, CARD_WIDTH, FONT_SIZE, font } from '../../common/brand.js';
|
|
2
|
+
import { Card } from '../../common/Card.js';
|
|
3
|
+
import { getLightDarkColors } from '../../common/color.js';
|
|
4
|
+
import { kFormatter } from '../../common/fmt.js';
|
|
5
|
+
import { icons } from '../../common/icons.js';
|
|
6
|
+
import { getLanguageColor } from '../../common/languageColors.js';
|
|
7
|
+
import { localize } from '../../common/localize.js';
|
|
8
|
+
import { parseEmojis } from '../../common/ops.js';
|
|
9
|
+
import { countWrappedLines, wrapTextMultiline, createLanguageNode, flexLayout, iconWithLabel, measureText, wrappedTextNode, wrappedTextStyles, } from '../../common/render.js';
|
|
10
|
+
import { el, rule } from '../../markup/index.js';
|
|
11
|
+
import { gistCardLocales } from './locales.js';
|
|
12
12
|
const ICON_SIZE = 16;
|
|
13
13
|
const CARD_DEFAULT_WIDTH = CARD_WIDTH.standard;
|
|
14
14
|
const X_OFFSET = 25;
|
|
@@ -26,8 +26,8 @@ const renderGistCard = (gistData, options = {}) => {
|
|
|
26
26
|
const { name, nameWithOwner, description, language, starsCount, forksCount } = gistData;
|
|
27
27
|
const { locale, theme = 'default_repocard', border_radius, show_owner = false, browser_rendering = false, hide_border = false, } = options;
|
|
28
28
|
const { lightColors, darkColors } = getLightDarkColors({ ...options, theme });
|
|
29
|
-
const
|
|
30
|
-
const desc = parseEmojis(description ||
|
|
29
|
+
const t = localize(gistCardLocales, locale);
|
|
30
|
+
const desc = parseEmojis(description || t.noDescription());
|
|
31
31
|
let descriptionLines;
|
|
32
32
|
let descriptionSvg;
|
|
33
33
|
if (browser_rendering) {
|
|
@@ -59,7 +59,7 @@ const renderGistCard = (gistData, options = {}) => {
|
|
|
59
59
|
const totalForks = kFormatter(forksCount);
|
|
60
60
|
const svgStars = iconWithLabel(icons.star, totalStars, 'starsCount', ICON_SIZE);
|
|
61
61
|
const svgForks = iconWithLabel(icons.fork, totalForks, 'forksCount', ICON_SIZE);
|
|
62
|
-
const languageName = language ||
|
|
62
|
+
const languageName = language || t.unspecifiedLanguage();
|
|
63
63
|
const languageColor = getLanguageColor(languageName);
|
|
64
64
|
const svgLanguage = createLanguageNode(languageName, languageColor);
|
|
65
65
|
const starAndForkCount = flexLayout({
|
|
@@ -104,7 +104,12 @@ const renderGistCard = (gistData, options = {}) => {
|
|
|
104
104
|
// shows has to be repeated here.
|
|
105
105
|
card.setAccessibilityLabel({
|
|
106
106
|
title: card.title,
|
|
107
|
-
desc:
|
|
107
|
+
desc: t.accessibilityDesc({
|
|
108
|
+
desc,
|
|
109
|
+
language: languageName,
|
|
110
|
+
stars: totalStars,
|
|
111
|
+
forks: totalForks,
|
|
112
|
+
}),
|
|
108
113
|
});
|
|
109
114
|
return card.render([
|
|
110
115
|
descriptionSvg,
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/** The gist card's labels in the locales they have been translated into. */
|
|
2
|
+
declare const gistCardLocales: {
|
|
3
|
+
readonly noDescription: {
|
|
4
|
+
readonly en: "No description provided";
|
|
5
|
+
};
|
|
6
|
+
readonly unspecifiedLanguage: {
|
|
7
|
+
readonly en: "Unspecified";
|
|
8
|
+
};
|
|
9
|
+
readonly accessibilityDesc: {
|
|
10
|
+
readonly en: "{desc}. Language: {language}, Stars: {stars}, Forks: {forks}";
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
export { gistCardLocales };
|
|
14
|
+
//# sourceMappingURL=locales.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"locales.d.ts","sourceRoot":"","sources":["../../../src/cards/gist/locales.ts"],"names":[],"mappings":"AAEA,4EAA4E;AAC5E,QAAA,MAAM,eAAe;;;;;;;;;;CAWnB,CAAC;AAEH,OAAO,EAAE,eAAe,EAAE,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { defineLocales } from '../../common/localize.js';
|
|
2
|
+
/** The gist card's labels in the locales they have been translated into. */
|
|
3
|
+
const gistCardLocales = defineLocales({
|
|
4
|
+
noDescription: {
|
|
5
|
+
en: 'No description provided',
|
|
6
|
+
},
|
|
7
|
+
unspecifiedLanguage: {
|
|
8
|
+
en: 'Unspecified',
|
|
9
|
+
},
|
|
10
|
+
// What an assistive reader gets in place of the card, whose inner text `role="img"` hides.
|
|
11
|
+
accessibilityDesc: {
|
|
12
|
+
en: '{desc}. Language: {language}, Stars: {stars}, Forks: {forks}',
|
|
13
|
+
},
|
|
14
|
+
});
|
|
15
|
+
export { gistCardLocales };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import type { OrganizationData } from '../../fetchers/types.ts';
|
|
2
|
+
import type { CardOptions, CommonCardOptions } from '../options.ts';
|
|
3
|
+
interface OrgCardOptions extends CommonCardOptions {
|
|
4
|
+
locale: string;
|
|
5
|
+
hide: Array<string>;
|
|
6
|
+
show: Array<string>;
|
|
7
|
+
show_icons: boolean;
|
|
8
|
+
hide_title: boolean;
|
|
9
|
+
hide_description: boolean;
|
|
10
|
+
card_width: number;
|
|
11
|
+
line_height: number | string;
|
|
12
|
+
custom_title: string;
|
|
13
|
+
disable_animations: boolean;
|
|
14
|
+
number_format: string;
|
|
15
|
+
text_bold: boolean;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* Renders the organization card.
|
|
19
|
+
*
|
|
20
|
+
* @returns The organization card SVG object.
|
|
21
|
+
*/
|
|
22
|
+
declare const renderCard: (organization: OrganizationData, options?: CardOptions<OrgCardOptions>) => string;
|
|
23
|
+
/**
|
|
24
|
+
* The card, and the values each of its options accepts, keyed by the option's own name.
|
|
25
|
+
* They ride on the renderer so a list cannot be found without what draws it;
|
|
26
|
+
* the api handler forwards them onto its own export, which is what a UI reads.
|
|
27
|
+
*/
|
|
28
|
+
declare const renderOrganizationCard: typeof renderCard & {
|
|
29
|
+
OPTIONS: {
|
|
30
|
+
show: readonly ["releases", "commits", "members", "top_language", "created"];
|
|
31
|
+
hide: readonly ["repos", "stars", "forks", "watchers", "open_issues", "open_prs"];
|
|
32
|
+
number_format: readonly ["short", "long"];
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
export { renderOrganizationCard };
|
|
36
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/cards/organization/index.ts"],"names":[],"mappings":"AAgBA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAGhE,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,eAAe,CAAC;AA6BpE,UAAU,cAAe,SAAQ,iBAAiB;IAChD,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,IAAI,EAAE,KAAK,CAAC,MAAM,CAAC,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,UAAU,EAAE,OAAO,CAAC;IACpB,gBAAgB,EAAE,OAAO,CAAC;IAC1B,UAAU,EAAE,MAAM,CAAC;IACnB,WAAW,EAAE,MAAM,GAAG,MAAM,CAAC;IAC7B,YAAY,EAAE,MAAM,CAAC;IACrB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,OAAO,CAAC;CACpB;AAkCD;;;;GAIG;AACH,QAAA,MAAM,UAAU,iBACA,gBAAgB,YACrB,WAAW,CAAC,cAAc,CAAC,KACnC,MA+OF,CAAC;AAEF;;;;GAIG;AACH,QAAA,MAAM,sBAAsB;;QAExB,IAAI;QACJ,IAAI;QACJ,aAAa;;CAEf,CAAC;AAEH,OAAO,EAAE,sBAAsB,EAAE,CAAC"}
|