@nivaro/react 0.3.114 → 0.3.115

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 (281) hide show
  1. package/dist/components/ScreenShareHost.js +24 -0
  2. package/dist/full.css +50 -2
  3. package/dist/hooks/useSessionRecorder.js +61 -60
  4. package/dist/index.d.ts +1717 -21
  5. package/dist/index.js +1091 -950
  6. package/dist/shared/components/ActivityEntry.js +209 -97
  7. package/dist/shared/components/AgentPresenceChip.js +51 -0
  8. package/dist/shared/components/AnnouncementBanner.js +56 -41
  9. package/dist/shared/components/AutolinkedText.js +98 -85
  10. package/dist/shared/components/BroadcastView.js +149 -141
  11. package/dist/shared/components/CacheStamp.js +78 -30
  12. package/dist/shared/components/CollectionBrowserView.js +4088 -3592
  13. package/dist/shared/components/ConfigChangeStrip.js +63 -0
  14. package/dist/shared/components/ConfigReachNote.js +107 -0
  15. package/dist/shared/components/ConformanceView.js +389 -319
  16. package/dist/shared/components/DataTable.js +1 -0
  17. package/dist/shared/components/DelegateCoverLine.js +164 -0
  18. package/dist/shared/components/EnvironmentNotice.js +56 -65
  19. package/dist/shared/components/FilePreviewLightbox.js +89 -43
  20. package/dist/shared/components/FindingFixedMark.js +23 -0
  21. package/dist/shared/components/GridPresenceLine.js +100 -0
  22. package/dist/shared/components/IdleReloadWatcher.js +82 -43
  23. package/dist/shared/components/InStep.js +46 -0
  24. package/dist/shared/components/ItemEditForm.js +5504 -4889
  25. package/dist/shared/components/LiveAnnouncer.js +62 -0
  26. package/dist/shared/components/LiveCount.js +54 -0
  27. package/dist/shared/components/LiveFigure.js +28 -0
  28. package/dist/shared/components/LiveListControls.js +114 -0
  29. package/dist/shared/components/LiveNewMatchesPill.js +25 -0
  30. package/dist/shared/components/LiveOffNote.js +44 -0
  31. package/dist/shared/components/LivePreferenceHost.js +42 -0
  32. package/dist/shared/components/LiveRowMark.js +25 -20
  33. package/dist/shared/components/LiveTraceView.js +257 -0
  34. package/dist/shared/components/MapView.js +30 -29
  35. package/dist/shared/components/MatrixEditor.js +497 -462
  36. package/dist/shared/components/MyWorkView.js +346 -272
  37. package/dist/shared/components/NotificationBell.js +215 -201
  38. package/dist/shared/components/PageRenderer.js +636 -599
  39. package/dist/shared/components/PresenceDot.js +21 -0
  40. package/dist/shared/components/ProfileView.js +656 -536
  41. package/dist/shared/components/RealtimeStatusBanner.js +25 -25
  42. package/dist/shared/components/RecentRecordsRail.js +51 -48
  43. package/dist/shared/components/RecordCompare.js +241 -150
  44. package/dist/shared/components/RecordDrilldownSheet.js +66 -64
  45. package/dist/shared/components/RecordGridEditor.js +350 -311
  46. package/dist/shared/components/RecordHoverCard.js +147 -0
  47. package/dist/shared/components/RecordPeekHost.js +111 -0
  48. package/dist/shared/components/RecordReadView.js +414 -412
  49. package/dist/shared/components/RelativeTime.js +16 -0
  50. package/dist/shared/components/ReportView.js +1396 -1304
  51. package/dist/shared/components/ScreenRefreshButton.js +77 -0
  52. package/dist/shared/components/TabCountHost.js +10 -0
  53. package/dist/shared/components/TickerNumber.js +19 -18
  54. package/dist/shared/components/TipLayer.js +70 -58
  55. package/dist/shared/components/WidgetImageMenu.js +59 -0
  56. package/dist/shared/components/WidgetSlot.js +571 -524
  57. package/dist/shared/components/activity/RecordActivityStream.js +317 -0
  58. package/dist/shared/components/bulk/BulkSelectionNotices.js +220 -0
  59. package/dist/shared/components/cbv/approval-changed.js +20 -0
  60. package/dist/shared/components/cbv/changed-by-others.js +251 -0
  61. package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +320 -0
  62. package/dist/shared/components/change-proposals/ProposalValue.js +28 -0
  63. package/dist/shared/components/change-proposals/ProposeChangeButton.js +44 -0
  64. package/dist/shared/components/change-proposals/ProposeChangeDialog.js +359 -0
  65. package/dist/shared/components/change-proposals/types.js +4 -0
  66. package/dist/shared/components/chat/ChatPanel.js +1571 -1528
  67. package/dist/shared/components/chat/Composer.js +276 -298
  68. package/dist/shared/components/chat/room-due.js +13 -0
  69. package/dist/shared/components/collections-directory/CollectionRow.js +76 -75
  70. package/dist/shared/components/collections-directory/CollectionsDirectory.js +415 -395
  71. package/dist/shared/components/collections-directory/directory-data.js +75 -63
  72. package/dist/shared/components/imports/ImportConsole.js +159 -155
  73. package/dist/shared/components/imports/ImportDuplicatesNotice.js +46 -31
  74. package/dist/shared/components/integrations/SendStatus.js +202 -0
  75. package/dist/shared/components/integrations/console/IntegrationsConsole.js +45 -36
  76. package/dist/shared/components/integrations/console/ReadyToSendView.js +453 -0
  77. package/dist/shared/components/integrations/console/api.js +161 -117
  78. package/dist/shared/components/integrations/console/tone.js +15 -12
  79. package/dist/shared/components/item-edit/CatalogPickerField.js +1353 -1245
  80. package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +162 -0
  81. package/dist/shared/components/item-edit/CloneDialog.js +208 -206
  82. package/dist/shared/components/item-edit/DerivedCauseNote.js +57 -0
  83. package/dist/shared/components/item-edit/DraftRecoveryBanner.js +81 -70
  84. package/dist/shared/components/item-edit/DuplicateNotice.js +169 -101
  85. package/dist/shared/components/item-edit/FieldAffordances.js +294 -385
  86. package/dist/shared/components/item-edit/FieldComments.js +159 -116
  87. package/dist/shared/components/item-edit/FieldPointer.js +132 -0
  88. package/dist/shared/components/item-edit/FieldRenderer.js +277 -273
  89. package/dist/shared/components/item-edit/FieldRow.js +519 -439
  90. package/dist/shared/components/item-edit/FieldSourceBadge.js +88 -0
  91. package/dist/shared/components/item-edit/FilePickerField.js +454 -369
  92. package/dist/shared/components/item-edit/GroupSection.js +618 -567
  93. package/dist/shared/components/item-edit/HeldEditsChip.js +113 -0
  94. package/dist/shared/components/item-edit/InlineTableField.js +2891 -2723
  95. package/dist/shared/components/item-edit/ListNeighborNav.js +79 -0
  96. package/dist/shared/components/item-edit/LiveTraceSheet.js +26 -0
  97. package/dist/shared/components/item-edit/M2MCombobox.js +284 -273
  98. package/dist/shared/components/item-edit/OutboxReviewTray.js +313 -0
  99. package/dist/shared/components/item-edit/PickerBadges.js +52 -0
  100. package/dist/shared/components/item-edit/PlanGrid.js +434 -439
  101. package/dist/shared/components/item-edit/RecalcValue.js +55 -0
  102. package/dist/shared/components/item-edit/RecordChatActions.js +76 -64
  103. package/dist/shared/components/item-edit/RecordChatMentionsChip.js +103 -0
  104. package/dist/shared/components/item-edit/RecordGrantTools.js +87 -86
  105. package/dist/shared/components/item-edit/RecordHelpChip.js +70 -0
  106. package/dist/shared/components/item-edit/RecordLiveSync.js +230 -217
  107. package/dist/shared/components/item-edit/RecordOutbox.js +53 -52
  108. package/dist/shared/components/item-edit/RecordRecapStrip.js +109 -36
  109. package/dist/shared/components/item-edit/RelationCombobox.js +229 -217
  110. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +105 -100
  111. package/dist/shared/components/item-edit/RemoteChangeUi.js +454 -0
  112. package/dist/shared/components/item-edit/RemoteUploads.js +55 -0
  113. package/dist/shared/components/item-edit/RemovedLineNote.js +92 -0
  114. package/dist/shared/components/item-edit/RichTextEditorImpl.js +298 -223
  115. package/dist/shared/components/item-edit/ScheduledChangeChip.js +244 -0
  116. package/dist/shared/components/item-edit/SectionPresence.js +78 -0
  117. package/dist/shared/components/item-edit/SplitLinesButton.js +166 -0
  118. package/dist/shared/components/item-edit/catalog-line-watch.js +94 -0
  119. package/dist/shared/components/item-edit/coedit/collab.js +84 -0
  120. package/dist/shared/components/item-edit/coedit/context.js +24 -0
  121. package/dist/shared/components/item-edit/coedit/cursors.js +103 -0
  122. package/dist/shared/components/item-edit/coedit/safe-link.js +15 -0
  123. package/dist/shared/components/item-edit/coedit/session.js +382 -0
  124. package/dist/shared/components/item-edit/coedit/useCoedit.js +49 -0
  125. package/dist/shared/components/item-edit/file-live.js +77 -0
  126. package/dist/shared/components/item-edit/file-processing.js +87 -0
  127. package/dist/shared/components/item-edit/layout-switch.js +148 -0
  128. package/dist/shared/components/item-edit/live-related.js +23 -0
  129. package/dist/shared/components/item-edit/live-title.js +66 -0
  130. package/dist/shared/components/item-edit/partner-needs.js +142 -0
  131. package/dist/shared/components/item-edit/removed-line.js +58 -0
  132. package/dist/shared/components/item-edit/render-stability.js +70 -59
  133. package/dist/shared/components/layout-editor/ChangeNote.js +36 -34
  134. package/dist/shared/components/layout-editor/CollabParts.js +72 -70
  135. package/dist/shared/components/layout-editor/LayoutEditor.js +306 -303
  136. package/dist/shared/components/list/InlineEdit.js +504 -208
  137. package/dist/shared/components/list/ListViewers.js +81 -0
  138. package/dist/shared/components/merge/MergeRecordsDialog.js +1227 -0
  139. package/dist/shared/components/merge/MergeWithFlow.js +290 -0
  140. package/dist/shared/components/merge/merge-values.js +110 -0
  141. package/dist/shared/components/monitoring/InactiveUserLinksView.js +285 -258
  142. package/dist/shared/components/notifications/NotificationCenterView.js +388 -321
  143. package/dist/shared/components/notifications/NotificationDetailBits.js +205 -130
  144. package/dist/shared/components/notifications/NotificationRulesEditor.js +72 -52
  145. package/dist/shared/components/notifications/bundles.js +21 -19
  146. package/dist/shared/components/notifications/resolved-line.js +25 -0
  147. package/dist/shared/components/ops/OpsTasksView.js +45 -44
  148. package/dist/shared/components/panels/AccessGrantedNote.js +85 -0
  149. package/dist/shared/components/panels/AlertBanners.js +132 -0
  150. package/dist/shared/components/panels/AsyncUserPicker.js +54 -45
  151. package/dist/shared/components/panels/BranchLanes.js +82 -54
  152. package/dist/shared/components/panels/CommentAwareness.js +332 -0
  153. package/dist/shared/components/panels/CommentImages.js +219 -0
  154. package/dist/shared/components/panels/CommentPanel.js +649 -530
  155. package/dist/shared/components/panels/ExternalRequestsChip.js +98 -80
  156. package/dist/shared/components/panels/NewSinceChip.js +16 -0
  157. package/dist/shared/components/panels/OwnerOpenedLine.js +85 -0
  158. package/dist/shared/components/panels/PipelinePanel.js +1644 -1494
  159. package/dist/shared/components/panels/ResubmissionDiff.js +293 -0
  160. package/dist/shared/components/panels/SlaBreachBanner.js +30 -29
  161. package/dist/shared/components/panels/SlaClock.js +130 -99
  162. package/dist/shared/components/panels/TaskPanel.js +308 -287
  163. package/dist/shared/components/panels/unseen-move-check.js +101 -0
  164. package/dist/shared/components/pipeline/OwnerMatrix.js +80 -71
  165. package/dist/shared/components/pipeline/OwnerMatrixSheet.js +495 -0
  166. package/dist/shared/components/pipeline/PipelineEditorView.js +1855 -1771
  167. package/dist/shared/components/profile/AgentNameField.js +141 -0
  168. package/dist/shared/components/profile/AgentsPanel.js +55 -46
  169. package/dist/shared/components/profile/PersonAccess.js +398 -330
  170. package/dist/shared/components/profile/PersonAdminTools.js +127 -113
  171. package/dist/shared/components/profile/PersonProfile.js +81 -73
  172. package/dist/shared/components/profile/SignInTroubleshooter.js +361 -0
  173. package/dist/shared/components/queue/QueueBulkBar.js +101 -84
  174. package/dist/shared/components/queue/QueueItemSheet.js +66 -66
  175. package/dist/shared/components/queue/QueueTeamStrip.js +279 -0
  176. package/dist/shared/components/queue/QueueWorklist.js +1927 -1635
  177. package/dist/shared/components/send-view/SendViewButton.js +136 -0
  178. package/dist/shared/components/send-view/SentViewCards.js +147 -0
  179. package/dist/shared/components/support/ReportProblem.js +1 -0
  180. package/dist/shared/components/support/ScreenShare.js +554 -0
  181. package/dist/shared/components/support/SupportView.js +160 -129
  182. package/dist/shared/components/support/TicketDetailSheet.js +101 -89
  183. package/dist/shared/components/watch-list/WatchDock.js +1044 -0
  184. package/dist/shared/components/watch-list/WatchExtras.js +723 -0
  185. package/dist/shared/components/watch-list/WatchListButton.js +46 -0
  186. package/dist/shared/components/watch-list/WatchPinButton.js +67 -0
  187. package/dist/shared/components/watch-list/WatchRows.js +348 -0
  188. package/dist/shared/lib/activity-sentence.js +87 -75
  189. package/dist/shared/lib/agent-presence.js +46 -0
  190. package/dist/shared/lib/approval-progress.js +49 -0
  191. package/dist/shared/lib/attention-prefs.js +27 -0
  192. package/dist/shared/lib/cell-locks.js +56 -0
  193. package/dist/shared/lib/co-edit.js +166 -0
  194. package/dist/shared/lib/coedit-registry.js +44 -0
  195. package/dist/shared/lib/comment-awareness.js +124 -0
  196. package/dist/shared/lib/comment-images.js +45 -0
  197. package/dist/shared/lib/config-watch.js +94 -0
  198. package/dist/shared/lib/copy-rules.js +65 -0
  199. package/dist/shared/lib/count-step.js +30 -0
  200. package/dist/shared/lib/deadline-ticker.js +68 -0
  201. package/dist/shared/lib/derived-causes.js +115 -0
  202. package/dist/shared/lib/draft-store.js +114 -85
  203. package/dist/shared/lib/error-hints.js +1 -0
  204. package/dist/shared/lib/field-merge.js +126 -0
  205. package/dist/shared/lib/filter-sentence.js +10 -10
  206. package/dist/shared/lib/focus-mode.js +16 -12
  207. package/dist/shared/lib/grid-cursors.js +77 -0
  208. package/dist/shared/lib/grid-presence.js +182 -0
  209. package/dist/shared/lib/idle-reload.js +100 -73
  210. package/dist/shared/lib/in-step.js +45 -0
  211. package/dist/shared/lib/integration-chip.js +19 -18
  212. package/dist/shared/lib/line-locks.js +141 -0
  213. package/dist/shared/lib/line-split.js +41 -0
  214. package/dist/shared/lib/linked-changes.js +150 -0
  215. package/dist/shared/lib/list-return.js +231 -0
  216. package/dist/shared/lib/list-viewers.js +52 -0
  217. package/dist/shared/lib/live-announcer.js +86 -0
  218. package/dist/shared/lib/live-counts.js +85 -0
  219. package/dist/shared/lib/live-data-changed.js +108 -0
  220. package/dist/shared/lib/live-deltas.js +81 -0
  221. package/dist/shared/lib/live-findings.js +113 -0
  222. package/dist/shared/lib/live-groups.js +122 -0
  223. package/dist/shared/lib/live-link-labels.js +162 -0
  224. package/dist/shared/lib/live-list-flow.js +334 -0
  225. package/dist/shared/lib/live-list.js +143 -129
  226. package/dist/shared/lib/live-moves.js +51 -0
  227. package/dist/shared/lib/live-ops.js +26 -26
  228. package/dist/shared/lib/live-pickers.js +7 -0
  229. package/dist/shared/lib/live-preference.js +184 -0
  230. package/dist/shared/lib/live-queries.js +226 -181
  231. package/dist/shared/lib/live-screen.js +333 -0
  232. package/dist/shared/lib/live-search.js +108 -0
  233. package/dist/shared/lib/live-seen.js +35 -0
  234. package/dist/shared/lib/live-views.js +100 -0
  235. package/dist/shared/lib/live.js +159 -133
  236. package/dist/shared/lib/missed-updates.js +198 -0
  237. package/dist/shared/lib/newer-file.js +56 -0
  238. package/dist/shared/lib/notification-sound.js +42 -20
  239. package/dist/shared/lib/own-writes.js +59 -41
  240. package/dist/shared/lib/picker-badges.js +94 -0
  241. package/dist/shared/lib/presence-signals.js +131 -84
  242. package/dist/shared/lib/realtime.js +49 -24
  243. package/dist/shared/lib/record-gaps.js +85 -0
  244. package/dist/shared/lib/record-outbox.js +369 -222
  245. package/dist/shared/lib/record-peek.js +75 -0
  246. package/dist/shared/lib/record-tabs.js +92 -72
  247. package/dist/shared/lib/relative-ticker.js +42 -0
  248. package/dist/shared/lib/request-gate.js +119 -119
  249. package/dist/shared/lib/rollup-recalc.js +107 -0
  250. package/dist/shared/lib/room-gaps.js +40 -36
  251. package/dist/shared/lib/rum.js +137 -87
  252. package/dist/shared/lib/save-progress.js +20 -0
  253. package/dist/shared/lib/scheduled-countdown.js +67 -0
  254. package/dist/shared/lib/screen-refresh.js +160 -0
  255. package/dist/shared/lib/screen-share.js +234 -0
  256. package/dist/shared/lib/seen-since.js +74 -0
  257. package/dist/shared/lib/selection-watch.js +205 -0
  258. package/dist/shared/lib/send-status.js +132 -0
  259. package/dist/shared/lib/send-view.js +23 -0
  260. package/dist/shared/lib/socket-liveness.js +155 -0
  261. package/dist/shared/lib/socket-realtime.js +168 -140
  262. package/dist/shared/lib/state-census.js +53 -0
  263. package/dist/shared/lib/summary-mode.js +61 -39
  264. package/dist/shared/lib/tab-attention.js +143 -32
  265. package/dist/shared/lib/table-density.js +64 -0
  266. package/dist/shared/lib/track-travel.js +40 -0
  267. package/dist/shared/lib/unseen-changes.js +68 -0
  268. package/dist/shared/lib/upload-file.js +33 -0
  269. package/dist/shared/lib/upload-presence.js +127 -0
  270. package/dist/shared/lib/urgent-chime.js +65 -0
  271. package/dist/shared/lib/use-online-users.js +32 -11
  272. package/dist/shared/lib/user-sync.js +155 -39
  273. package/dist/shared/lib/waiting-count.js +44 -0
  274. package/dist/shared/lib/watch-desktop.js +83 -0
  275. package/dist/shared/lib/watch-list.js +447 -0
  276. package/dist/shared/lib/widget-image-render.js +64 -0
  277. package/dist/shared/lib/widget-image.js +111 -0
  278. package/dist/shared/lib/worker-socket.js +130 -104
  279. package/dist/shared/lib/write-to-screen.js +133 -0
  280. package/package.json +1 -1
  281. package/styles.css +49 -1
