@fuzdev/fuz_ui 0.207.0 → 0.209.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 (55) hide show
  1. package/README.md +1 -1
  2. package/dist/ApiIndex.svelte +9 -9
  3. package/dist/ApiModule.svelte +4 -4
  4. package/dist/DeclarationDetail.svelte +26 -5
  5. package/dist/DeclarationDetail.svelte.d.ts +1 -1
  6. package/dist/DeclarationDetail.svelte.d.ts.map +1 -1
  7. package/dist/EcosystemLinks.svelte +2 -2
  8. package/dist/ProjectLinks.svelte +3 -31
  9. package/dist/ProjectLinks.svelte.d.ts.map +1 -1
  10. package/dist/TypeLink.svelte +11 -0
  11. package/dist/TypeLink.svelte.d.ts +9 -0
  12. package/dist/TypeLink.svelte.d.ts.map +1 -1
  13. package/dist/api_search.svelte.d.ts +17 -20
  14. package/dist/api_search.svelte.d.ts.map +1 -1
  15. package/dist/api_search.svelte.js +32 -63
  16. package/dist/csp.d.ts +19 -1
  17. package/dist/csp.d.ts.map +1 -1
  18. package/dist/csp.js +26 -1
  19. package/dist/declaration.svelte.d.ts +25 -1
  20. package/dist/declaration.svelte.d.ts.map +1 -1
  21. package/dist/declaration.svelte.js +43 -3
  22. package/dist/logos.d.ts +1 -1
  23. package/dist/logos.d.ts.map +1 -1
  24. package/dist/logos.js +1 -1
  25. package/dist/projects.d.ts +0 -3
  26. package/dist/projects.d.ts.map +1 -1
  27. package/dist/projects.js +3 -3
  28. package/dist/sparkline.d.ts +1 -1
  29. package/dist/sparkline.js +1 -1
  30. package/package.json +7 -7
  31. package/src/lib/api_search.svelte.ts +34 -82
  32. package/src/lib/csp.ts +27 -1
  33. package/src/lib/declaration.svelte.ts +49 -3
  34. package/src/lib/logos.ts +1 -1
  35. package/src/lib/projects.ts +3 -6
  36. package/src/lib/sparkline.ts +1 -1
  37. package/dist/ProjectActivityChart.svelte +0 -137
  38. package/dist/ProjectActivityChart.svelte.d.ts +0 -30
  39. package/dist/ProjectActivityChart.svelte.d.ts.map +0 -1
  40. package/dist/project_stats.d.ts +0 -121
  41. package/dist/project_stats.d.ts.map +0 -1
  42. package/dist/project_stats.js +0 -153
  43. package/dist/project_stats_data.d.ts +0 -3
  44. package/dist/project_stats_data.d.ts.map +0 -1
  45. package/dist/project_stats_data.js +0 -469
  46. package/dist/project_stats_update.task.d.ts +0 -4
  47. package/dist/project_stats_update.task.d.ts.map +0 -1
  48. package/dist/project_stats_update.task.js +0 -50
  49. package/dist/publish.task.d.ts +0 -3
  50. package/dist/publish.task.d.ts.map +0 -1
  51. package/dist/publish.task.js +0 -23
  52. package/src/lib/project_stats.ts +0 -220
  53. package/src/lib/project_stats_data.ts +0 -472
  54. package/src/lib/project_stats_update.task.ts +0 -53
  55. package/src/lib/publish.task.ts +0 -22
