@sentinel-nvr/web 0.13.0 → 0.14.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui/index.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  PlayerController,
3
3
  rlog
4
- } from "../chunk-6UEIHAAJ.js";
4
+ } from "../chunk-3XHGDU27.js";
5
5
  import {
6
6
  SENTINEL_DAY_MS,
7
7
  SENTINEL_EVENT_CLASSES,
@@ -24,7 +24,7 @@ import {
24
24
  sentinelWallMarks,
25
25
  sentinelWallSeconds,
26
26
  weekdayShorts
27
- } from "../chunk-UBLIUYEA.js";
27
+ } from "../chunk-365BAYXD.js";
28
28
 
29
29
  // src/ui/context.tsx
30
30
  import { createContext, useContext } from "react";
@@ -581,6 +581,24 @@ function CameraGrid({ cameras }) {
581
581
  ] });
582
582
  }
583
583
 
584
+ // src/ui/outside.ts
585
+ function isIosHomeScreenApp(nav = globalThis.navigator ?? {}) {
586
+ return nav.standalone === true;
587
+ }
588
+ function iosMajor(ua = globalThis.navigator?.userAgent ?? "") {
589
+ const m = /\bOS (\d+)[_.]\d+.* like Mac OS X/.exec(ua);
590
+ return m ? Number(m[1]) : null;
591
+ }
592
+ function outsideAppHref(url, env = {
593
+ standalone: globalThis.navigator?.standalone,
594
+ userAgent: globalThis.navigator?.userAgent
595
+ }) {
596
+ if (!isIosHomeScreenApp(env) || !/^https?:\/\//i.test(url)) return url;
597
+ const major = iosMajor(env.userAgent ?? "");
598
+ if (major !== null && major < 17) return url;
599
+ return "x-safari-" + url;
600
+ }
601
+
584
602
  // src/ui/components/EventList.tsx
585
603
  import { Fragment as Fragment2 } from "react";
586
604
  import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
@@ -1332,7 +1350,8 @@ import {
1332
1350
  Play,
1333
1351
  Rewind,
1334
1352
  Volume2,
1335
- VolumeX
1353
+ VolumeX,
1354
+ X
1336
1355
  } from "lucide-react";
1337
1356
 
1338
1357
  // src/ui/camera-logic.ts
@@ -1398,6 +1417,20 @@ function CameraPage(p) {
1398
1417
  const [ps, setPs] = useState4(IDLE);
1399
1418
  const [loadError, setLoadError] = useState4(false);
1400
1419
  const [dt, setDt] = useState4(false);
1420
+ const [pipNote, setPipNote] = useState4(null);
1421
+ useEffect3(() => {
1422
+ if (!pipNote) return;
1423
+ const i = setTimeout(() => setPipNote(null), 15e3);
1424
+ return () => clearTimeout(i);
1425
+ }, [pipNote]);
1426
+ const onPip = useCallback(() => {
1427
+ const c = ctl.current;
1428
+ if (!c) return;
1429
+ void c.pip().then((r) => {
1430
+ if (r === "unsupported") setPipNote(isIosHomeScreenApp() ? "homescreen" : "unsupported");
1431
+ else if (r === "entered") setPipNote(null);
1432
+ });
1433
+ }, []);
1401
1434
  const body = useRef2(null);
1402
1435
  const stage = useRef2(null);
1403
1436
  const video = useRef2(null);
@@ -1744,16 +1777,7 @@ function CameraPage(p) {
1744
1777
  children: /* @__PURE__ */ jsx9(Camera2, { size: 16 })
1745
1778
  }
1746
1779
  ),
1747
- /* @__PURE__ */ jsx9(
1748
- "button",
1749
- {
1750
- type: "button",
1751
- className: "nvr-iconbtn",
1752
- "aria-label": t("nvr.player.pip"),
1753
- onClick: () => ctl.current?.pip(),
1754
- children: /* @__PURE__ */ jsx9(PictureInPicture2, { size: 16 })
1755
- }
1756
- ),
1780
+ /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-iconbtn", "aria-label": t("nvr.player.pip"), onClick: onPip, children: /* @__PURE__ */ jsx9(PictureInPicture2, { size: 16 }) }),
1757
1781
  /* @__PURE__ */ jsx9(
1758
1782
  "button",
1759
1783
  {
@@ -1765,6 +1789,30 @@ function CameraPage(p) {
1765
1789
  }
1766
1790
  )
1767
1791
  ] })
1792
+ ] }),
1793
+ pipNote && /* @__PURE__ */ jsxs7("div", { className: "nvr-pipnote", role: "status", children: [
1794
+ /* @__PURE__ */ jsx9("span", { children: t(pipNote === "homescreen" ? "nvr.player.pipHomeScreen" : "nvr.player.pipUnsupported") }),
1795
+ pipNote === "homescreen" && p.externalUrl && /* @__PURE__ */ jsx9(
1796
+ "a",
1797
+ {
1798
+ className: "nvr-pipnote__open",
1799
+ href: outsideAppHref(p.externalUrl),
1800
+ target: "_blank",
1801
+ rel: "noopener noreferrer",
1802
+ onClick: () => rlog("pip-outside", { href: outsideAppHref(p.externalUrl).split(":")[0] }),
1803
+ children: t("nvr.player.openInSafari")
1804
+ }
1805
+ ),
1806
+ /* @__PURE__ */ jsx9(
1807
+ "button",
1808
+ {
1809
+ type: "button",
1810
+ className: "nvr-iconbtn nvr-pipnote__close",
1811
+ "aria-label": t("nvr.player.dismiss"),
1812
+ onClick: () => setPipNote(null),
1813
+ children: /* @__PURE__ */ jsx9(X, { size: 14 })
1814
+ }
1815
+ )
1768
1816
  ] })
1769
1817
  ] }) }),
1770
1818
  /* @__PURE__ */ jsxs7("aside", { className: "nvr-card nvr-cam__right", children: [
@@ -2125,7 +2173,9 @@ export {
2125
2173
  hexHue,
2126
2174
  humanBytes,
2127
2175
  interpolate,
2176
+ isIosHomeScreenApp,
2128
2177
  isThemeName,
2178
+ outsideAppHref,
2129
2179
  pickLocale,
2130
2180
  rememberTileSnapshot,
2131
2181
  resolveMode,