@event-timeline/core 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.
- package/LICENSE +21 -0
- package/README.md +77 -0
- package/dist/index.cjs +2626 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +439 -0
- package/dist/index.d.ts +439 -0
- package/dist/index.js +2614 -0
- package/dist/index.js.map +1 -0
- package/package.json +60 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Karl Gorgoglione
|
|
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,77 @@
|
|
|
1
|
+
# @event-timeline/core
|
|
2
|
+
|
|
3
|
+
Framework-agnostic Canvas timeline engine — pure TypeScript, **zero React**, no
|
|
4
|
+
DOM-framework assumptions. It renders **elements** (horizontal lanes) and
|
|
5
|
+
**events** (directed arrows between lanes at a point in time) on a `<canvas>` and
|
|
6
|
+
stays smooth while panning/zooming large datasets.
|
|
7
|
+
|
|
8
|
+
This is the engine behind [`@event-timeline/react`](https://www.npmjs.com/package/@event-timeline/react).
|
|
9
|
+
Use it directly to embed the timeline in any framework (or none). See
|
|
10
|
+
[`docs/DESIGN.md`](https://github.com/KarlGorgoglione/event-timeline/blob/main/docs/DESIGN.md)
|
|
11
|
+
for the architecture.
|
|
12
|
+
|
|
13
|
+
## Install
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
pnpm add @event-timeline/core
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
The only runtime dependency is [`date-fns`](https://date-fns.org/) (imported
|
|
20
|
+
per-function to stay tree-shakeable). Calendar math runs in **UTC** so ticks are
|
|
21
|
+
machine-stable.
|
|
22
|
+
|
|
23
|
+
## Quick start
|
|
24
|
+
|
|
25
|
+
The engine is handed two stacked canvases — a **base** layer (lines, arrows,
|
|
26
|
+
header) and an **overlay** layer (hover/selection) — and is driven imperatively.
|
|
27
|
+
It attaches **no** `ResizeObserver`; the host calls `resize()` on size changes.
|
|
28
|
+
|
|
29
|
+
```ts
|
|
30
|
+
import { TimelineEngine } from '@event-timeline/core';
|
|
31
|
+
|
|
32
|
+
const engine = new TimelineEngine(baseCanvas, overlayCanvas, {
|
|
33
|
+
multiSelect: true,
|
|
34
|
+
// onDiagnostic, layout, clustering, lod, styleResolvers, formatters, onFrameStats…
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
engine.resize(container.clientWidth, container.clientHeight, devicePixelRatio);
|
|
38
|
+
engine.setData({ elements, events });
|
|
39
|
+
engine.fit();
|
|
40
|
+
|
|
41
|
+
const off = engine.on('hover', (hit) => {
|
|
42
|
+
/* hit is a typed discriminated union: element | event | cluster | null */
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
// later
|
|
46
|
+
off();
|
|
47
|
+
engine.dispose();
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
The engine consumes the overlay canvas's pointer/wheel events itself (pan, zoom
|
|
51
|
+
about the cursor, hover, click/selection). Pan is anchored in the **time
|
|
52
|
+
domain**, and all time↔screen math lives in a single Camera/scale module
|
|
53
|
+
(the §3 "single source of coordinate truth").
|
|
54
|
+
|
|
55
|
+
## Highlights
|
|
56
|
+
|
|
57
|
+
- **Virtualised & culled** rendering over a sorted temporal index (binary-search
|
|
58
|
+
range queries) plus per-element buckets — built for ~50k events.
|
|
59
|
+
- **Clustering & LOD** (§6): dense events collapse into themeable "×N" markers
|
|
60
|
+
that expand on zoom; per-event labels gate on a zoom threshold.
|
|
61
|
+
- **Pluggable layout** (§7): `byFirstEvent` (default), `barycenter`
|
|
62
|
+
crossing-reduction, and `explicit` ordering — pure `order()` strategies.
|
|
63
|
+
- **Theming & resolution chain** (§11): per-item `style` → resolver → theme
|
|
64
|
+
default, plus label/tick formatters.
|
|
65
|
+
- **Live/streaming** (§10): `addEvents` / `removeEvents` / `addElements` /
|
|
66
|
+
`updateElement` update indexes incrementally (stable-append layout).
|
|
67
|
+
- **Swappable renderer seam** (§4): `Renderer` exposes only backend-free draw
|
|
68
|
+
verbs in device pixels (a WebGL backend can replace Canvas2D unchanged).
|
|
69
|
+
- **Lenient validation** (§1): invalid items are dropped and reported through an
|
|
70
|
+
injectable `onDiagnostic` sink — never thrown.
|
|
71
|
+
- **Observable frames** (§13): an optional `onFrameStats` sink reports per-layer
|
|
72
|
+
draw time for benchmarking, with zero overhead when omitted.
|
|
73
|
+
|
|
74
|
+
## License
|
|
75
|
+
|
|
76
|
+
[MIT](https://github.com/KarlGorgoglione/event-timeline/blob/main/LICENSE) ©
|
|
77
|
+
Karl Gorgoglione
|