@nice2dev/ui-platform 1.0.12 → 1.0.15
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 +14 -0
- package/dist/index.cjs +4 -4
- package/dist/index.mjs +259 -255
- package/dist/style.css +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -349,24 +349,24 @@ const Xe = ce(null), Ke = {
|
|
|
349
349
|
const h = window.open(t, a, C);
|
|
350
350
|
if (!h)
|
|
351
351
|
return g(
|
|
352
|
-
(
|
|
352
|
+
(v) => v.map((j) => j.id === a ? { ...j, state: "error" } : j)
|
|
353
353
|
), null;
|
|
354
354
|
u.current.set(a, h);
|
|
355
|
-
const
|
|
355
|
+
const b = {
|
|
356
356
|
...y,
|
|
357
357
|
window: h,
|
|
358
358
|
state: "open"
|
|
359
359
|
};
|
|
360
|
-
g((
|
|
360
|
+
g((v) => v.map((j) => j.id === a ? b : j));
|
|
361
361
|
const R = setInterval(() => {
|
|
362
|
-
h.closed && (clearInterval(R), u.current.delete(a), g((
|
|
362
|
+
h.closed && (clearInterval(R), u.current.delete(a), g((v) => v.filter((j) => j.id !== a)), k == null || k(b));
|
|
363
363
|
}, 500);
|
|
364
364
|
return c.fullscreen && h.addEventListener("load", () => {
|
|
365
|
-
var
|
|
366
|
-
(j = (
|
|
367
|
-
}), p == null || p(
|
|
365
|
+
var v, j;
|
|
366
|
+
(j = (v = h.document.documentElement).requestFullscreen) == null || j.call(v);
|
|
367
|
+
}), p == null || p(b), b;
|
|
368
368
|
} catch (h) {
|
|
369
|
-
return console.error("Failed to open window:", h), g((
|
|
369
|
+
return console.error("Failed to open window:", h), g((b) => b.map((R) => R.id === a ? { ...R, state: "error" } : R)), null;
|
|
370
370
|
}
|
|
371
371
|
},
|
|
372
372
|
[
|
|
@@ -509,30 +509,30 @@ const tt = ce(null), nt = {
|
|
|
509
509
|
idleTime: 0,
|
|
510
510
|
isPinDialogOpen: !1
|
|
511
511
|
}), [F, G] = ee(""), [X, $] = ee(!1), V = s(async () => {
|
|
512
|
-
const
|
|
513
|
-
if (
|
|
512
|
+
const b = f.current;
|
|
513
|
+
if (b)
|
|
514
514
|
try {
|
|
515
|
-
|
|
515
|
+
b.requestFullscreen ? await b.requestFullscreen() : b.webkitRequestFullscreen ? await b.webkitRequestFullscreen() : b.msRequestFullscreen && await b.msRequestFullscreen();
|
|
516
516
|
} catch (R) {
|
|
517
517
|
console.warn("Failed to enter fullscreen:", R);
|
|
518
518
|
}
|
|
519
519
|
}, []), O = s(async () => {
|
|
520
520
|
try {
|
|
521
521
|
document.exitFullscreen ? await document.exitFullscreen() : document.webkitExitFullscreen ? await document.webkitExitFullscreen() : document.msExitFullscreen && await document.msExitFullscreen();
|
|
522
|
-
} catch (
|
|
523
|
-
console.warn("Failed to exit fullscreen:",
|
|
522
|
+
} catch (b) {
|
|
523
|
+
console.warn("Failed to exit fullscreen:", b);
|
|
524
524
|
}
|
|
525
525
|
}, []), z = s(async () => {
|
|
526
526
|
B.isFullscreen ? await O() : await V();
|
|
527
527
|
}, [B.isFullscreen, V, O]), d = s(() => {
|
|
528
|
-
T((
|
|
529
|
-
...
|
|
528
|
+
T((b) => ({
|
|
529
|
+
...b,
|
|
530
530
|
mode: "locked",
|
|
531
531
|
isLocked: !0,
|
|
532
532
|
isAdminMode: !1
|
|
533
533
|
})), M == null || M("locked");
|
|
534
534
|
}, [M]), A = s(
|
|
535
|
-
(
|
|
535
|
+
(b) => w.exitPin && b !== w.exitPin ? ($(!0), setTimeout(() => $(!1), 1e3), !1) : (T((R) => ({
|
|
536
536
|
...R,
|
|
537
537
|
mode: R.isFullscreen ? "fullscreen" : "windowed",
|
|
538
538
|
isLocked: !1,
|
|
@@ -540,54 +540,54 @@ const tt = ce(null), nt = {
|
|
|
540
540
|
})), G(""), !0),
|
|
541
541
|
[w.exitPin]
|
|
542
542
|
), P = s(() => {
|
|
543
|
-
T((
|
|
543
|
+
T((b) => ({ ...b, isAdminMode: !0 })), o == null || o();
|
|
544
544
|
}, [o]), E = s(() => {
|
|
545
|
-
T((
|
|
545
|
+
T((b) => ({ ...b, isAdminMode: !1 }));
|
|
546
546
|
}, []), i = s(() => {
|
|
547
547
|
I.current.timer && clearTimeout(I.current.timer), I.current.count++, I.current.count >= w.adminTapCount ? (I.current.count = 0, P()) : I.current.timer = setTimeout(() => {
|
|
548
548
|
I.current.count = 0;
|
|
549
549
|
}, w.adminTapTimeout);
|
|
550
550
|
}, [w.adminTapCount, w.adminTapTimeout, P]), r = s(() => {
|
|
551
|
-
g.current && clearTimeout(g.current), B.isScreensaverActive && (T((
|
|
552
|
-
T((
|
|
551
|
+
g.current && clearTimeout(g.current), B.isScreensaverActive && (T((b) => ({ ...b, isScreensaverActive: !1 })), N == null || N()), w.inactivityTimeout > 0 && (g.current = setTimeout(() => {
|
|
552
|
+
T((b) => ({ ...b, isScreensaverActive: !0 })), u == null || u();
|
|
553
553
|
}, w.inactivityTimeout));
|
|
554
554
|
}, [w.inactivityTimeout, B.isScreensaverActive, N, u]), e = s(() => {
|
|
555
|
-
T((
|
|
555
|
+
T((b) => ({ ...b, isScreensaverActive: !0 }));
|
|
556
556
|
}, []), t = s(() => {
|
|
557
|
-
T((
|
|
557
|
+
T((b) => ({ ...b, isScreensaverActive: !1 })), r();
|
|
558
558
|
}, [r]), n = s(() => {
|
|
559
|
-
T((
|
|
559
|
+
T((b) => ({ ...b, isPinDialogOpen: !0 })), G(""), $(!1);
|
|
560
560
|
}, []), a = s(() => {
|
|
561
|
-
T((
|
|
561
|
+
T((b) => ({ ...b, isPinDialogOpen: !1 })), G(""), $(!1);
|
|
562
562
|
}, []), c = s(() => {
|
|
563
563
|
A(F);
|
|
564
564
|
}, [F, A]), C = s(
|
|
565
|
-
(
|
|
566
|
-
|
|
565
|
+
(b) => {
|
|
566
|
+
b.key === "Enter" && c();
|
|
567
567
|
},
|
|
568
568
|
[c]
|
|
569
569
|
);
|
|
570
570
|
ne(() => {
|
|
571
|
-
const
|
|
571
|
+
const b = () => {
|
|
572
572
|
const R = !!document.fullscreenElement;
|
|
573
|
-
T((
|
|
574
|
-
...
|
|
575
|
-
mode:
|
|
573
|
+
T((v) => ({
|
|
574
|
+
...v,
|
|
575
|
+
mode: v.isLocked ? "locked" : R ? "fullscreen" : "windowed",
|
|
576
576
|
isFullscreen: R
|
|
577
577
|
})), U == null || U(R);
|
|
578
578
|
};
|
|
579
|
-
return document.addEventListener("fullscreenchange",
|
|
580
|
-
document.removeEventListener("fullscreenchange",
|
|
579
|
+
return document.addEventListener("fullscreenchange", b), document.addEventListener("webkitfullscreenchange", b), () => {
|
|
580
|
+
document.removeEventListener("fullscreenchange", b), document.removeEventListener("webkitfullscreenchange", b);
|
|
581
581
|
};
|
|
582
582
|
}, [U]), ne(() => {
|
|
583
583
|
if (!w.disableContextMenu)
|
|
584
584
|
return;
|
|
585
|
-
const
|
|
585
|
+
const b = (R) => {
|
|
586
586
|
B.isAdminMode || R.preventDefault();
|
|
587
587
|
};
|
|
588
|
-
return document.addEventListener("contextmenu",
|
|
588
|
+
return document.addEventListener("contextmenu", b), () => document.removeEventListener("contextmenu", b);
|
|
589
589
|
}, [w.disableContextMenu, B.isAdminMode]), ne(() => {
|
|
590
|
-
const
|
|
590
|
+
const b = async (R) => {
|
|
591
591
|
const j = w.exitShortcut.toLowerCase().split("+"), q = j.includes("ctrl") === R.ctrlKey, Y = j.includes("shift") === R.shiftKey, W = j.includes("alt") === R.altKey, H = j.some((x) => x === R.key.toLowerCase());
|
|
592
592
|
if (q && Y && W && H) {
|
|
593
593
|
R.preventDefault(), (L ? await L("keyboard") : !0) && (B.isLocked ? n() : O());
|
|
@@ -614,7 +614,7 @@ const tt = ce(null), nt = {
|
|
|
614
614
|
}
|
|
615
615
|
}
|
|
616
616
|
};
|
|
617
|
-
return document.addEventListener("keydown",
|
|
617
|
+
return document.addEventListener("keydown", b), () => document.removeEventListener("keydown", b);
|
|
618
618
|
}, [
|
|
619
619
|
w.disableShortcuts,
|
|
620
620
|
w.exitShortcut,
|
|
@@ -626,31 +626,31 @@ const tt = ce(null), nt = {
|
|
|
626
626
|
]), ne(() => {
|
|
627
627
|
if (!w.disableCopyPaste)
|
|
628
628
|
return;
|
|
629
|
-
const
|
|
630
|
-
B.isAdminMode ||
|
|
631
|
-
}, R = (
|
|
632
|
-
B.isAdminMode ||
|
|
629
|
+
const b = (v) => {
|
|
630
|
+
B.isAdminMode || v.preventDefault();
|
|
631
|
+
}, R = (v) => {
|
|
632
|
+
B.isAdminMode || v.preventDefault();
|
|
633
633
|
};
|
|
634
|
-
return document.addEventListener("copy",
|
|
635
|
-
document.removeEventListener("copy",
|
|
634
|
+
return document.addEventListener("copy", b), document.addEventListener("paste", R), () => {
|
|
635
|
+
document.removeEventListener("copy", b), document.removeEventListener("paste", R);
|
|
636
636
|
};
|
|
637
637
|
}, [w.disableCopyPaste, B.isAdminMode]), ne(() => {
|
|
638
|
-
const
|
|
638
|
+
const b = ["mousedown", "mousemove", "keydown", "touchstart", "scroll"], R = () => {
|
|
639
639
|
r();
|
|
640
640
|
};
|
|
641
|
-
for (const
|
|
642
|
-
document.addEventListener(
|
|
641
|
+
for (const v of b)
|
|
642
|
+
document.addEventListener(v, R);
|
|
643
643
|
return r(), () => {
|
|
644
|
-
for (const
|
|
645
|
-
document.removeEventListener(
|
|
644
|
+
for (const v of b)
|
|
645
|
+
document.removeEventListener(v, R);
|
|
646
646
|
g.current && clearTimeout(g.current);
|
|
647
647
|
};
|
|
648
648
|
}, [r]), ne(() => {
|
|
649
649
|
if (w.autoFullscreen) {
|
|
650
|
-
const
|
|
650
|
+
const b = setTimeout(() => {
|
|
651
651
|
V();
|
|
652
652
|
}, 100);
|
|
653
|
-
return () => clearTimeout(
|
|
653
|
+
return () => clearTimeout(b);
|
|
654
654
|
}
|
|
655
655
|
}, [w.autoFullscreen, V]), oe(
|
|
656
656
|
D,
|
|
@@ -738,7 +738,7 @@ const tt = ce(null), nt = {
|
|
|
738
738
|
type: "password",
|
|
739
739
|
className: `nice-kiosk-mode__pin-input ${X ? "nice-kiosk-mode__pin-input--error" : ""}`,
|
|
740
740
|
value: F,
|
|
741
|
-
onChange: (
|
|
741
|
+
onChange: (b) => G(b.target.value),
|
|
742
742
|
onKeyPress: C,
|
|
743
743
|
maxLength: 8,
|
|
744
744
|
autoFocus: !0,
|
|
@@ -1516,7 +1516,7 @@ const pt = {
|
|
|
1516
1516
|
staticDetectionThreshold: 3e4,
|
|
1517
1517
|
autoDetectStatic: !1
|
|
1518
1518
|
}, yt = ie((m, D) => {
|
|
1519
|
-
var c, C, y, h,
|
|
1519
|
+
var c, C, y, h, b, R;
|
|
1520
1520
|
const {
|
|
1521
1521
|
config: _,
|
|
1522
1522
|
enabled: S = !0,
|
|
@@ -1535,7 +1535,7 @@ const pt = {
|
|
|
1535
1535
|
}), [I, B] = ee(0), [T, F] = ee({ x: 50, y: 50, dx: 1, dy: 1 }), G = s(() => {
|
|
1536
1536
|
if (!o.pixelShift)
|
|
1537
1537
|
return;
|
|
1538
|
-
const { maxShift:
|
|
1538
|
+
const { maxShift: v } = o.pixelShift, j = Math.floor(Math.random() * (v * 2 + 1)) - v, q = Math.floor(Math.random() * (v * 2 + 1)) - v;
|
|
1539
1539
|
g((Y) => ({
|
|
1540
1540
|
...Y,
|
|
1541
1541
|
shiftX: j,
|
|
@@ -1544,12 +1544,12 @@ const pt = {
|
|
|
1544
1544
|
}, [o.pixelShift]), X = s(() => {
|
|
1545
1545
|
!o.pixelShift || L.current || (G(), L.current = setInterval(G, o.pixelShift.interval));
|
|
1546
1546
|
}, [o.pixelShift, G]), $ = s(() => {
|
|
1547
|
-
L.current && (clearInterval(L.current), L.current = null), g((
|
|
1547
|
+
L.current && (clearInterval(L.current), L.current = null), g((v) => ({ ...v, shiftX: 0, shiftY: 0 }));
|
|
1548
1548
|
}, []), V = s(() => {
|
|
1549
1549
|
!o.colorCycle || w.current || (w.current = setInterval(() => {
|
|
1550
|
-
B((
|
|
1550
|
+
B((v) => {
|
|
1551
1551
|
var j;
|
|
1552
|
-
return (
|
|
1552
|
+
return (v + 1) % (((j = o.colorCycle) == null ? void 0 : j.colors.length) || 1);
|
|
1553
1553
|
});
|
|
1554
1554
|
}, o.colorCycle.interval));
|
|
1555
1555
|
}, [o.colorCycle]), O = s(() => {
|
|
@@ -1557,12 +1557,12 @@ const pt = {
|
|
|
1557
1557
|
}, []), z = s(() => {
|
|
1558
1558
|
if (!S || f.isActive)
|
|
1559
1559
|
return;
|
|
1560
|
-
const
|
|
1560
|
+
const v = o.modes;
|
|
1561
1561
|
g((j) => ({
|
|
1562
1562
|
...j,
|
|
1563
1563
|
isActive: !0,
|
|
1564
|
-
activeModes:
|
|
1565
|
-
})),
|
|
1564
|
+
activeModes: v
|
|
1565
|
+
})), v.includes("pixel-shift") && X(), v.includes("color-cycling") && V(), v.includes("dimming") && g((j) => ({ ...j, isDimmed: !0 })), v.includes("screensaver") && g((j) => ({ ...j, isScreensaverActive: !0 })), p == null || p(), M == null || M(v);
|
|
1566
1566
|
}, [
|
|
1567
1567
|
S,
|
|
1568
1568
|
f.isActive,
|
|
@@ -1572,8 +1572,8 @@ const pt = {
|
|
|
1572
1572
|
p,
|
|
1573
1573
|
M
|
|
1574
1574
|
]), d = s(() => {
|
|
1575
|
-
f.isActive && ($(), O(), g((
|
|
1576
|
-
...
|
|
1575
|
+
f.isActive && ($(), O(), g((v) => ({
|
|
1576
|
+
...v,
|
|
1577
1577
|
isActive: !1,
|
|
1578
1578
|
activeModes: [],
|
|
1579
1579
|
isDimmed: !1,
|
|
@@ -1586,36 +1586,36 @@ const pt = {
|
|
|
1586
1586
|
z();
|
|
1587
1587
|
}, o.inactivityTimeout));
|
|
1588
1588
|
}, [S, f.isActive, o.inactivityTimeout, z, d]), E = s(() => {
|
|
1589
|
-
g((
|
|
1589
|
+
g((v) => ({ ...v, isScreensaverActive: !0 }));
|
|
1590
1590
|
}, []), i = s(() => {
|
|
1591
|
-
g((
|
|
1592
|
-
}, [P]), r = s((
|
|
1591
|
+
g((v) => ({ ...v, isScreensaverActive: !1 })), P();
|
|
1592
|
+
}, [P]), r = s((v) => {
|
|
1593
1593
|
g((j) => ({
|
|
1594
1594
|
...j,
|
|
1595
|
-
isDimmed:
|
|
1595
|
+
isDimmed: v > 0
|
|
1596
1596
|
}));
|
|
1597
1597
|
}, []);
|
|
1598
1598
|
ne(() => {
|
|
1599
1599
|
var j;
|
|
1600
1600
|
if (!f.isScreensaverActive || ((j = o.screensaver) == null ? void 0 : j.type) !== "bounce")
|
|
1601
1601
|
return;
|
|
1602
|
-
const
|
|
1602
|
+
const v = setInterval(() => {
|
|
1603
1603
|
F((q) => {
|
|
1604
1604
|
let { x: Y, y: W, dx: H, dy: x } = q;
|
|
1605
1605
|
return Y += H * 0.5, W += x * 0.5, (Y <= 0 || Y >= 90) && (H = -H), (W <= 0 || W >= 90) && (x = -x), { x: Y, y: W, dx: H, dy: x };
|
|
1606
1606
|
});
|
|
1607
1607
|
}, 50);
|
|
1608
|
-
return () => clearInterval(
|
|
1608
|
+
return () => clearInterval(v);
|
|
1609
1609
|
}, [f.isScreensaverActive, (c = o.screensaver) == null ? void 0 : c.type]), ne(() => {
|
|
1610
1610
|
if (!S)
|
|
1611
1611
|
return;
|
|
1612
|
-
const
|
|
1612
|
+
const v = ["mousedown", "mousemove", "keydown", "touchstart", "scroll", "wheel"], j = () => {
|
|
1613
1613
|
P();
|
|
1614
1614
|
};
|
|
1615
|
-
for (const q of
|
|
1615
|
+
for (const q of v)
|
|
1616
1616
|
document.addEventListener(q, j);
|
|
1617
1617
|
return P(), () => {
|
|
1618
|
-
for (const q of
|
|
1618
|
+
for (const q of v)
|
|
1619
1619
|
document.removeEventListener(q, j);
|
|
1620
1620
|
N.current && clearTimeout(N.current), $(), O();
|
|
1621
1621
|
};
|
|
@@ -1647,8 +1647,8 @@ const pt = {
|
|
|
1647
1647
|
const e = () => {
|
|
1648
1648
|
if (!f.isScreensaverActive)
|
|
1649
1649
|
return null;
|
|
1650
|
-
const
|
|
1651
|
-
switch (
|
|
1650
|
+
const v = o.screensaver || { type: "blank" };
|
|
1651
|
+
switch (v.type) {
|
|
1652
1652
|
case "blank":
|
|
1653
1653
|
return /* @__PURE__ */ l(
|
|
1654
1654
|
"div",
|
|
@@ -1716,7 +1716,7 @@ const pt = {
|
|
|
1716
1716
|
className: "nice-sbp__screensaver nice-sbp__screensaver--custom",
|
|
1717
1717
|
onClick: i,
|
|
1718
1718
|
onTouchStart: i,
|
|
1719
|
-
children:
|
|
1719
|
+
children: v.component
|
|
1720
1720
|
}
|
|
1721
1721
|
);
|
|
1722
1722
|
default:
|
|
@@ -1729,7 +1729,7 @@ const pt = {
|
|
|
1729
1729
|
"--dim-level": f.isDimmed ? ((y = o.dimming) == null ? void 0 : y.level) || 0.3 : 0,
|
|
1730
1730
|
"--dim-duration": `${((h = o.dimming) == null ? void 0 : h.fadeDuration) || 2e3}ms`
|
|
1731
1731
|
}, a = f.isActive && o.modes.includes("color-cycling") ? {
|
|
1732
|
-
backgroundColor: (
|
|
1732
|
+
backgroundColor: (b = o.colorCycle) == null ? void 0 : b.colors[I],
|
|
1733
1733
|
transition: `background-color ${((R = o.colorCycle) == null ? void 0 : R.transitionDuration) || 1e3}ms ease`
|
|
1734
1734
|
} : {};
|
|
1735
1735
|
return /* @__PURE__ */ K(
|
|
@@ -1820,15 +1820,15 @@ const wt = {
|
|
|
1820
1820
|
for (const Y of A)
|
|
1821
1821
|
P += Y.targetX, E += Y.targetY, i += Y.actualX, r += Y.actualY;
|
|
1822
1822
|
const t = P / e, n = E / e, a = i / e, c = r / e;
|
|
1823
|
-
let C = 0, y = 0, h = 0,
|
|
1823
|
+
let C = 0, y = 0, h = 0, b = 0;
|
|
1824
1824
|
for (const Y of A) {
|
|
1825
1825
|
const W = Y.targetX - t, H = Y.targetY - n, x = Y.actualX - a, J = Y.actualY - c;
|
|
1826
|
-
C += W * W, y += W * x, h += H * H,
|
|
1826
|
+
C += W * W, y += W * x, h += H * H, b += H * J;
|
|
1827
1827
|
}
|
|
1828
|
-
const R = y !== 0 ? C / y : 1,
|
|
1828
|
+
const R = y !== 0 ? C / y : 1, v = b !== 0 ? h / b : 1, j = t - R * a, q = n - v * c;
|
|
1829
1829
|
return {
|
|
1830
1830
|
scaleX: R,
|
|
1831
|
-
scaleY:
|
|
1831
|
+
scaleY: v,
|
|
1832
1832
|
offsetX: j,
|
|
1833
1833
|
offsetY: q,
|
|
1834
1834
|
rotation: 0
|
|
@@ -2390,8 +2390,8 @@ const _t = {
|
|
|
2390
2390
|
O.fillStyle = o.lineColor, O.font = `${o.fontSize}px ${o.font}`, O.textBaseline = o.textPosition === "top" ? "top" : "bottom";
|
|
2391
2391
|
let h = r;
|
|
2392
2392
|
o.textAlign === "center" ? (h = r + P / 2, O.textAlign = "center") : o.textAlign === "right" ? (h = r + P, O.textAlign = "right") : O.textAlign = "left";
|
|
2393
|
-
const
|
|
2394
|
-
O.fillText(_, h,
|
|
2393
|
+
const b = o.textPosition === "top" ? E + o.textMargin : a - i - o.textMargin;
|
|
2394
|
+
O.fillText(_, h, b);
|
|
2395
2395
|
}
|
|
2396
2396
|
const y = V.toDataURL("image/png");
|
|
2397
2397
|
g(y), w(null), p == null || p(y);
|
|
@@ -2425,8 +2425,8 @@ const _t = {
|
|
|
2425
2425
|
const y = o.textAlign === "center" ? "middle" : o.textAlign === "right" ? "end" : "start";
|
|
2426
2426
|
let h = P;
|
|
2427
2427
|
o.textAlign === "center" ? h = P + r / 2 : o.textAlign === "right" && (h = P + r);
|
|
2428
|
-
const
|
|
2429
|
-
C = `<text x="${h}" y="${
|
|
2428
|
+
const b = o.textPosition === "top" ? d + o.fontSize : t - A - o.textMargin;
|
|
2429
|
+
C = `<text x="${h}" y="${b}" font-family="${o.font}" font-size="${o.fontSize}" text-anchor="${y}" fill="${o.lineColor}">${_}</text>`;
|
|
2430
2430
|
}
|
|
2431
2431
|
return `<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}" viewBox="0 0 ${e} ${t}">
|
|
2432
2432
|
<rect width="100%" height="100%" fill="${o.background}"/>
|
|
@@ -2571,7 +2571,7 @@ const Tt = {
|
|
|
2571
2571
|
const H = W instanceof Error ? W.message : "Failed to initialize barcode detector";
|
|
2572
2572
|
A(H), k == null || k(new Error(H));
|
|
2573
2573
|
}
|
|
2574
|
-
}, [n, w.formats, k]),
|
|
2574
|
+
}, [n, w.formats, k]), b = s(async () => {
|
|
2575
2575
|
if (!(!f.current || !B.current || !$))
|
|
2576
2576
|
try {
|
|
2577
2577
|
const H = await B.current.detect(f.current);
|
|
@@ -2606,11 +2606,11 @@ const Tt = {
|
|
|
2606
2606
|
p
|
|
2607
2607
|
]), R = s(async () => {
|
|
2608
2608
|
X(!0), A(null), await h(), await c();
|
|
2609
|
-
}, [h, c]),
|
|
2609
|
+
}, [h, c]), v = s(() => {
|
|
2610
2610
|
X(!1), T.current && (clearInterval(T.current), T.current = null), C();
|
|
2611
2611
|
}, [C]), j = s(async () => {
|
|
2612
|
-
G ?
|
|
2613
|
-
}, [G, R,
|
|
2612
|
+
G ? v() : await R();
|
|
2613
|
+
}, [G, R, v]), q = s(() => {
|
|
2614
2614
|
if (!f.current || !g.current)
|
|
2615
2615
|
return null;
|
|
2616
2616
|
const W = g.current, H = f.current;
|
|
@@ -2618,10 +2618,10 @@ const Tt = {
|
|
|
2618
2618
|
const x = W.getContext("2d");
|
|
2619
2619
|
return x ? (x.drawImage(H, 0, 0), W.toDataURL("image/png")) : null;
|
|
2620
2620
|
}, []);
|
|
2621
|
-
ne(() => (G && $ && w.continuous && (T.current = setInterval(
|
|
2621
|
+
ne(() => (G && $ && w.continuous && (T.current = setInterval(b, w.scanInterval)), () => {
|
|
2622
2622
|
T.current && (clearInterval(T.current), T.current = null);
|
|
2623
|
-
}), [G, $, w.continuous, w.scanInterval,
|
|
2624
|
-
|
|
2623
|
+
}), [G, $, w.continuous, w.scanInterval, b]), ne(() => (u && R(), () => {
|
|
2624
|
+
v();
|
|
2625
2625
|
}), []), ne(() => {
|
|
2626
2626
|
G && !$ && c();
|
|
2627
2627
|
}, [i, G, $, c]), oe(
|
|
@@ -2636,7 +2636,7 @@ const Tt = {
|
|
|
2636
2636
|
hasPermission: P
|
|
2637
2637
|
}),
|
|
2638
2638
|
start: R,
|
|
2639
|
-
stop:
|
|
2639
|
+
stop: v,
|
|
2640
2640
|
toggle: j,
|
|
2641
2641
|
takeSnapshot: q,
|
|
2642
2642
|
switchCamera: y,
|
|
@@ -2650,7 +2650,7 @@ const Tt = {
|
|
|
2650
2650
|
n,
|
|
2651
2651
|
P,
|
|
2652
2652
|
R,
|
|
2653
|
-
|
|
2653
|
+
v,
|
|
2654
2654
|
j,
|
|
2655
2655
|
q,
|
|
2656
2656
|
y,
|
|
@@ -2832,15 +2832,15 @@ const Bt = ce(null), qt = {
|
|
|
2832
2832
|
const J = x instanceof Error ? x.message : "Failed to start camera";
|
|
2833
2833
|
t(J), o == null || o(new Error(J));
|
|
2834
2834
|
}
|
|
2835
|
-
}, [d, y, o]),
|
|
2835
|
+
}, [d, y, o]), b = s(() => {
|
|
2836
2836
|
F.current && cancelAnimationFrame(F.current), B.current && (B.current.getTracks().forEach((x) => x.stop()), B.current = null), g.current && (g.current.srcObject = null), z(!1), r([]);
|
|
2837
2837
|
}, []);
|
|
2838
2838
|
ne(() => () => {
|
|
2839
|
-
|
|
2840
|
-
}, [
|
|
2839
|
+
b();
|
|
2840
|
+
}, [b]);
|
|
2841
2841
|
const R = s(() => {
|
|
2842
2842
|
P.trim() && (n(P.trim()), E(""));
|
|
2843
|
-
}, [P, n]),
|
|
2843
|
+
}, [P, n]), v = s(() => {
|
|
2844
2844
|
const x = ["Value", "Format", "Quantity", "Timestamp"], J = $.map((Q) => [
|
|
2845
2845
|
`"${Q.value.replace(/"/g, '""')}"`,
|
|
2846
2846
|
Q.format,
|
|
@@ -2850,31 +2850,31 @@ const Bt = ce(null), qt = {
|
|
|
2850
2850
|
return [x.join(","), ...J.map((Q) => Q.join(","))].join(`
|
|
2851
2851
|
`);
|
|
2852
2852
|
}, [$]), j = s(() => JSON.stringify($, null, 2), [$]), q = s(() => {
|
|
2853
|
-
|
|
2854
|
-
}, [$,
|
|
2853
|
+
b(), M == null || M($);
|
|
2854
|
+
}, [$, b, M]);
|
|
2855
2855
|
oe(
|
|
2856
2856
|
D,
|
|
2857
2857
|
() => ({
|
|
2858
2858
|
startScanning: h,
|
|
2859
|
-
stopScanning:
|
|
2859
|
+
stopScanning: b,
|
|
2860
2860
|
getItems: () => $,
|
|
2861
2861
|
addItem: (x, J) => n(x, J),
|
|
2862
2862
|
removeItem: a,
|
|
2863
2863
|
updateQuantity: c,
|
|
2864
2864
|
clearAll: C,
|
|
2865
|
-
exportCSV:
|
|
2865
|
+
exportCSV: v,
|
|
2866
2866
|
exportJSON: j,
|
|
2867
2867
|
isScanning: () => O
|
|
2868
2868
|
}),
|
|
2869
2869
|
[
|
|
2870
2870
|
h,
|
|
2871
|
-
|
|
2871
|
+
b,
|
|
2872
2872
|
$,
|
|
2873
2873
|
n,
|
|
2874
2874
|
a,
|
|
2875
2875
|
c,
|
|
2876
2876
|
C,
|
|
2877
|
-
|
|
2877
|
+
v,
|
|
2878
2878
|
j,
|
|
2879
2879
|
O
|
|
2880
2880
|
]
|
|
@@ -2887,7 +2887,7 @@ const Bt = ce(null), qt = {
|
|
|
2887
2887
|
updateQuantity: c,
|
|
2888
2888
|
clearAll: C,
|
|
2889
2889
|
startScanning: h,
|
|
2890
|
-
stopScanning:
|
|
2890
|
+
stopScanning: b
|
|
2891
2891
|
}, W = $.reduce((x, J) => x + J.quantity, 0), H = ["nice-batch-scanner", O && "nice-batch-scanner--scanning", L].filter(Boolean).join(" ");
|
|
2892
2892
|
return /* @__PURE__ */ l(Bt.Provider, { value: Y, children: /* @__PURE__ */ K("div", { className: H, children: [
|
|
2893
2893
|
/* @__PURE__ */ K("div", { className: "nice-batch-scanner__scanner", children: [
|
|
@@ -2936,7 +2936,7 @@ const Bt = ce(null), qt = {
|
|
|
2936
2936
|
"button",
|
|
2937
2937
|
{
|
|
2938
2938
|
className: `nice-batch-scanner__btn nice-batch-scanner__btn--${O ? "stop" : "start"}`,
|
|
2939
|
-
onClick: O ?
|
|
2939
|
+
onClick: O ? b : h,
|
|
2940
2940
|
children: O ? "Stop Scanning" : "Start Scanning"
|
|
2941
2941
|
}
|
|
2942
2942
|
),
|
|
@@ -3348,7 +3348,7 @@ const Xt = {
|
|
|
3348
3348
|
f.current && (f.current.getTracks().forEach((Q) => Q.stop()), f.current = null), L.current && (L.current.srcObject = null), X(!1), t(!1);
|
|
3349
3349
|
}, []), h = s(async () => {
|
|
3350
3350
|
E(P === "user" ? "environment" : "user"), T && y();
|
|
3351
|
-
}, [P, T, y]),
|
|
3351
|
+
}, [P, T, y]), b = s(async () => {
|
|
3352
3352
|
if (!f.current || !i)
|
|
3353
3353
|
return;
|
|
3354
3354
|
const Q = f.current.getVideoTracks()[0], Z = !e;
|
|
@@ -3367,7 +3367,7 @@ const Xt = {
|
|
|
3367
3367
|
const Z = Q instanceof Error ? Q.message : "Failed to initialize QR detector";
|
|
3368
3368
|
z(Z), p == null || p(new Error(Z));
|
|
3369
3369
|
}
|
|
3370
|
-
}, [c, p]),
|
|
3370
|
+
}, [c, p]), v = s(
|
|
3371
3371
|
(Q, Z) => {
|
|
3372
3372
|
const re = {
|
|
3373
3373
|
text: Q,
|
|
@@ -3396,7 +3396,7 @@ const Xt = {
|
|
|
3396
3396
|
if (N.continuous && re.rawValue === B.current)
|
|
3397
3397
|
return;
|
|
3398
3398
|
B.current = re.rawValue;
|
|
3399
|
-
const se =
|
|
3399
|
+
const se = v(re.rawValue, re);
|
|
3400
3400
|
N.highlightDetected && se.boundingBox && (a(se.boundingBox), setTimeout(() => a(null), 500)), N.beepOnScan && Qt(), N.vibrateOnScan && Jt(), V(se), S == null || S(se), setTimeout(() => {
|
|
3401
3401
|
B.current = null;
|
|
3402
3402
|
}, 1e3);
|
|
@@ -3409,7 +3409,7 @@ const Xt = {
|
|
|
3409
3409
|
N.highlightDetected,
|
|
3410
3410
|
N.beepOnScan,
|
|
3411
3411
|
N.vibrateOnScan,
|
|
3412
|
-
|
|
3412
|
+
v,
|
|
3413
3413
|
S
|
|
3414
3414
|
]), q = s(async () => {
|
|
3415
3415
|
F(!0), z(null), await R(), await C();
|
|
@@ -3431,7 +3431,7 @@ const Xt = {
|
|
|
3431
3431
|
try {
|
|
3432
3432
|
const ae = await g.current.detect(re);
|
|
3433
3433
|
if (ae.length > 0) {
|
|
3434
|
-
const le =
|
|
3434
|
+
const le = v(ae[0].rawValue, ae[0]);
|
|
3435
3435
|
Z(le);
|
|
3436
3436
|
} else
|
|
3437
3437
|
Z(null);
|
|
@@ -3440,7 +3440,7 @@ const Xt = {
|
|
|
3440
3440
|
}
|
|
3441
3441
|
}, re.onerror = () => Z(null), re.src = URL.createObjectURL(Q);
|
|
3442
3442
|
}),
|
|
3443
|
-
[c,
|
|
3443
|
+
[c, v]
|
|
3444
3444
|
);
|
|
3445
3445
|
ne(() => (T && G && N.continuous && (I.current = setInterval(j, N.scanInterval)), () => {
|
|
3446
3446
|
I.current && (clearInterval(I.current), I.current = null);
|
|
@@ -3465,7 +3465,7 @@ const Xt = {
|
|
|
3465
3465
|
stop: Y,
|
|
3466
3466
|
toggle: W,
|
|
3467
3467
|
switchCamera: h,
|
|
3468
|
-
toggleTorch:
|
|
3468
|
+
toggleTorch: b,
|
|
3469
3469
|
takeSnapshot: H,
|
|
3470
3470
|
scanImage: x
|
|
3471
3471
|
}),
|
|
@@ -3482,7 +3482,7 @@ const Xt = {
|
|
|
3482
3482
|
Y,
|
|
3483
3483
|
W,
|
|
3484
3484
|
h,
|
|
3485
|
-
|
|
3485
|
+
b,
|
|
3486
3486
|
H,
|
|
3487
3487
|
x
|
|
3488
3488
|
]
|
|
@@ -4188,8 +4188,8 @@ const sn = ce(null), an = {
|
|
|
4188
4188
|
priority: (a == null ? void 0 : a.priority) ?? 0
|
|
4189
4189
|
};
|
|
4190
4190
|
return new Promise((y, h) => {
|
|
4191
|
-
const
|
|
4192
|
-
|
|
4191
|
+
const v = c.transaction(N.storeName, "readwrite").objectStore(N.storeName).add(C);
|
|
4192
|
+
v.onerror = () => h(v.error), v.onsuccess = () => {
|
|
4193
4193
|
g((j) => ({ ...j, pendingCount: j.pendingCount + 1 })), y(C.id);
|
|
4194
4194
|
};
|
|
4195
4195
|
});
|
|
@@ -4258,14 +4258,14 @@ const sn = ce(null), an = {
|
|
|
4258
4258
|
for (let C = 0; C < a.length && !w.current; C++) {
|
|
4259
4259
|
const y = a[C], h = await O(y);
|
|
4260
4260
|
if (h ? n.success++ : y.attempts >= y.maxAttempts && n.failed++, !h && y.attempts < y.maxAttempts) {
|
|
4261
|
-
const
|
|
4261
|
+
const b = Math.min(
|
|
4262
4262
|
N.retryDelay * Math.pow(N.backoffFactor, y.attempts - 1),
|
|
4263
4263
|
N.maxRetryDelay
|
|
4264
4264
|
);
|
|
4265
|
-
await cn(
|
|
4265
|
+
await cn(b);
|
|
4266
4266
|
}
|
|
4267
|
-
g((
|
|
4268
|
-
...
|
|
4267
|
+
g((b) => ({
|
|
4268
|
+
...b,
|
|
4269
4269
|
syncProgress: Math.round((C + 1) / c * 100)
|
|
4270
4270
|
}));
|
|
4271
4271
|
}
|
|
@@ -4315,8 +4315,8 @@ const sn = ce(null), an = {
|
|
|
4315
4315
|
y.onerror = () => C(y.error), y.oncomplete = async () => {
|
|
4316
4316
|
await V(), c();
|
|
4317
4317
|
};
|
|
4318
|
-
for (const
|
|
4319
|
-
h.delete(
|
|
4318
|
+
for (const b of a)
|
|
4319
|
+
h.delete(b.id);
|
|
4320
4320
|
});
|
|
4321
4321
|
},
|
|
4322
4322
|
[I, F, N.storeName, V]
|
|
@@ -4328,8 +4328,8 @@ const sn = ce(null), an = {
|
|
|
4328
4328
|
y.onerror = () => C(y.error), y.oncomplete = async () => {
|
|
4329
4329
|
await V(), c();
|
|
4330
4330
|
};
|
|
4331
|
-
for (const
|
|
4332
|
-
h.delete(
|
|
4331
|
+
for (const b of a)
|
|
4332
|
+
h.delete(b.id);
|
|
4333
4333
|
});
|
|
4334
4334
|
},
|
|
4335
4335
|
[I, X, N.storeName, V]
|
|
@@ -4601,10 +4601,10 @@ const Be = ie(
|
|
|
4601
4601
|
const h = await O(i, C, c);
|
|
4602
4602
|
if (!h.ok)
|
|
4603
4603
|
throw new Error(`HTTP ${h.status}`);
|
|
4604
|
-
const
|
|
4605
|
-
await T(n,
|
|
4606
|
-
const
|
|
4607
|
-
data:
|
|
4604
|
+
const b = await h.json(), R = h.headers.get("etag") || void 0;
|
|
4605
|
+
await T(n, b, t);
|
|
4606
|
+
const v = {
|
|
4607
|
+
data: b,
|
|
4608
4608
|
timestamp: /* @__PURE__ */ new Date(),
|
|
4609
4609
|
etag: R,
|
|
4610
4610
|
key: n,
|
|
@@ -4612,7 +4612,7 @@ const Be = ie(
|
|
|
4612
4612
|
source: "network",
|
|
4613
4613
|
url: i
|
|
4614
4614
|
};
|
|
4615
|
-
return f((j) => ({ ...j, isFetching: !1 })), k == null || k(
|
|
4615
|
+
return f((j) => ({ ...j, isFetching: !1 })), k == null || k(v), v;
|
|
4616
4616
|
} catch (h) {
|
|
4617
4617
|
throw o == null || o(h instanceof Error ? h : new Error(String(h)), i), h;
|
|
4618
4618
|
}
|
|
@@ -4622,8 +4622,8 @@ const Be = ie(
|
|
|
4622
4622
|
case "cache-only": {
|
|
4623
4623
|
const h = await B(n);
|
|
4624
4624
|
if (h)
|
|
4625
|
-
return f((
|
|
4626
|
-
throw f((
|
|
4625
|
+
return f((b) => ({ ...b, isFetching: !1, hits: b.hits + 1 })), M == null || M(h), h;
|
|
4626
|
+
throw f((b) => ({ ...b, isFetching: !1, misses: b.misses + 1 })), U == null || U(i), new Error("No cache entry found");
|
|
4627
4627
|
}
|
|
4628
4628
|
case "network-only":
|
|
4629
4629
|
return f((h) => ({ ...h, misses: h.misses + 1 })), await y();
|
|
@@ -4631,7 +4631,7 @@ const Be = ie(
|
|
|
4631
4631
|
if (!a) {
|
|
4632
4632
|
const h = await B(n);
|
|
4633
4633
|
if (h && !h.isStale)
|
|
4634
|
-
return f((
|
|
4634
|
+
return f((b) => ({ ...b, isFetching: !1, hits: b.hits + 1 })), M == null || M(h), h;
|
|
4635
4635
|
}
|
|
4636
4636
|
return f((h) => ({ ...h, misses: h.misses + 1 })), await y();
|
|
4637
4637
|
}
|
|
@@ -4639,20 +4639,20 @@ const Be = ie(
|
|
|
4639
4639
|
try {
|
|
4640
4640
|
return f((h) => ({ ...h, misses: h.misses + 1 })), await y();
|
|
4641
4641
|
} catch (h) {
|
|
4642
|
-
const
|
|
4643
|
-
if (
|
|
4644
|
-
return f((R) => ({ ...R, isFetching: !1, hits: R.hits + 1 })), M == null || M(
|
|
4642
|
+
const b = await B(n);
|
|
4643
|
+
if (b)
|
|
4644
|
+
return f((R) => ({ ...R, isFetching: !1, hits: R.hits + 1 })), M == null || M(b), b;
|
|
4645
4645
|
throw h;
|
|
4646
4646
|
}
|
|
4647
4647
|
case "stale-while-revalidate":
|
|
4648
4648
|
default: {
|
|
4649
4649
|
const h = await B(n);
|
|
4650
|
-
return h && !a ? (f((
|
|
4651
|
-
}), f((
|
|
4650
|
+
return h && !a ? (f((b) => ({ ...b, hits: b.hits + 1 })), M == null || M(h), h.isStale && y().catch(() => {
|
|
4651
|
+
}), f((b) => ({ ...b, isFetching: !1 })), h) : (f((b) => ({ ...b, misses: b.misses + 1 })), await y());
|
|
4652
4652
|
}
|
|
4653
4653
|
}
|
|
4654
4654
|
} catch (h) {
|
|
4655
|
-
throw f((
|
|
4655
|
+
throw f((b) => ({ ...b, isFetching: !1 })), h;
|
|
4656
4656
|
}
|
|
4657
4657
|
},
|
|
4658
4658
|
[
|
|
@@ -5020,13 +5020,13 @@ const hn = ce(null), gn = {
|
|
|
5020
5020
|
dismissConflict: t,
|
|
5021
5021
|
clearResolved: n,
|
|
5022
5022
|
clearAll: a
|
|
5023
|
-
}, h = e(),
|
|
5023
|
+
}, h = e(), b = (q, Y, W) => {
|
|
5024
5024
|
P(q, Y, W);
|
|
5025
5025
|
}, R = (q) => {
|
|
5026
5026
|
t(q);
|
|
5027
|
-
},
|
|
5027
|
+
}, v = (q) => L ? L({
|
|
5028
5028
|
conflict: q,
|
|
5029
|
-
onResolve: (Y, W) =>
|
|
5029
|
+
onResolve: (Y, W) => b(q.id, Y, W),
|
|
5030
5030
|
onDismiss: () => R(q.id)
|
|
5031
5031
|
}) : /* @__PURE__ */ K("div", { className: "nice-conflict-item", children: [
|
|
5032
5032
|
/* @__PURE__ */ K("div", { className: "nice-conflict-item__header", children: [
|
|
@@ -5055,7 +5055,7 @@ const hn = ce(null), gn = {
|
|
|
5055
5055
|
"button",
|
|
5056
5056
|
{
|
|
5057
5057
|
className: "nice-conflict-btn nice-conflict-btn--client",
|
|
5058
|
-
onClick: () =>
|
|
5058
|
+
onClick: () => b(q.id, "client-wins"),
|
|
5059
5059
|
disabled: B,
|
|
5060
5060
|
children: "Keep Mine"
|
|
5061
5061
|
}
|
|
@@ -5064,7 +5064,7 @@ const hn = ce(null), gn = {
|
|
|
5064
5064
|
"button",
|
|
5065
5065
|
{
|
|
5066
5066
|
className: "nice-conflict-btn nice-conflict-btn--server",
|
|
5067
|
-
onClick: () =>
|
|
5067
|
+
onClick: () => b(q.id, "server-wins"),
|
|
5068
5068
|
disabled: B,
|
|
5069
5069
|
children: "Use Server"
|
|
5070
5070
|
}
|
|
@@ -5073,7 +5073,7 @@ const hn = ce(null), gn = {
|
|
|
5073
5073
|
"button",
|
|
5074
5074
|
{
|
|
5075
5075
|
className: "nice-conflict-btn nice-conflict-btn--merge",
|
|
5076
|
-
onClick: () =>
|
|
5076
|
+
onClick: () => b(q.id, "merge"),
|
|
5077
5077
|
disabled: B,
|
|
5078
5078
|
children: "Merge"
|
|
5079
5079
|
}
|
|
@@ -5094,7 +5094,7 @@ const hn = ce(null), gn = {
|
|
|
5094
5094
|
if (N)
|
|
5095
5095
|
return N({
|
|
5096
5096
|
conflicts: h,
|
|
5097
|
-
onResolve:
|
|
5097
|
+
onResolve: b,
|
|
5098
5098
|
onDismiss: R
|
|
5099
5099
|
});
|
|
5100
5100
|
const q = /* @__PURE__ */ K("div", { className: "nice-conflict-list", children: [
|
|
@@ -5106,7 +5106,7 @@ const hn = ce(null), gn = {
|
|
|
5106
5106
|
] }),
|
|
5107
5107
|
/* @__PURE__ */ l("button", { className: "nice-conflict-list__close", onClick: C, children: "✕" })
|
|
5108
5108
|
] }),
|
|
5109
|
-
/* @__PURE__ */ l("div", { className: "nice-conflict-list__items", children: h.map(
|
|
5109
|
+
/* @__PURE__ */ l("div", { className: "nice-conflict-list__items", children: h.map(v) }),
|
|
5110
5110
|
h.length > 1 && /* @__PURE__ */ K("div", { className: "nice-conflict-list__bulk", children: [
|
|
5111
5111
|
/* @__PURE__ */ l(
|
|
5112
5112
|
"button",
|
|
@@ -5172,13 +5172,13 @@ const _n = ce(null), Ue = ie((m, D) => {
|
|
|
5172
5172
|
const a = t.result, c = n.oldVersion, C = n.newVersion;
|
|
5173
5173
|
for (const h of _.stores)
|
|
5174
5174
|
if (!a.objectStoreNames.contains(h.name)) {
|
|
5175
|
-
const
|
|
5175
|
+
const b = a.createObjectStore(h.name, {
|
|
5176
5176
|
keyPath: h.keyPath,
|
|
5177
5177
|
autoIncrement: h.autoIncrement
|
|
5178
5178
|
});
|
|
5179
5179
|
if (h.indexes)
|
|
5180
5180
|
for (const R of h.indexes)
|
|
5181
|
-
|
|
5181
|
+
b.createIndex(R.name, R.keyPath, R.options);
|
|
5182
5182
|
}
|
|
5183
5183
|
(y = _.onUpgrade) == null || y.call(_, a, c, C);
|
|
5184
5184
|
}, t.onsuccess = () => {
|
|
@@ -5230,11 +5230,11 @@ const _n = ce(null), Ue = ie((m, D) => {
|
|
|
5230
5230
|
return new Promise((n, a) => {
|
|
5231
5231
|
const C = t.transaction(r, "readonly").objectStore(r), h = (e != null && e.index ? C.index(e.index) : C).getAll(e == null ? void 0 : e.range, e == null ? void 0 : e.limit);
|
|
5232
5232
|
h.onerror = () => {
|
|
5233
|
-
var
|
|
5234
|
-
return a(new Error((
|
|
5233
|
+
var b;
|
|
5234
|
+
return a(new Error((b = h.error) == null ? void 0 : b.message));
|
|
5235
5235
|
}, h.onsuccess = () => {
|
|
5236
|
-
let
|
|
5237
|
-
e != null && e.offset && (
|
|
5236
|
+
let b = h.result;
|
|
5237
|
+
e != null && e.offset && (b = b.slice(e.offset)), n(b);
|
|
5238
5238
|
};
|
|
5239
5239
|
});
|
|
5240
5240
|
},
|
|
@@ -5245,8 +5245,8 @@ const _n = ce(null), Ue = ie((m, D) => {
|
|
|
5245
5245
|
return new Promise((n, a) => {
|
|
5246
5246
|
const C = t.transaction(r, "readonly").objectStore(r), h = (e != null && e.index ? C.index(e.index) : C).getAllKeys(e == null ? void 0 : e.range, e == null ? void 0 : e.limit);
|
|
5247
5247
|
h.onerror = () => {
|
|
5248
|
-
var
|
|
5249
|
-
return a(new Error((
|
|
5248
|
+
var b;
|
|
5249
|
+
return a(new Error((b = h.error) == null ? void 0 : b.message));
|
|
5250
5250
|
}, h.onsuccess = () => n(h.result);
|
|
5251
5251
|
});
|
|
5252
5252
|
},
|
|
@@ -5257,8 +5257,8 @@ const _n = ce(null), Ue = ie((m, D) => {
|
|
|
5257
5257
|
return new Promise((a, c) => {
|
|
5258
5258
|
const h = n.transaction(r, "readwrite").objectStore(r).add(e, t);
|
|
5259
5259
|
h.onerror = () => {
|
|
5260
|
-
var
|
|
5261
|
-
return c(new Error((
|
|
5260
|
+
var b;
|
|
5261
|
+
return c(new Error((b = h.error) == null ? void 0 : b.message));
|
|
5262
5262
|
}, h.onsuccess = () => a(h.result);
|
|
5263
5263
|
});
|
|
5264
5264
|
},
|
|
@@ -5269,8 +5269,8 @@ const _n = ce(null), Ue = ie((m, D) => {
|
|
|
5269
5269
|
return new Promise((a, c) => {
|
|
5270
5270
|
const h = n.transaction(r, "readwrite").objectStore(r).put(e, t);
|
|
5271
5271
|
h.onerror = () => {
|
|
5272
|
-
var
|
|
5273
|
-
return c(new Error((
|
|
5272
|
+
var b;
|
|
5273
|
+
return c(new Error((b = h.error) == null ? void 0 : b.message));
|
|
5274
5274
|
}, h.onsuccess = () => a(h.result);
|
|
5275
5275
|
});
|
|
5276
5276
|
},
|
|
@@ -5315,23 +5315,23 @@ const _n = ce(null), Ue = ie((m, D) => {
|
|
|
5315
5315
|
async (r, e) => {
|
|
5316
5316
|
const t = await g(), n = [];
|
|
5317
5317
|
return new Promise((a, c) => {
|
|
5318
|
-
const y = t.transaction(r, "readonly").objectStore(r),
|
|
5319
|
-
let R = 0,
|
|
5320
|
-
|
|
5318
|
+
const y = t.transaction(r, "readonly").objectStore(r), b = (e.index ? y.index(e.index) : y).openCursor(e.range, e.direction);
|
|
5319
|
+
let R = 0, v = 0;
|
|
5320
|
+
b.onerror = () => {
|
|
5321
5321
|
var j;
|
|
5322
|
-
return c(new Error((j =
|
|
5323
|
-
},
|
|
5324
|
-
const j =
|
|
5322
|
+
return c(new Error((j = b.error) == null ? void 0 : j.message));
|
|
5323
|
+
}, b.onsuccess = () => {
|
|
5324
|
+
const j = b.result;
|
|
5325
5325
|
if (j) {
|
|
5326
5326
|
if (e.offset && R < e.offset) {
|
|
5327
5327
|
R++, j.continue();
|
|
5328
5328
|
return;
|
|
5329
5329
|
}
|
|
5330
|
-
if (e.limit &&
|
|
5330
|
+
if (e.limit && v >= e.limit) {
|
|
5331
5331
|
a(n);
|
|
5332
5332
|
return;
|
|
5333
5333
|
}
|
|
5334
|
-
n.push(j.value),
|
|
5334
|
+
n.push(j.value), v++, j.continue();
|
|
5335
5335
|
} else
|
|
5336
5336
|
a(n);
|
|
5337
5337
|
};
|
|
@@ -5361,8 +5361,8 @@ const _n = ce(null), Ue = ie((m, D) => {
|
|
|
5361
5361
|
return c(new Error((h = C.error) == null ? void 0 : h.message));
|
|
5362
5362
|
}, C.oncomplete = () => a(n);
|
|
5363
5363
|
for (const h of e) {
|
|
5364
|
-
const
|
|
5365
|
-
|
|
5364
|
+
const b = y.add(h);
|
|
5365
|
+
b.onsuccess = () => n.push(b.result);
|
|
5366
5366
|
}
|
|
5367
5367
|
});
|
|
5368
5368
|
},
|
|
@@ -5377,8 +5377,8 @@ const _n = ce(null), Ue = ie((m, D) => {
|
|
|
5377
5377
|
return c(new Error((h = C.error) == null ? void 0 : h.message));
|
|
5378
5378
|
}, C.oncomplete = () => a(n);
|
|
5379
5379
|
for (const h of e) {
|
|
5380
|
-
const
|
|
5381
|
-
|
|
5380
|
+
const b = y.put(h);
|
|
5381
|
+
b.onsuccess = () => n.push(b.result);
|
|
5382
5382
|
}
|
|
5383
5383
|
});
|
|
5384
5384
|
},
|
|
@@ -5534,8 +5534,8 @@ const Sn = ce(null), Nn = {
|
|
|
5534
5534
|
metadata: t
|
|
5535
5535
|
};
|
|
5536
5536
|
return new Promise((c, C) => {
|
|
5537
|
-
const
|
|
5538
|
-
|
|
5537
|
+
const b = n.transaction("drafts", "readwrite").objectStore("drafts").add(a);
|
|
5538
|
+
b.onerror = () => C(b.error), b.onsuccess = () => {
|
|
5539
5539
|
p == null || p(a), E(), c(a.id);
|
|
5540
5540
|
};
|
|
5541
5541
|
});
|
|
@@ -5559,11 +5559,11 @@ const Sn = ce(null), Nn = {
|
|
|
5559
5559
|
return new Promise((t, n) => {
|
|
5560
5560
|
const y = e.transaction("drafts", "readonly").objectStore("drafts").index("formId").getAll(r);
|
|
5561
5561
|
y.onerror = () => n(y.error), y.onsuccess = () => {
|
|
5562
|
-
const h = y.result.map((
|
|
5563
|
-
...
|
|
5564
|
-
createdAt: new Date(
|
|
5565
|
-
modifiedAt: new Date(
|
|
5566
|
-
syncedAt:
|
|
5562
|
+
const h = y.result.map((b) => ({
|
|
5563
|
+
...b,
|
|
5564
|
+
createdAt: new Date(b.createdAt),
|
|
5565
|
+
modifiedAt: new Date(b.modifiedAt),
|
|
5566
|
+
syncedAt: b.syncedAt ? new Date(b.syncedAt) : void 0
|
|
5567
5567
|
}));
|
|
5568
5568
|
t(h);
|
|
5569
5569
|
};
|
|
@@ -5596,8 +5596,8 @@ const Sn = ce(null), Nn = {
|
|
|
5596
5596
|
version: t.version + 1
|
|
5597
5597
|
};
|
|
5598
5598
|
return new Promise((c, C) => {
|
|
5599
|
-
const
|
|
5600
|
-
|
|
5599
|
+
const b = n.transaction("drafts", "readwrite").objectStore("drafts").put(a);
|
|
5600
|
+
b.onerror = () => C(b.error), b.onsuccess = () => {
|
|
5601
5601
|
p == null || p(a), c();
|
|
5602
5602
|
};
|
|
5603
5603
|
});
|
|
@@ -5918,7 +5918,7 @@ const Ie = () => {
|
|
|
5918
5918
|
case "online":
|
|
5919
5919
|
return L;
|
|
5920
5920
|
}
|
|
5921
|
-
},
|
|
5921
|
+
}, b = () => {
|
|
5922
5922
|
switch (y) {
|
|
5923
5923
|
case "offline":
|
|
5924
5924
|
case "reconnecting":
|
|
@@ -5937,7 +5937,7 @@ const Ie = () => {
|
|
|
5937
5937
|
};
|
|
5938
5938
|
if (!P || d.isOnline && !p && !c)
|
|
5939
5939
|
return null;
|
|
5940
|
-
const
|
|
5940
|
+
const v = [
|
|
5941
5941
|
"nice-offline-indicator",
|
|
5942
5942
|
`nice-offline-indicator--${_}`,
|
|
5943
5943
|
`nice-offline-indicator--${S}`,
|
|
@@ -5947,8 +5947,8 @@ const Ie = () => {
|
|
|
5947
5947
|
O
|
|
5948
5948
|
].filter(Boolean).join(" ");
|
|
5949
5949
|
if (X)
|
|
5950
|
-
return /* @__PURE__ */ l("div", { className:
|
|
5951
|
-
const j = () => /* @__PURE__ */ l("span", { className: "nice-offline-indicator__icon", children:
|
|
5950
|
+
return /* @__PURE__ */ l("div", { className: v, style: z, children: X(d) });
|
|
5951
|
+
const j = () => /* @__PURE__ */ l("span", { className: "nice-offline-indicator__icon", children: b() }), q = () => /* @__PURE__ */ l("span", { className: "nice-offline-indicator__message", children: h() }), Y = () => g ? /* @__PURE__ */ K("div", { className: "nice-offline-indicator__details", children: [
|
|
5952
5952
|
d.offlineDuration !== void 0 && /* @__PURE__ */ K("span", { className: "nice-offline-indicator__duration", children: [
|
|
5953
5953
|
"Offline for ",
|
|
5954
5954
|
R(d.offlineDuration)
|
|
@@ -5974,19 +5974,19 @@ const Ie = () => {
|
|
|
5974
5974
|
) });
|
|
5975
5975
|
switch (_) {
|
|
5976
5976
|
case "icon-only":
|
|
5977
|
-
return /* @__PURE__ */ l("div", { className:
|
|
5977
|
+
return /* @__PURE__ */ l("div", { className: v, style: z, title: h(), children: j() });
|
|
5978
5978
|
case "minimal":
|
|
5979
|
-
return /* @__PURE__ */ K("div", { className:
|
|
5979
|
+
return /* @__PURE__ */ K("div", { className: v, style: z, children: [
|
|
5980
5980
|
j(),
|
|
5981
5981
|
q()
|
|
5982
5982
|
] });
|
|
5983
5983
|
case "badge":
|
|
5984
|
-
return /* @__PURE__ */ K("div", { className:
|
|
5984
|
+
return /* @__PURE__ */ K("div", { className: v, style: z, children: [
|
|
5985
5985
|
/* @__PURE__ */ l("div", { className: "nice-offline-indicator__badge-dot" }),
|
|
5986
5986
|
/* @__PURE__ */ l("span", { className: "nice-offline-indicator__badge-text", children: h() })
|
|
5987
5987
|
] });
|
|
5988
5988
|
case "toast":
|
|
5989
|
-
return /* @__PURE__ */ l("div", { className:
|
|
5989
|
+
return /* @__PURE__ */ l("div", { className: v, style: z, children: /* @__PURE__ */ K("div", { className: "nice-offline-indicator__toast", children: [
|
|
5990
5990
|
j(),
|
|
5991
5991
|
/* @__PURE__ */ K("div", { className: "nice-offline-indicator__toast-content", children: [
|
|
5992
5992
|
q(),
|
|
@@ -5994,7 +5994,7 @@ const Ie = () => {
|
|
|
5994
5994
|
] })
|
|
5995
5995
|
] }) });
|
|
5996
5996
|
case "detailed":
|
|
5997
|
-
return /* @__PURE__ */ l("div", { className:
|
|
5997
|
+
return /* @__PURE__ */ l("div", { className: v, style: z, children: /* @__PURE__ */ K("div", { className: "nice-offline-indicator__detailed", children: [
|
|
5998
5998
|
j(),
|
|
5999
5999
|
/* @__PURE__ */ K("div", { className: "nice-offline-indicator__detailed-content", children: [
|
|
6000
6000
|
q(),
|
|
@@ -6004,7 +6004,7 @@ const Ie = () => {
|
|
|
6004
6004
|
] }) });
|
|
6005
6005
|
case "banner":
|
|
6006
6006
|
default:
|
|
6007
|
-
return /* @__PURE__ */ l("div", { className:
|
|
6007
|
+
return /* @__PURE__ */ l("div", { className: v, style: z, children: /* @__PURE__ */ K("div", { className: "nice-offline-indicator__banner", children: [
|
|
6008
6008
|
j(),
|
|
6009
6009
|
q(),
|
|
6010
6010
|
g && /* @__PURE__ */ K(ve, { children: [
|
|
@@ -6054,9 +6054,9 @@ const An = ce(null), Dn = {
|
|
|
6054
6054
|
cachedCount: 0,
|
|
6055
6055
|
totalCacheSize: 0,
|
|
6056
6056
|
isDownloading: !1
|
|
6057
|
-
}), I = s(async () => N.current ? N.current : new Promise((R,
|
|
6057
|
+
}), I = s(async () => N.current ? N.current : new Promise((R, v) => {
|
|
6058
6058
|
const j = indexedDB.open(u.dbName, 1);
|
|
6059
|
-
j.onerror = () =>
|
|
6059
|
+
j.onerror = () => v(j.error), j.onupgradeneeded = () => {
|
|
6060
6060
|
const q = j.result;
|
|
6061
6061
|
if (!q.objectStoreNames.contains("media")) {
|
|
6062
6062
|
const Y = q.createObjectStore("media", { keyPath: "id" });
|
|
@@ -6068,27 +6068,27 @@ const An = ce(null), Dn = {
|
|
|
6068
6068
|
};
|
|
6069
6069
|
}), [u.dbName]), B = s(
|
|
6070
6070
|
async (R) => {
|
|
6071
|
-
const
|
|
6071
|
+
const v = await I();
|
|
6072
6072
|
return new Promise((j, q) => {
|
|
6073
|
-
const H =
|
|
6073
|
+
const H = v.transaction("media", "readwrite").objectStore("media").put(R);
|
|
6074
6074
|
H.onerror = () => q(H.error), H.onsuccess = () => j();
|
|
6075
6075
|
});
|
|
6076
6076
|
},
|
|
6077
6077
|
[I]
|
|
6078
6078
|
), T = s(
|
|
6079
|
-
async (R,
|
|
6079
|
+
async (R, v) => {
|
|
6080
6080
|
const j = await I();
|
|
6081
6081
|
return new Promise((q, Y) => {
|
|
6082
|
-
const x = j.transaction("blobs", "readwrite").objectStore("blobs").put({ id: R, blob:
|
|
6082
|
+
const x = j.transaction("blobs", "readwrite").objectStore("blobs").put({ id: R, blob: v });
|
|
6083
6083
|
x.onerror = () => Y(x.error), x.onsuccess = () => q();
|
|
6084
6084
|
});
|
|
6085
6085
|
},
|
|
6086
6086
|
[I]
|
|
6087
6087
|
), F = s(
|
|
6088
6088
|
async (R) => {
|
|
6089
|
-
const
|
|
6089
|
+
const v = await I();
|
|
6090
6090
|
return new Promise((j, q) => {
|
|
6091
|
-
const H =
|
|
6091
|
+
const H = v.transaction("blobs", "readonly").objectStore("blobs").get(R);
|
|
6092
6092
|
H.onerror = () => q(H.error), H.onsuccess = () => {
|
|
6093
6093
|
var x;
|
|
6094
6094
|
return j((x = H.result) == null ? void 0 : x.blob);
|
|
@@ -6098,9 +6098,9 @@ const An = ce(null), Dn = {
|
|
|
6098
6098
|
[I]
|
|
6099
6099
|
), G = s(
|
|
6100
6100
|
async (R) => {
|
|
6101
|
-
const
|
|
6101
|
+
const v = await I();
|
|
6102
6102
|
return new Promise((j, q) => {
|
|
6103
|
-
const H =
|
|
6103
|
+
const H = v.transaction("media", "readonly").objectStore("media").get(R);
|
|
6104
6104
|
H.onerror = () => q(H.error), H.onsuccess = () => {
|
|
6105
6105
|
const x = H.result;
|
|
6106
6106
|
x && (x.cachedAt = x.cachedAt ? new Date(x.cachedAt) : void 0, x.expiresAt = x.expiresAt ? new Date(x.expiresAt) : void 0), j(x);
|
|
@@ -6110,10 +6110,10 @@ const An = ce(null), Dn = {
|
|
|
6110
6110
|
[I]
|
|
6111
6111
|
), X = s(async () => {
|
|
6112
6112
|
const R = await I();
|
|
6113
|
-
return new Promise((
|
|
6113
|
+
return new Promise((v, j) => {
|
|
6114
6114
|
const W = R.transaction("media", "readonly").objectStore("media").getAll();
|
|
6115
6115
|
W.onerror = () => j(W.error), W.onsuccess = () => {
|
|
6116
|
-
|
|
6116
|
+
v(
|
|
6117
6117
|
W.result.map((H) => ({
|
|
6118
6118
|
...H,
|
|
6119
6119
|
cachedAt: H.cachedAt ? new Date(H.cachedAt) : void 0,
|
|
@@ -6124,9 +6124,9 @@ const An = ce(null), Dn = {
|
|
|
6124
6124
|
});
|
|
6125
6125
|
}, [I]), $ = s(
|
|
6126
6126
|
async (R) => {
|
|
6127
|
-
const
|
|
6127
|
+
const v = await I();
|
|
6128
6128
|
return new Promise((j, q) => {
|
|
6129
|
-
const x =
|
|
6129
|
+
const x = v.transaction("media", "readonly").objectStore("media").index("type").getAll(R);
|
|
6130
6130
|
x.onerror = () => q(x.error), x.onsuccess = () => j(x.result);
|
|
6131
6131
|
});
|
|
6132
6132
|
},
|
|
@@ -6139,24 +6139,24 @@ const An = ce(null), Dn = {
|
|
|
6139
6139
|
[X]
|
|
6140
6140
|
), O = s(
|
|
6141
6141
|
async (R) => {
|
|
6142
|
-
const
|
|
6142
|
+
const v = await I();
|
|
6143
6143
|
return new Promise((j, q) => {
|
|
6144
|
-
const x =
|
|
6144
|
+
const x = v.transaction("media", "readonly").objectStore("media").index("url").get(R);
|
|
6145
6145
|
x.onerror = () => q(x.error), x.onsuccess = () => j(x.result);
|
|
6146
6146
|
});
|
|
6147
6147
|
},
|
|
6148
6148
|
[I]
|
|
6149
6149
|
), z = s(
|
|
6150
6150
|
async (R) => {
|
|
6151
|
-
const
|
|
6152
|
-
return (
|
|
6151
|
+
const v = await O(R);
|
|
6152
|
+
return (v == null ? void 0 : v.status) === "completed";
|
|
6153
6153
|
},
|
|
6154
6154
|
[O]
|
|
6155
6155
|
), d = s(
|
|
6156
6156
|
async (R) => {
|
|
6157
|
-
const
|
|
6158
|
-
if (
|
|
6159
|
-
return
|
|
6157
|
+
const v = w.current.get(R);
|
|
6158
|
+
if (v)
|
|
6159
|
+
return v;
|
|
6160
6160
|
const j = await F(R);
|
|
6161
6161
|
if (!j)
|
|
6162
6162
|
return;
|
|
@@ -6165,7 +6165,7 @@ const An = ce(null), Dn = {
|
|
|
6165
6165
|
},
|
|
6166
6166
|
[F]
|
|
6167
6167
|
), A = s(
|
|
6168
|
-
async (R,
|
|
6168
|
+
async (R, v) => {
|
|
6169
6169
|
var H;
|
|
6170
6170
|
const j = await O(R);
|
|
6171
6171
|
if ((j == null ? void 0 : j.status) === "completed")
|
|
@@ -6173,16 +6173,16 @@ const An = ce(null), Dn = {
|
|
|
6173
6173
|
const q = new AbortController(), Y = (j == null ? void 0 : j.id) || Ln(), W = {
|
|
6174
6174
|
id: Y,
|
|
6175
6175
|
url: R,
|
|
6176
|
-
type: (
|
|
6177
|
-
name: (
|
|
6176
|
+
type: (v == null ? void 0 : v.type) || "other",
|
|
6177
|
+
name: (v == null ? void 0 : v.name) || Tn(R),
|
|
6178
6178
|
mimeType: "",
|
|
6179
6179
|
size: 0,
|
|
6180
6180
|
status: "queued",
|
|
6181
6181
|
progress: 0,
|
|
6182
6182
|
downloadedBytes: 0,
|
|
6183
|
-
metadata:
|
|
6184
|
-
tags:
|
|
6185
|
-
priority:
|
|
6183
|
+
metadata: v == null ? void 0 : v.metadata,
|
|
6184
|
+
tags: v == null ? void 0 : v.tags,
|
|
6185
|
+
priority: v == null ? void 0 : v.priority
|
|
6186
6186
|
};
|
|
6187
6187
|
L.current.set(Y, q), await B(W), S == null || S(W), g((x) => ({
|
|
6188
6188
|
...x,
|
|
@@ -6197,12 +6197,12 @@ const An = ce(null), Dn = {
|
|
|
6197
6197
|
}));
|
|
6198
6198
|
const x = await fetch(R, {
|
|
6199
6199
|
signal: q.signal,
|
|
6200
|
-
headers:
|
|
6200
|
+
headers: v == null ? void 0 : v.headers
|
|
6201
6201
|
});
|
|
6202
6202
|
if (!x.ok)
|
|
6203
6203
|
throw new Error(`HTTP ${x.status}`);
|
|
6204
6204
|
const J = x.headers.get("content-length"), Q = x.headers.get("content-type") || "", Z = J ? parseInt(J, 10) : 0;
|
|
6205
|
-
W.size = Z, W.mimeType = Q, W.type = (
|
|
6205
|
+
W.size = Z, W.mimeType = Q, W.type = (v == null ? void 0 : v.type) || Pn(R, Q);
|
|
6206
6206
|
const re = (H = x.body) == null ? void 0 : H.getReader();
|
|
6207
6207
|
if (!re)
|
|
6208
6208
|
throw new Error("No response body");
|
|
@@ -6215,7 +6215,7 @@ const An = ce(null), Dn = {
|
|
|
6215
6215
|
se.push(be), ae += be.length, W.downloadedBytes = ae, W.progress = Z > 0 ? Math.round(ae / Z * 100) : 0, await B(W), p == null || p(W);
|
|
6216
6216
|
}
|
|
6217
6217
|
const le = new Blob(se, { type: Q });
|
|
6218
|
-
return await T(Y, le), W.status = "completed", W.progress = 100, W.size = le.size, W.cachedAt = /* @__PURE__ */ new Date(), W.expiresAt =
|
|
6218
|
+
return await T(Y, le), W.status = "completed", W.progress = 100, W.size = le.size, W.cachedAt = /* @__PURE__ */ new Date(), W.expiresAt = v != null && v.cacheDuration ? new Date(Date.now() + v.cacheDuration) : new Date(Date.now() + u.defaultCacheDuration), await B(W), k == null || k(W), Y;
|
|
6219
6219
|
} catch (x) {
|
|
6220
6220
|
throw x.name === "AbortError" ? W.status = "cancelled" : (W.status = "failed", W.error = x instanceof Error ? x.message : "Download failed", M == null || M(W, x instanceof Error ? x : new Error(String(x)))), await B(W), x;
|
|
6221
6221
|
} finally {
|
|
@@ -6238,28 +6238,28 @@ const An = ce(null), Dn = {
|
|
|
6238
6238
|
]
|
|
6239
6239
|
), P = s(
|
|
6240
6240
|
async (R) => {
|
|
6241
|
-
const
|
|
6241
|
+
const v = [];
|
|
6242
6242
|
for (let j = 0; j < R.length; j += u.maxConcurrentDownloads) {
|
|
6243
6243
|
const q = R.slice(j, j + u.maxConcurrentDownloads), Y = await Promise.allSettled(
|
|
6244
6244
|
q.map((W) => A(W.url, W.options))
|
|
6245
6245
|
);
|
|
6246
6246
|
for (const W of Y)
|
|
6247
|
-
W.status === "fulfilled" &&
|
|
6247
|
+
W.status === "fulfilled" && v.push(W.value);
|
|
6248
6248
|
}
|
|
6249
|
-
return
|
|
6249
|
+
return v;
|
|
6250
6250
|
},
|
|
6251
6251
|
[A, u.maxConcurrentDownloads]
|
|
6252
6252
|
), E = s((R) => {
|
|
6253
|
-
const
|
|
6254
|
-
|
|
6253
|
+
const v = L.current.get(R);
|
|
6254
|
+
v && v.abort();
|
|
6255
6255
|
}, []), i = s(
|
|
6256
6256
|
async (R) => {
|
|
6257
|
-
const
|
|
6258
|
-
|
|
6259
|
-
type:
|
|
6260
|
-
name:
|
|
6261
|
-
metadata:
|
|
6262
|
-
tags:
|
|
6257
|
+
const v = await G(R);
|
|
6258
|
+
v && (v.status === "paused" || v.status === "failed") && await A(v.url, {
|
|
6259
|
+
type: v.type,
|
|
6260
|
+
name: v.name,
|
|
6261
|
+
metadata: v.metadata,
|
|
6262
|
+
tags: v.tags
|
|
6263
6263
|
});
|
|
6264
6264
|
},
|
|
6265
6265
|
[G, A]
|
|
@@ -6272,33 +6272,33 @@ const An = ce(null), Dn = {
|
|
|
6272
6272
|
for (const [R] of L.current)
|
|
6273
6273
|
E(R);
|
|
6274
6274
|
}, [E]), t = s(async () => {
|
|
6275
|
-
const
|
|
6276
|
-
await P(
|
|
6275
|
+
const v = (await X()).filter((j) => j.status === "paused" || j.status === "failed");
|
|
6276
|
+
await P(v.map((j) => ({ url: j.url })));
|
|
6277
6277
|
}, [X, P]), n = s(
|
|
6278
6278
|
async (R) => {
|
|
6279
|
-
const
|
|
6279
|
+
const v = await I(), j = w.current.get(R);
|
|
6280
6280
|
j && (URL.revokeObjectURL(j), w.current.delete(R)), await new Promise((q, Y) => {
|
|
6281
|
-
const W =
|
|
6281
|
+
const W = v.transaction(["media", "blobs"], "readwrite");
|
|
6282
6282
|
W.objectStore("media").delete(R), W.objectStore("blobs").delete(R), W.onerror = () => Y(W.error), W.oncomplete = () => q();
|
|
6283
6283
|
}), U == null || U(R), await h();
|
|
6284
6284
|
},
|
|
6285
6285
|
[I, U]
|
|
6286
6286
|
), a = s(async () => {
|
|
6287
6287
|
const R = await I();
|
|
6288
|
-
for (const [,
|
|
6289
|
-
URL.revokeObjectURL(
|
|
6290
|
-
w.current.clear(), await new Promise((
|
|
6288
|
+
for (const [, v] of w.current)
|
|
6289
|
+
URL.revokeObjectURL(v);
|
|
6290
|
+
w.current.clear(), await new Promise((v, j) => {
|
|
6291
6291
|
const q = R.transaction(["media", "blobs"], "readwrite");
|
|
6292
|
-
q.objectStore("media").clear(), q.objectStore("blobs").clear(), q.onerror = () => j(q.error), q.oncomplete = () =>
|
|
6292
|
+
q.objectStore("media").clear(), q.objectStore("blobs").clear(), q.onerror = () => j(q.error), q.oncomplete = () => v();
|
|
6293
6293
|
}), await h();
|
|
6294
6294
|
}, [I]), c = s(async () => {
|
|
6295
|
-
const R = await X(),
|
|
6295
|
+
const R = await X(), v = Date.now();
|
|
6296
6296
|
let j = 0;
|
|
6297
6297
|
for (const q of R)
|
|
6298
|
-
q.expiresAt && q.expiresAt.getTime() <
|
|
6298
|
+
q.expiresAt && q.expiresAt.getTime() < v && (await n(q.id), j++);
|
|
6299
6299
|
return j;
|
|
6300
6300
|
}, [X, n]), C = s(async () => {
|
|
6301
|
-
const
|
|
6301
|
+
const v = (await X()).filter((Y) => Y.status === "completed"), j = {
|
|
6302
6302
|
image: { count: 0, size: 0 },
|
|
6303
6303
|
video: { count: 0, size: 0 },
|
|
6304
6304
|
audio: { count: 0, size: 0 },
|
|
@@ -6306,22 +6306,22 @@ const An = ce(null), Dn = {
|
|
|
6306
6306
|
other: { count: 0, size: 0 }
|
|
6307
6307
|
};
|
|
6308
6308
|
let q = 0;
|
|
6309
|
-
for (const Y of
|
|
6309
|
+
for (const Y of v)
|
|
6310
6310
|
q += Y.size, j[Y.type].count++, j[Y.type].size += Y.size;
|
|
6311
6311
|
return {
|
|
6312
6312
|
totalSize: q,
|
|
6313
|
-
itemCount:
|
|
6313
|
+
itemCount: v.length,
|
|
6314
6314
|
byType: j
|
|
6315
6315
|
};
|
|
6316
6316
|
}, [X]), y = s(
|
|
6317
6317
|
async (R) => {
|
|
6318
|
-
await P(R.map((
|
|
6318
|
+
await P(R.map((v) => ({ url: v, options: { priority: -1 } })));
|
|
6319
6319
|
},
|
|
6320
6320
|
[P]
|
|
6321
6321
|
), h = s(async () => {
|
|
6322
6322
|
const R = await C();
|
|
6323
|
-
g((
|
|
6324
|
-
...
|
|
6323
|
+
g((v) => ({
|
|
6324
|
+
...v,
|
|
6325
6325
|
cachedCount: R.itemCount,
|
|
6326
6326
|
totalCacheSize: R.totalSize
|
|
6327
6327
|
}));
|
|
@@ -6329,11 +6329,11 @@ const An = ce(null), Dn = {
|
|
|
6329
6329
|
ne(() => {
|
|
6330
6330
|
const R = () => {
|
|
6331
6331
|
g((j) => ({ ...j, isOnline: !0 })), u.autoResumeOnReconnect && t();
|
|
6332
|
-
},
|
|
6332
|
+
}, v = () => {
|
|
6333
6333
|
g((j) => ({ ...j, isOnline: !1 })), e();
|
|
6334
6334
|
};
|
|
6335
|
-
return window.addEventListener("online", R), window.addEventListener("offline",
|
|
6336
|
-
window.removeEventListener("online", R), window.removeEventListener("offline",
|
|
6335
|
+
return window.addEventListener("online", R), window.addEventListener("offline", v), () => {
|
|
6336
|
+
window.removeEventListener("online", R), window.removeEventListener("offline", v);
|
|
6337
6337
|
};
|
|
6338
6338
|
}, [u.autoResumeOnReconnect, t, e]), ne(() => {
|
|
6339
6339
|
if (!u.autoCleanup)
|
|
@@ -6342,10 +6342,14 @@ const An = ce(null), Dn = {
|
|
|
6342
6342
|
c();
|
|
6343
6343
|
}, u.cleanupInterval);
|
|
6344
6344
|
return () => clearInterval(R);
|
|
6345
|
-
}, [u.autoCleanup, u.cleanupInterval, c]), ne(() =>
|
|
6346
|
-
|
|
6347
|
-
|
|
6348
|
-
|
|
6345
|
+
}, [u.autoCleanup, u.cleanupInterval, c]), ne(() => {
|
|
6346
|
+
I().then(() => h());
|
|
6347
|
+
const R = w.current;
|
|
6348
|
+
return () => {
|
|
6349
|
+
for (const [, v] of R)
|
|
6350
|
+
URL.revokeObjectURL(v);
|
|
6351
|
+
};
|
|
6352
|
+
}, [I, h]), oe(
|
|
6349
6353
|
D,
|
|
6350
6354
|
() => ({
|
|
6351
6355
|
getState: () => f,
|
|
@@ -6390,7 +6394,7 @@ const An = ce(null), Dn = {
|
|
|
6390
6394
|
y
|
|
6391
6395
|
]
|
|
6392
6396
|
);
|
|
6393
|
-
const
|
|
6397
|
+
const b = {
|
|
6394
6398
|
...f,
|
|
6395
6399
|
download: A,
|
|
6396
6400
|
downloadMultiple: P,
|
|
@@ -6407,7 +6411,7 @@ const An = ce(null), Dn = {
|
|
|
6407
6411
|
clearCache: a,
|
|
6408
6412
|
preload: y
|
|
6409
6413
|
};
|
|
6410
|
-
return /* @__PURE__ */ l(An.Provider, { value:
|
|
6414
|
+
return /* @__PURE__ */ l(An.Provider, { value: b, children: o });
|
|
6411
6415
|
}
|
|
6412
6416
|
);
|
|
6413
6417
|
ze.displayName = "NiceOfflineMedia";
|
|
@@ -6461,10 +6465,10 @@ const On = ce(null), Rn = {
|
|
|
6461
6465
|
return [];
|
|
6462
6466
|
const c = await caches.keys(), C = [];
|
|
6463
6467
|
for (const y of c) {
|
|
6464
|
-
const h = await caches.open(y),
|
|
6468
|
+
const h = await caches.open(y), b = await h.keys();
|
|
6465
6469
|
let R = 0;
|
|
6466
|
-
for (const
|
|
6467
|
-
const j = await h.match(
|
|
6470
|
+
for (const v of b) {
|
|
6471
|
+
const j = await h.match(v);
|
|
6468
6472
|
if (j) {
|
|
6469
6473
|
const q = await j.clone().blob();
|
|
6470
6474
|
R += q.size;
|
|
@@ -6473,7 +6477,7 @@ const On = ce(null), Rn = {
|
|
|
6473
6477
|
C.push({
|
|
6474
6478
|
name: y,
|
|
6475
6479
|
size: R,
|
|
6476
|
-
itemCount:
|
|
6480
|
+
itemCount: b.length
|
|
6477
6481
|
});
|
|
6478
6482
|
}
|
|
6479
6483
|
return F((y) => ({ ...y, caches: C })), C;
|