@jorgerdz/timeview 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 (90) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +263 -0
  4. package/dist/cli/timeview.js +6710 -0
  5. package/dist/timeview.cjs +1 -0
  6. package/dist/timeview.js +5667 -0
  7. package/dist/tokens.css +67 -0
  8. package/dist/types/timeview/BandedTimeline.d.ts +11 -0
  9. package/dist/types/timeview/BandedTimeline.d.ts.map +1 -0
  10. package/dist/types/timeview/DensityHeatmap.d.ts +11 -0
  11. package/dist/types/timeview/DensityHeatmap.d.ts.map +1 -0
  12. package/dist/types/timeview/LaneCalendar.d.ts +11 -0
  13. package/dist/types/timeview/LaneCalendar.d.ts.map +1 -0
  14. package/dist/types/timeview/MetricTimeline.d.ts +8 -0
  15. package/dist/types/timeview/MetricTimeline.d.ts.map +1 -0
  16. package/dist/types/timeview/SpanMatrix.d.ts +8 -0
  17. package/dist/types/timeview/SpanMatrix.d.ts.map +1 -0
  18. package/dist/types/timeview/config.d.ts +22 -0
  19. package/dist/types/timeview/config.d.ts.map +1 -0
  20. package/dist/types/timeview/core/aggregate.d.ts +113 -0
  21. package/dist/types/timeview/core/aggregate.d.ts.map +1 -0
  22. package/dist/types/timeview/core/calendar.d.ts +27 -0
  23. package/dist/types/timeview/core/calendar.d.ts.map +1 -0
  24. package/dist/types/timeview/core/intervals.d.ts +8 -0
  25. package/dist/types/timeview/core/intervals.d.ts.map +1 -0
  26. package/dist/types/timeview/core/labels.d.ts +5 -0
  27. package/dist/types/timeview/core/labels.d.ts.map +1 -0
  28. package/dist/types/timeview/core/metric.d.ts +58 -0
  29. package/dist/types/timeview/core/metric.d.ts.map +1 -0
  30. package/dist/types/timeview/core/time.d.ts +22 -0
  31. package/dist/types/timeview/core/time.d.ts.map +1 -0
  32. package/dist/types/timeview/dashboard.d.ts +17 -0
  33. package/dist/types/timeview/dashboard.d.ts.map +1 -0
  34. package/dist/types/timeview/data.d.ts +21 -0
  35. package/dist/types/timeview/data.d.ts.map +1 -0
  36. package/dist/types/timeview/export.d.ts +14 -0
  37. package/dist/types/timeview/export.d.ts.map +1 -0
  38. package/dist/types/timeview/index.d.ts +28 -0
  39. package/dist/types/timeview/index.d.ts.map +1 -0
  40. package/dist/types/timeview/registry.d.ts +285 -0
  41. package/dist/types/timeview/registry.d.ts.map +1 -0
  42. package/dist/types/timeview/shared/Caption.d.ts +9 -0
  43. package/dist/types/timeview/shared/Caption.d.ts.map +1 -0
  44. package/dist/types/timeview/shared/EmptyState.d.ts +16 -0
  45. package/dist/types/timeview/shared/EmptyState.d.ts.map +1 -0
  46. package/dist/types/timeview/shared/Legend.d.ts +10 -0
  47. package/dist/types/timeview/shared/Legend.d.ts.map +1 -0
  48. package/dist/types/timeview/shared/Tooltip.d.ts +15 -0
  49. package/dist/types/timeview/shared/Tooltip.d.ts.map +1 -0
  50. package/dist/types/timeview/shared/useMeasuredWidth.d.ts +2 -0
  51. package/dist/types/timeview/shared/useMeasuredWidth.d.ts.map +1 -0
  52. package/dist/types/timeview/types.d.ts +158 -0
  53. package/dist/types/timeview/types.d.ts.map +1 -0
  54. package/docs/AGENT-USAGE.md +93 -0
  55. package/docs/COMPATIBILITY.md +134 -0
  56. package/docs/STUDIO.md +41 -0
  57. package/examples/README.md +21 -0
  58. package/examples/configs/bandedTimeline.json +31 -0
  59. package/examples/configs/densityHeatmap.json +33 -0
  60. package/examples/configs/laneCalendar.json +31 -0
  61. package/examples/configs/metricTimeline.json +51 -0
  62. package/examples/configs/spanMatrix.json +31 -0
  63. package/package.json +94 -0
  64. package/render.html +12 -0
  65. package/src/render.tsx +67 -0
  66. package/src/styles/tokens.css +67 -0
  67. package/src/timeview/BandedTimeline.tsx +620 -0
  68. package/src/timeview/DensityHeatmap.tsx +513 -0
  69. package/src/timeview/LaneCalendar.tsx +496 -0
  70. package/src/timeview/MetricTimeline.tsx +993 -0
  71. package/src/timeview/SpanMatrix.tsx +721 -0
  72. package/src/timeview/config.ts +399 -0
  73. package/src/timeview/core/aggregate.ts +317 -0
  74. package/src/timeview/core/calendar.ts +81 -0
  75. package/src/timeview/core/intervals.ts +52 -0
  76. package/src/timeview/core/labels.ts +19 -0
  77. package/src/timeview/core/metric.ts +263 -0
  78. package/src/timeview/core/time.ts +103 -0
  79. package/src/timeview/dashboard.ts +80 -0
  80. package/src/timeview/data.ts +242 -0
  81. package/src/timeview/export.ts +48 -0
  82. package/src/timeview/index.ts +106 -0
  83. package/src/timeview/registry.ts +207 -0
  84. package/src/timeview/shared/Caption.tsx +40 -0
  85. package/src/timeview/shared/EmptyState.tsx +90 -0
  86. package/src/timeview/shared/Legend.tsx +67 -0
  87. package/src/timeview/shared/Tooltip.tsx +59 -0
  88. package/src/timeview/shared/useMeasuredWidth.ts +21 -0
  89. package/src/timeview/types.ts +159 -0
  90. package/vite.config.ts +11 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,15 @@
