@nivaro/react 0.3.8 → 0.3.10

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/components/fields/FileField.js +20 -19
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/replayUploadQueue.js +107 -93
  4. package/dist/hooks/useNivaroForm.js +129 -126
  5. package/dist/hooks/useSessionRecorder.js +103 -101
  6. package/dist/index.d.ts +115 -2
  7. package/dist/index.js +466 -447
  8. package/dist/shared/components/CollectionBrowserView.js +1058 -1059
  9. package/dist/shared/components/ConformanceView.js +36 -35
  10. package/dist/shared/components/DataTable.js +230 -223
  11. package/dist/shared/components/ForceReloadBanner.js +58 -34
  12. package/dist/shared/components/ItemEditForm.js +3687 -3580
  13. package/dist/shared/components/JsonMapEditor.js +18 -17
  14. package/dist/shared/components/MatrixEditor.js +8 -7
  15. package/dist/shared/components/MyWorkView.js +32 -31
  16. package/dist/shared/components/PageRenderer.js +146 -145
  17. package/dist/shared/components/QueryTable.js +49 -49
  18. package/dist/shared/components/RecordGridEditor.js +76 -75
  19. package/dist/shared/components/ai/AiMemorySuggestions.js +15 -14
  20. package/dist/shared/components/ai/AskPanel.js +55 -54
  21. package/dist/shared/components/bulk/BulkActionButtons.js +30 -29
  22. package/dist/shared/components/bulk/PushBulkButtons.js +57 -56
  23. package/dist/shared/components/chat/ChatPanel.js +288 -287
  24. package/dist/shared/components/chat/SlashCommands.js +30 -29
  25. package/dist/shared/components/chat/chat-outbox.js +76 -75
  26. package/dist/shared/components/help-videos/recorder/useLeaveWarning.js +6 -5
  27. package/dist/shared/components/integrations/console/SignalCard.js +124 -123
  28. package/dist/shared/components/integrations/console/SnoozeMenu.js +24 -23
  29. package/dist/shared/components/item-edit/CloneDialog.js +85 -78
  30. package/dist/shared/components/item-edit/InlineTableField.js +301 -300
  31. package/dist/shared/components/item-edit/MembershipSetField.js +24 -23
  32. package/dist/shared/components/item-edit/QuickCreateButton.js +8 -7
  33. package/dist/shared/components/item-edit/RecordLiveSync.js +101 -100
  34. package/dist/shared/components/item-edit/staged-links.js +86 -0
  35. package/dist/shared/components/layout-editor/LayoutEditor.js +275 -274
  36. package/dist/shared/components/layout-editor/editors/cascade-rule-row.js +18 -17
  37. package/dist/shared/components/layout-editor/inspector/HelpTab.js +37 -36
  38. package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +50 -49
  39. package/dist/shared/components/panels/CommentPanel.js +237 -236
  40. package/dist/shared/components/profile/AiMemoryCard.js +15 -14
  41. package/dist/shared/components/profile/PersonAdminTools.js +70 -67
  42. package/dist/shared/components/profile/usePersonPresence.js +42 -37
  43. package/dist/shared/components/queue/QueueItemSheet.js +36 -35
  44. package/dist/shared/components/queue/QueueWorklist.js +597 -598
  45. package/dist/shared/lib/client-version.js +63 -0
  46. package/dist/shared/lib/force-reload.js +36 -0
  47. package/dist/shared/lib/load-error.js +11 -10
  48. package/dist/shared/lib/presence-live.js +73 -0
  49. package/dist/shared/lib/presence-state.js +39 -31
  50. package/dist/shared/lib/record-outbox.js +76 -75
  51. package/dist/shared/lib/request-gate.js +120 -102
  52. package/dist/shared/lib/rum.js +45 -36
  53. package/dist/shared/lib/safe-error.js +39 -0
  54. package/dist/shared/lib/server-clock.js +11 -7
  55. package/dist/shared/lib/signed-out.js +114 -0
  56. package/dist/shared/lib/socket-realtime.js +19 -17
  57. package/dist/shared/lib/unsaved-work.js +62 -0
  58. package/dist/shared/lib/use-online-users.js +11 -10
  59. package/dist/shared/lib/worker-socket.js +89 -79
  60. package/package.json +1 -1
@@ -1,53 +1,52 @@
1
1
  import { endSessionRecording as $, appendSessionRecordingEvents as X, sessionRecordingEnabled as ce, startSessionRecording as T } from "@nivaro/sdk";
2
2
  import { useRef as de, useEffect as fe } from "react";
