@sentinel-nvr/web 0.9.0 → 0.10.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/README.md +24 -8
- package/dist/api/index.d.ts +1 -1
- package/dist/api/index.js +11 -1
- package/dist/{chunk-LADO3WMJ.js → chunk-MS6D4OUE.js} +74 -13
- package/dist/chunk-MS6D4OUE.js.map +1 -0
- package/dist/{client-Dtfs8TX2.d.ts → client-BEc4796_.d.ts} +31 -6
- package/dist/{controller-C01h-VeS.d.ts → controller-DUCnMIrR.d.ts} +1 -1
- package/dist/player/index.d.ts +2 -2
- package/dist/ui/index.d.ts +2 -2
- package/dist/ui/index.js +30 -28
- package/dist/ui/index.js.map +1 -1
- package/package.json +2 -1
- package/dist/chunk-LADO3WMJ.js.map +0 -1
package/README.md
CHANGED
|
@@ -15,10 +15,24 @@ One npm package, **`@sentinel-nvr/web`**, with subpath entry points (one version
|
|
|
15
15
|
|---|---|---|
|
|
16
16
|
| `@sentinel-nvr/web/api` | **available** | DOM-free data model + types mirroring the plugin's `docs/API.md`, URL/setup parsing, event classification, storage forecast, timeline clip-run merge, locale formatters, and a `fetch`/WebSocket `SentinelClient`. No framework deps. |
|
|
17
17
|
| `@sentinel-nvr/web/player` | **available** | `PlayerController`, WebRTC signaling, the no-reneg recorded-playback relay client, watchdog and the live/recorded fallback chain. |
|
|
18
|
-
| `@sentinel-nvr/web/ui` |
|
|
18
|
+
| `@sentinel-nvr/web/ui` | **available** | React components — the whole **camera page** (`CameraPage`: stage, control pill, info bar, tabs, class filters, vertical timeline, events list, date chip; `CameraTitle` header row), class badges, event strip, camera tiles, date picker, stat cards — the i18n dictionaries (`nvr.*`, 7 locales) and the theme system (4 identities × light/dark/auto + accent hue). Styles in `@sentinel-nvr/web/ui/ui.css` (HAPulse tokens). |
|
|
19
19
|
|
|
20
|
-
The
|
|
21
|
-
|
|
20
|
+
The earlier `@sentinel-nvr/api@0.1.0` is deprecated in favour of `@sentinel-nvr/web/api`.
|
|
21
|
+
|
|
22
|
+
### Server compatibility (recorded playback)
|
|
23
|
+
|
|
24
|
+
The player talks to the plugin's relay endpoints (`docs/API.md` in `sentinel-nvr`). Newer packages degrade gracefully
|
|
25
|
+
on older servers, but only get their full behaviour with the matching plugin:
|
|
26
|
+
|
|
27
|
+
| Package | Needs plugin from | Relay feature |
|
|
28
|
+
|---|---|---|
|
|
29
|
+
| 0.7.x | 2026-09-23 | scrub by target: `api/relay-target` (server-side servo stops at the timeline centre), `relay-pos` returns `{t, r}` |
|
|
30
|
+
| 0.8.x | 2026-09-24 | jumps with a still picture: `relay-seek&mark=1&avoid=W` answers `{w}`; the still is lifted on the first frame of that width (older servers: timer) |
|
|
31
|
+
| 0.9.x | 2026-09-25 | speed buttons in place: `api/relay-speed` (older servers: a seek to the displayed position); stills fade out two frames after the video runs |
|
|
32
|
+
| 0.10.x | any | calendar days instead of ±24 h (DST days are 23/25 h: no duplicate clips/events on 25.10., "next day" works, time picker and axis on the wall clock), `SentinelSetup.prefix` / `sentinelPublicBase(origin, prefix)` / `exchangeSentinelToken(…, prefix)` for a reverse-proxy path prefix. No server change needed. |
|
|
33
|
+
|
|
34
|
+
Lab note: headless Chromium reports an 800×600 screen unless `screenWidth/screenHeight` are emulated; the Scrypted
|
|
35
|
+
sink then transcodes every stream to 800 px / 15 fps, which distorts latency and resolution measurements.
|
|
22
36
|
|
|
23
37
|
The plugin's server code (`sentinel-nvr/src`) also imports `@sentinel-nvr/api`
|
|
24
38
|
for its API types, so server and both clients share one contract.
|
|
@@ -26,11 +40,13 @@ for its API types, so server and both clients share one contract.
|
|
|
26
40
|
## Design contracts (for `ui`)
|
|
27
41
|
|
|
28
42
|
- **Theming:** components read only `--*` CSS custom properties (HAPulse token
|
|
29
|
-
names).
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
43
|
+
names). `applyTheme(identity, mode, accentHue)` sets them on `<html>`; hosts that
|
|
44
|
+
already define the tokens (HAPulse) skip it. Fonts and radii are static host tokens.
|
|
45
|
+
- **i18n:** components take a `t(key, vars)` + `locale` via `SentinelUiProvider`. `ui`
|
|
46
|
+
ships the `nvr.*` dictionaries (`@sentinel-nvr/web/ui/locales/<code>.json`); hosts merge them.
|
|
47
|
+
- **Camera page:** hosts render `<CameraPage …/>` with `header` (their page header, e.g.
|
|
48
|
+
`<CameraTitle/>` + actions) and `renderDatePicker` (their modal around `useDatePicker`).
|
|
49
|
+
Everything visible inside comes from the package, so both consumers look identical.
|
|
34
50
|
|
|
35
51
|
## Develop
|
|
36
52
|
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as SENTINEL_DAY_MS, a as SENTINEL_ENDPOINT_PATH, b as SENTINEL_EVENT_CLASSES, c as SentinelBox, d as SentinelCamera, e as SentinelClient, f as SentinelClip, g as SentinelClipsResponse, h as SentinelEvent, i as SentinelEventBox, j as SentinelEventClass, k as SentinelHttpError, l as SentinelRecentEvent, m as SentinelRun, n as SentinelSetup, o as SentinelStats, p as SentinelStorageForecast, q as SentinelStorageStatus, r as exchangeSentinelToken, s as parseSentinelSetup, t as
|
|
1
|
+
export { S as SENTINEL_DAY_MS, a as SENTINEL_ENDPOINT_PATH, b as SENTINEL_EVENT_CLASSES, c as SentinelBox, d as SentinelCamera, e as SentinelClient, f as SentinelClip, g as SentinelClipsResponse, h as SentinelEvent, i as SentinelEventBox, j as SentinelEventClass, k as SentinelHttpError, l as SentinelRecentEvent, m as SentinelRun, n as SentinelSetup, o as SentinelStats, p as SentinelStorageForecast, q as SentinelStorageStatus, r as exchangeSentinelToken, s as parseSentinelSetup, t as sentinelAddDays, u as sentinelAtTime, v as sentinelClassOf, w as sentinelClassesOf, x as sentinelClipIndexFor, y as sentinelClipRuns, z as sentinelDayEnd, A as sentinelDayOf, B as sentinelEntryUrl, C as sentinelEventPlayTs, D as sentinelHumanBytes, E as sentinelLoginBase, F as sentinelMergeDays, G as sentinelPublicBase, H as sentinelStorageForecast, I as sentinelTimelineLink, J as sentinelUrl, K as sentinelWallMarks, L as sentinelWallSeconds } from '../client-BEc4796_.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Locale-aware, translation-free formatting (Intl only). Word-dependent helpers
|
package/dist/api/index.js
CHANGED
|
@@ -11,10 +11,13 @@ import {
|
|
|
11
11
|
fmtTimeSec,
|
|
12
12
|
hhmmInput,
|
|
13
13
|
parseSentinelSetup,
|
|
14
|
+
sentinelAddDays,
|
|
15
|
+
sentinelAtTime,
|
|
14
16
|
sentinelClassOf,
|
|
15
17
|
sentinelClassesOf,
|
|
16
18
|
sentinelClipIndexFor,
|
|
17
19
|
sentinelClipRuns,
|
|
20
|
+
sentinelDayEnd,
|
|
18
21
|
sentinelDayOf,
|
|
19
22
|
sentinelEntryUrl,
|
|
20
23
|
sentinelEventPlayTs,
|
|
@@ -25,8 +28,10 @@ import {
|
|
|
25
28
|
sentinelStorageForecast,
|
|
26
29
|
sentinelTimelineLink,
|
|
27
30
|
sentinelUrl,
|
|
31
|
+
sentinelWallMarks,
|
|
32
|
+
sentinelWallSeconds,
|
|
28
33
|
weekdayShorts
|
|
29
|
-
} from "../chunk-
|
|
34
|
+
} from "../chunk-MS6D4OUE.js";
|
|
30
35
|
export {
|
|
31
36
|
SENTINEL_DAY_MS,
|
|
32
37
|
SENTINEL_ENDPOINT_PATH,
|
|
@@ -40,10 +45,13 @@ export {
|
|
|
40
45
|
fmtTimeSec,
|
|
41
46
|
hhmmInput,
|
|
42
47
|
parseSentinelSetup,
|
|
48
|
+
sentinelAddDays,
|
|
49
|
+
sentinelAtTime,
|
|
43
50
|
sentinelClassOf,
|
|
44
51
|
sentinelClassesOf,
|
|
45
52
|
sentinelClipIndexFor,
|
|
46
53
|
sentinelClipRuns,
|
|
54
|
+
sentinelDayEnd,
|
|
47
55
|
sentinelDayOf,
|
|
48
56
|
sentinelEntryUrl,
|
|
49
57
|
sentinelEventPlayTs,
|
|
@@ -54,6 +62,8 @@ export {
|
|
|
54
62
|
sentinelStorageForecast,
|
|
55
63
|
sentinelTimelineLink,
|
|
56
64
|
sentinelUrl,
|
|
65
|
+
sentinelWallMarks,
|
|
66
|
+
sentinelWallSeconds,
|
|
57
67
|
weekdayShorts
|
|
58
68
|
};
|
|
59
69
|
//# sourceMappingURL=index.js.map
|
|
@@ -21,10 +21,12 @@ function parseSentinelSetup(input) {
|
|
|
21
21
|
}
|
|
22
22
|
if (!u.hostname) return null;
|
|
23
23
|
const token = u.searchParams.get("token");
|
|
24
|
-
|
|
24
|
+
const at = u.pathname.indexOf("/endpoint/");
|
|
25
|
+
const prefix = at > 0 ? u.pathname.slice(0, at).replace(/\/+$/, "") : "";
|
|
26
|
+
return { origin: u.origin, token: token && token.trim() ? token.trim() : null, prefix };
|
|
25
27
|
}
|
|
26
|
-
function sentinelPublicBase(origin) {
|
|
27
|
-
return `${origin.replace(/\/+$/, "")}${SENTINEL_ENDPOINT_PATH}/public/`;
|
|
28
|
+
function sentinelPublicBase(origin, prefix = "") {
|
|
29
|
+
return `${origin.replace(/\/+$/, "")}${prefix.replace(/\/+$/, "")}${SENTINEL_ENDPOINT_PATH}/public/`;
|
|
28
30
|
}
|
|
29
31
|
function sentinelLoginBase(origin) {
|
|
30
32
|
return `${origin.replace(/\/+$/, "")}${SENTINEL_ENDPOINT_PATH}/`;
|
|
@@ -101,20 +103,74 @@ function sentinelClipIndexFor(clips, ts) {
|
|
|
101
103
|
function sentinelDayOf(ts) {
|
|
102
104
|
return new Date(ts).setHours(0, 0, 0, 0);
|
|
103
105
|
}
|
|
106
|
+
function sentinelAddDays(ts, n) {
|
|
107
|
+
const d = new Date(ts);
|
|
108
|
+
d.setHours(0, 0, 0, 0);
|
|
109
|
+
d.setDate(d.getDate() + n);
|
|
110
|
+
return d.getTime();
|
|
111
|
+
}
|
|
112
|
+
function sentinelDayEnd(ts) {
|
|
113
|
+
return sentinelAddDays(ts, 1);
|
|
114
|
+
}
|
|
115
|
+
function sentinelAtTime(ts, h, m, s = 0) {
|
|
116
|
+
const d = new Date(ts);
|
|
117
|
+
d.setHours(h, m, s, 0);
|
|
118
|
+
return d.getTime();
|
|
119
|
+
}
|
|
120
|
+
function sentinelWallMarks(from, to, step, max = 8e3) {
|
|
121
|
+
const stepSec = Math.max(1, Math.round(step / 1e3));
|
|
122
|
+
const out = [];
|
|
123
|
+
for (let day = sentinelDayOf(from); day <= to && out.length < max; day = sentinelAddDays(day, 1)) {
|
|
124
|
+
const end = sentinelDayEnd(day);
|
|
125
|
+
const regular = end - day === SENTINEL_DAY_MS;
|
|
126
|
+
const k0 = Math.max(0, Math.floor((from - day - 36e5) / (stepSec * 1e3)));
|
|
127
|
+
const k1 = Math.min(Math.floor(86400 / stepSec), Math.ceil((to - day + 36e5) / (stepSec * 1e3)));
|
|
128
|
+
for (let k = k0; k <= k1 && out.length < max; k++) {
|
|
129
|
+
const sec = k * stepSec;
|
|
130
|
+
if (sec >= 86400) break;
|
|
131
|
+
let t;
|
|
132
|
+
if (regular) t = day + sec * 1e3;
|
|
133
|
+
else {
|
|
134
|
+
const d = new Date(day);
|
|
135
|
+
d.setHours(Math.floor(sec / 3600), Math.floor(sec % 3600 / 60), sec % 60, 0);
|
|
136
|
+
if (d.getHours() * 3600 + d.getMinutes() * 60 + d.getSeconds() !== sec) continue;
|
|
137
|
+
t = d.getTime();
|
|
138
|
+
}
|
|
139
|
+
if (t >= from && t <= to && (!out.length || t > out[out.length - 1])) out.push(t);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
return out;
|
|
143
|
+
}
|
|
144
|
+
function sentinelWallSeconds(ts) {
|
|
145
|
+
const d = new Date(ts);
|
|
146
|
+
return d.getHours() * 3600 + d.getMinutes() * 60 + d.getSeconds();
|
|
147
|
+
}
|
|
104
148
|
function sentinelMergeDays(days) {
|
|
105
149
|
const keys = Object.keys(days).map(Number).sort((a, b) => a - b);
|
|
106
|
-
const clips =
|
|
150
|
+
const clips = /* @__PURE__ */ new Map(), events = /* @__PURE__ */ new Map();
|
|
151
|
+
const motionRaw = [];
|
|
107
152
|
let codecs = null;
|
|
108
153
|
for (const k of keys) {
|
|
109
154
|
const d = days[k];
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
155
|
+
for (const c of d.clips) clips.set(c.id, c);
|
|
156
|
+
for (const e of d.events) events.set(e.id || `${e.timestamp}`, e);
|
|
157
|
+
motionRaw.push(...d.motion);
|
|
113
158
|
if (d.codecs) codecs = d.codecs;
|
|
114
159
|
}
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
160
|
+
motionRaw.sort((a, b) => a[0] - b[0]);
|
|
161
|
+
const motion = [];
|
|
162
|
+
for (const m of motionRaw) {
|
|
163
|
+
const last = motion[motion.length - 1];
|
|
164
|
+
if (last && m[0] <= last[1]) last[1] = Math.max(last[1], m[1]);
|
|
165
|
+
else motion.push([m[0], m[1]]);
|
|
166
|
+
}
|
|
167
|
+
return {
|
|
168
|
+
clips: [...clips.values()].sort((a, b) => a.startTime - b.startTime),
|
|
169
|
+
events: [...events.values()].sort((a, b) => a.timestamp - b.timestamp),
|
|
170
|
+
motion,
|
|
171
|
+
codecs,
|
|
172
|
+
oldestDay: keys.length ? keys[0] : null
|
|
173
|
+
};
|
|
118
174
|
}
|
|
119
175
|
function sentinelHumanBytes(b) {
|
|
120
176
|
if (!b || b <= 0) return { value: "0", unit: "B" };
|
|
@@ -215,11 +271,11 @@ var SentinelHttpError = class extends Error {
|
|
|
215
271
|
this.status = status;
|
|
216
272
|
}
|
|
217
273
|
};
|
|
218
|
-
async function exchangeSentinelToken(origin, username, password, timeoutMs = 1e4) {
|
|
274
|
+
async function exchangeSentinelToken(origin, username, password, timeoutMs = 1e4, prefix = "") {
|
|
219
275
|
const path = "api/token-exchange";
|
|
220
276
|
let r;
|
|
221
277
|
try {
|
|
222
|
-
r = await fetch(sentinelPublicBase(origin) + path, {
|
|
278
|
+
r = await fetch(sentinelPublicBase(origin, prefix) + path, {
|
|
223
279
|
method: "POST",
|
|
224
280
|
cache: "no-store",
|
|
225
281
|
signal: AbortSignal.timeout(timeoutMs),
|
|
@@ -275,6 +331,11 @@ export {
|
|
|
275
331
|
sentinelClipRuns,
|
|
276
332
|
sentinelClipIndexFor,
|
|
277
333
|
sentinelDayOf,
|
|
334
|
+
sentinelAddDays,
|
|
335
|
+
sentinelDayEnd,
|
|
336
|
+
sentinelAtTime,
|
|
337
|
+
sentinelWallMarks,
|
|
338
|
+
sentinelWallSeconds,
|
|
278
339
|
sentinelMergeDays,
|
|
279
340
|
sentinelHumanBytes,
|
|
280
341
|
SentinelClient,
|
|
@@ -287,4 +348,4 @@ export {
|
|
|
287
348
|
weekdayShorts,
|
|
288
349
|
hhmmInput
|
|
289
350
|
};
|
|
290
|
-
//# sourceMappingURL=chunk-
|
|
351
|
+
//# sourceMappingURL=chunk-MS6D4OUE.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/model.ts","../src/api/client.ts","../src/api/format.ts"],"sourcesContent":["/**\n * Sentinel NVR — DOM-free data model + pure helpers.\n *\n * Mirrors the Sentinel NVR plugin's `docs/API.md` (the binding contract): types,\n * URL/setup parsing, event classification, the playback-start heuristic, the\n * storage forecast the status page computes, and the timeline clip-run merge.\n * No fetch/DOM here — the browser client lives in `client.ts`.\n */\n\n// ---------------------------------------------------------------------------\n// Types (docs/API.md §3)\n// ---------------------------------------------------------------------------\n\n/** UI classes of an event; anything unknown collapses to `motion`. */\nexport type SentinelEventClass = 'person' | 'car' | 'bike' | 'animal' | 'package' | 'motion';\n\nexport const SENTINEL_EVENT_CLASSES: readonly SentinelEventClass[] = [\n 'person', 'car', 'bike', 'animal', 'package', 'motion',\n];\n\nexport type SentinelBox = [number, number, number, number];\n\n/** `api/cameras` entry. */\nexport interface SentinelCamera {\n id: string;\n name: string;\n recording: boolean;\n online: boolean;\n lastSegmentAt?: number;\n eventsToday: number;\n lastEventTs?: number;\n latestThumbId?: string;\n latestTs?: number;\n /** RFC-6381 codec string of the recordings (MSE). */\n codecs?: string;\n}\n\n/** `api/stats`. */\nexport interface SentinelStats {\n cameras: number;\n recording: number;\n eventsToday: number;\n segments: number;\n bytes: number;\n earliest?: number;\n retentionDays: number;\n diskFree: number;\n diskTotal: number;\n minFreeBytes: number;\n}\n\n/** `api/recent-events` entry (short form). */\nexport interface SentinelRecentEvent {\n camera: string;\n cameraName: string;\n ts: number;\n startTs?: number;\n classes: string[];\n score: number;\n}\n\nexport interface SentinelEventBox {\n class: string;\n rawClass?: string;\n score: number;\n box: SentinelBox;\n nbox?: SentinelBox;\n}\n\n/** Full event (`api/clips.events`). */\nexport interface SentinelEvent {\n id: string;\n timestamp: number;\n startTs?: number;\n classes: string[];\n score: number;\n source: 'object' | 'motion';\n boxes?: SentinelEventBox[];\n}\n\n/** Recording segment (`api/clips.clips`). */\nexport interface SentinelClip {\n id: string;\n videoId?: string;\n thumbnailId?: string;\n startTime: number;\n duration?: number;\n event?: string;\n detectionClasses?: string[];\n}\n\nexport interface SentinelClipsResponse {\n clips: SentinelClip[];\n events: SentinelEvent[];\n motion: [number, number][];\n codecs?: string;\n}\n\nexport const SENTINEL_DAY_MS = 24 * 60 * 60 * 1000;\n\n// ---------------------------------------------------------------------------\n// Setup / URLs (docs/API.md §1)\n// ---------------------------------------------------------------------------\n\n/** Where the plugin lives below a Scrypted origin. */\nexport const SENTINEL_ENDPOINT_PATH = '/endpoint/@local/sentinel-nvr';\n\nexport interface SentinelSetup {\n /** Scrypted origin, e.g. `https://192.168.2.120:10443` (no trailing slash). */\n origin: string;\n /** Access token found in the pasted URL (`?token=`), if any. */\n token: string | null;\n /**\n * Reverse-proxy path prefix in front of Scrypted's `/endpoint/…` (e.g. `/scrypted` for\n * `https://proxy/scrypted/endpoint/@local/sentinel-nvr/public/`), `''` without one.\n * Only derived when the pasted URL contains `/endpoint/`. Since 0.10.0.\n */\n prefix: string;\n}\n\n/**\n * Turn whatever the user pastes into a clean Scrypted origin (+ token, when the\n * pasted string was Sentinel's embed URL). Accepts a bare host (`https://` is\n * assumed), the Scrypted root, the plugin's login/public path, or the embed\n * URL with `?token=…&embed=1`. Returns null for unusable input.\n */\nexport function parseSentinelSetup(input: string | null | undefined): SentinelSetup | null {\n const raw = (input ?? '').trim();\n if (!raw) return null;\n const withScheme = /^https?:\\/\\//i.test(raw) ? raw : `https://${raw}`;\n let u: URL;\n try {\n u = new URL(withScheme);\n } catch {\n return null;\n }\n if (!u.hostname) return null;\n const token = u.searchParams.get('token');\n const at = u.pathname.indexOf('/endpoint/');\n const prefix = at > 0 ? u.pathname.slice(0, at).replace(/\\/+$/, '') : '';\n return { origin: u.origin, token: token && token.trim() ? token.trim() : null, prefix };\n}\n\n/** Token-guarded machine base (`…/public/`), always with a trailing slash; `prefix` = reverse-proxy path prefix. */\nexport function sentinelPublicBase(origin: string, prefix = ''): string {\n return `${origin.replace(/\\/+$/, '')}${prefix.replace(/\\/+$/, '')}${SENTINEL_ENDPOINT_PATH}/public/`;\n}\n\n/**\n * Human base behind the Scrypted login (`…/sentinel-nvr/`). NOT a link target:\n * without a session Scrypted answers \"Not Authorized\" here. Humans enter via\n * `sentinelEntryUrl` (the public base without a token shows Sentinel's sign-in\n * page, or redirects straight here when a session exists).\n */\nexport function sentinelLoginBase(origin: string): string {\n return `${origin.replace(/\\/+$/, '')}${SENTINEL_ENDPOINT_PATH}/`;\n}\n\n/** Where a human opens Sentinel's own UI: the public base WITHOUT a token (sign-in page / 302 into the session). */\nexport function sentinelEntryUrl(origin: string): string {\n return sentinelPublicBase(origin);\n}\n\n/**\n * Absolute URL for an API/media path below the public base, with the token as\n * a query parameter (a `GET` with a query token is a CORS \"simple request\" —\n * the `x-sentinel-token` header would force a preflight the plugin does not\n * answer; `<img>`/`<video>` sources need the query form anyway).\n */\nexport function sentinelUrl(base: string, token: string, path: string): string {\n const u = base + path;\n if (!token) return u;\n return `${u}${u.includes('?') ? '&' : '?'}token=${encodeURIComponent(token)}`;\n}\n\n/**\n * Deep link into Sentinel's own web UI for a camera timeline — via the entry\n * URL (sign-in or 302 into the session; browsers carry the `#` fragment across\n * the redirect).\n */\nexport function sentinelTimelineLink(origin: string, cameraId: string, atMs?: number): string {\n const q = atMs ? `?at=${Math.round(atMs)}` : '';\n return `${sentinelEntryUrl(origin)}#/timeline/${encodeURIComponent(cameraId)}${q}`;\n}\n\n// ---------------------------------------------------------------------------\n// Events\n// ---------------------------------------------------------------------------\n\nfunction isKnownClass(k: string): k is SentinelEventClass {\n return (SENTINEL_EVENT_CLASSES as readonly string[]).includes(k);\n}\n\n/** Primary class of an event (first known class, else `motion`). */\nexport function sentinelClassOf(ev: { classes?: string[] | undefined }): SentinelEventClass {\n const k = ev.classes?.[0];\n return k !== undefined && isKnownClass(k) ? k : 'motion';\n}\n\n/** Distinct known classes of an event, in order — never empty. */\nexport function sentinelClassesOf(ev: { classes?: string[] | undefined }): SentinelEventClass[] {\n const out: SentinelEventClass[] = [];\n for (const k of ev.classes ?? []) {\n const c: SentinelEventClass = isKnownClass(k) ? k : 'motion';\n if (!out.includes(c)) out.push(c);\n }\n return out.length ? out : [sentinelClassOf(ev)];\n}\n\n/**\n * Where playback starts for an event: 2 s before the first sighting when the\n * detector recorded one, else 3 s before the trigger (docs/API.md §3.3).\n */\nexport function sentinelEventPlayTs(ev: { timestamp?: number; ts?: number; startTs?: number }): number {\n const ts = ev.startTs || ev.ts || ev.timestamp || 0;\n return ev.startTs ? ts - 2000 : ts - 3000;\n}\n\n// ---------------------------------------------------------------------------\n// Storage forecast (docs/API.md §3.2 — the same maths the Sentinel status page uses)\n// ---------------------------------------------------------------------------\n\nexport type SentinelStorageStatus = 'unknown' | 'unreachable' | 'reachable' | 'filling';\n\nexport interface SentinelStorageForecast {\n /** Days spanned by the archive (earliest segment → now). */\n spanDays: number;\n /** Bytes recorded per day (0 until at least an hour of footage exists). */\n ratePerDay: number;\n /** Free-space guard reserve, clamped to the disk size. */\n reserve: number;\n /** Free bytes above the reserve. */\n usableFree: number;\n /** Bytes available for recordings = archive + usable free. */\n capacity: number;\n /** Days the archive can grow to at the current rate (0 = unknown). */\n fitsDays: number;\n /** Days until the reserve is reached (0 = unknown). */\n fillsInDays: number;\n /** The disk is effectively full (free ≤ 2 % above the reserve) → steady-state eviction. */\n steady: boolean;\n /** Bytes used by something other than recordings. */\n other: number;\n /** Which forecast message applies. */\n status: SentinelStorageStatus;\n}\n\nexport function sentinelStorageForecast(st: SentinelStats, nowMs: number = Date.now()): SentinelStorageForecast {\n const spanDays = st.earliest ? Math.max(0, (nowMs - st.earliest) / SENTINEL_DAY_MS) : 0;\n const ratePerDay = spanDays >= 1 / 24 ? st.bytes / Math.max(spanDays, 1 / 24) : 0;\n const reserve = Math.min(st.minFreeBytes || 0, st.diskTotal);\n const usableFree = Math.max(0, st.diskFree - reserve);\n const capacity = st.bytes + usableFree;\n const fitsDays = ratePerDay ? capacity / ratePerDay : 0;\n const fillsInDays = ratePerDay ? usableFree / ratePerDay : 0;\n const steady = usableFree < 0.02 * st.diskTotal;\n const other = Math.max(0, st.diskTotal - st.diskFree - st.bytes);\n let status: SentinelStorageStatus = 'unknown';\n if (ratePerDay) {\n if (fitsDays < st.retentionDays * 0.95) status = 'unreachable';\n else if (steady || spanDays >= st.retentionDays) status = 'reachable';\n else status = 'filling';\n }\n return { spanDays, ratePerDay, reserve, usableFree, capacity, fitsDays, fillsInDays, steady, other, status };\n}\n\n// ---------------------------------------------------------------------------\n// Timeline helpers\n// ---------------------------------------------------------------------------\n\nexport interface SentinelRun { s: number; e: number }\n\n/**\n * Contiguous recording runs: segments whose gap is ≤ `gapMs` (2 s) are drawn as\n * ONE band (otherwise every 60-s segment boundary shows a notch).\n */\nexport function sentinelClipRuns(clips: SentinelClip[], gapMs = 2000): SentinelRun[] {\n const out: SentinelRun[] = [];\n let cur: SentinelRun | null = null;\n for (const c of clips) {\n const e = c.startTime + (c.duration || 0);\n if (cur && c.startTime - cur.e <= gapMs) cur.e = Math.max(cur.e, e);\n else { cur = { s: c.startTime, e }; out.push(cur); }\n }\n return out;\n}\n\n/** Index of the clip covering `ts` (60 s assumed when a duration is missing), −1 if none. */\nexport function sentinelClipIndexFor(clips: SentinelClip[], ts: number): number {\n for (let i = 0; i < clips.length; i++) {\n const c = clips[i]!;\n if (ts >= c.startTime && ts < c.startTime + (c.duration || 60000)) return i;\n }\n return -1;\n}\n\n/** Local-midnight start of the day containing `ts`. */\nexport function sentinelDayOf(ts: number): number {\n return new Date(ts).setHours(0, 0, 0, 0);\n}\n\n// Calendar-day arithmetic. A local day is 23 or 25 hours long on DST change days, so\n// \"day ± 24 h\" lands an hour off midnight there (a second key for the same day, requests\n// shifted by an hour, \"next day\" staying on the same date). Always step calendar days:\n\n/** Local midnight `n` calendar days from the day of `ts`. */\nexport function sentinelAddDays(ts: number, n: number): number {\n const d = new Date(ts);\n d.setHours(0, 0, 0, 0);\n d.setDate(d.getDate() + n);\n return d.getTime();\n}\n\n/** End of the local day of `ts` (= next local midnight). */\nexport function sentinelDayEnd(ts: number): number {\n return sentinelAddDays(ts, 1);\n}\n\n/** Wall-clock time h:m on the local day of `ts` (not `midnight + h·3600 s`, which is an hour off on DST days). */\nexport function sentinelAtTime(ts: number, h: number, m: number, s = 0): number {\n const d = new Date(ts);\n d.setHours(h, m, s, 0);\n return d.getTime();\n}\n\n/**\n * Timestamps of local wall-clock marks every `step` ms (a divisor of a day: 15 s … 6 h) within [from, to],\n * ascending: a 3-h step marks 00:00/03:00/06:00 local time in every time zone (UTC-aligned steps showed\n * 02:00/05:00/08:00 in CEST). On DST days a mark that does not exist is skipped, a repeated hour marked once.\n */\nexport function sentinelWallMarks(from: number, to: number, step: number, max = 8000): number[] {\n const stepSec = Math.max(1, Math.round(step / 1000));\n const out: number[] = [];\n for (let day = sentinelDayOf(from); day <= to && out.length < max; day = sentinelAddDays(day, 1)) {\n const end = sentinelDayEnd(day);\n const regular = end - day === SENTINEL_DAY_MS;\n // only the marks near the window (+1 h slack on DST days)\n const k0 = Math.max(0, Math.floor((from - day - 3600_000) / (stepSec * 1000)));\n const k1 = Math.min(Math.floor(86400 / stepSec), Math.ceil((to - day + 3600_000) / (stepSec * 1000)));\n for (let k = k0; k <= k1 && out.length < max; k++) {\n const sec = k * stepSec;\n if (sec >= 86400) break;\n let t: number;\n if (regular) t = day + sec * 1000;\n else {\n const d = new Date(day);\n d.setHours(Math.floor(sec / 3600), Math.floor((sec % 3600) / 60), sec % 60, 0);\n // a wall time that does not exist (spring gap) normalises to another hour: skip it\n if (d.getHours() * 3600 + d.getMinutes() * 60 + d.getSeconds() !== sec) continue;\n t = d.getTime();\n }\n if (t >= from && t <= to && (!out.length || t > out[out.length - 1]!)) out.push(t);\n }\n }\n return out;\n}\n\n/** Local wall-clock seconds since midnight (for \"is this mark on a label step?\"). */\nexport function sentinelWallSeconds(ts: number): number {\n const d = new Date(ts);\n return d.getHours() * 3600 + d.getMinutes() * 60 + d.getSeconds();\n}\n\n/**\n * Merge per-day clip responses into one sorted, continuous data set. A clip or motion span that\n * crosses midnight comes with both days — kept once (by id / by interval).\n */\nexport function sentinelMergeDays(days: Record<number, SentinelClipsResponse>): {\n clips: SentinelClip[]; events: SentinelEvent[]; motion: [number, number][]; codecs: string | null; oldestDay: number | null;\n} {\n const keys = Object.keys(days).map(Number).sort((a, b) => a - b);\n const clips = new Map<string, SentinelClip>(), events = new Map<string, SentinelEvent>();\n const motionRaw: [number, number][] = [];\n let codecs: string | null = null;\n for (const k of keys) {\n const d = days[k]!;\n for (const c of d.clips) clips.set(c.id, c);\n for (const e of d.events) events.set(e.id || `${e.timestamp}`, e);\n motionRaw.push(...d.motion);\n if (d.codecs) codecs = d.codecs;\n }\n motionRaw.sort((a, b) => a[0] - b[0]);\n const motion: [number, number][] = [];\n for (const m of motionRaw) {\n const last = motion[motion.length - 1];\n if (last && m[0] <= last[1]) last[1] = Math.max(last[1], m[1]);\n else motion.push([m[0], m[1]]);\n }\n return {\n clips: [...clips.values()].sort((a, b) => a.startTime - b.startTime),\n events: [...events.values()].sort((a, b) => a.timestamp - b.timestamp),\n motion,\n codecs,\n oldestDay: keys.length ? keys[0]! : null,\n };\n}\n\n/** Human-readable byte size split into value + unit (binary steps). */\nexport function sentinelHumanBytes(b: number): { value: string; unit: string } {\n if (!b || b <= 0) return { value: '0', unit: 'B' };\n const u = ['B', 'KB', 'MB', 'GB', 'TB'];\n const i = Math.min(u.length - 1, Math.floor(Math.log(b) / Math.log(1024)));\n return { value: (b / Math.pow(1024, i)).toFixed(i ? 1 : 0), unit: u[i]! };\n}\n","/**\n * Browser client for the Sentinel NVR plugin's token-guarded `/public/` endpoint.\n *\n * The plugin sends permissive CORS on every answer (JSON, the 204 control replies,\n * api/segment incl. 206, api/livemse, images, errors) and answers OPTIONS, so a\n * cross-origin static SPA can talk to it directly with `?token=`. Media elements\n * may use crossOrigin=\"anonymous\". Older builds (JSON-only CORS) degrade: control()\n * treats an unreadable reply as delivered; media fetches fall into the next fallback.\n */\n\nimport { sentinelPublicBase, sentinelEntryUrl, sentinelUrl } from './model';\n\nexport class SentinelClient {\n readonly origin: string;\n readonly token: string;\n readonly base: string;\n /** \"Open Sentinel\" target: public base without token → sign-in / 302 into the session. */\n readonly entryUrl: string;\n /** fetch() can read media bodies (segments, live fMP4): the plugin sends CORS on media. */\n readonly corsMedia = true;\n\n /**\n * @param origin Scrypted origin, e.g. https://host:10443\n * @param token access token (empty behind a Scrypted login session)\n * @param opts.base override the request base: needed when the plugin is served\n * under a reverse-proxy prefix, or behind the Scrypted login path\n * (`…/endpoint/@local/sentinel-nvr/`, cookie session, no token). Defaults to\n * the token-guarded public base below `origin`.\n */\n constructor(origin: string, token: string, opts: { base?: string } = {}) {\n this.origin = origin;\n this.token = token;\n this.base = opts.base ? opts.base.replace(/\\/*$/, '/') : sentinelPublicBase(origin);\n this.entryUrl = sentinelEntryUrl(origin);\n }\n\n /** Cache key — a new client is built whenever origin/token change. */\n get key(): string {\n return `${this.origin} ${this.token}`;\n }\n\n url(path: string): string {\n return sentinelUrl(this.base, this.token, path);\n }\n\n /** JSON GET with a timeout (an unreachable host otherwise waits for the browser's TCP timeout). */\n async getJson<T>(path: string, signal?: AbortSignal, timeoutMs = 10_000): Promise<T> {\n const signals: AbortSignal[] = [AbortSignal.timeout(timeoutMs)];\n if (signal) signals.push(signal);\n // AbortSignal.any is Chrome 116 / Safari 17.4+; older engines get the timeout signal alone.\n const combined = typeof AbortSignal.any === 'function' ? AbortSignal.any(signals) : signals[0]!;\n const r = await fetch(this.url(path), { cache: 'no-store', signal: combined });\n if (!r.ok) throw new SentinelHttpError(r.status, path);\n return (await r.json()) as T;\n }\n\n /**\n * Fire a control GET (204 = ok, 404 = session gone). Resolves `r.ok`; a rejected\n * fetch (network error) resolves false so the player can recover instead of\n * believing a seek/rate change landed. (The plugin sends CORS on every reply.)\n */\n async control(path: string): Promise<boolean> {\n try {\n const r = await fetch(this.url(path), { cache: 'no-store' });\n return r.ok;\n } catch {\n return false;\n }\n }\n\n /** Text POST (client telemetry). Best effort, never throws. */\n postText(path: string, body: string): void {\n try {\n void fetch(this.url(path), { method: 'POST', body, keepalive: true }).catch(() => { /* telemetry only */ });\n } catch { /* ignore */ }\n }\n\n /** WebSocket signaling URL (the plugin's Engine.IO handler). */\n signalingUrl(cameraId: string, params: Record<string, string> = {}): string {\n const u = new URL(this.url(''));\n u.protocol = u.protocol === 'https:' ? 'wss:' : 'ws:';\n u.hash = '';\n u.searchParams.set('camera', cameraId);\n u.searchParams.set('signaling', '1');\n for (const [k, v] of Object.entries(params)) u.searchParams.set(k, v);\n return u.href;\n }\n\n // ---- media URL helpers (all <img>/<video>-loadable) ----\n snapshotUrl(cameraId: string, bust?: number): string {\n return this.url(`api/snapshot?camera=${encodeURIComponent(cameraId)}`) + (bust != null ? `&_=${bust}` : '');\n }\n eventThumbUrl(cameraId: string, ts: number): string {\n return this.url(`api/evthumb?camera=${encodeURIComponent(cameraId)}&ts=${Math.round(ts)}`);\n }\n eventFrameUrl(cameraId: string, ts: number): string {\n return this.url(`api/evframe?camera=${encodeURIComponent(cameraId)}&ts=${Math.round(ts)}`);\n }\n segmentThumbUrl(thumbId: string): string {\n return this.url(`api/thumb?id=${encodeURIComponent(thumbId)}`);\n }\n}\n\nexport class SentinelHttpError extends Error {\n readonly status: number;\n constructor(status: number, path: string) {\n super(`${status} ${path}`);\n this.name = 'SentinelHttpError';\n this.status = status;\n }\n}\n\n/**\n * Trade Scrypted credentials for the plugin's access token (`POST …/public/api/token-exchange`,\n * plugin ≥ 2026-09-22). Rejects with `SentinelHttpError`: 401 wrong credentials, 403 token access\n * switched off in the plugin or (plugin ≥ 2026-09-26) not a Scrypted admin, 404 plugin too old,\n * 429 too many attempts, 503 Scrypted login unavailable; 0 = unreachable. `prefix` = reverse-proxy\n * path prefix (SentinelSetup.prefix, since 0.10.0).\n */\nexport async function exchangeSentinelToken(origin: string, username: string, password: string, timeoutMs = 10_000, prefix = ''): Promise<string> {\n const path = 'api/token-exchange';\n let r: Response;\n try {\n r = await fetch(sentinelPublicBase(origin, prefix) + path, {\n method: 'POST', cache: 'no-store', signal: AbortSignal.timeout(timeoutMs),\n headers: { 'Content-Type': 'application/json' }, body: JSON.stringify({ username, password }),\n });\n } catch {\n throw new SentinelHttpError(0, path);\n }\n if (!r.ok) throw new SentinelHttpError(r.status, path);\n const j = (await r.json()) as { token?: unknown };\n if (typeof j.token !== 'string' || !j.token) throw new SentinelHttpError(502, path);\n return j.token;\n}\n","/**\n * Locale-aware, translation-free formatting (Intl only). Word-dependent helpers\n * (relative time, \"N days\") live in @sentinel-nvr/ui, which owns the i18n dictionary.\n */\n\nconst pad = (n: number) => String(n).padStart(2, '0');\n\n/** HH:MM in the viewer's locale (24 h where the locale uses it). */\nexport function fmtTime(ts: number, locale: string): string {\n return new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit' }).format(ts);\n}\n\n/** HH:MM:SS. */\nexport function fmtTimeSec(ts: number, locale: string): string {\n return new Intl.DateTimeFormat(locale, { hour: '2-digit', minute: '2-digit', second: '2-digit' }).format(ts);\n}\n\n/** \"Mon 8 Sep\" style day label. */\nexport function fmtDay(ts: number, locale: string): string {\n return new Intl.DateTimeFormat(locale, { weekday: 'short', day: 'numeric', month: 'short' }).format(ts);\n}\n\n/** Month + year for a date-picker header. */\nexport function fmtMonthYear(ts: number, locale: string): string {\n return new Intl.DateTimeFormat(locale, { month: 'long', year: 'numeric' }).format(ts);\n}\n\n/** Weekday short names (Monday first) for a date-picker grid. */\nexport function weekdayShorts(locale: string): string[] {\n const f = new Intl.DateTimeFormat(locale, { weekday: 'short' });\n // 2024-01-01 is a Monday.\n return Array.from({ length: 7 }, (_, i) => f.format(new Date(2024, 0, 1 + i)));\n}\n\n/** HH:MM string for a <input type=\"time\">. */\nexport function hhmmInput(ts: number): string {\n const d = new Date(ts);\n return `${pad(d.getHours())}:${pad(d.getMinutes())}`;\n}\n"],"mappings":";AAgBO,IAAM,yBAAwD;AAAA,EACnE;AAAA,EAAU;AAAA,EAAO;AAAA,EAAQ;AAAA,EAAU;AAAA,EAAW;AAChD;AAgFO,IAAM,kBAAkB,KAAK,KAAK,KAAK;AAOvC,IAAM,yBAAyB;AAqB/B,SAAS,mBAAmB,OAAwD;AACzF,QAAM,OAAO,SAAS,IAAI,KAAK;AAC/B,MAAI,CAAC,IAAK,QAAO;AACjB,QAAM,aAAa,gBAAgB,KAAK,GAAG,IAAI,MAAM,WAAW,GAAG;AACnE,MAAI;AACJ,MAAI;AACF,QAAI,IAAI,IAAI,UAAU;AAAA,EACxB,QAAQ;AACN,WAAO;AAAA,EACT;AACA,MAAI,CAAC,EAAE,SAAU,QAAO;AACxB,QAAM,QAAQ,EAAE,aAAa,IAAI,OAAO;AACxC,QAAM,KAAK,EAAE,SAAS,QAAQ,YAAY;AAC1C,QAAM,SAAS,KAAK,IAAI,EAAE,SAAS,MAAM,GAAG,EAAE,EAAE,QAAQ,QAAQ,EAAE,IAAI;AACtE,SAAO,EAAE,QAAQ,EAAE,QAAQ,OAAO,SAAS,MAA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AO,MAAM,KAAK,EAAE,QAAQ,EAAE,GAAG,CAAC,GAAG,MAAM,EAAE,OAAO,IAAI,KAAK,MAAM,GAAG,IAAI,CAAC,CAAC,CAAC;AAC/E;AAGO,SAAS,UAAU,IAAoB;AAC5C,QAAM,IAAI,IAAI,KAAK,EAAE;AACrB,SAAO,GAAG,IAAI,EAAE,SAAS,CAAC,CAAC,IAAI,IAAI,EAAE,WAAW,CAAC,CAAC;AACpD;","names":[]}
|
|
@@ -87,6 +87,12 @@ interface SentinelSetup {
|
|
|
87
87
|
origin: string;
|
|
88
88
|
/** Access token found in the pasted URL (`?token=`), if any. */
|
|
89
89
|
token: string | null;
|
|
90
|
+
/**
|
|
91
|
+
* Reverse-proxy path prefix in front of Scrypted's `/endpoint/…` (e.g. `/scrypted` for
|
|
92
|
+
* `https://proxy/scrypted/endpoint/@local/sentinel-nvr/public/`), `''` without one.
|
|
93
|
+
* Only derived when the pasted URL contains `/endpoint/`. Since 0.10.0.
|
|
94
|
+
*/
|
|
95
|
+
prefix: string;
|
|
90
96
|
}
|
|
91
97
|
/**
|
|
92
98
|
* Turn whatever the user pastes into a clean Scrypted origin (+ token, when the
|
|
@@ -95,8 +101,8 @@ interface SentinelSetup {
|
|
|
95
101
|
* URL with `?token=…&embed=1`. Returns null for unusable input.
|
|
96
102
|
*/
|
|
97
103
|
declare function parseSentinelSetup(input: string | null | undefined): SentinelSetup | null;
|
|
98
|
-
/** Token-guarded machine base (`…/public/`), always with a trailing slash. */
|
|
99
|
-
declare function sentinelPublicBase(origin: string): string;
|
|
104
|
+
/** Token-guarded machine base (`…/public/`), always with a trailing slash; `prefix` = reverse-proxy path prefix. */
|
|
105
|
+
declare function sentinelPublicBase(origin: string, prefix?: string): string;
|
|
100
106
|
/**
|
|
101
107
|
* Human base behind the Scrypted login (`…/sentinel-nvr/`). NOT a link target:
|
|
102
108
|
* without a session Scrypted answers "Not Authorized" here. Humans enter via
|
|
@@ -173,7 +179,24 @@ declare function sentinelClipRuns(clips: SentinelClip[], gapMs?: number): Sentin
|
|
|
173
179
|
declare function sentinelClipIndexFor(clips: SentinelClip[], ts: number): number;
|
|
174
180
|
/** Local-midnight start of the day containing `ts`. */
|
|
175
181
|
declare function sentinelDayOf(ts: number): number;
|
|
176
|
-
/**
|
|
182
|
+
/** Local midnight `n` calendar days from the day of `ts`. */
|
|
183
|
+
declare function sentinelAddDays(ts: number, n: number): number;
|
|
184
|
+
/** End of the local day of `ts` (= next local midnight). */
|
|
185
|
+
declare function sentinelDayEnd(ts: number): number;
|
|
186
|
+
/** Wall-clock time h:m on the local day of `ts` (not `midnight + h·3600 s`, which is an hour off on DST days). */
|
|
187
|
+
declare function sentinelAtTime(ts: number, h: number, m: number, s?: number): number;
|
|
188
|
+
/**
|
|
189
|
+
* Timestamps of local wall-clock marks every `step` ms (a divisor of a day: 15 s … 6 h) within [from, to],
|
|
190
|
+
* ascending: a 3-h step marks 00:00/03:00/06:00 local time in every time zone (UTC-aligned steps showed
|
|
191
|
+
* 02:00/05:00/08:00 in CEST). On DST days a mark that does not exist is skipped, a repeated hour marked once.
|
|
192
|
+
*/
|
|
193
|
+
declare function sentinelWallMarks(from: number, to: number, step: number, max?: number): number[];
|
|
194
|
+
/** Local wall-clock seconds since midnight (for "is this mark on a label step?"). */
|
|
195
|
+
declare function sentinelWallSeconds(ts: number): number;
|
|
196
|
+
/**
|
|
197
|
+
* Merge per-day clip responses into one sorted, continuous data set. A clip or motion span that
|
|
198
|
+
* crosses midnight comes with both days — kept once (by id / by interval).
|
|
199
|
+
*/
|
|
177
200
|
declare function sentinelMergeDays(days: Record<number, SentinelClipsResponse>): {
|
|
178
201
|
clips: SentinelClip[];
|
|
179
202
|
events: SentinelEvent[];
|
|
@@ -242,8 +265,10 @@ declare class SentinelHttpError extends Error {
|
|
|
242
265
|
/**
|
|
243
266
|
* Trade Scrypted credentials for the plugin's access token (`POST …/public/api/token-exchange`,
|
|
244
267
|
* plugin ≥ 2026-09-22). Rejects with `SentinelHttpError`: 401 wrong credentials, 403 token access
|
|
245
|
-
* switched off in the plugin
|
|
268
|
+
* switched off in the plugin or (plugin ≥ 2026-09-26) not a Scrypted admin, 404 plugin too old,
|
|
269
|
+
* 429 too many attempts, 503 Scrypted login unavailable; 0 = unreachable. `prefix` = reverse-proxy
|
|
270
|
+
* path prefix (SentinelSetup.prefix, since 0.10.0).
|
|
246
271
|
*/
|
|
247
|
-
declare function exchangeSentinelToken(origin: string, username: string, password: string, timeoutMs?: number): Promise<string>;
|
|
272
|
+
declare function exchangeSentinelToken(origin: string, username: string, password: string, timeoutMs?: number, prefix?: string): Promise<string>;
|
|
248
273
|
|
|
249
|
-
export {
|
|
274
|
+
export { sentinelDayOf as A, sentinelEntryUrl as B, sentinelEventPlayTs as C, sentinelHumanBytes as D, sentinelLoginBase as E, sentinelMergeDays as F, sentinelPublicBase as G, sentinelStorageForecast as H, sentinelTimelineLink as I, sentinelUrl as J, sentinelWallMarks as K, sentinelWallSeconds as L, SENTINEL_DAY_MS as S, SENTINEL_ENDPOINT_PATH as a, SENTINEL_EVENT_CLASSES as b, type SentinelBox as c, type SentinelCamera as d, SentinelClient as e, type SentinelClip as f, type SentinelClipsResponse as g, type SentinelEvent as h, type SentinelEventBox as i, type SentinelEventClass as j, SentinelHttpError as k, type SentinelRecentEvent as l, type SentinelRun as m, type SentinelSetup as n, type SentinelStats as o, type SentinelStorageForecast as p, type SentinelStorageStatus as q, exchangeSentinelToken as r, parseSentinelSetup as s, sentinelAddDays as t, sentinelAtTime as u, sentinelClassOf as v, sentinelClassesOf as w, sentinelClipIndexFor as x, sentinelClipRuns as y, sentinelDayEnd as z };
|
package/dist/player/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { P as PlayerController, a as PlayerLabel, b as PlayerOptions, c as PlayerRefs, d as PlayerState } from '../controller-
|
|
2
|
-
import { e as SentinelClient } from '../client-
|
|
1
|
+
export { P as PlayerController, a as PlayerLabel, b as PlayerOptions, c as PlayerRefs, d as PlayerState } from '../controller-DUCnMIrR.js';
|
|
2
|
+
import { e as SentinelClient } from '../client-BEc4796_.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* WebRTC session over the plugin's WebSocket signaling (docs/API.md §6).
|
package/dist/ui/index.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import * as react from 'react';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
-
import { e as SentinelClient, j as SentinelEventClass, l as SentinelRecentEvent, d as SentinelCamera, h as SentinelEvent, o as SentinelStats, f as SentinelClip } from '../client-
|
|
4
|
-
import { d as PlayerState } from '../controller-
|
|
3
|
+
import { e as SentinelClient, j as SentinelEventClass, l as SentinelRecentEvent, d as SentinelCamera, h as SentinelEvent, o as SentinelStats, f as SentinelClip } from '../client-BEc4796_.js';
|
|
4
|
+
import { d as PlayerState } from '../controller-DUCnMIrR.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Minimal translation core with the same dictionary semantics as HAPulse:
|
package/dist/ui/index.js
CHANGED
|
@@ -6,16 +6,21 @@ import {
|
|
|
6
6
|
fmtTime,
|
|
7
7
|
fmtTimeSec,
|
|
8
8
|
hhmmInput,
|
|
9
|
+
sentinelAddDays,
|
|
10
|
+
sentinelAtTime,
|
|
9
11
|
sentinelClassOf,
|
|
10
12
|
sentinelClassesOf,
|
|
11
13
|
sentinelClipRuns,
|
|
14
|
+
sentinelDayEnd,
|
|
12
15
|
sentinelDayOf,
|
|
13
16
|
sentinelEventPlayTs,
|
|
14
17
|
sentinelHumanBytes,
|
|
15
18
|
sentinelMergeDays,
|
|
16
19
|
sentinelStorageForecast,
|
|
20
|
+
sentinelWallMarks,
|
|
21
|
+
sentinelWallSeconds,
|
|
17
22
|
weekdayShorts
|
|
18
|
-
} from "../chunk-
|
|
23
|
+
} from "../chunk-MS6D4OUE.js";
|
|
19
24
|
import {
|
|
20
25
|
PlayerController,
|
|
21
26
|
rlog
|
|
@@ -1022,17 +1027,13 @@ function VerticalTimeline(p) {
|
|
|
1022
1027
|
const steps = [6e4, 3e5, 6e5, 9e5, 18e5, 36e5, 72e5, 108e5, 216e5];
|
|
1023
1028
|
const step = steps.find((s) => s >= 70 / px) ?? steps[steps.length - 1];
|
|
1024
1029
|
const topTs = px > 0 ? tsForY(0) : p.rangeEnd;
|
|
1025
|
-
const
|
|
1026
|
-
const
|
|
1027
|
-
for (let t2 = a0; t2 <= Math.min(topTs, winEnd) && axis.length < 2e3; t2 += step) axis.push(t2);
|
|
1030
|
+
const axisEnd = Math.min(topTs, winEnd), axisStart = Math.max(p.rangeStart, winStart);
|
|
1031
|
+
const axis = axisEnd >= axisStart ? sentinelWallMarks(axisStart, axisEnd, step, 2e3) : [];
|
|
1028
1032
|
const q = step / 4;
|
|
1029
|
-
const ticks = [];
|
|
1030
|
-
|
|
1031
|
-
const t0 = Math.max(p.rangeStart, Math.floor(winStart / q) * q);
|
|
1032
|
-
for (let t2 = t0; t2 <= Math.min(topTs, winEnd) && ticks.length < 8e3; t2 += q) ticks.push(t2);
|
|
1033
|
-
}
|
|
1033
|
+
const ticks = q * px >= 3 && axisEnd >= axisStart ? sentinelWallMarks(axisStart, axisEnd, q, 8e3) : [];
|
|
1034
|
+
const stepSec = Math.round(step / 1e3);
|
|
1034
1035
|
const midnights = [];
|
|
1035
|
-
for (let t2 =
|
|
1036
|
+
for (let t2 = sentinelAddDays(axisStart, 0); t2 <= axisEnd && midnights.length < 400; t2 = sentinelAddDays(t2, 1)) if (t2 > p.rangeStart) midnights.push(t2);
|
|
1036
1037
|
let lastThumbY = -1e9;
|
|
1037
1038
|
const thumbGap = (window.innerWidth < 900 ? 63 : 77) + 6;
|
|
1038
1039
|
const now = Date.now();
|
|
@@ -1046,7 +1047,10 @@ function VerticalTimeline(p) {
|
|
|
1046
1047
|
return /* @__PURE__ */ jsxs6("div", { className: "nvr-vtl vtl-wrap", children: [
|
|
1047
1048
|
/* @__PURE__ */ jsx8("div", { className: "vtl-scroll", ref: scroll, onScroll, onPointerDown: down, onTouchStart: down, children: /* @__PURE__ */ jsxs6("div", { className: "vtl-content", style: { height: span * px + PAD + PAD_BOT }, children: [
|
|
1048
1049
|
/* @__PURE__ */ jsx8("div", { className: "vtl-daybg", style: { top: 0, height: span * px + PAD } }),
|
|
1049
|
-
ticks.map((t2) =>
|
|
1050
|
+
ticks.map((t2) => {
|
|
1051
|
+
const w = sentinelWallSeconds(t2);
|
|
1052
|
+
return /* @__PURE__ */ jsx8("div", { className: "vtick" + (w % stepSec === 0 ? " vtick--l" : w % (stepSec / 2) === 0 ? " vtick--m" : ""), style: { top: yFor(t2) } }, "t" + t2);
|
|
1053
|
+
}),
|
|
1050
1054
|
axis.map((t2) => /* @__PURE__ */ jsx8("div", { className: "vaxis nvr-data", style: { top: yFor(t2) }, children: hhmm(t2) }, t2)),
|
|
1051
1055
|
midnights.map((t2) => /* @__PURE__ */ jsx8("div", { className: "vday", style: { top: yFor(t2) }, children: /* @__PURE__ */ jsx8("span", { className: "nvr-data", children: dayLbl(t2) }) }, "d" + t2)),
|
|
1052
1056
|
runs.map((r, i) => inWin(r.s, r.e) && /* @__PURE__ */ jsx8("div", { className: "vseg", style: { top: yFor(r.e), height: Math.max(2, (r.e - r.s) * px) } }, i)),
|
|
@@ -1098,7 +1102,7 @@ import { Calendar, Camera as Camera2, ChevronLeft as ChevronLeft2, ChevronRight
|
|
|
1098
1102
|
|
|
1099
1103
|
// src/ui/camera-logic.ts
|
|
1100
1104
|
function dateChipNav(centerDay, oldestAllowed, today = sentinelDayOf(Date.now())) {
|
|
1101
|
-
return { prevDisabled: centerDay -
|
|
1105
|
+
return { prevDisabled: sentinelAddDays(centerDay, -1) < oldestAllowed, nextDisabled: centerDay >= today };
|
|
1102
1106
|
}
|
|
1103
1107
|
function stageStatus(ps, t, locale, loadError = false, now = Date.now()) {
|
|
1104
1108
|
const label = loadError ? t("nvr.error.loadFailed") : ps.label ? t(`nvr.player.${ps.label}`) : "";
|
|
@@ -1153,18 +1157,18 @@ function CameraPage(p) {
|
|
|
1153
1157
|
const merged = useMemo2(() => {
|
|
1154
1158
|
const m = sentinelMergeDays(days);
|
|
1155
1159
|
const rangeStart = m.oldestDay ?? todayStart();
|
|
1156
|
-
const rangeEnd = Math.min(todayStart()
|
|
1160
|
+
const rangeEnd = Math.min(sentinelDayEnd(todayStart()), nowTick + 20 * 6e4);
|
|
1157
1161
|
return { ...m, rangeStart, rangeEnd };
|
|
1158
1162
|
}, [days, nowTick]);
|
|
1159
1163
|
const mergedNow = useCallback(() => {
|
|
1160
1164
|
const m = sentinelMergeDays(daysRef.current);
|
|
1161
|
-
return { ...m, rangeStart: m.oldestDay ?? todayStart(), rangeEnd: Math.min(todayStart()
|
|
1165
|
+
return { ...m, rangeStart: m.oldestDay ?? todayStart(), rangeEnd: Math.min(sentinelDayEnd(todayStart()), Date.now() + 20 * 6e4) };
|
|
1162
1166
|
}, []);
|
|
1163
1167
|
useEffect3(() => {
|
|
1164
1168
|
ctl.current?.setClips(merged.clips, merged.codecs, merged.rangeStart, merged.rangeEnd);
|
|
1165
1169
|
}, [merged]);
|
|
1166
1170
|
const fetchDay = useCallback(async (ds) => {
|
|
1167
|
-
const d = await client.getJson(`api/clips?camera=${encodeURIComponent(camId)}&start=${ds}&end=${ds
|
|
1171
|
+
const d = await client.getJson(`api/clips?camera=${encodeURIComponent(camId)}&start=${ds}&end=${sentinelDayEnd(ds)}`);
|
|
1168
1172
|
d.clips = (d.clips || []).sort((a, b) => a.startTime - b.startTime);
|
|
1169
1173
|
d.events = d.events || [];
|
|
1170
1174
|
d.motion = d.motion || [];
|
|
@@ -1172,7 +1176,7 @@ function CameraPage(p) {
|
|
|
1172
1176
|
}, [client, camId]);
|
|
1173
1177
|
const ensureDay = useCallback(async (ds, force = false) => {
|
|
1174
1178
|
if (ds > todayStart()) return;
|
|
1175
|
-
if (earliest && ds
|
|
1179
|
+
if (earliest && sentinelAddDays(ds, 1) < sentinelDayOf(earliest)) return;
|
|
1176
1180
|
if (!force && (daysRef.current[ds] || loading.current.has(ds))) return;
|
|
1177
1181
|
loading.current.add(ds);
|
|
1178
1182
|
try {
|
|
@@ -1180,6 +1184,7 @@ function CameraPage(p) {
|
|
|
1180
1184
|
if (camRef.current !== camId) return;
|
|
1181
1185
|
daysRef.current = { ...daysRef.current, [ds]: d };
|
|
1182
1186
|
setDays((prev) => ({ ...prev, [ds]: d }));
|
|
1187
|
+
setLoadError(false);
|
|
1183
1188
|
} finally {
|
|
1184
1189
|
loading.current.delete(ds);
|
|
1185
1190
|
}
|
|
@@ -1187,9 +1192,7 @@ function CameraPage(p) {
|
|
|
1187
1192
|
const onCenter = useCallback((ts) => {
|
|
1188
1193
|
const d = sentinelDayOf(ts);
|
|
1189
1194
|
setCenterDay(d);
|
|
1190
|
-
|
|
1191
|
-
void ensureDay(d - SENTINEL_DAY_MS);
|
|
1192
|
-
void ensureDay(d + SENTINEL_DAY_MS);
|
|
1195
|
+
for (const x of [d, sentinelAddDays(d, -1), sentinelAddDays(d, 1)]) ensureDay(x).catch(() => setLoadError(true));
|
|
1193
1196
|
}, [ensureDay]);
|
|
1194
1197
|
useEffect3(() => {
|
|
1195
1198
|
const st = stage.current, cd = body.current;
|
|
@@ -1237,7 +1240,7 @@ function CameraPage(p) {
|
|
|
1237
1240
|
else c.posterFromSnapshot(lastTileSnapshot(camId));
|
|
1238
1241
|
const t0 = todayStart();
|
|
1239
1242
|
const target = startAt ? sentinelDayOf(startAt) : t0;
|
|
1240
|
-
Promise.all([ensureDay(target), ensureDay(target -
|
|
1243
|
+
Promise.all([ensureDay(target), ensureDay(sentinelAddDays(target, -1)), target !== t0 ? ensureDay(t0) : Promise.resolve(), target === t0 ? Promise.resolve() : ensureDay(sentinelAddDays(target, 1))]).then(() => {
|
|
1241
1244
|
if (c.camId !== camId || ctl.current !== c) return;
|
|
1242
1245
|
setLoadError(false);
|
|
1243
1246
|
const m = mergedNow();
|
|
@@ -1299,20 +1302,20 @@ function CameraPage(p) {
|
|
|
1299
1302
|
const goToDay = useCallback(async (ds, at) => {
|
|
1300
1303
|
const c = ctl.current;
|
|
1301
1304
|
if (!c) return;
|
|
1302
|
-
await Promise.all([ensureDay(ds), ensureDay(ds -
|
|
1305
|
+
await Promise.all([ensureDay(ds), ensureDay(sentinelAddDays(ds, -1)), ensureDay(sentinelAddDays(ds, 1))]);
|
|
1303
1306
|
if (camRef.current !== camId) return;
|
|
1304
1307
|
if (ds === todayStart() && at == null) {
|
|
1305
1308
|
goLive();
|
|
1306
1309
|
return;
|
|
1307
1310
|
}
|
|
1308
|
-
const want = at ?? ds
|
|
1311
|
+
const want = at ?? sentinelAtTime(ds, 12, 0);
|
|
1309
1312
|
if (want > Date.now()) {
|
|
1310
1313
|
goLive();
|
|
1311
1314
|
return;
|
|
1312
1315
|
}
|
|
1313
1316
|
const m = mergedNow();
|
|
1314
1317
|
c.setClips(m.clips, m.codecs, m.rangeStart, m.rangeEnd);
|
|
1315
|
-
const inDay = m.clips.filter((x) => x.startTime >= ds && x.startTime < ds
|
|
1318
|
+
const inDay = m.clips.filter((x) => x.startTime >= ds && x.startTime < sentinelDayEnd(ds));
|
|
1316
1319
|
const exact = c.clipIndexFor(want) >= 0;
|
|
1317
1320
|
const pick = exact ? want : (inDay.find((x) => x.startTime >= want) || inDay[inDay.length - 1])?.startTime;
|
|
1318
1321
|
setJump({ ts: pick ?? want, n: Date.now() });
|
|
@@ -1418,12 +1421,12 @@ function CameraPage(p) {
|
|
|
1418
1421
|
}
|
|
1419
1422
|
) : /* @__PURE__ */ jsx9(EventList, { camId, events: merged.events, filterOff, onPick: playEvent }),
|
|
1420
1423
|
/* @__PURE__ */ jsxs7("div", { className: "nvr-datechip" + (ps.live ? "" : " nvr-datechip--rec"), children: [
|
|
1421
|
-
/* @__PURE__ */ jsx9("button", { type: "button", onClick: () =>
|
|
1424
|
+
/* @__PURE__ */ jsx9("button", { type: "button", onClick: () => goToDay(sentinelAddDays(centerDay, -1)).catch(() => setLoadError(true)), disabled: nav.prevDisabled, "aria-label": t("nvr.date.prevDay"), children: /* @__PURE__ */ jsx9(ChevronLeft2, { size: 14 }) }),
|
|
1422
1425
|
/* @__PURE__ */ jsxs7("button", { type: "button", className: "nvr-datechip__lbl nvr-data", onClick: () => setDt(true), "aria-label": t("nvr.date.title"), children: [
|
|
1423
1426
|
/* @__PURE__ */ jsx9(Calendar, { size: 13 }),
|
|
1424
1427
|
fmtDay(centerDay, locale)
|
|
1425
1428
|
] }),
|
|
1426
|
-
/* @__PURE__ */ jsx9("button", { type: "button", onClick: () =>
|
|
1429
|
+
/* @__PURE__ */ jsx9("button", { type: "button", onClick: () => goToDay(sentinelAddDays(centerDay, 1)).catch(() => setLoadError(true)), disabled: nav.nextDisabled, "aria-label": t("nvr.date.nextDay"), children: /* @__PURE__ */ jsx9(ChevronRight2, { size: 14 }) })
|
|
1427
1430
|
] })
|
|
1428
1431
|
] })
|
|
1429
1432
|
] }),
|
|
@@ -1434,9 +1437,8 @@ function CameraPage(p) {
|
|
|
1434
1437
|
onClose: () => setDt(false),
|
|
1435
1438
|
onGo: (ds, time) => {
|
|
1436
1439
|
setDt(false);
|
|
1437
|
-
const at = time ? ds
|
|
1438
|
-
goToDay(ds, at).catch(() =>
|
|
1439
|
-
});
|
|
1440
|
+
const at = time ? sentinelAtTime(ds, Number(time.split(":")[0]), Number(time.split(":")[1])) : void 0;
|
|
1441
|
+
goToDay(ds, at).catch(() => setLoadError(true));
|
|
1440
1442
|
}
|
|
1441
1443
|
})
|
|
1442
1444
|
] });
|