@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,18 +1,18 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var d = (n, t, e) =>
|
|
4
|
-
const K = 2e6, M = 6e4,
|
|
1
|
+
var m = Object.defineProperty;
|
|
2
|
+
var B = (n, t, e) => t in n ? m(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
|
|
3
|
+
var d = (n, t, e) => B(n, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
const K = 2e6, M = 6e4, k = 6e4, O = 2e7, U = 6e5, C = 2e3, N = 6e4, D = 864e5;
|
|
5
5
|
function Q(n, t = 2e6) {
|
|
6
6
|
const e = [];
|
|
7
|
-
let r = [],
|
|
8
|
-
for (const
|
|
9
|
-
let
|
|
7
|
+
let r = [], i = 2;
|
|
8
|
+
for (const u of n) {
|
|
9
|
+
let s = 0;
|
|
10
10
|
try {
|
|
11
|
-
|
|
11
|
+
s = JSON.stringify(u).length + 1;
|
|
12
12
|
} catch {
|
|
13
13
|
continue;
|
|
14
14
|
}
|
|
15
|
-
r.length > 0 &&
|
|
15
|
+
r.length > 0 && i + s > t && (e.push(r), r = [], i = 2), r.push(u), i += s;
|
|
16
16
|
}
|
|
17
17
|
return r.length > 0 && e.push(r), e;
|
|
18
18
|
}
|
|
@@ -20,9 +20,13 @@ function T(n, t = Math.random) {
|
|
|
20
20
|
const e = Math.max(1, Math.floor(n)), r = Math.min(6e4, 2e3 * 2 ** (e - 1));
|
|
21
21
|
return Math.round(r / 2 + t() * (r / 2));
|
|
22
22
|
}
|
|
23
|
-
function
|
|
23
|
+
function S(n) {
|
|
24
24
|
return n === 409 ? "closed" : n === 413 || n === 400 ? "drop-chunk" : n === 408 || n === 429 ? "retry" : typeof n == "number" && n >= 400 && n < 500 ? "abandon" : "retry";
|
|
25
25
|
}
|
|
26
|
+
function R(n) {
|
|
27
|
+
const t = S(n);
|
|
28
|
+
return t === "closed" || t === "abandon" ? "stop" : "next";
|
|
29
|
+
}
|
|
26
30
|
function E(n) {
|
|
27
31
|
var r;
|
|
28
32
|
const t = n, e = typeof (t == null ? void 0 : t.status) == "number" ? t.status : (r = t == null ? void 0 : t.response) == null ? void 0 : r.status;
|
|
@@ -36,10 +40,10 @@ function q(n) {
|
|
|
36
40
|
}
|
|
37
41
|
}
|
|
38
42
|
function I(n, t = 0) {
|
|
39
|
-
const e =
|
|
43
|
+
const e = b(n, t);
|
|
40
44
|
return JSON.stringify({ seq: n.seq, events: n.events, ...e });
|
|
41
45
|
}
|
|
42
|
-
function
|
|
46
|
+
function b(n, t = 0) {
|
|
43
47
|
const e = {};
|
|
44
48
|
return n.route && (e.route = n.route), n.build && (e.build = n.build), t > 0 && (e.retries = t), e;
|
|
45
49
|
}
|
|
@@ -50,38 +54,38 @@ function v() {
|
|
|
50
54
|
n.set(t(e.recordingId, e.seq), e);
|
|
51
55
|
},
|
|
52
56
|
async list(e) {
|
|
53
|
-
return [...n.values()].filter((r) => r.recordingId === e).sort((r,
|
|
57
|
+
return [...n.values()].filter((r) => r.recordingId === e).sort((r, i) => r.seq - i.seq);
|
|
54
58
|
},
|
|
55
59
|
async remove(e, r) {
|
|
56
60
|
n.delete(t(e, r));
|
|
57
61
|
},
|
|
58
62
|
async clear(e) {
|
|
59
|
-
for (const [r,
|
|
63
|
+
for (const [r, i] of n) i.recordingId === e && n.delete(r);
|
|
60
64
|
},
|
|
61
65
|
async prune(e) {
|
|
62
|
-
for (const [r,
|
|
66
|
+
for (const [r, i] of n) i.at < e && n.delete(r);
|
|
63
67
|
}
|
|
64
68
|
};
|
|
65
69
|
}
|
|
66
70
|
const _ = "nivaro-replay-queue", p = "chunks";
|
|
67
|
-
function
|
|
71
|
+
function x(n) {
|
|
68
72
|
const t = typeof indexedDB < "u" ? indexedDB : null, e = v();
|
|
69
73
|
if (!t) return e;
|
|
70
|
-
const r = new Promise((
|
|
74
|
+
const r = new Promise((s) => {
|
|
71
75
|
try {
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
+
const o = t.open(_, 1);
|
|
77
|
+
o.onupgradeneeded = () => {
|
|
78
|
+
o.result.createObjectStore(p, { keyPath: ["recordingId", "seq"] }).createIndex("at", "at");
|
|
79
|
+
}, o.onsuccess = () => s(o.result), o.onerror = () => s(null), o.onblocked = () => s(null);
|
|
76
80
|
} catch {
|
|
77
|
-
|
|
81
|
+
s(null);
|
|
78
82
|
}
|
|
79
|
-
}),
|
|
80
|
-
async function
|
|
83
|
+
}), i = (s) => IDBKeyRange.bound([s, -1 / 0], [s, 1 / 0]);
|
|
84
|
+
async function u(s, o, h, c) {
|
|
81
85
|
const l = await r;
|
|
82
86
|
return l ? new Promise((a) => {
|
|
83
87
|
try {
|
|
84
|
-
const f = l.transaction(p,
|
|
88
|
+
const f = l.transaction(p, s), g = o(f.objectStore(p));
|
|
85
89
|
f.oncomplete = () => a(g ? g() : c), f.onerror = () => a(c), f.onabort = () => a(c);
|
|
86
90
|
} catch {
|
|
87
91
|
a(c);
|
|
@@ -89,56 +93,56 @@ function w(n) {
|
|
|
89
93
|
}) : h();
|
|
90
94
|
}
|
|
91
95
|
return {
|
|
92
|
-
put: (
|
|
96
|
+
put: (s) => u(
|
|
93
97
|
"readwrite",
|
|
94
|
-
(
|
|
95
|
-
|
|
98
|
+
(o) => {
|
|
99
|
+
o.put(s);
|
|
96
100
|
},
|
|
97
|
-
() => e.put(
|
|
101
|
+
() => e.put(s),
|
|
98
102
|
void 0
|
|
99
103
|
),
|
|
100
|
-
list: (
|
|
104
|
+
list: (s) => u(
|
|
101
105
|
"readonly",
|
|
102
|
-
(
|
|
103
|
-
const h =
|
|
106
|
+
(o) => {
|
|
107
|
+
const h = o.getAll(i(s));
|
|
104
108
|
return () => (h.result ?? []).sort((c, l) => c.seq - l.seq);
|
|
105
109
|
},
|
|
106
|
-
() => e.list(
|
|
110
|
+
() => e.list(s),
|
|
107
111
|
[]
|
|
108
112
|
),
|
|
109
|
-
remove: (
|
|
113
|
+
remove: (s, o) => u(
|
|
110
114
|
"readwrite",
|
|
111
115
|
(h) => {
|
|
112
|
-
h.delete([
|
|
116
|
+
h.delete([s, o]);
|
|
113
117
|
},
|
|
114
|
-
() => e.remove(
|
|
118
|
+
() => e.remove(s, o),
|
|
115
119
|
void 0
|
|
116
120
|
),
|
|
117
|
-
clear: (
|
|
121
|
+
clear: (s) => u(
|
|
118
122
|
"readwrite",
|
|
119
|
-
(
|
|
120
|
-
|
|
123
|
+
(o) => {
|
|
124
|
+
o.delete(i(s));
|
|
121
125
|
},
|
|
122
|
-
() => e.clear(
|
|
126
|
+
() => e.clear(s),
|
|
123
127
|
void 0
|
|
124
128
|
),
|
|
125
|
-
prune: (
|
|
129
|
+
prune: (s) => u(
|
|
126
130
|
"readwrite",
|
|
127
|
-
(
|
|
128
|
-
const h =
|
|
131
|
+
(o) => {
|
|
132
|
+
const h = o.index("at").openCursor(IDBKeyRange.upperBound(s, !0));
|
|
129
133
|
h.onsuccess = () => {
|
|
130
134
|
const c = h.result;
|
|
131
135
|
c && (c.delete(), c.continue());
|
|
132
136
|
};
|
|
133
137
|
},
|
|
134
|
-
() => e.prune(
|
|
138
|
+
() => e.prune(s),
|
|
135
139
|
void 0
|
|
136
140
|
)
|
|
137
141
|
};
|
|
138
142
|
}
|
|
139
143
|
let y = null;
|
|
140
|
-
function
|
|
141
|
-
return y || (y =
|
|
144
|
+
function F() {
|
|
145
|
+
return y || (y = x()), y;
|
|
142
146
|
}
|
|
143
147
|
function P() {
|
|
144
148
|
try {
|
|
@@ -147,7 +151,7 @@ function P() {
|
|
|
147
151
|
return null;
|
|
148
152
|
}
|
|
149
153
|
}
|
|
150
|
-
function
|
|
154
|
+
function Y(n, t) {
|
|
151
155
|
try {
|
|
152
156
|
const e = n == null ? void 0 : n.getItem(t);
|
|
153
157
|
if (!e) return null;
|
|
@@ -157,34 +161,34 @@ function F(n, t) {
|
|
|
157
161
|
return null;
|
|
158
162
|
}
|
|
159
163
|
}
|
|
160
|
-
function
|
|
164
|
+
function H(n, t, e) {
|
|
161
165
|
try {
|
|
162
166
|
n == null || n.setItem(t, JSON.stringify(e));
|
|
163
167
|
} catch {
|
|
164
168
|
}
|
|
165
169
|
}
|
|
166
|
-
function
|
|
170
|
+
function J(n, t) {
|
|
167
171
|
try {
|
|
168
172
|
n == null || n.removeItem(t);
|
|
169
173
|
} catch {
|
|
170
174
|
}
|
|
171
175
|
}
|
|
172
|
-
function
|
|
176
|
+
function L(n, t, e) {
|
|
173
177
|
if (!n) return !1;
|
|
174
178
|
const r = t - n.lastActivityAt;
|
|
175
179
|
return !(r < 0 || r > 6e5);
|
|
176
180
|
}
|
|
177
|
-
function
|
|
181
|
+
function w(n, t) {
|
|
178
182
|
const e = [];
|
|
179
183
|
let r = t;
|
|
180
|
-
for (const
|
|
181
|
-
const
|
|
182
|
-
if (
|
|
183
|
-
e.push({ chunk:
|
|
184
|
+
for (const i of n) {
|
|
185
|
+
const u = I(i), s = q(u);
|
|
186
|
+
if (s > r) break;
|
|
187
|
+
e.push({ chunk: i, body: u }), r -= s;
|
|
184
188
|
}
|
|
185
189
|
return e;
|
|
186
190
|
}
|
|
187
|
-
class
|
|
191
|
+
class W {
|
|
188
192
|
constructor(t) {
|
|
189
193
|
d(this, "recordingId", null);
|
|
190
194
|
d(this, "nextSeq", 0);
|
|
@@ -195,6 +199,12 @@ class L {
|
|
|
195
199
|
* up from sessionStorage until the server has taken a chunk for it.
|
|
196
200
|
*/
|
|
197
201
|
d(this, "trusted", !0);
|
|
202
|
+
/**
|
|
203
|
+
* The recording was refused for good (closed / abandoned): nothing more is
|
|
204
|
+
* queued or sent for it until `begin()` / `rebase()` points the uploader at
|
|
205
|
+
* another one. A pagehide keepalive after the refusal sends nothing.
|
|
206
|
+
*/
|
|
207
|
+
d(this, "stopped", !1);
|
|
198
208
|
d(this, "pending", []);
|
|
199
209
|
d(this, "bytesQueued", 0);
|
|
200
210
|
d(this, "restored", /* @__PURE__ */ new WeakSet());
|
|
@@ -212,10 +222,10 @@ class L {
|
|
|
212
222
|
* this tab left in the store for it; they go first.
|
|
213
223
|
*/
|
|
214
224
|
begin(t, e = 0, r = {}) {
|
|
215
|
-
this.recordingId = t, this.nextSeq = e, this.trusted = r.trusted ?? !0, this.attempt = 0, this.pending = [], this.bytesQueued = 0;
|
|
216
|
-
for (const
|
|
217
|
-
|
|
218
|
-
this.pending.sort((
|
|
225
|
+
this.recordingId = t, this.nextSeq = e, this.trusted = r.trusted ?? !0, this.stopped = !1, this.attempt = 0, this.pending = [], this.bytesQueued = 0;
|
|
226
|
+
for (const i of r.restored ?? [])
|
|
227
|
+
i.recordingId === t && (this.restored.add(i), this.pending.push(i), this.bytesQueued += i.bytes, i.seq >= this.nextSeq && (this.nextSeq = i.seq + 1));
|
|
228
|
+
this.pending.sort((i, u) => i.seq - u.seq), this.enforceBound();
|
|
219
229
|
}
|
|
220
230
|
hasPending() {
|
|
221
231
|
return this.pending.length > 0;
|
|
@@ -235,13 +245,13 @@ class L {
|
|
|
235
245
|
* names the route it was recorded on and the build (#1368).
|
|
236
246
|
*/
|
|
237
247
|
enqueue(t, e = {}) {
|
|
238
|
-
if (!this.recordingId || t.length === 0) return null;
|
|
248
|
+
if (!this.recordingId || this.stopped || t.length === 0) return null;
|
|
239
249
|
let r = 2;
|
|
240
250
|
try {
|
|
241
251
|
r = JSON.stringify(t).length;
|
|
242
252
|
} catch {
|
|
243
253
|
}
|
|
244
|
-
const
|
|
254
|
+
const i = {
|
|
245
255
|
recordingId: this.recordingId,
|
|
246
256
|
seq: this.nextSeq++,
|
|
247
257
|
events: t,
|
|
@@ -250,7 +260,7 @@ class L {
|
|
|
250
260
|
...e.route ? { route: e.route } : {},
|
|
251
261
|
...e.build ? { build: e.build } : {}
|
|
252
262
|
};
|
|
253
|
-
return this.pending.push(
|
|
263
|
+
return this.pending.push(i), this.bytesQueued += r, this.store.put(i), this.enforceBound(), i;
|
|
254
264
|
}
|
|
255
265
|
/** Oldest first, but never the last chunk standing. */
|
|
256
266
|
enforceBound() {
|
|
@@ -277,7 +287,7 @@ class L {
|
|
|
277
287
|
* Callers keep this single-flight.
|
|
278
288
|
*/
|
|
279
289
|
async drain(t = !1) {
|
|
280
|
-
for (; this.recordingId && this.pending.length > 0; ) {
|
|
290
|
+
for (; this.recordingId && !this.stopped && this.pending.length > 0; ) {
|
|
281
291
|
if (!this.online()) return "offline";
|
|
282
292
|
const e = this.pending[0], r = t && e.bytes <= 6e4;
|
|
283
293
|
this.sending = e, this.sendingKeepaliveBytes = r ? e.bytes : 0;
|
|
@@ -287,21 +297,23 @@ class L {
|
|
|
287
297
|
e.seq,
|
|
288
298
|
e.events,
|
|
289
299
|
r,
|
|
290
|
-
|
|
300
|
+
b(e, this.attempt)
|
|
291
301
|
), this.trusted = !0, this.attempt = 0, this.forget(e);
|
|
292
|
-
} catch (
|
|
293
|
-
const
|
|
294
|
-
if (
|
|
302
|
+
} catch (i) {
|
|
303
|
+
const u = E(i), s = S(u);
|
|
304
|
+
if (s === "retry")
|
|
295
305
|
return this.attempt++, "retry";
|
|
296
|
-
if (
|
|
297
|
-
console.warn(
|
|
306
|
+
if (s === "drop-chunk") {
|
|
307
|
+
console.warn(
|
|
308
|
+
`[session-recorder] chunk ${e.seq} refused (too large or malformed) — dropped`
|
|
309
|
+
), this.trusted = !0, this.forget(e);
|
|
298
310
|
continue;
|
|
299
311
|
}
|
|
300
|
-
if (!this.trusted) {
|
|
301
|
-
for (const
|
|
312
|
+
if (!this.trusted && u !== 401) {
|
|
313
|
+
for (const o of [...this.pending]) this.restored.has(o) && this.forget(o);
|
|
302
314
|
return "stale";
|
|
303
315
|
}
|
|
304
|
-
return this.discard(),
|
|
316
|
+
return this.discard(), this.stopped = !0, s === "closed" ? "closed" : "abandoned";
|
|
305
317
|
} finally {
|
|
306
318
|
this.sending = null, this.sendingKeepaliveBytes = 0;
|
|
307
319
|
}
|
|
@@ -313,11 +325,11 @@ class L {
|
|
|
313
325
|
* restart at 0 in the same order.
|
|
314
326
|
*/
|
|
315
327
|
rebase(t) {
|
|
316
|
-
const e = this.recordingId, r = this.pending.filter((
|
|
317
|
-
e && e !== t && this.store.clear(e), this.recordingId = t, this.nextSeq = 0, this.trusted = !0, this.attempt = 0, this.pending = [], this.bytesQueued = 0;
|
|
318
|
-
for (const
|
|
319
|
-
const
|
|
320
|
-
this.pending.push(
|
|
328
|
+
const e = this.recordingId, r = this.pending.filter((i) => !this.restored.has(i));
|
|
329
|
+
e && e !== t && this.store.clear(e), this.recordingId = t, this.nextSeq = 0, this.trusted = !0, this.stopped = !1, this.attempt = 0, this.pending = [], this.bytesQueued = 0;
|
|
330
|
+
for (const i of r) {
|
|
331
|
+
const u = { ...i, recordingId: t, seq: this.nextSeq++ };
|
|
332
|
+
this.pending.push(u), this.bytesQueued += u.bytes, this.store.put(u);
|
|
321
333
|
}
|
|
322
334
|
}
|
|
323
335
|
/**
|
|
@@ -328,33 +340,35 @@ class L {
|
|
|
328
340
|
* the server ignores a seq it already holds.
|
|
329
341
|
*/
|
|
330
342
|
keepaliveBatch(t = 6e4) {
|
|
343
|
+
if (this.stopped) return [];
|
|
331
344
|
const e = this.pending.filter((r) => r !== this.sending);
|
|
332
|
-
return
|
|
345
|
+
return w(e, t - this.sendingKeepaliveBytes);
|
|
333
346
|
}
|
|
334
347
|
}
|
|
335
348
|
export {
|
|
336
|
-
|
|
337
|
-
|
|
349
|
+
C as BACKOFF_BASE_MS,
|
|
350
|
+
N as BACKOFF_MAX_MS,
|
|
338
351
|
K as CHUNK_BYTES,
|
|
339
|
-
|
|
352
|
+
k as KEEPALIVE_BUDGET,
|
|
340
353
|
M as KEEPALIVE_CHUNK_BYTES,
|
|
341
354
|
D as ORPHAN_TTL_MS,
|
|
342
|
-
|
|
355
|
+
O as QUEUE_MAX_BYTES,
|
|
343
356
|
U as RESUME_WINDOW_MS,
|
|
344
|
-
|
|
357
|
+
W as ReplayUploader,
|
|
345
358
|
T as backoffDelay,
|
|
346
359
|
I as chunkBody,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
360
|
+
b as chunkExtra,
|
|
361
|
+
S as classifyUploadError,
|
|
362
|
+
J as clearResume,
|
|
363
|
+
R as clipChunkFailure,
|
|
350
364
|
E as errorStatus,
|
|
351
|
-
|
|
352
|
-
|
|
365
|
+
x as idbChunkStore,
|
|
366
|
+
L as isResumable,
|
|
353
367
|
v as memoryChunkStore,
|
|
354
|
-
|
|
355
|
-
|
|
368
|
+
w as packKeepalive,
|
|
369
|
+
Y as readResume,
|
|
356
370
|
P as sessionStore,
|
|
357
|
-
|
|
371
|
+
F as sharedChunkStore,
|
|
358
372
|
Q as splitBySize,
|
|
359
|
-
|
|
373
|
+
H as writeResume
|
|
360
374
|
};
|