@sentinel-nvr/web 0.17.0 → 0.18.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 +20 -0
- package/dist/api/index.d.ts +5 -2
- package/dist/api/index.js +3 -1
- package/dist/{chunk-5RHE6TBS.js → chunk-7W5ORHOB.js} +2 -2
- package/dist/{chunk-UK7LBC3R.js → chunk-P7VKKFVA.js} +16 -2
- package/dist/chunk-P7VKKFVA.js.map +1 -0
- package/dist/{client-Db79VnMp.d.ts → client-BZP21uB4.d.ts} +45 -3
- package/dist/{controller-B5d2PRav.d.ts → controller-DwyUCzWR.d.ts} +1 -1
- package/dist/player/index.d.ts +2 -2
- package/dist/player/index.js +2 -2
- package/dist/ui/index.d.ts +24 -7
- package/dist/ui/index.js +55 -15
- package/dist/ui/index.js.map +1 -1
- package/dist/ui/ui.css +555 -0
- package/package.json +1 -1
- package/dist/chunk-UK7LBC3R.js.map +0 -1
- /package/dist/{chunk-5RHE6TBS.js.map → chunk-7W5ORHOB.js.map} +0 -0
package/README.md
CHANGED
|
@@ -38,6 +38,7 @@ on older servers, but only get their full behaviour with the matching plugin ver
|
|
|
38
38
|
| 0.15.x | any (priority order from the server: ≥ 1.3.0; older servers are sorted client-side) | event classes by priority (a cyclist is a person), class filters hide an event only when all its classes are off, chips count every contained class — client only. |
|
|
39
39
|
| 0.16.x | any (spans: ≥ 1.3.0) | events as time spans: bar from first sighting to last movement on the timeline, running events pulse, duration/„running“ in the list (`endTs`/`open`); older servers show plain markers. 0.16.5: storage values in the UI language, today refresh during playback — client only. 0.16.7: overlapping timeline markers grouped with a count, a tap zooms in — client only. 0.16.8: the events tab counts the centred day — client only. 0.16.9: "yesterday" in front of the time in the overview events strip — client only. 0.16.10: "recording stalled" on tiles and in the status pill (`stalled` from plugin ≥ 2026-10-05; older servers: no change). 0.16.11: `header`/`externalUrl` may take the playback position — client only. |
|
|
40
40
|
| 0.17.x | plugin with `features: ["export"]` (older plugins: no clip button, everything else as 0.16.x) | clip download on the camera page: "Download clip" in the info bar and per event in the list, range as a band on the timeline, edges set over the playhead line, `api/export` → `api/export-status` → `api/export-file` (save, or share up to 100 MB); `SentinelClient.startExport/exportStatus/exportFileUrl/cancelExport`, `SentinelHttpError.code`. |
|
|
41
|
+
| 0.18.x | any | opt-in immersive camera page: `CameraPage appearance="immersive"` (`data-nvr-appearance` on the page) — picture edge to edge with the header over it on phones, floating controls, tabs as a segment, styled by the host through `--nvr-ctl-*`, `--nvr-float-*`, `--nvr-seg-*`, `--nvr-live-*`, `--nvr-shade-top`/`-bottom`, `--nvr-ease`/`--nvr-dur`; `header(at, { live })`, `CameraTitle` `live`/`at` (LIVE badge or the picture's time). Without the prop the page is unchanged. Client only. |
|
|
41
42
|
|
|
42
43
|
Lab note: Scrypted's WebRTC sink re-encodes (1280 px, 15 fps) for clients that are not Windows/macOS/iOS and report a
|
|
43
44
|
screen below 1920 physical pixels, unless the source declares a width ≤ 1280. Plugin ≥ 1.2.0 declares it for recorded
|
|
@@ -58,6 +59,25 @@ The server keeps its own types; `docs/API.md` in the plugin repository is the co
|
|
|
58
59
|
Everything visible inside comes from the package, so both consumers look identical.
|
|
59
60
|
Optional `externalUrl` = this camera outside the app (Sentinel's public entry, no token): offered as "Open in
|
|
60
61
|
Safari" when an iPhone/iPad Home-Screen app refuses Picture-in-Picture.
|
|
62
|
+
- **Immersive camera page** (0.18.0, opt-in): `appearance="immersive"` puts `data-nvr-appearance="immersive"` on
|
|
63
|
+
`.nvr-cam`; every rule for it is scoped to that attribute, so the default page stays as it is. Below 900 px the page
|
|
64
|
+
owns the screen: the host hides its own bars and gives the page the viewport (`.nvr-cam__body` is `100dvh`, at least
|
|
65
|
+
27rem; on a short screen the picture yields first). The picture runs edge to edge and the header row (`CameraTitle`:
|
|
66
|
+
back, name + badge, host actions) lies over it with a gradient — give icon actions the class `nvr-iconbtn` to get
|
|
67
|
+
the same round button as back. The controls float as capsules, the tabs are a segment with a sliding lens
|
|
68
|
+
(`.nvr-tabs[data-active]`, only on this page), the timeline reaches the bottom edge (safe areas kept). From 900 px
|
|
69
|
+
the header stays above the columns, the picture has no card frame. The timeline keeps its geometry. Meant for dark
|
|
70
|
+
tokens: the host scopes its theme dark on the page (the package re-derives its own `--nvr-*` colours there). Hooks,
|
|
71
|
+
all optional (fallback = the default look): over the picture `--nvr-ctl-bg`, `-filter`, `-rim` (1-px edge, may be a
|
|
72
|
+
gradient), `-shadow`, `-fg`, `-text-shadow`; over the timeline (date chip, zoom) `--nvr-float-bg`, `-filter`,
|
|
73
|
+
`-rim`, `-shadow`, `-fg`, `-accent` (the chip's text while a recording plays); segment `--nvr-seg-track`, `-lens`,
|
|
74
|
+
`-shadow`; LIVE badge, live jump and the live line's label `--nvr-live-bg`, `-fg` (badge and live jump also
|
|
75
|
+
`--nvr-live-shadow`); the gradients' dark end `--nvr-shade-top` (under the header, default black 70 %) and
|
|
76
|
+
`--nvr-shade-bottom` (under the controls, default black 35 %; on devices with a hovering pointer it shows with the
|
|
77
|
+
controls); the lens' motion `--nvr-ease`, `--nvr-dur` (with reduced motion the chosen tab's fill fades over in 200
|
|
78
|
+
ms instead). The name and time in the header lie on the top gradient, which is dark in every theme: without
|
|
79
|
+
`--nvr-ctl-fg` they are white. `header` as a function gets `(at, { live })`; pass both to `CameraTitle` (`live`, `at`) for the LIVE
|
|
80
|
+
badge or the picture's time next to the name.
|
|
61
81
|
|
|
62
82
|
## Develop
|
|
63
83
|
|
package/dist/api/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { S as SENTINEL_CLASS_PRIORITY, a as SENTINEL_DAY_MS, b as SENTINEL_ENDPOINT_PATH, c as SENTINEL_EVENT_CLASSES, d as SENTINEL_MIN_SPAN_MS, e as SentinelBox, f as SentinelCamera, g as SentinelClient, h as SentinelClip, i as SentinelClipsResponse, j as
|
|
1
|
+
export { S as SENTINEL_CLASS_PRIORITY, a as SENTINEL_DAY_MS, b as SENTINEL_ENDPOINT_PATH, c as SENTINEL_EVENT_CLASSES, d as SENTINEL_MIN_SPAN_MS, e as SentinelBox, f as SentinelCamera, g as SentinelClient, h as SentinelClip, i as SentinelClipsResponse, j as SentinelDetection, k as SentinelEvent, l as SentinelEventBox, m as SentinelEventClass, n as SentinelExportStart, o as SentinelExportState, p as SentinelExportStatus, q as SentinelHistogram, r as SentinelHttpError, s as SentinelRecentEvent, t as SentinelRecordingState, u as SentinelRun, v as SentinelSetup, w as SentinelStats, x as SentinelStorageForecast, y as SentinelStorageStatus, z as exchangeSentinelToken, A as parseSentinelSetup, B as sentinelAddDays, C as sentinelAtTime, D as sentinelClassOf, E as sentinelClassesOf, F as sentinelClipIndexFor, G as sentinelClipRuns, H as sentinelDayEnd, I as sentinelDayOf, J as sentinelDuration, K as sentinelEntryUrl, L as sentinelEventHidden, M as sentinelEventPlayTs, N as sentinelEventSpan, O as sentinelHasFeature, P as sentinelHumanBytes, Q as sentinelLoginBase, R as sentinelMergeDays, T as sentinelPublicBase, U as sentinelRecordingState, V as sentinelStorageForecast, W as sentinelTimelineLink, X as sentinelUrl, Y as sentinelWallMarks, Z as sentinelWallSeconds, _ as timeoutSignal } from '../client-BZP21uB4.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Locale-aware, translation-free formatting (Intl only). Word-dependent helpers
|
|
@@ -22,5 +22,8 @@ declare function fmtMonthYear(ts: number, locale: string): string;
|
|
|
22
22
|
declare function weekdayShorts(locale: string): string[];
|
|
23
23
|
/** HH:MM string for a <input type="time">. */
|
|
24
24
|
declare function hhmmInput(ts: number): string;
|
|
25
|
+
/** A whole number with the locale's digit grouping ("48.210" in German, "48,210" in English); an unknown tag falls
|
|
26
|
+
* back to the plain digits. */
|
|
27
|
+
declare function fmtCount(n: number, locale: string): string;
|
|
25
28
|
|
|
26
|
-
export { fmtDay, fmtDayPrefix, fmtMonthYear, fmtTime, fmtTimeSec, hhmmInput, weekdayShorts };
|
|
29
|
+
export { fmtCount, fmtDay, fmtDayPrefix, fmtMonthYear, fmtTime, fmtTimeSec, hhmmInput, weekdayShorts };
|
package/dist/api/index.js
CHANGED
|
@@ -7,6 +7,7 @@ import {
|
|
|
7
7
|
SentinelClient,
|
|
8
8
|
SentinelHttpError,
|
|
9
9
|
exchangeSentinelToken,
|
|
10
|
+
fmtCount,
|
|
10
11
|
fmtDay,
|
|
11
12
|
fmtDayPrefix,
|
|
12
13
|
fmtMonthYear,
|
|
@@ -40,7 +41,7 @@ import {
|
|
|
40
41
|
sentinelWallSeconds,
|
|
41
42
|
timeoutSignal,
|
|
42
43
|
weekdayShorts
|
|
43
|
-
} from "../chunk-
|
|
44
|
+
} from "../chunk-P7VKKFVA.js";
|
|
44
45
|
export {
|
|
45
46
|
SENTINEL_CLASS_PRIORITY,
|
|
46
47
|
SENTINEL_DAY_MS,
|
|
@@ -50,6 +51,7 @@ export {
|
|
|
50
51
|
SentinelClient,
|
|
51
52
|
SentinelHttpError,
|
|
52
53
|
exchangeSentinelToken,
|
|
54
|
+
fmtCount,
|
|
53
55
|
fmtDay,
|
|
54
56
|
fmtDayPrefix,
|
|
55
57
|
fmtMonthYear,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
timeoutSignal
|
|
3
|
-
} from "./chunk-
|
|
3
|
+
} from "./chunk-P7VKKFVA.js";
|
|
4
4
|
|
|
5
5
|
// src/player/rlog.ts
|
|
6
6
|
var brand = "web";
|
|
@@ -2640,4 +2640,4 @@ export {
|
|
|
2640
2640
|
settleStep,
|
|
2641
2641
|
PlayerController
|
|
2642
2642
|
};
|
|
2643
|
-
//# sourceMappingURL=chunk-
|
|
2643
|
+
//# sourceMappingURL=chunk-7W5ORHOB.js.map
|
|
@@ -432,6 +432,19 @@ function hhmmInput(ts) {
|
|
|
432
432
|
const d = new Date(ts);
|
|
433
433
|
return `${pad(d.getHours())}:${pad(d.getMinutes())}`;
|
|
434
434
|
}
|
|
435
|
+
var countFmt = /* @__PURE__ */ new Map();
|
|
436
|
+
function fmtCount(n, locale) {
|
|
437
|
+
let f = countFmt.get(locale);
|
|
438
|
+
if (f === void 0) {
|
|
439
|
+
try {
|
|
440
|
+
f = new Intl.NumberFormat(locale, { maximumFractionDigits: 0 });
|
|
441
|
+
} catch {
|
|
442
|
+
f = null;
|
|
443
|
+
}
|
|
444
|
+
countFmt.set(locale, f);
|
|
445
|
+
}
|
|
446
|
+
return f ? f.format(n) : String(Math.round(n));
|
|
447
|
+
}
|
|
435
448
|
|
|
436
449
|
export {
|
|
437
450
|
SENTINEL_EVENT_CLASSES,
|
|
@@ -474,6 +487,7 @@ export {
|
|
|
474
487
|
fmtDay,
|
|
475
488
|
fmtMonthYear,
|
|
476
489
|
weekdayShorts,
|
|
477
|
-
hhmmInput
|
|
490
|
+
hhmmInput,
|
|
491
|
+
fmtCount
|
|
478
492
|
};
|
|
479
|
-
//# sourceMappingURL=chunk-
|
|
493
|
+
//# sourceMappingURL=chunk-P7VKKFVA.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',\n 'car',\n 'bike',\n 'animal',\n 'package',\n 'motion',\n];\n\nexport type SentinelBox = [number, number, number, number];\n\n/** `api/cameras[].detection` (plugin ≥ 1.3.0): is object detection really working? */\nexport interface SentinelDetection {\n /** ok | stalled (no frames for > 10 s) | error (also: engine hangs) | no-engine (camera's own detector or motion only)\n * | off (detection or recording switched off) */\n state: 'ok' | 'stalled' | 'error' | 'no-engine' | 'off';\n /** engine | camera | motion | none — may be absent when switched off */\n mode?: string;\n fps?: number;\n lastFrameAgoMs?: number;\n model?: string;\n /** share of the shared Coral: level 0 (unthrottled) … 4 */\n coral?: { level: number; rate: number; share: number; waitP95: number; shed: number };\n /** plugin ≥ 2026-10-01: engine watchdog; `down` = hung / being reloaded, nothing analysed */\n engine?: { state: 'ok' | 'suspect' | 'down'; downForMs?: number; reloads?: number };\n /** plugin ≥ 2026-10-01: spans not analysed live, still to be analysed from the recordings */\n gaps?: {\n pending: number;\n pendingMs: number;\n /** only during an outage going on right now: since when, and why */\n openForMs?: number;\n reason?: 'engine' | 'feed' | 'restart' | 'manual';\n };\n}\n\n/** `api/cameras` entry. */\nexport interface SentinelCamera {\n id: string;\n name: string;\n recording: boolean;\n online: boolean;\n /** plugin ≥ 2026-10-05: recording watchdog — ffmpeg ran ≥ 3 min without a new segment and is being restarted; stays set\n * (also while the restart is pending, `online` false) until a segment arrives again. */\n stalled?: boolean;\n /** plugin ≥ 2026-10-05: since when nothing was recorded (ms) */\n stalledSince?: number;\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 /** plugin ≥ 1.3.0: state of the object detection */\n detection?: SentinelDetection;\n}\n\n/**\n * Recording state of a camera tile: `off` = recording switched off, `stalled` = recording hangs (watchdog, outranks\n * `offline`: during the restart after a stall ffmpeg is briefly down), `offline` = ffmpeg not running (camera\n * unreachable), `ok` = recording.\n */\nexport type SentinelRecordingState = 'off' | 'stalled' | 'offline' | 'ok';\n\nexport function sentinelRecordingState(\n cam: Pick<SentinelCamera, 'recording' | 'online' | 'stalled'>,\n): SentinelRecordingState {\n if (!cam.recording) return 'off';\n if (cam.stalled) return 'stalled';\n return cam.online ? 'ok' : 'offline';\n}\n\n/** `api/stats`. */\nexport interface SentinelStats {\n cameras: number;\n /** cameras recording right now (plugin ≥ 2026-10-05; before: cameras with recording switched on) */\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 /** plugin ≥ 2026-09-26: storage root usable (storage guard); false = not recording, nothing deleted. */\n storageOk?: boolean;\n /** why not: 'marker' (share not mounted), 'missing', 'error' (file system error), 'timeout' (hung mount); treat a\n * value a newer plugin may add like 'error' */\n storageProblem?: 'missing' | 'marker' | 'error' | 'timeout';\n /** optional server features (plugin ≥ 2026-10-06: `\"export\"` = clip export, `api/export*`) */\n features?: string[];\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 /** plugin ≥ 1.3.0: event as a time span — last movement of one of its objects */\n endTs?: number;\n /** plugin ≥ 1.3.0: the event is still running */\n open?: boolean;\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 /** plugin ≥ 1.3.0: picture time of this box (later than `timestamp` = the object joined the running event) */\n ts?: number;\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 /** plugin ≥ 1.3.0: event as a time span — last movement of one of its objects */\n endTs?: number;\n /** plugin ≥ 1.3.0: the event is still running (its objects are still there) */\n open?: boolean;\n /** plugin ≥ 2026-10-01: found afterwards in the recording (the live detection was not running then) */\n backfill?: boolean;\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 /** optional server features (plugin ≥ 2026-10-06: `\"export\"` = clip export, `api/export*`) */\n features?: string[];\n}\n\n/** `api/events-histogram`: today's events per hour of the viewer's day (index 0–23, `?tz=`). */\nexport interface SentinelHistogram {\n buckets: number[];\n}\n\n/** A server answer (`api/clips`, `api/stats`) announces `feature` — older plugins send no `features` at all. */\nexport function sentinelHasFeature(\n r: { features?: string[] | undefined } | null | undefined,\n feature: string,\n): boolean {\n return Array.isArray(r?.features) && r.features.includes(feature);\n}\n\n/** `POST api/export` (202): a clip export job was started. Times in ms; `from`/`to` as the server cut them (`from` raised\n * to the oldest recording, `to` lowered to \"now − 10 s\" = `clipped`). */\nexport interface SentinelExportStart {\n id: string;\n camera: string;\n from: number;\n to: number;\n /** `to` was lowered: the end was not recorded yet */\n clipped: boolean;\n /** length of the clip without the gaps */\n durationMs: number;\n segments: number;\n /** recording gaps inside the range (skipped in the clip) */\n gaps: [number, number][];\n estBytes: number;\n filename: string;\n}\n\nexport type SentinelExportState = 'running' | 'done' | 'failed' | 'cancelled';\n\n/** `GET api/export-status`. */\nexport interface SentinelExportStatus {\n id: string;\n state: SentinelExportState;\n /** 0 … 1 */\n progress: number;\n bytes?: number;\n filename: string;\n error?: string;\n /** done: the file is deleted after this (ms) */\n expiresAt?: number;\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.0.2.10: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, prefix = ''): string {\n return `${origin.replace(/\\/+$/, '')}${prefix.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).\n * `prefix` = reverse-proxy path prefix (`SentinelSetup.prefix`), as for the request base. */\nexport function sentinelEntryUrl(origin: string, prefix = ''): string {\n return sentinelPublicBase(origin, prefix);\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 cost an extra preflight round trip; the\n * plugin answers OPTIONS since 2026-09-12, builds before that did not;\n * `<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, prefix = ''): string {\n const q = atMs ? `?at=${Math.round(atMs)}` : '';\n return `${sentinelEntryUrl(origin, prefix)}#/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/** Which class of a multi-class event matters most (a cyclist is a person first). Servers from plugin 1.3.0 send\n * `classes` in this order; older ones sent them alphabetically — the helpers below sort themselves. */\nexport const SENTINEL_CLASS_PRIORITY: readonly SentinelEventClass[] = [\n 'person',\n 'animal',\n 'bike',\n 'car',\n 'package',\n 'motion',\n];\n\n/** Distinct known classes of an event by priority (unknown classes count as `motion`) — 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 if (!out.length) out.push('motion');\n return out.sort((a, b) => SENTINEL_CLASS_PRIORITY.indexOf(a) - SENTINEL_CLASS_PRIORITY.indexOf(b));\n}\n\n/** Primary class of an event: its most important class (person > animal > bike > car > package), else `motion`. */\nexport function sentinelClassOf(ev: { classes?: string[] | undefined }): SentinelEventClass {\n return sentinelClassesOf(ev)[0];\n}\n\n/** A class filter hides an event only when ALL of its classes are switched off (a cyclist stays visible with\n * „Fahrzeug“ off, because it is also a person). */\nexport function sentinelEventHidden(\n ev: { classes?: string[] | undefined },\n off: Partial<Record<SentinelEventClass, boolean>>,\n): boolean {\n return sentinelClassesOf(ev).every((c) => off[c]);\n}\n\n/** Shorter spans are drawn as a plain marker. */\nexport const SENTINEL_MIN_SPAN_MS = 3000;\n\n/**\n * An event as a time span (plugin ≥ 1.3.0): from its first sighting to the last movement of its objects — a running\n * event reaches up to `now`. Undefined for short events and for servers without `endTs`.\n */\nexport function sentinelEventSpan(\n ev: { timestamp?: number; ts?: number; startTs?: number; endTs?: number; open?: boolean },\n now = Date.now(),\n): { start: number; end: number; open: boolean } | undefined {\n const t = ev.timestamp ?? ev.ts ?? 0;\n const start = Math.min(ev.startTs ?? t, t);\n const open = !!ev.open;\n const end = open ? Math.max(now, ev.endTs ?? t) : ev.endTs;\n if (end === undefined || end - start < SENTINEL_MIN_SPAN_MS)\n return open ? { start, end: end ?? now, open } : undefined;\n return { start, end, open };\n}\n\n/** A span's length as m:ss (h:mm:ss from one hour). */\nexport function sentinelDuration(ms: number): string {\n const s = Math.max(0, Math.round(ms / 1000));\n const h = Math.floor(s / 3600),\n m = Math.floor((s % 3600) / 60),\n sec = String(s % 60).padStart(2, '0');\n return h ? `${h}:${String(m).padStart(2, '0')}:${sec}` : `${m}:${sec}`;\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 {\n s: number;\n e: number;\n}\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 {\n cur = { s: c.startTime, e };\n out.push(cur);\n }\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[];\n events: SentinelEvent[];\n motion: [number, number][];\n codecs: string | null;\n oldestDay: number | null;\n} {\n const keys = Object.keys(days)\n .map(Number)\n .sort((a, b) => a - b);\n const clips = new Map<string, SentinelClip>(),\n 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\nconst bytesFmt = new Map<string, Intl.NumberFormat | null>();\n/** Fixed-decimals number in a locale (\"7,7\" in German, \"7.7\" in English); an unknown tag falls back to toFixed. */\nfunction fixedIn(n: number, digits: number, locale: string): string {\n const key = `${locale}|${digits}`;\n let f = bytesFmt.get(key);\n if (f === undefined) {\n try {\n f = new Intl.NumberFormat(locale, { minimumFractionDigits: digits, maximumFractionDigits: digits });\n } catch {\n f = null;\n }\n bytesFmt.set(key, f);\n }\n return f ? f.format(n) : n.toFixed(digits);\n}\n\n/** Human-readable byte size split into value + unit (binary steps). With `locale` the value carries that language's\n * decimal separator (de \"7,7\", en \"7.7\"); without it, a plain decimal point as before. */\nexport function sentinelHumanBytes(b: number, locale?: string): { 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 const n = b / Math.pow(1024, i),\n digits = i ? 1 : 0;\n return { value: locale ? fixedIn(n, digits, locale) : n.toFixed(digits), 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 {\n sentinelPublicBase,\n sentinelEntryUrl,\n sentinelUrl,\n type SentinelExportStart,\n type SentinelExportStatus,\n} 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 * @param opts.prefix reverse-proxy path prefix (`SentinelSetup.prefix`): goes into the default base and into\n * `entryUrl` — an overridden `base` does not tell it (it may be the login path), so pass both behind a proxy.\n */\n constructor(origin: string, token: string, opts: { base?: string; prefix?: string } = {}) {\n this.origin = origin;\n this.token = token;\n const prefix = opts.prefix ?? '';\n this.base = opts.base ? opts.base.replace(/\\/*$/, '/') : sentinelPublicBase(origin, prefix);\n this.entryUrl = sentinelEntryUrl(origin, prefix);\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 await httpError(r, path);\n return (await r.json()) as T;\n }\n\n /** JSON POST (parameters in the query, no body) with a timeout; 204 resolves `undefined`. Errors like `getJson`,\n * a network error as status 0. */\n async postJson<T>(path: string, timeoutMs = 10_000): Promise<T> {\n let r: Response;\n try {\n r = await fetch(this.url(path), { method: 'POST', cache: 'no-store', signal: timeoutSignal(timeoutMs) });\n } catch {\n throw new SentinelHttpError(0, path);\n }\n if (!r.ok) throw await httpError(r, path);\n if (r.status === 204) return undefined as T;\n return (await r.json()) as T;\n }\n\n // ---- clip export (plugin with `features: [\"export\"]`, its docs/API.md) ----\n /** Start an export job for [from, to] (ms). `tz` = the viewer's time zone (file name). Rejects with\n * `SentinelHttpError` (`code` = the server's `error`: 'bad range', 'no recording', 'too long', 'busy', …). */\n startExport(cameraId: string, from: number, to: number, tz?: string): Promise<SentinelExportStart> {\n const q =\n `api/export?camera=${encodeURIComponent(cameraId)}&from=${Math.round(from)}&to=${Math.round(to)}` +\n (tz ? `&tz=${encodeURIComponent(tz)}` : '');\n return this.postJson<SentinelExportStart>(q);\n }\n exportStatus(id: string): Promise<SentinelExportStatus> {\n return this.getJson<SentinelExportStatus>(`api/export-status?id=${encodeURIComponent(id)}`);\n }\n /** The finished file (`Content-Disposition: attachment`, Range). */\n exportFileUrl(id: string): string {\n return this.url(`api/export-file?id=${encodeURIComponent(id)}`);\n }\n /** Stop a running job / drop its file. Best effort: resolves false on any failure. */\n async cancelExport(id: string): Promise<boolean> {\n try {\n await this.postJson<void>(`api/export-cancel?id=${encodeURIComponent(id)}`, 5000);\n return true;\n } catch {\n return false;\n }\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, timeoutMs = 8000): Promise<boolean> {\n try {\n // bounded: a hanging control request kept the player's \"one in flight\" gate closed for good\n const r = await fetch(this.url(path), { cache: 'no-store', signal: timeoutSignal(timeoutMs) });\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(() => {\n /* telemetry only */\n });\n } catch {\n /* ignore */\n }\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 /** `width` = resized picture (plugin ≥ 2026-09-27, older ones ignore it and send the camera's original) */\n snapshotUrl(cameraId: string, bust?: number, width?: number): string {\n return (\n this.url(`api/snapshot?camera=${encodeURIComponent(cameraId)}`) +\n (width ? `&w=${Math.round(width)}` : '') +\n (bust != null ? `&_=${bust}` : '')\n );\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 /** the server's `error` from a JSON error body (e.g. 'busy'); undefined for plain-text answers and network errors */\n readonly code: string | undefined;\n /** the whole JSON error body (extra fields like `at` or `maxMs`) */\n readonly body: Record<string, unknown> | undefined;\n constructor(status: number, path: string, code?: string, body?: Record<string, unknown>) {\n super(`${status} ${path}${code ? ` (${code})` : ''}`);\n this.name = 'SentinelHttpError';\n this.status = status;\n this.code = code;\n this.body = body;\n }\n}\n\n/** Error for a non-ok answer: reads `{error}` when the body is JSON (the export routes), else the status only. */\nasync function httpError(r: Response, path: string): Promise<SentinelHttpError> {\n let body: Record<string, unknown> | undefined;\n try {\n if ((r.headers.get('content-type') || '').includes('json')) {\n const j: unknown = await r.json();\n if (j && typeof j === 'object' && !Array.isArray(j)) body = j as Record<string, unknown>;\n }\n } catch {\n /* not JSON after all */\n }\n const code = typeof body?.error === 'string' ? body.error : undefined;\n return new SentinelHttpError(r.status, path, code, body);\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(\n origin: string,\n username: string,\n password: string,\n timeoutMs = 10_000,\n prefix = '',\n): 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',\n cache: 'no-store',\n signal: AbortSignal.timeout(timeoutMs),\n headers: { 'Content-Type': 'application/json' },\n 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/** AbortSignal that fires after `ms` (undefined on engines without AbortSignal.timeout — Safari < 16). */\nexport function timeoutSignal(ms: number): AbortSignal | undefined {\n return typeof AbortSignal !== 'undefined' && typeof AbortSignal.timeout === 'function'\n ? AbortSignal.timeout(ms)\n : undefined;\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/**\n * Day in front of a time where \"HH:MM\" alone is ambiguous: '' on the viewer's today (and for a clock running a bit\n * ahead), the locale's word for yesterday (\"gestern\", \"yesterday\", \"i går\" — Intl, no dictionary key), else a short\n * numeric date (\"3.10.\", \"10/3\"). Calendar days of the viewer's time zone, so DST days (23/25 h) count as one day.\n */\nexport function fmtDayPrefix(ts: number, locale: string, now: number = Date.now()): string {\n const day = new Date(ts).setHours(0, 0, 0, 0);\n const today = new Date(now).setHours(0, 0, 0, 0);\n if (day >= today) return '';\n const y = new Date(today);\n y.setDate(y.getDate() - 1);\n if (day === y.getTime()) return new Intl.RelativeTimeFormat(locale, { numeric: 'auto' }).format(-1, 'day');\n return new Intl.DateTimeFormat(locale, { day: 'numeric', month: 'numeric' }).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\nconst countFmt = new Map<string, Intl.NumberFormat | null>();\n/** A whole number with the locale's digit grouping (\"48.210\" in German, \"48,210\" in English); an unknown tag falls\n * back to the plain digits. */\nexport function fmtCount(n: number, locale: string): string {\n let f = countFmt.get(locale);\n if (f === undefined) {\n try {\n f = new Intl.NumberFormat(locale, { maximumFractionDigits: 0 });\n } catch {\n f = null;\n }\n countFmt.set(locale, f);\n }\n return f ? f.format(n) : String(Math.round(n));\n}\n"],"mappings":";AAgBO,IAAM,yBAAwD;AAAA,EACnE;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AACF;AAyDO,SAAS,uBACd,KACwB;AACxB,MAAI,CAAC,IAAI,UAAW,QAAO;AAC3B,MAAI,IAAI,QAAS,QAAO;AACxB,SAAO,IAAI,SAAS,OAAO;AAC7B;AA2FO,SAAS,mBACd,GACA,SACS;AACT,SAAO,MAAM,QAAQ,GAAG,QAAQ,KAAK,EAAE,SAAS,SAAS,OAAO;AAClE;AAmCO,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,MAAM,KAAK,IAAI,MAAM,KAAK,IAAI,MAAM,OAAO;AACxF;AAGO,SAAS,mBA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,OAAO,QAAQ,MAAM,UAAU,CAAC,EAAE,OAAO,EAAE;AACtF;AAGO,SAAS,cAAc,QAA0B;AACtD,QAAM,IAAI,IAAI,KAAK,eAAe,QAAQ,EAAE,SAAS,QAAQ,CAAC;AAE9D,SAAO,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;AAEA,IAAM,WAAW,oBAAI,IAAsC;AAGpD,SAAS,SAAS,GAAW,QAAwB;AAC1D,MAAI,IAAI,SAAS,IAAI,MAAM;AAC3B,MAAI,MAAM,QAAW;AACnB,QAAI;AACF,UAAI,IAAI,KAAK,aAAa,QAAQ,EAAE,uBAAuB,EAAE,CAAC;AAAA,IAChE,QAAQ;AACN,UAAI;AAAA,IACN;AACA,aAAS,IAAI,QAAQ,CAAC;AAAA,EACxB;AACA,SAAO,IAAI,EAAE,OAAO,CAAC,IAAI,OAAO,KAAK,MAAM,CAAC,CAAC;AAC/C;","names":[]}
|
|
@@ -10,6 +10,39 @@
|
|
|
10
10
|
type SentinelEventClass = 'person' | 'car' | 'bike' | 'animal' | 'package' | 'motion';
|
|
11
11
|
declare const SENTINEL_EVENT_CLASSES: readonly SentinelEventClass[];
|
|
12
12
|
type SentinelBox = [number, number, number, number];
|
|
13
|
+
/** `api/cameras[].detection` (plugin ≥ 1.3.0): is object detection really working? */
|
|
14
|
+
interface SentinelDetection {
|
|
15
|
+
/** ok | stalled (no frames for > 10 s) | error (also: engine hangs) | no-engine (camera's own detector or motion only)
|
|
16
|
+
* | off (detection or recording switched off) */
|
|
17
|
+
state: 'ok' | 'stalled' | 'error' | 'no-engine' | 'off';
|
|
18
|
+
/** engine | camera | motion | none — may be absent when switched off */
|
|
19
|
+
mode?: string;
|
|
20
|
+
fps?: number;
|
|
21
|
+
lastFrameAgoMs?: number;
|
|
22
|
+
model?: string;
|
|
23
|
+
/** share of the shared Coral: level 0 (unthrottled) … 4 */
|
|
24
|
+
coral?: {
|
|
25
|
+
level: number;
|
|
26
|
+
rate: number;
|
|
27
|
+
share: number;
|
|
28
|
+
waitP95: number;
|
|
29
|
+
shed: number;
|
|
30
|
+
};
|
|
31
|
+
/** plugin ≥ 2026-10-01: engine watchdog; `down` = hung / being reloaded, nothing analysed */
|
|
32
|
+
engine?: {
|
|
33
|
+
state: 'ok' | 'suspect' | 'down';
|
|
34
|
+
downForMs?: number;
|
|
35
|
+
reloads?: number;
|
|
36
|
+
};
|
|
37
|
+
/** plugin ≥ 2026-10-01: spans not analysed live, still to be analysed from the recordings */
|
|
38
|
+
gaps?: {
|
|
39
|
+
pending: number;
|
|
40
|
+
pendingMs: number;
|
|
41
|
+
/** only during an outage going on right now: since when, and why */
|
|
42
|
+
openForMs?: number;
|
|
43
|
+
reason?: 'engine' | 'feed' | 'restart' | 'manual';
|
|
44
|
+
};
|
|
45
|
+
}
|
|
13
46
|
/** `api/cameras` entry. */
|
|
14
47
|
interface SentinelCamera {
|
|
15
48
|
id: string;
|
|
@@ -28,6 +61,8 @@ interface SentinelCamera {
|
|
|
28
61
|
latestTs?: number;
|
|
29
62
|
/** RFC-6381 codec string of the recordings (MSE). */
|
|
30
63
|
codecs?: string;
|
|
64
|
+
/** plugin ≥ 1.3.0: state of the object detection */
|
|
65
|
+
detection?: SentinelDetection;
|
|
31
66
|
}
|
|
32
67
|
/**
|
|
33
68
|
* Recording state of a camera tile: `off` = recording switched off, `stalled` = recording hangs (watchdog, outranks
|
|
@@ -51,8 +86,9 @@ interface SentinelStats {
|
|
|
51
86
|
minFreeBytes: number;
|
|
52
87
|
/** plugin ≥ 2026-09-26: storage root usable (storage guard); false = not recording, nothing deleted. */
|
|
53
88
|
storageOk?: boolean;
|
|
54
|
-
/** why not: 'marker' (share not mounted), 'missing', 'error', 'timeout'
|
|
55
|
-
|
|
89
|
+
/** why not: 'marker' (share not mounted), 'missing', 'error' (file system error), 'timeout' (hung mount); treat a
|
|
90
|
+
* value a newer plugin may add like 'error' */
|
|
91
|
+
storageProblem?: 'missing' | 'marker' | 'error' | 'timeout';
|
|
56
92
|
/** optional server features (plugin ≥ 2026-10-06: `"export"` = clip export, `api/export*`) */
|
|
57
93
|
features?: string[];
|
|
58
94
|
}
|
|
@@ -91,6 +127,8 @@ interface SentinelEvent {
|
|
|
91
127
|
endTs?: number;
|
|
92
128
|
/** plugin ≥ 1.3.0: the event is still running (its objects are still there) */
|
|
93
129
|
open?: boolean;
|
|
130
|
+
/** plugin ≥ 2026-10-01: found afterwards in the recording (the live detection was not running then) */
|
|
131
|
+
backfill?: boolean;
|
|
94
132
|
}
|
|
95
133
|
/** Recording segment (`api/clips.clips`). */
|
|
96
134
|
interface SentinelClip {
|
|
@@ -110,6 +148,10 @@ interface SentinelClipsResponse {
|
|
|
110
148
|
/** optional server features (plugin ≥ 2026-10-06: `"export"` = clip export, `api/export*`) */
|
|
111
149
|
features?: string[];
|
|
112
150
|
}
|
|
151
|
+
/** `api/events-histogram`: today's events per hour of the viewer's day (index 0–23, `?tz=`). */
|
|
152
|
+
interface SentinelHistogram {
|
|
153
|
+
buckets: number[];
|
|
154
|
+
}
|
|
113
155
|
/** A server answer (`api/clips`, `api/stats`) announces `feature` — older plugins send no `features` at all. */
|
|
114
156
|
declare function sentinelHasFeature(r: {
|
|
115
157
|
features?: string[] | undefined;
|
|
@@ -388,4 +430,4 @@ declare function exchangeSentinelToken(origin: string, username: string, passwor
|
|
|
388
430
|
/** AbortSignal that fires after `ms` (undefined on engines without AbortSignal.timeout — Safari < 16). */
|
|
389
431
|
declare function timeoutSignal(ms: number): AbortSignal | undefined;
|
|
390
432
|
|
|
391
|
-
export {
|
|
433
|
+
export { parseSentinelSetup as A, sentinelAddDays as B, sentinelAtTime as C, sentinelClassOf as D, sentinelClassesOf as E, sentinelClipIndexFor as F, sentinelClipRuns as G, sentinelDayEnd as H, sentinelDayOf as I, sentinelDuration as J, sentinelEntryUrl as K, sentinelEventHidden as L, sentinelEventPlayTs as M, sentinelEventSpan as N, sentinelHasFeature as O, sentinelHumanBytes as P, sentinelLoginBase as Q, sentinelMergeDays as R, SENTINEL_CLASS_PRIORITY as S, sentinelPublicBase as T, sentinelRecordingState as U, sentinelStorageForecast as V, sentinelTimelineLink as W, sentinelUrl as X, sentinelWallMarks as Y, sentinelWallSeconds as Z, timeoutSignal as _, SENTINEL_DAY_MS as a, SENTINEL_ENDPOINT_PATH as b, SENTINEL_EVENT_CLASSES as c, SENTINEL_MIN_SPAN_MS as d, type SentinelBox as e, type SentinelCamera as f, SentinelClient as g, type SentinelClip as h, type SentinelClipsResponse as i, type SentinelDetection as j, type SentinelEvent as k, type SentinelEventBox as l, type SentinelEventClass as m, type SentinelExportStart as n, type SentinelExportState as o, type SentinelExportStatus as p, type SentinelHistogram as q, SentinelHttpError as r, type SentinelRecentEvent as s, type SentinelRecordingState as t, type SentinelRun as u, type SentinelSetup as v, type SentinelStats as w, type SentinelStorageForecast as x, type SentinelStorageStatus as y, exchangeSentinelToken as z };
|
package/dist/player/index.d.ts
CHANGED
|
@@ -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-
|
|
2
|
-
import { g as SentinelClient } from '../client-
|
|
1
|
+
export { P as PipResult, a as PlayerController, b as PlayerLabel, c as PlayerOptions, d as PlayerRefs, e as PlayerState } from '../controller-DwyUCzWR.js';
|
|
2
|
+
import { g as SentinelClient } from '../client-BZP21uB4.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. */
|
package/dist/player/index.js
CHANGED
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 { g as SentinelClient,
|
|
4
|
-
import { e as PlayerState } from '../controller-
|
|
3
|
+
import { g as SentinelClient, m as SentinelEventClass, s as SentinelRecentEvent, f as SentinelCamera, k as SentinelEvent, w as SentinelStats, h as SentinelClip } from '../client-BZP21uB4.js';
|
|
4
|
+
import { e as PlayerState } from '../controller-DwyUCzWR.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Minimal translation core with the same dictionary semantics as HAPulse:
|
|
@@ -356,8 +356,16 @@ interface CameraPageProps {
|
|
|
356
356
|
/** media elements load with CORS (a cross-origin host needs it for canvas snapshots) */
|
|
357
357
|
crossOrigin?: boolean | undefined;
|
|
358
358
|
/** rendered above the two columns — the host's page header (see `CameraTitle`). As a function it gets the playback
|
|
359
|
-
* position (`at`, ms; `undefined` while live), e.g. for a link that opens this camera at the same moment elsewhere
|
|
360
|
-
|
|
359
|
+
* position (`at`, ms; `undefined` while live), e.g. for a link that opens this camera at the same moment elsewhere,
|
|
360
|
+
* and whether the page shows live (`info.live`; `at` may also be `undefined` when no position is known yet, e.g.
|
|
361
|
+
* while a recording session starts). */
|
|
362
|
+
header?: ReactNode | ((at: number | undefined, info: CameraHeaderInfo) => ReactNode);
|
|
363
|
+
/** `'immersive'`: the picture edge to edge with the header over it on phones, controls as floating capsules, the
|
|
364
|
+
* tabs as a segment (`data-nvr-appearance="immersive"` on the page; meant for dark tokens, the host scopes them).
|
|
365
|
+
* The host can style the floating parts through `--nvr-ctl-*`, `--nvr-float-*`, `--nvr-seg-*`, `--nvr-live-*`,
|
|
366
|
+
* `--nvr-shade-top`/`-bottom` and `--nvr-ease`/`--nvr-dur` (README).
|
|
367
|
+
* Default `'default'`: the page as before. */
|
|
368
|
+
appearance?: 'default' | 'immersive' | undefined;
|
|
361
369
|
/** the host wraps the date picker in its own modal primitive */
|
|
362
370
|
renderDatePicker: (req: DatePickerRequest) => ReactNode;
|
|
363
371
|
/** This camera outside the app (Sentinel's public entry, no token). Offered as "open in Safari" when a Home-Screen
|
|
@@ -365,11 +373,20 @@ interface CameraPageProps {
|
|
|
365
373
|
* gets the playback position like `header` (`sentinelTimelineLink(origin, id, at)`), so Safari continues there. */
|
|
366
374
|
externalUrl?: string | ((at: number | undefined) => string) | undefined;
|
|
367
375
|
}
|
|
368
|
-
/**
|
|
369
|
-
|
|
376
|
+
/** What a `header` function gets besides the playback position. */
|
|
377
|
+
interface CameraHeaderInfo {
|
|
378
|
+
/** the page shows live */
|
|
379
|
+
live: boolean;
|
|
380
|
+
}
|
|
381
|
+
/** Host header row: back button + camera name (+ host actions on the right). Same metrics in every host.
|
|
382
|
+
* `live` / `at` (from the `header` function) add a badge next to the name: "LIVE", or the time of the picture
|
|
383
|
+
* (with "yesterday" or a short date in front on another day); without them the row is as before. */
|
|
384
|
+
declare function CameraTitle({ name, onBack, children, live, at, }: {
|
|
370
385
|
name: string;
|
|
371
386
|
onBack: () => void;
|
|
372
387
|
children?: ReactNode;
|
|
388
|
+
live?: boolean | undefined;
|
|
389
|
+
at?: number | undefined;
|
|
373
390
|
}): react.JSX.Element;
|
|
374
391
|
|
|
375
392
|
declare function CameraPage(p: CameraPageProps): react.JSX.Element;
|
|
@@ -402,4 +419,4 @@ declare function ThemeSwatch({ name, active, previewMode, onClick, ariaLabel, }:
|
|
|
402
419
|
}): react.JSX.Element;
|
|
403
420
|
declare function AppearanceSection(p: AppearanceProps): react.JSX.Element;
|
|
404
421
|
|
|
405
|
-
export { type AppearanceProps, AppearanceSection, CameraGrid, CameraPage, type CameraPageProps, CameraTiles, CameraTitle, CardTitle, ClassBadge, DatePickerPanel, type DatePickerPanelProps, type DatePickerRequest, type Dict, EventBadges, EventList, EventsStrip, Hero, HistogramCard, type ResolvedMode, type ScrubHandlers, type SentinelUiNav, SentinelUiProvider, type SentinelUiValue, StatTile, StorageCard, type TFn, THEMES, THEME_LABELS, THEME_NAMES, TOKEN_TO_VAR, type ThemeMode, type ThemeName, ThemeSwatch, type ThemeTokens, type TileSnapshot, type TimelineProps, type Tone, UI_LOCALES, UI_LOCALE_LABELS, type UiLocale, VerticalTimeline, accentOverride, applyTheme, classLabel, createT, dateChipNav, eventLabel, fmtDays, fmtRelative, hexHue, humanBytes, interpolate, isIosHomeScreenApp, isThemeName, outsideAppHref, pickLocale, rememberTileSnapshot, resolveMode, resolveThemeMode, stageStatus, tileSnapshotWidth, translate, useDatePicker, useSentinelUi, watchSystemMode };
|
|
422
|
+
export { type AppearanceProps, AppearanceSection, CameraGrid, type CameraHeaderInfo, CameraPage, type CameraPageProps, CameraTiles, CameraTitle, CardTitle, ClassBadge, DatePickerPanel, type DatePickerPanelProps, type DatePickerRequest, type Dict, EventBadges, EventList, EventsStrip, Hero, HistogramCard, type ResolvedMode, type ScrubHandlers, type SentinelUiNav, SentinelUiProvider, type SentinelUiValue, StatTile, StorageCard, type TFn, THEMES, THEME_LABELS, THEME_NAMES, TOKEN_TO_VAR, type ThemeMode, type ThemeName, ThemeSwatch, type ThemeTokens, type TileSnapshot, type TimelineProps, type Tone, UI_LOCALES, UI_LOCALE_LABELS, type UiLocale, VerticalTimeline, accentOverride, applyTheme, classLabel, createT, dateChipNav, eventLabel, fmtDays, fmtRelative, hexHue, humanBytes, interpolate, isIosHomeScreenApp, isThemeName, outsideAppHref, pickLocale, rememberTileSnapshot, resolveMode, resolveThemeMode, stageStatus, tileSnapshotWidth, translate, useDatePicker, useSentinelUi, watchSystemMode };
|
package/dist/ui/index.js
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import {
|
|
2
2
|
PlayerController,
|
|
3
3
|
rlog
|
|
4
|
-
} from "../chunk-
|
|
4
|
+
} from "../chunk-7W5ORHOB.js";
|
|
5
5
|
import {
|
|
6
6
|
SENTINEL_CLASS_PRIORITY,
|
|
7
7
|
SENTINEL_DAY_MS,
|
|
8
8
|
SENTINEL_EVENT_CLASSES,
|
|
9
9
|
SentinelHttpError,
|
|
10
|
+
fmtCount,
|
|
10
11
|
fmtDay,
|
|
11
12
|
fmtDayPrefix,
|
|
12
13
|
fmtMonthYear,
|
|
@@ -33,7 +34,7 @@ import {
|
|
|
33
34
|
sentinelWallMarks,
|
|
34
35
|
sentinelWallSeconds,
|
|
35
36
|
weekdayShorts
|
|
36
|
-
} from "../chunk-
|
|
37
|
+
} from "../chunk-P7VKKFVA.js";
|
|
37
38
|
|
|
38
39
|
// src/ui/context.tsx
|
|
39
40
|
import { createContext, useContext } from "react";
|
|
@@ -859,7 +860,7 @@ function Hero({ cameras, stats }) {
|
|
|
859
860
|
/* @__PURE__ */ jsx7(Zap, { size: 14, strokeWidth: 2 }),
|
|
860
861
|
t("nvr.hero.eventsToday")
|
|
861
862
|
] }),
|
|
862
|
-
/* @__PURE__ */ jsx7("span", { className: "nvr-hero__primary-value nvr-data", children: stats.eventsToday })
|
|
863
|
+
/* @__PURE__ */ jsx7("span", { className: "nvr-hero__primary-value nvr-data", children: fmtCount(stats.eventsToday, locale) })
|
|
863
864
|
] }),
|
|
864
865
|
/* @__PURE__ */ jsxs5("div", { className: "nvr-hero__stats", children: [
|
|
865
866
|
/* @__PURE__ */ jsx7(
|
|
@@ -1026,7 +1027,7 @@ function StorageCard({ stats }) {
|
|
|
1026
1027
|
] }),
|
|
1027
1028
|
/* @__PURE__ */ jsxs5("li", { children: [
|
|
1028
1029
|
/* @__PURE__ */ jsx7("span", { children: t("nvr.storage.segments") }),
|
|
1029
|
-
/* @__PURE__ */ jsx7("b", { className: "nvr-data", children: stats.segments })
|
|
1030
|
+
/* @__PURE__ */ jsx7("b", { className: "nvr-data", children: fmtCount(stats.segments, locale) })
|
|
1030
1031
|
] })
|
|
1031
1032
|
] }),
|
|
1032
1033
|
/* @__PURE__ */ jsx7("p", { className: `nvr-note${fc.status === "unreachable" ? " nvr-note--warn" : ""}`, children: note })
|
|
@@ -1569,6 +1570,7 @@ var CLIP_AROUND_MS = 3e4;
|
|
|
1569
1570
|
var CLIP_LIVE_MS = 6e4;
|
|
1570
1571
|
var CLIP_GAP_MS = 2e3;
|
|
1571
1572
|
var CLIP_SHARE_MAX = 100 * 1024 * 1024;
|
|
1573
|
+
var CLIP_BLOB_MAX = CLIP_SHARE_MAX;
|
|
1572
1574
|
var CLIP_POLL_MS = 700;
|
|
1573
1575
|
var CLIP_POLL_GIVEUP_MS = 6e4;
|
|
1574
1576
|
function clipRangeForEvent(ev, now = Date.now()) {
|
|
@@ -1658,12 +1660,22 @@ function fmtClipTime(ts, locale) {
|
|
|
1658
1660
|
}
|
|
1659
1661
|
}
|
|
1660
1662
|
function clipWays(s) {
|
|
1661
|
-
const
|
|
1663
|
+
const known = s.bytes > 0;
|
|
1664
|
+
const fits = known && s.bytes <= CLIP_SHARE_MAX;
|
|
1662
1665
|
if (s.standalone)
|
|
1663
1666
|
return fits ? { prefetch: true, share: s.canShareFiles, save: "blob" } : { prefetch: false, share: false, save: "safari" };
|
|
1667
|
+
if (s.crossOrigin)
|
|
1668
|
+
return known && s.bytes <= CLIP_BLOB_MAX ? { prefetch: true, share: fits && s.canShareFiles, save: "blob" } : { prefetch: false, share: false, save: "tab" };
|
|
1664
1669
|
if (fits && s.canShareFiles) return { prefetch: true, share: true, save: "link" };
|
|
1665
1670
|
return { prefetch: false, share: false, save: "link" };
|
|
1666
1671
|
}
|
|
1672
|
+
function isCrossOrigin(url, base = typeof location !== "undefined" ? location.href : "") {
|
|
1673
|
+
try {
|
|
1674
|
+
return new URL(url, base).origin !== new URL(base).origin;
|
|
1675
|
+
} catch {
|
|
1676
|
+
return false;
|
|
1677
|
+
}
|
|
1678
|
+
}
|
|
1667
1679
|
function clipErrorKind(status, code) {
|
|
1668
1680
|
if (code === "busy" || status === 429) return "busy";
|
|
1669
1681
|
if (code === "no space" || status === 507) return "noSpace";
|
|
@@ -1763,7 +1775,8 @@ function ClipBar(p) {
|
|
|
1763
1775
|
);
|
|
1764
1776
|
const finish = useCallback(
|
|
1765
1777
|
async (g, d) => {
|
|
1766
|
-
const
|
|
1778
|
+
const crossOrigin = isCrossOrigin(client.exportFileUrl(d.id));
|
|
1779
|
+
const ways = clipWays({ bytes: d.bytes, canShareFiles: canShareFiles(), standalone, crossOrigin });
|
|
1767
1780
|
if (!ways.prefetch) {
|
|
1768
1781
|
setJob({ s: "ready", ...d, ways });
|
|
1769
1782
|
return;
|
|
@@ -1789,9 +1802,10 @@ function ClipBar(p) {
|
|
|
1789
1802
|
err: "prefetch",
|
|
1790
1803
|
msg: String(e?.message ?? e).slice(0, 80),
|
|
1791
1804
|
bytes: d.bytes,
|
|
1792
|
-
standalone
|
|
1805
|
+
standalone,
|
|
1806
|
+
xo: crossOrigin
|
|
1793
1807
|
});
|
|
1794
|
-
setJob({ s: "ready", ...d, ways: { prefetch: false, share: false, save: "link" } });
|
|
1808
|
+
setJob({ s: "ready", ...d, ways: { prefetch: false, share: false, save: crossOrigin ? "tab" : "link" } });
|
|
1795
1809
|
} finally {
|
|
1796
1810
|
if (abort.current === ac) abort.current = null;
|
|
1797
1811
|
}
|
|
@@ -1993,7 +2007,20 @@ function ClipBar(p) {
|
|
|
1993
2007
|
onClick: () => log("blob"),
|
|
1994
2008
|
children: t("nvr.clip.save")
|
|
1995
2009
|
}
|
|
1996
|
-
) : /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-btn nvr-btn--primary", disabled: true, children: t("nvr.clip.save") }) :
|
|
2010
|
+
) : /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-btn nvr-btn--primary", disabled: true, children: t("nvr.clip.save") }) : ready.ways.save === "tab" ? (
|
|
2011
|
+
// another origin, too large for the page: a new tab saves it (attachment), the host page stays
|
|
2012
|
+
/* @__PURE__ */ jsx9(
|
|
2013
|
+
"a",
|
|
2014
|
+
{
|
|
2015
|
+
className: "nvr-btn nvr-btn--primary",
|
|
2016
|
+
href: fileUrl,
|
|
2017
|
+
target: "_blank",
|
|
2018
|
+
rel: "noopener noreferrer",
|
|
2019
|
+
onClick: () => log("tab"),
|
|
2020
|
+
children: t("nvr.clip.save")
|
|
2021
|
+
}
|
|
2022
|
+
)
|
|
2023
|
+
) : /* @__PURE__ */ jsx9(
|
|
1997
2024
|
"a",
|
|
1998
2025
|
{
|
|
1999
2026
|
className: "nvr-btn nvr-btn--primary",
|
|
@@ -2085,12 +2112,24 @@ var IDLE = {
|
|
|
2085
2112
|
muted: true
|
|
2086
2113
|
};
|
|
2087
2114
|
var todayStart = () => sentinelDayOf(Date.now());
|
|
2088
|
-
function CameraTitle({
|
|
2089
|
-
|
|
2115
|
+
function CameraTitle({
|
|
2116
|
+
name,
|
|
2117
|
+
onBack,
|
|
2118
|
+
children,
|
|
2119
|
+
live,
|
|
2120
|
+
at
|
|
2121
|
+
}) {
|
|
2122
|
+
const { t, locale } = useSentinelUi();
|
|
2123
|
+
const day = !live && at != null ? fmtDayPrefix(at, locale) : "";
|
|
2124
|
+
const badge = live ? /* @__PURE__ */ jsx10("span", { className: "nvr-cam__badge nvr-cam__badge--live", children: t("nvr.live") }) : at != null ? /* @__PURE__ */ jsx10("span", { className: "nvr-cam__badge nvr-cam__badge--time nvr-data", children: day ? `${day} ${fmtTimeSec(at, locale)}` : fmtTimeSec(at, locale) }) : null;
|
|
2125
|
+
const h1 = /* @__PURE__ */ jsx10("h1", { className: "nvr-cam__h1", children: name });
|
|
2090
2126
|
return /* @__PURE__ */ jsxs8("div", { className: "nvr-cam__head", children: [
|
|
2091
2127
|
/* @__PURE__ */ jsxs8("div", { className: "nvr-cam__title", children: [
|
|
2092
2128
|
/* @__PURE__ */ jsx10("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.back"), onClick: onBack, children: /* @__PURE__ */ jsx10(ChevronLeft2, { size: 20 }) }),
|
|
2093
|
-
/* @__PURE__ */
|
|
2129
|
+
badge ? /* @__PURE__ */ jsxs8("span", { className: "nvr-cam__name", children: [
|
|
2130
|
+
h1,
|
|
2131
|
+
badge
|
|
2132
|
+
] }) : h1
|
|
2094
2133
|
] }),
|
|
2095
2134
|
children ? /* @__PURE__ */ jsx10("div", { className: "nvr-cam__actions", children }) : null
|
|
2096
2135
|
] });
|
|
@@ -2514,9 +2553,10 @@ function CameraPage(p) {
|
|
|
2514
2553
|
const nav = dateChipNav(centerDay, oldestAllowed);
|
|
2515
2554
|
const cors = p.crossOrigin ? "anonymous" : void 0;
|
|
2516
2555
|
const at = !ps.live && ps.playhead != null ? ps.playhead : void 0;
|
|
2517
|
-
const header = typeof p.header === "function" ? p.header(at) : p.header;
|
|
2556
|
+
const header = typeof p.header === "function" ? p.header(at, { live: ps.live }) : p.header;
|
|
2557
|
+
const immersive = p.appearance === "immersive";
|
|
2518
2558
|
const externalUrl = typeof p.externalUrl === "function" ? p.externalUrl(at) : p.externalUrl;
|
|
2519
|
-
return /* @__PURE__ */ jsxs8("div", { className: "nvr-cam", children: [
|
|
2559
|
+
return /* @__PURE__ */ jsxs8("div", { className: "nvr-cam", "data-nvr-appearance": immersive ? "immersive" : void 0, children: [
|
|
2520
2560
|
header,
|
|
2521
2561
|
/* @__PURE__ */ jsxs8("div", { className: "nvr-cam__body" + (clip ? " nvr-cam__body--clip" : ""), ref: body, children: [
|
|
2522
2562
|
/* @__PURE__ */ jsx10("div", { className: "nvr-cam__left", children: /* @__PURE__ */ jsxs8("div", { className: "nvr-card nvr-stage-card", children: [
|
|
@@ -2652,7 +2692,7 @@ function CameraPage(p) {
|
|
|
2652
2692
|
] })
|
|
2653
2693
|
] }) }),
|
|
2654
2694
|
/* @__PURE__ */ jsxs8("aside", { className: "nvr-card nvr-cam__right" + (clip ? " nvr-cam__right--clip" : ""), children: [
|
|
2655
|
-
/* @__PURE__ */ jsxs8("div", { className: "nvr-tabs", role: "tablist", children: [
|
|
2695
|
+
/* @__PURE__ */ jsxs8("div", { className: "nvr-tabs", role: "tablist", "data-active": immersive ? tab : void 0, children: [
|
|
2656
2696
|
/* @__PURE__ */ jsx10(
|
|
2657
2697
|
"button",
|
|
2658
2698
|
{
|