#357 · Sources and Dating context apply to durations, shown in the reader (#341)
- timeline-app
- pull request
Closes #341 A duration opened in the reader showed no **Sources** and no **Date precision**, though its metadata can hold `sources`. The reader already shows every plugin field that applies to an entity's kind; the cause is that both plugins targeted moments only (no `targets`, so `pluginTargets` gave `['moments']`), and `durationPlugins` left them out for durations, in the reader and in the duration editor alike. **Fix:** version 2 of **Sources** (`moment-sources`) and **Dating context** (`dating-context`), each with `targets: ['moments', 'durations']` and otherwise the same fields, so values stored under version 1 carry over. Following how the repository versions plugins (Moment shapes, Timeline theme), version 1 of each stays in `BUILTIN_PLUGINS` as `LEGACY_*`: it remains in the library at its detail URL, is still recognised as official, and timelines pinned to it keep working, for moments only, until **Update to v2** in the plugin library upgrades it in place. New installs, and new seed timelines, get version 2. Extending the plugins is in scope because the reader had no other way to show these fields: it only shows fields of plugins that apply to the entity's kind, by design. Historical dates and Geological ages stay moment-only (the issue did not ask for them). Dating context stays one pair of fields for a whole duration rather than separate start and end fields: the issue's case, an approximate start or end, fits in its text. - `src/plugins.ts`: the two version 2 manifests, version 1 kept as `LEGACY_MOMENT_SOURCES` and `LEGACY_DATING_CONTEXT`. - `docs/plugins.md`: Sources and Dating context sections. **Tests** - `test/plugins.test.mjs`: for both plugins, version 1 targets moments and version 2 both kinds, with the same fields; both are official; `durationPlugins` includes version 2 only; the library offers version 2, and version 1's detail is still served. Fails before the fix. - `test/view-mode-browser.mjs`: the duration in the reader shows its Date precision and its source link. Fails before the fix (`actual: []`). - `npm test` (335 pass), `npm run typecheck`, prettier on the changed files, and the full chromium browser suite (`test/browser.mjs`): all pass. Touches `test/view-mode-browser.mjs`, which my PRs for #344 and #345 also change, in other parts of the file.