@nivaro/react 0.3.137 → 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/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,8 +1,9 @@
|
|
|
1
1
|
import { useQueryClient as O, useQuery as f } from "@tanstack/react-query";
|
|
2
|
-
import { useCallback as K, useState as
|
|
3
|
-
import { useNivaroClient as
|
|
2
|
+
import { useCallback as K, useState as C, useEffect as g, useMemo as L } from "react";
|
|
3
|
+
import { useNivaroClient as M, useItemEditAuth as A, useOptionalNivaroClient as E } from "../../context.js";
|
|
4
4
|
import { get as k } from "../../lib/commands.js";
|
|
5
|
-
import {
|
|
5
|
+
import { useLiveOps as P } from "../../lib/live-ops.js";
|
|
6
|
+
import { deadCreatesFor as R, shownTrackers as j } from "./tracker-model.js";
|
|
6
7
|
const l = {
|
|
7
8
|
all: ["trackers"],
|
|
8
9
|
featurePublic: () => ["trackers", "feature", "public"],
|
|
@@ -17,41 +18,41 @@ const l = {
|
|
|
17
18
|
projects: (e, t) => ["trackers", "projects", e, t],
|
|
18
19
|
labels: (e, t) => ["trackers", "labels", e, t],
|
|
19
20
|
users: (e, t, n) => ["trackers", "users", e, t, n]
|
|
20
|
-
},
|
|
21
|
+
}, D = (e) => {
|
|
21
22
|
var n;
|
|
22
23
|
const t = e;
|
|
23
24
|
return (t == null ? void 0 : t.status) ?? ((n = t == null ? void 0 : t.response) == null ? void 0 : n.status);
|
|
24
25
|
};
|
|
25
|
-
async function
|
|
26
|
+
async function N(e) {
|
|
26
27
|
var t;
|
|
27
28
|
try {
|
|
28
29
|
return !!((t = (await e.request(k("/trackers/feature/public"))).data) != null && t.enabled);
|
|
29
30
|
} catch (n) {
|
|
30
|
-
if (
|
|
31
|
+
if (D(n) === 404) return !1;
|
|
31
32
|
throw n;
|
|
32
33
|
}
|
|
33
34
|
}
|
|
34
|
-
function
|
|
35
|
-
const e =
|
|
35
|
+
function W() {
|
|
36
|
+
const e = E(), t = f({
|
|
36
37
|
queryKey: l.featurePublic(),
|
|
37
|
-
queryFn: () =>
|
|
38
|
+
queryFn: () => N(e),
|
|
38
39
|
enabled: !!e,
|
|
39
40
|
staleTime: 6e4,
|
|
40
41
|
retry: !1
|
|
41
42
|
});
|
|
42
43
|
return { on: t.data === !0, loading: t.isLoading };
|
|
43
44
|
}
|
|
44
|
-
function
|
|
45
|
+
function $(e, t) {
|
|
45
46
|
return (e ?? []).filter((n) => {
|
|
46
47
|
var r, a;
|
|
47
48
|
return n.is_active !== !1 && ((a = (r = n.sync) == null ? void 0 : r.sources) == null ? void 0 : a[t]) !== !1;
|
|
48
49
|
});
|
|
49
50
|
}
|
|
50
|
-
const
|
|
51
|
-
function
|
|
52
|
-
const n =
|
|
51
|
+
const U = (e) => e.request(k("/trackers")).then((t) => t.data ?? []);
|
|
52
|
+
function z(e, t) {
|
|
53
|
+
const n = M(), { isAdmin: r } = A(), a = f({
|
|
53
54
|
queryKey: l.connections(),
|
|
54
|
-
queryFn: () =>
|
|
55
|
+
queryFn: () => U(n),
|
|
55
56
|
enabled: t.enabled && r,
|
|
56
57
|
staleTime: 6e4,
|
|
57
58
|
retry: !1
|
|
@@ -64,80 +65,88 @@ function U(e, t) {
|
|
|
64
65
|
staleTime: 6e4,
|
|
65
66
|
retry: !1
|
|
66
67
|
});
|
|
67
|
-
return { connections:
|
|
68
|
+
return { connections: L(() => t.enabled ? r ? $(a.data, e) : u.data ?? [] : [], [t.enabled, r, a.data, u.data, e]), loading: r ? a.isLoading : u.isLoading };
|
|
68
69
|
}
|
|
69
|
-
const
|
|
70
|
-
function
|
|
71
|
-
const [n, r] =
|
|
72
|
-
|
|
70
|
+
const B = 12e4, G = 4e3;
|
|
71
|
+
function H(e, t) {
|
|
72
|
+
const [n, r] = C(null), [a, u] = C(!1);
|
|
73
|
+
g(() => {
|
|
73
74
|
e && (r(null), u(!1));
|
|
74
|
-
}, [e]),
|
|
75
|
+
}, [e]), g(() => {
|
|
75
76
|
if (n == null) return;
|
|
76
|
-
const
|
|
77
|
+
const c = Math.max(0, n + B - Date.now()), y = window.setTimeout(() => {
|
|
77
78
|
r(null), u(!0);
|
|
78
|
-
},
|
|
79
|
+
}, c);
|
|
79
80
|
return () => window.clearTimeout(y);
|
|
80
81
|
}, [n]);
|
|
81
|
-
const
|
|
82
|
+
const o = K(() => {
|
|
82
83
|
u(!1), r(Date.now()), t();
|
|
83
84
|
}, [t]), s = n != null && !e;
|
|
84
85
|
return {
|
|
85
86
|
creating: s,
|
|
86
87
|
stalled: a && !e,
|
|
87
|
-
pollMs: s ?
|
|
88
|
-
markCreating:
|
|
89
|
-
checkAgain:
|
|
88
|
+
pollMs: s ? G : !1,
|
|
89
|
+
markCreating: o,
|
|
90
|
+
checkAgain: o
|
|
90
91
|
};
|
|
91
92
|
}
|
|
92
|
-
function
|
|
93
|
-
const n =
|
|
94
|
-
enabled:
|
|
95
|
-
sourceId:
|
|
93
|
+
function te(e, t = {}) {
|
|
94
|
+
const n = M(), r = O(), { isAdmin: a } = A(), o = W().on && !!(e != null && e.id), s = (e == null ? void 0 : e.kind) ?? "record", c = (e == null ? void 0 : e.id) ?? "", y = t.mayCreate !== !1, { connections: q } = z(s, {
|
|
95
|
+
enabled: o && y,
|
|
96
|
+
sourceId: c
|
|
96
97
|
}), T = K(() => {
|
|
97
|
-
r.invalidateQueries({ queryKey: l.linksFor(s,
|
|
98
|
-
}, [r, s,
|
|
99
|
-
|
|
98
|
+
r.invalidateQueries({ queryKey: l.linksFor(s, c) }), r.invalidateQueries({ queryKey: l.sourceLinks(s, c) }), a && r.invalidateQueries({ queryKey: l.deadOutbox() });
|
|
99
|
+
}, [r, s, c, a]);
|
|
100
|
+
P(
|
|
101
|
+
o ? "trackers" : null,
|
|
102
|
+
() => {
|
|
103
|
+
r.invalidateQueries({ queryKey: l.linksFor(s, c) }), r.invalidateQueries({ queryKey: l.sourceLinks(s, c) });
|
|
104
|
+
},
|
|
105
|
+
{ debounceMs: 1500 }
|
|
106
|
+
);
|
|
107
|
+
const [v, I] = C(!1), w = f({
|
|
108
|
+
queryKey: l.linksFor(s, c),
|
|
100
109
|
queryFn: () => n.request(
|
|
101
|
-
k("/trackers/links/for", { source_kind: s, source_id:
|
|
110
|
+
k("/trackers/links/for", { source_kind: s, source_id: c })
|
|
102
111
|
).then((i) => i.data ?? []),
|
|
103
|
-
enabled:
|
|
112
|
+
enabled: o,
|
|
104
113
|
staleTime: 3e4,
|
|
105
114
|
retry: !1,
|
|
106
|
-
refetchInterval:
|
|
107
|
-
}), m =
|
|
108
|
-
queryKey: l.sourceLinks(s,
|
|
115
|
+
refetchInterval: v
|
|
116
|
+
}), m = o && a && s !== "issue" && y, _ = f({
|
|
117
|
+
queryKey: l.sourceLinks(s, c),
|
|
109
118
|
queryFn: () => n.request(
|
|
110
|
-
k(`/trackers/links/source/${s}/${encodeURIComponent(
|
|
119
|
+
k(`/trackers/links/source/${s}/${encodeURIComponent(c)}`)
|
|
111
120
|
).then((i) => i.data ?? []),
|
|
112
121
|
enabled: m,
|
|
113
122
|
staleTime: 3e4,
|
|
114
123
|
retry: !1,
|
|
115
|
-
refetchInterval:
|
|
116
|
-
}), b =
|
|
124
|
+
refetchInterval: v
|
|
125
|
+
}), b = o ? w.data ?? [] : [], Q = new Set(
|
|
117
126
|
b.map((i) => i.connection).filter((i) => i != null)
|
|
118
|
-
),
|
|
119
|
-
(i) =>
|
|
120
|
-
) ?? null : null, h = b.length > 0 || !!
|
|
127
|
+
), p = o && a ? (_.data ?? []).find(
|
|
128
|
+
(i) => Q.has(i.connection) || q.some((x) => x.id === i.connection)
|
|
129
|
+
) ?? null : null, h = b.length > 0 || !!p, F = f({
|
|
121
130
|
queryKey: l.deadOutbox(),
|
|
122
131
|
queryFn: () => n.request(k("/trackers/outbox", { status: "dead" })).then((i) => i.data ?? []),
|
|
123
|
-
enabled: m && !h &&
|
|
132
|
+
enabled: m && !h && w.isSuccess,
|
|
124
133
|
staleTime: 6e4,
|
|
125
134
|
retry: !1
|
|
126
|
-
}), d =
|
|
127
|
-
|
|
128
|
-
const
|
|
129
|
-
() => m && !h ?
|
|
130
|
-
[m, h, s,
|
|
135
|
+
}), d = H(h, T);
|
|
136
|
+
g(() => I(d.pollMs), [d.pollMs]);
|
|
137
|
+
const S = L(
|
|
138
|
+
() => m && !h ? R(F.data, { kind: s, id: c }) : [],
|
|
139
|
+
[m, h, s, c, F.data]
|
|
131
140
|
);
|
|
132
141
|
return {
|
|
133
|
-
on:
|
|
142
|
+
on: o,
|
|
134
143
|
isAdmin: a,
|
|
135
|
-
connections:
|
|
136
|
-
canCreate:
|
|
144
|
+
connections: o ? q : [],
|
|
145
|
+
canCreate: o && y && q.length > 0,
|
|
137
146
|
chips: b,
|
|
138
|
-
shown:
|
|
139
|
-
link:
|
|
140
|
-
failed:
|
|
147
|
+
shown: j(b, p),
|
|
148
|
+
link: p,
|
|
149
|
+
failed: S,
|
|
141
150
|
creating: d.creating,
|
|
142
151
|
slow: d.stalled,
|
|
143
152
|
markCreating: d.markCreating,
|
|
@@ -146,14 +155,14 @@ function Z(e, t = {}) {
|
|
|
146
155
|
};
|
|
147
156
|
}
|
|
148
157
|
export {
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
158
|
+
G as CREATE_POLL_MS,
|
|
159
|
+
B as CREATE_WAIT_MS,
|
|
160
|
+
U as fetchTrackerConnections,
|
|
161
|
+
N as fetchTrackerFeature,
|
|
162
|
+
$ as syncingConnections,
|
|
154
163
|
l as trackerQueryKeys,
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
164
|
+
H as useCreateWait,
|
|
165
|
+
te as useSourceTracker,
|
|
166
|
+
z as useTrackerConnections,
|
|
167
|
+
W as useTrackerFeature
|
|
159
168
|
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useQueryClient as v } from "@tanstack/react-query";
|
|
2
|
+
import { useEffect as w } from "react";
|
|
3
|
+
const l = "nvr:config-update";
|
|
4
|
+
function N(n, o) {
|
|
5
|
+
return n ? o.some((e) => !!e && e === n) : !0;
|
|
6
|
+
}
|
|
7
|
+
function J(n, o, e = {}) {
|
|
8
|
+
const r = v(), i = e.enabled !== !1, s = e.jitterMs ?? 1500, c = JSON.stringify(n), f = JSON.stringify(o);
|
|
9
|
+
w(() => {
|
|
10
|
+
if (!i || typeof window > "u") return;
|
|
11
|
+
const d = JSON.parse(c), m = JSON.parse(f);
|
|
12
|
+
let t = null;
|
|
13
|
+
const a = (y) => {
|
|
14
|
+
var u;
|
|
15
|
+
const p = (u = y.detail) == null ? void 0 : u.collection;
|
|
16
|
+
!N(p, d) || t || (t = setTimeout(
|
|
17
|
+
() => {
|
|
18
|
+
t = null;
|
|
19
|
+
for (const h of m)
|
|
20
|
+
r.invalidateQueries({ queryKey: h, refetchType: "active" }, { cancelRefetch: !1 });
|
|
21
|
+
},
|
|
22
|
+
Math.floor(Math.random() * Math.max(0, s))
|
|
23
|
+
));
|
|
24
|
+
};
|
|
25
|
+
return window.addEventListener(l, a), () => {
|
|
26
|
+
window.removeEventListener(l, a), t && clearTimeout(t);
|
|
27
|
+
};
|
|
28
|
+
}, [r, i, s, c, f]);
|
|
29
|
+
}
|
|
30
|
+
export {
|
|
31
|
+
l as CONFIG_UPDATE_WINDOW_EVENT,
|
|
32
|
+
N as configUpdateTouches,
|
|
33
|
+
J as useConfigUpdateRefresh
|
|
34
|
+
};
|
|
@@ -3,32 +3,32 @@ import { useLiveOps as b } from "./live-ops.js";
|
|
|
3
3
|
function y(n, t) {
|
|
4
4
|
return `cfg-${n}:${t}`;
|
|
5
5
|
}
|
|
6
|
-
const
|
|
6
|
+
const d = (n, t) => n != null && t != null && String(n).toLowerCase() === String(t).toLowerCase();
|
|
7
7
|
function S(n, t, o) {
|
|
8
8
|
var i;
|
|
9
|
-
const r = typeof t.part == "string" && t.part ? t.part : "several", e = t.by,
|
|
9
|
+
const r = typeof t.part == "string" && t.part ? t.part : "several", e = t.by, s = e && e.id != null ? { id: String(e.id), name: typeof e.name == "string" ? e.name : "Someone" } : null;
|
|
10
10
|
return n ? {
|
|
11
|
-
by:
|
|
11
|
+
by: d((i = n.by) == null ? void 0 : i.id, s == null ? void 0 : s.id) || !n.by && !s ? s : null,
|
|
12
12
|
part: n.part === r ? r : "several",
|
|
13
13
|
at: o,
|
|
14
14
|
count: n.count + 1
|
|
15
|
-
} : { by:
|
|
15
|
+
} : { by: s, part: r, at: o, count: 1 };
|
|
16
16
|
}
|
|
17
17
|
function $(n, t, o = {}) {
|
|
18
|
-
const [r, e] = p(null),
|
|
18
|
+
const [r, e] = p(null), s = m(null), c = t != null && t !== "" ? y(n, t) : null, { meId: i, onChange: u } = o;
|
|
19
19
|
b(
|
|
20
|
-
|
|
21
|
-
(
|
|
22
|
-
if (
|
|
23
|
-
const g = S(
|
|
24
|
-
|
|
20
|
+
c,
|
|
21
|
+
(a) => {
|
|
22
|
+
if (a != null && a.reconnect || a != null && a.by && d(a.by.id, i)) return;
|
|
23
|
+
const g = S(s.current, a ?? {}, Date.now());
|
|
24
|
+
s.current = g, e(g), u == null || u(g);
|
|
25
25
|
},
|
|
26
26
|
{ enabled: o.enabled !== !1, debounceMs: 250 }
|
|
27
27
|
);
|
|
28
|
-
const
|
|
29
|
-
|
|
28
|
+
const l = w(() => {
|
|
29
|
+
s.current = null, e(null);
|
|
30
30
|
}, []);
|
|
31
|
-
return { change: r, clear:
|
|
31
|
+
return { change: r, clear: l };
|
|
32
32
|
}
|
|
33
33
|
const h = {
|
|
34
34
|
state: "changed a state",
|
|
@@ -67,7 +67,7 @@ const C = /* @__PURE__ */ new Set([
|
|
|
67
67
|
"sort",
|
|
68
68
|
"updated_at"
|
|
69
69
|
]);
|
|
70
|
-
function
|
|
70
|
+
function f(n) {
|
|
71
71
|
const t = {};
|
|
72
72
|
for (const o of Object.keys(n).sort()) C.has(o) || (t[o] = n[o]);
|
|
73
73
|
try {
|
|
@@ -77,10 +77,10 @@ function d(n) {
|
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
79
|
function W(n, t) {
|
|
80
|
-
const o = new Map((n ?? []).map((e) => [String(e.id),
|
|
80
|
+
const o = new Map((n ?? []).map((e) => [String(e.id), f(e)])), r = [];
|
|
81
81
|
for (const e of t ?? []) {
|
|
82
|
-
const
|
|
83
|
-
|
|
82
|
+
const s = String(e.id), c = o.get(s);
|
|
83
|
+
c != null && c !== f(e) && r.push(s);
|
|
84
84
|
}
|
|
85
85
|
return r;
|
|
86
86
|
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useRef as s, useEffect as l } from "react";
|
|
2
|
+
function a() {
|
|
3
|
+
return typeof document > "u" || document.visibilityState !== "hidden";
|
|
4
|
+
}
|
|
5
|
+
function d(o, r) {
|
|
6
|
+
const u = r.now ?? (() => Date.now()), c = r.isVisible ?? a;
|
|
7
|
+
let t = Number.NEGATIVE_INFINITY, n = null, e = !1;
|
|
8
|
+
const i = () => {
|
|
9
|
+
if (n = null, !c()) {
|
|
10
|
+
e = !0;
|
|
11
|
+
return;
|
|
12
|
+
}
|
|
13
|
+
e = !1, t = u(), o();
|
|
14
|
+
};
|
|
15
|
+
return {
|
|
16
|
+
poke() {
|
|
17
|
+
if (n) return;
|
|
18
|
+
const f = t + r.gapMs - u();
|
|
19
|
+
f <= 0 ? i() : n = setTimeout(i, f);
|
|
20
|
+
},
|
|
21
|
+
resume() {
|
|
22
|
+
!n && e && c() && i();
|
|
23
|
+
},
|
|
24
|
+
cancel() {
|
|
25
|
+
n && clearTimeout(n), n = null, e = !1;
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
function p(o, r, u = !0) {
|
|
30
|
+
const c = s(o);
|
|
31
|
+
c.current = o;
|
|
32
|
+
const t = s(null);
|
|
33
|
+
return l(() => {
|
|
34
|
+
if (!u) return;
|
|
35
|
+
const e = d(() => c.current(), { gapMs: r });
|
|
36
|
+
t.current = e;
|
|
37
|
+
const i = () => e.resume();
|
|
38
|
+
return typeof document < "u" && document.addEventListener("visibilitychange", i), () => {
|
|
39
|
+
typeof document < "u" && document.removeEventListener("visibilitychange", i), e.cancel(), t.current === e && (t.current = null);
|
|
40
|
+
};
|
|
41
|
+
}, [r, u]), s(() => {
|
|
42
|
+
var e;
|
|
43
|
+
return (e = t.current) == null ? void 0 : e.poke();
|
|
44
|
+
}).current;
|
|
45
|
+
}
|
|
46
|
+
export {
|
|
47
|
+
d as createGapRefresher,
|
|
48
|
+
p as useGapRefresh
|
|
49
|
+
};
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { toneForObligation as s } from "./obligation-filters.js";
|
|
2
2
|
const r = { danger: 3, warning: 2, positive: 1, neutral: 0 };
|
|
3
|
-
function
|
|
4
|
-
const
|
|
5
|
-
for (const o of
|
|
3
|
+
function a(i) {
|
|
4
|
+
const n = /* @__PURE__ */ new Map();
|
|
5
|
+
for (const o of i) {
|
|
6
6
|
if (o.outcome === "superseded") continue;
|
|
7
|
-
const t = s(o
|
|
8
|
-
(!
|
|
7
|
+
const t = s(o), e = n.get(o.api);
|
|
8
|
+
(!e || r[t] > r[e]) && n.set(o.api, t);
|
|
9
9
|
}
|
|
10
|
-
return [...
|
|
10
|
+
return [...n.entries()].map(([o, t]) => ({ api: o, tone: t }));
|
|
11
11
|
}
|
|
12
12
|
export {
|
|
13
|
-
|
|
13
|
+
a as dotsForRecord
|
|
14
14
|
};
|
|
@@ -1,41 +1,44 @@
|
|
|
1
1
|
import { useRef as m, useEffect as l, useState as h } from "react";
|
|
2
2
|
import { useLiveEvent as S } from "./live.js";
|
|
3
3
|
import { useOptionalRealtime as b } from "./realtime.js";
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
r
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
4
|
+
import { useResync as w } from "./reconnect-resync.js";
|
|
5
|
+
function j(t, u, n = {}) {
|
|
6
|
+
const c = b(), r = n.enabled !== !1 && !!t, s = m(n.match);
|
|
7
|
+
s.current = n.match;
|
|
8
|
+
const o = m(u);
|
|
9
|
+
o.current = u, l(() => {
|
|
10
|
+
if (!(!c || !r || !t))
|
|
11
|
+
return c.emit("ops:join", { topic: t }), () => c.emit("ops:leave", { topic: t });
|
|
12
|
+
}, [c, r, t]), S(
|
|
10
13
|
"ops:changed",
|
|
11
14
|
(e) => {
|
|
12
|
-
|
|
15
|
+
u(e ?? {});
|
|
13
16
|
},
|
|
14
17
|
{
|
|
15
|
-
enabled:
|
|
18
|
+
enabled: r,
|
|
16
19
|
debounceMs: n.debounceMs ?? 300,
|
|
17
20
|
includeOwn: !0,
|
|
18
|
-
match: (e) => (e == null ? void 0 : e.topic) === t && (!
|
|
21
|
+
match: (e) => (e == null ? void 0 : e.topic) === t && (!s.current || s.current(e ?? {}))
|
|
19
22
|
}
|
|
20
|
-
);
|
|
23
|
+
), w(() => o.current({ topic: t, reconnect: !0 }), { enabled: r });
|
|
21
24
|
}
|
|
22
|
-
function
|
|
23
|
-
const n = m(null), [
|
|
25
|
+
function y(t, u = 4e3) {
|
|
26
|
+
const n = m(null), [c, r] = h(() => /* @__PURE__ */ new Set()), s = (t ?? []).map(String).join("\0");
|
|
24
27
|
return l(() => {
|
|
25
|
-
const
|
|
26
|
-
if (n.current =
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
() =>
|
|
30
|
-
const a = new Set(
|
|
31
|
-
for (const d of
|
|
28
|
+
const o = new Set(s ? s.split("\0") : []), e = n.current;
|
|
29
|
+
if (n.current = o, !e || e.size === 0) return;
|
|
30
|
+
const i = [...o].filter((f) => !e.has(f));
|
|
31
|
+
i.length !== 0 && (r((f) => /* @__PURE__ */ new Set([...f, ...i])), setTimeout(
|
|
32
|
+
() => r((f) => {
|
|
33
|
+
const a = new Set(f);
|
|
34
|
+
for (const d of i) a.delete(d);
|
|
32
35
|
return a;
|
|
33
36
|
}),
|
|
34
|
-
|
|
37
|
+
u
|
|
35
38
|
));
|
|
36
|
-
}, [
|
|
39
|
+
}, [s, u]), c;
|
|
37
40
|
}
|
|
38
41
|
export {
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
y as useFreshIds,
|
|
43
|
+
j as useLiveOps
|
|
41
44
|
};
|