@stats-forge/github-stats-forge-core 0.0.2 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (208) hide show
  1. package/README.md +0 -10
  2. package/build/api/api-result.d.ts +6 -7
  3. package/build/api/api-result.d.ts.map +1 -1
  4. package/build/api/api-result.js +4 -5
  5. package/build/api/gist.d.ts +3 -10
  6. package/build/api/gist.d.ts.map +1 -1
  7. package/build/api/gist.js +4 -11
  8. package/build/api/index.d.ts +12 -12
  9. package/build/api/params.d.ts +11 -8
  10. package/build/api/params.d.ts.map +1 -1
  11. package/build/api/params.js +16 -14
  12. package/build/api/pin.d.ts +3 -19
  13. package/build/api/pin.d.ts.map +1 -1
  14. package/build/api/pin.js +6 -22
  15. package/build/api/stats.d.ts +10 -4
  16. package/build/api/stats.d.ts.map +1 -1
  17. package/build/api/stats.js +6 -32
  18. package/build/api/top-langs.d.ts +12 -6
  19. package/build/api/top-langs.d.ts.map +1 -1
  20. package/build/api/top-langs.js +6 -26
  21. package/build/api/wakatime.d.ts +13 -5
  22. package/build/api/wakatime.d.ts.map +1 -1
  23. package/build/api/wakatime.js +4 -21
  24. package/build/calculateRank.d.ts +0 -9
  25. package/build/calculateRank.d.ts.map +1 -1
  26. package/build/calculateRank.js +12 -17
  27. package/build/cards/gist.d.ts +2 -4
  28. package/build/cards/gist.d.ts.map +1 -1
  29. package/build/cards/gist.js +27 -36
  30. package/build/cards/options.d.ts +1 -1
  31. package/build/cards/repo.d.ts +2 -4
  32. package/build/cards/repo.d.ts.map +1 -1
  33. package/build/cards/repo.js +61 -93
  34. package/build/cards/stats.d.ts +3 -8
  35. package/build/cards/stats.d.ts.map +1 -1
  36. package/build/cards/stats.js +119 -165
  37. package/build/cards/top-languages.d.ts +5 -31
  38. package/build/cards/top-languages.d.ts.map +1 -1
  39. package/build/cards/top-languages.js +176 -384
  40. package/build/cards/wakatime.d.ts +4 -6
  41. package/build/cards/wakatime.d.ts.map +1 -1
  42. package/build/cards/wakatime.js +118 -185
  43. package/build/common/Card.d.ts +14 -62
  44. package/build/common/Card.d.ts.map +1 -1
  45. package/build/common/Card.js +97 -199
  46. package/build/common/I18n.d.ts +0 -6
  47. package/build/common/I18n.d.ts.map +1 -1
  48. package/build/common/I18n.js +3 -6
  49. package/build/common/color.d.ts +4 -17
  50. package/build/common/color.d.ts.map +1 -1
  51. package/build/common/color.js +67 -49
  52. package/build/common/config.d.ts +4 -14
  53. package/build/common/config.d.ts.map +1 -1
  54. package/build/common/config.js +3 -16
  55. package/build/common/constants.d.ts +4 -2
  56. package/build/common/constants.d.ts.map +1 -1
  57. package/build/common/constants.js +3 -1
  58. package/build/common/date.d.ts +0 -2
  59. package/build/common/date.d.ts.map +1 -1
  60. package/build/common/date.js +0 -2
  61. package/build/common/emojiMap.d.ts +8 -0
  62. package/build/common/emojiMap.d.ts.map +1 -0
  63. package/build/common/emojiMap.js +10 -0
  64. package/build/common/emojiMap.json +1915 -0
  65. package/build/common/error.d.ts +1 -10
  66. package/build/common/error.d.ts.map +1 -1
  67. package/build/common/error.js +1 -10
  68. package/build/common/fmt.d.ts +3 -15
  69. package/build/common/fmt.d.ts.map +1 -1
  70. package/build/common/fmt.js +7 -35
  71. package/build/common/http.d.ts +2 -7
  72. package/build/common/http.d.ts.map +1 -1
  73. package/build/common/http.js +8 -17
  74. package/build/common/icons.d.ts +18 -20
  75. package/build/common/icons.d.ts.map +1 -1
  76. package/build/common/icons.js +103 -67
  77. package/build/common/languageColors.d.ts +0 -1
  78. package/build/common/languageColors.d.ts.map +1 -1
  79. package/build/common/languageColors.js +1 -4
  80. package/build/common/languageColors.json +18 -2
  81. package/build/common/ops.d.ts +3 -14
  82. package/build/common/ops.d.ts.map +1 -1
  83. package/build/common/ops.js +19 -30
  84. package/build/common/render.d.ts +28 -82
  85. package/build/common/render.d.ts.map +1 -1
  86. package/build/common/render.js +175 -211
  87. package/build/common/retryer.d.ts +2 -7
  88. package/build/common/retryer.d.ts.map +1 -1
  89. package/build/common/retryer.js +4 -11
  90. package/build/fetchers/gist.d.ts +2 -5
  91. package/build/fetchers/gist.d.ts.map +1 -1
  92. package/build/fetchers/gist.js +1 -5
  93. package/build/fetchers/index.d.ts +12 -12
  94. package/build/fetchers/repo.d.ts +2 -11
  95. package/build/fetchers/repo.d.ts.map +1 -1
  96. package/build/fetchers/repo.js +20 -33
  97. package/build/fetchers/stats.d.ts +2 -32
  98. package/build/fetchers/stats.d.ts.map +1 -1
  99. package/build/fetchers/stats.js +27 -86
  100. package/build/fetchers/top-languages.d.ts +2 -9
  101. package/build/fetchers/top-languages.d.ts.map +1 -1
  102. package/build/fetchers/top-languages.js +15 -31
  103. package/build/fetchers/types.d.ts +1 -1
  104. package/build/fetchers/wakatime.d.ts +2 -6
  105. package/build/fetchers/wakatime.d.ts.map +1 -1
  106. package/build/fetchers/wakatime.js +1 -5
  107. package/build/graphql/contributionsDocument.d.ts +3 -3
  108. package/build/graphql/contributionsDocument.d.ts.map +1 -1
  109. package/build/graphql/contributionsDocument.js +0 -1
  110. package/build/graphql/generated/gist.d.ts +1 -1
  111. package/build/graphql/generated/repo.d.ts +1 -1
  112. package/build/graphql/generated/stats.d.ts +3 -3
  113. package/build/graphql/generated/top-languages.d.ts +2 -2
  114. package/build/graphql/graphqlDocument.d.ts +0 -1
  115. package/build/graphql/graphqlDocument.d.ts.map +1 -1
  116. package/build/graphql/graphqlDocument.js +0 -1
  117. package/build/graphql/reposContributedToDocument.d.ts +4 -5
  118. package/build/graphql/reposContributedToDocument.d.ts.map +1 -1
  119. package/build/graphql/reposContributedToDocument.js +0 -2
  120. package/build/markup/css.d.ts +35 -0
  121. package/build/markup/css.d.ts.map +1 -0
  122. package/build/markup/css.js +64 -0
  123. package/build/markup/element.d.ts +41 -0
  124. package/build/markup/element.d.ts.map +1 -0
  125. package/build/markup/element.js +127 -0
  126. package/build/markup/html.d.ts +13 -0
  127. package/build/markup/html.d.ts.map +1 -0
  128. package/build/markup/html.js +27 -0
  129. package/build/markup/index.d.ts +9 -0
  130. package/build/markup/index.d.ts.map +1 -0
  131. package/build/markup/index.js +6 -0
  132. package/build/markup/serialize.d.ts +16 -0
  133. package/build/markup/serialize.d.ts.map +1 -0
  134. package/build/markup/serialize.js +17 -0
  135. package/build/themes/index.d.ts +332 -333
  136. package/build/themes/index.d.ts.map +1 -1
  137. package/build/themes/index.js +1 -1
  138. package/build/translations.d.ts +2 -6
  139. package/build/translations.d.ts.map +1 -1
  140. package/build/translations.js +621 -628
  141. package/package.json +17 -26
  142. package/src/api/api-result.ts +10 -9
  143. package/src/api/gist.ts +11 -18
  144. package/src/api/index.ts +12 -12
  145. package/src/api/params.ts +27 -21
  146. package/src/api/pin.ts +13 -28
  147. package/src/api/stats.ts +13 -39
  148. package/src/api/top-langs.ts +13 -33
  149. package/src/api/wakatime.ts +11 -28
  150. package/src/calculateRank.ts +12 -23
  151. package/src/cards/gist.ts +40 -43
  152. package/src/cards/options.ts +1 -1
  153. package/src/cards/repo.ts +97 -107
  154. package/src/cards/stats.ts +165 -184
  155. package/src/cards/top-languages.ts +297 -413
  156. package/src/cards/wakatime.ts +193 -221
  157. package/src/common/Card.ts +165 -217
  158. package/src/common/I18n.ts +3 -6
  159. package/src/common/color.ts +80 -57
  160. package/src/common/config.ts +5 -18
  161. package/src/common/constants.ts +5 -2
  162. package/src/common/date.ts +0 -2
  163. package/src/common/emojiMap.json +1915 -0
  164. package/src/common/emojiMap.ts +13 -0
  165. package/src/common/error.ts +2 -11
  166. package/src/common/fmt.ts +7 -44
  167. package/src/common/http.ts +9 -15
  168. package/src/common/icons.ts +117 -42
  169. package/src/common/languageColors.json +18 -2
  170. package/src/common/languageColors.ts +1 -4
  171. package/src/common/ops.ts +26 -34
  172. package/src/common/render.ts +279 -232
  173. package/src/common/retryer.ts +8 -15
  174. package/src/fetchers/gist.ts +8 -12
  175. package/src/fetchers/index.ts +12 -12
  176. package/src/fetchers/repo.ts +27 -40
  177. package/src/fetchers/stats.ts +44 -102
  178. package/src/fetchers/top-languages.ts +26 -40
  179. package/src/fetchers/types.ts +1 -1
  180. package/src/fetchers/wakatime.ts +5 -9
  181. package/src/graphql/contributionsDocument.ts +7 -5
  182. package/src/graphql/generated/gist.ts +1 -1
  183. package/src/graphql/generated/repo.ts +1 -1
  184. package/src/graphql/generated/stats.ts +2 -2
  185. package/src/graphql/generated/top-languages.ts +2 -2
  186. package/src/graphql/graphqlDocument.ts +0 -1
  187. package/src/graphql/reposContributedToDocument.ts +6 -7
  188. package/src/markup/css.ts +118 -0
  189. package/src/markup/element.ts +246 -0
  190. package/src/markup/html.ts +34 -0
  191. package/src/markup/index.ts +9 -0
  192. package/src/markup/serialize.ts +27 -0
  193. package/src/themes/index.ts +1 -1
  194. package/src/translations.ts +622 -629
  195. package/build/cards/index.d.ts +0 -11
  196. package/build/cards/index.d.ts.map +0 -1
  197. package/build/cards/index.js +0 -7
  198. package/build/common/html.d.ts +0 -8
  199. package/build/common/html.d.ts.map +0 -1
  200. package/build/common/html.js +0 -14
  201. package/build/index.d.ts +0 -15
  202. package/build/index.d.ts.map +0 -1
  203. package/build/index.js +0 -10
  204. package/src/_emoji-name-map.d.ts +0 -10
  205. package/src/_github-username-regex.d.ts +0 -4
  206. package/src/cards/index.ts +0 -21
  207. package/src/common/html.ts +0 -17
  208. package/src/index.ts +0 -18
