@overdoser/react-toolkit 0.8.3 → 0.10.1

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 (33) hide show
  1. package/AGENTS.md +6 -0
  2. package/CHANGELOG.md +88 -0
  3. package/README.md +2 -0
  4. package/components/Timeline/GanttTimeline.d.ts +144 -0
  5. package/components/Timeline/GanttTimeline.js +312 -0
  6. package/components/Timeline/GanttTimeline.module.scss.js +55 -0
  7. package/components/Timeline/HistoryTimeline.d.ts +184 -0
  8. package/components/Timeline/HistoryTimeline.js +445 -0
  9. package/components/Timeline/HistoryTimeline.module.scss.js +59 -0
  10. package/components/Timeline/Timeline.module.scss.js +111 -0
  11. package/components/Timeline/TimelineShared.d.ts +79 -0
  12. package/components/Timeline/TimelineShared.js +173 -0
  13. package/components/Timeline/TraceTimeline.d.ts +180 -0
  14. package/components/Timeline/TraceTimeline.js +536 -0
  15. package/components/Timeline/TraceTimeline.module.scss.js +111 -0
  16. package/components/Timeline/demoData.d.ts +42 -0
  17. package/components/Timeline/historyLayout.d.ts +82 -0
  18. package/components/Timeline/historyLayout.js +264 -0
  19. package/components/Timeline/index.d.ts +7 -0
  20. package/components/Timeline/timelineCore.d.ts +100 -0
  21. package/components/Timeline/timelineCore.js +193 -0
  22. package/components/Timeline/traceLayout.d.ts +72 -0
  23. package/components/Timeline/traceLayout.js +92 -0
  24. package/components/Timeline/useTimeline.d.ts +39 -0
  25. package/components/Timeline/useTimeline.js +81 -0
  26. package/index.css +1 -1
  27. package/index.d.ts +2 -0
  28. package/index.js +93 -87
  29. package/index.layered.css +1 -1
  30. package/llms.txt +115 -1
  31. package/manifest.json +323 -0
  32. package/package.json +2 -1
  33. package/recipes/live-timeline-feed.tsx +147 -0
