@sentinel-nvr/web 0.16.0 → 0.16.2

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.
@@ -1,4 +1,4 @@
1
- export { P as PipResult, a as PlayerController, b as PlayerLabel, c as PlayerOptions, d as PlayerRefs, e as PlayerState } from '../controller-BJvKiDMZ.js';
1
+ export { P as PipResult, a as PlayerController, b as PlayerLabel, c as PlayerOptions, d as PlayerRefs, e as PlayerState } from '../controller-D8rAubW4.js';
2
2
  import { g as SentinelClient } from '../client-DS5wDfMN.js';
3
3
 
4
4
  /** Recorded playback runs ~17 s behind real time (fragment flush + relay); a forward jump closer to "now" than this has no
@@ -10,6 +10,39 @@ declare const SKIP_LIVE_EDGE_MS = 20000;
10
10
  */
11
11
  declare function skipTarget(live: boolean, currentTs: number | null | undefined, ms: number, now: number): number | 'live' | null;
12
12
 
13
+ /** "At the target": the servo stops within ±1.5 s of it (SERVO_DONE_MS), leaving key mode re-enters the nearest keyframe
14
+ * (± half a 4-s GOP), then it plays on at 1× until two polls have shown that. */
15
+ declare const SETTLE_NEAR_MS = 5000;
16
+ /** "Normal speed" between the last two polls (poll jitter, keyframe re-entry). */
17
+ declare const SETTLE_V_MIN = 0.5;
18
+ declare const SETTLE_V_MAX = 2;
19
+ /** Give up when the distance has not shrunk by SETTLE_PROGRESS_MS for this long (no footage at the target, polls stuck,
20
+ * server lost the target). */
21
+ declare const SETTLE_STALL_MS = 3000;
22
+ declare const SETTLE_PROGRESS_MS = 1000;
23
+ /** Hard cap, however slowly the picture still approaches. */
24
+ declare const SETTLE_CAP_MS = 30000;
25
+ interface SettleTrack {
26
+ t0: number;
27
+ best: number;
28
+ bestAt: number;
29
+ }
30
+ /** One relay-pos poll: picture on screen, when it was received, the server's current rate (null = not reported), and the
31
+ * poll before it (same command generation) for the speed. */
32
+ interface SettleSample {
33
+ pos: number;
34
+ at: number;
35
+ r: number | null;
36
+ prev: {
37
+ pos: number;
38
+ at: number;
39
+ } | null;
40
+ }
41
+ type SettleState = 'arrived' | 'wait' | 'giveup';
42
+ declare function settleStart(pos: number, target: number, now: number): SettleTrack;
43
+ /** One check against the gesture's final target. Updates `s`. */
44
+ declare function settleStep(s: SettleTrack, x: SettleSample, target: number, now: number): SettleState;
45
+
13
46
  /**
14
47
  * WebRTC session over the plugin's WebSocket signaling (docs/API.md §6).
15
48
  * Battle-tested flow: options first, createLocalDescription/setRemoteDescription
@@ -64,4 +97,4 @@ declare class WebRtcSession {
64
97
  declare function setRlogClient(c: SentinelClient | null, b?: string): void;
65
98
  declare function rlog(tag: string, data?: Record<string, unknown>): void;
66
99
 
67
- export { SKIP_LIVE_EDGE_MS, type SessionCallbacks, type SessionOptions, WebRtcSession, mobileClient, rlog, setRlogClient, skipTarget };
100
+ export { SETTLE_CAP_MS, SETTLE_NEAR_MS, SETTLE_PROGRESS_MS, SETTLE_STALL_MS, SETTLE_V_MAX, SETTLE_V_MIN, SKIP_LIVE_EDGE_MS, type SessionCallbacks, type SessionOptions, type SettleSample, type SettleState, type SettleTrack, WebRtcSession, mobileClient, rlog, setRlogClient, settleStart, settleStep, skipTarget };
@@ -1,20 +1,36 @@
1
1
  import {
2
2
  PlayerController,
3
+ SETTLE_CAP_MS,
4
+ SETTLE_NEAR_MS,
5
+ SETTLE_PROGRESS_MS,
6
+ SETTLE_STALL_MS,
7
+ SETTLE_V_MAX,
8
+ SETTLE_V_MIN,
3
9
  SKIP_LIVE_EDGE_MS,
4
10
  WebRtcSession,
5
11
  mobileClient,
6
12
  rlog,
7
13
  setRlogClient,
14
+ settleStart,
15
+ settleStep,
8
16
  skipTarget
9
- } from "../chunk-XOLSBEY5.js";
17
+ } from "../chunk-JRYP7MG6.js";
10
18
  import "../chunk-Y4WFO6G3.js";
11
19
  export {
12
20
  PlayerController,
21
+ SETTLE_CAP_MS,
22
+ SETTLE_NEAR_MS,
23
+ SETTLE_PROGRESS_MS,
24
+ SETTLE_STALL_MS,
25
+ SETTLE_V_MAX,
26
+ SETTLE_V_MIN,
13
27
  SKIP_LIVE_EDGE_MS,
14
28
  WebRtcSession,
15
29
  mobileClient,
16
30
  rlog,
17
31
  setRlogClient,
32
+ settleStart,
33
+ settleStep,
18
34
  skipTarget
19
35
  };
20
36
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  import * as react from 'react';
2
2
  import { ReactNode } from 'react';
3
3
  import { g as SentinelClient, l as SentinelEventClass, n as SentinelRecentEvent, f as SentinelCamera, j as SentinelEvent, q as SentinelStats, h as SentinelClip } from '../client-DS5wDfMN.js';
4
- import { e as PlayerState } from '../controller-BJvKiDMZ.js';
4
+ import { e as PlayerState } from '../controller-D8rAubW4.js';
5
5
 
6
6
  /**
7
7
  * Minimal translation core with the same dictionary semantics as HAPulse:
@@ -267,7 +267,8 @@ interface ScrubHandlers {
267
267
  * drift becomes a seek — every seek shows ~2.4 s of stale stream before the new picture, so step-wise wheel scrolling
268
268
  * with a seek per step made the picture run back and forth (user 23.09.) */