@@ -1,220 +0,0 @@
1
- /**
2
- * Types and pure helpers for project commit-activity stats.
3
- *
4
- * The committed dataset (`project_stats_data.ts`, written by the
5
- * `project_stats_update` task) stores daily commit counts per project as the
6
- * master granularity; coarser scopes like monthly are derived at runtime by
7
- * rebucketing. All date handling is UTC — `YYYY-MM-DD` strings and "epoch
8
- * days" (days since the Unix epoch) — so results are deterministic across
9
- * machines.
10
- *
11
- * @module
12
- */
13
-
14
- const DAY_MS = 86_400_000;
15
-
16
- /**
17
- * Daily commit counts for one project.
18
- */
19
- export interface ProjectCommitStats {
20
- /**
21
- * Project name, matching `project_items`.
22
- */
23
- name: string;
24
- /**
25
- * UTC date (`YYYY-MM-DD`) of the first day bucket, the day of the first commit.
26
- */
27
- start_date: string;
28
- /**
29
- * Commits per UTC day from `start_date` through the snapshot's `end_date`, inclusive.
30
- */
31
- daily_counts: Array<number>;
32
- }
33
-
34
- /**
35
- * A snapshot of commit stats across projects, sharing a single `end_date`.
36
- */
37
- export interface ProjectStatsSnapshot {
38
- /**
39
- * ISO datetime when the snapshot was collected.
40
- */
41
- generated_at: string;
42
- /**
43
- * UTC date (`YYYY-MM-DD`) of the final day bucket, shared by every project.
44
- */
45
- end_date: string;
46
- projects: Array<ProjectCommitStats>;
47
- }
48
-
49
- /**
50
- * A derived series of bucketed counts for one project.
51
- */
52
- export interface ProjectStatsSeries {
53
- name: string;
54
- counts: Array<number>;
55
- }
56
-
57
- /**
58
- * Converts a UTC `YYYY-MM-DD` date to days since the Unix epoch.
59
- */
60
- export const epoch_day_from_date = (date: string): number => {
61
- const [year, month, day] = date.split('-').map(Number);
62
- return Date.UTC(year!, month! - 1, day) / DAY_MS;
63
- };
64
-
65
- /**
66
- * Converts days since the Unix epoch to a UTC `YYYY-MM-DD` date.
67
- */
68
- export const date_from_epoch_day = (epoch_day: number): string =>
69
- new Date(epoch_day * DAY_MS).toISOString().slice(0, 10);
70
-
71
- /**
72
- * Buckets commit timestamps into daily counts from the earliest commit's UTC
73
- * day through `end_date`, inclusive.
74
- *
75
- * @param timestamps - commit times as Unix epoch seconds
76
- * @param end_date - UTC date (`YYYY-MM-DD`) of the final bucket; later timestamps clamp into it
77
- * @returns the start date and daily counts, or `null` if `timestamps` is empty
78
- */
79
- export const daily_counts_from_timestamps = (
80
- timestamps: Array<number>,
81
- end_date: string
82
- ): { start_date: string; daily_counts: Array<number> } | null => {
83
- if (timestamps.length === 0) return null;
84
- const days = timestamps.map((t) => Math.floor((t * 1000) / DAY_MS));
85
- const end_day = epoch_day_from_date(end_date);
86
- let start_day = end_day;
87
- for (const day of days) {
88
- if (day < start_day) start_day = day;
89
- }
90
- const daily_counts: Array<number> = new Array(end_day - start_day + 1).fill(0);
91
- for (const day of days) {
92
- daily_counts[Math.min(day, end_day) - start_day]! += 1;
93
- }
94
- return { start_date: date_from_epoch_day(start_day), daily_counts };
95
- };
96
-
97
- /**
98
- * Pads `daily_counts` with leading zeros so the series starts at
99
- * `padded_start_date` instead of `start_date`.
100
- *
101
- * Returns the input array unchanged when `padded_start_date` is not earlier
102
- * than `start_date`.
103
- */
104
- export const daily_counts_pad_start = (
105
- daily_counts: Array<number>,
106
- start_date: string,
107
- padded_start_date: string
108
- ): Array<number> => {
109
- const pad = epoch_day_from_date(start_date) - epoch_day_from_date(padded_start_date);
110
- if (pad <= 0) return daily_counts;
111
- return (new Array(pad).fill(0) as Array<number>).concat(daily_counts);
112
- };
113
-
114
- /**
115
- * Rebuckets daily counts into calendar-month (UTC) counts.
116
- *
117
- * The first and last buckets may cover partial months.
118
- */
119
- export const monthly_counts_from_daily = (
120
- daily_counts: Array<number>,
121
- start_date: string
122
- ): Array<number> => {
123
- const start_day = epoch_day_from_date(start_date);
124
- const counts: Array<number> = [];
125
- let current_month_key: number | null = null;
126
- for (let i = 0; i < daily_counts.length; i++) {
127
- const date = new Date((start_day + i) * DAY_MS);
128
- const month_key = date.getUTCFullYear() * 12 + date.getUTCMonth();
129
- if (month_key !== current_month_key) {
130
- current_month_key = month_key;
131
- counts.push(0);
132
- }
133
- counts[counts.length - 1]! += daily_counts[i]!;
134
- }
135
- return counts;
136
- };
137
-
138
- /**
139
- * Rebuckets daily counts into 7-day counts, anchored at the end of the series
140
- * so the newest bucket always covers a full 7 days.
141
- *
142
- * The first bucket may cover fewer days when the length isn't a multiple of 7.
143
- */
144
- export const weekly_counts_from_daily = (daily_counts: Array<number>): Array<number> => {
145
- const counts: Array<number> = [];
146
- for (let end = daily_counts.length; end > 0; end -= 7) {
147
- let sum = 0;
148
- for (let i = Math.max(0, end - 7); i < end; i++) {
149
- sum += daily_counts[i]!;
150
- }
151
- counts.push(sum);
152
- }
153
- return counts.reverse();
154
- };
155
-
156
- const to_aligned_series = (
157
- snapshot: ProjectStatsSnapshot,
158
- rebucket: (daily_counts: Array<number>, start_date: string) => Array<number>
159
- ): { series: Array<ProjectStatsSeries>; max: number } => {
160
- if (snapshot.projects.length === 0) return { series: [], max: 0 };
161
- let shared_start = snapshot.projects[0]!.start_date;
162
- for (const project of snapshot.projects) {
163
- if (project.start_date < shared_start) shared_start = project.start_date;
164
- }
165
- let max = 0;
166
- const series = snapshot.projects.map((project) => {
167
- const daily = daily_counts_pad_start(project.daily_counts, project.start_date, shared_start);
168
- const counts = rebucket(daily, shared_start);
169
- for (const count of counts) {
170
- if (count > max) max = count;
171
- }
172
- return { name: project.name, counts };
173
- });
174
- return { series, max };
175
- };
176
-
177
- /**
178
- * Derives aligned monthly series for every project in `snapshot`, sharing one
179
- * time window and one scale.
180
- *
181
- * Each series spans from the earliest project's `start_date` through the
182
- * snapshot's `end_date` (younger projects are zero-padded at the front), so
183
- * all series have the same length and bucket boundaries. `max` is the largest
184
- * monthly count across all projects, for rendering every series at the same
185
- * vertical scale.
186
- */
187
- export const project_stats_to_monthly_series = (
188
- snapshot: ProjectStatsSnapshot
189
- ): { series: Array<ProjectStatsSeries>; max: number } =>
190
- to_aligned_series(snapshot, monthly_counts_from_daily);
191
-
192
- /**
193
- * Derives aligned weekly series for every project in `snapshot`, sharing one
194
- * time window and one scale — the weekly sibling of
195
- * `project_stats_to_monthly_series`.
196
- */
197
- export const project_stats_to_weekly_series = (
198
- snapshot: ProjectStatsSnapshot
199
- ): { series: Array<ProjectStatsSeries>; max: number } =>
200
- to_aligned_series(snapshot, weekly_counts_from_daily);
201
-
202
- const start_date_formatter = new Intl.DateTimeFormat('en-US', {
203
- month: 'long',
204
- day: 'numeric',
205
- year: 'numeric',
206
- timeZone: 'UTC'
207
- });
208
-
209
- /**
210
- * Formats a one-line human-readable summary of a project's commit stats,
211
- * e.g. `"gro — 2,386 commits since August 7, 2019"`. Used for accessible
212
- * labels and tooltips.
213
- */
214
- export const project_stats_label = (project: ProjectCommitStats): string => {
215
- let total = 0;
216
- for (const count of project.daily_counts) {
217
- total += count;
218
- }
219
- return `${project.name} — ${total.toLocaleString('en-US')} commits since ${start_date_formatter.format(new Date(project.start_date))}`;
220
- };