@nivaro/react 0.3.8 → 0.3.9
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/replayUploadQueue.js +107 -93
- package/dist/hooks/useSessionRecorder.js +103 -101
- package/dist/index.d.ts +46 -1
- package/dist/index.js +300 -292
- package/dist/shared/components/CollectionBrowserView.js +318 -318
- package/dist/shared/components/DataTable.js +230 -223
- package/dist/shared/components/QueryTable.js +49 -49
- package/dist/shared/components/chat/ChatPanel.js +288 -287
- package/dist/shared/components/panels/CommentPanel.js +237 -236
- package/dist/shared/components/profile/usePersonPresence.js +42 -37
- package/dist/shared/lib/presence-live.js +54 -0
- package/dist/shared/lib/presence-state.js +39 -31
- package/dist/shared/lib/request-gate.js +120 -102
- package/dist/shared/lib/rum.js +45 -36
- package/dist/shared/lib/signed-out.js +114 -0
- package/dist/shared/lib/socket-realtime.js +19 -17
- package/dist/shared/lib/use-online-users.js +11 -10
- package/dist/shared/lib/worker-socket.js +89 -79
- package/package.json +1 -1
|
@@ -1,194 +1,204 @@
|
|
|
1
|
-
import { bindClientChaosSocket as
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { bindClientChaosSocket as x } from "./client-chaos.js";
|
|
2
|
+
import { onSignedIn as z, signedOutBackoff as F, isSignedOut as U } from "./signed-out.js";
|
|
3
|
+
const j = 1, B = "nvr-realtime-worker";
|
|
4
|
+
function N() {
|
|
4
5
|
return typeof window < "u" && typeof window.SharedWorker == "function";
|
|
5
6
|
}
|
|
6
|
-
function
|
|
7
|
+
function Y() {
|
|
7
8
|
try {
|
|
8
|
-
const o = localStorage.getItem(
|
|
9
|
+
const o = localStorage.getItem(B);
|
|
9
10
|
return o === "on" || o === "off" ? o : null;
|
|
10
11
|
} catch {
|
|
11
12
|
return null;
|
|
12
13
|
}
|
|
13
14
|
}
|
|
14
|
-
function
|
|
15
|
-
if (!
|
|
15
|
+
function $(o) {
|
|
16
|
+
if (!N() || Y() === "off") return !1;
|
|
16
17
|
try {
|
|
17
18
|
return new URL(o, window.location.href).origin === window.location.origin;
|
|
18
19
|
} catch {
|
|
19
20
|
return !1;
|
|
20
21
|
}
|
|
21
22
|
}
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
let
|
|
25
|
-
const
|
|
26
|
-
let
|
|
27
|
-
const
|
|
28
|
-
for (const r of [...
|
|
23
|
+
function J(o) {
|
|
24
|
+
const u = /* @__PURE__ */ new Map(), g = /* @__PURE__ */ new Set();
|
|
25
|
+
let c = "pending", s = null, n = null, d = !1, T = null, K = 0;
|
|
26
|
+
const E = /* @__PURE__ */ new Map(), M = [];
|
|
27
|
+
let R = 0, k = null, p = null, m = !1, w = !1, b = 0, h = 0, v = null;
|
|
28
|
+
const A = (e, t) => {
|
|
29
|
+
for (const r of [...u.get(e) ?? []])
|
|
29
30
|
try {
|
|
30
31
|
r(...t);
|
|
31
32
|
} catch {
|
|
32
33
|
}
|
|
33
|
-
for (const r of [...
|
|
34
|
+
for (const r of [...g])
|
|
34
35
|
try {
|
|
35
36
|
r(e, ...t);
|
|
36
37
|
} catch {
|
|
37
38
|
}
|
|
38
|
-
},
|
|
39
|
+
}, C = () => {
|
|
39
40
|
if (k && clearTimeout(k), k = null, p && clearInterval(p), p = null, s)
|
|
40
41
|
try {
|
|
41
42
|
s.postMessage({ t: "bye" }), s.close();
|
|
42
43
|
} catch {
|
|
43
44
|
}
|
|
44
45
|
s = null;
|
|
45
|
-
},
|
|
46
|
-
var
|
|
47
|
-
if (
|
|
48
|
-
const t =
|
|
49
|
-
|
|
46
|
+
}, l = (e) => {
|
|
47
|
+
var i, y, S;
|
|
48
|
+
if (c === "fallback" || m) return;
|
|
49
|
+
const t = d;
|
|
50
|
+
C(), c = "fallback", d = !1;
|
|
50
51
|
const r = o.fallback();
|
|
51
|
-
n = r, w && ((
|
|
52
|
-
for (const [
|
|
53
|
-
|
|
52
|
+
n = r, w && ((i = r.disconnect) == null || i.call(r));
|
|
53
|
+
for (const [O, W] of u) for (const q of W) r.on(O, q);
|
|
54
|
+
g.size && ((y = r.onAny) == null || y.call(r, (O, ...W) => I(O, W))), t && A("disconnect", ["worker-fallback"]), (S = o.onMode) == null || S.call(o, "fallback", e);
|
|
54
55
|
};
|
|
55
|
-
function
|
|
56
|
-
for (const r of [...
|
|
56
|
+
function I(e, t) {
|
|
57
|
+
for (const r of [...g])
|
|
57
58
|
try {
|
|
58
59
|
r(e, ...t);
|
|
59
60
|
} catch {
|
|
60
61
|
}
|
|
61
62
|
}
|
|
62
|
-
const
|
|
63
|
+
const D = () => a({
|
|
63
64
|
t: "hello",
|
|
64
65
|
app: o.app,
|
|
65
66
|
features: o.features ?? [],
|
|
66
67
|
version: o.version ?? {},
|
|
67
68
|
active: typeof document > "u" || document.visibilityState === "visible"
|
|
68
|
-
}),
|
|
69
|
+
}), a = (e) => {
|
|
69
70
|
try {
|
|
70
71
|
s == null || s.postMessage(e);
|
|
71
72
|
} catch {
|
|
72
|
-
|
|
73
|
+
l("port-closed");
|
|
73
74
|
}
|
|
74
|
-
},
|
|
75
|
+
}, L = (e) => {
|
|
75
76
|
var r;
|
|
76
77
|
const t = e.data;
|
|
77
78
|
if (!(!t || typeof t != "object" || m))
|
|
78
|
-
switch (
|
|
79
|
+
switch (R = Date.now(), t.t) {
|
|
79
80
|
case "ready": {
|
|
80
|
-
if (k && clearTimeout(k), k = null, t.proto !==
|
|
81
|
-
|
|
82
|
-
Date.now() -
|
|
81
|
+
if (k && clearTimeout(k), k = null, t.proto !== j) return l(`proto-${String(t.proto)}`);
|
|
82
|
+
c = "worker", w || D(), p = setInterval(() => {
|
|
83
|
+
Date.now() - R > (o.silentMs ?? 2e4) && l("worker-silent");
|
|
83
84
|
}, 5e3), (r = o.onMode) == null || r.call(o, "worker", "ready");
|
|
84
85
|
return;
|
|
85
86
|
}
|
|
86
87
|
case "ping":
|
|
87
|
-
|
|
88
|
+
a({ t: "pong" });
|
|
88
89
|
return;
|
|
89
90
|
case "status": {
|
|
90
|
-
|
|
91
|
-
const
|
|
92
|
-
if (
|
|
91
|
+
d = !!t.connected;
|
|
92
|
+
const i = typeof t.transport == "string" ? t.transport : null, y = i === "websocket" && T !== "websocket";
|
|
93
|
+
if (T = i, y) for (const S of M.splice(0)) S();
|
|
93
94
|
return;
|
|
94
95
|
}
|
|
95
96
|
case "need-token":
|
|
96
|
-
|
|
97
|
+
P().then(
|
|
98
|
+
(i) => a({ t: "token", req: t.req, token: i, ...i ? {} : { signedOut: U() } })
|
|
99
|
+
);
|
|
97
100
|
return;
|
|
98
101
|
case "ev": {
|
|
99
102
|
if (w) return;
|
|
100
|
-
t.event === "connect" && (
|
|
103
|
+
t.event === "connect" && (d = !0), t.event === "disconnect" && (d = !1), A(String(t.event), Array.isArray(t.args) ? t.args : []);
|
|
101
104
|
return;
|
|
102
105
|
}
|
|
103
106
|
case "ack": {
|
|
104
|
-
const
|
|
105
|
-
|
|
107
|
+
const i = E.get(t.id);
|
|
108
|
+
E.delete(t.id), i == null || i(...Array.isArray(t.args) ? t.args : []);
|
|
106
109
|
return;
|
|
107
110
|
}
|
|
108
111
|
case "fallback":
|
|
109
|
-
|
|
112
|
+
l(String(t.reason ?? "worker"));
|
|
110
113
|
return;
|
|
111
114
|
default:
|
|
112
115
|
return;
|
|
113
116
|
}
|
|
114
|
-
},
|
|
115
|
-
if (
|
|
117
|
+
}, P = async () => {
|
|
118
|
+
if (Date.now() < h) return null;
|
|
119
|
+
const e = await o.authToken().catch(() => null);
|
|
120
|
+
return e ? (b = 0, h = 0, e) : (b += 1, h = Date.now() + F(b), null);
|
|
121
|
+
}, _ = () => {
|
|
122
|
+
if (!$(o.url)) return l("unsupported");
|
|
116
123
|
try {
|
|
117
124
|
const e = new SharedWorker(o.url, { name: o.name ?? o.app });
|
|
118
|
-
s = e.port, s.onmessage =
|
|
125
|
+
s = e.port, s.onmessage = L, s.onmessageerror = () => l("message-error"), e.onerror = () => l("worker-error"), s.start(), k = setTimeout(() => l("no-greeting"), o.readyTimeoutMs ?? 15e3);
|
|
119
126
|
} catch {
|
|
120
|
-
|
|
127
|
+
l("construct-failed");
|
|
121
128
|
}
|
|
122
129
|
if (typeof window < "u") {
|
|
123
130
|
const e = () => {
|
|
124
|
-
|
|
131
|
+
c === "worker" && document.visibilityState === "visible" && a({ t: "active" });
|
|
125
132
|
};
|
|
126
133
|
document.addEventListener("visibilitychange", e), window.addEventListener("focus", e), window.addEventListener("pagehide", () => {
|
|
127
|
-
|
|
134
|
+
c === "worker" && a({ t: "bye" });
|
|
128
135
|
});
|
|
129
136
|
}
|
|
130
137
|
}, f = {
|
|
131
138
|
get connected() {
|
|
132
|
-
return w &&
|
|
139
|
+
return w && c !== "fallback" ? !1 : c === "fallback" ? !!(n != null && n.connected) : d;
|
|
133
140
|
},
|
|
134
141
|
on(e, t) {
|
|
135
|
-
const r =
|
|
136
|
-
return
|
|
142
|
+
const r = u.get(e) ?? /* @__PURE__ */ new Set();
|
|
143
|
+
return u.set(e, r), r.add(t), c === "fallback" && (n == null || n.on(e, t)), f;
|
|
137
144
|
},
|
|
138
145
|
off(e, t) {
|
|
139
146
|
var r;
|
|
140
|
-
return t ? (r =
|
|
147
|
+
return t ? (r = u.get(e)) == null || r.delete(t) : u.delete(e), c === "fallback" && (n == null || n.off(e, t)), f;
|
|
141
148
|
},
|
|
142
149
|
once(e, t) {
|
|
143
|
-
const r = (...
|
|
144
|
-
f.off(e, r), t(...
|
|
150
|
+
const r = (...i) => {
|
|
151
|
+
f.off(e, r), t(...i);
|
|
145
152
|
};
|
|
146
153
|
return f.on(e, r);
|
|
147
154
|
},
|
|
148
155
|
onAny(e) {
|
|
149
156
|
var r;
|
|
150
|
-
const t =
|
|
151
|
-
return
|
|
157
|
+
const t = g.size === 0;
|
|
158
|
+
return g.add(e), c === "fallback" && t && ((r = n == null ? void 0 : n.onAny) == null || r.call(n, (i, ...y) => I(i, y))), f;
|
|
152
159
|
},
|
|
153
160
|
offAny(e) {
|
|
154
|
-
return
|
|
161
|
+
return g.delete(e), f;
|
|
155
162
|
},
|
|
156
163
|
listeners(e) {
|
|
157
|
-
return [...
|
|
164
|
+
return [...u.get(e) ?? []];
|
|
158
165
|
},
|
|
159
166
|
emit(e, ...t) {
|
|
160
|
-
if (
|
|
167
|
+
if (c === "fallback") return n == null ? void 0 : n.emit(e, ...t);
|
|
161
168
|
const r = t[t.length - 1];
|
|
162
169
|
if (w)
|
|
163
170
|
return typeof r == "function" && setTimeout(() => r(), 0), f;
|
|
164
171
|
if (typeof r == "function") {
|
|
165
|
-
const
|
|
166
|
-
|
|
167
|
-
} else
|
|
172
|
+
const i = ++K;
|
|
173
|
+
E.set(i, r), a({ t: "emit", event: e, payload: t[0], ack: i });
|
|
174
|
+
} else a({ t: "emit", event: e, payload: t[0] });
|
|
168
175
|
return f;
|
|
169
176
|
},
|
|
170
177
|
connect() {
|
|
171
178
|
var e;
|
|
172
|
-
|
|
179
|
+
c === "fallback" ? (e = n == null ? void 0 : n.connect) == null || e.call(n) : a({ t: "connect" });
|
|
173
180
|
},
|
|
174
181
|
disconnect() {
|
|
175
182
|
var e;
|
|
176
|
-
m = !0,
|
|
183
|
+
m = !0, v == null || v(), C(), (e = n == null ? void 0 : n.disconnect) == null || e.call(n);
|
|
177
184
|
},
|
|
178
|
-
|
|
185
|
+
signedIn() {
|
|
186
|
+
b = 0, h = 0, !(c !== "worker" || m) && (a({ t: "signed-in" }), (typeof document > "u" || document.visibilityState === "visible") && a({ t: "active" }));
|
|
187
|
+
},
|
|
188
|
+
mode: () => c,
|
|
179
189
|
chaosPause(e) {
|
|
180
190
|
var t, r;
|
|
181
191
|
if (!(e === w || m)) {
|
|
182
|
-
if (w = e,
|
|
192
|
+
if (w = e, c === "fallback") {
|
|
183
193
|
e ? (t = n == null ? void 0 : n.disconnect) == null || t.call(n) : (r = n == null ? void 0 : n.connect) == null || r.call(n);
|
|
184
194
|
return;
|
|
185
195
|
}
|
|
186
196
|
if (e) {
|
|
187
|
-
const
|
|
188
|
-
|
|
197
|
+
const i = d;
|
|
198
|
+
d = !1, i && A("disconnect", ["transport close"]);
|
|
189
199
|
return;
|
|
190
200
|
}
|
|
191
|
-
|
|
201
|
+
c === "worker" && D(), typeof window < "u" && window.dispatchEvent(new CustomEvent("nvr:catchup-full"));
|
|
192
202
|
}
|
|
193
203
|
},
|
|
194
204
|
io: {
|
|
@@ -197,23 +207,23 @@ function j(o) {
|
|
|
197
207
|
return {
|
|
198
208
|
get name() {
|
|
199
209
|
var e, t, r;
|
|
200
|
-
return
|
|
210
|
+
return c === "fallback" ? (r = (t = (e = n == null ? void 0 : n.io) == null ? void 0 : e.engine) == null ? void 0 : t.transport) == null ? void 0 : r.name : T ?? void 0;
|
|
201
211
|
}
|
|
202
212
|
};
|
|
203
213
|
},
|
|
204
214
|
once(e, t) {
|
|
205
|
-
e === "upgrade" &&
|
|
215
|
+
e === "upgrade" && M.push(t);
|
|
206
216
|
}
|
|
207
217
|
}
|
|
208
218
|
}
|
|
209
219
|
};
|
|
210
|
-
return
|
|
220
|
+
return v = z(() => f.signedIn()), _(), x(f), f;
|
|
211
221
|
}
|
|
212
222
|
export {
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
223
|
+
B as WORKER_SOCKET_PREF_KEY,
|
|
224
|
+
j as WORKER_SOCKET_PROTO,
|
|
225
|
+
J as createWorkerSocket,
|
|
226
|
+
N as sharedWorkerSupported,
|
|
227
|
+
$ as shouldUseWorkerSocket,
|
|
228
|
+
Y as workerSocketPreference
|
|
219
229
|
};
|