3
- import { sessionStore as pe, sharedChunkStore as me, ReplayUploader as he, clearResume as P, ORPHAN_TTL_MS as we, readResume as ge, isResumable as ve, splitBySize as Z, writeResume as ye, KEEPALIVE_CHUNK_BYTES as be, CHUNK_BYTES as Re, backoffDelay as Se } from "./replayUploadQueue.js";
4
- import { useAutoRecord as ke } from "./useAutoRecord.js";
5
- import { useOptionalNivaroClient as Ee } from "../shared/context.js";
3
+ import { sessionStore as pe, sharedChunkStore as he, ReplayUploader as me, clearResume as P, ORPHAN_TTL_MS as we, readResume as ge, isResumable as ve, splitBySize as Z, writeResume as ye, KEEPALIVE_CHUNK_BYTES as be, CHUNK_BYTES as Re, backoffDelay as Se, errorStatus as ke, clipChunkFailure as Ee } from "./replayUploadQueue.js";
4
+ import { useAutoRecord as Ae } from "./useAutoRecord.js";
5
+ import { useOptionalNivaroClient as Ce } from "../shared/context.js";
6
6
  import { normalizeReplayMasking as B, buildReplayMaskingOptions as z } from "../shared/lib/replay-masking.js";
7
- import { normalizeReplaySampling as x, replaySampleDraw as Ae, currentReplayRoute as _, isReplayRouteSampled as Y, attributeChunkRoutes as ee } from "../shared/lib/replay-sampling.js";
8
- import { emitReplayTap as Ce, setReplayRecorderMode as N, registerReplayCapture as Ie, clipEndOffset as _e, withClipKind as De } from "../shared/lib/replay-capture.js";
9
- import { instrumentConsole as qe, instrumentRequests as Le, redactSecrets as Te } from "../shared/lib/replay-context.js";
10
- import { instrumentSocket as Pe } from "../shared/lib/replay-socket.js";
11
- const Ne = "nivaro-react@0.3.8", j = 1e4, Me = 150, Oe = 3e3, Ue = 600, We = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
12
- function Fe(n) {
7
+ import { normalizeReplaySampling as x, replaySampleDraw as Ie, currentReplayRoute as _, isReplayRouteSampled as Y, attributeChunkRoutes as ee } from "../shared/lib/replay-sampling.js";
8
+ import { emitReplayTap as _e, setReplayRecorderMode as N, registerReplayCapture as De, clipEndOffset as qe, withClipKind as Le } from "../shared/lib/replay-capture.js";
9
+ import { instrumentConsole as Te, instrumentRequests as Pe, redactSecrets as Ne } from "../shared/lib/replay-context.js";
10
+ import { instrumentSocket as Me } from "../shared/lib/replay-socket.js";
11
+ const Oe = "nivaro-react@0.3.10", j = 1e4, Ue = 150, We = 3e3, Fe = 600, He = (n) => `nvr_replay_resume${n ? `:${n}` : ""}`, G = () => typeof navigator > "u" || navigator.onLine !== !1;
12
+ function Ke(n) {
13
13
  return typeof n.url != "string" || typeof fetch != "function" ? null : (f, a) => {
14
- const l = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
15
- return l && (d.Authorization = `Bearer ${l}`), fetch(`${n.url}/api/session-recordings/${f}/events`, {
14
+ const u = typeof n.getToken == "function" ? n.getToken() : void 0, d = { "Content-Type": "application/json" };
15
+ return u && (d.Authorization = `Bearer ${u}`), fetch(`${n.url}/api/session-recordings/${f}/events`, {
16
16
  method: "POST",
17
17
  keepalive: !0,
18
- credentials: l ? "omit" : "include",
18
+ credentials: u ? "omit" : "include",
19
19
  headers: d,
20
20
  body: a
21
21
  });
22
22
  };
23
23
  }
24
- async function He(n, f, a, l, d) {
25
- var u;
26
- const c = Z(l), { routes: R } = ee(c, d.startRoute);
27
- for (const [e, y] of c.entries()) {
28
- const h = a();
24
+ async function $e(n, f, a, u, d) {
25
+ const l = Z(u), { routes: b } = ee(l, d.startRoute);
26
+ for (const [c, e] of l.entries()) {
27
+ const g = a();
29
28
  try {
30
29
  await n.request(
31
- X(f, h, y, {
32
- route: R[e],
30
+ X(f, g, e, {
31
+ route: b[c],
33
32
  ...d.build ? { build: d.build } : {}
34
33
  })
35
34
  );
36
35
  } catch (v) {
37
- const b = v.status ?? ((u = v.response) == null ? void 0 : u.status);
38
- if (b === 409) return "closed";
39
- b === 413 && console.warn(`[session-recorder] chunk ${h} too large — dropped`);
36
+ const y = ke(v);
37
+ if (Ee(y) === "stop") return "closed";
38
+ y === 413 && console.warn(`[session-recorder] chunk ${g} too large — dropped`);
40
39
  }
41
40
  }
42
41
  return "ok";
43
42
  }
44
- const Ke = 3e4, $e = 3e4;
45
- let J = !1, g = null, k = null;
46
- async function Be(n = "error") {
47
- if (!k) return null;
43
+ const Be = 3e4, ze = 3e4;
44
+ let J = !1, w = null, S = null;
45
+ async function xe(n = "error") {
46
+ if (!S) return null;
48
47
  try {
49
48
  return await Promise.race([
50
- k(n),
49
+ S(n),
51
50
  new Promise((f) => setTimeout(() => f(null), 4e3))
52
51
  ]);
53
52
  } catch {
@@ -64,27 +63,27 @@ async function Q() {
64
63
  }
65
64
  }
66
65
  function V(n, f) {
67
- const a = qe(n), l = Le(n), d = Pe(n), c = () => {
66
+ const a = Te(n), u = Pe(n), d = Me(n), l = () => {
68
67
  f == null || f();
69
68
  try {
70
69
  n("route", {
71
- path: Te(window.location.pathname + window.location.search)
70
+ path: Ne(window.location.pathname + window.location.search)
72
71
  });
73
72
  } catch {
74
73
  }
75
- }, R = history.pushState.bind(history), u = history.replaceState.bind(history);
74
+ }, b = history.pushState.bind(history), c = history.replaceState.bind(history);
76
75
  return history.pushState = (...e) => {
77
- R(...e), c();
76
+ b(...e), l();
78
77
  }, history.replaceState = (...e) => {
79
- u(...e), c();
80
- }, window.addEventListener("popstate", c), c(), () => {
81
- a(), l(), d(), history.pushState = R, history.replaceState = u, window.removeEventListener("popstate", c);
78
+ c(...e), l();
79
+ }, window.addEventListener("popstate", l), l(), () => {
80
+ a(), u(), d(), history.pushState = b, history.replaceState = c, window.removeEventListener("popstate", l);
82
81
  };
83
82
  }
84
- function et(n = {}) {
85
- const f = Ee(), a = n.client ?? f, l = n.app, d = n.disabled ?? !1, c = n.build ?? Ne;
86
- ke({ client: a, disabled: d });
87
- const R = de({
83
+ function nt(n = {}) {
84
+ const f = Ce(), a = n.client ?? f, u = n.app, d = n.disabled ?? !1, l = n.build ?? Oe;
85
+ Ae({ client: a, disabled: d });
86
+ const b = de({
88
87
  buffer: [],
89
88
  stop: null,
90
89
  uninstrument: null,
@@ -102,21 +101,21 @@ function et(n = {}) {
102
101
  });
103
102
  fe(() => {
104
103
  if (!a || d || typeof window > "u") return;
105
- let u = !1;
106
- const e = R.current;
104
+ let c = !1;
105
+ const e = b.current;
107
106
  e.dead = !1;
108
- const y = a, h = pe(), v = We(l), b = me(), E = Fe(y), te = async (t, r, i, m, s = {}) => {
109
- if (!m || !E) {
110
- await y.request(X(t, r, i, s));
107
+ const g = a, v = pe(), y = He(u), k = he(), E = Ke(g), te = async (t, r, i, h, s = {}) => {
108
+ if (!h || !E) {
109
+ await g.request(X(t, r, i, s));
111
110
  return;
112
111
  }
113
112
  const p = await E(t, JSON.stringify({ seq: r, events: i, ...s }));
114
113
  if (!p.ok) throw Object.assign(new Error(`HTTP ${p.status}`), { status: p.status });
115
- }, o = new he({ store: b, send: te, online: G });
116
- let S = null, A = 0;
117
- const re = () => document.readyState === "complete" && Date.now() - e.lastNavAt >= Oe;
114
+ }, o = new me({ store: k, send: te, online: G });
115
+ let R = null, A = 0;
116
+ const re = () => document.readyState === "complete" && Date.now() - e.lastNavAt >= We;
118
117
  function C() {
119
- o.recordingId && ye(h, v, {
118
+ o.recordingId && ye(v, y, {
120
119
  recordingId: o.recordingId,
121
120
  nextSeq: o.nextSeq,
122
121
  startedAt: e.startedAt,
@@ -124,71 +123,71 @@ function et(n = {}) {
124
123
  });
125
124
  }
126
125
  function I() {
127
- S && clearTimeout(S), S = null, A = 0;
126
+ R && clearTimeout(R), R = null, A = 0;
128
127
  }
129
128
  function ne() {
130
129
  I();
131
130
  const t = Se(o.attempt);
132
- A = Date.now() + t, S = setTimeout(() => {
133
- S = null, A = 0, w(!0);
131
+ A = Date.now() + t, R = setTimeout(() => {
132
+ R = null, A = 0, m(!0);
134
133
  }, t);
135
134
  }
136
135
  function M() {
137
136
  var t;
138
- e.dead = !0, (t = e.stop) == null || t.call(e), I(), o.discard(), P(h, v);
137
+ e.dead = !0, (t = e.stop) == null || t.call(e), e.stop = null, e.buffer = [], I(), o.discard(), o.stopped = !0, P(v, y);
139
138
  }
140
139
  function O(t) {
141
140
  if (e.buffer.length === 0 || !o.recordingId) return;
142
141
  const r = e.buffer;
143
142
  e.buffer = [];
144
- const i = Z(r, t ? be : Re), { routes: m } = ee(i, e.bufferRoute);
143
+ const i = Z(r, t ? be : Re), { routes: h } = ee(i, e.bufferRoute);
145
144
  for (const [s, p] of i.entries())
146
- o.enqueue(p, { route: m[s], ...c ? { build: c } : {} });
145
+ o.enqueue(p, { route: h[s], ...l ? { build: l } : {} });
147
146
  C();
148
147
  }
149
148
  async function oe(t) {
150
- if (!u) {
149
+ if (!c) {
151
150
  if (t === "retry") ne();
152
151
  else if (t === "closed" || t === "abandoned") M();
153
152
  else if (t === "stale")
154
153
  try {
155
- const r = await y.request(T(l));
156
- if (u) return;
154
+ const r = await g.request(T(u));
155
+ if (c) return;
157
156
  o.rebase(r.data.id), e.startedAt = Date.now(), C(), e.flushAfter = !0;
158
157
  } catch {
159
158
  M();
160
159
  }
161
160
  }
162
161
  }
163
- function w(t = !1, r = !1) {
164
- return e.inFlight ? (t && (e.flushAfter = !0), e.inFlight) : e.dead || !o.recordingId || !t && !re() && e.buffer.length < Ue || (O(r), !o.hasPending() || Date.now() < A) ? Promise.resolve() : (e.inFlight = o.drain(r).then(oe).catch(() => {
162
+ function m(t = !1, r = !1) {
163
+ return e.inFlight ? (t && (e.flushAfter = !0), e.inFlight) : e.dead || !o.recordingId || !t && !re() && e.buffer.length < Fe || (O(r), !o.hasPending() || Date.now() < A) ? Promise.resolve() : (e.inFlight = o.drain(r).then(oe).catch(() => {
165
164
  }).finally(() => {
166
- e.inFlight = null, e.flushAfter && (e.flushAfter = !1, w(!0));
165
+ e.inFlight = null, e.flushAfter && (e.flushAfter = !1, m(!0));
167
166
  }), e.inFlight);
168
167
  }
169
168
  function U() {
170
169
  const t = window.requestIdleCallback;
171
- t ? t(() => void w(), { timeout: j }) : w();
170
+ t ? t(() => void m(), { timeout: j }) : m();
172
171
  }
173
172
  async function ie() {
174
173
  const t = await Q();
175
- if (u || !t) return;
176
- b.prune(Date.now() - we);
177
- const r = ge(h, v);
174
+ if (c || !t) return;
175
+ k.prune(Date.now() - we);
176
+ const r = ge(v, y);
178
177
  if (r && ve(r, Date.now())) {
179
- const s = await b.list(r.recordingId);
180
- if (u) return;
178
+ const s = await k.list(r.recordingId);
179
+ if (c) return;
181
180
  o.begin(r.recordingId, r.nextSeq, { trusted: !1, restored: s }), e.startedAt = r.startedAt;
182
181
  } else {
183
- r && (b.clear(r.recordingId), P(h, v));
184
- const s = await y.request(T(l));
185
- if (u) return;
182
+ r && (k.clear(r.recordingId), P(v, y));
183
+ const s = await g.request(T(u));
184
+ if (c) return;
186
185
  o.begin(s.data.id), e.startedAt = Date.now();
187
186
  }
188
187
  C(), e.lastNavAt = Date.now();
189
- const i = Ae(h);
188
+ const i = Ie(v);
190
189
  e.route = _(), e.bufferRoute = e.route, e.sampled = Y(q, e.route, i);
191
- const m = () => {
190
+ const h = () => {
192
191
  var p;
193
192
  e.route = _();
194
193
  const s = e.sampled;
@@ -203,7 +202,7 @@ function et(n = {}) {
203
202
  };
204
203
  e.stop = t({
205
204
  emit(s) {
206
- e.sampled && (e.buffer.length === 0 && (e.bufferRoute = e.route), e.buffer.push(s), e.buffer.length >= Me && U());
205
+ e.sampled && (e.buffer.length === 0 && (e.bufferRoute = e.route), e.buffer.push(s), e.buffer.length >= Ue && U());
207
206
  },
208
207
  ...z(() => D),
209
208
  checkoutEveryNms: 6e4
@@ -213,28 +212,28 @@ function et(n = {}) {
213
212
  p
214
213
  ),
215
214
  () => {
216
- e.lastNavAt = Date.now(), m();
215
+ e.lastNavAt = Date.now(), h();
217
216
  }
218
- ), k = async () => {
217
+ ), S = async () => {
219
218
  if (!o.recordingId) return null;
220
219
  const s = Date.now() - e.startedAt;
221
- return await w(!0).catch(() => {
220
+ return await m(!0).catch(() => {
222
221
  }), o.recordingId ? { recording_id: o.recordingId, offset_ms: s } : null;
223
- }, N("full"), g = () => {
222
+ }, N("full"), w = () => {
224
223
  if (!o.recordingId) return null;
225
224
  const s = Date.now() - e.startedAt;
226
- return async () => (await w(!0).catch(() => {
225
+ return async () => (await m(!0).catch(() => {
227
226
  }), o.recordingId ? { recording_id: o.recordingId, offset_ms: s } : null);
228
227
  };
229
228
  }
230
229
  async function se() {
231
230
  const t = await Q();
232
- u || !t || (e.buffer = [], e.prevWindow = [], e.route = _(), e.bufferRoute = e.route, e.prevWindowRoute = e.route, e.stop = t({
231
+ c || !t || (e.buffer = [], e.prevWindow = [], e.route = _(), e.bufferRoute = e.route, e.prevWindowRoute = e.route, e.stop = t({
233
232
  emit(r, i) {
234
- Ce(r), i ? (e.prevWindow = e.buffer, e.prevWindowRoute = e.bufferRoute, e.buffer = [r], e.bufferRoute = e.route) : e.buffer.push(r);
233
+ _e(r), i ? (e.prevWindow = e.buffer, e.prevWindowRoute = e.bufferRoute, e.buffer = [r], e.bufferRoute = e.route) : e.buffer.push(r);
235
234
  },
236
235
  ...z(() => D),
237
- checkoutEveryNms: Ke
236
+ checkoutEveryNms: Be
238
237
  }) ?? null, e.uninstrument = V(
239
238
  (r, i) => t.addCustomEvent(
240
239
  r,
@@ -243,35 +242,38 @@ function et(n = {}) {
243
242
  () => {
244
243
  e.route = _();
245
244
  }
246
- ), N("clip"), g = (r) => {
247
- const i = [...e.prevWindow, ...e.buffer], m = e.prevWindow.length > 0 ? e.prevWindowRoute : e.bufferRoute;
245
+ ), N("clip"), w = (r) => {
246
+ const i = [...e.prevWindow, ...e.buffer], h = e.prevWindow.length > 0 ? e.prevWindowRoute : e.bufferRoute;
248
247
  if (i.length === 0 || !a) return null;
249
- const s = _e(i, r);
248
+ const s = qe(i, r);
250
249
  return async () => {
251
250
  const L = (await a.request(
252
- De(T(l ?? "error-clip", void 0, !0), r)
251
+ Le(T(u ?? "error-clip", void 0, !0), r)
253
252
  )).data.id;
254
253
  let le = 0;
255
- return await He(a, L, () => le++, i, { startRoute: m, build: c }), await a.request($(L)).catch(() => {
254
+ return await $e(a, L, () => le++, i, {
255
+ startRoute: h,
256
+ build: l
257
+ }) === "ok" && await a.request($(L)).catch(() => {
256
258
  }), { recording_id: L, offset_ms: s };
257
259
  };
258
- }, k = async (r) => {
260
+ }, S = async (r) => {
259
261
  if (r === "error") {
260
- if (e.lastClip && Date.now() - e.lastClip.at < $e)
262
+ if (e.lastClip && Date.now() - e.lastClip.at < ze)
261
263
  return e.lastClip.link;
262
264
  e.lastClip = { at: Date.now(), link: null };
263
265
  }
264
- const i = g == null ? void 0 : g(r);
266
+ const i = w == null ? void 0 : w(r);
265
267
  if (!i) return null;
266
- const m = await i();
267
- return r === "error" && (e.lastClip = { at: Date.now(), link: m }), m;
268
+ const h = await i();
269
+ return r === "error" && (e.lastClip = { at: Date.now(), link: h }), h;
268
270
  });
269
271
  }
270
272
  let W = !1, D = B(null), q = x(null);
271
273
  async function ae() {
272
274
  try {
273
275
  const t = await a.request(ce());
274
- if (u) return;
276
+ if (c) return;
275
277
  D = B(t.data.masking), q = x(t.data.sampling);
276
278
  const r = t.data.cap_reached === !0;
277
279
  W = t.data.enabled === !0 && !r;
@@ -282,7 +284,7 @@ function et(n = {}) {
282
284
  }
283
285
  ae();
284
286
  const ue = setInterval(U, j), F = () => {
285
- document.visibilityState === "hidden" && w(!0, !0);
287
+ document.visibilityState === "hidden" && m(!0, !0);
286
288
  };
287
289
  document.addEventListener("visibilitychange", F);
288
290
  const H = () => {
@@ -296,23 +298,23 @@ function et(n = {}) {
296
298
  };
297
299
  window.addEventListener("pagehide", H);
298
300
  const K = () => {
299
- I(), w(!0);
301
+ I(), m(!0);
300
302
  };
301
303
  return window.addEventListener("online", K), () => {
302
304
  var t, r;
303
- u = !0, k = null, g = null, N(null), document.removeEventListener("visibilitychange", F), window.removeEventListener("pagehide", H), window.removeEventListener("online", K), clearInterval(ue), I(), (t = e.uninstrument) == null || t.call(e), e.uninstrument = null, (r = e.stop) == null || r.call(e), e.stop = null, e.prevWindow = [], w(!0).then(() => {
305
+ c = !0, S = null, w = null, N(null), document.removeEventListener("visibilitychange", F), window.removeEventListener("pagehide", H), window.removeEventListener("online", K), clearInterval(ue), I(), (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(() => {
304
306
  const i = o.recordingId;
305
- i && (e.dead || y.request($(i)).catch(() => {
306
- }), o.discard(), o.recordingId = null, P(h, v));
307
+ i && (e.dead || g.request($(i)).catch(() => {
308
+ }), o.discard(), o.recordingId = null, P(v, y));
307
309
  });
308
310
  };
309
- }, [a, d, l, c]);
311
+ }, [a, d, u, l]);
310
312
  }
311
- Ie(
312
- (n) => Be(n),
313
- (n) => (g == null ? void 0 : g(n)) ?? null
313
+ De(
314
+ (n) => xe(n),
315
+ (n) => (w == null ? void 0 : w(n)) ?? null
314
316
  );
315
317
  export {
316
- Be as captureErrorClip,
317
- et as useSessionRecorder
318
+ xe as captureErrorClip,
319
+ nt as useSessionRecorder
318
320
  };
package/dist/index.d.ts CHANGED
@@ -3063,7 +3063,8 @@ export declare const FORCE_RELOAD_EVENT = "nvr:force-refresh";
3063
3063
  * the app root. Mount it once per host.
3064
3064
  *
3065
3065
  * A second push while a countdown is running restarts the clock with the
3066
- * newer duration — the later instruction wins.
3066
+ * newer duration — the later instruction wins. The same instruction arriving
3067
+ * twice (live, then again on a reconnect) is ignored.
3067
3068
  *
3068
3069
  * The countdown runs against a wall-clock deadline, not a count of timer
3069
3070
  * ticks: a background tab's timers wake about once a minute, so counting 15
@@ -3071,12 +3072,36 @@ export declare const FORCE_RELOAD_EVENT = "nvr:force-refresh";
3071
3072
  * build never reloaded while the admin watched). A throttled tab reloads at
3072
3073
  * its first wake past the deadline, and a frozen one the moment it is shown
3073
3074
  * or focused again.
3075
+ *
3076
+ * Sticky refresh: a tab that was asleep or offline is told when it reconnects,
3077
+ * and a tab below an app's minimum build is told on connect
3078
+ * (api/src/services/sticky-refresh.ts). Each checks for itself first
3079
+ * (lib/force-reload.ts) and marks the instruction before reloading, so it
3080
+ * never reloads twice for one instruction (twice at most for a minimum build).
3081
+ *
3082
+ * Unsaved work (lib/unsaved-work.ts) holds the reload: past the deadline the
3083
+ * banner says a reload is waiting and reloads the moment the edits are saved
3084
+ * or discarded — or when the person clicks Reload now.
3074
3085
  */
3075
3086
  export declare function ForceReloadBanner(): JSX.Element | null;
3076
3087
 
3088
+ /**
3089
+ * Sticky force refresh — the client half of api/src/services/sticky-refresh.ts.
3090
+ *
3091
+ * The server pushes `client:force-refresh` live, again when a tab that missed it connects, and
3092
+ * whenever a tab connects below an app's minimum build. A browser's shared worker carries every
3093
+ * tab of an app on ONE socket and reports the first tab's build, so a push meant for an old tab
3094
+ * can reach a newer one: each tab checks for itself here before counting down.
3095
+ */
3096
+ /** What `client:force-refresh` carries. Everything after `message` is optional (older servers). */
3077
3097
  export declare interface ForceReloadDetail {
3078
3098
  seconds?: number;
3079
3099
  message?: string;
3100
+ id?: string;
3101
+ issued_at?: number;
3102
+ reason?: 'push' | 'sticky' | 'min-build';
3103
+ min_build?: string;
3104
+ set_at?: number;
3080
3105
  }
3081
3106
 
3082
3107
  /** Drop every settled metadata answer (call after a configuration write made outside the SDK client). */
@@ -3400,12 +3425,20 @@ declare interface GridSumCapConfig {
3400
3425
  message?: string;
3401
3426
  }
3402
3427
 
3428
+ /**
3429
+ * Run one identity call through the gate: `blocked()` answers without a request while the tab
3430
+ * is signed out (outside its probe window); a success opens the gate, a signed-out 401 closes it.
3431
+ */
3432
+ export declare function guardIdentityCall<T>(call: () => Promise<T>, blocked: () => T | Promise<T>): Promise<T>;
3433
+
3403
3434
  declare type GuardRule = {
3404
3435
  field: string;
3405
3436
  op: string;
3406
3437
  value?: unknown;
3407
3438
  };
3408
3439
 
3440
+ export declare function hasUnsavedWork(): boolean;
3441
+
3409
3442
  export declare interface HeaderWidgetInfo {
3410
3443
  field: string;
3411
3444
  widgetId: number;
@@ -4797,6 +4830,19 @@ export declare function isChatPanelPinned(): boolean;
4797
4830
 
4798
4831
  export declare function isCleanRecording(): boolean;
4799
4832
 
4833
+ /** A bug in our own code (not the server's answer, not the network). */
4834
+ export declare function isCodeError(err: unknown): boolean;
4835
+
4836
+ /** True once a 401 said this tab is signed out, until a sign-in is heard. */
4837
+ export declare function isSignedOut(): boolean;
4838
+
4839
+ /**
4840
+ * Does this error say the tab is signed out? `identity` = it came from a "who am I" call, where
4841
+ * any 401 (bar View-as) counts; elsewhere only the session-gone codes do (a public form's wrong
4842
+ * password is a 401 too).
4843
+ */
4844
+ export declare function isSignedOutError(err: unknown, identity?: boolean): boolean;
4845
+
4800
4846
  /**
4801
4847
  * Stale code chunks after a deploy. Screens load lazily by hashed file names, and a new
4802
4848
  * release no longer serves the previous build's files — so a tab opened before the deploy
@@ -5930,6 +5976,21 @@ export declare function NivaroProvider({ client, children, batchReads, persistMe
5930
5976
  */
5931
5977
  export declare function normalizeFieldType(rawType: string, iface: string | null, relation: FormFieldDescriptor['relation']): FormFieldType;
5932
5978
 
5979
+ /** The host swapped credentials (a new bearer token): whatever was refused may work now. */
5980
+ export declare function noteCredentialChanged(): void;
5981
+
5982
+ /**
5983
+ * An identity call succeeded: this tab is signed in. Other tabs hear it when this tab was
5984
+ * signed out until now, or the first time this page learns it (a fresh page after sign-in).
5985
+ */
5986
+ export declare function noteSignedIn(): void;
5987
+
5988
+ /**
5989
+ * A 401 from the API: close the gate and push the next probe further out. `escalate: false`
5990
+ * (a refusal from an ordinary read) only closes an open gate — it never lengthens the wait.
5991
+ */
5992
+ export declare function noteUnauthorized(escalate?: boolean): void;
5993
+
5933
5994
  declare type Notice = (message: string, tone?: 'error' | 'success') => void;
5934
5995
 
5935
5996
  export declare function NotificationActions({ actions, notificationId, onDone, onError, size, className }: NotificationActionsProps): JSX.Element | null;
@@ -6279,6 +6340,9 @@ export declare function onFieldInterfacesChange(cb: () => void): () => void;
6279
6340
  */
6280
6341
  export declare function onIdleChange(fn: (idle: boolean) => void): () => void;
6281
6342
 
6343
+ /** Called once each time the tab goes from signed out to signed in. Returns the unsubscribe. */
6344
+ export declare function onSignedIn(cb: () => void): () => void;
6345
+
6282
6346
  export declare function openAskPanel(question?: string): void;
6283
6347
 
6284
6348
  export declare function openCatalogItem(collection: string, id: string, context?: Record<string, unknown>): void;
@@ -8171,6 +8235,9 @@ export declare function registerReplayCapture(fn: Capture, snap?: Snapshot): ()
8171
8235
 
8172
8236
  export declare function registerRoomOpener(fn: RoomOpener): () => void;
8173
8237
 
8238
+ /** Report a source of unsaved work; the returned function removes it. */
8239
+ export declare function registerUnsavedWork(label: string, dirty: () => boolean): () => void;
8240
+
8174
8241
  /** Register the host's opener. Returns an unregister function. */
8175
8242
  export declare function registerViewAsOpener(fn: ViewAsOpener): () => void;
8176
8243
 
@@ -8332,6 +8399,13 @@ export declare function reportClientCrash(client: {
8332
8399
  url?: string;
8333
8400
  }): Promise<void>;
8334
8401
 
8402
+ /**
8403
+ * Send a code error to the issue log once (POST /issues/client, with the
8404
+ * replay when a recorder is running). Anything else is the server's answer and
8405
+ * already logged there. Never throws.
8406
+ */
8407
+ export declare function reportCodeError(client: Parameters<typeof reportClientCrash>[0] | null | undefined, err: unknown): void;
8408
+
8335
8409
  export declare function ReportProblemButton({ app, floating, className, children, onReported }: {
8336
8410
  /** Your front end's label ('efp'), stored with the report. */
8337
8411
  app?: string;
@@ -9224,6 +9298,18 @@ export declare interface SocketRealtimeOptions {
9224
9298
 
9225
9299
  export declare type SocketRealtimeWindowEvent = 'catchupFull' | 'accessChanged' | 'configUpdate' | 'forceRefresh';
9226
9300
 
9301
+ /**
9302
+ * No raw JavaScript error text on screen, ever. "Cannot read properties of
9303
+ * null (reading 'id')" told a person nothing and invited them to press Save
9304
+ * again (2026-10-23: a duplicate workflow). A code error (a TypeError,
9305
+ * ReferenceError or RangeError that is not a network failure and carries no
9306
+ * HTTP status) shows one plain sentence instead, and the real error goes to
9307
+ * the issue log through the client crash report. A SyntaxError is left alone:
9308
+ * at runtime it comes from JSON.parse / RegExp on what a person typed, and its
9309
+ * text tells them what to fix.
9310
+ */
9311
+ export declare const SOMETHING_WENT_WRONG = "Something went wrong \u2014 it\u2019s been reported";
9312
+
9227
9313
  declare type Speed = 0.5 | 1 | 1.5 | 2 | 4;
9228
9314
 
9229
9315
  export declare function splitMessageTokens(text: string, entityPattern: string): MessageToken[];
@@ -9354,6 +9440,9 @@ export declare function SubmissionStatusPill({ status }: {
9354
9440
 
9355
9441
  export declare function subscribeClientChaos(cb: () => void): () => void;
9356
9442
 
9443
+ /** Told when a source comes or goes, or the record outbox changes. */
9444
+ export declare function subscribeUnsavedWork(cb: () => void): () => void;
9445
+
9357
9446
  /**
9358
9447
  * The one subscription editor — create + edit for nivaro_notification_subscriptions,
9359
9448
  * shared by the profile's Notifications & alerts card and the My Subscriptions
@@ -9832,6 +9921,9 @@ declare interface UnsavedSummary {
9832
9921
  text: string;
9833
9922
  }
9834
9923
 
9924
+ /** What would be lost, by label (empty = nothing). */
9925
+ export declare function unsavedWorkLabels(): string[];
9926
+
9835
9927
  /** The ids an update covers: one, a coalesced list, or null = "too many — refresh it all". */
9836
9928
  export declare function updateItemIds(ev: CollectionUpdateEvent): Array<string | number> | null;
9837
9929
 
@@ -10551,6 +10643,13 @@ export declare function useRelationOptions(client: NivaroClient | null, relatedC
10551
10643
  /** The single required videos (the same fetch as useRequiredList). */
10552
10644
  export declare function useRequiredVideos(): UseQueryResult<NoInfer<HelpVideoDto[]>, Error>;
10553
10645
 
10646
+ /**
10647
+ * The sentence to show for a failed action: the server's explanation when it
10648
+ * gave one, the plain "something went wrong" for a code error, else the
10649
+ * error's own message (or `fallback`).
10650
+ */
10651
+ export declare function userErrorMessage(err: unknown, fallback?: string): string;
10652
+
10554
10653
  export declare function useRoomMembership(): {
10555
10654
  join: UseMutationResult<unknown, Error, string, unknown>;
10556
10655
  leave: UseMutationResult<unknown, Error, string, unknown>;
@@ -10700,6 +10799,9 @@ export declare function useTypingIndicator(room: string | null): {
10700
10799
 
10701
10800
  export declare function useUnreadChirp(totalUnread: number, rooms?: RoomInfo[]): void;
10702
10801
 
10802
+ /** A form reports its dirty state while mounted. */
10803
+ export declare function useUnsavedWork(dirty: boolean, label?: string): void;
10804
+
10703
10805
  /** Directory of users to add to a private channel. */
10704
10806
  export declare function useUserSearch(search: string, enabled: boolean): {
10705
10807
  users: NoInfer<{
@@ -10925,6 +11027,12 @@ export declare interface WorkerSocket extends FallbackSocket {
10925
11027
  * disconnect and connect.
10926
11028
  */
10927
11029
  chaosPause(down: boolean): void;
11030
+ /**
11031
+ * The person signed in (a host that learns it outside the signed-out gate calls this; the gate's
11032
+ * own `noteSignedIn` does it for every worker socket): the worker asks this tab for a token now
11033
+ * instead of staying parked or waiting out its backoff.
11034
+ */
11035
+ signedIn(): void;
10928
11036
  /** The transport the worker's socket uses (for status displays). */
10929
11037
  io: {
10930
11038
  engine: {
@@ -10947,7 +11055,12 @@ export declare interface WorkerSocketOptions {
10947
11055
  features?: string[];
10948
11056
  /** Build fields for `client:hello` (client-version.ts `clientVersion()`). */
10949
11057
  version?: Record<string, unknown>;
10950
- /** Mint a `/auth/ws-token` for the worker's socket (the worker asks one tab per connect). */
11058
+ /**
11059
+ * Mint a `/auth/ws-token` for the worker's socket (the worker asks one tab per connect). A
11060
+ * null answer (signed out, or no token to be had) backs this tab off: the worker's next asks
11061
+ * are answered null without calling this until the wait (1 s doubling to 5 min, jittered)
11062
+ * passes, or the tab hears a sign-in (signed-out.ts).
11063
+ */
10951
11064
  authToken: () => Promise<string | null>;
10952
11065
  /** The host's own socket, created only when the worker cannot serve this tab. */
10953
11066
  fallback: () => FallbackSocket;