@@ -0,0 +1,42 @@
1
+ import { TraceTimelineEvent } from './TraceTimeline';
2
+ import { HistoryTimelineEvent } from './HistoryTimeline';
3
+ import { GanttTimelineTask } from './GanttTimeline';
4
+ export declare const TRACE_SERVICES: string[];
5
+ export declare function makeTraceEvents(mid: string, t0: number, r: () => number): TraceTimelineEvent[];
6
+ export interface DemoManifest {
7
+ id: string;
8
+ title: string;
9
+ events: TraceTimelineEvent[];
10
+ }
11
+ export declare function sampleManifests(): DemoManifest[];
12
+ export interface SimStep {
13
+ at: number;
14
+ ev: Record<string, unknown>;
15
+ }
16
+ export declare function manifestSimScript(): {
17
+ mid: string;
18
+ title: string;
19
+ script: SimStep[];
20
+ };
21
+ export interface DemoSubject {
22
+ id: string;
23
+ name: string;
24
+ events: HistoryTimelineEvent[];
25
+ }
26
+ export declare function sampleSubjects(): DemoSubject[];
27
+ export declare function subjectSimScript(subject: string): {
28
+ script: SimStep[];
29
+ };
30
+ export declare function sampleTasks(): GanttTimelineTask[];
31
+ export declare function tasksSimScript(): {
32
+ script: SimStep[];
33
+ };
34
+ export interface DemoSim {
35
+ playing(): boolean;
36
+ done(): boolean;
37
+ play(): void;
38
+ pause(): void;
39
+ }
40
+ export declare function makeSim(script: SimStep[], push: (ev: Record<string, unknown>) => void,
41
+ /** Called when the script drains on its own (keep play/pause UI in sync). */
42
+ onDone?: () => void): DemoSim;
@@ -0,0 +1,82 @@
1
+ /**
2
+ * HistoryTimeline layout, ported near-verbatim from the design handoff
3
+ * (`Subject History.dc.html` logic block). Pure and unit-tested for the
4
+ * collision-avoidance guarantees. The algorithm, in order:
5
+ *
6
+ * 1. **Side split** — events too close to share a side (cluster threshold
7
+ * 120px horizontal / 110px vertical) alternate around the axis; isolated
8
+ * events alternate globally. Narrow vertical mode forces all to one side.
9
+ * 2. **Circles** sit ON the axis; they step outward in 20px levels only when
10
+ * their level within 46px is occupied on their side (protects Z stubs), or
11
+ * when a close event exists on the opposite side.
12
+ * 3. **Per-side reconciliation, newest first.** Rows extend away from the
13
+ * axis, each sized by its tallest/widest chip + 12px gap. A chip prefers a
14
+ * straight centered stem (may slide sideways past occupied extents as long
15
+ * as the stem still lands inside it); same-side bursts are placed as
16
+ * groups on consecutive rows with parallel Z-leads; non-group conflicts
17
+ * fall back to Z-leads with bounded slides, and as a last resort an extra
18
+ * row (never identical coordinates).
19
+ */
20
+ export interface HistoryLayoutEventInput {
21
+ id: string;
22
+ title: string;
23
+ detail: string;
24
+ start: number;
25
+ /** `null` = ongoing. */
26
+ end: number | null;
27
+ }
28
+ export interface HistoryLayoutConfig {
29
+ orientation: 'horizontal' | 'vertical';
30
+ spacing: 'equal' | 'log' | 'proportional';
31
+ /** Scroll container client width. */
32
+ containerWidth: number;
33
+ /** Viewport height (drives fit targets). */
34
+ viewportHeight: number;
35
+ /** Current time (sizes ongoing events). */
36
+ now: number;
37
+ /** Explicit zoom factor, or `'fit'` to fit-with-cross-axis-iteration. */
38
+ k: number | 'fit';
39
+ }
40
+ export interface HistorySeg {
41
+ l: number;
42
+ t: number;
43
+ w: number;
44
+ h: number;
45
+ }
46
+ export interface HistoryLayoutItem {
47
+ id: string;
48
+ /** Axis-position of the event. */
49
+ pos: number;
50
+ dotX: number;
51
+ dotY: number;
52
+ cardLeft: number;
53
+ cardTop: number;
54
+ cardW: number;
55
+ cardH: number;
56
+ /** Burst-condensed member (detail omitted). */
57
+ condensed: boolean;
58
+ /** Lead-line segments (axis-colored, drawn under dots and cards). */
59
+ segs: HistorySeg[];
60
+ /** 0 = above/right of the axis, 1 = below/left. */
61
+ side: number;
62
+ row: number;
63
+ mode: 's' | 'z';
64
+ }
65
+ export interface HistoryLayoutResult {
66
+ items: HistoryLayoutItem[];
67
+ axisY: number;
68
+ axisX: number;
69
+ innerW: number;
70
+ innerH: number;
71
+ /** Effective zoom factor after fit iteration. */
72
+ kEff: number;
73
+ /** Fit zoom factor (100% reference). */
74
+ kFit: number;
75
+ /** Axis-positions per event (tick placement for equal/log spacing). */
76
+ posArr: number[];
77
+ /** Time→position map (proportional spacing only). */
78
+ mapT: ((t: number) => number) | null;
79
+ /** Pixel length of the time span (proportional tick generation). */
80
+ innerSpan: number;
81
+ }
82
+ export declare function computeHistoryLayout(events: HistoryLayoutEventInput[], cfg: HistoryLayoutConfig): HistoryLayoutResult;
@@ -0,0 +1,264 @@
1
+ function Ut(jt, S) {
2
+ const C = jt.slice().sort((g, L) => g.start - L.start), X = C.length, $ = S.now, d = S.orientation === "horizontal", F = S.spacing, j = S.containerWidth, G = j < 640, tt = !d && G ? Math.max(190, j - 110) : 230, Lt = 144, st = d ? 150 : 80, Ot = d ? 150 : 140, it = X ? C[0].start : $, Pt = X ? Math.max(it + 1, ...C.map((g) => g.end == null ? $ : Math.max(g.end, g.start))) : $ + 1, At = Math.max(1, Pt - it);
3
+ let ot;
4
+ d ? ot = F === "equal" ? 300 + Math.max(0, X - 1) * 264 : Math.max(j, X * (F === "proportional" ? 200 : 170)) : ot = F === "equal" ? 200 + Math.max(0, X - 1) * 190 : Math.max(460, X * (F === "proportional" ? 150 : 130) + 180);
5
+ const Xt = (d ? j : Math.max(420, Math.round(S.viewportHeight * 0.66))) / ot, bt = (g) => {
6
+ const L = Math.max(320, Math.round(ot * g)), x = L - st - Ot;
7
+ let M = [], k = null;
8
+ if (F === "proportional")
9
+ k = (t) => st + (t - it) / At * x, M = C.map((t) => k(t.start));
10
+ else if (F === "log") {
11
+ const t = At / Math.max(8, X * 2), s = [];
12
+ let e = 0;
13
+ C.forEach((p, E) => {
14
+ E > 0 && (e += Math.log1p((p.start - C[E - 1].start) / t)), s.push(e);
15
+ });
16
+ const o = e || 1;
17
+ M = s.map((p) => st + p / o * x);
18
+ } else
19
+ M = C.map((t, s) => st + (X > 1 ? s * x / (X - 1) : 0));
20
+ let P = d ? Math.max(j, L) : 900;
21
+ const r = d ? 600 : L, b = d ? 120 : 110, v = [];
22
+ let Y = X ? [0] : [];
23
+ for (let t = 1; t < X; t++)
24
+ M[t] - M[t - 1] < b ? Y.push(t) : (v.push(Y), Y = [t]);
25
+ Y.length && v.push(Y);
26
+ const O = !d && G, h = C.map(() => ({ side: 0, row: 0, mode: "s", dlv: 0, rx: 0, lx: 0 }));
27
+ let H = 0;
28
+ for (let t = v.length - 1; t >= 0; t--) {
29
+ const s = v[t];
30
+ for (let e = s.length - 1; e >= 0; e--) {
31
+ const o = s.length - 1 - e;
32
+ h[s[e]].side = O ? 0 : s.length === 1 ? H++ % 2 : o % 2;
33
+ }
34
+ }
35
+ const Ft = M.map(
36
+ (t, s) => M.some((e, o) => o !== s && h[o].side !== h[s].side && Math.abs(e - t) < 18)
37
+ ), It = d ? tt * 0.55 : 110, U = new Array(X).fill(-1), nt = [];
38
+ [0, 1].forEach((t) => {
39
+ const s = [];
40
+ for (let o = 0; o < X; o++) h[o].side === t && s.push(o);
41
+ let e = null;
42
+ for (let o = 1; o < s.length; o++)
43
+ M[s[o]] - M[s[o - 1]] < It ? (e || (e = [s[o - 1]], nt.push(e), U[s[o - 1]] = nt.length - 1), e.push(s[o]), U[s[o]] = nt.length - 1) : e = null;
44
+ });
45
+ const Gt = {}, B = [], W = [];
46
+ for (let t = 0; t < X; t++) {
47
+ const s = C[t], e = U[t] >= 0, o = String(s.title || ""), p = String(s.detail || ""), E = s.end == null, at = (E ? $ : s.end) - s.start, wt = E || at > 0, gt = Math.min(2, Math.max(1, Math.ceil(o.length / 26))), N = e || !p ? 0 : Math.min(2, Math.ceil(p.length / 34));
48
+ B.push(Math.round(7 + gt * 17 + 3 + 15 + (N ? 3 + N * 16 : 0) + (wt ? 24 : 0) + 8)), W.push(
49
+ !d && G ? tt : e ? Math.max(160, Math.min(230, o.length * 7 + 64)) : 230
50
+ );
51
+ }
52
+ const Tt = [
53
+ { chips: [], stems: [] },
54
+ { chips: [], stems: [] }
55
+ ], _t = d ? 46 : 80, _ = [[], []];
56
+ for (let t = X - 1; t >= 0; t--) {
57
+ const s = _[h[t].side], e = M[t];
58
+ let o = Ft[t] ? 1 : 0;
59
+ for (; s.some((p) => p.lv === o && Math.abs(p.p - e) < _t); ) o++;
60
+ h[t].dlv = o, s.push({ p: e, lv: o, i: t });
61
+ }
62
+ const ft = 10, Rt = (t, s) => _[h[t].side].some(
63
+ (e) => e.i !== t && e.lv > h[t].dlv && Math.abs(e.p - s) < ft
64
+ ), Nt = (t, s, e) => _[h[t].side].some(
65
+ (o) => o.i !== t && (o.lv === h[t].dlv && o.p > s && o.p < e + ft || o.lv > h[t].dlv && Math.abs(o.p - e) < ft)
66
+ );
67
+ for (let t = X - 1; t >= 0; t--) {
68
+ const s = h[t], e = Tt[s.side], o = M[t], p = W[t], E = B[t], at = d ? o - p / 2 : o - 44, wt = (c, l, i) => !e.chips.some((m) => m.row === c && l < m.x2 + 10 && i > m.x1 - 10), gt = (c, l, i) => e.stems.some((m) => m.row > c && m.x > l - 6 && m.x < i + 6), N = (c, l) => e.chips.some((i) => i.row < c && l > i.x1 - 6 && l < i.x2 + 6), V = d ? p : E, Vt = Math.round(V / 2) - 20, y = (c, l) => {
69
+ let i = l, m = 0, f = !0;
70
+ for (; f && m++ < 60; ) {
71
+ f = !1;
72
+ for (const n of e.chips)
73
+ n.row === c && i < n.x2 + 10 && i + V > n.x1 - 10 && (i = n.x2 + 10, f = !0);
74
+ for (const n of e.stems)
75
+ n.row > c && n.x > i - 6 && n.x < i + V + 6 && (i = n.x + 7, f = !0);
76
+ }
77
+ return i;
78
+ }, St = (c, l) => {
79
+ const i = M[c], m = _[h[c].side];
80
+ let f = 1 / 0;
81
+ for (const a of m)
82
+ a.i !== c && a.lv === h[c].dlv && a.p > i && (f = Math.min(f, a.p - 8));
83
+ const n = (a) => !m.some((A) => A.i !== c && A.lv > h[c].dlv && Math.abs(A.p - a) < 8) && !e.stems.some((A) => Math.abs(A.x - a) < 4), u = Math.min(Math.max(l, i + 8), f);
84
+ for (let a = u; a <= f && a <= u + 80; a++) if (n(a)) return a;
85
+ for (let a = u - 1; a >= i + 8; a--) if (n(a)) return a;
86
+ return u;
87
+ }, Jt = (c, l) => {
88
+ const i = M[c];
89
+ return _[h[c].side].some(
90
+ (m) => m.i !== c && (m.lv > h[c].dlv && Math.abs(m.p - l) < 8 || m.lv === h[c].dlv && m.p > i && m.p < l + 8)
91
+ );
92
+ }, vt = (c, l, i) => {
93
+ const m = M[c], f = _[h[c].side];
94
+ let n = 1 / 0;
95
+ for (const w of f)
96
+ w.i !== c && w.lv === h[c].dlv && w.p > m && (n = Math.min(n, w.p - 28));
97
+ const u = (w) => !f.some((J) => J.i !== c && J.lv > h[c].dlv && Math.abs(J.p - (w + 20)) < 8);
98
+ let a = y(l, i), A = 0;
99
+ for (; !u(a) && a < n && A++ < 40; ) a = y(l, a + 4);
100
+ if (a > n || !u(a)) {
101
+ for (let w = Math.min(a, n); w >= i; w -= 2)
102
+ if (u(w) && y(l, w) === w) return w;
103
+ }
104
+ return a;
105
+ }, ct = U[t];
106
+ if (ct >= 0) {
107
+ if (!Gt[ct]) {
108
+ Gt[ct] = !0;
109
+ const c = nt[ct].slice().reverse(), l = c.length, i = c.map((f, n) => {
110
+ const u = l - 1 - n, a = M[f], A = Math.round(d ? a + 8 + (u + 1) * 10 : a + 10), w = Math.round(d ? Math.max(A + 12, a + 24 + u * 16) : a + 20);
111
+ return { j: f, jj: n, rx: A, lx: w, x1: w, x2: w + (d ? W[f] : B[f]) };
112
+ });
113
+ let m = 0;
114
+ for (; m <= 5; m++) {
115
+ let f = !0;
116
+ for (const n of i) {
117
+ const u = m + n.jj;
118
+ if (!wt(u, n.x1, n.x2) || gt(u, n.x1, n.x2)) {
119
+ f = !1;
120
+ break;
121
+ }
122
+ }
123
+ if (f) break;
124
+ }
125
+ for (let f = i.length - 1; f >= 0; f--) {
126
+ const n = i[f], u = h[n.j], a = m + n.jj, A = M[n.j], w = d ? W[n.j] : B[n.j], J = d ? A - W[n.j] / 2 : A - 44, lt = y(a, J), Kt = e.stems.some((z) => z.row > a && Math.abs(z.x - A) < 8);
127
+ if (lt - J <= Math.round(w / 2) - 20 && !Kt && !N(a, A) && !Rt(n.j, A))
128
+ u.row = a, u.mode = "s", u.sx1 = Math.round(lt), e.chips.push({ row: a, x1: lt, x2: lt + w, h: B[n.j], w: W[n.j] }), e.stems.push({ x: A, row: a });
129
+ else {
130
+ let z, Z;
131
+ d ? (z = Math.round(St(n.j, n.rx)), Z = Math.round(y(a, Math.max(n.lx, z + 12)))) : (z = n.rx, Z = Math.round(vt(n.j, a, n.lx))), u.row = a, u.mode = "z", u.rx = z, u.lx = Z, e.chips.push({ row: a, x1: Z, x2: Z + w, h: B[n.j], w: W[n.j] }), e.stems.push({ x: z, row: a });
132
+ }
133
+ }
134
+ }
135
+ continue;
136
+ }
137
+ let D = !1;
138
+ for (let c = 0; c <= 5 && !D; c++) {
139
+ const l = y(c, at);
140
+ l - at <= Vt && !N(c, o) && !Rt(t, o) && (s.row = c, s.mode = "s", s.sx1 = Math.round(l), e.chips.push({ row: c, x1: l, x2: l + V, h: E, w: p }), e.stems.push({ x: o, row: c }), D = !0);
141
+ }
142
+ if (!D)
143
+ for (const c of [64, 340]) {
144
+ for (let l = 0; l <= 5 && !D; l++) {
145
+ const i = o + 10 + l * 7, m = d ? i + 14 : o + 20, f = d ? y(l, m) : vt(t, l, m), n = d ? !Nt(t, o, i) : !Jt(t, f + 20);
146
+ f - m <= c && !N(l, d ? i : f + 20) && n && (s.row = l, s.mode = "z", s.rx = Math.round(i), s.lx = Math.round(f), e.chips.push({ row: l, x1: f, x2: f + V, h: E, w: p }), e.stems.push({ x: i, row: l }), D = !0);
147
+ }
148
+ if (D) break;
149
+ }
150
+ if (!D) {
151
+ let l, i;
152
+ d ? (l = Math.round(St(t, o + 10)), i = y(6, Math.max(o + 24, l + 12))) : (l = o + 10, i = vt(t, 6, o + 20)), s.row = 6, s.mode = "z", s.rx = Math.round(l), s.lx = Math.round(i), e.chips.push({ row: 6, x1: i, x2: i + V, h: E, w: p }), e.stems.push({ x: l, row: 6 });
153
+ }
154
+ }
155
+ const Et = Tt.map((t) => {
156
+ const s = [];
157
+ t.chips.forEach((p) => {
158
+ s[p.row] = Math.max(s[p.row] || 0, (d ? p.h : p.w) || (d ? Lt : tt));
159
+ });
160
+ const e = [];
161
+ let o = 44;
162
+ for (let p = 0; p < s.length; p++)
163
+ e[p] = o, o += (s[p] || 90) + 12;
164
+ return e.total = o, e;
165
+ }), mt = Et[0], pt = Et[1];
166
+ let ut = 0, rt = 0, Mt = 0;
167
+ if (d)
168
+ ut = 46 + Math.max(mt.total, 190), Mt = ut + Math.max(pt.total, 130) + 24;
169
+ else {
170
+ rt = G ? 26 : Math.round(j / 2), Mt = r;
171
+ const t = Math.max(0, 78 - (rt - pt.total - 16));
172
+ P = Math.max(j - 2, rt + mt.total + 16 + t + 24);
173
+ }
174
+ return { posArr: M, mapT: k, innerW: P, innerLen: r, innerSpan: x, meta: h, groupOf: U, chArr: B, cwArr: W, offA: mt, offB: pt, axisY: ut, axisX: rt, innerH: Mt };
175
+ };
176
+ let K = S.k === "fit" ? Xt : S.k, q = bt(K);
177
+ if (S.k === "fit") {
178
+ const g = d ? Math.max(380, Math.round(S.viewportHeight * 0.8)) : j + 4;
179
+ let L = 0;
180
+ for (; L++ < 6 && (d ? q.innerH > g : q.innerW > g); )
181
+ K = K * 1.3, q = bt(K);
182
+ }
183
+ const { posArr: kt, mapT: Wt, innerSpan: yt, meta: zt, groupOf: qt, chArr: Bt, cwArr: Dt, offA: Ht, offB: Yt, axisY: Q } = q;
184
+ let T = q.axisX, et = q.innerW, ht = q.innerH, I = 0, dt = 0, xt = 1e9;
185
+ const R = 1.5, Ct = C.map((g, L) => {
186
+ const x = zt[L], M = Math.round(kt[L]), k = Dt[L], P = Bt[L], r = {
187
+ id: g.id,
188
+ pos: M,
189
+ dotX: 0,
190
+ dotY: 0,
191
+ cardLeft: 0,
192
+ cardTop: 0,
193
+ cardW: k,
194
+ cardH: P,
195
+ condensed: qt[L] >= 0,
196
+ segs: [],
197
+ side: x.side,
198
+ row: x.row,
199
+ mode: x.mode
200
+ };
201
+ if (d) {
202
+ const b = M;
203
+ r.dotX = b;
204
+ const v = x.side === 0;
205
+ r.dotY = v ? Q - x.dlv * 20 : Q + x.dlv * 20;
206
+ const Y = v ? Ht : Yt, O = Y[x.row] != null ? Y[x.row] : 44 + x.row * (Lt + 12);
207
+ if (r.cardTop = v ? Q - O - P : Q + O, x.mode === "s") {
208
+ r.cardLeft = x.sx1 != null ? x.sx1 : b - Math.round(k / 2);
209
+ const h = v ? r.cardTop + P : r.dotY + 8, H = v ? r.dotY - 8 : r.cardTop;
210
+ r.segs.push({ l: b - 1, t: h, w: R, h: Math.max(2, H - h) });
211
+ } else {
212
+ const h = x.rx;
213
+ r.cardLeft = x.lx;
214
+ const H = r.cardTop + Math.round(P / 2);
215
+ r.segs.push({ l: b + 7, t: r.dotY - 1, w: Math.max(2, h - b - 7 + R), h: R }), r.segs.push({ l: h - 1, t: Math.min(r.dotY, H), w: R, h: Math.abs(H - r.dotY) + R }), r.segs.push({ l: h - 1, t: H - 1, w: Math.max(2, r.cardLeft - h + 1), h: R });
216
+ }
217
+ I = Math.max(I, r.cardLeft + k);
218
+ } else {
219
+ const b = M;
220
+ r.dotY = b;
221
+ const v = x.side === 0;
222
+ r.dotX = v || G ? T + x.dlv * 20 : T - x.dlv * 20;
223
+ const Y = v ? Ht : Yt, O = Y[x.row] != null ? Y[x.row] : 44 + x.row * (tt + 14);
224
+ if (x.mode === "s") {
225
+ r.cardTop = x.sx1 != null ? x.sx1 : b - 44, r.cardLeft = G ? T + 34 : v ? T + O : T - O - k;
226
+ const h = v || G ? r.dotX + 8 : r.cardLeft + k, H = v || G ? r.cardLeft : r.dotX - 8;
227
+ r.segs.push({ l: h, t: b - 1, w: Math.max(2, H - h), h: R });
228
+ } else {
229
+ r.cardTop = x.lx, r.cardLeft = G ? T + 34 : v ? T + O + 16 : T - O - 16 - k;
230
+ const h = r.cardTop + 20;
231
+ r.segs.push({ l: r.dotX - 1, t: b + 7, w: R, h: Math.max(2, h - b - 7 + R) });
232
+ const H = v || G ? r.cardLeft : r.cardLeft + k;
233
+ r.segs.push({ l: Math.min(r.dotX, H), t: h - 1, w: Math.max(2, Math.abs(H - r.dotX)), h: R });
234
+ }
235
+ dt = Math.max(dt, r.cardTop + P), I = Math.max(I, r.cardLeft + k), xt = Math.min(xt, r.cardLeft);
236
+ }
237
+ return r;
238
+ });
239
+ if (d) et = Math.max(et, I + 40);
240
+ else {
241
+ ht = Math.max(ht, dt + 40);
242
+ const g = Math.max(0, 78 - xt);
243
+ g && (T += g, Ct.forEach((L) => {
244
+ L.dotX += g, L.cardLeft += g, L.segs.forEach((x) => {
245
+ x.l += g;
246
+ });
247
+ })), et = Math.max(j - 2, I + g + 24);
248
+ }
249
+ return {
250
+ items: Ct,
251
+ axisY: Q,
252
+ axisX: T,
253
+ innerW: Math.ceil(et),
254
+ innerH: Math.ceil(ht),
255
+ kEff: K,
256
+ kFit: Xt,
257
+ posArr: kt,
258
+ mapT: Wt,
259
+ innerSpan: yt
260
+ };
261
+ }
262
+ export {
263
+ Ut as computeHistoryLayout
264
+ };
@@ -0,0 +1,7 @@
1
+ export type { TimelineSummaryPlacement } from './TimelineShared';
2
+ export { TraceTimeline } from './TraceTimeline';
3
+ export type { TraceTimelineProps, TraceTimelineEvent, TraceTimelineClasses, TraceTimelineItemContext, } from './TraceTimeline';
4
+ export { HistoryTimeline } from './HistoryTimeline';
5
+ export type { HistoryTimelineProps, HistoryTimelineEvent, HistoryTimelineClasses, HistoryTimelineOrientation, HistoryTimelineSpacing, HistoryTimelineItemContext, } from './HistoryTimeline';
6
+ export { GanttTimeline } from './GanttTimeline';
7
+ export type { GanttTimelineProps, GanttTimelineTask, GanttTimelineClasses, GanttTimelineItemContext, } from './GanttTimeline';
@@ -0,0 +1,100 @@
1
+ /**
2
+ * Shared internals for the Timeline family (TraceTimeline, HistoryTimeline,
3
+ * GanttTimeline). Ported from the design-handoff `timeline-core.js` — the
4
+ * formatting rules, tick step table, and matching/highlighting semantics are
5
+ * part of the visual spec and must stay behaviorally identical.
6
+ */
7
+ export declare const SECOND = 1000;
8
+ export declare const MINUTE: number;
9
+ export declare const HOUR: number;
10
+ export declare const DAY: number;
11
+ /** `HH:MM:SS` in local time, optionally with milliseconds. */
12
+ export declare function fmtClock(t: number, ms?: boolean): string;
13
+ /** `Jul 27` in local time. */
14
+ export declare function fmtDate(t: number): string;
15
+ /**
16
+ * `Jul 27 · 14:03:22`; the year is included when not the current year, and the
17
+ * clock is dropped entirely for events older than two years.
18
+ */
19
+ export declare function fmtDateTime(t: number): string;
20
+ /** `HH:MM:SS` in UTC, optionally with milliseconds. */
21
+ export declare function fmtClockUTC(t: number, ms?: boolean): string;
22
+ /** `YYYY-MM-DD` in UTC. */
23
+ export declare function fmtDateISO(t: number): string;
24
+ /** Full ISO timestamp with explicit `Z`: `YYYY-MM-DDTHH:MM:SS[.mmm]Z`. */
25
+ export declare function fmtISO(t: number, ms?: boolean): string;
26
+ /** Adaptive duration: `412ms`, `3.1s`, `4m 12s`, `3h 20m`, `2.5d`, `1.2y`. */
27
+ export declare function fmtDur(ms: number | null | undefined): string;
28
+ /** Tick step table spanning 1 millisecond → 500 years. */
29
+ export declare const TICK_STEPS: number[];
30
+ /**
31
+ * Subdivision for a tick step: how many equal `parts` it splits into for minor
32
+ * marks, and which part index gets a medium mark (`0` = none). Steps outside
33
+ * `TICK_STEPS` fall back to a plain quarter split.
34
+ */
35
+ export declare function tickSubdiv(step: number): {
36
+ parts: number;
37
+ medium: number;
38
+ };
39
+ export interface Tick {
40
+ t: number;
41
+ label: string;
42
+ }
43
+ export interface TickResult {
44
+ step: number;
45
+ list: Tick[];
46
+ }
47
+ /**
48
+ * Pick a step from the table so ticks are at least `minPx` apart across
49
+ * `widthPx`, and enumerate them. Labels use the local clock below day
50
+ * granularity (with milliseconds below second granularity) and `Jul 27`-style
51
+ * dates above it.
52
+ */
53
+ export declare function ticks(t0: number, t1: number, widthPx: number, minPx?: number): TickResult;
54
+ export interface HighlightPart {
55
+ t: string;
56
+ hit: boolean;
57
+ }
58
+ /**
59
+ * Split `text` into matched/unmatched parts against a case-insensitive query
60
+ * so matched substrings can be wrapped in `<mark>`-style spans.
61
+ */
62
+ export declare function highlightParts(text: unknown, q: string | undefined): HighlightPart[];
63
+ /**
64
+ * Keyword match: case-insensitive AND over whitespace-separated tokens against
65
+ * the JSON serialization of the event.
66
+ */
67
+ export declare function eventMatches(ev: unknown, q: string | undefined): boolean;
68
+ /**
69
+ * Fuzzy score for pickers: each token scores by substring position (best) or
70
+ * character subsequence (weak); a token that matches neither zeroes the score.
71
+ */
72
+ export declare function fuzzyScore(hay: unknown, q: string): number;
73
+ /** Category palette cycled across services / tags / rows. */
74
+ export declare const TIMELINE_PALETTE_VARS: string[];
75
+ /** Mix a palette color with white, e.g. tinted chip/badge backgrounds. */
76
+ export declare function tint(color: string, pct: number): string;
77
+ /**
78
+ * Theme tokens referenced from inline styles (dynamic, per-event colors are
79
+ * computed in JS; static chrome colors live in the SCSS modules).
80
+ */
81
+ export declare const TL_COLORS: {
82
+ readonly ink: "var(--crk-timeline-ink, #23201c)";
83
+ readonly body: "var(--crk-timeline-body, #3b352f)";
84
+ readonly secondary: "var(--crk-timeline-secondary, #57504a)";
85
+ readonly muted: "var(--crk-timeline-muted, #857d73)";
86
+ readonly faint: "var(--crk-timeline-faint, #b0a79b)";
87
+ readonly hairline: "var(--crk-timeline-hairline, #e8e2d9)";
88
+ readonly stem: "var(--crk-timeline-stem, #c9c1b5)";
89
+ readonly stemHot: "var(--crk-timeline-stem-hot, #8a8175)";
90
+ readonly accent: "var(--crk-timeline-accent, #0e7568)";
91
+ readonly accentDark: "var(--crk-timeline-accent-dark, #0b5a50)";
92
+ readonly accentTint: "var(--crk-timeline-accent-tint, #e4f1ee)";
93
+ readonly hlWash: "var(--crk-timeline-hl-wash, #fff3d1)";
94
+ readonly hlWashSoft: "var(--crk-timeline-hl-wash-soft, #fff9e8)";
95
+ readonly hlMark: "var(--crk-timeline-hl-mark, #ffdf7e)";
96
+ readonly hlRing: "var(--crk-timeline-hl-ring, #f3d98b)";
97
+ readonly hlBorder: "var(--crk-timeline-hl-border, #e8b931)";
98
+ readonly hlBarBg: "var(--crk-timeline-hl-bar, #ffe9ae)";
99
+ readonly selectedRing: "var(--crk-timeline-selected-ring, #b8ddd6)";
100
+ };
@@ -0,0 +1,193 @@
1
+ const O = 1e3, U = 6e4, N = 36e5, S = 864e5, c = (t) => String(t).padStart(2, "0"), A = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
2
+ function u(t, e) {
3
+ const n = new Date(t);
4
+ return c(n.getHours()) + ":" + c(n.getMinutes()) + ":" + c(n.getSeconds()) + (e ? "." + String(n.getMilliseconds()).padStart(3, "0") : "");
5
+ }
6
+ function s(t) {
7
+ const e = new Date(t);
8
+ return A[e.getMonth()] + " " + e.getDate();
9
+ }
10
+ function C(t) {
11
+ const e = new Date(t).getFullYear(), n = e !== (/* @__PURE__ */ new Date()).getFullYear();
12
+ return n && Date.now() - t > 2 * 365 * 864e5 ? s(t) + " " + e : s(t) + (n ? " " + e : "") + " · " + u(t);
13
+ }
14
+ function Y(t, e) {
15
+ const n = new Date(t);
16
+ return c(n.getUTCHours()) + ":" + c(n.getUTCMinutes()) + ":" + c(n.getUTCSeconds()) + (e ? "." + String(n.getUTCMilliseconds()).padStart(3, "0") : "");
17
+ }
18
+ function h(t) {
19
+ const e = new Date(t);
20
+ return e.getUTCFullYear() + "-" + c(e.getUTCMonth() + 1) + "-" + c(e.getUTCDate());
21
+ }
22
+ function M(t, e) {
23
+ return h(t) + "T" + Y(t, e) + "Z";
24
+ }
25
+ function d(t) {
26
+ return t == null ? "" : t < 1e3 ? Math.round(t) + "ms" : t < 6e4 ? (t / 1e3).toFixed(t < 10 * 1e3 ? 1 : 0) + "s" : t < 36e5 ? Math.floor(t / 6e4) + "m " + Math.round(t % 6e4 / 1e3) + "s" : t < 2 * 864e5 ? Math.floor(t / 36e5) + "h " + Math.round(t % 36e5 / 6e4) + "m" : t < 365 * 864e5 ? (t / 864e5).toFixed(1) + "d" : (t / (365.25 * 864e5)).toFixed(t < 3650 * 864e5 ? 1 : 0) + "y";
27
+ }
28
+ const l = [
29
+ 1,
30
+ 2,
31
+ 5,
32
+ 10,
33
+ 25,
34
+ 50,
35
+ 100,
36
+ 250,
37
+ 500,
38
+ 1e3,
39
+ 2 * 1e3,
40
+ 5 * 1e3,
41
+ 10 * 1e3,
42
+ 15 * 1e3,
43
+ 30 * 1e3,
44
+ 6e4,
45
+ 2 * 6e4,
46
+ 5 * 6e4,
47
+ 10 * 6e4,
48
+ 15 * 6e4,
49
+ 30 * 6e4,
50
+ 36e5,
51
+ 2 * 36e5,
52
+ 3 * 36e5,
53
+ 6 * 36e5,
54
+ 12 * 36e5,
55
+ 864e5,
56
+ 2 * 864e5,
57
+ 7 * 864e5,
58
+ 14 * 864e5,
59
+ 30 * 864e5,
60
+ 90 * 864e5,
61
+ 180 * 864e5,
62
+ 365 * 864e5,
63
+ 730 * 864e5,
64
+ 1825 * 864e5,
65
+ 3650 * 864e5,
66
+ 9131 * 864e5,
67
+ 18262 * 864e5,
68
+ 36525 * 864e5,
69
+ 91311 * 864e5,
70
+ 182625 * 864e5
71
+ ], E = /* @__PURE__ */ new Map([
72
+ [1, [0, 0]],
73
+ [2, [2, 0]],
74
+ [5, [5, 0]],
75
+ [10, [10, 5]],
76
+ [25, [5, 0]],
77
+ [50, [10, 5]],
78
+ [100, [10, 5]],
79
+ [250, [5, 0]],
80
+ [500, [10, 5]],
81
+ [1e3, [10, 5]],
82
+ [2 * 1e3, [4, 2]],
83
+ [5 * 1e3, [5, 0]],
84
+ [10 * 1e3, [10, 5]],
85
+ [15 * 1e3, [3, 0]],
86
+ [30 * 1e3, [6, 3]],
87
+ [6e4, [6, 3]],
88
+ [2 * 6e4, [4, 2]],
89
+ [5 * 6e4, [5, 0]],
90
+ [10 * 6e4, [10, 5]],
91
+ [15 * 6e4, [3, 0]],
92
+ [30 * 6e4, [6, 3]],
93
+ [36e5, [6, 3]],
94
+ [2 * 36e5, [4, 2]],
95
+ [3 * 36e5, [3, 0]],
96
+ [6 * 36e5, [6, 3]],
97
+ [12 * 36e5, [4, 2]],
98
+ [864e5, [4, 2]],
99
+ [2 * 864e5, [4, 2]],
100
+ [7 * 864e5, [7, 0]],
101
+ [14 * 864e5, [14, 7]],
102
+ [30 * 864e5, [6, 3]],
103
+ [90 * 864e5, [3, 0]],
104
+ [180 * 864e5, [6, 3]],
105
+ [365 * 864e5, [4, 2]],
106
+ [730 * 864e5, [4, 2]],
107
+ [1825 * 864e5, [5, 0]],
108
+ [3650 * 864e5, [10, 5]],
109
+ [9131 * 864e5, [5, 0]],
110
+ [18262 * 864e5, [10, 5]],
111
+ [36525 * 864e5, [10, 5]],
112
+ [91311 * 864e5, [5, 0]],
113
+ [182625 * 864e5, [5, 0]]
114
+ ]);
115
+ function g(t) {
116
+ const e = E.get(t) || [4, 0];
117
+ return { parts: e[0], medium: e[1] };
118
+ }
119
+ function T(t, e, n, a) {
120
+ a = a || 88;
121
+ const D = Math.max(1, e - t), r = l.find((f) => f / D * n >= a) || l[l.length - 1], o = [];
122
+ let i = Math.ceil(t / r) * r;
123
+ for (; i <= e; i += r)
124
+ o.push({ t: i, label: r >= 864e5 ? s(i) : u(i, r < 1e3) });
125
+ return { step: r, list: o };
126
+ }
127
+ function I(t, e) {
128
+ const n = String(t ?? "");
129
+ if (e = (e || "").trim(), !e) return [{ t: n, hit: !1 }];
130
+ const a = e.toLowerCase(), D = n.toLowerCase(), r = [];
131
+ let o = 0;
132
+ for (; ; ) {
133
+ const i = D.indexOf(a, o);
134
+ if (i < 0) {
135
+ o < n.length && r.push({ t: n.slice(o), hit: !1 });
136
+ break;
137
+ }
138
+ i > o && r.push({ t: n.slice(o, i), hit: !1 }), r.push({ t: n.slice(i, i + e.length), hit: !0 }), o = i + e.length;
139
+ }
140
+ return r.length ? r : [{ t: n, hit: !1 }];
141
+ }
142
+ function k(t, e) {
143
+ if (e = (e || "").trim(), !e) return !0;
144
+ let n;
145
+ try {
146
+ n = JSON.stringify(t).toLowerCase();
147
+ } catch {
148
+ n = String(t).toLowerCase();
149
+ }
150
+ return e.toLowerCase().split(/\s+/).filter(Boolean).every((a) => n.includes(a));
151
+ }
152
+ const H = [
153
+ "var(--crk-timeline-1, #0e7568)",
154
+ "var(--crk-timeline-2, #4c5bd4)",
155
+ "var(--crk-timeline-3, #c05f2c)",
156
+ "var(--crk-timeline-4, #96488a)",
157
+ "var(--crk-timeline-5, #3e6b8f)",
158
+ "var(--crk-timeline-6, #b03a48)"
159
+ ];
160
+ function R(t, e) {
161
+ return `color-mix(in srgb, ${t} ${e}%, white)`;
162
+ }
163
+ const m = {
164
+ body: "var(--crk-timeline-body, #3b352f)",
165
+ stem: "var(--crk-timeline-stem, #c9c1b5)",
166
+ stemHot: "var(--crk-timeline-stem-hot, #8a8175)",
167
+ hlWashSoft: "var(--crk-timeline-hl-wash-soft, #fff9e8)",
168
+ hlRing: "var(--crk-timeline-hl-ring, #f3d98b)",
169
+ hlBorder: "var(--crk-timeline-hl-border, #e8b931)",
170
+ hlBarBg: "var(--crk-timeline-hl-bar, #ffe9ae)",
171
+ selectedRing: "var(--crk-timeline-selected-ring, #b8ddd6)"
172
+ };
173
+ export {
174
+ S as DAY,
175
+ N as HOUR,
176
+ U as MINUTE,
177
+ O as SECOND,
178
+ l as TICK_STEPS,
179
+ H as TIMELINE_PALETTE_VARS,
180
+ m as TL_COLORS,
181
+ k as eventMatches,
182
+ u as fmtClock,
183
+ Y as fmtClockUTC,
184
+ s as fmtDate,
185
+ h as fmtDateISO,
186
+ C as fmtDateTime,
187
+ d as fmtDur,
188
+ M as fmtISO,
189
+ I as highlightParts,
190
+ g as tickSubdiv,
191
+ T as ticks,
192
+ R as tint
193
+ };