@sentinel-nvr/web 0.10.0 → 0.11.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/dist/ui/index.js CHANGED
@@ -1,3 +1,7 @@
1
+ import {
2
+ PlayerController,
3
+ rlog
4
+ } from "../chunk-MAUN6MNY.js";
1
5
  import {
2
6
  SENTINEL_DAY_MS,
3
7
  SENTINEL_EVENT_CLASSES,
@@ -20,11 +24,7 @@ import {
20
24
  sentinelWallMarks,
21
25
  sentinelWallSeconds,
22
26
  weekdayShorts
23
- } from "../chunk-MS6D4OUE.js";
24
- import {
25
- PlayerController,
26
- rlog
27
- } from "../chunk-Z22KWFHI.js";
27
+ } from "../chunk-LN4VXI2V.js";
28
28
 
29
29
  // src/ui/context.tsx
30
30
  import { createContext, useContext } from "react";
@@ -681,7 +681,10 @@ function Hero({ cameras, stats }) {
681
681
  return /* @__PURE__ */ jsxs5("div", { className: "nvr-card nvr-hero", children: [
682
682
  /* @__PURE__ */ jsxs5("div", { className: "nvr-hero__head", children: [
683
683
  /* @__PURE__ */ jsx7(CardTitle, { icon: /* @__PURE__ */ jsx7(Gauge, { size: 16, strokeWidth: 1.75 }), title: t("nvr.hero.title"), sub: t("nvr.hero.sub") }),
684
- /* @__PURE__ */ jsxs5("span", { className: `nvr-pill ${offline > 0 ? "nvr-pill--danger" : "nvr-pill--positive"}`, children: [
684
+ stats.storageOk === false ? /* @__PURE__ */ jsxs5("span", { className: "nvr-pill nvr-pill--danger", title: stats.storageProblem, children: [
685
+ /* @__PURE__ */ jsx7("span", { className: "nvr-pill__dot", "aria-hidden": "true" }),
686
+ t("nvr.hero.storageProblem")
687
+ ] }) : /* @__PURE__ */ jsxs5("span", { className: `nvr-pill ${offline > 0 ? "nvr-pill--danger" : "nvr-pill--positive"}`, children: [
685
688
  /* @__PURE__ */ jsx7("span", { className: "nvr-pill__dot", "aria-hidden": "true" }),
686
689
  offline > 0 ? t("nvr.hero.offline", { count: offline }) : t("nvr.hero.allOnline")
687
690
  ] })
@@ -886,26 +889,29 @@ function VerticalTimeline(p) {
886
889
  document.removeEventListener("touchcancel", off);
887
890
  };
888
891
  }, []);
889
- useEffect2(() => {
890
- const t2 = setInterval(() => {
891
- const v = VT.current;
892
- if (!v.user) {
893
- const ts = p.live ? Date.now() : p.following() ? p.playhead() : null;
894
- if (ts != null) {
895
- const cur = centerTs();
896
- const d = ts - cur;
897
- if (Math.abs(d) > 3e3 && Math.abs(d * px) > 1.5 && Date.now() - v.lastJumpLog > 1e3) {
898
- v.lastJumpLog = Date.now();
899
- rlog("follow-jump", { dSec: Math.round(d / 100) / 10, live: p.live, sinceIdle: v.idleAt ? Date.now() - v.idleAt : -1, px: Math.round(px * 1e6) / 1e6 });
900
- }
901
- scrollCenter(ts);
892
+ const followTick = () => {
893
+ const v = VT.current;
894
+ if (!v.user) {
895
+ const ts = p.live ? Date.now() : p.following() ? p.playhead() : null;
896
+ if (ts != null) {
897
+ const cur = centerTs();
898
+ const d = ts - cur;
899
+ if (Math.abs(d) > 3e3 && Math.abs(d * px) > 1.5 && Date.now() - v.lastJumpLog > 1e3) {
900
+ v.lastJumpLog = Date.now();
901
+ rlog("follow-jump", { dSec: Math.round(d / 100) / 10, live: p.live, sinceIdle: v.idleAt ? Date.now() - v.idleAt : -1, px: Math.round(px * 1e6) / 1e6 });
902
902
  }
903
+ scrollCenter(ts);
903
904
  }
904
- notifyCenter();
905
- tick((n) => n + 1);
906
- }, 100);
905
+ }
906
+ notifyCenter();
907
+ tick((n) => n + 1);
908
+ };
909
+ const followRef = useRef(followTick);
910
+ followRef.current = followTick;
911
+ useEffect2(() => {
912
+ const t2 = setInterval(() => followRef.current(), 100);
907
913
  return () => clearInterval(t2);
908
- });
914
+ }, []);
909
915
  const notifyCenter = () => {
910
916
  const v = VT.current;
911
917
  if (Date.now() - v.lastCenterCb < 400) return;
@@ -948,12 +954,15 @@ function VerticalTimeline(p) {
948
954
  clearTimeout(v.relT);
949
955
  v.relT = window.setTimeout(userIdle, 250);
950
956
  };
957
+ const releaseRef = useRef(release);
958
+ releaseRef.current = release;
951
959
  useEffect2(() => {
952
- for (const n of ["pointerup", "pointercancel", "touchend"]) window.addEventListener(n, release);
960
+ const h = () => releaseRef.current();
961
+ for (const n of ["pointerup", "pointercancel", "touchend"]) window.addEventListener(n, h);
953
962
  return () => {
954
- for (const n of ["pointerup", "pointercancel", "touchend"]) window.removeEventListener(n, release);
963
+ for (const n of ["pointerup", "pointercancel", "touchend"]) window.removeEventListener(n, h);
955
964
  };
956
- });
965
+ }, []);
957
966
  const onScroll = () => {
958
967
  const v = VT.current;
959
968
  const el = scroll.current;
@@ -992,21 +1001,25 @@ function VerticalTimeline(p) {
992
1001
  if (!v.down) userIdle();
993
1002
  }, 700);
994
1003
  };
1004
+ const onWheel = (e) => {
1005
+ const el = scroll.current;
1006
+ if (!e.ctrlKey) {
1007
+ markUser();
1008
+ return;
1009
+ }
1010
+ e.preventDefault();
1011
+ const r = el.getBoundingClientRect();
1012
+ const y = e.clientY - r.top;
1013
+ applyZoom(px * Math.exp(-e.deltaY * 2e-3), tsForY(el.scrollTop + y), y);
1014
+ };
1015
+ const wheelRef = useRef(onWheel);
1016
+ wheelRef.current = onWheel;
995
1017
  useEffect2(() => {
996
1018
  const el = scroll.current;
997
- const onWheel = (e) => {
998
- if (!e.ctrlKey) {
999
- markUser();
1000
- return;
1001
- }
1002
- e.preventDefault();
1003
- const r = el.getBoundingClientRect();
1004
- const y = e.clientY - r.top;
1005
- applyZoom(px * Math.exp(-e.deltaY * 2e-3), tsForY(el.scrollTop + y), y);
1006
- };
1007
- el.addEventListener("wheel", onWheel, { passive: false });
1008
- return () => el.removeEventListener("wheel", onWheel);
1009
- });
1019
+ const h = (e) => wheelRef.current(e);
1020
+ el.addEventListener("wheel", h, { passive: false });
1021
+ return () => el.removeEventListener("wheel", h);
1022
+ }, []);
1010
1023
  const applyZoom = (npx, anchor, anchorY) => {
1011
1024
  const c = clamp(npx, minPx, maxPx);
1012
1025
  setPx(c);
@@ -1105,11 +1118,22 @@ function dateChipNav(centerDay, oldestAllowed, today = sentinelDayOf(Date.now())
1105
1118
  return { prevDisabled: sentinelAddDays(centerDay, -1) < oldestAllowed, nextDisabled: centerDay >= today };
1106
1119
  }
1107
1120
  function stageStatus(ps, t, locale, loadError = false, now = Date.now()) {
1108
- const label = loadError ? t("nvr.error.loadFailed") : ps.label ? t(`nvr.player.${ps.label}`) : "";
1121
+ let label = loadError ? t("nvr.error.loadFailed") : ps.label ? t(`nvr.player.${ps.label}`) : "";
1122
+ if (!ps.live && !loadError && label && (ps.transport === "mse" || ps.transport === "native")) label += ` (${t("nvr.player.fallbackMode")})`;
1109
1123
  if (ps.live || ps.playhead == null) return label;
1110
1124
  const day = sentinelDayOf(ps.playhead) === sentinelDayOf(now) ? "" : fmtDay(ps.playhead, locale) + " ";
1111
1125
  return `${label} \xB7 ${day}${fmtTimeSec(ps.playhead, locale)}`;
1112
1126
  }
1127
+ function shouldHandleKey(e) {
1128
+ if (e.defaultPrevented || e.ctrlKey || e.metaKey || e.altKey) return false;
1129
+ const el = e.target;
1130
+ if (!el || typeof el !== "object") return true;
1131
+ if (el.isContentEditable) return false;
1132
+ const tag = (el.tagName || "").toLowerCase();
1133
+ if (tag === "input" || tag === "select" || tag === "textarea") return false;
1134
+ if (e.key === " " && (tag === "button" || tag === "a" || tag === "summary" || el.getAttribute?.("role") === "button")) return false;
1135
+ return true;
1136
+ }
1113
1137
 
1114
1138
  // src/ui/components/CameraPage.tsx
1115
1139
  import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
@@ -1154,6 +1178,7 @@ function CameraPage(p) {
1154
1178
  daysRef.current = days;
1155
1179
  const camRef = useRef2(camId);
1156
1180
  camRef.current = camId;
1181
+ const deepRef = useRef2("");
1157
1182
  const merged = useMemo2(() => {
1158
1183
  const m = sentinelMergeDays(days);
1159
1184
  const rangeStart = m.oldestDay ?? todayStart();
@@ -1250,7 +1275,17 @@ function CameraPage(p) {
1250
1275
  setJump({ ts: startAt, n: Date.now() });
1251
1276
  } else c.goLive();
1252
1277
  }).catch(() => setLoadError(true));
1278
+ deepRef.current = `${camId}|${startAt}`;
1253
1279
  }, [camId, client]);
1280
+ useEffect3(() => {
1281
+ const key = `${camId}|${startAt}`;
1282
+ if (!startAt || !ctl.current || key === deepRef.current) return;
1283
+ deepRef.current = key;
1284
+ const c = ctl.current;
1285
+ c.freezeCurrent();
1286
+ c.posterEvent(posterTs || startAt);
1287
+ goToDay(sentinelDayOf(startAt), startAt).catch(() => setLoadError(true));
1288
+ }, [startAt, posterTs]);
1254
1289
  useEffect3(() => {
1255
1290
  if (ctl.current && name) ctl.current.camName = name;
1256
1291
  }, [name]);
@@ -1331,9 +1366,7 @@ function CameraPage(p) {
1331
1366
  }), []);
1332
1367
  useEffect3(() => {
1333
1368
  const k = (e) => {
1334
- if (dt) return;
1335
- const tag = (e.target?.tagName || "").toLowerCase();
1336
- if (tag === "input" || tag === "select" || tag === "textarea") return;
1369
+ if (dt || !shouldHandleKey(e)) return;
1337
1370
  const c = ctl.current;
1338
1371
  if (!c) return;
1339
1372
  if (e.key === " ") {
@@ -1589,4 +1622,5 @@ export {
1589
1622
  useSentinelUi,
1590
1623
  watchSystemMode
1591
1624
  };
1625
+ /*! Theme tokens derived from HAPulse (https://github.com/jlnbln/HAPulse) — MIT License, Copyright (c) 2026 Julian */
1592
1626
  //# sourceMappingURL=index.js.map