269
269
  hold: (centerTs: number) => void;
270
- /** gesture settled → back to auto-follow; the player lands exactly on centerTs if it drifted */
270
+ /** gesture settled (700 ms quiet): centerTs is the final target; auto-follow resumes once `following()` is true again —
271
+ * on the relay only when the picture plays at the target (PlayerController.scrubSettling) */
271
272
  idle: (centerTs: number) => void;
272
273
  }
273
274
  interface TimelineProps {
@@ -298,9 +299,9 @@ interface TimelineProps {
298
299
  * FIXED centre line is the playhead; the content scrolls natively and simply
299
300
  * continues across midnight (day separators in the axis). Recording band,
300
301
  * motion stretches, class-coloured event markers with thumbnails, LIVE line.
301
- * Scrolling = scrub time-lapse (server-side rate from the scroll velocity): a
302
- * brief hold preview-seeks, the release lands on the centre at 1×, 700 ms of
303
- * silence hands control back to auto-follow. Only the visible window is
302
+ * Scrolling = scrub time-lapse (the server steers onto the centre): 700 ms of
303
+ * silence end the gesture, and the view stays parked on the centre until the
304
+ * picture plays there at 1× (then auto-follow). Only the visible window is
304
305
  * rendered (a fortnight of markers would otherwise be thousands of nodes).
305
306
  */
306
307
  declare function VerticalTimeline(p: TimelineProps): react.JSX.Element;
package/dist/ui/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PlayerController,
3
3
  rlog
4
- } from "../chunk-XOLSBEY5.js";
4
+ } from "../chunk-JRYP7MG6.js";
5
5
  import {
6
6
  SENTINEL_DAY_MS,
7
7
  SENTINEL_EVENT_CLASSES,
@@ -991,7 +991,7 @@ function StorageCard({ stats }) {
991
991
  }
992
992
 
993
993
  // src/ui/components/VerticalTimeline.tsx
994
- import { useEffect as useEffect2, useMemo, useRef, useState as useState3 } from "react";
994
+ import { useEffect as useEffect2, useLayoutEffect, useMemo, useRef, useState as useState3 } from "react";
995
995
  import { Plus, Minus, ArrowUp } from "lucide-react";
996
996
  import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
997
997
  function VerticalTimeline(p) {
@@ -1036,8 +1036,16 @@ function VerticalTimeline(p) {
1036
1036
  const span = p.rangeEnd - p.rangeStart;
1037
1037
  const yFor = (ts) => PAD + (p.rangeEnd - ts) * px;
1038
1038
  const tsForY = (y) => p.rangeEnd - (y - PAD) / px;
1039
- const centerTs = () => tsForY((scroll.current?.scrollTop || 0) + vh * HEAD);
1039
+ const zoomAnchor = useRef(null);
1040
+ const geo = useRef({ rangeStart: p.rangeStart, rangeEnd: p.rangeEnd, px, vh, PAD });
1041
+ geo.current = { rangeStart: p.rangeStart, rangeEnd: p.rangeEnd, px, vh, PAD };
1042
+ const centerTs = () => {
1043
+ const g = geo.current;
1044
+ if (!(g.px > 0)) return Math.min(Date.now(), g.rangeEnd - 1);
1045
+ return g.rangeEnd - ((scroll.current?.scrollTop || 0) + g.vh * HEAD - g.PAD) / g.px;
1046
+ };
1040
1047
  const clamp = (v, a, b) => Math.min(b, Math.max(a, v));
1048
+ const clampRange = (ts) => clamp(ts, geo.current.rangeStart, geo.current.rangeEnd - 1);
1041
1049
  const setTop = (el, top2, why) => {
1042
1050
  const v = VT.current;
1043
1051
  v.selfAt = Date.now();
@@ -1074,12 +1082,24 @@ function VerticalTimeline(p) {
1074
1082
  scrollCenter(Date.now());
1075
1083
  }, [px]);
1076
1084
  const prevEnd = useRef(p.rangeEnd);
1077
- useEffect2(() => {
1085
+ useLayoutEffect(() => {
1078
1086
  const d = p.rangeEnd - prevEnd.current;
1079
1087
  prevEnd.current = p.rangeEnd;
1080
1088
  const el = scroll.current;
1081
- if (d && el && px) setTop(el, el.scrollTop + d * px, "range");
1089
+ if (d && el && px) {
1090
+ setTop(el, el.scrollTop + d * px, "range");
1091
+ tick((n) => n + 1);
1092
+ }
1082
1093
  }, [p.rangeEnd, px]);
1094
+ useLayoutEffect(() => {
1095
+ const a = zoomAnchor.current;
1096
+ zoomAnchor.current = null;
1097
+ const el = scroll.current;
1098
+ if (a && el && px) {
1099
+ setTop(el, PAD + (p.rangeEnd - a.ts) * px - a.y, "zoom");
1100
+ tick((n) => n + 1);
1101
+ }
1102
+ }, [px]);
1083
1103
  useEffect2(() => {
1084
1104
  if (p.jump && px) scrollCenter(p.jump.ts, "jump");
1085
1105
  }, [p.jump?.n, px]);
@@ -1131,22 +1151,22 @@ function VerticalTimeline(p) {
1131
1151
  const v = VT.current;
1132
1152
  if (Date.now() - v.lastCenterCb < 400) return;
1133
1153
  v.lastCenterCb = Date.now();
1134
- p.onCenter(clamp(centerTs(), p.rangeStart, p.rangeEnd - 1));
1154
+ p.onCenter(clampRange(centerTs()));
1135
1155
  };
1136
1156
  const scrubSeek = (ts) => {
1137
1157
  const v = VT.current;
1138
1158
  v.previewing = true;
1139
- p.scrub.seek(clamp(ts ?? centerTs(), p.rangeStart, p.rangeEnd - 1));
1159
+ p.scrub.seek(clampRange(ts ?? centerTs()));
1140
1160
  };
1141
1161
  const userIdle = () => {
1142
1162
  VT.current.user = 0;
1143
1163
  VT.current.idleAt = Date.now();
1144
- p.scrub.idle(clamp(centerTs(), p.rangeStart, p.rangeEnd - 1));
1164
+ p.scrub.idle(clampRange(centerTs()));
1145
1165
  };
1146
1166
  const scrubHold = () => {
1147
1167
  const v = VT.current;
1148
1168
  v.previewing = true;
1149
- p.scrub.hold(clamp(centerTs(), p.rangeStart, p.rangeEnd - 1));
1169
+ p.scrub.hold(clampRange(centerTs()));
1150
1170
  };
1151
1171
  const markUser = () => {
1152
1172
  const v = VT.current;
@@ -1242,14 +1262,12 @@ function VerticalTimeline(p) {
1242
1262
  }, []);
1243
1263
  const applyZoom = (npx, anchor, anchorY) => {
1244
1264
  const c = clamp(npx, minPx, maxPx);
1265
+ if (c === px) return;
1266
+ zoomAnchor.current = { ts: anchor, y: anchorY };
1245
1267
  setPx(c);
1246
- requestAnimationFrame(() => {
1247
- const el = scroll.current;
1248
- if (el) setTop(el, PAD + (p.rangeEnd - anchor) * c - anchorY, "zoom");
1249
- });
1250
1268
  };
1251
1269
  const zoomStep = (f) => {
1252
- const a = p.live ? Date.now() : p.playhead() ?? centerTs();
1270
+ const a = p.live ? Date.now() : p.following() ? p.playhead() ?? centerTs() : centerTs();
1253
1271
  applyZoom(px * f, a, vh * HEAD);
1254
1272
  };
1255
1273
  const runs = useMemo(() => sentinelClipRuns(p.clips), [p.clips]);