@nivaro/react 0.3.99 → 0.3.101

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.
Files changed (60) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useFormSchema.js +82 -85
  3. package/dist/hooks/useSessionRecorder.js +206 -175
  4. package/dist/index.d.ts +84 -16
  5. package/dist/index.js +627 -622
  6. package/dist/lib/commands.js +15 -11
  7. package/dist/shared/components/ActivityEntry.js +5 -5
  8. package/dist/shared/components/CollectionBrowserView.js +516 -503
  9. package/dist/shared/components/ItemEditForm.js +3471 -3465
  10. package/dist/shared/components/JobsTray.js +76 -61
  11. package/dist/shared/components/MyWorkView.js +133 -126
  12. package/dist/shared/components/NotificationBell.js +322 -289
  13. package/dist/shared/components/RecordCompare.js +38 -40
  14. package/dist/shared/components/RecordReadView.js +119 -119
  15. package/dist/shared/components/TipLayer.js +56 -41
  16. package/dist/shared/components/cbv/FoundElsewhere.js +61 -0
  17. package/dist/shared/components/integrations/console/SignalCard.js +40 -40
  18. package/dist/shared/components/integrations/console/drill/SubmissionDrill.js +95 -73
  19. package/dist/shared/components/integrations/console/drill/status.js +23 -18
  20. package/dist/shared/components/item-edit/InlineGridField.js +45 -45
  21. package/dist/shared/components/item-edit/InlineTableField.js +750 -749
  22. package/dist/shared/components/item-edit/QuickPickerDialog.js +44 -44
  23. package/dist/shared/components/item-edit/RawEditSheet.js +122 -114
  24. package/dist/shared/components/item-edit/RecordInsights.js +86 -86
  25. package/dist/shared/components/item-edit/RelationCombobox.js +454 -378
  26. package/dist/shared/components/item-edit/SummaryPanel.js +56 -48
  27. package/dist/shared/components/item-edit/header-path-preview.js +46 -34
  28. package/dist/shared/components/item-edit/related-missing.js +75 -19
  29. package/dist/shared/components/notifications/DeliveryChips.js +1 -2
  30. package/dist/shared/components/notifications/NotificationCenterView.js +249 -226
  31. package/dist/shared/components/panels/AccessDeniedPanel.js +31 -28
  32. package/dist/shared/components/panels/BackgroundMove.js +242 -0
  33. package/dist/shared/components/panels/MoveAdvisory.js +204 -0
  34. package/dist/shared/components/panels/PipelinePanel.js +1459 -1220
  35. package/dist/shared/components/panels/RecordIntegrityBanner.js +113 -112
  36. package/dist/shared/components/profile/ActivityFeedCard.js +322 -0
  37. package/dist/shared/components/profile/DayTimeline.js +145 -140
  38. package/dist/shared/components/profile/PersonAccess.js +679 -383
  39. package/dist/shared/components/profile/PersonActivity.js +404 -427
  40. package/dist/shared/components/profile/PersonDidPanel.js +248 -134
  41. package/dist/shared/components/profile/PersonProfile.js +33 -32
  42. package/dist/shared/components/profile/journey-view.js +166 -0
  43. package/dist/shared/lib/activity-sentence.js +319 -236
  44. package/dist/shared/lib/commands.js +18 -14
  45. package/dist/shared/lib/error-hints.js +1 -1
  46. package/dist/shared/lib/job-failure-text.js +12 -0
  47. package/dist/shared/lib/jobs-tray.js +60 -41
  48. package/dist/shared/lib/move-failure.js +19 -0
  49. package/dist/shared/lib/obligation-banner.js +22 -21
  50. package/dist/shared/lib/partner-failure.js +83 -0
  51. package/dist/shared/lib/prefetch.js +73 -73
  52. package/dist/shared/lib/replay-checkout.js +18 -13
  53. package/dist/shared/lib/replay-context.js +90 -77
  54. package/dist/shared/lib/replay-idle.js +21 -0
  55. package/dist/shared/lib/replay-socket.js +21 -17
  56. package/dist/shared/lib/rum.js +56 -51
  57. package/dist/shared/lib/safe-error.js +17 -13
  58. package/dist/shared/lib/stale-chunk.js +69 -26
  59. package/dist/shared/lib/system-collections.js +20 -0
  60. package/package.json +1 -1
