@nivaro/react 0.2.54 → 0.2.55

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 (150) hide show
  1. package/dist/full.css +1 -1
  2. package/dist/hooks/useSessionRecorder.js +99 -98
  3. package/dist/index.d.ts +339 -2
  4. package/dist/index.js +644 -618
  5. package/dist/layout-editor.d.ts +4 -0
  6. package/dist/shared/components/BackgroundRunOffer.js +117 -0
  7. package/dist/shared/components/BroadcastView.js +214 -213
  8. package/dist/shared/components/CollectionBrowserView.js +2592 -2695
  9. package/dist/shared/components/ItemEditForm.js +4066 -3832
  10. package/dist/shared/components/JobsTray.js +100 -55
  11. package/dist/shared/components/MyWorkView.js +91 -89
  12. package/dist/shared/components/NotificationBell.js +80 -79
  13. package/dist/shared/components/ProfileView.js +568 -520
  14. package/dist/shared/components/RecordCompare.js +254 -0
  15. package/dist/shared/components/RecordReadView.js +599 -552
  16. package/dist/shared/components/ReportView.js +578 -543
  17. package/dist/shared/components/RowPresence.js +91 -0
  18. package/dist/shared/components/WidgetSlot.js +474 -458
  19. package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
  20. package/dist/shared/components/ai/AskPanel.js +139 -119
  21. package/dist/shared/components/ai/FirstWeekCard.js +126 -0
  22. package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
  23. package/dist/shared/components/bulk/bulk-field-options.js +45 -0
  24. package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
  25. package/dist/shared/components/chat/ChannelArchive.js +326 -0
  26. package/dist/shared/components/chat/ChannelExtras.js +141 -121
  27. package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
  28. package/dist/shared/components/chat/ChatPanel.js +1695 -1733
  29. package/dist/shared/components/chat/Composer.js +357 -303
  30. package/dist/shared/components/chat/MessageActions.js +92 -0
  31. package/dist/shared/components/chat/MessageFormat.js +290 -264
  32. package/dist/shared/components/chat/OutboxBubbles.js +146 -0
  33. package/dist/shared/components/chat/RequestIdCard.js +135 -0
  34. package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
  35. package/dist/shared/components/chat/RoomParts.js +213 -274
  36. package/dist/shared/components/chat/ScreenClip.js +184 -0
  37. package/dist/shared/components/chat/chat-core.js +402 -483
  38. package/dist/shared/components/chat/chat-drafts.js +59 -0
  39. package/dist/shared/components/chat/chat-emoji.js +348 -0
  40. package/dist/shared/components/chat/chat-local-time.js +41 -0
  41. package/dist/shared/components/chat/chat-outbox.js +303 -0
  42. package/dist/shared/components/chat/chat-window.js +163 -0
  43. package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
  44. package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
  45. package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
  46. package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
  47. package/dist/shared/components/help-videos/api.js +76 -73
  48. package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
  49. package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
  50. package/dist/shared/components/item-edit/FieldAffordances.js +2 -2
  51. package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
  52. package/dist/shared/components/item-edit/FieldRow.js +292 -279
  53. package/dist/shared/components/item-edit/GroupSection.js +698 -574
  54. package/dist/shared/components/item-edit/InlineTableField.js +3 -1
  55. package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
  56. package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
  57. package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
  58. package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
  59. package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
  60. package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
  61. package/dist/shared/components/item-edit/lazy-sections.js +36 -0
  62. package/dist/shared/components/item-edit/lock-why.js +39 -32
  63. package/dist/shared/components/item-edit/picker-miss.js +26 -0
  64. package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
  65. package/dist/shared/components/item-edit/useFormUsageBeacon.js +51 -45
  66. package/dist/shared/components/layout-editor/AddPanel.js +134 -117
  67. package/dist/shared/components/layout-editor/ChangeNote.js +25 -24
  68. package/dist/shared/components/layout-editor/CollabParts.js +80 -75
  69. package/dist/shared/components/layout-editor/DesignNode.js +126 -120
  70. package/dist/shared/components/layout-editor/EditorCanvas.js +30 -27
  71. package/dist/shared/components/layout-editor/EditorTopBar.js +203 -192
  72. package/dist/shared/components/layout-editor/HistoryPanel.js +120 -104
  73. package/dist/shared/components/layout-editor/LayoutEditor.js +768 -671
  74. package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
  75. package/dist/shared/components/layout-editor/StagedChip.js +22 -0
  76. package/dist/shared/components/layout-editor/StructureMenu.js +237 -186
  77. package/dist/shared/components/layout-editor/collab/FormFollowShare.js +149 -103
  78. package/dist/shared/components/layout-editor/collab/collab-api.js +29 -26
  79. package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +81 -80
  80. package/dist/shared/components/layout-editor/dnd/node.js +69 -57
  81. package/dist/shared/components/layout-editor/draft-recovery.js +113 -43
  82. package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
  83. package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
  84. package/dist/shared/components/layout-editor/entry/presets.js +71 -0
  85. package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
  86. package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
  87. package/dist/shared/components/layout-editor/grid-guides.js +142 -0
  88. package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
  89. package/dist/shared/components/layout-editor/inspector/BulkInspector.js +61 -57
  90. package/dist/shared/components/layout-editor/inspector/GroupInspector.js +247 -151
  91. package/dist/shared/components/layout-editor/inspector/Inspector.js +176 -155
  92. package/dist/shared/components/layout-editor/inspector/LookTab.js +167 -116
  93. package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
  94. package/dist/shared/components/layout-editor/inspector/PickerTab.js +84 -82
  95. package/dist/shared/components/layout-editor/inspector/RulesTab.js +66 -62
  96. package/dist/shared/components/layout-editor/inspector/kit.js +69 -68
  97. package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
  98. package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
  99. package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
  100. package/dist/shared/components/layout-editor/overview/describe-conditions.js +6 -0
  101. package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
  102. package/dist/shared/components/layout-editor/parity-keys.json.js +1 -1
  103. package/dist/shared/components/layout-editor/restore-piece.js +192 -0
  104. package/dist/shared/components/layout-editor/section-structure.js +241 -0
  105. package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
  106. package/dist/shared/components/layout-editor/settings/FormSettings.js +41 -39
  107. package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
  108. package/dist/shared/components/layout-editor/settings/ToolsSection.js +147 -111
  109. package/dist/shared/components/layout-editor/settings/WhoSection.js +29 -26
  110. package/dist/shared/components/layout-editor/settings/settings-registry.js +114 -17
  111. package/dist/shared/components/layout-editor/staged-api.js +64 -0
  112. package/dist/shared/components/layout-editor/structure-ops.js +81 -77
  113. package/dist/shared/components/layout-editor/testing/TestingPanels.js +65 -60
  114. package/dist/shared/components/layout-editor/testing/testing-model.js +198 -185
  115. package/dist/shared/components/layout-editor/toolbar-kit.js +11 -11
  116. package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
  117. package/dist/shared/components/layout-editor/usage/UsagePanel.js +144 -70
  118. package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
  119. package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
  120. package/dist/shared/components/layout-editor/useLayoutDraft.js +25 -24
  121. package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
  122. package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
  123. package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
  124. package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
  125. package/dist/shared/components/profile/AgentsPanel.js +479 -0
  126. package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
  127. package/dist/shared/components/support/SupportAnalytics.js +171 -0
  128. package/dist/shared/components/support/SupportView.js +75 -73
  129. package/dist/shared/lib/background-runs.js +150 -0
  130. package/dist/shared/lib/delivery-ack.js +9 -0
  131. package/dist/shared/lib/entry-badge-style.js +13 -0
  132. package/dist/shared/lib/entry-config.js +71 -0
  133. package/dist/shared/lib/form-sections.js +64 -0
  134. package/dist/shared/lib/form-structure.js +99 -0
  135. package/dist/shared/lib/form-usage-beacon.js +101 -52
  136. package/dist/shared/lib/jobs-tray.js +25 -23
  137. package/dist/shared/lib/keyset-pager.js +37 -0
  138. package/dist/shared/lib/layout-ops.js +84 -82
  139. package/dist/shared/lib/layout-resolve.js +113 -0
  140. package/dist/shared/lib/placement-behaviour.js +144 -0
  141. package/dist/shared/lib/prefetch.js +149 -0
  142. package/dist/shared/lib/presence-hooks.js +199 -0
  143. package/dist/shared/lib/record-outbox.js +82 -81
  144. package/dist/shared/lib/replay-socket.js +93 -0
  145. package/dist/shared/lib/request-gate.js +51 -50
  146. package/dist/shared/lib/room-gaps.js +96 -0
  147. package/dist/shared/lib/search-log.js +27 -0
  148. package/dist/shared/lib/socket-realtime.js +101 -80
  149. package/dist/shared/lib/worker-socket.js +200 -0
  150. package/package.json +1 -1
