@nivaro/react 0.3.136 → 0.3.138
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/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +1 -1
- package/dist/index.d.ts +95 -4
- package/dist/index.js +748 -743
- package/dist/shared/components/CollectionBrowserView.js +392 -389
- package/dist/shared/components/DelegateCoverLine.js +80 -87
- package/dist/shared/components/ItemEditForm.js +589 -588
- package/dist/shared/components/MyWorkView.js +284 -286
- package/dist/shared/components/NotificationBell.js +251 -205
- package/dist/shared/components/ai/AiAnalyticsView.js +878 -417
- package/dist/shared/components/ai/AiPlanCard.js +164 -122
- package/dist/shared/components/ai/AiPlanUndo.js +291 -0
- package/dist/shared/components/ai/call-log/CallDrawer.js +357 -0
- package/dist/shared/components/ai/call-log/RawJson.js +126 -0
- package/dist/shared/components/ai/call-log/ThreadView.js +223 -0
- package/dist/shared/components/ai/call-log/TranscriptView.js +227 -0
- package/dist/shared/components/ai/call-log/controls.js +364 -0
- package/dist/shared/components/ai/call-log/format.js +46 -0
- package/dist/shared/components/ai/call-log/url.js +105 -0
- package/dist/shared/components/chat/ChatPanel.js +86 -86
- package/dist/shared/components/chat/chat-core.js +422 -346
- package/dist/shared/components/integrations/IntegrationObligationsView.js +98 -98
- package/dist/shared/components/integrations/RecordIntegrationPreview.js +102 -93
- package/dist/shared/components/integrations/console/api.js +11 -1
- package/dist/shared/components/item-edit/HeaderRollupExplainer.js +5 -1
- package/dist/shared/components/item-edit/RecordLiveSync.js +241 -229
- package/dist/shared/components/item-edit/RecordRecapChanges.js +166 -0
- package/dist/shared/components/item-edit/RecordRecapStrip.js +254 -84
- package/dist/shared/components/item-edit/live-related.js +34 -18
- package/dist/shared/components/panels/RevisionsPanel.js +735 -683
- package/dist/shared/components/queue/QueueWorklist.js +323 -316
- package/dist/shared/components/support/SupportRequestDialog.js +198 -181
- package/dist/shared/components/trackers/use-tracker-link.js +74 -65
- package/dist/shared/lib/config-update-refresh.js +34 -0
- package/dist/shared/lib/config-watch.js +17 -17
- package/dist/shared/lib/gap-refresh.js +49 -0
- package/dist/shared/lib/integration-dots.js +8 -8
- package/dist/shared/lib/live-ops.js +26 -23
- package/dist/shared/lib/live-pickers.js +1 -1
- package/dist/shared/lib/live-queries.js +223 -195
- package/dist/shared/lib/live.js +56 -51
- package/dist/shared/lib/obligation-banner.js +11 -10
- package/dist/shared/lib/obligation-filters.js +22 -18
- package/dist/shared/lib/obligation-reason-text.js +18 -8
- package/dist/shared/lib/presence-hooks.js +133 -132
- package/dist/shared/lib/reconnect-resync.js +90 -0
- package/dist/shared/lib/record-room-holds.js +43 -0
- package/dist/shared/lib/socket-realtime.js +116 -105
- package/dist/shared/lib/user-sync.js +1 -6
- package/package.json +1 -1
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
import { useQuery as F } from "@tanstack/react-query";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as R, useEffect as v, useCallback as C, useMemo as A, useRef as U } from "react";
|
|
3
3
|
import { useOptionalNivaroClient as q } from "../context.js";
|
|
4
4
|
import { post as $, get as B } from "./commands.js";
|
|
5
5
|
import { trackActivity as N, onIdleChange as W, idleState as z } from "./idle.js";
|
|
6
6
|
import { useLiveEvent as E } from "./live.js";
|
|
7
|
-
import { useMyUserId as M, useRecordSignalPeers as
|
|
8
|
-
import { useOptionalRealtime as P, useRealtimeStatus as
|
|
7
|
+
import { useMyUserId as M, useRecordSignalPeers as H, useRecordSignalWhile as Q } from "./presence-signals.js";
|
|
8
|
+
import { useOptionalRealtime as P, useRealtimeStatus as Y } from "./realtime.js";
|
|
9
|
+
import { newRecordRoomHolder as G } from "./record-room-holds.js";
|
|
9
10
|
let O = null, I = !1;
|
|
10
11
|
const T = /* @__PURE__ */ new Set();
|
|
11
12
|
function L() {
|
|
@@ -14,123 +15,123 @@ function L() {
|
|
|
14
15
|
function D() {
|
|
15
16
|
if (I || typeof document > "u") return;
|
|
16
17
|
I = !0, N(), O = L() ? Date.now() : null;
|
|
17
|
-
const
|
|
18
|
-
const
|
|
19
|
-
if (
|
|
20
|
-
O =
|
|
18
|
+
const r = () => {
|
|
19
|
+
const o = L();
|
|
20
|
+
if (o !== (O != null)) {
|
|
21
|
+
O = o ? Date.now() : null;
|
|
21
22
|
for (const e of T)
|
|
22
23
|
try {
|
|
23
|
-
e(
|
|
24
|
+
e(o);
|
|
24
25
|
} catch {
|
|
25
26
|
}
|
|
26
27
|
}
|
|
27
28
|
};
|
|
28
|
-
document.addEventListener("visibilitychange",
|
|
29
|
+
document.addEventListener("visibilitychange", r), W(r);
|
|
29
30
|
}
|
|
30
31
|
function K() {
|
|
31
32
|
return D(), O != null;
|
|
32
33
|
}
|
|
33
|
-
function
|
|
34
|
-
return D(), T.add(
|
|
34
|
+
function J(r) {
|
|
35
|
+
return D(), T.add(r), () => T.delete(r);
|
|
35
36
|
}
|
|
36
|
-
function _(
|
|
37
|
+
function _(r, o, e = Date.now()) {
|
|
37
38
|
return K() ? {
|
|
38
|
-
collection:
|
|
39
|
-
item: String(
|
|
39
|
+
collection: r,
|
|
40
|
+
item: String(o),
|
|
40
41
|
hidden: !0,
|
|
41
42
|
hidden_ms: Math.max(0, e - (O ?? e))
|
|
42
|
-
} : { collection:
|
|
43
|
+
} : { collection: r, item: String(o), hidden: !1 };
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
-
const e =
|
|
46
|
-
for (const t of
|
|
45
|
+
function X(r, o) {
|
|
46
|
+
const e = o ? String(o).toUpperCase() : null, i = /* @__PURE__ */ new Set(), s = [];
|
|
47
|
+
for (const t of r ?? []) {
|
|
47
48
|
if (!t || t.id == null) continue;
|
|
48
49
|
const u = String(t.id).toUpperCase();
|
|
49
50
|
u === e || i.has(u) || (i.add(u), s.push(t));
|
|
50
51
|
}
|
|
51
52
|
return s;
|
|
52
53
|
}
|
|
53
|
-
function V(
|
|
54
|
-
const e =
|
|
55
|
-
s.current =
|
|
56
|
-
|
|
57
|
-
}, [e == null ? void 0 : e.state,
|
|
54
|
+
function V(r, o) {
|
|
55
|
+
const e = Y(), i = U(!1), s = U(r);
|
|
56
|
+
s.current = r, v(() => {
|
|
57
|
+
o && ((e == null ? void 0 : e.state) === "reconnecting" ? i.current = !0 : i.current && (i.current = !1, s.current()));
|
|
58
|
+
}, [e == null ? void 0 : e.state, o]);
|
|
58
59
|
}
|
|
59
|
-
function
|
|
60
|
-
const e = P(), i = M(), s =
|
|
61
|
-
!t || !e || !
|
|
62
|
-
}, [e,
|
|
60
|
+
function ae(r, o) {
|
|
61
|
+
const e = P(), i = M(), s = o == null ? "" : String(o), t = !!e && !!r && !!s && s !== "new", [u, m] = R([]), y = A(() => G("p"), []), h = C(() => {
|
|
62
|
+
!t || !e || !r || (e.emit("record:join", { collection: r, item: s, holder: y }), K() && e.emit("record:visibility", _(r, s)));
|
|
63
|
+
}, [e, r, s, t, y]);
|
|
63
64
|
return v(() => {
|
|
64
|
-
if (
|
|
65
|
+
if (m([]), !t) return;
|
|
65
66
|
h();
|
|
66
|
-
const
|
|
67
|
-
|
|
67
|
+
const n = J(() => {
|
|
68
|
+
r && (e == null || e.emit("record:visibility", _(r, s)));
|
|
68
69
|
});
|
|
69
70
|
return () => {
|
|
70
|
-
|
|
71
|
+
n(), e == null || e.emit("record:leave", { collection: r, item: s, holder: y });
|
|
71
72
|
};
|
|
72
|
-
}, [e,
|
|
73
|
+
}, [e, r, s, t, h, y]), V(h, t), E(
|
|
73
74
|
"record:viewers",
|
|
74
|
-
(
|
|
75
|
-
Array.isArray(
|
|
75
|
+
(n) => {
|
|
76
|
+
Array.isArray(n == null ? void 0 : n.viewers) && m(n.viewers);
|
|
76
77
|
},
|
|
77
78
|
{
|
|
78
79
|
enabled: t,
|
|
79
80
|
includeOwn: !0,
|
|
80
81
|
// An older server names no record: accept, as the hosts' own hooks do.
|
|
81
|
-
match: (
|
|
82
|
+
match: (n) => (n == null ? void 0 : n.collection) == null || (n == null ? void 0 : n.item) == null ? !0 : n.collection === r && String(n.item) === s
|
|
82
83
|
}
|
|
83
|
-
), { viewers:
|
|
84
|
+
), { viewers: A(() => X(u, i), [u, i]) };
|
|
84
85
|
}
|
|
85
|
-
function
|
|
86
|
-
const i = P(), s = M(), t =
|
|
87
|
-
v(() =>
|
|
86
|
+
function de(r, o, e = {}) {
|
|
87
|
+
const i = P(), s = M(), t = o == null ? "" : String(o), u = !!i && !!r && !!t && t !== "new", [m, y] = R({});
|
|
88
|
+
v(() => y({}), [r, t]), E(
|
|
88
89
|
"field:editing",
|
|
89
|
-
(
|
|
90
|
-
typeof (
|
|
91
|
-
const p = { ...b },
|
|
92
|
-
return
|
|
90
|
+
(n) => {
|
|
91
|
+
typeof (n == null ? void 0 : n.field) == "string" && y((b) => {
|
|
92
|
+
const p = { ...b }, d = n.user;
|
|
93
|
+
return d && (!s || String(d.id).toUpperCase() !== s.toUpperCase()) ? p[n.field] = d : delete p[n.field], p;
|
|
93
94
|
});
|
|
94
95
|
},
|
|
95
96
|
{
|
|
96
97
|
enabled: u,
|
|
97
98
|
includeOwn: !0,
|
|
98
|
-
match: (
|
|
99
|
+
match: (n) => (n == null ? void 0 : n.collection) == null || (n == null ? void 0 : n.item) == null ? !0 : n.collection === r && String(n.item) === t
|
|
99
100
|
}
|
|
100
101
|
);
|
|
101
|
-
const
|
|
102
|
-
(
|
|
103
|
-
u &&
|
|
102
|
+
const h = C(
|
|
103
|
+
(n) => {
|
|
104
|
+
u && n && (i == null || i.emit("field:focus", { field: n, collection: r, item: t }));
|
|
104
105
|
},
|
|
105
|
-
[i,
|
|
106
|
-
),
|
|
107
|
-
(
|
|
108
|
-
u &&
|
|
106
|
+
[i, r, t, u]
|
|
107
|
+
), S = C(
|
|
108
|
+
(n) => {
|
|
109
|
+
u && n && (i == null || i.emit("field:blur", { field: n, collection: r, item: t }));
|
|
109
110
|
},
|
|
110
|
-
[i,
|
|
111
|
+
[i, r, t, u]
|
|
111
112
|
);
|
|
112
113
|
return v(() => {
|
|
113
114
|
if (!u || !e.capture || typeof document > "u") return;
|
|
114
|
-
const
|
|
115
|
-
var c, g,
|
|
116
|
-
return (
|
|
117
|
-
}, b = (
|
|
118
|
-
const c =
|
|
115
|
+
const n = (d) => {
|
|
116
|
+
var c, g, f;
|
|
117
|
+
return (f = (g = (c = d.target) == null ? void 0 : c.closest) == null ? void 0 : g.call(c, "[data-field]")) == null ? void 0 : f.getAttribute("data-field");
|
|
118
|
+
}, b = (d) => {
|
|
119
|
+
const c = n(d);
|
|
120
|
+
c && h(c);
|
|
121
|
+
}, p = (d) => {
|
|
122
|
+
const c = n(d);
|
|
119
123
|
c && S(c);
|
|
120
|
-
}, p = (m) => {
|
|
121
|
-
const c = o(m);
|
|
122
|
-
c && l(c);
|
|
123
124
|
};
|
|
124
125
|
return document.addEventListener("focusin", b), document.addEventListener("focusout", p), () => {
|
|
125
126
|
document.removeEventListener("focusin", b), document.removeEventListener("focusout", p);
|
|
126
127
|
};
|
|
127
|
-
}, [u, e.capture,
|
|
128
|
+
}, [u, e.capture, h, S]), { editing: m, focus: h, blur: S };
|
|
128
129
|
}
|
|
129
|
-
function
|
|
130
|
-
const e =
|
|
131
|
-
|
|
132
|
-
const t =
|
|
133
|
-
t.current && clearTimeout(t.current), t.current = null, s(
|
|
130
|
+
function me(r, o) {
|
|
131
|
+
const e = H(r, o, "note"), [i, s] = R(!1);
|
|
132
|
+
Q(r, o, "note", i);
|
|
133
|
+
const t = U(null), u = C((m) => {
|
|
134
|
+
t.current && clearTimeout(t.current), t.current = null, s(m), m && (t.current = setTimeout(() => s(!1), 6e3));
|
|
134
135
|
}, []);
|
|
135
136
|
return v(
|
|
136
137
|
() => () => {
|
|
@@ -139,124 +140,124 @@ function ae(n, r) {
|
|
|
139
140
|
[]
|
|
140
141
|
), { typing: e, setTyping: u };
|
|
141
142
|
}
|
|
142
|
-
const
|
|
143
|
-
function k(
|
|
144
|
-
return `${
|
|
143
|
+
const Z = {};
|
|
144
|
+
function k(r, o) {
|
|
145
|
+
return `${r}:${o}`;
|
|
145
146
|
}
|
|
146
|
-
function
|
|
147
|
-
const
|
|
148
|
-
if (!(
|
|
149
|
-
const e = String(
|
|
150
|
-
return
|
|
147
|
+
function ee(r) {
|
|
148
|
+
const o = r;
|
|
149
|
+
if (!(o != null && o.collection)) return [];
|
|
150
|
+
const e = String(o.collection), i = (s) => Array.isArray(s) ? s.map(String) : [];
|
|
151
|
+
return o.rows && typeof o.rows == "object" ? Object.entries(o.rows).map(([s, t]) => [
|
|
151
152
|
k(e, s),
|
|
152
153
|
i(t)
|
|
153
|
-
]) :
|
|
154
|
+
]) : o.item == null ? [] : [[k(e, String(o.item)), i(o.user_ids)]];
|
|
154
155
|
}
|
|
155
|
-
function
|
|
156
|
-
const
|
|
156
|
+
function te(r) {
|
|
157
|
+
const o = q(), e = [...new Set(r.map((s) => s.toUpperCase()))].sort().join(","), { data: i } = F({
|
|
157
158
|
queryKey: ["presence-visible-people", e],
|
|
158
|
-
queryFn: () =>
|
|
159
|
+
queryFn: () => o.request(
|
|
159
160
|
B(`/presence/people?ids=${encodeURIComponent(e.split(",").slice(0, 100).join(","))}`)
|
|
160
161
|
).then((s) => new Set((s.data ?? []).map((t) => String(t.user_id).toUpperCase()))).catch(() => /* @__PURE__ */ new Set()),
|
|
161
|
-
enabled: !!
|
|
162
|
+
enabled: !!o && e.length > 0,
|
|
162
163
|
staleTime: 5 * 6e4
|
|
163
164
|
});
|
|
164
165
|
return e.length === 0 ? null : i ?? null;
|
|
165
166
|
}
|
|
166
|
-
function
|
|
167
|
-
const
|
|
168
|
-
for (const i of
|
|
167
|
+
function j(r) {
|
|
168
|
+
const o = /* @__PURE__ */ new Map();
|
|
169
|
+
for (const i of r) {
|
|
169
170
|
const s = i.indexOf(":");
|
|
170
171
|
if (s <= 0) continue;
|
|
171
|
-
const t = i.slice(0, s), u =
|
|
172
|
-
u.push(i.slice(s + 1)),
|
|
172
|
+
const t = i.slice(0, s), u = o.get(t) ?? [];
|
|
173
|
+
u.push(i.slice(s + 1)), o.set(t, u);
|
|
173
174
|
}
|
|
174
175
|
const e = [];
|
|
175
|
-
for (const [i, s] of
|
|
176
|
+
for (const [i, s] of o)
|
|
176
177
|
for (let t = 0; t < s.length; t += 100)
|
|
177
178
|
e.push({ collection: i, items: s.slice(t, t + 100) });
|
|
178
179
|
return e;
|
|
179
180
|
}
|
|
180
|
-
function
|
|
181
|
-
const e = P(), i = q(), s = M(), t =
|
|
181
|
+
function we(r, o = {}) {
|
|
182
|
+
const e = P(), i = q(), s = M(), t = o.enabled !== !1 && r.length > 0, u = r.filter((c) => c.collection && c.item != null).map((c) => k(c.collection, c.item)).join(""), [m, y] = R({}), [h, S] = R({}), n = U(/* @__PURE__ */ new Set()), b = C(() => {
|
|
182
183
|
if (!(!e || !t))
|
|
183
|
-
for (const c of
|
|
184
|
+
for (const c of j(n.current)) e.emit("presence:watch", c);
|
|
184
185
|
}, [e, t]);
|
|
185
186
|
v(() => {
|
|
186
187
|
if (!e || !t) return;
|
|
187
|
-
const c = new Set(u.split("").filter(Boolean)), g = [...c].filter((
|
|
188
|
-
|
|
189
|
-
for (const
|
|
190
|
-
if (
|
|
191
|
-
for (const
|
|
192
|
-
|
|
193
|
-
const
|
|
194
|
-
for (const
|
|
195
|
-
return
|
|
188
|
+
const c = new Set(u.split("").filter(Boolean)), g = [...c].filter((l) => !n.current.has(l)), f = [...n.current].filter((l) => !c.has(l));
|
|
189
|
+
n.current = c;
|
|
190
|
+
for (const l of j(g)) e.emit("presence:watch", l);
|
|
191
|
+
if (f.length) {
|
|
192
|
+
for (const l of j(f)) e.emit("presence:unwatch", l);
|
|
193
|
+
y((l) => {
|
|
194
|
+
const w = { ...l };
|
|
195
|
+
for (const a of f) delete w[a];
|
|
196
|
+
return w;
|
|
196
197
|
});
|
|
197
198
|
}
|
|
198
199
|
}, [e, u, t]), v(() => {
|
|
199
200
|
if (e)
|
|
200
201
|
return () => {
|
|
201
|
-
|
|
202
|
+
n.current.size && e.emit("presence:unwatch", {}), n.current = /* @__PURE__ */ new Set(), y({});
|
|
202
203
|
};
|
|
203
204
|
}, [e]), V(b, !!e && t), E(
|
|
204
205
|
"presence:rows",
|
|
205
206
|
(c) => {
|
|
206
|
-
const g =
|
|
207
|
-
g.length !== 0 &&
|
|
208
|
-
const
|
|
209
|
-
for (const [
|
|
210
|
-
|
|
211
|
-
return
|
|
207
|
+
const g = ee(c);
|
|
208
|
+
g.length !== 0 && y((f) => {
|
|
209
|
+
const l = { ...f };
|
|
210
|
+
for (const [w, a] of g)
|
|
211
|
+
a.length ? l[w] = a : delete l[w];
|
|
212
|
+
return l;
|
|
212
213
|
});
|
|
213
214
|
},
|
|
214
215
|
{ enabled: !!e && t, includeOwn: !0 }
|
|
215
216
|
), v(() => {
|
|
216
217
|
if (e || !i || !t) return;
|
|
217
|
-
const c =
|
|
218
|
-
const x =
|
|
219
|
-
return { collection:
|
|
218
|
+
const c = o.pollMs ?? 3e4, g = u.split("").filter(Boolean).slice(0, 100).map((a) => {
|
|
219
|
+
const x = a.indexOf(":");
|
|
220
|
+
return { collection: a.slice(0, x), item_id: a.slice(x + 1) };
|
|
220
221
|
});
|
|
221
|
-
let
|
|
222
|
-
const
|
|
223
|
-
i.request($("/presence/record-viewers", { pairs: g })).then((
|
|
224
|
-
|
|
222
|
+
let f = !0;
|
|
223
|
+
const l = () => {
|
|
224
|
+
i.request($("/presence/record-viewers", { pairs: g })).then((a) => {
|
|
225
|
+
f && S(a.data ?? {});
|
|
225
226
|
}).catch(() => {
|
|
226
227
|
});
|
|
227
228
|
};
|
|
228
|
-
|
|
229
|
-
const
|
|
229
|
+
l();
|
|
230
|
+
const w = c > 0 ? setInterval(l, c) : null;
|
|
230
231
|
return () => {
|
|
231
|
-
|
|
232
|
+
f = !1, w && clearInterval(w);
|
|
232
233
|
};
|
|
233
|
-
}, [e, i, u, t,
|
|
234
|
-
const p =
|
|
235
|
-
return
|
|
236
|
-
if (!t) return
|
|
234
|
+
}, [e, i, u, t, o.pollMs]);
|
|
235
|
+
const p = A(() => [...new Set(Object.values(m).flat())], [m]), d = te(p);
|
|
236
|
+
return A(() => {
|
|
237
|
+
if (!t) return Z;
|
|
237
238
|
const c = {}, g = s == null ? void 0 : s.toUpperCase();
|
|
238
239
|
if (e)
|
|
239
|
-
for (const [
|
|
240
|
-
const
|
|
241
|
-
|
|
242
|
-
ids:
|
|
243
|
-
count:
|
|
240
|
+
for (const [f, l] of Object.entries(m)) {
|
|
241
|
+
const w = l.filter((a) => a.toUpperCase() !== g);
|
|
242
|
+
w.length !== 0 && (c[f] = {
|
|
243
|
+
ids: d ? w.filter((a) => d.has(a.toUpperCase())) : [],
|
|
244
|
+
count: w.length
|
|
244
245
|
});
|
|
245
246
|
}
|
|
246
247
|
else
|
|
247
|
-
for (const [
|
|
248
|
+
for (const [f, l] of Object.entries(h)) l > 0 && (c[f] = { ids: [], count: l });
|
|
248
249
|
return c;
|
|
249
|
-
}, [t, e,
|
|
250
|
+
}, [t, e, m, h, d, s]);
|
|
250
251
|
}
|
|
251
252
|
export {
|
|
252
|
-
|
|
253
|
-
|
|
253
|
+
X as distinctOtherViewers,
|
|
254
|
+
J as onRecordTabAway,
|
|
254
255
|
K as recordTabAway,
|
|
255
256
|
_ as recordVisibilityPayload,
|
|
256
257
|
k as rowPresenceKey,
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
258
|
+
ee as rowPresenceUpdates,
|
|
259
|
+
de as useFieldFocus,
|
|
260
|
+
ae as usePresence,
|
|
261
|
+
we as useRowPresence,
|
|
262
|
+
me as useTyping
|
|
262
263
|
};
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
import { useRef as S, useEffect as V } from "react";
|
|
2
|
+
import { getLiveMode as W } from "./live-preference.js";
|
|
3
|
+
import { useOptionalRealtime as _ } from "./realtime.js";
|
|
4
|
+
const j = "nvr:resync";
|
|
5
|
+
function C(n, e = {}) {
|
|
6
|
+
var p, x;
|
|
7
|
+
const s = Math.max(0, e.jitterMs ?? 4e3), o = Math.max(0, e.cooldownMs ?? 5e3), r = e.wakeGapMs ?? 15e4, f = e.wakeTickMs ?? 15e3, a = e.now ?? (() => Date.now()), L = e.random ?? Math.random, c = e.doc === void 0 ? typeof document > "u" ? null : document : e.doc, h = e.win === void 0 ? typeof window > "u" ? null : window : e.win, m = e.allowed ?? (() => W() !== "off"), l = /* @__PURE__ */ new Set();
|
|
8
|
+
let w = !1, i = null, d = null, k = Number.NEGATIVE_INFINITY, v = null;
|
|
9
|
+
const E = () => !!c && c.visibilityState === "hidden", g = (t) => {
|
|
10
|
+
if (!w) {
|
|
11
|
+
if (E()) {
|
|
12
|
+
d = d ?? t;
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
if (d = null, !!m()) {
|
|
16
|
+
k = a();
|
|
17
|
+
for (const u of [...l])
|
|
18
|
+
try {
|
|
19
|
+
u(t);
|
|
20
|
+
} catch {
|
|
21
|
+
}
|
|
22
|
+
try {
|
|
23
|
+
h == null || h.dispatchEvent(new CustomEvent(j, { detail: { reason: t } }));
|
|
24
|
+
} catch {
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
}, y = (t) => {
|
|
29
|
+
if (w) return;
|
|
30
|
+
if (i) {
|
|
31
|
+
t === "reconnect" && (v = "reconnect");
|
|
32
|
+
return;
|
|
33
|
+
}
|
|
34
|
+
v = t;
|
|
35
|
+
const u = a() - k, D = Math.max(0, o - u) + Math.floor(L() * Math.max(0, s));
|
|
36
|
+
i = setTimeout(() => {
|
|
37
|
+
i = null;
|
|
38
|
+
const G = v ?? t;
|
|
39
|
+
v = null, g(G);
|
|
40
|
+
}, D);
|
|
41
|
+
};
|
|
42
|
+
let T = ((p = n == null ? void 0 : n.status) == null ? void 0 : p.call(n).state) !== "reconnecting";
|
|
43
|
+
const b = (x = n == null ? void 0 : n.onStatus) == null ? void 0 : x.call(n, (t) => {
|
|
44
|
+
const u = t.state === "live";
|
|
45
|
+
u && !T && t.resumed !== null && y("reconnect"), T = u;
|
|
46
|
+
});
|
|
47
|
+
let I = a();
|
|
48
|
+
const N = f > 0 ? setInterval(() => {
|
|
49
|
+
const t = a();
|
|
50
|
+
t - I > r && y("wake"), I = t;
|
|
51
|
+
}, f) : null, R = () => {
|
|
52
|
+
!E() && d && !i && g(d);
|
|
53
|
+
};
|
|
54
|
+
return c == null || c.addEventListener("visibilitychange", R), {
|
|
55
|
+
subscribe(t) {
|
|
56
|
+
return l.add(t), () => {
|
|
57
|
+
l.delete(t);
|
|
58
|
+
};
|
|
59
|
+
},
|
|
60
|
+
trigger: y,
|
|
61
|
+
listeners: () => l.size,
|
|
62
|
+
dispose() {
|
|
63
|
+
w || (w = !0, b == null || b(), N && clearInterval(N), i && clearTimeout(i), i = null, c == null || c.removeEventListener("visibilitychange", R), l.clear());
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
const M = /* @__PURE__ */ new WeakMap();
|
|
68
|
+
function O(n, e) {
|
|
69
|
+
let s = M.get(n);
|
|
70
|
+
s || (s = C(n), M.set(n, s));
|
|
71
|
+
const o = s, r = o.subscribe(e);
|
|
72
|
+
return () => {
|
|
73
|
+
r(), o.listeners() === 0 && (o.dispose(), M.get(n) === o && M.delete(n));
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
function B(n, e = {}) {
|
|
77
|
+
const s = _(), o = S(n);
|
|
78
|
+
o.current = n;
|
|
79
|
+
const r = e.enabled !== !1;
|
|
80
|
+
V(() => {
|
|
81
|
+
if (!(!s || !r))
|
|
82
|
+
return O(s, (f) => o.current(f));
|
|
83
|
+
}, [s, r]);
|
|
84
|
+
}
|
|
85
|
+
export {
|
|
86
|
+
j as RESYNC_WINDOW_EVENT,
|
|
87
|
+
C as createResyncDetector,
|
|
88
|
+
O as onResync,
|
|
89
|
+
B as useResync
|
|
90
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
function c(o) {
|
|
2
|
+
const e = o ?? {};
|
|
3
|
+
return typeof e.collection != "string" || !e.collection || e.item == null || e.item === "" ? null : {
|
|
4
|
+
collection: e.collection,
|
|
5
|
+
item: String(e.item),
|
|
6
|
+
holder: typeof e.holder == "string" ? e.holder : ""
|
|
7
|
+
};
|
|
8
|
+
}
|
|
9
|
+
const l = (o, e) => `${o}\0${e}`;
|
|
10
|
+
function s() {
|
|
11
|
+
const o = /* @__PURE__ */ new Map();
|
|
12
|
+
return {
|
|
13
|
+
join(e) {
|
|
14
|
+
const t = c(e);
|
|
15
|
+
if (!t) return null;
|
|
16
|
+
const n = l(t.collection, t.item), r = o.get(n) ?? {
|
|
17
|
+
ref: { collection: t.collection, item: t.item },
|
|
18
|
+
holders: /* @__PURE__ */ new Set()
|
|
19
|
+
};
|
|
20
|
+
return r.holders.add(t.holder), o.set(n, r), r.ref;
|
|
21
|
+
},
|
|
22
|
+
leave(e) {
|
|
23
|
+
const t = c(e);
|
|
24
|
+
if (!t) return null;
|
|
25
|
+
const n = l(t.collection, t.item), r = o.get(n);
|
|
26
|
+
return r ? (r.holders.delete(t.holder), r.holders.size > 0 ? null : (o.delete(n), r.ref)) : { collection: t.collection, item: t.item };
|
|
27
|
+
},
|
|
28
|
+
held() {
|
|
29
|
+
return [...o.values()].map((e) => e.ref);
|
|
30
|
+
},
|
|
31
|
+
has(e, t) {
|
|
32
|
+
return o.has(l(e, String(t)));
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
let i = 0;
|
|
37
|
+
function u(o = "h") {
|
|
38
|
+
return i += 1, `${o}${i}`;
|
|
39
|
+
}
|
|
40
|
+
export {
|
|
41
|
+
s as createRecordRoomHolds,
|
|
42
|
+
u as newRecordRoomHolder
|
|
43
|
+
};
|