@@ -1,90 +1,91 @@
1
- import { endSessionRecording as $, appendSessionRecordingEvents as X, sessionRecordingEnabled as ce, startSessionRecording as L } from "@nivaro/sdk";
2
- import { useRef as de, useEffect as fe } from "react";
3
- import { sessionStore as pe, sharedChunkStore as he, ReplayUploader as me, clearResume as P, ORPHAN_TTL_MS as we, readResume as ye, isResumable as ge, splitBySize as Z, writeResume as ve, KEEPALIVE_CHUNK_BYTES as be, CHUNK_BYTES as Re, backoffDelay as Se, errorStatus as ke, clipChunkFailure as Ce } from "./replayUploadQueue.js";
4
- import { useAutoRecord as Ee } from "./useAutoRecord.js";
5
- import { useOptionalNivaroClient as Ae } from "../shared/context.js";
6
- import { normalizeReplayMasking as B, buildReplayMaskingOptions as z } from "../shared/lib/replay-masking.js";
7
- import { normalizeReplaySampling as x, replaySampleDraw as Ie, currentReplayRoute as D, isReplayRouteSampled as Y, attributeChunkRoutes as ee } from "../shared/lib/replay-sampling.js";
8
- import { noteReplayEvent as _e, createReplayCheckoutState as De } from "../shared/lib/replay-checkout.js";
9
- import { emitReplayTap as Te, setReplayRecorderMode as N, registerReplayCapture as qe, clipEndOffset as Le, withClipKind as Pe } from "../shared/lib/replay-capture.js";
10
- import { instrumentConsole as Ne, instrumentRequests as Fe, redactSecrets as Me } from "../shared/lib/replay-context.js";
11
- import { instrumentSocket as Oe } from "../shared/lib/replay-socket.js";
12
- const Ue = "nivaro-react@0.3.99", j = 1e4, We = 150, He = 3e3, Ke = 600, $e = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
13
- function Be(n) {
14
- return typeof n.url != "string" || typeof fetch != "function" ? null : (f, a) => {
15
- const u = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
16
- return u && (d.Authorization = `Bearer ${u}`), fetch(`${n.url}/api/session-recordings/${f}/events`, {
1
+ import { endSessionRecording as M, appendSessionRecordingEvents as te, sessionRecordingEnabled as pe, startSessionRecording as q } from "@nivaro/sdk";
2
+ import { useRef as he, useEffect as me } from "react";
3
+ import { sessionStore as we, sharedChunkStore as ye, ReplayUploader as ge, clearResume as N, ORPHAN_TTL_MS as ve, readResume as Re, isResumable as be, splitBySize as re, writeResume as Se, KEEPALIVE_CHUNK_BYTES as ke, CHUNK_BYTES as Ie, backoffDelay as Ae, errorStatus as Ee, clipChunkFailure as Ce } from "./replayUploadQueue.js";
4
+ import { useAutoRecord as _e } from "./useAutoRecord.js";
5
+ import { useOptionalNivaroClient as De } from "../shared/context.js";
6
+ import { normalizeReplayMasking as x, buildReplayMaskingOptions as j } from "../shared/lib/replay-masking.js";
7
+ import { normalizeReplaySampling as G, replaySampleDraw as Te, currentReplayRoute as L, isReplayRouteSampled as J, attributeChunkRoutes as ne } from "../shared/lib/replay-sampling.js";
8
+ import { noteReplayIdle as qe, createReplayIdleState as Le, REPLAY_IDLE_RESTART_MS as Pe } from "../shared/lib/replay-idle.js";
9
+ import { noteReplayEvent as Fe, createReplayCheckoutState as Me } from "../shared/lib/replay-checkout.js";
10
+ import { emitReplayTap as Ne, setReplayRecorderMode as O, registerReplayCapture as Oe, clipEndOffset as Ue, withClipKind as We } from "../shared/lib/replay-capture.js";
11
+ import { instrumentConsole as He, instrumentRequests as Ke, redactSecrets as $e } from "../shared/lib/replay-context.js";
12
+ import { instrumentSocket as Be } from "../shared/lib/replay-socket.js";
13
+ const ze = "nivaro-react@0.3.101", Q = 1e4, Ye = 150, xe = 3e3, je = 600, Ge = (o) => `nvr_replay_resume${o ? `:${o}` : ""}`, V = () => typeof navigator > "u" || navigator.onLine !== !1;
14
+ function Je(o) {
15
+ return typeof o.url != "string" || typeof fetch != "function" ? null : (f, u) => {
16
+ const l = typeof o.getToken == "function" ? o.getToken() : void 0, d = { "Content-Type": "application/json" };
17
+ return l && (d.Authorization = `Bearer ${l}`), fetch(`${o.url}/api/session-recordings/${f}/events`, {
17
18
  method: "POST",
18
19
  keepalive: !0,
19
- credentials: u ? "omit" : "include",
20
+ credentials: l ? "omit" : "include",
20
21
  headers: d,
21
- body: a
22
+ body: u
22
23
  });
23
24
  };
24
25
  }
25
- async function ze(n, f, a, u, d) {
26
- const l = Z(u), { routes: R } = ee(l, d.startRoute);
27
- for (const [c, e] of l.entries()) {
28
- const g = a();
26
+ async function Qe(o, f, u, l, d) {
27
+ const c = re(l), { routes: S } = ne(c, d.startRoute);
28
+ for (const [a, e] of c.entries()) {
29
+ const h = u();
29
30
  try {
30
- await n.request(
31
- X(f, g, e, {
32
- route: R[c],
31
+ await o.request(
32
+ te(f, h, e, {
33
+ route: S[a],
33
34
  ...d.build ? { build: d.build } : {}
34
35
  })
35
36
  );
36
- } catch (v) {
37
- const b = ke(v);
37
+ } catch (R) {
38
+ const b = Ee(R);
38
39
  if (Ce(b) === "stop") return "closed";
39
- b === 413 && console.warn(`[session-recorder] chunk ${g} too large — dropped`);
40
+ b === 413 && console.warn(`[session-recorder] chunk ${h} too large — dropped`);
40
41
  }
41
42
  }
42
43
  return "ok";
43
44
  }
44
- const xe = 3e4, Ye = 3e4;
45
- let J = !1, y = null, k = null;
46
- async function je(n = "error") {
47
- if (!k) return null;
45
+ const Ve = 3e4, Xe = 3e4;
46
+ let X = !1, v = null, E = null;
47
+ async function Ze(o = "error") {
48
+ if (!E) return null;
48
49
  try {
49
50
  return await Promise.race([
50
- k(n),
51
+ E(o),
51
52
  new Promise((f) => setTimeout(() => f(null), 4e3))
52
53
  ]);
53
54
  } catch {
54
55
  return null;
55
56
  }
56
57
  }
57
- async function Q() {
58
+ async function Z() {
58
59
  try {
59
60
  return (await import("rrweb")).record;
60
61
  } catch {
61
- return J || (J = !0, console.warn(
62
+ return X || (X = !0, console.warn(
62
63
  "[nivaro] session recording is enabled on the instance but `rrweb` is not installed in this app — run `npm i rrweb` to record."
63
64
  )), null;
64
65
  }
65
66
  }
66
- function V(n, f) {
67
- const a = Ne(n), u = Fe(n), d = Oe(n), l = () => {
67
+ function ee(o, f) {
68
+ const u = He(o), l = Ke(o), d = Be(o), c = () => {
68
69
  f == null || f();
69
70
  try {
70
- n("route", {
71
- path: Me(window.location.pathname + window.location.search)
71
+ o("route", {
72
+ path: $e(window.location.pathname + window.location.search)
72
73
  });
73
74
  } catch {
74
75
  }
75
- }, R = history.pushState.bind(history), c = history.replaceState.bind(history);
76
+ }, S = history.pushState.bind(history), a = history.replaceState.bind(history);
76
77
  return history.pushState = (...e) => {
77
- R(...e), l();
78
+ S(...e), c();
78
79
  }, history.replaceState = (...e) => {
79
- c(...e), l();
80
- }, window.addEventListener("popstate", l), l(), () => {
81
- a(), u(), d(), history.pushState = R, history.replaceState = c, window.removeEventListener("popstate", l);
80
+ a(...e), c();
81
+ }, window.addEventListener("popstate", c), c(), () => {
82
+ u(), l(), d(), history.pushState = S, history.replaceState = a, window.removeEventListener("popstate", c);
82
83
  };
83
84
  }
84
- function st(n = {}) {
85
- const f = Ae(), a = n.client ?? f, u = n.app, d = n.disabled ?? !1, l = n.build ?? Ue;
86
- Ee({ client: a, disabled: d });
87
- const R = de({
85
+ function ft(o = {}) {
86
+ const f = De(), u = o.client ?? f, l = o.app, d = o.disabled ?? !1, c = o.build ?? ze;
87
+ _e({ client: u, disabled: d });
88
+ const S = he({
88
89
  buffer: [],
89
90
  stop: null,
90
91
  uninstrument: null,
@@ -100,99 +101,111 @@ function st(n = {}) {
100
101
  prevWindowRoute: "/",
101
102
  sampled: !0
102
103
  });
103
- fe(() => {
104
- if (!a || d || typeof window > "u") return;
105
- let c = !1;
106
- const e = R.current;
104
+ me(() => {
105
+ if (!u || d || typeof window > "u") return;
106
+ let a = !1;
107
+ const e = S.current;
107
108
  e.dead = !1;
108
- const g = a, v = pe(), b = $e(u), C = he(), E = Be(g), te = async (t, r, i, h, w = {}) => {
109
- if (!h || !E) {
110
- await g.request(X(t, r, i, w));
109
+ const h = u, R = we(), b = Ge(l), C = ye(), _ = Je(h), oe = async (t, r, i, w, y = {}) => {
110
+ if (!w || !_) {
111
+ await h.request(te(t, r, i, y));
111
112
  return;
112
113
  }
113
- const s = await E(t, JSON.stringify({ seq: r, events: i, ...w }));
114
- if (!s.ok) throw Object.assign(new Error(`HTTP ${s.status}`), { status: s.status });
115
- }, o = new me({ store: C, send: te, online: G });
116
- let S = null, A = 0;
117
- const re = () => document.readyState === "complete" && Date.now() - e.lastNavAt >= He;
114
+ const g = await _(t, JSON.stringify({ seq: r, events: i, ...y }));
115
+ if (!g.ok) throw Object.assign(new Error(`HTTP ${g.status}`), { status: g.status });
116
+ }, n = new ge({ store: C, send: oe, online: V });
117
+ let k = null, D = 0;
118
+ const ie = () => document.readyState === "complete" && Date.now() - e.lastNavAt >= xe;
118
119
  function I() {
119
- o.recordingId && ve(v, b, {
120
- recordingId: o.recordingId,
121
- nextSeq: o.nextSeq,
120
+ n.recordingId && Se(R, b, {
121
+ recordingId: n.recordingId,
122
+ nextSeq: n.nextSeq,
122
123
  startedAt: e.startedAt,
123
124
  lastActivityAt: Date.now()
124
125
  });
125
126
  }
126
- function _() {
127
- S && clearTimeout(S), S = null, A = 0;
127
+ function T() {
128
+ k && clearTimeout(k), k = null, D = 0;
128
129
  }
129
- function ne() {
130
- _();
131
- const t = Se(o.attempt);
132
- A = Date.now() + t, S = setTimeout(() => {
133
- S = null, A = 0, m(!0);
130
+ function se() {
131
+ T();
132
+ const t = Ae(n.attempt);
133
+ D = Date.now() + t, k = setTimeout(() => {
134
+ k = null, D = 0, m(!0);
134
135
  }, t);
135
136
  }
136
- function F() {
137
+ function U() {
137
138
  var t;
138
- e.dead = !0, (t = e.stop) == null || t.call(e), e.stop = null, e.buffer = [], _(), o.discard(), o.stopped = !0, P(v, b);
139
+ e.dead = !0, (t = e.stop) == null || t.call(e), e.stop = null, e.buffer = [], T(), n.discard(), n.stopped = !0, N(R, b);
139
140
  }
140
- function M(t) {
141
- if (e.buffer.length === 0 || !o.recordingId) return;
141
+ function W(t) {
142
+ if (e.buffer.length === 0 || !n.recordingId) return;
142
143
  const r = e.buffer;
143
144
  e.buffer = [];
144
- const i = Z(r, t ? be : Re), { routes: h } = ee(i, e.bufferRoute);
145
- for (const [w, s] of i.entries())
146
- o.enqueue(s, { route: h[w], ...l ? { build: l } : {} });
145
+ const i = re(r, t ? ke : Ie), { routes: w } = ne(i, e.bufferRoute);
146
+ for (const [y, g] of i.entries())
147
+ n.enqueue(g, { route: w[y], ...c ? { build: c } : {} });
147
148
  I();
148
149
  }
149
- async function oe(t) {
150
- if (!c) {
151
- if (t === "retry") ne();
152
- else if (t === "closed" || t === "abandoned") F();
150
+ async function ae(t) {
151
+ if (!a) {
152
+ if (t === "retry") se();
153
+ else if (t === "closed" || t === "abandoned") U();
153
154
  else if (t === "stale")
154
155
  try {
155
- const r = await g.request(L(u));
156
- if (c) return;
157
- o.rebase(r.data.id), e.startedAt = Date.now(), I(), e.flushAfter = !0;
156
+ const r = await h.request(q(l));
157
+ if (a) return;
158
+ n.rebase(r.data.id), e.startedAt = Date.now(), I(), e.flushAfter = !0;
158
159
  } catch {
159
- F();
160
+ U();
160
161
  }
161
162
  }
162
163
  }
163
164
  function m(t = !1, r = !1) {
164
- return e.inFlight ? (t && (e.flushAfter = !0), e.inFlight) : e.dead || !o.recordingId || !t && !re() && e.buffer.length < Ke || (M(r), !o.hasPending() || Date.now() < A) ? Promise.resolve() : (e.inFlight = o.drain(r).then(oe).catch(() => {
165
+ return e.inFlight ? (t && (e.flushAfter = !0), e.inFlight) : e.dead || !n.recordingId || !t && !ie() && e.buffer.length < je || (W(r), !n.hasPending() || Date.now() < D) ? Promise.resolve() : (e.inFlight = n.drain(r).then(ae).catch(() => {
165
166
  }).finally(() => {
166
167
  e.inFlight = null, e.flushAfter && (e.flushAfter = !1, m(!0));
167
168
  }), e.inFlight);
168
169
  }
169
- function O() {
170
+ async function ue() {
171
+ const t = n.recordingId;
172
+ if (!(!t || e.dead) && (await m(!0).catch(() => {
173
+ }), !(a || e.dead || n.recordingId !== t || n.hasPending())))
174
+ try {
175
+ const r = await h.request(q(l));
176
+ if (a || e.dead) return;
177
+ h.request(M(t)).catch(() => {
178
+ }), n.begin(r.data.id), e.startedAt = Date.now(), I();
179
+ } catch {
180
+ }
181
+ }
182
+ function H() {
170
183
  const t = window.requestIdleCallback;
171
- t ? t(() => void m(), { timeout: j }) : m();
184
+ t ? t(() => void m(), { timeout: Q }) : m();
172
185
  }
173
- async function ie() {
174
- const t = await Q();
175
- if (c || !t) return;
176
- C.prune(Date.now() - we);
177
- const r = ye(v, b);
178
- if (r && ge(r, Date.now())) {
186
+ async function le() {
187
+ const t = await Z();
188
+ if (a || !t) return;
189
+ C.prune(Date.now() - ve);
190
+ const r = Re(R, b);
191
+ if (r && be(r, Date.now())) {
179
192
  const s = await C.list(r.recordingId);
180
- if (c) return;
181
- o.begin(r.recordingId, r.nextSeq, { trusted: !1, restored: s }), e.startedAt = r.startedAt;
193
+ if (a) return;
194
+ n.begin(r.recordingId, r.nextSeq, { trusted: !1, restored: s }), e.startedAt = r.startedAt;
182
195
  } else {
183
- r && (C.clear(r.recordingId), P(v, b));
184
- const s = await g.request(L(u));
185
- if (c) return;
186
- o.begin(s.data.id), e.startedAt = Date.now();
196
+ r && (C.clear(r.recordingId), N(R, b));
197
+ const s = await h.request(q(l));
198
+ if (a) return;
199
+ n.begin(s.data.id), e.startedAt = Date.now();
187
200
  }
188
201
  I(), e.lastNavAt = Date.now();
189
- const i = Ie(v);
190
- e.route = D(), e.bufferRoute = e.route, e.sampled = Y(q, e.route, i);
191
- const h = () => {
202
+ const i = Te(R);
203
+ e.route = L(), e.bufferRoute = e.route, e.sampled = J(F, e.route, i);
204
+ const w = () => {
192
205
  var p;
193
- e.route = D();
206
+ e.route = L();
194
207
  const s = e.sampled;
195
- if (e.sampled = Y(q, e.route, i), e.sampled && !s)
208
+ if (e.sampled = J(F, e.route, i), e.sampled && !s)
196
209
  try {
197
210
  (p = t.takeFullSnapshot) == null || p.call(
198
211
  t,
@@ -200,128 +213,146 @@ function st(n = {}) {
200
213
  );
201
214
  } catch {
202
215
  }
203
- }, w = De();
216
+ }, y = Me(), g = Le(), A = (s) => {
217
+ setTimeout(() => {
218
+ (async () => {
219
+ var p;
220
+ if (s >= Pe && await ue(), !(a || e.dead))
221
+ try {
222
+ (p = t.takeFullSnapshot) == null || p.call(t, !0);
223
+ } catch {
224
+ }
225
+ })();
226
+ }, 0);
227
+ };
204
228
  e.stop = t({
205
229
  emit(s) {
206
- e.sampled && (e.buffer.length === 0 && (e.bufferRoute = e.route), e.buffer.push(s), e.buffer.length >= We && O(), _e(w, s) && setTimeout(() => {
207
- var p;
208
- try {
209
- (p = t.takeFullSnapshot) == null || p.call(t, !0);
210
- } catch {
211
- w.pending = !1;
230
+ const p = qe(g, s);
231
+ if (e.sampled) {
232
+ if (p !== "keep") {
233
+ p === "resume" && A(g.idleMs);
234
+ return;
212
235
  }
213
- }, 0));
236
+ e.buffer.length === 0 && (e.bufferRoute = e.route), e.buffer.push(s), e.buffer.length >= Ye && H(), Fe(y, s) && setTimeout(() => {
237
+ var Y;
238
+ try {
239
+ (Y = t.takeFullSnapshot) == null || Y.call(t, !0);
240
+ } catch {
241
+ y.pending = !1;
242
+ }
243
+ }, 0);
244
+ }
214
245
  },
215
- ...z(() => T)
216
- }) ?? null, e.uninstrument = V(
246
+ ...j(() => P)
247
+ }) ?? null, e.uninstrument = ee(
217
248
  (s, p) => t.addCustomEvent(
218
249
  s,
219
250
  p
220
251
  ),
221
252
  () => {
222
- e.lastNavAt = Date.now(), h();
253
+ e.lastNavAt = Date.now(), w();
223
254
  }
224
- ), k = async () => {
225
- if (!o.recordingId) return null;
255
+ ), E = async () => {
256
+ if (!n.recordingId) return null;
226
257
  const s = Date.now() - e.startedAt;
227
258
  return await m(!0).catch(() => {
228
- }), o.recordingId ? { recording_id: o.recordingId, offset_ms: s } : null;
229
- }, N("full"), y = () => {
230
- if (!o.recordingId) return null;
259
+ }), n.recordingId ? { recording_id: n.recordingId, offset_ms: s } : null;
260
+ }, O("full"), v = () => {
261
+ if (!n.recordingId) return null;
231
262
  const s = Date.now() - e.startedAt;
232
263
  return async () => (await m(!0).catch(() => {
233
- }), o.recordingId ? { recording_id: o.recordingId, offset_ms: s } : null);
264
+ }), n.recordingId ? { recording_id: n.recordingId, offset_ms: s } : null);
234
265
  };
235
266
  }
236
- async function se() {
237
- const t = await Q();
238
- c || !t || (e.buffer = [], e.prevWindow = [], e.route = D(), e.bufferRoute = e.route, e.prevWindowRoute = e.route, e.stop = t({
267
+ async function ce() {
268
+ const t = await Z();
269
+ a || !t || (e.buffer = [], e.prevWindow = [], e.route = L(), e.bufferRoute = e.route, e.prevWindowRoute = e.route, e.stop = t({
239
270
  emit(r, i) {
240
- Te(r), i ? (e.prevWindow = e.buffer, e.prevWindowRoute = e.bufferRoute, e.buffer = [r], e.bufferRoute = e.route) : e.buffer.push(r);
271
+ Ne(r), i ? (e.prevWindow = e.buffer, e.prevWindowRoute = e.bufferRoute, e.buffer = [r], e.bufferRoute = e.route) : e.buffer.push(r);
241
272
  },
242
- ...z(() => T),
243
- checkoutEveryNms: xe
244
- }) ?? null, e.uninstrument = V(
273
+ ...j(() => P),
274
+ checkoutEveryNms: Ve
275
+ }) ?? null, e.uninstrument = ee(
245
276
  (r, i) => t.addCustomEvent(
246
277
  r,
247
278
  i
248
279
  ),
249
280
  () => {
250
- e.route = D();
281
+ e.route = L();
251
282
  }
252
- ), N("clip"), y = (r) => {
253
- const i = [...e.prevWindow, ...e.buffer], h = e.prevWindow.length > 0 ? e.prevWindowRoute : e.bufferRoute;
254
- if (i.length === 0 || !a) return null;
255
- const w = Le(i, r);
283
+ ), O("clip"), v = (r) => {
284
+ const i = [...e.prevWindow, ...e.buffer], w = e.prevWindow.length > 0 ? e.prevWindowRoute : e.bufferRoute;
285
+ if (i.length === 0 || !u) return null;
286
+ const y = Ue(i, r);
256
287
  return async () => {
257
- const p = (await a.request(
258
- Pe(L(u ?? "error-clip", void 0, !0), r)
288
+ const A = (await u.request(
289
+ We(q(l ?? "error-clip", void 0, !0), r)
259
290
  )).data.id;
260
- let le = 0;
261
- return await ze(a, p, () => le++, i, {
262
- startRoute: h,
263
- build: l
264
- }) === "ok" && await a.request($(p)).catch(() => {
265
- }), { recording_id: p, offset_ms: w };
291
+ let s = 0;
292
+ return await Qe(u, A, () => s++, i, {
293
+ startRoute: w,
294
+ build: c
295
+ }) === "ok" && await u.request(M(A)).catch(() => {
296
+ }), { recording_id: A, offset_ms: y };
266
297
  };
267
- }, k = async (r) => {
298
+ }, E = async (r) => {
268
299
  if (r === "error") {
269
- if (e.lastClip && Date.now() - e.lastClip.at < Ye)
300
+ if (e.lastClip && Date.now() - e.lastClip.at < Xe)
270
301
  return e.lastClip.link;
271
302
  e.lastClip = { at: Date.now(), link: null };
272
303
  }
273
- const i = y == null ? void 0 : y(r);
304
+ const i = v == null ? void 0 : v(r);
274
305
  if (!i) return null;
275
- const h = await i();
276
- return r === "error" && (e.lastClip = { at: Date.now(), link: h }), h;
306
+ const w = await i();
307
+ return r === "error" && (e.lastClip = { at: Date.now(), link: w }), w;
277
308
  });
278
309
  }
279
- let U = !1, T = B(null), q = x(null);
280
- async function ae() {
310
+ let K = !1, P = x(null), F = G(null);
311
+ async function de() {
281
312
  try {
282
- const t = await a.request(ce());
283
- if (c) return;
284
- T = B(t.data.masking), q = x(t.data.sampling);
313
+ const t = await u.request(pe());
314
+ if (a) return;
315
+ P = x(t.data.masking), F = G(t.data.sampling);
285
316
  const r = t.data.cap_reached === !0;
286
- U = t.data.enabled === !0 && !r;
317
+ K = t.data.enabled === !0 && !r;
287
318
  const i = t.data.enabled !== !0 && t.data.error_replay === !0 && !r;
288
- U ? await ie() : i && await se();
319
+ K ? await le() : i && await ce();
289
320
  } catch {
290
321
  }
291
322
  }
292
- ae();
293
- const ue = setInterval(O, j), W = () => {
323
+ de();
324
+ const fe = setInterval(H, Q), $ = () => {
294
325
  document.visibilityState === "hidden" && m(!0, !0);
295
326
  };
296
- document.addEventListener("visibilitychange", W);
297
- const H = () => {
298
- if (!(e.dead || !o.recordingId) && (M(!0), I(), !(!G() || !E)))
299
- for (const { chunk: t, body: r } of o.keepaliveBatch())
327
+ document.addEventListener("visibilitychange", $);
328
+ const B = () => {
329
+ if (!(e.dead || !n.recordingId) && (W(!0), I(), !(!V() || !_)))
330
+ for (const { chunk: t, body: r } of n.keepaliveBatch())
300
331
  try {
301
- E(t.recordingId, r).catch(() => {
332
+ _(t.recordingId, r).catch(() => {
302
333
  });
303
334
  } catch {
304
335
  }
305
336
  };
306
- window.addEventListener("pagehide", H);
307
- const K = () => {
308
- _(), m(!0);
337
+ window.addEventListener("pagehide", B);
338
+ const z = () => {
339
+ T(), m(!0);
309
340
  };
310
- return window.addEventListener("online", K), () => {
341
+ return window.addEventListener("online", z), () => {
311
342
  var t, r;
312
- c = !0, k = null, y = null, N(null), document.removeEventListener("visibilitychange", W), window.removeEventListener("pagehide", H), window.removeEventListener("online", K), clearInterval(ue), _(), (t = e.uninstrument) == null || t.call(e), e.uninstrument = null, (r = e.stop) == null || r.call(e), e.stop = null, e.prevWindow = [], m(!0).then(() => {
313
- const i = o.recordingId;
314
- i && (e.dead || g.request($(i)).catch(() => {
315
- }), o.discard(), o.recordingId = null, P(v, b));
343
+ a = !0, E = null, v = null, O(null), document.removeEventListener("visibilitychange", $), window.removeEventListener("pagehide", B), window.removeEventListener("online", z), clearInterval(fe), T(), (t = e.uninstrument) == null || t.call(e), e.uninstrument = null, (r = e.stop) == null || r.call(e), e.stop = null, e.prevWindow = [], m(!0).then(() => {
344
+ const i = n.recordingId;
345
+ i && (e.dead || h.request(M(i)).catch(() => {
346
+ }), n.discard(), n.recordingId = null, N(R, b));
316
347
  });
317
348
  };
318
- }, [a, d, u, l]);
349
+ }, [u, d, l, c]);
319
350
  }
320
- qe(
321
- (n) => je(n),
322
- (n) => (y == null ? void 0 : y(n)) ?? null
351
+ Oe(
352
+ (o) => Ze(o),
353
+ (o) => (v == null ? void 0 : v(o)) ?? null
323
354
  );
324
355
  export {
325
- je as captureErrorClip,
326
- st as useSessionRecorder
356
+ Ze as captureErrorClip,
357
+ ft as useSessionRecorder
327
358
  };