1
+ # Changelog
2
+
3
+ Timeview follows semantic versioning after the first published package. Compatibility rules
4
+ for `TimeviewConfigV1` and `timeview.dataset.v1` are documented in
5
+ `docs/COMPATIBILITY.md`.
6
+
7
+ ## 0.1.0
8
+
9
+ - Prepare the project for npm publication as `@jorgerdz/timeview`.
10
+ - Add library build outputs, declaration files, CSS token export, and a `timeview` CLI bin.
11
+ - Document contribution, release, and generic agent usage paths.
12
+ - Add basic config validation tests and CI checks.
13
+ - Add complete JSON examples for every visualizer.
14
+ - Add CLI `--json` success/error output and documented exit codes.
15
+ - Upgrade Vite/tooling dependency chain so `npm audit` reports zero vulnerabilities.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Timeview contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,263 @@
1
+ # Timeview
2
+
3
+ A library of reusable, time-based visualization components. Each visualizer renders a
4
+ shared `TimeDataset` (schema `timeview.dataset.v1`) projected by a view-specific `ViewSpec`,
5
+ so the same data can drive any chart.
6
+
7
+ Current visualizers:
8
+ - **BandedTimeline:** a horizontal day axis with instant-event milestones and colored
9
+ interval bands in stacked lanes.
10
+ - **LaneCalendar:** the same events and intervals projected onto Mon-start week rows and
11
+ seven day columns.
12
+ - **DensityHeatmap:** an aggregation view for counts and active duration by day/week and
13
+ category/total.
14
+ - **MetricTimeline:** logged numeric values over time, such as weight, with contextual
15
+ state bands for periods like diet, maintenance, and off-plan.
16
+ - **SpanMatrix:** category rows by day/week columns, showing interval presence, continuity,
17
+ overlap, and milestones as discrete cells.
18
+
19
+ ## Visual examples
20
+
21
+ These examples are rendered from the default registry configs using the local Timeview
22
+ renderer.
23
+
24
+ ### BandedTimeline
25
+
26
+ Horizontal interval bands and milestone diamonds on a continuous day axis.
27
+
28
+ ![BandedTimeline example](docs/assets/timeview-examples/bandedTimeline.png)
29
+
30
+ ### LaneCalendar
31
+
32
+ The same event and interval model projected into week rows and day cells.
33
+
34
+ ![LaneCalendar example](docs/assets/timeview-examples/laneCalendar.png)
35
+
36
+ ### DensityHeatmap
37
+
38
+ Category-by-time aggregation for spotting count or duration density.
39
+
40
+ ![DensityHeatmap example](docs/assets/timeview-examples/densityHeatmap.png)
41
+
42
+ ### MetricTimeline
43
+
44
+ Numeric samples over time with contextual state bands, target lines, milestones, and a
45
+ frozen export viewport.
46
+
47
+ ![MetricTimeline example](docs/assets/timeview-examples/metricTimeline.png)
48
+
49
+ ### SpanMatrix
50
+
51
+ Category rows by day/week buckets, with continuity, overlap counts, milestone markers, and
52
+ today highlighting.
53
+
54
+ ![SpanMatrix example](docs/assets/timeview-examples/spanMatrix.png)
55
+
56
+ ## Quick start
57
+
58
+ Install the React package in an application:
59
+
60
+ ```bash
61
+ npm install @jorgerdz/timeview
62
+ ```
63
+
64
+ ```tsx
65
+ import { BandedTimeline, TV_PALETTES, type TimeDataset } from "@jorgerdz/timeview";
66
+ import "@jorgerdz/timeview/tokens.css";
67
+
68
+ const dataset: TimeDataset = {
69
+ schemaVersion: "timeview.dataset.v1",
70
+ timezone: "UTC",
71
+ labels: [{ id: "work", name: "Work" }],
72
+ events: [],
73
+ intervals: [
74
+ {
75
+ id: "focus",
76
+ title: "Focus block",
77
+ range: { start: "2026-06-10", end: "2026-06-11" },
78
+ labelIds: ["work"],
79
+ },
80
+ ],
81
+ };
82
+
83
+ <BandedTimeline
84
+ dataset={dataset}
85
+ palette={TV_PALETTES.Studio}
86
+ spec={{ kind: "bandedTimeline", title: "Launch preparation" }}
87
+ />;
88
+ ```
89
+
90
+ For local development in this repository:
91
+
92
+ ```bash
93
+ npm install
94
+ npm run dev # open the printed localhost URL
95
+ ```
96
+
97
+ The dev page is the component studio. It renders all registered visualizers and lets you
98
+ switch datasets, palettes, density, visualizer-specific options, live/frozen date behavior,
99
+ preview width, and dataset/spec JSON. It also supports URL hash share links, copyable JSON
100
+ configs, copyable React snippets, PNG/HTML exports, and a copyable LLM prompt for
101
+ generating valid configs.
102
+
103
+ ```bash
104
+ npm run build # typecheck (tsc -b) + production bundle to dist/
105
+ npm test # typecheck + config validation tests
106
+ npm run typecheck # types only
107
+ ```
108
+
109
+ Complete JSON examples for every visualizer live in `examples/configs`.
110
+
111
+ ## Local agent rendering
112
+
113
+ Command-running agents such as Hermes can use Timeview locally to create deterministic
114
+ daily dashboard graphics. The agent writes a `TimeviewConfigV1` JSON file, validates it,
115
+ then asks the CLI to render PNG or self-contained HTML artifacts through headless Chromium.
116
+
117
+ ```bash
118
+ npm install
119
+ npx playwright install chromium
120
+
121
+ npm run --silent timeview -- describe --json
122
+ npm run timeview -- validate ./daily/weight-trend.json --json
123
+ npm run timeview -- render ./daily/weight-trend.json \
124
+ --format png \
125
+ --preset 1600x900 \
126
+ --out ./daily/out/weight-trend.png \
127
+ --json
128
+ ```
129
+
130
+ For multi-panel daily dashboards, use a dashboard manifest:
131
+
132
+ ```json
133
+ {
134
+ "v": 1,
135
+ "title": "Daily Dashboard",
136
+ "generatedAt": "2026-06-10",
137
+ "panels": [
138
+ {
139
+ "id": "weight-trend",
140
+ "title": "Weight trend",
141
+ "format": "png",
142
+ "preset": "1600x900",
143
+ "config": {
144
+ "v": 1,
145
+ "visualizer": "bandedTimeline",
146
+ "dataset": {
147
+ "schemaVersion": "timeview.dataset.v1",
148
+ "timezone": "UTC",
149
+ "labels": [{ "id": "work", "name": "Work" }],
150
+ "events": [],
151
+ "intervals": [
152
+ {
153
+ "id": "focus",
154
+ "title": "Focus block",
155
+ "range": { "start": "2026-06-10", "end": "2026-06-11" },
156
+ "labelIds": ["work"]
157
+ }
158
+ ]
159
+ },
160
+ "spec": { "kind": "bandedTimeline", "title": "Daily Dashboard" },
161
+ "palette": ["#2563eb"]
162
+ }
163
+ }
164
+ ]
165
+ }
166
+ ```
167
+
168
+ Render the full dashboard with:
169
+
170
+ ```bash
171
+ npm run timeview -- render-dashboard ./daily/dashboard.json --out ./daily/out --today 2026-06-10
172
+ ```
173
+
174
+ The dashboard command writes individual chart files plus `dashboard.html`,
175
+ `dashboard.md`, and `manifest.json`. For reproducible agent output, set `today` fields to
176
+ an ISO date or `null`; if a config uses `today: "auto"`, the CLI freezes it to `--today`
177
+ or the local date at render time.
178
+
179
+ See `docs/HERMES-TIMEVIEW-SKILL.md` for the agent-facing guide.
180
+ See `docs/AGENT-USAGE.md` for the generic CLI and automation guide.
181
+
182
+ ## Using the component
183
+
184
+ ```tsx
185
+ import { BandedTimeline, TV_DATA, TV_PALETTES } from "./timeview";
186
+
187
+ <BandedTimeline
188
+ dataset={TV_DATA.default}
189
+ palette={TV_PALETTES.Studio}
190
+ spec={{
191
+ title: "Launch preparation timeline",
192
+ density: "comfortable", // | "compact"
193
+ overlapMode: "lanes", // | "packed" | "layered" | "hatched"
194
+ legend: { position: "bottom" }, // "top" | "bottom" | "right" | "off"
195
+ caption: { position: "bottom", text: "Intervals may overlap." },
196
+ events: { showLabels: true },
197
+ }}
198
+ />;
199
+ ```
200
+
201
+ For hosted/studio configs, use the shared runtime helpers:
202
+
203
+ ```ts
204
+ import {
205
+ decodeTimeviewConfig,
206
+ encodeTimeviewConfig,
207
+ normalizeViewSpec,
208
+ validateTimeDataset,
209
+ } from "./timeview";
210
+ ```
211
+
212
+ `LaneCalendarSpec.today` is explicit: `"auto"` uses the browser-local current date, an ISO
213
+ string freezes the marker, and `null` or omitted disables it.
214
+
215
+ Color is **data-only**: `palette[i]` maps to `dataset.labels` by index, so the same dataset
216
+ re-themes by swapping the palette. The indigo chrome accent is reserved for selection/focus.
217
+
218
+ ## Layout
219
+
220
+ ```
221
+ src/
222
+ styles/tokens.css # the design language — single source of truth (--tv-*)
223
+ timeview/
224
+ types.ts # TimeDataset + ViewSpec contract
225
+ config.ts # validation, spec normalization, URL-safe config helpers
226
+ registry.ts # visualizer defaults, supported controls, agent guidance
227
+ data.ts # fixtures, palettes, scale/format helpers
228
+ BandedTimeline.tsx # horizontal interval/milestone visualizer
229
+ LaneCalendar.tsx # week/day calendar visualizer
230
+ DensityHeatmap.tsx # aggregation matrix visualizer
231
+ MetricTimeline.tsx # metric line + state-band visualizer
232
+ SpanMatrix.tsx # interval presence / continuity matrix visualizer
233
+ index.ts # public surface
234
+ render.tsx # headless CLI render entrypoint
235
+ demo/
236
+ Stage.tsx # component studio
237
+ studio/ # studio layout and inspector chrome
238
+ scripts/timeview.ts # local agent rendering CLI
239
+ docs/DESIGN-NOTES.md # full handoff: API, states, export, a11y
240
+ docs/COMPATIBILITY.md # schema/config/API compatibility and versioning policy
241
+ docs/PERSISTENCE.md # short-link/backend persistence design notes
242
+ docs/HERMES-TIMEVIEW-SKILL.md # command-running agent guide
243
+ CLAUDE.md # durable conventions for new visualizers
244
+ ```
245
+
246
+ See `docs/DESIGN-NOTES.md` for component states, interaction models, accessibility, and
247
+ export notes. See `docs/ROADMAP.md` for the product roadmap across library mode, hosted
248
+ renderer mode, agent mode, and future visualizers. See `docs/STUDIO.md` for studio build
249
+ and deployment notes. See `docs/COMPATIBILITY.md` for the schema/config/API compatibility
250
+ policy. See `docs/PERSISTENCE.md` for the future short-link and backend storage contract.
251
+ See `CLAUDE.md` for the conventions every future visualizer must follow.
252
+
253
+ ## Roadmap
254
+
255
+ The roadmap has two parallel tracks:
256
+
257
+ - **Foundation and product surface:** package publishing, design system, registry,
258
+ showcase/studio site, hosted renderer, live browser behavior, and agent capability docs.
259
+ - **Visualizer expansion:** more projections over the same `TimeDataset`, such as
260
+ `GanttTracks`, `MilestoneMap`, `TimeRibbon`, `RangeTable`, `MonthCalendar`,
261
+ `ActivityHistogram`, and `OverlapInspector`.
262
+
263
+ See `docs/ROADMAP.md` for details.