@@ -0,0 +1,155 @@
1
+ import { clientSocketGone as _ } from "./client-chaos.js";
2
+ const x = /* @__PURE__ */ new Set(["io client disconnect", "io server disconnect"]);
3
+ function K(e, i = {}) {
4
+ var N;
5
+ const r = i.now ?? Date.now, o = i.silenceMs ?? 4e4, l = i.probeTimeoutMs ?? 5e3, t = i.tickMs ?? 5e3, s = i.sleepGapMs ?? 75e3, d = i.wakeWindowMs ?? 15e3, G = i.repairWindowMs ?? 12e3, H = i.maxRepairs ?? 2, g = () => {
6
+ var n;
7
+ try {
8
+ return ((n = i.held) == null ? void 0 : n.call(i)) === !0;
9
+ } catch {
10
+ return !1;
11
+ }
12
+ };
13
+ let S = !1, h = !1, v = r(), R = r(), U = 0, M, p = !1, a = null, c = !1, w = 0, u = !1, m = null;
14
+ const T = /* @__PURE__ */ new Set(), f = { probes: 0, failedProbes: 0, repairs: 0, repaired: 0, gaveUp: 0 }, W = (n, L) => {
15
+ if (n !== c) {
16
+ c = n;
17
+ for (const P of [...T])
18
+ try {
19
+ P(n, L);
20
+ } catch {
21
+ }
22
+ }
23
+ }, y = () => {
24
+ m && clearTimeout(m), m = null;
25
+ }, O = () => {
26
+ u = !0, w = 0, y(), f.gaveUp++, W(!1, "gave-up");
27
+ }, b = () => {
28
+ if (!(u || g())) {
29
+ if (w >= H) {
30
+ O();
31
+ return;
32
+ }
33
+ w++, f.repairs++, W(!0), y(), m = setTimeout(() => {
34
+ m = null, c && b();
35
+ }, G);
36
+ try {
37
+ e.reconnect();
38
+ } catch {
39
+ }
40
+ }
41
+ }, E = () => {
42
+ if (p || c || u || g()) return;
43
+ p = !0, f.probes++;
44
+ let n = !1;
45
+ a = setTimeout(() => {
46
+ a = null, !n && (n = !0, p = !1, e.connected() && (f.failedProbes++, b()));
47
+ }, l);
48
+ try {
49
+ e.probe(() => {
50
+ n || (n = !0, p = !1, a && clearTimeout(a), a = null, v = r());
51
+ });
52
+ } catch {
53
+ }
54
+ }, I = () => {
55
+ if (U = r(), !(!S || u || c || g())) {
56
+ if (e.connected()) {
57
+ h && E();
58
+ return;
59
+ }
60
+ M && x.has(M) || b();
61
+ }
62
+ }, k = setInterval(() => A.tick(), t);
63
+ (N = k.unref) == null || N.call(k);
64
+ const A = {
65
+ heard() {
66
+ v = r();
67
+ },
68
+ up() {
69
+ S = !0, h = !0, v = r(), M = void 0, u = !1, c ? (f.repaired++, w = 0, y(), W(!1, "repaired")) : w = 0;
70
+ },
71
+ down(n) {
72
+ h = !1, M = n, a && clearTimeout(a), a = null, p = !1, !(c || !S || u || g()) && (n && x.has(n) || (n === "ping timeout" || r() - U <= d) && b());
73
+ },
74
+ wake() {
75
+ I();
76
+ },
77
+ tick() {
78
+ const n = r(), L = n - R;
79
+ if (R = n, L > s) {
80
+ I();
81
+ return;
82
+ }
83
+ h && e.connected() && n - v > o && E();
84
+ },
85
+ repairing: () => c,
86
+ onRepairing(n) {
87
+ return T.add(n), () => {
88
+ T.delete(n);
89
+ };
90
+ },
91
+ stats: () => ({ ...f }),
92
+ stop() {
93
+ clearInterval(k), y(), a && clearTimeout(a), a = null, T.clear();
94
+ }
95
+ };
96
+ return A;
97
+ }
98
+ const j = 3e4;
99
+ function q(e) {
100
+ if (typeof window > "u" || typeof document > "u") return () => {
101
+ };
102
+ const i = [], r = (t, s, d) => {
103
+ t && (t.addEventListener(s, d), i.push(() => t.removeEventListener(s, d)));
104
+ };
105
+ let o = document.visibilityState === "hidden" ? Date.now() : 0;
106
+ r(window, "online", () => e("online")), r(window, "pageshow", (t) => {
107
+ t != null && t.persisted && e("restored");
108
+ }), r(document, "resume", () => e("resumed")), r(document, "visibilitychange", () => {
109
+ if (document.visibilityState === "hidden") {
110
+ o = Date.now();
111
+ return;
112
+ }
113
+ const t = o ? Date.now() - o : 0;
114
+ o = 0, t >= j && e("visible");
115
+ });
116
+ const l = navigator.connection;
117
+ return r(l, "change", () => e("network")), () => {
118
+ for (const t of i) t();
119
+ };
120
+ }
121
+ const D = /* @__PURE__ */ new WeakMap();
122
+ function B(e) {
123
+ return e ? D.get(e) ?? null : null;
124
+ }
125
+ function C(e, i) {
126
+ D.set(e, i);
127
+ }
128
+ function F(e, i = {}) {
129
+ if (!e) return null;
130
+ const r = D.get(e);
131
+ if (r) return r;
132
+ const o = e.io;
133
+ if (!o || typeof o.on != "function") return null;
134
+ const l = o.on.bind(o), t = K(
135
+ {
136
+ connected: () => e.connected,
137
+ probe: (s) => {
138
+ (e.volatile ?? e).emit("time:sync", { c: Date.now() }, () => s());
139
+ },
140
+ reconnect: () => {
141
+ e.disconnect(), e.connect();
142
+ }
143
+ },
144
+ { held: _, ...i }
145
+ );
146
+ return l("ping", () => t.heard()), l("packet", () => t.heard()), e.on("auth:ok", () => t.up()), e.on("disconnect", (s) => t.down(s)), q((s) => t.wake(s)), D.set(e, t), t;
147
+ }
148
+ export {
149
+ j as HIDDEN_WAKE_MS,
150
+ F as attachSocketLiveness,
151
+ K as createLiveness,
152
+ B as livenessOf,
153
+ q as onWakeSignals,
154
+ C as registerLiveness
155
+ };
@@ -1,29 +1,31 @@
1
- var y = Object.defineProperty;
2
- var I = (i, n, r) => n in i ? y(i, n, { enumerable: !0, configurable: !0, writable: !0, value: r }) : i[n] = r;
3
- var N = (i, n, r) => I(i, typeof n != "symbol" ? n + "" : n, r);
4
- import { bindClientChaosSocket as J } from "./client-chaos.js";
5
- import { deliveryAckFor as O } from "./delivery-ack.js";
6
- import { forgetSettledReads as L } from "./request-gate.js";
7
- import { createRoomGapTracker as W, refetchEventsFor as $ } from "./room-gaps.js";
8
- const U = 3e3;
9
- function x(i = U) {
10
- const n = /* @__PURE__ */ new Map();
11
- return (r, d) => {
12
- var g;
13
- if (!(i > 0)) {
14
- d();
1
+ var k = Object.defineProperty;
2
+ var G = (l, o, n) => o in l ? k(l, o, { enumerable: !0, configurable: !0, writable: !0, value: n }) : l[o] = n;
3
+ var U = (l, o, n) => G(l, typeof o != "symbol" ? o + "" : o, n);
4
+ import { bindClientChaosSocket as $ } from "./client-chaos.js";
5
+ import { deliveryAckFor as x } from "./delivery-ack.js";
6
+ import { createRecordGapTracker as B, recordRefetchEvent as D } from "./record-gaps.js";
7
+ import { forgetSettledReads as W } from "./request-gate.js";
8
+ import { createRoomGapTracker as V, refetchEventsFor as z } from "./room-gaps.js";
9
+ import { livenessOf as H, attachSocketLiveness as K } from "./socket-liveness.js";
10
+ const I = 3e3;
11
+ function P(l = I) {
12
+ const o = /* @__PURE__ */ new Map();
13
+ return (n, m) => {
14
+ var w;
15
+ if (!(l > 0)) {
16
+ m();
15
17
  return;
16
18
  }
17
- const a = n.has(r);
18
- if (n.set(r, d), a) return;
19
- const l = setTimeout(
19
+ const u = o.has(n);
20
+ if (o.set(n, m), u) return;
21
+ const a = setTimeout(
20
22
  () => {
21
- const f = n.get(r);
22
- n.delete(r), f == null || f();
23
+ const d = o.get(n);
24
+ o.delete(n), d == null || d();
23
25
  },
24
- Math.floor(Math.random() * i)
26
+ Math.floor(Math.random() * l)
25
27
  );
26
- (g = l.unref) == null || g.call(l);
28
+ (w = a.unref) == null || w.call(a);
27
29
  };
28
30
  }
29
31
  const j = {
@@ -32,182 +34,208 @@ const j = {
32
34
  configUpdate: "nvr:config-update",
33
35
  forceRefresh: "nvr:force-refresh"
34
36
  };
35
- class C {
36
- constructor(n, r) {
37
- N(this, "refs", /* @__PURE__ */ new Map());
38
- this.join = n, this.leave = r;
37
+ class M {
38
+ constructor(o, n) {
39
+ U(this, "refs", /* @__PURE__ */ new Map());
40
+ this.join = o, this.leave = n;
39
41
  }
40
- add(n) {
41
- const r = this.refs.get(n) ?? 0;
42
- this.refs.set(n, r + 1), r === 0 && this.join(n);
42
+ add(o) {
43
+ const n = this.refs.get(o) ?? 0;
44
+ this.refs.set(o, n + 1), n === 0 && this.join(o);
43
45
  }
44
- remove(n) {
45
- const r = this.refs.get(n) ?? 0;
46
- r <= 0 || (r === 1 ? (this.refs.delete(n), this.leave(n)) : this.refs.set(n, r - 1));
46
+ remove(o) {
47
+ const n = this.refs.get(o) ?? 0;
48
+ n <= 0 || (n === 1 ? (this.refs.delete(o), this.leave(o)) : this.refs.set(o, n - 1));
47
49
  }
48
50
  rejoinAll() {
49
- for (const n of this.refs.keys()) this.join(n);
51
+ for (const o of this.refs.keys()) this.join(o);
50
52
  }
51
53
  keys() {
52
54
  return [...this.refs.keys()];
53
55
  }
54
56
  }
55
- function z(i) {
56
- let n = null, r = 0, d = !1, a = null, l = { state: "live", transport: null, refreshed: null, resumed: null };
57
- const g = /* @__PURE__ */ new Set(), f = (e) => {
58
- var o;
59
- return ((o = i.windowEvents) == null ? void 0 : o[e]) !== !1;
60
- }, b = x(i.reactionJitterMs ?? U), A = /* @__PURE__ */ new Set(), p = (e) => {
61
- const o = { ...l, ...e };
62
- if (!(o.state === l.state && o.transport === l.transport && o.refreshed === l.refreshed && o.resumed === l.resumed)) {
63
- l = o;
64
- for (const t of g) t(l);
57
+ function oe(l) {
58
+ let o = null, n = 0, m = !1, u = null, a = { state: "live", transport: null, refreshed: null, resumed: null };
59
+ const w = /* @__PURE__ */ new Set(), d = (e) => {
60
+ var t;
61
+ return ((t = l.windowEvents) == null ? void 0 : t[e]) !== !1;
62
+ }, L = P(l.reactionJitterMs ?? I), E = /* @__PURE__ */ new Set(), v = (e) => {
63
+ const t = { ...a, ...e };
64
+ if (!(t.state === a.state && t.transport === a.transport && t.refreshed === a.refreshed && t.resumed === a.resumed && (t.repair ?? null) === (a.repair ?? null))) {
65
+ a = t;
66
+ for (const s of w) s(a);
65
67
  }
66
68
  }, _ = () => {
67
- var e, o, t;
68
- return ((t = (o = (e = n == null ? void 0 : n.io) == null ? void 0 : e.engine) == null ? void 0 : o.transport) == null ? void 0 : t.name) ?? null;
69
- }, E = (e, o) => {
70
- a && clearTimeout(a), a = null, p({ state: "live", transport: _(), refreshed: e, resumed: o });
71
- }, h = (e, o) => {
72
- typeof window > "u" || window.dispatchEvent(new CustomEvent(e, { detail: o }));
73
- }, m = (e, o) => {
74
- n != null && n.connected && n.emit(e, o);
75
- }, F = (e, o) => {
76
- var t;
77
- for (const s of ((t = n == null ? void 0 : n.listeners) == null ? void 0 : t.call(n, e)) ?? []) s(o);
78
- }, M = (e) => {
79
- for (const o of $(e)) F(o.event, o.payload);
80
- h("nvr:realtime-stale", { rooms: e });
81
- }, w = W({
82
- request: (e) => m("catchup:room", e),
83
- dispatch: F,
84
- refetch: M
85
- }), R = new C(
69
+ var e, t, s;
70
+ return ((s = (t = (e = o == null ? void 0 : o.io) == null ? void 0 : e.engine) == null ? void 0 : t.transport) == null ? void 0 : s.name) ?? null;
71
+ };
72
+ let q = !1;
73
+ const N = () => {
74
+ q && (q = !1, v({ repair: null }));
75
+ }, C = (e, t) => {
76
+ u && clearTimeout(u), u = null, v({ state: "live", transport: _(), refreshed: e, resumed: t }), N();
77
+ }, g = (e, t) => {
78
+ typeof window > "u" || window.dispatchEvent(new CustomEvent(e, { detail: t }));
79
+ }, p = (e, t) => {
80
+ o != null && o.connected && o.emit(e, t);
81
+ }, F = (e, t) => {
82
+ var s;
83
+ for (const r of ((s = o == null ? void 0 : o.listeners) == null ? void 0 : s.call(o, e)) ?? []) r(t);
84
+ }, h = B({
85
+ refetch: (e) => {
86
+ for (const t of e) {
87
+ const s = D(t);
88
+ F(s.event, s.payload);
89
+ }
90
+ }
91
+ }), O = (e) => e.filter((t) => t.startsWith("collection:")).map((t) => t.slice(11)), y = (e) => {
92
+ h.forget(O(e));
93
+ for (const t of z(e)) F(t.event, t.payload);
94
+ g("nvr:realtime-stale", { rooms: e });
95
+ }, R = V({
96
+ request: (e) => p("catchup:room", e),
97
+ dispatch: (e, t) => {
98
+ h.observe(e, t), F(e, t);
99
+ },
100
+ refetch: y
101
+ }), S = new M(
86
102
  (e) => {
87
- w.reset([`collection:${e}`]), m("collection:join", { collection: e });
103
+ R.reset([`collection:${e}`]), h.forget([e]), p("collection:join", { collection: e });
88
104
  },
89
105
  (e) => {
90
- w.reset([`collection:${e}`]), m("collection:leave", { collection: e });
106
+ R.reset([`collection:${e}`]), h.forget([e]), p("collection:leave", { collection: e });
91
107
  }
92
- ), S = new C(
108
+ ), b = new M(
93
109
  // The Traffic Map page reads batched frames (api traffic-map-batch.ts); twin: admin
94
110
  // lib/socket.ts watchJoinPayload.
95
- (e) => m("admin:join", e === "traffic-map" ? { room: e, frames: "batch" } : { room: e }),
96
- (e) => m("admin:leave", { room: e })
97
- ), q = new C(
98
- (e) => m("ops:join", { topic: e }),
99
- (e) => m("ops:leave", { topic: e })
111
+ (e) => p("admin:join", e === "traffic-map" ? { room: e, frames: "batch" } : { room: e }),
112
+ (e) => p("admin:leave", { room: e })
113
+ ), A = new M(
114
+ (e) => p("ops:join", { topic: e }),
115
+ (e) => p("ops:leave", { topic: e })
100
116
  ), T = () => {
101
- var o;
102
- if (n) return n;
103
- const e = typeof i.socket == "function" ? i.socket() : i.socket;
104
- return n = e, J(e), d = e.connected, e.on("auth:ok", () => {
105
- if (w.reset(), R.rejoinAll(), S.rejoinAll(), q.rejoinAll(), d && r > 0) {
106
- const t = r;
107
- p({ transport: _() }), a && clearTimeout(a), a = setTimeout(() => E(null, "unverified"), i.catchupTimeoutMs ?? 8e3), e.emit("catchup", { cursor: t });
117
+ var s;
118
+ if (o) return o;
119
+ const e = typeof l.socket == "function" ? l.socket() : l.socket;
120
+ o = e, $(e);
121
+ const t = H(e) ?? K(e);
122
+ return t && (t.repairing() && (a = { ...a, repair: "silent" }), t.onRepairing((r, c) => {
123
+ q = !r && c === "repaired", q || v({ repair: r ? "silent" : null });
124
+ })), m = e.connected, e.on("auth:ok", () => {
125
+ if (R.reset(), S.rejoinAll(), b.rejoinAll(), A.rejoinAll(), m && n > 0) {
126
+ const r = n;
127
+ v({ transport: _() }), u && clearTimeout(u), u = setTimeout(() => C(null, "unverified"), l.catchupTimeoutMs ?? 8e3), e.emit("catchup", { cursor: r });
108
128
  } else
109
- p({
129
+ v({
110
130
  state: "live",
111
131
  transport: _(),
112
132
  refreshed: null,
113
- resumed: d && l.state === "reconnecting" ? "unverified" : null
114
- });
115
- d = !0;
116
- }), e.on("catchup:cursor", (t) => {
117
- r === 0 && typeof (t == null ? void 0 : t.seq) == "number" && t.seq > 0 && (r = t.seq);
133
+ resumed: m && a.state === "reconnecting" ? "unverified" : null
134
+ }), N();
135
+ m = !0;
136
+ }), e.on("catchup:cursor", (r) => {
137
+ n === 0 && typeof (r == null ? void 0 : r.seq) == "number" && r.seq > 0 && (n = r.seq);
118
138
  }), e.on("disconnect", () => {
119
- a && clearTimeout(a), a = null, p({ state: "reconnecting", refreshed: null });
120
- }), e.on("connect_error", () => p({ state: "reconnecting", refreshed: null })), (o = e.onAny) == null || o.call(e, (t, s) => {
121
- const c = s == null ? void 0 : s._seq;
122
- typeof c == "number" && c > r && (r = c), w.observe(s);
123
- const v = O(s);
124
- v && e.emit("rt:ack", v);
125
- }), e.on("catchup:room:events", (t) => w.replayed(t)), e.on("realtime:stale", (t) => {
126
- const s = Array.isArray(t == null ? void 0 : t.rooms) ? t.rooms.filter((c) => typeof c == "string") : [];
127
- w.reset(s), t != null && t.all ? (f("catchupFull") && h(j.catchupFull, {}), h("nvr:realtime-stale", { rooms: s, all: !0 })) : s.length && M(s);
139
+ u && clearTimeout(u), u = null;
140
+ const r = !!(t != null && t.repairing());
141
+ q = !1, v({ state: "reconnecting", refreshed: null, ...r ? {} : { repair: null } });
142
+ }), e.on("connect_error", () => v({ state: "reconnecting", refreshed: null })), (s = e.onAny) == null || s.call(e, (r, c) => {
143
+ const i = c == null ? void 0 : c._seq;
144
+ typeof i == "number" && i > n && (n = i), R.observe(c), h.observe(r, c);
145
+ const f = x(c);
146
+ f && e.emit("rt:ack", f);
147
+ }), e.on("catchup:room:events", (r) => R.replayed(r)), e.on("realtime:stale", (r) => {
148
+ const c = Array.isArray(r == null ? void 0 : r.rooms) ? r.rooms.filter((i) => typeof i == "string") : [];
149
+ R.reset(c), h.forget(r != null && r.all ? void 0 : O(c)), r != null && r.all ? (d("catchupFull") && g(j.catchupFull, {}), g("nvr:realtime-stale", { rooms: c, all: !0 })) : c.length && y(c);
128
150
  }), e.on(
129
151
  "catchup:events",
130
- (t) => {
131
- var s;
132
- for (const c of (t == null ? void 0 : t.events) ?? []) {
133
- c.seq > r && (r = c.seq);
134
- for (const v of ((s = e.listeners) == null ? void 0 : s.call(e, c.event)) ?? []) v({ ...c.payload, _seq: c.seq });
152
+ (r) => {
153
+ var c;
154
+ for (const i of (r == null ? void 0 : r.events) ?? []) {
155
+ i.seq > n && (n = i.seq);
156
+ const f = {
157
+ ...i.payload,
158
+ _seq: i.seq,
159
+ ...typeof i.iseq == "number" ? { _iseq: i.iseq } : {}
160
+ };
161
+ h.observe(i.event, f);
162
+ for (const J of ((c = e.listeners) == null ? void 0 : c.call(e, i.event)) ?? []) J(f);
135
163
  }
136
- E(null, "replayed");
164
+ C(null, "replayed");
137
165
  }
138
- ), e.on("catchup:full", (t) => {
139
- f("catchupFull") && b("full", () => h(j.catchupFull, {})), E(
140
- (t == null ? void 0 : t.reason) === "slow-consumer" ? "Live updates resumed. This tab fell too far behind to send each change, so the lists and records on this page were reloaded." : "Live updates resumed. The connection was gone too long to replay each change, so the lists and records on this page were reloaded.",
166
+ ), e.on("catchup:full", (r) => {
167
+ h.forget(), d("catchupFull") && L("full", () => g(j.catchupFull, {})), C(
168
+ (r == null ? void 0 : r.reason) === "slow-consumer" ? "Live updates resumed. This tab fell too far behind to send each change, so the lists and records on this page were reloaded." : "Live updates resumed. The connection was gone too long to replay each change, so the lists and records on this page were reloaded.",
141
169
  "reloaded"
142
170
  );
143
- }), e.on("access:changed", (t) => {
144
- var s;
145
- if (L(), (s = t == null ? void 0 : t.rooms_left) != null && s.length && f("accessChanged")) {
146
- for (const c of t.rooms_left) A.add(c);
147
- b("access", () => {
148
- const c = [...A];
149
- A.clear(), h(j.accessChanged, { rooms_left: c });
171
+ }), e.on("access:changed", (r) => {
172
+ var c;
173
+ if (W(), (c = r == null ? void 0 : r.rooms_left) != null && c.length && d("accessChanged")) {
174
+ for (const i of r.rooms_left) E.add(i);
175
+ L("access", () => {
176
+ const i = [...E];
177
+ E.clear(), g(j.accessChanged, { rooms_left: i });
150
178
  });
151
179
  }
152
- }), e.on("config:update", (t) => {
153
- L(), f("configUpdate") && h(j.configUpdate, t ?? {});
154
- }), e.on("client:force-refresh", (t) => {
155
- f("forceRefresh") && h(j.forceRefresh, t ?? {});
180
+ }), e.on("config:update", (r) => {
181
+ W(), d("configUpdate") && g(j.configUpdate, r ?? {});
182
+ }), e.on("client:force-refresh", (r) => {
183
+ d("forceRefresh") && g(j.forceRefresh, r ?? {});
156
184
  }), e;
157
185
  };
158
186
  return {
159
- subscribeCollections(e, o) {
160
- const t = T(), s = [...new Set(e.filter(Boolean))];
161
- for (const u of s) R.add(u);
162
- const c = (u) => {
163
- u != null && u.collection && s.includes(u.collection) && o(u);
187
+ subscribeCollections(e, t) {
188
+ const s = T(), r = [...new Set(e.filter(Boolean))];
189
+ for (const f of r) S.add(f);
190
+ const c = (f) => {
191
+ f != null && f.collection && r.includes(f.collection) && t(f);
164
192
  };
165
- t.on("collection:update", c);
166
- let v = !1;
193
+ s.on("collection:update", c);
194
+ let i = !1;
167
195
  return () => {
168
- if (!v) {
169
- v = !0, t.off("collection:update", c);
170
- for (const u of s) R.remove(u);
196
+ if (!i) {
197
+ i = !0, s.off("collection:update", c);
198
+ for (const f of r) S.remove(f);
171
199
  }
172
200
  };
173
201
  },
174
- on(e, o) {
175
- const t = T();
176
- return t.on(e, o), () => {
177
- t.off(e, o);
202
+ on(e, t) {
203
+ const s = T();
204
+ return s.on(e, t), () => {
205
+ s.off(e, t);
178
206
  };
179
207
  },
180
- emit(e, o) {
208
+ emit(e, t) {
181
209
  if (T(), e === "ops:join" || e === "ops:leave") {
182
- const t = String((o == null ? void 0 : o.topic) ?? "");
183
- if (!t) return;
184
- e === "ops:join" ? q.add(t) : q.remove(t);
210
+ const s = String((t == null ? void 0 : t.topic) ?? "");
211
+ if (!s) return;
212
+ e === "ops:join" ? A.add(s) : A.remove(s);
185
213
  return;
186
214
  }
187
- n == null || n.emit(e, o);
215
+ o == null || o.emit(e, t);
188
216
  },
189
217
  status() {
190
- return l;
218
+ return a;
191
219
  },
192
220
  onStatus(e) {
193
- return T(), g.add(e), () => {
194
- g.delete(e);
221
+ return T(), w.add(e), () => {
222
+ w.delete(e);
195
223
  };
196
224
  },
197
225
  joinWatch(e) {
198
- T(), S.add(e);
199
- let o = !1;
226
+ T(), b.add(e);
227
+ let t = !1;
200
228
  return () => {
201
- o || (o = !0, S.remove(e));
229
+ t || (t = !0, b.remove(e));
202
230
  };
203
231
  },
204
232
  held() {
205
- return { collections: R.keys(), watch: S.keys(), ops: q.keys() };
233
+ return { collections: S.keys(), watch: b.keys(), ops: A.keys() };
206
234
  }
207
235
  };
208
236
  }
209
237
  export {
210
- U as REACTION_JITTER_MS,
211
- x as createJitteredReaction,
212
- z as createSocketRealtime
238
+ I as REACTION_JITTER_MS,
239
+ P as createJitteredReaction,
240
+ oe as createSocketRealtime
213
241
  };
@@ -0,0 +1,53 @@
1
+ import { useQuery as l } from "@tanstack/react-query";
2
+ import { useMemo as a } from "react";
3
+ import { useNivaroClient as d } from "../context.js";
4
+ import { get as f } from "./commands.js";
5
+ import { liveQueryMeta as m } from "./live-queries.js";
6
+ const p = (t, n) => !!t && t.toUpperCase() === n.toUpperCase();
7
+ function h(t, n) {
8
+ const s = /* @__PURE__ */ new Map();
9
+ for (const e of n) {
10
+ const u = t.filter((o) => p(o.state_id, e)).map((o) => ({
11
+ collection: o.collection,
12
+ count: Number(o.count) || 0,
13
+ oldestAt: o.oldest_at ?? null
14
+ })).sort((o, c) => c.count - o.count);
15
+ let r = null;
16
+ for (const o of u)
17
+ o.oldestAt && (!r || Date.parse(o.oldestAt) < Date.parse(r)) && (r = o.oldestAt);
18
+ s.set(e, {
19
+ count: u.reduce((o, c) => o + c.count, 0),
20
+ oldestAt: r,
21
+ byCollection: u
22
+ });
23
+ }
24
+ return s;
25
+ }
26
+ function A(t, n = Date.now()) {
27
+ if (!t) return null;
28
+ const s = Date.parse(t);
29
+ if (!Number.isFinite(s)) return null;
30
+ const e = Math.floor(Math.max(0, n - s) / 864e5);
31
+ return e < 1 ? "oldest today" : e > 365 ? `oldest ${(e / 365.25).toFixed(1)} yr` : e > 60 ? `oldest ${Math.round(e / 30.4)} mo` : `oldest ${e} d`;
32
+ }
33
+ function D(t, n) {
34
+ return `/collections/${encodeURIComponent(t)}?state=${encodeURIComponent(n)}`;
35
+ }
36
+ function U(t, n) {
37
+ const s = d(), e = [...new Set(n)].sort().join("|"), i = a(() => e ? e.split("|") : [], [e]);
38
+ return l({
39
+ queryKey: ["instance-distribution", t],
40
+ enabled: !!t,
41
+ queryFn: () => s.request(f(`/pipelines/${t}/instance-distribution`)),
42
+ staleTime: 3e4,
43
+ // A move says `$state` on its record; creates and deletes always count; a plain column edit
44
+ // does not (fields: []), so typing in a record never re-counts the pipeline.
45
+ meta: i.length ? m({ reads: i, fields: [], aspects: ["$state"], minGapMs: 15e3 }) : void 0
46
+ });
47
+ }
48
+ export {
49
+ h as censusByState,
50
+ A as oldestHint,
51
+ D as stateListPath,
52
+ U as useStateCensus
53
+ };