@sentinel-nvr/web 0.17.0 → 0.17.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ui/index.js +31 -5
- package/dist/ui/index.js.map +1 -1
- package/package.json +1 -1
package/dist/ui/index.js
CHANGED
|
@@ -1569,6 +1569,7 @@ var CLIP_AROUND_MS = 3e4;
|
|
|
1569
1569
|
var CLIP_LIVE_MS = 6e4;
|
|
1570
1570
|
var CLIP_GAP_MS = 2e3;
|
|
1571
1571
|
var CLIP_SHARE_MAX = 100 * 1024 * 1024;
|
|
1572
|
+
var CLIP_BLOB_MAX = CLIP_SHARE_MAX;
|
|
1572
1573
|
var CLIP_POLL_MS = 700;
|
|
1573
1574
|
var CLIP_POLL_GIVEUP_MS = 6e4;
|
|
1574
1575
|
function clipRangeForEvent(ev, now = Date.now()) {
|
|
@@ -1658,12 +1659,22 @@ function fmtClipTime(ts, locale) {
|
|
|
1658
1659
|
}
|
|
1659
1660
|
}
|
|
1660
1661
|
function clipWays(s) {
|
|
1661
|
-
const
|
|
1662
|
+
const known = s.bytes > 0;
|
|
1663
|
+
const fits = known && s.bytes <= CLIP_SHARE_MAX;
|
|
1662
1664
|
if (s.standalone)
|
|
1663
1665
|
return fits ? { prefetch: true, share: s.canShareFiles, save: "blob" } : { prefetch: false, share: false, save: "safari" };
|
|
1666
|
+
if (s.crossOrigin)
|
|
1667
|
+
return known && s.bytes <= CLIP_BLOB_MAX ? { prefetch: true, share: fits && s.canShareFiles, save: "blob" } : { prefetch: false, share: false, save: "tab" };
|
|
1664
1668
|
if (fits && s.canShareFiles) return { prefetch: true, share: true, save: "link" };
|
|
1665
1669
|
return { prefetch: false, share: false, save: "link" };
|
|
1666
1670
|
}
|
|
1671
|
+
function isCrossOrigin(url, base = typeof location !== "undefined" ? location.href : "") {
|
|
1672
|
+
try {
|
|
1673
|
+
return new URL(url, base).origin !== new URL(base).origin;
|
|
1674
|
+
} catch {
|
|
1675
|
+
return false;
|
|
1676
|
+
}
|
|
1677
|
+
}
|
|
1667
1678
|
function clipErrorKind(status, code) {
|
|
1668
1679
|
if (code === "busy" || status === 429) return "busy";
|
|
1669
1680
|
if (code === "no space" || status === 507) return "noSpace";
|
|
@@ -1763,7 +1774,8 @@ function ClipBar(p) {
|
|
|
1763
1774
|
);
|
|
1764
1775
|
const finish = useCallback(
|
|
1765
1776
|
async (g, d) => {
|
|
1766
|
-
const
|
|
1777
|
+
const crossOrigin = isCrossOrigin(client.exportFileUrl(d.id));
|
|
1778
|
+
const ways = clipWays({ bytes: d.bytes, canShareFiles: canShareFiles(), standalone, crossOrigin });
|
|
1767
1779
|
if (!ways.prefetch) {
|
|
1768
1780
|
setJob({ s: "ready", ...d, ways });
|
|
1769
1781
|
return;
|
|
@@ -1789,9 +1801,10 @@ function ClipBar(p) {
|
|
|
1789
1801
|
err: "prefetch",
|
|
1790
1802
|
msg: String(e?.message ?? e).slice(0, 80),
|
|
1791
1803
|
bytes: d.bytes,
|
|
1792
|
-
standalone
|
|
1804
|
+
standalone,
|
|
1805
|
+
xo: crossOrigin
|
|
1793
1806
|
});
|
|
1794
|
-
setJob({ s: "ready", ...d, ways: { prefetch: false, share: false, save: "link" } });
|
|
1807
|
+
setJob({ s: "ready", ...d, ways: { prefetch: false, share: false, save: crossOrigin ? "tab" : "link" } });
|
|
1795
1808
|
} finally {
|
|
1796
1809
|
if (abort.current === ac) abort.current = null;
|
|
1797
1810
|
}
|
|
@@ -1993,7 +2006,20 @@ function ClipBar(p) {
|
|
|
1993
2006
|
onClick: () => log("blob"),
|
|
1994
2007
|
children: t("nvr.clip.save")
|
|
1995
2008
|
}
|
|
1996
|
-
) : /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-btn nvr-btn--primary", disabled: true, children: t("nvr.clip.save") }) :
|
|
2009
|
+
) : /* @__PURE__ */ jsx9("button", { type: "button", className: "nvr-btn nvr-btn--primary", disabled: true, children: t("nvr.clip.save") }) : ready.ways.save === "tab" ? (
|
|
2010
|
+
// another origin, too large for the page: a new tab saves it (attachment), the host page stays
|
|
2011
|
+
/* @__PURE__ */ jsx9(
|
|
2012
|
+
"a",
|
|
2013
|
+
{
|
|
2014
|
+
className: "nvr-btn nvr-btn--primary",
|
|
2015
|
+
href: fileUrl,
|
|
2016
|
+
target: "_blank",
|
|
2017
|
+
rel: "noopener noreferrer",
|
|
2018
|
+
onClick: () => log("tab"),
|
|
2019
|
+
children: t("nvr.clip.save")
|
|
2020
|
+
}
|
|
2021
|
+
)
|
|
2022
|
+
) : /* @__PURE__ */ jsx9(
|
|
1997
2023
|
"a",
|
|
1998
2024
|
{
|
|
1999
2025
|
className: "nvr-btn nvr-btn--primary",
|