@@ -1,24 +1,25 @@
1
- import { get as C, patch as z } from "./commands.js";
2
- const G = "nivaro-record-outbox", x = "entries", H = 1, Z = 10080 * 60 * 1e3, P = 8e3;
3
- function Q(t) {
1
+ import { clearChatOutbox as z } from "../components/chat/chat-outbox.js";
2
+ import { get as C, patch as G } from "./commands.js";
3
+ const H = "nivaro-record-outbox", k = "entries", Z = 1, Q = 10080 * 60 * 1e3, P = 8e3;
4
+ function tt(t) {
4
5
  return t ? `${typeof location < "u" ? location.host : ""}|${t}` : null;
5
6
  }
6
- function tt(t) {
7
+ function et(t) {
7
8
  return t.slice(t.lastIndexOf("|") + 1);
8
9
  }
9
10
  function p(t, e, n) {
10
11
  return `${t}|${e}|${String(n)}`;
11
12
  }
12
- let et = !1;
13
+ let nt = !1;
13
14
  const O = /* @__PURE__ */ new Map();
14
- function nt() {
15
+ function ot() {
15
16
  return new Promise((t) => {
16
17
  try {
17
- if (et || typeof indexedDB > "u") return t(null);
18
- const e = indexedDB.open(G, H);
18
+ if (nt || typeof indexedDB > "u") return t(null);
19
+ const e = indexedDB.open(H, Z);
19
20
  e.onupgradeneeded = () => {
20
21
  const n = e.result;
21
- n.objectStoreNames.contains(x) || n.createObjectStore(x, { keyPath: "id" });
22
+ n.objectStoreNames.contains(k) || n.createObjectStore(k, { keyPath: "id" });
22
23
  }, e.onsuccess = () => t(e.result), e.onerror = () => t(null), e.onblocked = () => t(null);
23
24
  } catch {
24
25
  t(null);
@@ -26,10 +27,10 @@ function nt() {
26
27
  });
27
28
  }
28
29
  async function g(t, e) {
29
- const n = await nt();
30
+ const n = await ot();
30
31
  return n ? new Promise((r) => {
31
32
  try {
32
- const o = n.transaction(x, t), i = e(o.objectStore(x));
33
+ const o = n.transaction(k, t), i = e(o.objectStore(k));
33
34
  i.onsuccess = () => r({ ok: !0, value: i.result }), i.onerror = () => r({ ok: !1, value: null }), o.oncomplete = () => n.close(), o.onerror = () => {
34
35
  n.close(), r({ ok: !1, value: null });
35
36
  };
@@ -44,7 +45,7 @@ async function T(t) {
44
45
  async function v(t) {
45
46
  O.delete(t), await g("readwrite", (e) => e.delete(t));
46
47
  }
47
- async function S(t) {
48
+ async function x(t) {
48
49
  const e = await g("readonly", (n) => n.get(t));
49
50
  return e.ok ? e.value ?? null : O.get(t) ?? null;
50
51
  }
@@ -55,9 +56,9 @@ async function B() {
55
56
  function W(t) {
56
57
  return JSON.parse(JSON.stringify(t ?? null));
57
58
  }
58
- let l = null, ot = !1, j = null, w = null, a = [];
59
+ let l = null, rt = !1, j = null, w = null, a = [];
59
60
  const D = /* @__PURE__ */ new Set(), I = /* @__PURE__ */ new Set(), N = /* @__PURE__ */ new Set();
60
- let k = null, A = !1, h = null;
61
+ let S = null, A = !1, h = null;
61
62
  function d() {
62
63
  for (const t of D) t();
63
64
  }
@@ -76,9 +77,9 @@ function y() {
76
77
  }
77
78
  function K(t, e) {
78
79
  const n = new Date(t.created_at).getTime();
79
- return !Number.isFinite(n) || e - n > Z;
80
+ return !Number.isFinite(n) || e - n > Q;
80
81
  }
81
- async function rt(t) {
82
+ async function it(t) {
82
83
  const e = M();
83
84
  if (!e) return t();
84
85
  await e.request("nvr-record-outbox:sweep", {}, t).catch(() => {
@@ -86,16 +87,16 @@ async function rt(t) {
86
87
  }
87
88
  async function V() {
88
89
  const t = l;
89
- t && await rt(async () => {
90
+ t && await it(async () => {
90
91
  const e = Date.now();
91
92
  for (const n of await B()) {
92
93
  if (!n || n.owner !== t || !K(n, e)) continue;
93
- const r = await S(n.id);
94
+ const r = await x(n.id);
94
95
  r && (await v(n.id), a = a.filter((o) => o.id !== n.id), d(), y(), l === t && R({ type: "expired", entry: r }));
95
96
  }
96
97
  });
97
98
  }
98
- async function it(t) {
99
+ async function st(t) {
99
100
  for (const e of await B()) e && e.owner !== t && await v(e.id);
100
101
  }
101
102
  async function $() {
@@ -112,9 +113,9 @@ async function $() {
112
113
  }
113
114
  l === t && (a = r, d(), o && await V());
114
115
  }
115
- function yt(t, e, n) {
116
+ function ht(t, e, n) {
116
117
  j = t, n && (w = n);
117
- const r = Q(e);
118
+ const r = tt(e);
118
119
  if (!(!r || r === l)) {
119
120
  if (l = r, a = [], d(), typeof BroadcastChannel < "u" && !h)
120
121
  try {
@@ -122,21 +123,21 @@ function yt(t, e, n) {
122
123
  } catch {
123
124
  h = null;
124
125
  }
125
- !A && typeof window < "u" && (A = !0, window.addEventListener("online", () => m(0))), it(r).then(() => (y(), $())).then(() => {
126
- a.some((o) => o.status === "queued") && m(1e3);
126
+ !A && typeof window < "u" && (A = !0, window.addEventListener("online", () => b(0))), st(r).then(() => (y(), $())).then(() => {
127
+ a.some((o) => o.status === "queued") && b(1e3);
127
128
  });
128
129
  }
129
130
  }
130
- function wt() {
131
+ function mt() {
131
132
  return a;
132
133
  }
133
- function ht(t) {
134
+ function bt(t) {
134
135
  return D.add(t), () => D.delete(t);
135
136
  }
136
- function bt(t) {
137
+ function pt(t) {
137
138
  return I.add(t), () => I.delete(t);
138
139
  }
139
- function mt(t) {
140
+ function Ot(t) {
140
141
  return N.add(t), () => N.delete(t);
141
142
  }
142
143
  function F(t) {
@@ -144,7 +145,7 @@ function F(t) {
144
145
  const e = t, n = (e == null ? void 0 : e.status) ?? ((r = e == null ? void 0 : e.response) == null ? void 0 : r.status);
145
146
  return n == null ? !(e != null && e.response) : n === 0 || n === 502 || n === 503 || n === 504;
146
147
  }
147
- function st(t) {
148
+ function at(t) {
148
149
  const e = t == null ? void 0 : t.response, n = (e == null ? void 0 : e.data) ?? e;
149
150
  return (n == null ? void 0 : n.code) !== "MIDAIR_COLLISION" || !Array.isArray(n.conflicts) ? null : { conflicts: n.conflicts, latest: Number(n.latest_revision) || 0 };
150
151
  }
@@ -157,13 +158,13 @@ function L(t, e) {
157
158
  return !1;
158
159
  }
159
160
  }
160
- async function pt(t) {
161
+ async function gt(t) {
161
162
  const e = l;
162
- if (!e || ot) return null;
163
+ if (!e || rt) return null;
163
164
  const n = {};
164
165
  for (const [f, Y] of Object.entries(t.payload)) f.startsWith("_") || (n[f] = Y);
165
166
  if (Object.keys(n).length === 0) return null;
166
- const r = p(e, t.collection, t.item), o = a.find((f) => f.id === r) ?? await S(r), i = (/* @__PURE__ */ new Date()).toISOString(), c = !o || Object.keys(o.payload).every((f) => f in n), s = c ? {} : { ...o.before };
167
+ const r = p(e, t.collection, t.item), o = a.find((f) => f.id === r) ?? await x(r), i = (/* @__PURE__ */ new Date()).toISOString(), c = !o || Object.keys(o.payload).every((f) => f in n), s = c ? {} : { ...o.before };
167
168
  for (const f of Object.keys(n))
168
169
  (c || !(f in s)) && (s[f] = t.before[f] ?? null);
169
170
  const u = (o == null ? void 0 : o.base_revision) ?? null, X = c ? t.baseRevision : u == null || t.baseRevision == null ? null : Math.min(u, t.baseRevision), q = W({
@@ -182,11 +183,11 @@ async function pt(t) {
182
183
  conflicts: null,
183
184
  latest_revision: null
184
185
  });
185
- return l !== e ? null : (a = [...a.filter((f) => f.id !== r), q], d(), await T(q), y(), m(P), q);
186
+ return l !== e ? null : (a = [...a.filter((f) => f.id !== r), q], d(), await T(q), y(), b(P), q);
186
187
  }
187
- async function Ot(t, e, n) {
188
+ async function vt(t, e, n) {
188
189
  if (!l) return;
189
- const r = p(l, t, e), o = a.find((s) => s.id === r) ?? await S(r);
190
+ const r = p(l, t, e), o = a.find((s) => s.id === r) ?? await x(r);
190
191
  if (!o || o.owner !== l) return;
191
192
  const i = new Set(n), c = {};
192
193
  for (const [s, u] of Object.entries(o.payload)) i.has(s) || (c[s] = u);
@@ -203,16 +204,16 @@ async function Ot(t, e, n) {
203
204
  }
204
205
  y();
205
206
  }
206
- async function gt(t, e) {
207
+ async function xt(t, e) {
207
208
  if (!l) return;
208
209
  const n = p(l, t, e);
209
210
  a = a.filter((r) => r.id !== n), d(), await v(n), y();
210
211
  }
211
- async function vt() {
212
- a = [], O.clear(), d(), await g("readwrite", (t) => t.clear()), y();
212
+ async function St() {
213
+ z(), a = [], O.clear(), d(), await g("readwrite", (t) => t.clear()), y();
213
214
  }
214
- async function b(t, e) {
215
- const n = a.find((o) => o.id === t) ?? await S(t);
215
+ async function m(t, e) {
216
+ const n = a.find((o) => o.id === t) ?? await x(t);
216
217
  if (!n) return null;
217
218
  const r = { ...n, ...e };
218
219
  return a = a.some((o) => o.id === t) ? a.map((o) => o.id === t ? r : o) : a, d(), await T(r), y(), r;
@@ -222,7 +223,7 @@ function M() {
222
223
  return (t == null ? void 0 : t.locks) ?? null;
223
224
  }
224
225
  const _ = /* @__PURE__ */ new Set();
225
- function St(t, e) {
226
+ function kt(t, e) {
226
227
  if (!l) return () => {
227
228
  };
228
229
  const n = p(l, t, e);
@@ -237,7 +238,7 @@ function St(t, e) {
237
238
  _.delete(n), r();
238
239
  };
239
240
  }
240
- async function at(t, e) {
241
+ async function ct(t, e) {
241
242
  if (_.has(t)) return;
242
243
  const n = M();
243
244
  if (!n) return e();
@@ -247,27 +248,27 @@ async function at(t, e) {
247
248
  });
248
249
  }
249
250
  let E = !1;
250
- function m(t) {
251
- k && clearTimeout(k), k = setTimeout(() => {
252
- k = null, lt();
251
+ function b(t) {
252
+ S && clearTimeout(S), S = setTimeout(() => {
253
+ S = null, ut();
253
254
  }, t);
254
255
  }
255
- async function ct(t, e) {
256
+ async function lt(t, e) {
256
257
  var n;
257
258
  try {
258
259
  const r = await t.request(C("/auth/me")), o = (n = r == null ? void 0 : r.data) == null ? void 0 : n.id;
259
- return !!o && String(o).toLowerCase() === tt(e).toLowerCase();
260
+ return !!o && String(o).toLowerCase() === et(e).toLowerCase();
260
261
  } catch (r) {
261
262
  return F(r) ? null : !1;
262
263
  }
263
264
  }
264
- async function lt() {
265
+ async function ut() {
265
266
  if (E || !j || !l || (await V(), !a.some((r) => r.status === "queued"))) return;
266
267
  E = !0;
267
268
  const t = j, e = l;
268
269
  let n = !1;
269
270
  try {
270
- const r = await ct(t, e);
271
+ const r = await lt(t, e);
271
272
  if (r === null) {
272
273
  n = !0;
273
274
  return;
@@ -277,20 +278,20 @@ async function lt() {
277
278
  const o = a.filter((i) => i.status === "queued" && !_.has(i.id));
278
279
  for (const i of o) {
279
280
  if (l !== e) return;
280
- if (await at(i.id, async () => {
281
- const c = await S(i.id);
281
+ if (await ct(i.id, async () => {
282
+ const c = await x(i.id);
282
283
  if (!c || c.owner !== e || c.status !== "queued") {
283
284
  await $();
284
285
  return;
285
286
  }
286
- await ft(t, c) === "offline" && (n = !0);
287
+ await dt(t, c) === "offline" && (n = !0);
287
288
  }), n) break;
288
289
  }
289
290
  } finally {
290
- E = !1, n && m(P);
291
+ E = !1, n && b(P);
291
292
  }
292
293
  }
293
- async function ut(t, e) {
294
+ async function ft(t, e) {
294
295
  const n = Object.keys(e.payload), r = await t.request(
295
296
  C(`/items/${e.collection}/${encodeURIComponent(e.item)}`, { fields: n.join(",") })
296
297
  ), o = (r == null ? void 0 : r.data) ?? {}, i = [];
@@ -306,25 +307,25 @@ async function ut(t, e) {
306
307
  });
307
308
  return { conflicts: i, latest: c == null ? null : Number(c) || null };
308
309
  }
309
- async function ft(t, e) {
310
+ async function dt(t, e) {
310
311
  var n, r;
311
- await b(e.id, { status: "sending" });
312
+ await m(e.id, { status: "sending" });
312
313
  try {
313
314
  let o = e.base_revision;
314
315
  if (o == null) {
315
- const c = await ut(t, e);
316
+ const c = await ft(t, e);
316
317
  if (c.conflicts.length > 0) return J(e, c.conflicts, c.latest ?? 0);
317
318
  o = c.latest;
318
319
  }
319
320
  const i = { ...e.payload };
320
- return o != null && (i._base_revision = o), e.change_reason && (i._change_reason = e.change_reason), await t.request(z(`/items/${e.collection}/${encodeURIComponent(e.item)}`, i)), U(e);
321
+ return o != null && (i._base_revision = o), e.change_reason && (i._change_reason = e.change_reason), await t.request(G(`/items/${e.collection}/${encodeURIComponent(e.item)}`, i)), U(e);
321
322
  } catch (o) {
322
323
  if (F(o))
323
- return await b(e.id, { status: "queued", error: "Waiting for a connection" }), "offline";
324
- const i = st(o);
324
+ return await m(e.id, { status: "queued", error: "Waiting for a connection" }), "offline";
325
+ const i = at(o);
325
326
  if (i)
326
327
  return i.conflicts.every((u) => L(u.current_value, e.payload[u.field])) ? U(e) : J(e, i.conflicts, i.latest);
327
- const c = ((n = o == null ? void 0 : o.response) == null ? void 0 : n.message) ?? ((r = o == null ? void 0 : o.response) == null ? void 0 : r.error) ?? (o instanceof Error ? o.message : "Could not save"), s = await b(e.id, { status: "failed", error: c });
328
+ const c = ((n = o == null ? void 0 : o.response) == null ? void 0 : n.message) ?? ((r = o == null ? void 0 : o.response) == null ? void 0 : r.error) ?? (o instanceof Error ? o.message : "Could not save"), s = await m(e.id, { status: "failed", error: c });
328
329
  return s && R({ type: "failed", entry: s }), "failed";
329
330
  }
330
331
  }
@@ -332,7 +333,7 @@ async function U(t) {
332
333
  return a = a.filter((e) => e.id !== t.id), d(), await v(t.id), y(), R({ type: "replayed", entry: t }), w == null || w.invalidateQueries({ queryKey: ["item", t.collection] }), w == null || w.invalidateQueries({ queryKey: ["collision-base", t.collection] }), "done";
333
334
  }
334
335
  async function J(t, e, n) {
335
- const r = await b(t.id, {
336
+ const r = await m(t.id, {
336
337
  status: "conflict",
337
338
  conflicts: W(e),
338
339
  latest_revision: n,
@@ -340,32 +341,32 @@ async function J(t, e, n) {
340
341
  });
341
342
  return r && R({ type: "conflict", entry: r }), "conflict";
342
343
  }
343
- async function kt(t, e) {
344
- l && (await b(p(l, t, e), {
344
+ async function _t(t, e) {
345
+ l && (await m(p(l, t, e), {
345
346
  status: "queued",
346
347
  error: null,
347
348
  conflicts: null
348
- }), m(0));
349
+ }), b(0));
349
350
  }
350
351
  export {
351
- Z as RECORD_OUTBOX_TTL_MS,
352
- yt as bindRecordOutbox,
353
- ut as checkUnknownBase,
354
- St as claimRecordOutbox,
355
- vt as clearRecordOutbox,
356
- gt as discardRecordOutbox,
357
- pt as enqueueRecordSave,
358
- wt as getRecordOutbox,
352
+ Q as RECORD_OUTBOX_TTL_MS,
353
+ ht as bindRecordOutbox,
354
+ ft as checkUnknownBase,
355
+ kt as claimRecordOutbox,
356
+ St as clearRecordOutbox,
357
+ xt as discardRecordOutbox,
358
+ gt as enqueueRecordSave,
359
+ mt as getRecordOutbox,
359
360
  F as isOfflineSaveError,
360
- st as midairCollisionOf,
361
- bt as onRecordOutboxEvent,
362
- mt as onRecordOutboxRetry,
361
+ at as midairCollisionOf,
362
+ pt as onRecordOutboxEvent,
363
+ Ot as onRecordOutboxRetry,
363
364
  p as outboxEntryId,
364
- Q as outboxOwner,
365
- lt as replayRecordOutbox,
366
- kt as retryRecordOutbox,
367
- m as scheduleReplay,
368
- Ot as settleRecordOutbox,
369
- ht as subscribeRecordOutbox,
365
+ tt as outboxOwner,
366
+ ut as replayRecordOutbox,
367
+ _t as retryRecordOutbox,
368
+ b as scheduleReplay,
369
+ vt as settleRecordOutbox,
370
+ bt as subscribeRecordOutbox,
370
371
  V as sweepExpiredRecordOutbox
371
372
  };
@@ -0,0 +1,93 @@
1
+ import { redactSecrets as S } from "./replay-context.js";
2
+ const g = 800, h = 10, m = 20, A = /* @__PURE__ */ new Set([
3
+ "nvr:ping",
4
+ "nvr:pong",
5
+ "time:sync",
6
+ "chat:typing",
7
+ "presence:update",
8
+ "catchup:cursor"
9
+ ]), f = /* @__PURE__ */ new Set(), p = (n, e) => S(String(n)).replace(/\s+/g, " ").slice(0, e);
10
+ function _(n) {
11
+ const e = Array.isArray(n) ? n : n == null ? [] : [n], t = [];
12
+ for (const r of e)
13
+ (typeof r == "string" || typeof r == "number") && t.push(p(r, 64));
14
+ return t;
15
+ }
16
+ function E(n) {
17
+ const e = {}, t = Array.isArray(n) ? n[0] : n;
18
+ if (!t || typeof t != "object") return e;
19
+ const r = [t.room, t.collection, t.topic].find((i) => typeof i == "string" && i);
20
+ r && (e.room = p(r, 80));
21
+ const c = _(t.ids ?? t.keys ?? t.id ?? t.item ?? t.item_id);
22
+ c.length && (e.ids = c.slice(0, h), c.length > h && (e.n = c.length));
23
+ const s = t.fields ?? t.field_names ?? t.changed;
24
+ if (Array.isArray(s)) {
25
+ const i = s.filter((o) => typeof o == "string").map((o) => p(o, 48)).slice(0, m);
26
+ i.length && (e.fields = i);
27
+ }
28
+ return e;
29
+ }
30
+ function C(n, e) {
31
+ if (!(f.size === 0 || !n || A.has(n)))
32
+ try {
33
+ const t = {
34
+ kind: "event",
35
+ name: p(n, 80),
36
+ ...E(e)
37
+ };
38
+ for (const r of f) r(t);
39
+ } catch {
40
+ }
41
+ }
42
+ function d(n, e) {
43
+ if (f.size !== 0)
44
+ try {
45
+ const t = { kind: "connection", name: n };
46
+ e && (t.detail = p(e, 80));
47
+ for (const r of f) r(t);
48
+ } catch {
49
+ }
50
+ }
51
+ function O(n) {
52
+ var i;
53
+ let e = 0;
54
+ const t = (o, ...l) => {
55
+ var a, u;
56
+ if (o === "catchup:full") d("full-resync");
57
+ else if (o === "catchup:events") {
58
+ const y = ((u = (a = l[0]) == null ? void 0 : a.events) == null ? void 0 : u.length) ?? 0;
59
+ d("catch-up", `${y} missed event${y === 1 ? "" : "s"} replayed`);
60
+ } else C(o, l[0]);
61
+ }, r = () => d(e++ > 0 ? "reconnected" : "connected"), c = (o) => d("disconnected", o), s = (o) => d("error", o == null ? void 0 : o.message);
62
+ return (i = n.onAny) == null || i.call(n, t), n.on("connect", r), n.on("disconnect", c), n.on("connect_error", s), () => {
63
+ var o, l, a, u;
64
+ (o = n.offAny) == null || o.call(n, t), (l = n.off) == null || l.call(n, "connect", r), (a = n.off) == null || a.call(n, "disconnect", c), (u = n.off) == null || u.call(n, "connect_error", s);
65
+ };
66
+ }
67
+ function T(n, e = g) {
68
+ let t = 0, r = !1;
69
+ const c = (s) => {
70
+ if (!(r || t > e))
71
+ try {
72
+ if (t === e) {
73
+ t++, n("socket", { kind: "truncated", name: "cap reached" });
74
+ return;
75
+ }
76
+ t++, n("socket", s);
77
+ } catch {
78
+ }
79
+ };
80
+ return f.add(c), () => {
81
+ r = !0, f.delete(c);
82
+ };
83
+ }
84
+ export {
85
+ g as SOCKET_MAX_EVENTS,
86
+ m as SOCKET_MAX_FIELDS,
87
+ h as SOCKET_MAX_IDS,
88
+ E as describeSocketPayload,
89
+ T as instrumentSocket,
90
+ d as reportSocketConnection,
91
+ C as reportSocketEvent,
92
+ O as tapReplaySocket
93
+ };