@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.
- package/dist/components/ScreenShareHost.js +24 -0
- package/dist/full.css +50 -2
- package/dist/hooks/useSessionRecorder.js +61 -60
- package/dist/index.d.ts +1717 -21
- package/dist/index.js +1091 -950
- package/dist/shared/components/ActivityEntry.js +209 -97
- package/dist/shared/components/AgentPresenceChip.js +51 -0
- package/dist/shared/components/AnnouncementBanner.js +56 -41
- package/dist/shared/components/AutolinkedText.js +98 -85
- package/dist/shared/components/BroadcastView.js +149 -141
- package/dist/shared/components/CacheStamp.js +78 -30
- package/dist/shared/components/CollectionBrowserView.js +4088 -3592
- package/dist/shared/components/ConfigChangeStrip.js +63 -0
- package/dist/shared/components/ConfigReachNote.js +107 -0
- package/dist/shared/components/ConformanceView.js +389 -319
- package/dist/shared/components/DataTable.js +1 -0
- package/dist/shared/components/DelegateCoverLine.js +164 -0
- package/dist/shared/components/EnvironmentNotice.js +56 -65
- package/dist/shared/components/FilePreviewLightbox.js +89 -43
- package/dist/shared/components/FindingFixedMark.js +23 -0
- package/dist/shared/components/GridPresenceLine.js +100 -0
- package/dist/shared/components/IdleReloadWatcher.js +82 -43
- package/dist/shared/components/InStep.js +46 -0
- package/dist/shared/components/ItemEditForm.js +5504 -4889
- package/dist/shared/components/LiveAnnouncer.js +62 -0
- package/dist/shared/components/LiveCount.js +54 -0
- package/dist/shared/components/LiveFigure.js +28 -0
- package/dist/shared/components/LiveListControls.js +114 -0
- package/dist/shared/components/LiveNewMatchesPill.js +25 -0
- package/dist/shared/components/LiveOffNote.js +44 -0
- package/dist/shared/components/LivePreferenceHost.js +42 -0
- package/dist/shared/components/LiveRowMark.js +25 -20
- package/dist/shared/components/LiveTraceView.js +257 -0
- package/dist/shared/components/MapView.js +30 -29
- package/dist/shared/components/MatrixEditor.js +497 -462
- package/dist/shared/components/MyWorkView.js +346 -272
- package/dist/shared/components/NotificationBell.js +215 -201
- package/dist/shared/components/PageRenderer.js +636 -599
- package/dist/shared/components/PresenceDot.js +21 -0
- package/dist/shared/components/ProfileView.js +656 -536
- package/dist/shared/components/RealtimeStatusBanner.js +25 -25
- package/dist/shared/components/RecentRecordsRail.js +51 -48
- package/dist/shared/components/RecordCompare.js +241 -150
- package/dist/shared/components/RecordDrilldownSheet.js +66 -64
- package/dist/shared/components/RecordGridEditor.js +350 -311
- package/dist/shared/components/RecordHoverCard.js +147 -0
- package/dist/shared/components/RecordPeekHost.js +111 -0
- package/dist/shared/components/RecordReadView.js +414 -412
- package/dist/shared/components/RelativeTime.js +16 -0
- package/dist/shared/components/ReportView.js +1396 -1304
- package/dist/shared/components/ScreenRefreshButton.js +77 -0
- package/dist/shared/components/TabCountHost.js +10 -0
- package/dist/shared/components/TickerNumber.js +19 -18
- package/dist/shared/components/TipLayer.js +70 -58
- package/dist/shared/components/WidgetImageMenu.js +59 -0
- package/dist/shared/components/WidgetSlot.js +571 -524
- package/dist/shared/components/activity/RecordActivityStream.js +317 -0
- package/dist/shared/components/bulk/BulkSelectionNotices.js +220 -0
- package/dist/shared/components/cbv/approval-changed.js +20 -0
- package/dist/shared/components/cbv/changed-by-others.js +251 -0
- package/dist/shared/components/change-proposals/ChangeProposalsPanel.js +320 -0
- package/dist/shared/components/change-proposals/ProposalValue.js +28 -0
- package/dist/shared/components/change-proposals/ProposeChangeButton.js +44 -0
- package/dist/shared/components/change-proposals/ProposeChangeDialog.js +359 -0
- package/dist/shared/components/change-proposals/types.js +4 -0
- package/dist/shared/components/chat/ChatPanel.js +1571 -1528
- package/dist/shared/components/chat/Composer.js +276 -298
- package/dist/shared/components/chat/room-due.js +13 -0
- package/dist/shared/components/collections-directory/CollectionRow.js +76 -75
- package/dist/shared/components/collections-directory/CollectionsDirectory.js +415 -395
- package/dist/shared/components/collections-directory/directory-data.js +75 -63
- package/dist/shared/components/imports/ImportConsole.js +159 -155
- package/dist/shared/components/imports/ImportDuplicatesNotice.js +46 -31
- package/dist/shared/components/integrations/SendStatus.js +202 -0
- package/dist/shared/components/integrations/console/IntegrationsConsole.js +45 -36
- package/dist/shared/components/integrations/console/ReadyToSendView.js +453 -0
- package/dist/shared/components/integrations/console/api.js +161 -117
- package/dist/shared/components/integrations/console/tone.js +15 -12
- package/dist/shared/components/item-edit/CatalogPickerField.js +1353 -1245
- package/dist/shared/components/item-edit/ChangedAfterApprovalBadge.js +162 -0
- package/dist/shared/components/item-edit/CloneDialog.js +208 -206
- package/dist/shared/components/item-edit/DerivedCauseNote.js +57 -0
- package/dist/shared/components/item-edit/DraftRecoveryBanner.js +81 -70
- package/dist/shared/components/item-edit/DuplicateNotice.js +169 -101
- package/dist/shared/components/item-edit/FieldAffordances.js +294 -385
- package/dist/shared/components/item-edit/FieldComments.js +159 -116
- package/dist/shared/components/item-edit/FieldPointer.js +132 -0
- package/dist/shared/components/item-edit/FieldRenderer.js +277 -273
- package/dist/shared/components/item-edit/FieldRow.js +519 -439
- package/dist/shared/components/item-edit/FieldSourceBadge.js +88 -0
- package/dist/shared/components/item-edit/FilePickerField.js +454 -369
- package/dist/shared/components/item-edit/GroupSection.js +618 -567
- package/dist/shared/components/item-edit/HeldEditsChip.js +113 -0
- package/dist/shared/components/item-edit/InlineTableField.js +2891 -2723
- package/dist/shared/components/item-edit/ListNeighborNav.js +79 -0
- package/dist/shared/components/item-edit/LiveTraceSheet.js +26 -0
- package/dist/shared/components/item-edit/M2MCombobox.js +284 -273
- package/dist/shared/components/item-edit/OutboxReviewTray.js +313 -0
- package/dist/shared/components/item-edit/PickerBadges.js +52 -0
- package/dist/shared/components/item-edit/PlanGrid.js +434 -439
- package/dist/shared/components/item-edit/RecalcValue.js +55 -0
- package/dist/shared/components/item-edit/RecordChatActions.js +76 -64
- package/dist/shared/components/item-edit/RecordChatMentionsChip.js +103 -0
- package/dist/shared/components/item-edit/RecordGrantTools.js +87 -86
- package/dist/shared/components/item-edit/RecordHelpChip.js +70 -0
- package/dist/shared/components/item-edit/RecordLiveSync.js +230 -217
- package/dist/shared/components/item-edit/RecordOutbox.js +53 -52
- package/dist/shared/components/item-edit/RecordRecapStrip.js +109 -36
- package/dist/shared/components/item-edit/RelationCombobox.js +229 -217
- package/dist/shared/components/item-edit/RelationGroupedCombobox.js +105 -100
- package/dist/shared/components/item-edit/RemoteChangeUi.js +454 -0
- package/dist/shared/components/item-edit/RemoteUploads.js +55 -0
- package/dist/shared/components/item-edit/RemovedLineNote.js +92 -0
- package/dist/shared/components/item-edit/RichTextEditorImpl.js +298 -223
- package/dist/shared/components/item-edit/ScheduledChangeChip.js +244 -0
- package/dist/shared/components/item-edit/SectionPresence.js +78 -0
- package/dist/shared/components/item-edit/SplitLinesButton.js +166 -0
- package/dist/shared/components/item-edit/catalog-line-watch.js +94 -0
- package/dist/shared/components/item-edit/coedit/collab.js +84 -0
- package/dist/shared/components/item-edit/coedit/context.js +24 -0
- package/dist/shared/components/item-edit/coedit/cursors.js +103 -0
- package/dist/shared/components/item-edit/coedit/safe-link.js +15 -0
- package/dist/shared/components/item-edit/coedit/session.js +382 -0
- package/dist/shared/components/item-edit/coedit/useCoedit.js +49 -0
- package/dist/shared/components/item-edit/file-live.js +77 -0
- package/dist/shared/components/item-edit/file-processing.js +87 -0
- package/dist/shared/components/item-edit/layout-switch.js +148 -0
- package/dist/shared/components/item-edit/live-related.js +23 -0
- package/dist/shared/components/item-edit/live-title.js +66 -0
- package/dist/shared/components/item-edit/partner-needs.js +142 -0
- package/dist/shared/components/item-edit/removed-line.js +58 -0
- package/dist/shared/components/item-edit/render-stability.js +70 -59
- package/dist/shared/components/layout-editor/ChangeNote.js +36 -34
- package/dist/shared/components/layout-editor/CollabParts.js +72 -70
- package/dist/shared/components/layout-editor/LayoutEditor.js +306 -303
- package/dist/shared/components/list/InlineEdit.js +504 -208
- package/dist/shared/components/list/ListViewers.js +81 -0
- package/dist/shared/components/merge/MergeRecordsDialog.js +1227 -0
- package/dist/shared/components/merge/MergeWithFlow.js +290 -0
- package/dist/shared/components/merge/merge-values.js +110 -0
- package/dist/shared/components/monitoring/InactiveUserLinksView.js +285 -258
- package/dist/shared/components/notifications/NotificationCenterView.js +388 -321
- package/dist/shared/components/notifications/NotificationDetailBits.js +205 -130
- package/dist/shared/components/notifications/NotificationRulesEditor.js +72 -52
- package/dist/shared/components/notifications/bundles.js +21 -19
- package/dist/shared/components/notifications/resolved-line.js +25 -0
- package/dist/shared/components/ops/OpsTasksView.js +45 -44
- package/dist/shared/components/panels/AccessGrantedNote.js +85 -0
- package/dist/shared/components/panels/AlertBanners.js +132 -0
- package/dist/shared/components/panels/AsyncUserPicker.js +54 -45
- package/dist/shared/components/panels/BranchLanes.js +82 -54
- package/dist/shared/components/panels/CommentAwareness.js +332 -0
- package/dist/shared/components/panels/CommentImages.js +219 -0
- package/dist/shared/components/panels/CommentPanel.js +649 -530
- package/dist/shared/components/panels/ExternalRequestsChip.js +98 -80
- package/dist/shared/components/panels/NewSinceChip.js +16 -0
- package/dist/shared/components/panels/OwnerOpenedLine.js +85 -0
- package/dist/shared/components/panels/PipelinePanel.js +1644 -1494
- package/dist/shared/components/panels/ResubmissionDiff.js +293 -0
- package/dist/shared/components/panels/SlaBreachBanner.js +30 -29
- package/dist/shared/components/panels/SlaClock.js +130 -99
- package/dist/shared/components/panels/TaskPanel.js +308 -287
- package/dist/shared/components/panels/unseen-move-check.js +101 -0
- package/dist/shared/components/pipeline/OwnerMatrix.js +80 -71
- package/dist/shared/components/pipeline/OwnerMatrixSheet.js +495 -0
- package/dist/shared/components/pipeline/PipelineEditorView.js +1855 -1771
- package/dist/shared/components/profile/AgentNameField.js +141 -0
- package/dist/shared/components/profile/AgentsPanel.js +55 -46
- package/dist/shared/components/profile/PersonAccess.js +398 -330
- package/dist/shared/components/profile/PersonAdminTools.js +127 -113
- package/dist/shared/components/profile/PersonProfile.js +81 -73
- package/dist/shared/components/profile/SignInTroubleshooter.js +361 -0
- package/dist/shared/components/queue/QueueBulkBar.js +101 -84
- package/dist/shared/components/queue/QueueItemSheet.js +66 -66
- package/dist/shared/components/queue/QueueTeamStrip.js +279 -0
- package/dist/shared/components/queue/QueueWorklist.js +1927 -1635
- package/dist/shared/components/send-view/SendViewButton.js +136 -0
- package/dist/shared/components/send-view/SentViewCards.js +147 -0
- package/dist/shared/components/support/ReportProblem.js +1 -0
- package/dist/shared/components/support/ScreenShare.js +554 -0
- package/dist/shared/components/support/SupportView.js +160 -129
- package/dist/shared/components/support/TicketDetailSheet.js +101 -89
- package/dist/shared/components/watch-list/WatchDock.js +1044 -0
- package/dist/shared/components/watch-list/WatchExtras.js +723 -0
- package/dist/shared/components/watch-list/WatchListButton.js +46 -0
- package/dist/shared/components/watch-list/WatchPinButton.js +67 -0
- package/dist/shared/components/watch-list/WatchRows.js +348 -0
- package/dist/shared/lib/activity-sentence.js +87 -75
- package/dist/shared/lib/agent-presence.js +46 -0
- package/dist/shared/lib/approval-progress.js +49 -0
- package/dist/shared/lib/attention-prefs.js +27 -0
- package/dist/shared/lib/cell-locks.js +56 -0
- package/dist/shared/lib/co-edit.js +166 -0
- package/dist/shared/lib/coedit-registry.js +44 -0
- package/dist/shared/lib/comment-awareness.js +124 -0
- package/dist/shared/lib/comment-images.js +45 -0
- package/dist/shared/lib/config-watch.js +94 -0
- package/dist/shared/lib/copy-rules.js +65 -0
- package/dist/shared/lib/count-step.js +30 -0
- package/dist/shared/lib/deadline-ticker.js +68 -0
- package/dist/shared/lib/derived-causes.js +115 -0
- package/dist/shared/lib/draft-store.js +114 -85
- package/dist/shared/lib/error-hints.js +1 -0
- package/dist/shared/lib/field-merge.js +126 -0
- package/dist/shared/lib/filter-sentence.js +10 -10
- package/dist/shared/lib/focus-mode.js +16 -12
- package/dist/shared/lib/grid-cursors.js +77 -0
- package/dist/shared/lib/grid-presence.js +182 -0
- package/dist/shared/lib/idle-reload.js +100 -73
- package/dist/shared/lib/in-step.js +45 -0
- package/dist/shared/lib/integration-chip.js +19 -18
- package/dist/shared/lib/line-locks.js +141 -0
- package/dist/shared/lib/line-split.js +41 -0
- package/dist/shared/lib/linked-changes.js +150 -0
- package/dist/shared/lib/list-return.js +231 -0
- package/dist/shared/lib/list-viewers.js +52 -0
- package/dist/shared/lib/live-announcer.js +86 -0
- package/dist/shared/lib/live-counts.js +85 -0
- package/dist/shared/lib/live-data-changed.js +108 -0
- package/dist/shared/lib/live-deltas.js +81 -0
- package/dist/shared/lib/live-findings.js +113 -0
- package/dist/shared/lib/live-groups.js +122 -0
- package/dist/shared/lib/live-link-labels.js +162 -0
- package/dist/shared/lib/live-list-flow.js +334 -0
- package/dist/shared/lib/live-list.js +143 -129
- package/dist/shared/lib/live-moves.js +51 -0
- package/dist/shared/lib/live-ops.js +26 -26
- package/dist/shared/lib/live-pickers.js +7 -0
- package/dist/shared/lib/live-preference.js +184 -0
- package/dist/shared/lib/live-queries.js +226 -181
- package/dist/shared/lib/live-screen.js +333 -0
- package/dist/shared/lib/live-search.js +108 -0
- package/dist/shared/lib/live-seen.js +35 -0
- package/dist/shared/lib/live-views.js +100 -0
- package/dist/shared/lib/live.js +159 -133
- package/dist/shared/lib/missed-updates.js +198 -0
- package/dist/shared/lib/newer-file.js +56 -0
- package/dist/shared/lib/notification-sound.js +42 -20
- package/dist/shared/lib/own-writes.js +59 -41
- package/dist/shared/lib/picker-badges.js +94 -0
- package/dist/shared/lib/presence-signals.js +131 -84
- package/dist/shared/lib/realtime.js +49 -24
- package/dist/shared/lib/record-gaps.js +85 -0
- package/dist/shared/lib/record-outbox.js +369 -222
- package/dist/shared/lib/record-peek.js +75 -0
- package/dist/shared/lib/record-tabs.js +92 -72
- package/dist/shared/lib/relative-ticker.js +42 -0
- package/dist/shared/lib/request-gate.js +119 -119
- package/dist/shared/lib/rollup-recalc.js +107 -0
- package/dist/shared/lib/room-gaps.js +40 -36
- package/dist/shared/lib/rum.js +137 -87
- package/dist/shared/lib/save-progress.js +20 -0
- package/dist/shared/lib/scheduled-countdown.js +67 -0
- package/dist/shared/lib/screen-refresh.js +160 -0
- package/dist/shared/lib/screen-share.js +234 -0
- package/dist/shared/lib/seen-since.js +74 -0
- package/dist/shared/lib/selection-watch.js +205 -0
- package/dist/shared/lib/send-status.js +132 -0
- package/dist/shared/lib/send-view.js +23 -0
- package/dist/shared/lib/socket-liveness.js +155 -0
- package/dist/shared/lib/socket-realtime.js +168 -140
- package/dist/shared/lib/state-census.js +53 -0
- package/dist/shared/lib/summary-mode.js +61 -39
- package/dist/shared/lib/tab-attention.js +143 -32
- package/dist/shared/lib/table-density.js +64 -0
- package/dist/shared/lib/track-travel.js +40 -0
- package/dist/shared/lib/unseen-changes.js +68 -0
- package/dist/shared/lib/upload-file.js +33 -0
- package/dist/shared/lib/upload-presence.js +127 -0
- package/dist/shared/lib/urgent-chime.js +65 -0
- package/dist/shared/lib/use-online-users.js +32 -11
- package/dist/shared/lib/user-sync.js +155 -39
- package/dist/shared/lib/waiting-count.js +44 -0
- package/dist/shared/lib/watch-desktop.js +83 -0
- package/dist/shared/lib/watch-list.js +447 -0
- package/dist/shared/lib/widget-image-render.js +64 -0
- package/dist/shared/lib/widget-image.js +111 -0
- package/dist/shared/lib/worker-socket.js +130 -104
- package/dist/shared/lib/write-to-screen.js +133 -0
- package/package.json +1 -1
- package/styles.css +49 -1
|
@@ -1,156 +1,156 @@
|
|
|
1
|
-
import { clearChatOutbox as
|
|
2
|
-
import { get as
|
|
3
|
-
import { userErrorMessage as
|
|
4
|
-
const
|
|
5
|
-
function
|
|
1
|
+
import { clearChatOutbox as rt } from "../components/chat/chat-outbox.js";
|
|
2
|
+
import { get as v, patch as z } from "./commands.js";
|
|
3
|
+
import { userErrorMessage as st } from "./safe-error.js";
|
|
4
|
+
const at = "nivaro-record-outbox", I = "entries", lt = 1, ct = 10080 * 60 * 1e3, G = 8e3;
|
|
5
|
+
function ut(t) {
|
|
6
6
|
return t ? `${typeof location < "u" ? location.host : ""}|${t}` : null;
|
|
7
7
|
}
|
|
8
|
-
function
|
|
8
|
+
function ft(t) {
|
|
9
9
|
return t.slice(t.lastIndexOf("|") + 1);
|
|
10
10
|
}
|
|
11
|
-
function
|
|
11
|
+
function _(t, e, n) {
|
|
12
12
|
return `${t}|${e}|${String(n)}`;
|
|
13
13
|
}
|
|
14
|
-
let
|
|
15
|
-
const
|
|
16
|
-
function
|
|
14
|
+
let dt = !1;
|
|
15
|
+
const C = /* @__PURE__ */ new Map();
|
|
16
|
+
function yt() {
|
|
17
17
|
return new Promise((t) => {
|
|
18
18
|
try {
|
|
19
|
-
if (
|
|
20
|
-
const e = indexedDB.open(
|
|
19
|
+
if (dt || typeof indexedDB > "u") return t(null);
|
|
20
|
+
const e = indexedDB.open(at, lt);
|
|
21
21
|
e.onupgradeneeded = () => {
|
|
22
22
|
const n = e.result;
|
|
23
|
-
n.objectStoreNames.contains(
|
|
23
|
+
n.objectStoreNames.contains(I) || n.createObjectStore(I, { keyPath: "id" });
|
|
24
24
|
}, e.onsuccess = () => t(e.result), e.onerror = () => t(null), e.onblocked = () => t(null);
|
|
25
25
|
} catch {
|
|
26
26
|
t(null);
|
|
27
27
|
}
|
|
28
28
|
});
|
|
29
29
|
}
|
|
30
|
-
async function
|
|
31
|
-
const n = await
|
|
32
|
-
return n ? new Promise((
|
|
30
|
+
async function j(t, e) {
|
|
31
|
+
const n = await yt();
|
|
32
|
+
return n ? new Promise((o) => {
|
|
33
33
|
try {
|
|
34
|
-
const
|
|
35
|
-
|
|
36
|
-
n.close(),
|
|
34
|
+
const i = n.transaction(I, t), r = e(i.objectStore(I));
|
|
35
|
+
r.onsuccess = () => o({ ok: !0, value: r.result }), r.onerror = () => o({ ok: !1, value: null }), i.oncomplete = () => n.close(), i.onerror = () => {
|
|
36
|
+
n.close(), o({ ok: !1, value: null });
|
|
37
37
|
};
|
|
38
38
|
} catch {
|
|
39
|
-
n.close(),
|
|
39
|
+
n.close(), o({ ok: !1, value: null });
|
|
40
40
|
}
|
|
41
41
|
}) : { ok: !1, value: null };
|
|
42
42
|
}
|
|
43
|
-
async function
|
|
44
|
-
|
|
43
|
+
async function P(t) {
|
|
44
|
+
C.set(t.id, t), await j("readwrite", (e) => e.put(t));
|
|
45
45
|
}
|
|
46
|
-
async function
|
|
47
|
-
|
|
46
|
+
async function S(t) {
|
|
47
|
+
C.delete(t), await j("readwrite", (e) => e.delete(t));
|
|
48
48
|
}
|
|
49
49
|
async function x(t) {
|
|
50
|
-
const e = await
|
|
51
|
-
return e.ok ? e.value ?? null :
|
|
50
|
+
const e = await j("readonly", (n) => n.get(t));
|
|
51
|
+
return e.ok ? e.value ?? null : C.get(t) ?? null;
|
|
52
52
|
}
|
|
53
|
-
async function
|
|
54
|
-
const t = await
|
|
55
|
-
return t.ok ? t.value ?? [] : [...
|
|
53
|
+
async function V() {
|
|
54
|
+
const t = await j("readonly", (e) => e.getAll());
|
|
55
|
+
return t.ok ? t.value ?? [] : [...C.values()];
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function F(t) {
|
|
58
58
|
return JSON.parse(JSON.stringify(t ?? null));
|
|
59
59
|
}
|
|
60
|
-
let
|
|
61
|
-
const
|
|
62
|
-
let
|
|
63
|
-
function
|
|
64
|
-
for (const t of
|
|
60
|
+
let f = null, wt = !1, L = null, d = null, c = [];
|
|
61
|
+
const T = /* @__PURE__ */ new Set(), B = /* @__PURE__ */ new Set(), M = /* @__PURE__ */ new Set();
|
|
62
|
+
let $ = null, X = !1, b = null;
|
|
63
|
+
function w() {
|
|
64
|
+
for (const t of T) t();
|
|
65
65
|
}
|
|
66
|
-
function
|
|
67
|
-
for (const e of
|
|
66
|
+
function E(t) {
|
|
67
|
+
for (const e of B)
|
|
68
68
|
try {
|
|
69
69
|
e(t);
|
|
70
70
|
} catch {
|
|
71
71
|
}
|
|
72
72
|
}
|
|
73
|
-
function
|
|
73
|
+
function m() {
|
|
74
74
|
try {
|
|
75
|
-
|
|
75
|
+
b == null || b.postMessage({ type: "changed" });
|
|
76
76
|
} catch {
|
|
77
77
|
}
|
|
78
78
|
}
|
|
79
|
-
function
|
|
79
|
+
function Z(t, e) {
|
|
80
80
|
const n = new Date(t.created_at).getTime();
|
|
81
|
-
return !Number.isFinite(n) || e - n >
|
|
81
|
+
return !Number.isFinite(n) || e - n > ct;
|
|
82
82
|
}
|
|
83
|
-
async function
|
|
84
|
-
const e =
|
|
83
|
+
async function ht(t) {
|
|
84
|
+
const e = H();
|
|
85
85
|
if (!e) return t();
|
|
86
86
|
await e.request("nvr-record-outbox:sweep", {}, t).catch(() => {
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
|
-
async function
|
|
90
|
-
const t =
|
|
91
|
-
t && await
|
|
89
|
+
async function Q() {
|
|
90
|
+
const t = f;
|
|
91
|
+
t && await ht(async () => {
|
|
92
92
|
const e = Date.now();
|
|
93
|
-
for (const n of await
|
|
94
|
-
if (!n || n.owner !== t || !
|
|
95
|
-
const
|
|
96
|
-
|
|
93
|
+
for (const n of await V()) {
|
|
94
|
+
if (!n || n.owner !== t || !Z(n, e)) continue;
|
|
95
|
+
const o = await x(n.id);
|
|
96
|
+
o && (await S(n.id), c = c.filter((i) => i.id !== n.id), w(), m(), f === t && E({ type: "expired", entry: o }));
|
|
97
97
|
}
|
|
98
98
|
});
|
|
99
99
|
}
|
|
100
|
-
async function
|
|
101
|
-
for (const e of await
|
|
102
|
-
}
|
|
103
|
-
async function
|
|
104
|
-
if (!
|
|
105
|
-
const t =
|
|
106
|
-
let
|
|
107
|
-
for (const
|
|
108
|
-
if (!(!
|
|
109
|
-
if (
|
|
110
|
-
|
|
100
|
+
async function mt(t) {
|
|
101
|
+
for (const e of await V()) e && e.owner !== t && await S(e.id);
|
|
102
|
+
}
|
|
103
|
+
async function A() {
|
|
104
|
+
if (!f) return;
|
|
105
|
+
const t = f, e = await V(), n = Date.now(), o = [];
|
|
106
|
+
let i = !1;
|
|
107
|
+
for (const r of e)
|
|
108
|
+
if (!(!r || r.owner !== t)) {
|
|
109
|
+
if (Z(r, n)) {
|
|
110
|
+
i = !0;
|
|
111
111
|
continue;
|
|
112
112
|
}
|
|
113
|
-
|
|
113
|
+
o.push(r.status === "sending" ? { ...r, status: "queued" } : r);
|
|
114
114
|
}
|
|
115
|
-
|
|
115
|
+
f === t && (c = o, w(), i && await Q());
|
|
116
116
|
}
|
|
117
|
-
function
|
|
118
|
-
|
|
119
|
-
const
|
|
120
|
-
if (!(!
|
|
121
|
-
if (
|
|
117
|
+
function Rt(t, e, n) {
|
|
118
|
+
L = t, n && (d = n);
|
|
119
|
+
const o = ut(e);
|
|
120
|
+
if (!(!o || o === f)) {
|
|
121
|
+
if (f = o, c = [], w(), typeof BroadcastChannel < "u" && !b)
|
|
122
122
|
try {
|
|
123
|
-
|
|
123
|
+
b = new BroadcastChannel("nvr-record-outbox"), b.onmessage = () => void A();
|
|
124
124
|
} catch {
|
|
125
|
-
|
|
125
|
+
b = null;
|
|
126
126
|
}
|
|
127
|
-
!
|
|
128
|
-
|
|
127
|
+
!X && typeof window < "u" && (X = !0, window.addEventListener("online", () => O(0))), mt(o).then(() => (m(), A())).then(() => {
|
|
128
|
+
c.some((i) => i.status === "queued") && O(1e3);
|
|
129
129
|
});
|
|
130
130
|
}
|
|
131
131
|
}
|
|
132
|
-
function
|
|
133
|
-
return
|
|
132
|
+
function kt() {
|
|
133
|
+
return c;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
return
|
|
135
|
+
function qt(t) {
|
|
136
|
+
return T.add(t), () => T.delete(t);
|
|
137
137
|
}
|
|
138
|
-
function
|
|
139
|
-
return
|
|
138
|
+
function Ct(t) {
|
|
139
|
+
return B.add(t), () => B.delete(t);
|
|
140
140
|
}
|
|
141
|
-
function
|
|
142
|
-
return
|
|
141
|
+
function jt(t) {
|
|
142
|
+
return M.add(t), () => M.delete(t);
|
|
143
143
|
}
|
|
144
|
-
function
|
|
145
|
-
var
|
|
146
|
-
const e = t, n = (e == null ? void 0 : e.status) ?? ((
|
|
144
|
+
function k(t) {
|
|
145
|
+
var o;
|
|
146
|
+
const e = t, n = (e == null ? void 0 : e.status) ?? ((o = e == null ? void 0 : e.response) == null ? void 0 : o.status);
|
|
147
147
|
return n == null ? !(e != null && e.response) : n === 0 || n === 502 || n === 503 || n === 504;
|
|
148
148
|
}
|
|
149
|
-
function
|
|
149
|
+
function tt(t) {
|
|
150
150
|
const e = t == null ? void 0 : t.response, n = (e == null ? void 0 : e.data) ?? e;
|
|
151
151
|
return (n == null ? void 0 : n.code) !== "MIDAIR_COLLISION" || !Array.isArray(n.conflicts) ? null : { conflicts: n.conflicts, latest: Number(n.latest_revision) || 0 };
|
|
152
152
|
}
|
|
153
|
-
function
|
|
153
|
+
function g(t, e) {
|
|
154
154
|
if (t === e) return !0;
|
|
155
155
|
if (t == null || e == null) return t == null && e == null;
|
|
156
156
|
try {
|
|
@@ -159,215 +159,362 @@ function L(t, e) {
|
|
|
159
159
|
return !1;
|
|
160
160
|
}
|
|
161
161
|
}
|
|
162
|
-
async function
|
|
163
|
-
const e =
|
|
164
|
-
if (!e ||
|
|
162
|
+
async function Et(t) {
|
|
163
|
+
const e = f;
|
|
164
|
+
if (!e || wt) return null;
|
|
165
165
|
const n = {};
|
|
166
|
-
for (const [
|
|
166
|
+
for (const [l, R] of Object.entries(t.payload)) l.startsWith("_") || (n[l] = R);
|
|
167
167
|
if (Object.keys(n).length === 0) return null;
|
|
168
|
-
const
|
|
169
|
-
for (const
|
|
170
|
-
(
|
|
171
|
-
const u = (
|
|
172
|
-
id:
|
|
168
|
+
const o = _(e, t.collection, t.item), i = c.find((l) => l.id === o) ?? await x(o), r = (/* @__PURE__ */ new Date()).toISOString(), a = !i || Object.keys(i.payload).every((l) => l in n), s = a ? {} : { ...i.before };
|
|
169
|
+
for (const l of Object.keys(n))
|
|
170
|
+
(a || !(l in s)) && (s[l] = t.before[l] ?? null);
|
|
171
|
+
const u = (i == null ? void 0 : i.base_revision) ?? null, h = a ? t.baseRevision : u == null || t.baseRevision == null ? null : Math.min(u, t.baseRevision), y = F({
|
|
172
|
+
id: o,
|
|
173
173
|
owner: e,
|
|
174
174
|
collection: t.collection,
|
|
175
175
|
item: String(t.item),
|
|
176
|
-
payload: { ...(
|
|
176
|
+
payload: { ...(i == null ? void 0 : i.payload) ?? {}, ...n },
|
|
177
177
|
before: s,
|
|
178
|
-
base_revision:
|
|
179
|
-
change_reason: t.changeReason ?? (
|
|
180
|
-
created_at: (
|
|
181
|
-
updated_at:
|
|
178
|
+
base_revision: h ?? null,
|
|
179
|
+
change_reason: t.changeReason ?? (i == null ? void 0 : i.change_reason) ?? null,
|
|
180
|
+
created_at: (i == null ? void 0 : i.created_at) ?? r,
|
|
181
|
+
updated_at: r,
|
|
182
182
|
status: "queued",
|
|
183
183
|
error: null,
|
|
184
184
|
conflicts: null,
|
|
185
185
|
latest_revision: null
|
|
186
186
|
});
|
|
187
|
-
return
|
|
188
|
-
}
|
|
189
|
-
async function
|
|
190
|
-
if (!
|
|
191
|
-
const
|
|
192
|
-
if (!
|
|
193
|
-
const
|
|
194
|
-
for (const [s, u] of Object.entries(
|
|
195
|
-
if (Object.keys(
|
|
196
|
-
|
|
187
|
+
return f !== e ? null : (c = [...c.filter((l) => l.id !== o), y], w(), await P(y), m(), O(G), y);
|
|
188
|
+
}
|
|
189
|
+
async function $t(t, e, n) {
|
|
190
|
+
if (!f) return;
|
|
191
|
+
const o = _(f, t, e), i = c.find((s) => s.id === o) ?? await x(o);
|
|
192
|
+
if (!i || i.owner !== f) return;
|
|
193
|
+
const r = new Set(n), a = {};
|
|
194
|
+
for (const [s, u] of Object.entries(i.payload)) r.has(s) || (a[s] = u);
|
|
195
|
+
if (Object.keys(a).length === 0)
|
|
196
|
+
c = c.filter((s) => s.id !== o), w(), await S(o);
|
|
197
197
|
else {
|
|
198
198
|
const s = {
|
|
199
|
-
...
|
|
200
|
-
payload:
|
|
199
|
+
...i,
|
|
200
|
+
payload: a,
|
|
201
201
|
status: "queued",
|
|
202
202
|
updated_at: (/* @__PURE__ */ new Date()).toISOString()
|
|
203
203
|
};
|
|
204
|
-
|
|
204
|
+
c = c.map((u) => u.id === o ? s : u), w(), await P(s);
|
|
205
205
|
}
|
|
206
|
-
|
|
206
|
+
m();
|
|
207
207
|
}
|
|
208
|
-
async function
|
|
209
|
-
if (!
|
|
210
|
-
const n =
|
|
211
|
-
|
|
208
|
+
async function It(t, e) {
|
|
209
|
+
if (!f) return;
|
|
210
|
+
const n = _(f, t, e);
|
|
211
|
+
c = c.filter((o) => o.id !== n), w(), await S(n), m();
|
|
212
212
|
}
|
|
213
|
-
async function
|
|
214
|
-
|
|
213
|
+
async function Nt() {
|
|
214
|
+
rt(), c = [], C.clear(), w(), await j("readwrite", (t) => t.clear()), m();
|
|
215
215
|
}
|
|
216
|
-
async function
|
|
217
|
-
const n =
|
|
216
|
+
async function p(t, e) {
|
|
217
|
+
const n = c.find((i) => i.id === t) ?? await x(t);
|
|
218
218
|
if (!n) return null;
|
|
219
|
-
const
|
|
220
|
-
return
|
|
219
|
+
const o = { ...n, ...e };
|
|
220
|
+
return c = c.some((i) => i.id === t) ? c.map((i) => i.id === t ? o : i) : c, w(), await P(o), m(), o;
|
|
221
221
|
}
|
|
222
|
-
function
|
|
222
|
+
function H() {
|
|
223
223
|
const t = globalThis.navigator;
|
|
224
224
|
return (t == null ? void 0 : t.locks) ?? null;
|
|
225
225
|
}
|
|
226
|
-
const
|
|
227
|
-
function
|
|
228
|
-
if (!
|
|
226
|
+
const q = /* @__PURE__ */ new Set();
|
|
227
|
+
function Dt(t, e) {
|
|
228
|
+
if (!f) return () => {
|
|
229
229
|
};
|
|
230
|
-
const n =
|
|
231
|
-
|
|
232
|
-
let
|
|
230
|
+
const n = _(f, t, e);
|
|
231
|
+
q.add(n), c = [...c], w();
|
|
232
|
+
let o = () => {
|
|
233
233
|
};
|
|
234
|
-
const
|
|
235
|
-
|
|
236
|
-
}),
|
|
237
|
-
return
|
|
234
|
+
const i = new Promise((a) => {
|
|
235
|
+
o = a;
|
|
236
|
+
}), r = H();
|
|
237
|
+
return r && r.request(`nvr-record-outbox:${n}`, {}, () => i).catch(() => {
|
|
238
238
|
}), () => {
|
|
239
|
-
|
|
239
|
+
q.delete(n), c = [...c], w(), o();
|
|
240
240
|
};
|
|
241
241
|
}
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
242
|
+
const U = /* @__PURE__ */ new Set();
|
|
243
|
+
function Lt() {
|
|
244
|
+
if (c.some((t) => t.status === "conflict"))
|
|
245
|
+
for (const t of U) t();
|
|
246
|
+
}
|
|
247
|
+
function Tt(t) {
|
|
248
|
+
return U.add(t), () => U.delete(t);
|
|
249
|
+
}
|
|
250
|
+
function Bt(t) {
|
|
251
|
+
return q.has(t);
|
|
252
|
+
}
|
|
253
|
+
async function pt(t, e) {
|
|
254
|
+
if (q.has(t)) return;
|
|
255
|
+
const n = H();
|
|
245
256
|
if (!n) return e();
|
|
246
|
-
await n.request(`nvr-record-outbox:${t}`, { ifAvailable: !0 }, async (
|
|
247
|
-
|
|
257
|
+
await n.request(`nvr-record-outbox:${t}`, { ifAvailable: !0 }, async (o) => {
|
|
258
|
+
o && await e();
|
|
248
259
|
}).catch(() => {
|
|
249
260
|
});
|
|
250
261
|
}
|
|
251
|
-
let
|
|
252
|
-
function
|
|
253
|
-
|
|
254
|
-
|
|
262
|
+
let D = !1;
|
|
263
|
+
function O(t) {
|
|
264
|
+
$ && clearTimeout($), $ = setTimeout(() => {
|
|
265
|
+
$ = null, vt();
|
|
255
266
|
}, t);
|
|
256
267
|
}
|
|
257
|
-
async function
|
|
268
|
+
async function bt(t, e) {
|
|
258
269
|
var n;
|
|
259
270
|
try {
|
|
260
|
-
const
|
|
261
|
-
return !!
|
|
262
|
-
} catch (
|
|
263
|
-
return
|
|
271
|
+
const o = await t.request(v("/auth/me")), i = (n = o == null ? void 0 : o.data) == null ? void 0 : n.id;
|
|
272
|
+
return !!i && String(i).toLowerCase() === ft(e).toLowerCase();
|
|
273
|
+
} catch (o) {
|
|
274
|
+
return k(o) ? null : !1;
|
|
264
275
|
}
|
|
265
276
|
}
|
|
266
|
-
async function
|
|
267
|
-
if (
|
|
268
|
-
|
|
269
|
-
const t =
|
|
277
|
+
async function vt() {
|
|
278
|
+
if (D || !L || !f || (await Q(), !c.some((o) => o.status === "queued"))) return;
|
|
279
|
+
D = !0;
|
|
280
|
+
const t = L, e = f;
|
|
270
281
|
let n = !1;
|
|
271
282
|
try {
|
|
272
|
-
const
|
|
273
|
-
if (
|
|
283
|
+
const o = await bt(t, e);
|
|
284
|
+
if (o === null) {
|
|
274
285
|
n = !0;
|
|
275
286
|
return;
|
|
276
287
|
}
|
|
277
|
-
if (!
|
|
278
|
-
for (const
|
|
279
|
-
const
|
|
280
|
-
for (const
|
|
281
|
-
if (
|
|
282
|
-
if (await
|
|
283
|
-
const
|
|
284
|
-
if (!
|
|
285
|
-
await
|
|
288
|
+
if (!o) return;
|
|
289
|
+
for (const r of M) r();
|
|
290
|
+
const i = c.filter((r) => r.status === "queued" && !q.has(r.id));
|
|
291
|
+
for (const r of i) {
|
|
292
|
+
if (f !== e) return;
|
|
293
|
+
if (await pt(r.id, async () => {
|
|
294
|
+
const a = await x(r.id);
|
|
295
|
+
if (!a || a.owner !== e || a.status !== "queued") {
|
|
296
|
+
await A();
|
|
286
297
|
return;
|
|
287
298
|
}
|
|
288
|
-
await
|
|
299
|
+
await Ot(t, a) === "offline" && (n = !0);
|
|
289
300
|
}), n) break;
|
|
290
301
|
}
|
|
291
302
|
} finally {
|
|
292
|
-
|
|
303
|
+
D = !1, n && O(G);
|
|
293
304
|
}
|
|
294
305
|
}
|
|
295
|
-
async function
|
|
296
|
-
const n = Object.keys(e.payload),
|
|
297
|
-
|
|
298
|
-
),
|
|
306
|
+
async function Mt(t, e) {
|
|
307
|
+
const n = Object.keys(e.payload), o = await t.request(
|
|
308
|
+
v(`/items/${e.collection}/${encodeURIComponent(e.item)}`, { fields: n.join(",") })
|
|
309
|
+
), i = (o == null ? void 0 : o.data) ?? {}, r = [];
|
|
299
310
|
for (const s of n) {
|
|
300
|
-
const u =
|
|
301
|
-
!
|
|
311
|
+
const u = i[s] ?? null;
|
|
312
|
+
!g(u, e.before[s] ?? null) && !g(u, e.payload[s]) && r.push({ field: s, current_value: u });
|
|
302
313
|
}
|
|
303
|
-
const
|
|
304
|
-
|
|
314
|
+
const a = await t.request(
|
|
315
|
+
v("/revisions", { collection: e.collection, item: e.item, latest_only: "1" })
|
|
305
316
|
).then((s) => {
|
|
306
317
|
var u;
|
|
307
318
|
return ((u = s == null ? void 0 : s.data) == null ? void 0 : u.latest) ?? null;
|
|
308
319
|
});
|
|
309
|
-
return { conflicts:
|
|
320
|
+
return { conflicts: r, latest: a == null ? null : Number(a) || null };
|
|
321
|
+
}
|
|
322
|
+
async function gt(t, e) {
|
|
323
|
+
var h;
|
|
324
|
+
const n = await t.request(
|
|
325
|
+
v("/revisions", { collection: e.collection, item: e.item, latest_only: "1" })
|
|
326
|
+
), o = (h = n == null ? void 0 : n.data) == null ? void 0 : h.latest, i = o == null ? null : Number(o) || null;
|
|
327
|
+
if (e.base_revision != null && (i == null || i <= e.base_revision))
|
|
328
|
+
return { clashes: [], latest: e.base_revision };
|
|
329
|
+
const r = Object.keys(e.payload), a = await t.request(
|
|
330
|
+
v(`/items/${e.collection}/${encodeURIComponent(e.item)}`, { fields: r.join(",") })
|
|
331
|
+
), s = (a == null ? void 0 : a.data) ?? {}, u = [];
|
|
332
|
+
for (const y of r) {
|
|
333
|
+
if (!(y in s)) continue;
|
|
334
|
+
const l = s[y] ?? null;
|
|
335
|
+
!g(l, e.before[y] ?? null) && !g(l, e.payload[y]) && u.push({ field: y, current_value: l });
|
|
336
|
+
}
|
|
337
|
+
return u.length > 0 && await et(t, e, u), { clashes: u, latest: i };
|
|
310
338
|
}
|
|
311
|
-
async function
|
|
312
|
-
var n, r;
|
|
313
|
-
await h(e.id, { status: "sending" });
|
|
339
|
+
async function et(t, e, n) {
|
|
314
340
|
try {
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
341
|
+
const o = await t.request(
|
|
342
|
+
v("/revisions/field-touch", {
|
|
343
|
+
collection: e.collection,
|
|
344
|
+
item: e.item,
|
|
345
|
+
fields: n.map((r) => r.field).join(",")
|
|
346
|
+
})
|
|
347
|
+
), i = (o == null ? void 0 : o.data) ?? {};
|
|
348
|
+
for (const r of n) {
|
|
349
|
+
const a = i[r.field];
|
|
350
|
+
r.by = a != null && a.who ? String(a.who).slice(0, 80) : null, r.at = a != null && a.at ? String(a.at) : null;
|
|
320
351
|
}
|
|
321
|
-
|
|
322
|
-
|
|
352
|
+
} catch {
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
async function nt(t, e, n) {
|
|
356
|
+
if (n.length === 0) return [];
|
|
357
|
+
let o = null;
|
|
358
|
+
try {
|
|
359
|
+
const r = await t.request(
|
|
360
|
+
v(`/items/${e.collection}/${encodeURIComponent(e.item)}`, {
|
|
361
|
+
fields: n.map((a) => a.field).join(",")
|
|
362
|
+
})
|
|
363
|
+
);
|
|
364
|
+
o = (r == null ? void 0 : r.data) ?? null;
|
|
365
|
+
} catch {
|
|
366
|
+
o = null;
|
|
367
|
+
}
|
|
368
|
+
const i = n.map(
|
|
369
|
+
(r) => o && r.field in o ? { field: r.field, current_value: o[r.field] ?? null } : { field: r.field, current_value: null, hidden: !0 }
|
|
370
|
+
);
|
|
371
|
+
return await et(t, e, i), i;
|
|
372
|
+
}
|
|
373
|
+
function K(t, e) {
|
|
374
|
+
const n = {};
|
|
375
|
+
for (const o of e) o in t && (n[o] = t[o]);
|
|
376
|
+
return n;
|
|
377
|
+
}
|
|
378
|
+
function ot(t, e, n) {
|
|
379
|
+
const o = n ? K(t.payload, n) : { ...t.payload };
|
|
380
|
+
return e != null && (o._base_revision = e), t.change_reason && (o._change_reason = t.change_reason), o;
|
|
381
|
+
}
|
|
382
|
+
async function Ot(t, e) {
|
|
383
|
+
await p(e.id, { status: "sending" });
|
|
384
|
+
const n = `/items/${e.collection}/${encodeURIComponent(e.item)}`;
|
|
385
|
+
try {
|
|
386
|
+
let o = null;
|
|
387
|
+
try {
|
|
388
|
+
o = await gt(t, e);
|
|
389
|
+
} catch (r) {
|
|
390
|
+
if (k(r) || e.base_revision == null) throw r;
|
|
391
|
+
o = null;
|
|
392
|
+
}
|
|
393
|
+
const i = e.base_revision ?? (o == null ? void 0 : o.latest) ?? null;
|
|
394
|
+
return o && o.clashes.length > 0 ? await J(t, e, o, i) : (await t.request(z(n, ot(e, i))), Y(e));
|
|
323
395
|
} catch (o) {
|
|
324
|
-
if (
|
|
325
|
-
return await
|
|
326
|
-
const i =
|
|
327
|
-
if (i)
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
396
|
+
if (k(o))
|
|
397
|
+
return await p(e.id, { status: "queued", error: "Waiting for a connection" }), "offline";
|
|
398
|
+
const i = tt(o);
|
|
399
|
+
if (i) {
|
|
400
|
+
const r = i.conflicts.filter((s) => !g(s.current_value, e.payload[s.field]));
|
|
401
|
+
if (r.length === 0) return Y(e);
|
|
402
|
+
const a = await nt(t, e, r);
|
|
403
|
+
try {
|
|
404
|
+
return await J(
|
|
405
|
+
t,
|
|
406
|
+
e,
|
|
407
|
+
{ clashes: a, latest: i.latest },
|
|
408
|
+
e.base_revision,
|
|
409
|
+
!0
|
|
410
|
+
);
|
|
411
|
+
} catch (s) {
|
|
412
|
+
return k(s) ? (await p(e.id, { status: "queued", error: "Waiting for a connection" }), "offline") : W(e, s);
|
|
413
|
+
}
|
|
414
|
+
}
|
|
415
|
+
return W(e, o);
|
|
331
416
|
}
|
|
332
417
|
}
|
|
333
|
-
async function
|
|
334
|
-
|
|
418
|
+
async function W(t, e) {
|
|
419
|
+
var i, r;
|
|
420
|
+
const n = ((i = e == null ? void 0 : e.response) == null ? void 0 : i.message) ?? ((r = e == null ? void 0 : e.response) == null ? void 0 : r.error) ?? st(e, "Could not save"), o = await p(t.id, { status: "failed", error: n });
|
|
421
|
+
return o && E({ type: "failed", entry: o }), "failed";
|
|
335
422
|
}
|
|
336
|
-
async function J(t, e, n) {
|
|
337
|
-
const r =
|
|
423
|
+
async function J(t, e, n, o, i = !1) {
|
|
424
|
+
const r = new Set(n.clashes.map((l) => l.field)), a = Object.keys(e.payload).filter((l) => !r.has(l)), s = [...n.clashes];
|
|
425
|
+
let u = [];
|
|
426
|
+
if (a.length > 0)
|
|
427
|
+
try {
|
|
428
|
+
await t.request(
|
|
429
|
+
z(`/items/${e.collection}/${encodeURIComponent(e.item)}`, ot(e, o, a))
|
|
430
|
+
), u = a;
|
|
431
|
+
} catch (l) {
|
|
432
|
+
if (k(l)) throw l;
|
|
433
|
+
const R = tt(l);
|
|
434
|
+
if (!R || i) return W(e, l);
|
|
435
|
+
const it = R.conflicts.filter(
|
|
436
|
+
(N) => !r.has(N.field) && !g(N.current_value, e.payload[N.field])
|
|
437
|
+
);
|
|
438
|
+
return s.push(...await nt(t, e, it)), J(
|
|
439
|
+
t,
|
|
440
|
+
e,
|
|
441
|
+
{ clashes: s, latest: R.latest || n.latest },
|
|
442
|
+
o,
|
|
443
|
+
!0
|
|
444
|
+
);
|
|
445
|
+
}
|
|
446
|
+
const h = s.map((l) => l.field), y = await p(e.id, {
|
|
338
447
|
status: "conflict",
|
|
339
|
-
|
|
340
|
-
|
|
448
|
+
payload: K(e.payload, h),
|
|
449
|
+
before: K(e.before, h),
|
|
450
|
+
conflicts: F(s),
|
|
451
|
+
latest_revision: n.latest,
|
|
452
|
+
sent_fields: [.../* @__PURE__ */ new Set([...e.sent_fields ?? [], ...u])],
|
|
341
453
|
error: "Someone else changed this record"
|
|
342
454
|
});
|
|
343
|
-
return
|
|
455
|
+
return u.length > 0 && (d == null || d.invalidateQueries({ queryKey: ["item", e.collection] }), d == null || d.invalidateQueries({ queryKey: ["collision-base", e.collection] })), y && E({ type: "conflict", entry: y }), "conflict";
|
|
456
|
+
}
|
|
457
|
+
async function At(t, e, n, o) {
|
|
458
|
+
if (!f) return;
|
|
459
|
+
const i = _(f, t, e), r = c.find((l) => l.id === i) ?? await x(i);
|
|
460
|
+
if (!r || r.owner !== f || r.status !== "conflict") return;
|
|
461
|
+
const a = (r.conflicts ?? []).find((l) => l.field === n);
|
|
462
|
+
if (!a) return;
|
|
463
|
+
const s = { ...r.payload }, u = { ...r.before };
|
|
464
|
+
o === "theirs" ? (delete s[n], delete u[n]) : (typeof o == "object" && (s[n] = F(o.merged)), a.hidden || (u[n] = a.current_value));
|
|
465
|
+
const h = (r.conflicts ?? []).filter((l) => l.field !== n), y = (/* @__PURE__ */ new Date()).toISOString();
|
|
466
|
+
if (h.length > 0) {
|
|
467
|
+
await p(i, { payload: s, before: u, conflicts: h, updated_at: y });
|
|
468
|
+
return;
|
|
469
|
+
}
|
|
470
|
+
if (Object.keys(s).length === 0) {
|
|
471
|
+
c = c.filter((l) => l.id !== i), w(), await S(i), m(), E({ type: "resolved", entry: { ...r, payload: s, conflicts: [] } }), d == null || d.invalidateQueries({ queryKey: ["item", r.collection] });
|
|
472
|
+
return;
|
|
473
|
+
}
|
|
474
|
+
await p(i, {
|
|
475
|
+
payload: s,
|
|
476
|
+
before: u,
|
|
477
|
+
conflicts: null,
|
|
478
|
+
status: "queued",
|
|
479
|
+
error: null,
|
|
480
|
+
base_revision: r.latest_revision ?? r.base_revision,
|
|
481
|
+
updated_at: y
|
|
482
|
+
}), O(0);
|
|
483
|
+
}
|
|
484
|
+
async function Y(t) {
|
|
485
|
+
return c = c.filter((e) => e.id !== t.id), w(), await S(t.id), m(), E({ type: "replayed", entry: t }), d == null || d.invalidateQueries({ queryKey: ["item", t.collection] }), d == null || d.invalidateQueries({ queryKey: ["collision-base", t.collection] }), "done";
|
|
344
486
|
}
|
|
345
|
-
async function
|
|
346
|
-
|
|
487
|
+
async function Ut(t, e) {
|
|
488
|
+
f && (await p(_(f, t, e), {
|
|
347
489
|
status: "queued",
|
|
348
490
|
error: null,
|
|
349
491
|
conflicts: null
|
|
350
|
-
}),
|
|
492
|
+
}), O(0));
|
|
351
493
|
}
|
|
352
494
|
export {
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
495
|
+
ct as RECORD_OUTBOX_TTL_MS,
|
|
496
|
+
Rt as bindRecordOutbox,
|
|
497
|
+
Mt as checkUnknownBase,
|
|
498
|
+
Dt as claimRecordOutbox,
|
|
499
|
+
Nt as clearRecordOutbox,
|
|
500
|
+
It as discardRecordOutbox,
|
|
501
|
+
Et as enqueueRecordSave,
|
|
502
|
+
kt as getRecordOutbox,
|
|
503
|
+
k as isOfflineSaveError,
|
|
504
|
+
Bt as isRecordOutboxHeld,
|
|
505
|
+
tt as midairCollisionOf,
|
|
506
|
+
Lt as nudgeOutboxReview,
|
|
507
|
+
Tt as onOutboxReviewNudge,
|
|
508
|
+
Ct as onRecordOutboxEvent,
|
|
509
|
+
jt as onRecordOutboxRetry,
|
|
510
|
+
_ as outboxEntryId,
|
|
511
|
+
ut as outboxOwner,
|
|
512
|
+
gt as planOutboxSend,
|
|
513
|
+
vt as replayRecordOutbox,
|
|
514
|
+
At as resolveRecordOutboxField,
|
|
515
|
+
Ut as retryRecordOutbox,
|
|
516
|
+
O as scheduleReplay,
|
|
517
|
+
$t as settleRecordOutbox,
|
|
518
|
+
qt as subscribeRecordOutbox,
|
|
519
|
+
Q as sweepExpiredRecordOutbox
|
|
373
520
|
};
|