@sentinel-nvr/web 0.15.0 → 0.16.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.
@@ -1,4 +1,4 @@
1
- import { g as SentinelClip, f as SentinelClient } from './client-au18O0ne.js';
1
+ import { h as SentinelClip, g as SentinelClient } from './client-DS5wDfMN.js';
2
2
 
3
3
  /**
4
4
  * PlayerController — the whole playback brain of the NVR. Framework-free: it owns
@@ -104,6 +104,9 @@ declare class PlayerController {
104
104
  private rwLastTargetAt;
105
105
  private cmdSeq;
106
106
  private seekAt;
107
+ /** the last relay-pos answers as they came (picture position, server rate, the answer before in the same command
108
+ * generation) — the end of a scrub gesture waits for the picture to play at 1× at the target (settle.ts) */
109
+ private rwPoll;
107
110
  private w;
108
111
  private L;
109
112
  private M;
@@ -269,8 +272,9 @@ declare class PlayerController {
269
272
  fullscreen(): void;
270
273
  /** first gesture: scrub profile on (relay); MSE: freeze + pause */
271
274
  scrubBegin(): void;
272
- /** true between the end of a gesture and the profile switch back (SCRUB_OFF_DELAY_MS): the timeline must not auto-follow
273
- * the playhead in that window — the servo is still converging on the centre the user left */
275
+ /** true between the end of a gesture and the profile switch back (SCRUB_OFF_DELAY_MS, on the relay until the picture has
276
+ * reached the target): the timeline must not auto-follow the playhead in that window — the servo is still converging on
277
+ * the centre the user left, and the timeline stays parked there */
274
278
  scrubSettling(): boolean;
275
279
  /** scroll position while the gesture runs: the centre becomes the server's steering target (velocity unused since 0.7.0) */
276
280
  scrubMove(centerTs: number, _vel: number, _smoothTs: number): void;
@@ -279,7 +283,9 @@ declare class PlayerController {
279
283
  scrubSeek(ts: number, srate?: number): void;
280
284
  /** brief hold mid-gesture: nothing to do on the relay (the target already stands), MSE: preview seek */
281
285
  scrubHold(ts: number): void;
282
- /** gesture settled → final target, then back to the normal profile after SCRUB_OFF_DELAY_MS of quiet (a new gesture cancels it) */
286
+ /** gesture settled → final target, then back to the normal profile after SCRUB_OFF_DELAY_MS of quiet (a new gesture cancels
287
+ * it). A steered relay gesture keeps its target until the picture has arrived (settle.ts): the server steers on in the
288
+ * scrub profile and scrubSettling() keeps the timeline parked on the centre the user left. */
283
289
  scrubIdle(ts?: number): void;
284
290
  private hiddenTs;
285
291
  private onVisibility;
@@ -1,5 +1,5 @@
1
- export { P as PipResult, a as PlayerController, b as PlayerLabel, c as PlayerOptions, d as PlayerRefs, e as PlayerState } from '../controller-By7Ieyp2.js';
2
- import { f as SentinelClient } from '../client-au18O0ne.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
+ 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
5
5
  * recording to land on yet. */
@@ -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-4RUVCMQ6.js";
10
- import "../chunk-7EXBV2ZE.js";
17
+ } from "../chunk-JRYP7MG6.js";
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
- import { f as SentinelClient, k as SentinelEventClass, m as SentinelRecentEvent, e as SentinelCamera, i as SentinelEvent, p as SentinelStats, g as SentinelClip } from '../client-au18O0ne.js';
4
- import { e as PlayerState } from '../controller-By7Ieyp2.js';
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-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-4RUVCMQ6.js";
4
+ } from "../chunk-JRYP7MG6.js";
5
5
  import {
6
6
  SENTINEL_DAY_MS,
7
7
  SENTINEL_EVENT_CLASSES,
@@ -17,15 +17,17 @@ import {
17
17
  sentinelClipRuns,
18
18
  sentinelDayEnd,
19
19
  sentinelDayOf,
20
+ sentinelDuration,
20
21
  sentinelEventHidden,
21
22
  sentinelEventPlayTs,
23
+ sentinelEventSpan,
22
24
  sentinelHumanBytes,
23
25
  sentinelMergeDays,
24
26
  sentinelStorageForecast,
25
27
  sentinelWallMarks,
26
28
  sentinelWallSeconds,
27
29
  weekdayShorts
28
- } from "../chunk-7EXBV2ZE.js";
30
+ } from "../chunk-Y4WFO6G3.js";
29
31
 
30
32
  // src/ui/context.tsx
31
33
  import { createContext, useContext } from "react";