@@ -5,17 +5,13 @@ import { httpRequest } from '../common/http.js';
5
5
  *
6
6
  * WakaTime needs no GitHub token; the config is here for the transport it carries.
7
7
  *
8
- * @param props Fetcher props.
9
- * @param props.username WakaTime username.
10
- * @param props.api_domain Optional WakaTime API domain (defaults to `wakatime.com`).
11
- * @param config Deployment config supplying the transport.
12
8
  * @returns WakaTime data response.
13
9
  */
14
10
  const fetchWakatimeStats = async ({ username, api_domain, }, config) => {
15
11
  if (!username) {
16
12
  throw CardError.missingParam(['username']);
17
13
  }
18
- const domain = api_domain ? api_domain.replace(/\/$/gi, '') : 'wakatime.com';
14
+ const domain = api_domain ? api_domain.replaceAll(/\/$/gi, '') : 'wakatime.com';
19
15
  const res = await httpRequest(config.fetch, `https://${domain}/api/v1/users/${username}/stats?is_including_today=true`);
20
16
  // Only a 404 says the profile does not exist.
21
17
  // Any other failure is WakaTime being unavailable, which a retry can still answer,
@@ -1,4 +1,5 @@
1
- import type { YearContributionsFragment } from './generated/stats.js';
1
+ import type { YearContributionsFragment } from './generated/stats.ts';
2
+ import type { GraphQLDocument } from './graphqlDocument.ts';
2
3
  interface ContributionsQueryVariables {
3
4
  login: string;
4
5
  }
@@ -9,10 +10,9 @@ interface ContributionsQuery {
9
10
  * Build the all-time contributions query, one aliased `contributionsCollection` field per year.
10
11
  * The shape is only known at runtime.
11
12
  *
12
- * @param years Contribution years, one `year_<year>` alias each.
13
13
  * @returns Document for `createGraphQLFetcher`.
14
14
  */
15
- declare const buildContributionsDocument: (years: Array<number>) => import("./graphqlDocument.js").GraphQLDocument<ContributionsQuery, ContributionsQueryVariables>;
15
+ declare const buildContributionsDocument: (years: Array<number>) => GraphQLDocument<ContributionsQuery, ContributionsQueryVariables>;
16
16
  export { buildContributionsDocument };
17
17
  export type { ContributionsQuery };
18
18
  //# sourceMappingURL=contributionsDocument.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"contributionsDocument.d.ts","sourceRoot":"","sources":["../../src/graphql/contributionsDocument.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AAGtE,UAAU,2BAA2B;IACnC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,yBAAyB,CAAC,GAAG,IAAI,CAAC;CAClE;AAED;;;;;;GAMG;AACH,QAAA,MAAM,0BAA0B,GAAI,OAAO,KAAK,CAAC,MAAM,CAAC,oGAoBvD,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC;AACtC,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
1
+ {"version":3,"file":"contributionsDocument.d.ts","sourceRoot":"","sources":["../../src/graphql/contributionsDocument.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,sBAAsB,CAAC;AACtE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,UAAU,2BAA2B;IACnC,KAAK,EAAE,MAAM,CAAC;CACf;AAED,UAAU,kBAAkB;IAC1B,IAAI,EAAE,MAAM,CAAC,QAAQ,MAAM,EAAE,EAAE,yBAAyB,CAAC,GAAG,IAAI,CAAC;CAClE;AAED;;;;;GAKG;AACH,QAAA,MAAM,0BAA0B,UACvB,KAAK,CAAC,MAAM,CAAC,KACnB,eAAe,CAAC,kBAAkB,EAAE,2BAA2B,CAoBjE,CAAC;AAEF,OAAO,EAAE,0BAA0B,EAAE,CAAC;AACtC,YAAY,EAAE,kBAAkB,EAAE,CAAC"}
@@ -4,7 +4,6 @@ import { graphqlDocument } from './graphqlDocument.js';
4
4
  * Build the all-time contributions query, one aliased `contributionsCollection` field per year.
5
5
  * The shape is only known at runtime.
6
6
  *
7
- * @param years Contribution years, one `year_<year>` alias each.
8
7
  * @returns Document for `createGraphQLFetcher`.
9
8
  */
10
9
  const buildContributionsDocument = (years) => {
@@ -37,7 +37,7 @@ export type GistInfoQuery = {
37
37
  } | null;
38
38
  };
39
39
  };
40
- export declare const GistInfoDocument: import("../graphqlDocument.js").GraphQLDocument<GistInfoQuery, Exact<{
40
+ export declare const GistInfoDocument: import("../graphqlDocument.ts").GraphQLDocument<GistInfoQuery, Exact<{
41
41
  gistName: string;
42
42
  }>>;
43
43
  export {};
@@ -59,7 +59,7 @@ export type GetRepoQuery = {
59
59
  } | null;
60
60
  } | null;
61
61
  };
62
- export declare const GetRepoDocument: import("../graphqlDocument.js").GraphQLDocument<GetRepoQuery, Exact<{
62
+ export declare const GetRepoDocument: import("../graphqlDocument.ts").GraphQLDocument<GetRepoQuery, Exact<{
63
63
  login: string;
64
64
  repo: string;
65
65
  }>>;
@@ -4,7 +4,7 @@ type Exact<T extends {
4
4
  }> = {
5
5
  [K in keyof T]: T[K];
6
6
  };
7
- import type * as Types from './common.js';
7
+ import type * as Types from './common.ts';
8
8
  export type RepoNodeFragment = {
9
9
  name: string;
10
10
  stargazerCount: number;
@@ -131,12 +131,12 @@ export type RangeContributionsByRepoFragment = {
131
131
  } | null> | null;
132
132
  };
133
133
  };
134
- export declare const UserReposDocument: import("../graphqlDocument.js").GraphQLDocument<UserReposQuery, Exact<{
134
+ export declare const UserReposDocument: import("../graphqlDocument.ts").GraphQLDocument<UserReposQuery, Exact<{
135
135
  login: string;
136
136
  after?: string | null | undefined;
137
137
  ownerAffiliations?: Array<Types.RepositoryAffiliation | null | undefined> | Types.RepositoryAffiliation | null | undefined;
138
138
  }>>;
139
- export declare const UserInfoDocument: import("../graphqlDocument.js").GraphQLDocument<UserInfoQuery, Exact<{
139
+ export declare const UserInfoDocument: import("../graphqlDocument.ts").GraphQLDocument<UserInfoQuery, Exact<{
140
140
  login: string;
141
141
  after?: string | null | undefined;
142
142
  includeMergedPullRequests: boolean;
@@ -4,7 +4,7 @@ type Exact<T extends {
4
4
  }> = {
5
5
  [K in keyof T]: T[K];
6
6
  };
7
- import type * as Types from './common.js';
7
+ import type * as Types from './common.ts';
8
8
  export type TopLanguageFragment = {
9
9
  size: number;
10
10
  node: {
@@ -46,7 +46,7 @@ export type TopLanguagesQuery = {
46
46
  };
47
47
  } | null;
48
48
  };
49
- export declare const TopLanguagesDocument: import("../graphqlDocument.js").GraphQLDocument<TopLanguagesQuery, Exact<{
49
+ export declare const TopLanguagesDocument: import("../graphqlDocument.ts").GraphQLDocument<TopLanguagesQuery, Exact<{
50
50
  login: string;
51
51
  ownerAffiliations?: Array<Types.RepositoryAffiliation | null | undefined> | Types.RepositoryAffiliation | null | undefined;
52
52
  }>>;
@@ -13,7 +13,6 @@ interface GraphQLDocument<TResult, TVariables> {
13
13
  /**
14
14
  * Build a typed document.
15
15
  *
16
- * @param text The query text, including every fragment it spreads.
17
16
  * @returns The document to pass to the function created by `createGraphQLFetcher`.
18
17
  */
19
18
  declare const graphqlDocument: <TResult, TVariables>(text: string) => GraphQLDocument<TResult, TVariables>;
@@ -1 +1 @@
1
- {"version":3,"file":"graphqlDocument.d.ts","sourceRoot":"","sources":["../../src/graphql/graphqlDocument.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,UAAU,eAAe,CAAC,OAAO,EAAE,UAAU;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC;CACnC;AAED;;;;;GAKG;AACH,QAAA,MAAM,eAAe,GAAI,OAAO,EAAE,UAAU,EAC1C,MAAM,MAAM,KACX,eAAe,CAAC,OAAO,EAAE,UAAU,CAAe,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,YAAY,EAAE,eAAe,EAAE,CAAC"}
1
+ {"version":3,"file":"graphqlDocument.d.ts","sourceRoot":"","sources":["../../src/graphql/graphqlDocument.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,UAAU,eAAe,CAAC,OAAO,EAAE,UAAU;IAC3C,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,QAAQ,CAAC,EAAE,OAAO,CAAC;IAC5B,QAAQ,CAAC,WAAW,CAAC,EAAE,UAAU,CAAC;CACnC;AAED;;;;GAIG;AACH,QAAA,MAAM,eAAe,GAAI,OAAO,EAAE,UAAU,QACpC,MAAM,KACX,eAAe,CAAC,OAAO,EAAE,UAAU,CAAe,CAAC;AAEtD,OAAO,EAAE,eAAe,EAAE,CAAC;AAC3B,YAAY,EAAE,eAAe,EAAE,CAAC"}
@@ -1,7 +1,6 @@
1
1
  /**
2
2
  * Build a typed document.
3
3
  *
4
- * @param text The query text, including every fragment it spreads.
5
4
  * @returns The document to pass to the function created by `createGraphQLFetcher`.
6
5
  */
7
6
  const graphqlDocument = (text) => ({ text });
@@ -1,5 +1,6 @@
1
- import type { GitHubDateRange } from '../common/date.js';
2
- import type { RangeContributionsByRepoFragment } from './generated/stats.js';
1
+ import type { GitHubDateRange } from '../common/date.ts';
2
+ import type { RangeContributionsByRepoFragment } from './generated/stats.ts';
3
+ import type { GraphQLDocument } from './graphqlDocument.ts';
3
4
  /** max value GitHub allows for `first/maxRepositories` */
4
5
  declare const MAX_REPOSITORIES_LIMIT = 100;
5
6
  interface ReposContributedToQueryVariables {
@@ -17,11 +18,9 @@ interface ReposContributedToQuery {
17
18
  * Mirrors the `contributionTypes: [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY]`
18
19
  * filter used by `repositoriesContributedTo` in `stats.graphql`.
19
20
  *
20
- * @param ranges Ranges to fetch, one `range_<index>` alias each.
21
- * @param includeOwnRepos Whether to select `repositoryContributions`.
22
21
  * @returns Document for `createGraphQLFetcher`.
23
22
  */
24
- declare const buildReposContributedToDocument: (ranges: Array<GitHubDateRange>, includeOwnRepos: boolean) => import("./graphqlDocument.js").GraphQLDocument<ReposContributedToQuery, ReposContributedToQueryVariables>;
23
+ declare const buildReposContributedToDocument: (ranges: Array<GitHubDateRange>, includeOwnRepos: boolean) => GraphQLDocument<ReposContributedToQuery, ReposContributedToQueryVariables>;
25
24
  export { buildReposContributedToDocument, MAX_REPOSITORIES_LIMIT };
26
25
  export type { ReposContributedToQuery };
27
26
  //# sourceMappingURL=reposContributedToDocument.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"reposContributedToDocument.d.ts","sourceRoot":"","sources":["../../src/graphql/reposContributedToDocument.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAG7E,0DAA0D;AAC1D,QAAA,MAAM,sBAAsB,MAAM,CAAC;AAEnC,UAAU,gCAAgC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,gCAAgC,CAAC,GAAG,IAAI,CAAC;CAC1E;AAED;;;;;;;;;;;GAWG;AACH,QAAA,MAAM,+BAA+B,GACnC,QAAQ,KAAK,CAAC,eAAe,CAAC,EAC9B,iBAAiB,OAAO,8GA+CzB,CAAC;AAEF,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,CAAC;AACnE,YAAY,EAAE,uBAAuB,EAAE,CAAC"}
1
+ {"version":3,"file":"reposContributedToDocument.d.ts","sourceRoot":"","sources":["../../src/graphql/reposContributedToDocument.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAGzD,OAAO,KAAK,EAAE,gCAAgC,EAAE,MAAM,sBAAsB,CAAC;AAC7E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG5D,0DAA0D;AAC1D,QAAA,MAAM,sBAAsB,MAAM,CAAC;AAEnC,UAAU,gCAAgC;IACxC,KAAK,EAAE,MAAM,CAAC;IACd,eAAe,EAAE,MAAM,CAAC;CACzB;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,MAAM,CAAC,SAAS,MAAM,EAAE,EAAE,gCAAgC,CAAC,GAAG,IAAI,CAAC;CAC1E;AAED;;;;;;;;;GASG;AACH,QAAA,MAAM,+BAA+B,WAC3B,KAAK,CAAC,eAAe,CAAC,mBACb,OAAO,KACvB,eAAe,CAAC,uBAAuB,EAAE,gCAAgC,CA8C3E,CAAC;AAEF,OAAO,EAAE,+BAA+B,EAAE,sBAAsB,EAAE,CAAC;AACnE,YAAY,EAAE,uBAAuB,EAAE,CAAC"}
@@ -10,8 +10,6 @@ const MAX_REPOSITORIES_LIMIT = 100;
10
10
  * Mirrors the `contributionTypes: [COMMIT, ISSUE, PULL_REQUEST, REPOSITORY]`
11
11
  * filter used by `repositoriesContributedTo` in `stats.graphql`.
12
12
  *
13
- * @param ranges Ranges to fetch, one `range_<index>` alias each.
14
- * @param includeOwnRepos Whether to select `repositoryContributions`.
15
13
  * @returns Document for `createGraphQLFetcher`.
16
14
  */
17
15
  const buildReposContributedToDocument = (ranges, includeOwnRepos) => {
@@ -0,0 +1,35 @@
1
+ import type { Sink } from './serialize.ts';
2
+ /** Every CSS property a card declares, closed so a typo is a compile error, not a dropped rule. */
3
+ type CssProperty = '-webkit-box-orient' | '-webkit-line-clamp' | 'animation' | 'animation-delay' | 'animation-duration' | 'color' | 'display' | 'fill' | 'font' | 'font-size' | 'font-variant-numeric' | 'font-weight' | 'line-clamp' | 'line-height' | 'margin' | 'opacity' | 'overflow' | 'overflow-wrap' | 'padding-bottom' | 'stroke' | 'stroke-dasharray' | 'stroke-dashoffset' | 'stroke-linecap' | 'stroke-width' | 'text-overflow' | 'transform' | 'transform-origin' | 'width' | 'word-break';
4
+ /** A declaration whose value is `undefined` is left out, so a caller can inline a condition. */
5
+ type Declarations = Partial<Record<CssProperty, string | number | undefined>>;
6
+ type CssNode = {
7
+ readonly kind: 'rule';
8
+ readonly selector: string;
9
+ readonly declarations: Declarations;
10
+ } | {
11
+ readonly kind: 'at';
12
+ readonly prelude: string;
13
+ readonly children: Array<CssChild>;
14
+ } | {
15
+ readonly kind: 'comment';
16
+ readonly text: string;
17
+ };
18
+ /** Anything accepted where CSS is expected; falsy entries drop out, arrays flatten. */
19
+ type CssChild = CssNode | false | null | undefined | Array<CssChild>;
20
+ /**
21
+ * Selectors stay free-form: they compose (`.badge rect`), and a keyframe stop is one too (`from`).
22
+ */
23
+ declare const rule: (selector: string, declarations: Declarations) => CssNode;
24
+ declare const atRule: (prelude: string, ...children: Array<CssChild>) => CssNode;
25
+ declare const cssComment: (text: string) => CssNode;
26
+ /**
27
+ * Serializes a stylesheet, dropping every rule that would have come out empty.
28
+ *
29
+ * A block is written optimistically and rewound if its body turns out empty,
30
+ * so the tree is walked once however deeply the at-rules nest.
31
+ */
32
+ declare const writeCss: (children: Array<CssChild>, depth: number, sink: Sink) => void;
33
+ export { atRule, cssComment, rule, writeCss };
34
+ export type { CssChild, Declarations };
35
+ //# sourceMappingURL=css.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"css.d.ts","sourceRoot":"","sources":["../../src/markup/css.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,gBAAgB,CAAC;AAG3C,mGAAmG;AACnG,KAAK,WAAW,GACZ,oBAAoB,GACpB,oBAAoB,GACpB,WAAW,GACX,iBAAiB,GACjB,oBAAoB,GACpB,OAAO,GACP,SAAS,GACT,MAAM,GACN,MAAM,GACN,WAAW,GACX,sBAAsB,GACtB,aAAa,GACb,YAAY,GACZ,aAAa,GACb,QAAQ,GACR,SAAS,GACT,UAAU,GACV,eAAe,GACf,gBAAgB,GAChB,QAAQ,GACR,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,GAChB,cAAc,GACd,eAAe,GACf,WAAW,GACX,kBAAkB,GAClB,OAAO,GACP,YAAY,CAAC;AAEjB,gGAAgG;AAChG,KAAK,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAE9E,KAAK,OAAO,GACR;IAAE,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,YAAY,EAAE,YAAY,CAAA;CAAE,GACzF;IAAE,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAA;CAAE,GACrF;IAAE,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAA;CAAE,CAAC;AAExD,uFAAuF;AACvF,KAAK,QAAQ,GAAG,OAAO,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC;AAErE;;GAEG;AACH,QAAA,MAAM,IAAI,aAAc,MAAM,gBAAgB,YAAY,KAAG,OAI3D,CAAC;AAEH,QAAA,MAAM,MAAM,YAAa,MAAM,eAAe,KAAK,CAAC,QAAQ,CAAC,KAAG,OAI9D,CAAC;AAEH,QAAA,MAAM,UAAU,SAAU,MAAM,KAAG,OAAsC,CAAC;AAiB1E;;;;;GAKG;AACH,QAAA,MAAM,QAAQ,aAAc,KAAK,CAAC,QAAQ,CAAC,SAAS,MAAM,QAAQ,IAAI,KAAG,IA8BxE,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC;AAC9C,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,CAAC"}
@@ -0,0 +1,64 @@
1
+ import { INDENT, indentAt } from './serialize.js';
2
+ /**
3
+ * Selectors stay free-form: they compose (`.badge rect`), and a keyframe stop is one too (`from`).
4
+ */
5
+ const rule = (selector, declarations) => ({
6
+ kind: 'rule',
7
+ selector,
8
+ declarations,
9
+ });
10
+ const atRule = (prelude, ...children) => ({
11
+ kind: 'at',
12
+ prelude,
13
+ children,
14
+ });
15
+ const cssComment = (text) => ({ kind: 'comment', text });
16
+ /** Drops the rules that carry nothing and flattens the arrays. */
17
+ const flatten = (children, into = []) => {
18
+ for (const child of children) {
19
+ if (!child) {
20
+ continue;
21
+ }
22
+ if (Array.isArray(child)) {
23
+ flatten(child, into);
24
+ }
25
+ else {
26
+ into.push(child);
27
+ }
28
+ }
29
+ return into;
30
+ };
31
+ /**
32
+ * Serializes a stylesheet, dropping every rule that would have come out empty.
33
+ *
34
+ * A block is written optimistically and rewound if its body turns out empty,
35
+ * so the tree is walked once however deeply the at-rules nest.
36
+ */
37
+ const writeCss = (children, depth, sink) => {
38
+ const indent = indentAt(depth);
39
+ for (const node of flatten(children)) {
40
+ if (node.kind === 'comment') {
41
+ sink.out += `${indent}/* ${node.text} */\n`;
42
+ continue;
43
+ }
44
+ const mark = sink.out.length;
45
+ if (node.kind === 'at') {
46
+ sink.out += `${indent}${node.prelude} {\n`;
47
+ const bodyStart = sink.out.length;
48
+ writeCss(node.children, depth + 1, sink);
49
+ sink.out =
50
+ sink.out.length === bodyStart ? sink.out.slice(0, mark) : `${sink.out}${indent}}\n`;
51
+ continue;
52
+ }
53
+ sink.out += `${indent}${node.selector} {\n`;
54
+ const bodyStart = sink.out.length;
55
+ for (const property of Object.keys(node.declarations)) {
56
+ const value = node.declarations[property];
57
+ if (value !== undefined) {
58
+ sink.out += `${indent}${INDENT}${property}: ${String(value)};\n`;
59
+ }
60
+ }
61
+ sink.out = sink.out.length === bodyStart ? sink.out.slice(0, mark) : `${sink.out}${indent}}\n`;
62
+ }
63
+ };
64
+ export { atRule, cssComment, rule, writeCss };
@@ -0,0 +1,41 @@
1
+ import type { CssChild } from './css.ts';
2
+ /**
3
+ * Every element a card draws, closed so `el('circel', …)` is a compile error.
4
+ * `style` is absent on purpose: it comes from `style()`, which takes rules rather than children.
5
+ */
6
+ type Tag = 'a' | 'circle' | 'defs' | 'desc' | 'div' | 'foreignObject' | 'g' | 'linearGradient' | 'mask' | 'path' | 'rect' | 'stop' | 'svg' | 'text' | 'title' | 'tspan';
7
+ /**
8
+ * Every attribute a card writes, closed like `Tag`:
9
+ * a misspelled `stroke-width` would otherwise be valid TypeScript and invisible in the output.
10
+ */
11
+ type Attribute = 'alignment-baseline' | 'aria-hidden' | 'aria-labelledby' | 'class' | 'cx' | 'cy' | 'd' | 'data-testid' | 'data-view-component' | 'dominant-baseline' | 'dy' | 'fill' | 'fill-rule' | 'gradientTransform' | 'gradientUnits' | 'height' | 'href' | 'id' | 'mask' | 'offset' | 'r' | 'role' | 'rx' | 'ry' | 'size' | 'stop-color' | 'stroke' | 'stroke-dasharray' | 'stroke-dashoffset' | 'stroke-linecap' | 'stroke-opacity' | 'stroke-width' | 'style' | 'text-anchor' | 'transform' | 'version' | 'viewBox' | 'width' | 'x' | 'xmlns' | 'y';
12
+ /** An attribute whose value is `undefined` is not written, so a caller can inline a condition. */
13
+ type Attributes = Partial<Record<Attribute, string | number | undefined>>;
14
+ interface MarkupElement {
15
+ readonly tag: Tag;
16
+ readonly attributes: Attributes;
17
+ readonly children: Array<Child>;
18
+ }
19
+ interface StyleElement {
20
+ readonly tag: 'style';
21
+ readonly rules: Array<CssChild>;
22
+ }
23
+ /** Anything accepted as content; falsy entries drop out, arrays flatten, strings are escaped. */
24
+ type Child = MarkupElement | StyleElement | string | number | false | null | undefined | Array<Child>;
25
+ /**
26
+ * Builds one element. Attribute values and text children are encoded on the way out.
27
+ */
28
+ declare const el: (tag: Tag, attributes?: Attributes, ...children: Array<Child>) => MarkupElement;
29
+ /**
30
+ * Builds the `<style>` element from a stylesheet rather than from text.
31
+ */
32
+ declare const style: (...rules: Array<CssChild>) => StyleElement;
33
+ /**
34
+ * Serializes a finished card: one element per line, two spaces per nesting level.
35
+ *
36
+ * @returns The rendered SVG.
37
+ */
38
+ declare const renderMarkup: (root: MarkupElement) => string;
39
+ export { el, renderMarkup, style };
40
+ export type { Child, MarkupElement };
41
+ //# sourceMappingURL=element.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"element.d.ts","sourceRoot":"","sources":["../../src/markup/element.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AAMzC;;;GAGG;AACH,KAAK,GAAG,GACJ,GAAG,GACH,QAAQ,GACR,MAAM,GACN,MAAM,GACN,KAAK,GACL,eAAe,GACf,GAAG,GACH,gBAAgB,GAChB,MAAM,GACN,MAAM,GACN,MAAM,GACN,MAAM,GACN,KAAK,GACL,MAAM,GACN,OAAO,GACP,OAAO,CAAC;AAEZ;;;GAGG;AACH,KAAK,SAAS,GACV,oBAAoB,GACpB,aAAa,GACb,iBAAiB,GACjB,OAAO,GACP,IAAI,GACJ,IAAI,GACJ,GAAG,GACH,aAAa,GACb,qBAAqB,GACrB,mBAAmB,GACnB,IAAI,GACJ,MAAM,GACN,WAAW,GACX,mBAAmB,GACnB,eAAe,GACf,QAAQ,GACR,MAAM,GACN,IAAI,GACJ,MAAM,GACN,QAAQ,GACR,GAAG,GACH,MAAM,GACN,IAAI,GACJ,IAAI,GACJ,MAAM,GACN,YAAY,GACZ,QAAQ,GACR,kBAAkB,GAClB,mBAAmB,GACnB,gBAAgB,GAChB,gBAAgB,GAChB,cAAc,GACd,OAAO,GACP,aAAa,GACb,WAAW,GACX,SAAS,GACT,SAAS,GACT,OAAO,GACP,GAAG,GACH,OAAO,GACP,GAAG,CAAC;AAER,kGAAkG;AAClG,KAAK,UAAU,GAAG,OAAO,CAAC,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAAC,CAAC,CAAC;AAK1E,UAAU,aAAa;IACrB,QAAQ,CAAC,GAAG,EAAE,GAAG,CAAC;IAClB,QAAQ,CAAC,UAAU,EAAE,UAAU,CAAC;IAChC,QAAQ,CAAC,QAAQ,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;CACjC;AAED,UAAU,YAAY;IACpB,QAAQ,CAAC,GAAG,EAAE,OAAO,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC,QAAQ,CAAC,CAAC;CACjC;AAED,iGAAiG;AACjG,KAAK,KAAK,GACN,aAAa,GACb,YAAY,GACZ,MAAM,GACN,MAAM,GACN,KAAK,GACL,IAAI,GACJ,SAAS,GACT,KAAK,CAAC,KAAK,CAAC,CAAC;AAKjB;;GAEG;AACH,QAAA,MAAM,EAAE,QAAS,GAAG,eAAc,UAAU,eAAoB,KAAK,CAAC,KAAK,CAAC,KAAG,aAI7E,CAAC;AAEH;;GAEG;AACH,QAAA,MAAM,KAAK,aAAc,KAAK,CAAC,QAAQ,CAAC,KAAG,YAAyC,CAAC;AAmHrF;;;;GAIG;AACH,QAAA,MAAM,YAAY,SAAU,aAAa,KAAG,MAI3C,CAAC;AAEF,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,CAAC;AACnC,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC"}
@@ -0,0 +1,127 @@
1
+ import { writeCss } from './css.js';
2
+ import { encodeHTML } from './html.js';
3
+ import { indentAt } from './serialize.js';
4
+ /** Elements whose character data is part of the rendering, so they stay on one line. */
5
+ const INLINE_ELEMENTS = new Set(['text', 'tspan', 'title', 'desc', 'div']);
6
+ /**
7
+ * Builds one element. Attribute values and text children are encoded on the way out.
8
+ */
9
+ const el = (tag, attributes = {}, ...children) => ({
10
+ tag,
11
+ attributes,
12
+ children,
13
+ });
14
+ /**
15
+ * Builds the `<style>` element from a stylesheet rather than from text.
16
+ */
17
+ const style = (...rules) => ({ tag: 'style', rules });
18
+ const isStyle = (child) => 'rules' in child;
19
+ /** Drops the children that carry nothing and flattens the arrays. */
20
+ const flatten = (children, into = []) => {
21
+ for (const child of children) {
22
+ if (child === false || child === null || child === undefined || child === '') {
23
+ continue;
24
+ }
25
+ if (Array.isArray(child)) {
26
+ flatten(child, into);
27
+ }
28
+ else {
29
+ into.push(child);
30
+ }
31
+ }
32
+ return into;
33
+ };
34
+ const openTag = (node, selfClosing) => {
35
+ let tag = `<${node.tag}`;
36
+ const { attributes } = node;
37
+ // `Object.keys` widens to `string`, so the cast restores what the type already says.
38
+ for (const name of Object.keys(attributes)) {
39
+ const value = attributes[name];
40
+ if (value !== undefined) {
41
+ // A number can hold nothing that needs escaping, so it skips the scan.
42
+ tag += typeof value === 'number' ? ` ${name}="${value}"` : ` ${name}="${encodeHTML(value)}"`;
43
+ }
44
+ }
45
+ return `${tag}${selfClosing ? ' />' : '>'}`;
46
+ };
47
+ /** Serializes an element and its descendants onto one line, whitespace and all. */
48
+ const writeInline = (node) => {
49
+ if (typeof node === 'string') {
50
+ return encodeHTML(node);
51
+ }
52
+ if (typeof node === 'number') {
53
+ return String(node);
54
+ }
55
+ if (isStyle(node)) {
56
+ return '';
57
+ }
58
+ const children = flatten(node.children);
59
+ if (children.length === 0) {
60
+ return openTag(node, true);
61
+ }
62
+ let inner = '';
63
+ for (const child of children) {
64
+ inner += writeInline(child);
65
+ }
66
+ return `${openTag(node, false)}${inner}</${node.tag}>`;
67
+ };
68
+ /**
69
+ * A container is written optimistically and rewound if its content turns out empty,
70
+ * so an element that draws nothing costs one walk rather than two.
71
+ */
72
+ const write = (node, depth, sink) => {
73
+ const indent = indentAt(depth);
74
+ if (typeof node === 'string') {
75
+ sink.out += `${indent}${encodeHTML(node)}\n`;
76
+ return;
77
+ }
78
+ if (typeof node === 'number') {
79
+ sink.out += `${indent}${node}\n`;
80
+ return;
81
+ }
82
+ const mark = sink.out.length;
83
+ if (isStyle(node)) {
84
+ sink.out += `${indent}<style>\n`;
85
+ const bodyStart = sink.out.length;
86
+ writeCss(node.rules, depth + 1, sink);
87
+ sink.out =
88
+ sink.out.length === bodyStart ? sink.out.slice(0, mark) : `${sink.out}${indent}</style>\n`;
89
+ return;
90
+ }
91
+ const children = flatten(node.children);
92
+ if (children.length === 0) {
93
+ sink.out += `${indent}${openTag(node, true)}\n`;
94
+ return;
95
+ }
96
+ if (INLINE_ELEMENTS.has(node.tag)) {
97
+ let inner = '';
98
+ for (const child of children) {
99
+ inner += writeInline(child);
100
+ }
101
+ sink.out +=
102
+ inner === ''
103
+ ? `${indent}${openTag(node, true)}\n`
104
+ : `${indent}${openTag(node, false)}${inner}</${node.tag}>\n`;
105
+ return;
106
+ }
107
+ sink.out += `${indent}${openTag(node, false)}\n`;
108
+ const bodyStart = sink.out.length;
109
+ for (const child of children) {
110
+ write(child, depth + 1, sink);
111
+ }
112
+ sink.out =
113
+ sink.out.length === bodyStart
114
+ ? `${sink.out.slice(0, mark)}${indent}${openTag(node, true)}\n`
115
+ : `${sink.out}${indent}</${node.tag}>\n`;
116
+ };
117
+ /**
118
+ * Serializes a finished card: one element per line, two spaces per nesting level.
119
+ *
120
+ * @returns The rendered SVG.
121
+ */
122
+ const renderMarkup = (root) => {
123
+ const sink = { out: '' };
124
+ write(root, 0, sink);
125
+ return sink.out;
126
+ };
127
+ export { el, renderMarkup, style };
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Encodes a string for use as markup, one numeric character reference each.
3
+ *
4
+ * The serializer is now the only place text becomes markup, so nothing arrives pre-escaped:
5
+ * a literal `&#38;` is encoded like any other `&` rather than passed through as a reference.
6
+ *
7
+ * @see https://stackoverflow.com/a/48073476/10629172
8
+ *
9
+ * @returns The text, safe to place in an attribute or as character data.
10
+ */
11
+ declare const encodeHTML: (str: string) => string;
12
+ export { encodeHTML };
13
+ //# sourceMappingURL=html.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"html.d.ts","sourceRoot":"","sources":["../../src/markup/html.ts"],"names":[],"mappings":"AAYA;;;;;;;;;GASG;AACH,QAAA,MAAM,UAAU,QAAS,MAAM,KAAG,MASjC,CAAC;AAEF,OAAO,EAAE,UAAU,EAAE,CAAC"}
@@ -0,0 +1,27 @@
1
+ /**
2
+ * What has to be encoded: the markup characters, everything above plain ASCII, and a backspace.
3
+ * One source for both regexes, so the check and the replacement cannot disagree.
4
+ */
5
+ const ENCODED = String.raw `[<>&"'\u00A0-\u9999\u0008]`;
6
+ /** Non-global, so `.test` stays stateless: a global regex would carry `lastIndex`. */
7
+ const NEEDS_ENCODING = new RegExp(ENCODED);
8
+ const TO_ENCODE = new RegExp(ENCODED, 'g');
9
+ const BACKSPACE = '\u0008';
10
+ /**
11
+ * Encodes a string for use as markup, one numeric character reference each.
12
+ *
13
+ * The serializer is now the only place text becomes markup, so nothing arrives pre-escaped:
14
+ * a literal `&#38;` is encoded like any other `&` rather than passed through as a reference.
15
+ *
16
+ * @see https://stackoverflow.com/a/48073476/10629172
17
+ *
18
+ * @returns The text, safe to place in an attribute or as character data.
19
+ */
20
+ const encodeHTML = (str) => {
21
+ // Most strings a card writes are plain ASCII, so they leave without a rewrite.
22
+ if (!NEEDS_ENCODING.test(str)) {
23
+ return str;
24
+ }
25
+ return str.replace(TO_ENCODE, (char) => char === BACKSPACE ? '' : `&#${char.codePointAt(0) ?? 0};`);
26
+ };
27
+ export { encodeHTML };
@@ -0,0 +1,9 @@
1
+ /**
2
+ * The markup layer: a card is built as a tree of elements and rules, then serialized once.
3
+ * It depends on nothing else in the package, so it sits below `cards/`, not inside `common/`.
4
+ */
5
+ export { atRule, cssComment, rule } from './css.ts';
6
+ export type { CssChild, Declarations } from './css.ts';
7
+ export { el, renderMarkup, style } from './element.ts';
8
+ export type { Child, MarkupElement } from './element.ts';
9
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/markup/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AACpD,YAAY,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AACvD,OAAO,EAAE,EAAE,EAAE,YAAY,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AACvD,YAAY,EAAE,KAAK,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ /**
2
+ * The markup layer: a card is built as a tree of elements and rules, then serialized once.
3
+ * It depends on nothing else in the package, so it sits below `cards/`, not inside `common/`.
4
+ */
5
+ export { atRule, cssComment, rule } from './css.js';
6
+ export { el, renderMarkup, style } from './element.js';
@@ -0,0 +1,16 @@
1
+ /**
2
+ * What the markup and stylesheet serializers share: where output goes, and how deep a line sits.
3
+ * Both write into one growing string rather than a list of chunks, so nothing needs joining.
4
+ */
5
+ declare const INDENT = " ";
6
+ /** Collects serializer output. A plain holder so appends stay a property write. */
7
+ interface Sink {
8
+ out: string;
9
+ }
10
+ /**
11
+ * @returns Two spaces per level.
12
+ */
13
+ declare const indentAt: (depth: number) => string;
14
+ export { INDENT, indentAt };
15
+ export type { Sink };
16
+ //# sourceMappingURL=serialize.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serialize.d.ts","sourceRoot":"","sources":["../../src/markup/serialize.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,QAAA,MAAM,MAAM,OAAO,CAAC;AAEpB,mFAAmF;AACnF,UAAU,IAAI;IACZ,GAAG,EAAE,MAAM,CAAC;CACb;AAKD;;GAEG;AACH,QAAA,MAAM,QAAQ,UAAW,MAAM,KAAG,MAKjC,CAAC;AAEF,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,CAAC;AAC5B,YAAY,EAAE,IAAI,EAAE,CAAC"}
@@ -0,0 +1,17 @@
1
+ /**
2
+ * What the markup and stylesheet serializers share: where output goes, and how deep a line sits.
3
+ * Both write into one growing string rather than a list of chunks, so nothing needs joining.
4
+ */
5
+ const INDENT = ' ';
6
+ /** Indentation by depth, grown as the tree is walked rather than rebuilt per line. */
7
+ const indents = ['', INDENT];
8
+ /**
9
+ * @returns Two spaces per level.
10
+ */
11
+ const indentAt = (depth) => {
12
+ for (let i = indents.length; i <= depth; i += 1) {
13
+ indents.push(`${indents[i - 1] ?? ''}${INDENT}`);
14
+ }
15
+ return indents[depth] ?? '';
16
+ };
17
+ export { INDENT, indentAt };