refactor(timeline): move pure month-bucket math to $lib/shared/utils/monthBuckets

Relocate the 10 pure helpers (monthBoundaryFrom/To, buildMonthSequence,
fillDensityGaps, clipBucketsToRange, aggregateToYears, selectionBoundaryFrom/To,
tickIndicesFor, formatTickLabel) and their unit tests out of document/timeline.ts
into a shared module so lib/timeline/ can consume them without importing
lib/document/. The /api/documents/density glue (buildDensityUrl, fetchDensity,
DensityState, DensityFilters) stays in document/timeline.ts. Re-point the three
density components and the density-filter spec at the shared module.

Refs #779
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Marcel
2026-06-13 19:18:50 +02:00
parent 1348255ae3
commit 1dc3b91458
8 changed files with 435 additions and 426 deletions

View File

@@ -1,5 +1,5 @@
<script lang="ts">
import { formatTickLabel, tickIndicesFor } from '$lib/document/timeline';
import { formatTickLabel, tickIndicesFor } from '$lib/shared/utils/monthBuckets';
import { getLocale } from '$lib/paraglide/runtime';
import type { components } from '$lib/generated/api';