@@ -602,7 +604,7 @@ function outsideAppHref(url, env = {
602
604
 
603
605
  // src/ui/components/EventList.tsx
604
606
  import { Fragment as Fragment2 } from "react";
605
- import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
607
+ import { Fragment as Fragment3, jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
606
608
  function EventList({
607
609
  camId,
608
610
  events,
@@ -627,17 +629,31 @@ function EventList({
627
629
  " ",
628
630
  eventLabel(t, ev)
629
631
  ] }),
630
- /* @__PURE__ */ jsx5("span", { className: "nvr-evrow__t nvr-data", children: fmtTimeSec(ev.timestamp, locale) })
632
+ /* @__PURE__ */ jsxs3("span", { className: "nvr-evrow__t nvr-data", children: [
633
+ fmtTimeSec(ev.timestamp, locale),
634
+ /* @__PURE__ */ jsx5(EventSpanNote, { ev, t })
635
+ ] })
631
636
  ] })
632
637
  ] })
633
638
  ] }, ev.id);
634
639
  }) });
635
640
  }
641
+ function EventSpanNote({ ev, t }) {
642
+ const sp = sentinelEventSpan(ev);
643
+ if (!sp) return null;
644
+ return sp.open ? /* @__PURE__ */ jsxs3("span", { className: "nvr-evrow__open", children: [
645
+ " \xB7 ",
646
+ t("nvr.events.running")
647
+ ] }) : /* @__PURE__ */ jsxs3(Fragment3, { children: [
648
+ " \xB7 ",
649
+ sentinelDuration(sp.end - sp.start)
650
+ ] });
651
+ }
636
652
 
637
653
  // src/ui/components/DatePickerPanel.tsx
638
654
  import { useState as useState2 } from "react";
639
655
  import { ChevronLeft, ChevronRight } from "lucide-react";
640
- import { Fragment as Fragment3, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
656
+ import { Fragment as Fragment4, jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
641
657
  function useDatePicker({ dayStart, timeTs, oldestAllowed = -Infinity, onGo }) {
642
658
  const { t, locale } = useSentinelUi();
643
659
  const base = new Date(dayStart);
@@ -668,7 +684,7 @@ function useDatePicker({ dayStart, timeTs, oldestAllowed = -Infinity, onGo }) {
668
684
  setView(new Date(n.getFullYear(), n.getMonth(), 1));
669
685
  setSel(new Date(n.getFullYear(), n.getMonth(), n.getDate()));
670
686
  };
671
- const grid = /* @__PURE__ */ jsxs4(Fragment3, { children: [
687
+ const grid = /* @__PURE__ */ jsxs4(Fragment4, { children: [
672
688
  /* @__PURE__ */ jsxs4("div", { className: "nvr-dt__head", children: [
673
689
  /* @__PURE__ */ jsx6(
674
690
  "button",
@@ -975,9 +991,9 @@ function StorageCard({ stats }) {
975
991
  }
976
992
 
977
993
  // src/ui/components/VerticalTimeline.tsx
978
- import { useEffect as useEffect2, useMemo, useRef, useState as useState3 } from "react";
994
+ import { useEffect as useEffect2, useLayoutEffect, useMemo, useRef, useState as useState3 } from "react";
979
995
  import { Plus, Minus, ArrowUp } from "lucide-react";
980
- import { Fragment as Fragment4, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
996
+ import { Fragment as Fragment5, jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
981
997
  function VerticalTimeline(p) {
982
998
  const { client, t, locale } = useSentinelUi();
983
999
  const hhmm = (ts) => fmtTime(ts, locale), hhmmss = (ts) => fmtTimeSec(ts, locale), dayLbl = (ts) => fmtDay(ts, locale);
@@ -1020,8 +1036,15 @@ function VerticalTimeline(p) {
1020
1036
  const span = p.rangeEnd - p.rangeStart;
1021
1037
  const yFor = (ts) => PAD + (p.rangeEnd - ts) * px;
1022
1038
  const tsForY = (y) => p.rangeEnd - (y - PAD) / px;
1023
- const centerTs = () => tsForY((scroll.current?.scrollTop || 0) + vh * HEAD);
1039
+ const geo = useRef({ rangeStart: p.rangeStart, rangeEnd: p.rangeEnd, px, vh, PAD });
1040
+ geo.current = { rangeStart: p.rangeStart, rangeEnd: p.rangeEnd, px, vh, PAD };
1041
+ const centerTs = () => {
1042
+ const g = geo.current;
1043
+ if (!(g.px > 0)) return Math.min(Date.now(), g.rangeEnd - 1);
1044
+ return g.rangeEnd - ((scroll.current?.scrollTop || 0) + g.vh * HEAD - g.PAD) / g.px;
1045
+ };
1024
1046
  const clamp = (v, a, b) => Math.min(b, Math.max(a, v));
1047
+ const clampRange = (ts) => clamp(ts, geo.current.rangeStart, geo.current.rangeEnd - 1);
1025
1048
  const setTop = (el, top2, why) => {
1026
1049
  const v = VT.current;
1027
1050
  v.selfAt = Date.now();
@@ -1058,11 +1081,14 @@ function VerticalTimeline(p) {
1058
1081
  scrollCenter(Date.now());
1059
1082
  }, [px]);
1060
1083
  const prevEnd = useRef(p.rangeEnd);
1061
- useEffect2(() => {
1084
+ useLayoutEffect(() => {
1062
1085
  const d = p.rangeEnd - prevEnd.current;
1063
1086
  prevEnd.current = p.rangeEnd;
1064
1087
  const el = scroll.current;
1065
- if (d && el && px) setTop(el, el.scrollTop + d * px, "range");
1088
+ if (d && el && px) {
1089
+ setTop(el, el.scrollTop + d * px, "range");
1090
+ tick((n) => n + 1);
1091
+ }
1066
1092
  }, [p.rangeEnd, px]);
1067
1093
  useEffect2(() => {
1068
1094
  if (p.jump && px) scrollCenter(p.jump.ts, "jump");
@@ -1115,22 +1141,22 @@ function VerticalTimeline(p) {
1115
1141
  const v = VT.current;
1116
1142
  if (Date.now() - v.lastCenterCb < 400) return;
1117
1143
  v.lastCenterCb = Date.now();
1118
- p.onCenter(clamp(centerTs(), p.rangeStart, p.rangeEnd - 1));
1144
+ p.onCenter(clampRange(centerTs()));
1119
1145
  };
1120
1146
  const scrubSeek = (ts) => {
1121
1147
  const v = VT.current;
1122
1148
  v.previewing = true;
1123
- p.scrub.seek(clamp(ts ?? centerTs(), p.rangeStart, p.rangeEnd - 1));
1149
+ p.scrub.seek(clampRange(ts ?? centerTs()));
1124
1150
  };
1125
1151
  const userIdle = () => {
1126
1152
  VT.current.user = 0;
1127
1153
  VT.current.idleAt = Date.now();
1128
- p.scrub.idle(clamp(centerTs(), p.rangeStart, p.rangeEnd - 1));
1154
+ p.scrub.idle(clampRange(centerTs()));
1129
1155
  };
1130
1156
  const scrubHold = () => {
1131
1157
  const v = VT.current;
1132
1158
  v.previewing = true;
1133
- p.scrub.hold(clamp(centerTs(), p.rangeStart, p.rangeEnd - 1));
1159
+ p.scrub.hold(clampRange(centerTs()));
1134
1160
  };
1135
1161
  const markUser = () => {
1136
1162
  const v = VT.current;
@@ -1293,7 +1319,19 @@ function VerticalTimeline(p) {
1293
1319
  const k = sentinelClassOf(ev);
1294
1320
  const thumb = y - lastThumbY >= thumbGap && px > vh / (8 * 3600 * 1e3);
1295
1321
  if (thumb) lastThumbY = y;
1322
+ const sp = sentinelEventSpan(ev, now);
1296
1323
  return /* @__PURE__ */ jsxs6("div", { children: [
1324
+ sp && /* @__PURE__ */ jsx8(
1325
+ "div",
1326
+ {
1327
+ className: "vspan" + (sp.open ? " vspan--open" : ""),
1328
+ style: {
1329
+ top: yFor(sp.end),
1330
+ height: Math.max(3, (sp.end - sp.start) * px),
1331
+ background: `var(--nvr-c-${k})`
1332
+ }
1333
+ }
1334
+ ),
1297
1335
  /* @__PURE__ */ jsx8(
1298
1336
  "button",
1299
1337
  {
@@ -1304,7 +1342,7 @@ function VerticalTimeline(p) {
1304
1342
  title: hhmmss(sentinelEventPlayTs(ev))
1305
1343
  }
1306
1344
  ),
1307
- thumb && /* @__PURE__ */ jsxs6(Fragment4, { children: [
1345
+ thumb && /* @__PURE__ */ jsxs6(Fragment5, { children: [
1308
1346
  /* @__PURE__ */ jsxs6("div", { className: "vlink", style: { top: y }, children: [
1309
1347
  /* @__PURE__ */ jsx8("span", { className: "vlink-badges", children: /* @__PURE__ */ jsx8(EventBadges, { ev, t }) }),
1310
1348
  /* @__PURE__ */ jsx8("i", {})
@@ -1316,7 +1354,7 @@ function VerticalTimeline(p) {
1316
1354
  ] })
1317
1355
  ] }, ev.id);
1318
1356
  }),
1319
- inWin(now) && /* @__PURE__ */ jsxs6(Fragment4, { children: [
1357
+ inWin(now) && /* @__PURE__ */ jsxs6(Fragment5, { children: [
1320
1358
  /* @__PURE__ */ jsx8("div", { className: "vlive-line", style: { top: yFor(now) } }),
1321
1359
  /* @__PURE__ */ jsx8("button", { className: "vlive-chip", style: { top: yFor(now) }, onClick: p.onGoLive, children: t("nvr.live") })
1322
1360
  ] })