@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
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { useContext as s, createContext as i } from "react";
|
|
2
|
+
const o = i(null);
|
|
3
|
+
function a(e, t, r) {
|
|
4
|
+
const n = s(o);
|
|
5
|
+
return !n || !t || t === "new" || n.collection !== e || String(n.item) !== String(t) ? null : { collection: e, item: String(t), field: r, saved: () => n.saved(r) };
|
|
6
|
+
}
|
|
7
|
+
function c(e) {
|
|
8
|
+
const t = e.interface ?? "";
|
|
9
|
+
return t === "input-rich-text-html" || t === "rich_text" || t === "extension-editorjs" || e.type === "rich_text";
|
|
10
|
+
}
|
|
11
|
+
function u(e) {
|
|
12
|
+
const t = e.sharedFields.size > 0 && e.unsavedFields.length > 0 && e.otherChanges === 0 && e.unsavedFields.every((n) => e.sharedFields.has(n)), r = e.sharedFields.size > 0 && e.heldByOther && !e.recordGone && !e.stepLocked;
|
|
13
|
+
return { onlySharedUnsaved: t, open: r, saveOk: r && t };
|
|
14
|
+
}
|
|
15
|
+
function l(e, t) {
|
|
16
|
+
return e ? new Set(t) : null;
|
|
17
|
+
}
|
|
18
|
+
export {
|
|
19
|
+
o as CoeditFormContext,
|
|
20
|
+
c as isCoeditInterface,
|
|
21
|
+
l as saveValidationScope,
|
|
22
|
+
u as sharedTextUnderLock,
|
|
23
|
+
a as useCoeditTarget
|
|
24
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { Extension as p, Decoration as d } from "@tiptap/react";
|
|
2
|
+
const f = "nvrCoeditCursors";
|
|
3
|
+
function g(t, n, r) {
|
|
4
|
+
const o = t.storage.coeditCursors;
|
|
5
|
+
if (!(!o || t.isDestroyed) && (o.cursors = n, t.view.dispatch(t.state.tr.setMeta(f, !0).setMeta("addToHistory", !1)), !!r))
|
|
6
|
+
for (const e of t.view.dom.querySelectorAll(".nvr-coedit-caret"))
|
|
7
|
+
e.dataset.coedit === r && (e.classList.remove("nvr-coedit-wake"), e.offsetWidth, e.classList.add("nvr-coedit-wake"));
|
|
8
|
+
}
|
|
9
|
+
function u(t) {
|
|
10
|
+
return t.trim().split(/\s+/)[0] || t;
|
|
11
|
+
}
|
|
12
|
+
function l(t) {
|
|
13
|
+
const n = t.replace("#", ""), o = [0, 2, 4].map((e) => Number.parseInt(n.slice(e, e + 2), 16) / 255).map((e) => e <= 0.03928 ? e / 12.92 : ((e + 0.055) / 1.055) ** 2.4);
|
|
14
|
+
return 0.2126 * o[0] + 0.7152 * o[1] + 0.0722 * o[2];
|
|
15
|
+
}
|
|
16
|
+
function h(t) {
|
|
17
|
+
if (!/^#[0-9a-f]{6}$/i.test(t)) return "#ffffff";
|
|
18
|
+
const n = l(t), r = 1.05 / (n + 0.05), o = (n + 0.05) / (l("#0f172a") + 0.05);
|
|
19
|
+
return r >= 4.5 || r >= o ? "#ffffff" : "#0f172a";
|
|
20
|
+
}
|
|
21
|
+
function m(t, n, r) {
|
|
22
|
+
const o = document.createElement("span");
|
|
23
|
+
o.className = "nvr-coedit-caret nvr-coedit-wake", o.dataset.coedit = t, o.style.setProperty("--nvr-coedit", r), o.style.setProperty("--nvr-coedit-ink", h(r)), o.setAttribute("aria-hidden", "true");
|
|
24
|
+
const e = document.createElement("span");
|
|
25
|
+
return e.className = "nvr-coedit-flag", e.textContent = u(n), o.appendChild(e), o;
|
|
26
|
+
}
|
|
27
|
+
const x = p.create({
|
|
28
|
+
name: "coeditCursors",
|
|
29
|
+
addStorage() {
|
|
30
|
+
return { cursors: [] };
|
|
31
|
+
},
|
|
32
|
+
addDecorations() {
|
|
33
|
+
const t = this.storage;
|
|
34
|
+
return {
|
|
35
|
+
// Positions follow every change; the set is rebuilt when they could have moved.
|
|
36
|
+
shouldUpdate: ({ tr: n }) => (n.docChanged && t.cursors.length && (t.cursors = t.cursors.map((r) => ({
|
|
37
|
+
...r,
|
|
38
|
+
anchor: n.mapping.map(r.anchor, -1),
|
|
39
|
+
head: n.mapping.map(r.head, 1)
|
|
40
|
+
}))), n.docChanged || !!n.getMeta(f)),
|
|
41
|
+
create: ({ state: n }) => {
|
|
42
|
+
const r = n.doc.content.size, o = [];
|
|
43
|
+
for (const e of t.cursors) {
|
|
44
|
+
const i = Math.max(0, Math.min(r, e.head)), a = Math.max(0, Math.min(r, e.anchor)), s = Math.min(i, a), c = Math.max(i, a);
|
|
45
|
+
c > s && o.push(
|
|
46
|
+
d.Inline(s, c, {
|
|
47
|
+
class: "nvr-coedit-sel",
|
|
48
|
+
style: `--nvr-coedit: ${e.color}`
|
|
49
|
+
})
|
|
50
|
+
), o.push(
|
|
51
|
+
d.Widget(i, () => m(e.id, e.name, e.color), {
|
|
52
|
+
key: `nvr-coedit-${e.id}-${e.color}-${u(e.name)}`,
|
|
53
|
+
side: 1,
|
|
54
|
+
ignoreSelection: !0
|
|
55
|
+
})
|
|
56
|
+
);
|
|
57
|
+
}
|
|
58
|
+
return o;
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
}), b = `
|
|
63
|
+
.nvr-coedit-caret {
|
|
64
|
+
position: relative; display: inline-block; width: 0; height: 1.15em;
|
|
65
|
+
margin: 0 -1px; border-left: 2px solid var(--nvr-coedit); vertical-align: text-bottom;
|
|
66
|
+
pointer-events: none; user-select: none;
|
|
67
|
+
}
|
|
68
|
+
.nvr-coedit-flag {
|
|
69
|
+
position: absolute; left: -2px; bottom: 100%; margin-bottom: 1px;
|
|
70
|
+
padding: 0 5px; border-radius: 3px 3px 3px 0; white-space: nowrap;
|
|
71
|
+
background: var(--nvr-coedit); color: var(--nvr-coedit-ink, #fff);
|
|
72
|
+
font-family: inherit; font-size: 10px; font-weight: 600; line-height: 15px;
|
|
73
|
+
letter-spacing: 0.01em; opacity: 0;
|
|
74
|
+
box-shadow: 0 1px 2px rgb(15 23 42 / 0.18);
|
|
75
|
+
}
|
|
76
|
+
/* The name shows while the cursor moves, then fades quickly: an idle cursor is a thin line. */
|
|
77
|
+
.nvr-coedit-wake .nvr-coedit-flag { animation: nvr-coedit-flag 3.2s cubic-bezier(0.22, 1, 0.36, 1) both; }
|
|
78
|
+
@keyframes nvr-coedit-flag { 0%, 88% { opacity: 1; } 100% { opacity: 0; } }
|
|
79
|
+
/* Their selection: a tint and an underline in their own colour (the caret's), so it reads as
|
|
80
|
+
theirs on any background — a thin tint alone drifts toward the page colour in dark mode. */
|
|
81
|
+
.nvr-coedit-sel {
|
|
82
|
+
background-color: color-mix(in srgb, var(--nvr-coedit) 18%, transparent);
|
|
83
|
+
box-shadow: inset 0 -2px 0 var(--nvr-coedit);
|
|
84
|
+
}
|
|
85
|
+
.dark .nvr-coedit-sel {
|
|
86
|
+
background-color: color-mix(in srgb, var(--nvr-coedit) 30%, transparent);
|
|
87
|
+
box-shadow: inset 0 -2px 0 color-mix(in srgb, var(--nvr-coedit) 70%, white);
|
|
88
|
+
}
|
|
89
|
+
/* Written together: the field's "someone is editing" lock ring and name badge give way to
|
|
90
|
+
the cursors (one ring only — the editor's own focus ring). */
|
|
91
|
+
[data-field][data-coedit-live].nvr-remote-editing { outline: none !important; }
|
|
92
|
+
[data-field][data-coedit-live].nvr-remote-editing::after { display: none !important; }
|
|
93
|
+
@media (prefers-reduced-motion: reduce) {
|
|
94
|
+
.nvr-coedit-flag, .nvr-coedit-wake .nvr-coedit-flag { animation: none; opacity: 1; }
|
|
95
|
+
}
|
|
96
|
+
`;
|
|
97
|
+
export {
|
|
98
|
+
b as COEDIT_CURSOR_CSS,
|
|
99
|
+
x as CoeditCursors,
|
|
100
|
+
u as firstName,
|
|
101
|
+
h as inkOn,
|
|
102
|
+
g as setCoeditCursors
|
|
103
|
+
};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const i = /^(?:javascript|data|vbscript|file):/i;
|
|
2
|
+
function r(t) {
|
|
3
|
+
return t <= 32 || t >= 127 && t <= 160 || t === 5760 || t === 6158 || t >= 8192 && t <= 8207 || t === 8232 || t === 8233 || t === 8287 || t === 12288 || t === 65279;
|
|
4
|
+
}
|
|
5
|
+
function o(t) {
|
|
6
|
+
let n = "";
|
|
7
|
+
for (const e of t) r(e.codePointAt(0) ?? 0) || (n += e);
|
|
8
|
+
return n;
|
|
9
|
+
}
|
|
10
|
+
function u(t) {
|
|
11
|
+
return t == null || t === "" ? !0 : typeof t != "string" ? !1 : !i.test(o(t));
|
|
12
|
+
}
|
|
13
|
+
export {
|
|
14
|
+
u as isSafeLinkHref
|
|
15
|
+
};
|
|
@@ -0,0 +1,382 @@
|
|
|
1
|
+
var D = Object.defineProperty;
|
|
2
|
+
var T = (l, t, e) => t in l ? D(l, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : l[t] = e;
|
|
3
|
+
var o = (l, t, e) => T(l, typeof t != "symbol" ? t + "" : t, e);
|
|
4
|
+
import { noteCoeditLive as m, noteCoeditState as I } from "../../../lib/coedit-registry.js";
|
|
5
|
+
import { newClientId as b, stepFromJSON as C, receiveSteps as S, sessionDoc as A, COEDIT_REMOTE as v, rebaseable as p, confirmedDoc as w, htmlOf as E } from "./collab.js";
|
|
6
|
+
import { setCoeditCursors as M } from "./cursors.js";
|
|
7
|
+
const g = ["#7c3aed", "#be185d", "#c2410c", "#047857", "#2563eb", "#a16207"];
|
|
8
|
+
function y(l) {
|
|
9
|
+
let t = 0;
|
|
10
|
+
for (let e = 0; e < l.length; e++) t = Math.imul(t, 31) + l.charCodeAt(e) >>> 0;
|
|
11
|
+
return g[t % g.length];
|
|
12
|
+
}
|
|
13
|
+
const u = 3e3, L = 120, _ = 15e3, F = 2500, N = 300, P = 5e3;
|
|
14
|
+
class B {
|
|
15
|
+
constructor(t, e, i, s) {
|
|
16
|
+
o(this, "clientID", b());
|
|
17
|
+
o(this, "live", !1);
|
|
18
|
+
o(this, "sid", null);
|
|
19
|
+
o(this, "version", 0);
|
|
20
|
+
o(this, "unconfirmed", []);
|
|
21
|
+
o(this, "member", !1);
|
|
22
|
+
o(this, "write", !1);
|
|
23
|
+
o(this, "diverged", !1);
|
|
24
|
+
o(this, "sentAt", 0);
|
|
25
|
+
o(this, "sentCount", 0);
|
|
26
|
+
o(this, "retryTimer", null);
|
|
27
|
+
o(this, "cursorTimer", null);
|
|
28
|
+
o(this, "heartbeatTimer", null);
|
|
29
|
+
o(this, "resetTimer", null);
|
|
30
|
+
o(this, "closeWhenIdle", !1);
|
|
31
|
+
/** Typed outside any session (and outside an open waiting for its answer): never replaced,
|
|
32
|
+
* even before the form has caught up with the keystrokes. */
|
|
33
|
+
o(this, "typedApart", !1);
|
|
34
|
+
o(this, "lastCursorAt", 0);
|
|
35
|
+
/** Opened while not live: the document the open was sent with, and steps typed since. */
|
|
36
|
+
o(this, "pending", null);
|
|
37
|
+
/** The map of each version step (version → map), for cursors sent at an older version. */
|
|
38
|
+
o(this, "maps", /* @__PURE__ */ new Map());
|
|
39
|
+
/** Cursors that arrived ahead of this editor's version. */
|
|
40
|
+
o(this, "early", []);
|
|
41
|
+
o(this, "peers", /* @__PURE__ */ new Map());
|
|
42
|
+
/** Writers of a session our own edits stay apart from (names for the note only). */
|
|
43
|
+
o(this, "apart", /* @__PURE__ */ new Map());
|
|
44
|
+
o(this, "offs", []);
|
|
45
|
+
o(this, "disposed", !1);
|
|
46
|
+
/** When this editor last asked for a whole session after a summary answer. */
|
|
47
|
+
o(this, "fullSyncAskedAt", 0);
|
|
48
|
+
this.editor = t, this.target = e, this.transport = i, this.host = s;
|
|
49
|
+
}
|
|
50
|
+
// ── Wiring ──────────────────────────────────────────────────────────────────
|
|
51
|
+
start() {
|
|
52
|
+
const t = this.transport, e = (r) => r && r.collection === this.target.collection && String(r.item) === this.target.item && r.field === this.target.field, i = (r, d) => this.offs.push(t.on(r, (f) => !this.disposed && e(f) && d(f)));
|
|
53
|
+
i("coedit:state", (r) => this.onState(r)), i("coedit:active", (r) => this.onActive(r)), i("coedit:steps", (r) => this.onSteps(r)), i("coedit:cursor", (r) => this.onCursor(r)), i("coedit:ended", () => this.onEnded());
|
|
54
|
+
const s = this.editor, n = ({ transaction: r }) => this.onTransaction(r), h = () => this.onFocus(), a = () => this.onBlur(), c = () => this.scheduleCursor();
|
|
55
|
+
s.on("transaction", n), s.on("focus", h), s.on("blur", a), s.on("selectionUpdate", c), this.offs.push(() => {
|
|
56
|
+
s.off("transaction", n), s.off("focus", h), s.off("blur", a), s.off("selectionUpdate", c);
|
|
57
|
+
}), this.watch();
|
|
58
|
+
}
|
|
59
|
+
/** Join the field's rooms (again after a reconnect: a new socket holds no rooms). */
|
|
60
|
+
watch() {
|
|
61
|
+
this.transport.emit("coedit:watch", { ...this.target }), this.editor.isFocused && this.onFocus();
|
|
62
|
+
}
|
|
63
|
+
/** The connection dropped: carry on as a plain editor (the form keeps what was typed). */
|
|
64
|
+
disconnected() {
|
|
65
|
+
this.live && this.leaveLive(), this.member = !1, this.pending = null;
|
|
66
|
+
}
|
|
67
|
+
dispose() {
|
|
68
|
+
if (!this.disposed) {
|
|
69
|
+
this.member && this.transport.emit("coedit:close", { ...this.target, clientID: this.clientID }), this.transport.emit("coedit:unwatch", { ...this.target }), this.leaveLive(), this.disposed = !0;
|
|
70
|
+
for (const t of this.offs) t();
|
|
71
|
+
this.offs = [];
|
|
72
|
+
for (const t of [this.retryTimer, this.cursorTimer, this.resetTimer]) t && clearTimeout(t);
|
|
73
|
+
this.heartbeatTimer && clearInterval(this.heartbeatTimer);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
/** Is the form's value following the shared document (the person changed the field)? */
|
|
77
|
+
tracking() {
|
|
78
|
+
return this.live && this.host.fieldDirty();
|
|
79
|
+
}
|
|
80
|
+
isLive() {
|
|
81
|
+
return this.live;
|
|
82
|
+
}
|
|
83
|
+
// ── Server events ───────────────────────────────────────────────────────────
|
|
84
|
+
onState(t) {
|
|
85
|
+
if (this.write = !!t.write, !this.write && this.member && (this.member = !1, this.pending = null, this.leaveLive()), !t.session) {
|
|
86
|
+
this.live && this.onEnded(), this.editor.isFocused && this.write && !this.member && this.open();
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
const e = t.session;
|
|
90
|
+
if ("summary" in e) {
|
|
91
|
+
if (this.live && e.sid === this.sid) {
|
|
92
|
+
e.version > this.version && this.transport.emit("coedit:sync", {
|
|
93
|
+
...this.target,
|
|
94
|
+
sid: this.sid,
|
|
95
|
+
version: this.version
|
|
96
|
+
});
|
|
97
|
+
return;
|
|
98
|
+
}
|
|
99
|
+
const s = Date.now();
|
|
100
|
+
if (s - this.fullSyncAskedAt < P) return;
|
|
101
|
+
this.fullSyncAskedAt = s, this.transport.emit("coedit:sync", { ...this.target });
|
|
102
|
+
return;
|
|
103
|
+
}
|
|
104
|
+
const i = this.live && e.sid === this.sid;
|
|
105
|
+
if (!(i && e.version <= this.version)) {
|
|
106
|
+
if (i && e.version > this.version && e.baseVersion <= this.version) {
|
|
107
|
+
const s = this.version - e.baseVersion;
|
|
108
|
+
this.applyBatch(this.version, e.steps.slice(s));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
this.live && this.leaveLive(), this.enter(e);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
onActive(t) {
|
|
115
|
+
if (t != null && t.session) {
|
|
116
|
+
if (this.live) {
|
|
117
|
+
if (t.session.sid === this.sid) return;
|
|
118
|
+
this.leaveLive();
|
|
119
|
+
}
|
|
120
|
+
this.enter(t.session);
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
onSteps(t) {
|
|
124
|
+
if (!this.live || !Array.isArray(t.steps) || !Array.isArray(t.clientIDs) || t.sid !== this.sid) return;
|
|
125
|
+
const e = Number(t.version);
|
|
126
|
+
if (!Number.isInteger(e)) return;
|
|
127
|
+
if (e > this.version) {
|
|
128
|
+
this.transport.emit("coedit:sync", { ...this.target, sid: this.sid, version: this.version });
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const i = this.version - e;
|
|
132
|
+
i >= t.steps.length || this.applyBatch(
|
|
133
|
+
this.version,
|
|
134
|
+
t.steps.slice(i).map((s, n) => ({ s, c: String(t.clientIDs[i + n] ?? "") }))
|
|
135
|
+
);
|
|
136
|
+
}
|
|
137
|
+
applyBatch(t, e) {
|
|
138
|
+
if (e.length === 0) return;
|
|
139
|
+
const i = this.editor;
|
|
140
|
+
let s;
|
|
141
|
+
try {
|
|
142
|
+
s = e.map((a) => C(i.state, a.s));
|
|
143
|
+
} catch {
|
|
144
|
+
this.resync();
|
|
145
|
+
return;
|
|
146
|
+
}
|
|
147
|
+
const n = this.sentCount > 0;
|
|
148
|
+
let h;
|
|
149
|
+
try {
|
|
150
|
+
h = S(
|
|
151
|
+
i.state,
|
|
152
|
+
this.unconfirmed,
|
|
153
|
+
t,
|
|
154
|
+
s,
|
|
155
|
+
e.map((a) => a.c),
|
|
156
|
+
this.clientID
|
|
157
|
+
);
|
|
158
|
+
} catch {
|
|
159
|
+
this.resync();
|
|
160
|
+
return;
|
|
161
|
+
}
|
|
162
|
+
for (let a = 0; a < h.maps.length; a++) this.maps.set(t + a, h.maps[a]);
|
|
163
|
+
for (const a of this.maps.keys()) a < h.version - N && this.maps.delete(a);
|
|
164
|
+
this.version = h.version, this.unconfirmed = h.unconfirmed, h.tr && i.view.dispatch(h.tr), n && (h.confirmed > 0 || h.tr) && (this.sentCount = 0), this.noteConfirmed(), this.placeEarlyCursors(), this.send(), this.closeWhenIdle && this.maybeClose(), h.confirmed > 0 && this.scheduleCursor();
|
|
165
|
+
}
|
|
166
|
+
onCursor(t) {
|
|
167
|
+
var e, i, s, n;
|
|
168
|
+
if (!(typeof (t == null ? void 0 : t.clientID) != "string" || t.clientID === this.clientID)) {
|
|
169
|
+
if (!this.live) {
|
|
170
|
+
if (!this.diverged) return;
|
|
171
|
+
t.clear ? this.apart.delete(t.clientID) : this.apart.set(t.clientID, {
|
|
172
|
+
name: String(((e = t.user) == null ? void 0 : e.name) ?? "Someone").slice(0, 80),
|
|
173
|
+
color: y(String(((i = t.user) == null ? void 0 : i.id) ?? t.clientID))
|
|
174
|
+
}), (n = (s = this.host).onPeers) == null || n.call(s, this.uniquePeople([...this.apart.values()]));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
if (t.clear) {
|
|
178
|
+
this.peers.delete(t.clientID) && this.renderPeers();
|
|
179
|
+
return;
|
|
180
|
+
}
|
|
181
|
+
if (Number(t.version) > this.version) {
|
|
182
|
+
this.early = [...this.early.filter((h) => h.p.clientID !== t.clientID), { p: t }].slice(-20);
|
|
183
|
+
return;
|
|
184
|
+
}
|
|
185
|
+
this.placeCursor(t);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
onEnded() {
|
|
189
|
+
this.live && (this.leaveLive(), this.member = !1, this.host.fieldDirty() || (this.resetTimer && clearTimeout(this.resetTimer), this.resetTimer = setTimeout(() => {
|
|
190
|
+
this.resetTimer = null, !(this.disposed || this.live || this.host.fieldDirty()) && this.host.resetTo(this.host.formValue());
|
|
191
|
+
}, F)), this.editor.isFocused && this.write && this.open());
|
|
192
|
+
}
|
|
193
|
+
// ── Entering and leaving ────────────────────────────────────────────────────
|
|
194
|
+
enter(t) {
|
|
195
|
+
var h, a, c;
|
|
196
|
+
const e = this.editor;
|
|
197
|
+
let i;
|
|
198
|
+
try {
|
|
199
|
+
i = A(e.state, t);
|
|
200
|
+
} catch {
|
|
201
|
+
return;
|
|
202
|
+
}
|
|
203
|
+
const s = e.state.doc;
|
|
204
|
+
let n = [];
|
|
205
|
+
if ((h = this.pending) != null && h.doc.eq(i))
|
|
206
|
+
n = this.pending.steps;
|
|
207
|
+
else if (!s.eq(i)) {
|
|
208
|
+
if (this.typedApart || this.host.fieldDirty()) {
|
|
209
|
+
this.setDiverged(!0), this.pending = null;
|
|
210
|
+
return;
|
|
211
|
+
}
|
|
212
|
+
const r = e.state.tr.replaceWith(0, s.content.size, i.content);
|
|
213
|
+
r.setMeta(v, !0), r.setMeta("addToHistory", !1), e.view.dispatch(r);
|
|
214
|
+
}
|
|
215
|
+
this.pending = null, this.setDiverged(!1), this.resetTimer && (clearTimeout(this.resetTimer), this.resetTimer = null), this.live = !0, (c = (a = this.host).onLive) == null || c.call(a, !0), this.sid = t.sid, this.version = t.version, this.unconfirmed = n, this.sentCount = 0, this.maps.clear(), m(this.target.collection, this.target.item, this.target.field, !0), this.noteConfirmed(), this.editor.isFocused && this.write && !this.member && this.open(), this.send();
|
|
216
|
+
}
|
|
217
|
+
leaveLive() {
|
|
218
|
+
var t, e;
|
|
219
|
+
this.live && (this.live = !1, (e = (t = this.host).onLive) == null || e.call(t, !1), this.sid = null, this.unconfirmed = [], this.sentCount = 0, this.closeWhenIdle = !1, this.early = [], this.peers.size && (this.peers.clear(), this.renderPeers()), this.heartbeatTimer && (clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), m(this.target.collection, this.target.item, this.target.field, !1));
|
|
220
|
+
}
|
|
221
|
+
resync() {
|
|
222
|
+
this.leaveLive(), this.transport.emit("coedit:sync", { ...this.target });
|
|
223
|
+
}
|
|
224
|
+
setDiverged(t) {
|
|
225
|
+
var e, i, s, n;
|
|
226
|
+
this.diverged !== t && (this.diverged = t, !t && this.apart.size && (this.apart.clear(), (i = (e = this.host).onPeers) == null || i.call(e, [])), (n = (s = this.host).onDiverged) == null || n.call(s, t));
|
|
227
|
+
}
|
|
228
|
+
// ── Our side ────────────────────────────────────────────────────────────────
|
|
229
|
+
open() {
|
|
230
|
+
!this.write || this.disposed || (this.member = !0, this.closeWhenIdle = !1, this.live || (this.pending = { doc: this.editor.state.doc, steps: [] }), this.transport.emit("coedit:open", {
|
|
231
|
+
...this.target,
|
|
232
|
+
clientID: this.clientID,
|
|
233
|
+
doc: this.editor.state.doc.toJSON()
|
|
234
|
+
}), this.heartbeatTimer || (this.heartbeatTimer = setInterval(() => this.sendCursor(!0), _)));
|
|
235
|
+
}
|
|
236
|
+
onFocus() {
|
|
237
|
+
this.write && !this.member && this.editor.isEditable ? this.open() : this.scheduleCursor();
|
|
238
|
+
}
|
|
239
|
+
onBlur() {
|
|
240
|
+
this.member && (this.transport.emit("coedit:cursor", { ...this.target, clientID: this.clientID, clear: !0 }), this.closeWhenIdle = !0, this.maybeClose());
|
|
241
|
+
}
|
|
242
|
+
/** Leave the session once everything we typed is in (never with steps still unsent). */
|
|
243
|
+
maybeClose() {
|
|
244
|
+
if (!this.member || this.editor.isFocused) {
|
|
245
|
+
this.closeWhenIdle = !1;
|
|
246
|
+
return;
|
|
247
|
+
}
|
|
248
|
+
this.live && this.unconfirmed.length > 0 || (this.closeWhenIdle = !1, this.member = !1, this.pending = null, this.heartbeatTimer && (clearInterval(this.heartbeatTimer), this.heartbeatTimer = null), this.transport.emit("coedit:close", { ...this.target, clientID: this.clientID }));
|
|
249
|
+
}
|
|
250
|
+
onTransaction(t) {
|
|
251
|
+
if (t.docChanged) {
|
|
252
|
+
for (const e of this.peers.values())
|
|
253
|
+
e.anchor = t.mapping.map(e.anchor, -1), e.head = t.mapping.map(e.head, 1);
|
|
254
|
+
if (!t.getMeta(v))
|
|
255
|
+
if (this.live) {
|
|
256
|
+
for (let e = 0; e < t.steps.length; e++)
|
|
257
|
+
this.unconfirmed.push(p(t.steps[e], t.docs[e]));
|
|
258
|
+
this.send();
|
|
259
|
+
} else if (this.pending)
|
|
260
|
+
for (let e = 0; e < t.steps.length; e++)
|
|
261
|
+
this.pending.steps.push(p(t.steps[e], t.docs[e]));
|
|
262
|
+
else t.getMeta("preventUpdate") || (this.typedApart = !0);
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
/** Send the unconfirmed steps (one batch in flight at a time). */
|
|
266
|
+
send() {
|
|
267
|
+
if (!this.live || !this.member || this.unconfirmed.length === 0) return;
|
|
268
|
+
const t = Date.now();
|
|
269
|
+
if (this.sentCount > 0 && t - this.sentAt < u) {
|
|
270
|
+
this.armRetry();
|
|
271
|
+
return;
|
|
272
|
+
}
|
|
273
|
+
const e = this.unconfirmed.slice(0, 200);
|
|
274
|
+
this.sentCount = e.length, this.sentAt = t, this.transport.emit("coedit:steps", {
|
|
275
|
+
...this.target,
|
|
276
|
+
clientID: this.clientID,
|
|
277
|
+
sid: this.sid,
|
|
278
|
+
version: this.version,
|
|
279
|
+
steps: e.map((i) => i.step.toJSON())
|
|
280
|
+
}), this.armRetry();
|
|
281
|
+
}
|
|
282
|
+
armRetry() {
|
|
283
|
+
this.retryTimer || (this.retryTimer = setTimeout(() => {
|
|
284
|
+
this.retryTimer = null, this.sentCount > 0 && Date.now() - this.sentAt >= u && (this.sentCount = 0), this.send();
|
|
285
|
+
}, u));
|
|
286
|
+
}
|
|
287
|
+
scheduleCursor() {
|
|
288
|
+
if (!this.live || !this.member || !this.editor.isFocused || this.cursorTimer) return;
|
|
289
|
+
const t = Math.max(0, L - (Date.now() - this.lastCursorAt));
|
|
290
|
+
this.cursorTimer = setTimeout(() => {
|
|
291
|
+
this.cursorTimer = null, this.sendCursor(!1);
|
|
292
|
+
}, t);
|
|
293
|
+
}
|
|
294
|
+
/** Our selection, at the confirmed version (others can place it); also the heartbeat. */
|
|
295
|
+
sendCursor(t) {
|
|
296
|
+
if (!this.live || !this.member || this.disposed) return;
|
|
297
|
+
if (!this.editor.isFocused) {
|
|
298
|
+
t && this.transport.emit("coedit:cursor", {
|
|
299
|
+
...this.target,
|
|
300
|
+
clientID: this.clientID,
|
|
301
|
+
clear: !0
|
|
302
|
+
});
|
|
303
|
+
return;
|
|
304
|
+
}
|
|
305
|
+
if (this.unconfirmed.length > 0) return;
|
|
306
|
+
const { anchor: e, head: i } = this.editor.state.selection;
|
|
307
|
+
this.lastCursorAt = Date.now(), this.transport.emit("coedit:cursor", {
|
|
308
|
+
...this.target,
|
|
309
|
+
clientID: this.clientID,
|
|
310
|
+
version: this.version,
|
|
311
|
+
anchor: e,
|
|
312
|
+
head: i
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
// ── Cursors of others ──────────────────────────────────────────────────────
|
|
316
|
+
placeCursor(t) {
|
|
317
|
+
var a, c;
|
|
318
|
+
let e = Number(t.anchor), i = Number(t.head);
|
|
319
|
+
for (let r = Number(t.version); r < this.version; r++) {
|
|
320
|
+
const d = this.maps.get(r);
|
|
321
|
+
if (!d) return;
|
|
322
|
+
e = d.map(e, -1), i = d.map(i, 1);
|
|
323
|
+
}
|
|
324
|
+
for (const r of this.unconfirmed) {
|
|
325
|
+
const d = r.step.getMap();
|
|
326
|
+
e = d.map(e, -1), i = d.map(i, 1);
|
|
327
|
+
}
|
|
328
|
+
const s = this.editor.state.doc.content.size, n = (r) => Math.max(0, Math.min(s, r)), h = String(((a = t.user) == null ? void 0 : a.id) ?? "");
|
|
329
|
+
this.peers.set(t.clientID, {
|
|
330
|
+
clientID: t.clientID,
|
|
331
|
+
name: String(((c = t.user) == null ? void 0 : c.name) ?? "Someone").slice(0, 80),
|
|
332
|
+
color: y(h || t.clientID),
|
|
333
|
+
userId: h,
|
|
334
|
+
anchor: n(e),
|
|
335
|
+
head: n(i)
|
|
336
|
+
}), this.renderPeers(t.clientID);
|
|
337
|
+
}
|
|
338
|
+
placeEarlyCursors() {
|
|
339
|
+
if (this.early.length === 0) return;
|
|
340
|
+
const t = this.early.filter((e) => Number(e.p.version) <= this.version);
|
|
341
|
+
this.early = this.early.filter((e) => Number(e.p.version) > this.version);
|
|
342
|
+
for (const e of t) this.placeCursor(e.p);
|
|
343
|
+
}
|
|
344
|
+
renderPeers(t) {
|
|
345
|
+
var i, s;
|
|
346
|
+
const e = [...this.peers.values()].map((n) => ({
|
|
347
|
+
id: n.clientID,
|
|
348
|
+
name: n.name,
|
|
349
|
+
color: n.color,
|
|
350
|
+
anchor: n.anchor,
|
|
351
|
+
head: n.head
|
|
352
|
+
}));
|
|
353
|
+
M(this.editor, e, t), (s = (i = this.host).onPeers) == null || s.call(
|
|
354
|
+
i,
|
|
355
|
+
this.uniquePeople([...this.peers.values()].map((n) => ({ name: n.name, color: n.color })))
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
uniquePeople(t) {
|
|
359
|
+
const e = /* @__PURE__ */ new Map();
|
|
360
|
+
for (const i of t) e.has(i.name) || e.set(i.name, i);
|
|
361
|
+
return [...e.values()];
|
|
362
|
+
}
|
|
363
|
+
/** Remember the confirmed document state (a save of it is no conflict, coedit-registry). */
|
|
364
|
+
noteConfirmed() {
|
|
365
|
+
if (this.live)
|
|
366
|
+
try {
|
|
367
|
+
const t = w(this.editor.state, this.unconfirmed);
|
|
368
|
+
I(
|
|
369
|
+
this.target.collection,
|
|
370
|
+
this.target.item,
|
|
371
|
+
this.target.field,
|
|
372
|
+
E(t, this.editor.schema)
|
|
373
|
+
);
|
|
374
|
+
} catch {
|
|
375
|
+
}
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
export {
|
|
379
|
+
g as COEDIT_COLORS,
|
|
380
|
+
B as CoeditSession,
|
|
381
|
+
y as coeditColor
|
|
382
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { useState as u, useRef as m, useEffect as P } from "react";
|
|
2
|
+
import { useOptionalRealtime as H, useRealtimeStatus as M } from "../../../lib/realtime.js";
|
|
3
|
+
import { CoeditSession as O } from "./session.js";
|
|
4
|
+
const U = (s, e) => (s ?? "") === (e ?? "");
|
|
5
|
+
function k(s, e, w, R) {
|
|
6
|
+
const l = H(), n = M(), [i, S] = u(null), [T, C] = u(!1), [x, L] = u([]), [E, h] = u(!1), t = m(w);
|
|
7
|
+
t.current = w;
|
|
8
|
+
const f = m(e == null ? void 0 : e.saved);
|
|
9
|
+
f.current = e == null ? void 0 : e.saved;
|
|
10
|
+
const y = m(R);
|
|
11
|
+
y.current = R;
|
|
12
|
+
const d = e == null ? void 0 : e.collection, p = e == null ? void 0 : e.item, v = e == null ? void 0 : e.field;
|
|
13
|
+
P(() => {
|
|
14
|
+
if (!s || !l || !d || !p || !v) return;
|
|
15
|
+
const D = new O(
|
|
16
|
+
s,
|
|
17
|
+
{ collection: d, item: p, field: v },
|
|
18
|
+
{
|
|
19
|
+
emit: (o, c) => l.emit(o, c),
|
|
20
|
+
on: (o, c) => l.on(o, c)
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
fieldDirty: () => {
|
|
24
|
+
var o;
|
|
25
|
+
return !U(t.current, (o = f.current) == null ? void 0 : o.call(f));
|
|
26
|
+
},
|
|
27
|
+
formValue: () => t.current,
|
|
28
|
+
resetTo: (o) => {
|
|
29
|
+
if (s.isDestroyed) return;
|
|
30
|
+
const c = y.current(o);
|
|
31
|
+
s.getHTML() !== c && s.commands.setContent(c, { emitUpdate: !1 });
|
|
32
|
+
},
|
|
33
|
+
onDiverged: C,
|
|
34
|
+
onPeers: L,
|
|
35
|
+
onLive: h
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
return D.start(), S(D), () => {
|
|
39
|
+
D.dispose(), S(null), C(!1), L([]), h(!1);
|
|
40
|
+
};
|
|
41
|
+
}, [s, l, d, p, v]);
|
|
42
|
+
const r = m(!1);
|
|
43
|
+
return P(() => {
|
|
44
|
+
i && ((n == null ? void 0 : n.state) === "reconnecting" ? (r.current || i.disconnected(), r.current = !0) : r.current && (n == null ? void 0 : n.state) === "live" && (r.current = !1, i.watch()));
|
|
45
|
+
}, [n == null ? void 0 : n.state, i]), { session: i, diverged: T, peers: x, live: E };
|
|
46
|
+
}
|
|
47
|
+
export {
|
|
48
|
+
k as useCoedit
|
|
49
|
+
};
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { jsxs as E, jsx as m } from "react/jsx-runtime";
|
|
2
|
+
import { FileX as F } from "lucide-react";
|
|
3
|
+
import { useRef as S, useState as w, useEffect as v } from "react";
|
|
4
|
+
const b = 6e3, R = 600, N = 15e3, a = (t) => t.toLowerCase();
|
|
5
|
+
function _(t, i, f, g = Date.now()) {
|
|
6
|
+
if (t == null) return { arrived: [], gone: [] };
|
|
7
|
+
const l = (n) => {
|
|
8
|
+
const d = f.get(a(n));
|
|
9
|
+
return d != null && g - d < N;
|
|
10
|
+
}, h = new Set(t.map(a)), c = new Set(i.map(a));
|
|
11
|
+
return {
|
|
12
|
+
arrived: i.filter((n) => !h.has(a(n)) && !l(n)),
|
|
13
|
+
gone: t.filter((n) => !c.has(a(n)) && !l(n))
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
function M(t, i) {
|
|
17
|
+
t.current.set(a(i), Date.now());
|
|
18
|
+
}
|
|
19
|
+
function O(t, i) {
|
|
20
|
+
const f = S(null), [g, l] = w(() => /* @__PURE__ */ new Set()), [h, c] = w([]), [n, d] = w(() => /* @__PURE__ */ new Set()), p = S(/* @__PURE__ */ new Set()), x = (o, s) => {
|
|
21
|
+
const e = setTimeout(() => {
|
|
22
|
+
p.current.delete(e), o();
|
|
23
|
+
}, s);
|
|
24
|
+
p.current.add(e);
|
|
25
|
+
}, k = t == null ? null : [...t].map(a).sort().join(",");
|
|
26
|
+
return v(() => {
|
|
27
|
+
if (t == null) return;
|
|
28
|
+
const { arrived: o, gone: s } = _(f.current, t, i.current);
|
|
29
|
+
f.current = [...t], o.length > 0 && (l((e) => /* @__PURE__ */ new Set([...e, ...o])), c((e) => e.filter((r) => !o.some((u) => a(u) === a(r)))), x(
|
|
30
|
+
() => l((e) => {
|
|
31
|
+
const r = new Set(e);
|
|
32
|
+
for (const u of o) r.delete(u);
|
|
33
|
+
return r;
|
|
34
|
+
}),
|
|
35
|
+
2e3
|
|
36
|
+
)), s.length > 0 && (c((e) => [...e, ...s.filter((r) => !e.includes(r))]), x(
|
|
37
|
+
() => d((e) => /* @__PURE__ */ new Set([...e, ...s])),
|
|
38
|
+
b - R
|
|
39
|
+
), x(() => {
|
|
40
|
+
c((e) => e.filter((r) => !s.includes(r))), d((e) => {
|
|
41
|
+
const r = new Set(e);
|
|
42
|
+
for (const u of s) r.delete(u);
|
|
43
|
+
return r;
|
|
44
|
+
});
|
|
45
|
+
}, b));
|
|
46
|
+
}, [k]), v(() => {
|
|
47
|
+
const o = p.current;
|
|
48
|
+
return () => {
|
|
49
|
+
for (const s of o) clearTimeout(s);
|
|
50
|
+
o.clear();
|
|
51
|
+
};
|
|
52
|
+
}, []), { fresh: g, removed: h, leaving: n };
|
|
53
|
+
}
|
|
54
|
+
function j({ name: t, leaving: i }) {
|
|
55
|
+
return /* @__PURE__ */ E(
|
|
56
|
+
"div",
|
|
57
|
+
{
|
|
58
|
+
"data-file-removed": !0,
|
|
59
|
+
"aria-live": "polite",
|
|
60
|
+
className: `flex items-center gap-2 rounded-lg border border-dashed border-slate-200 p-2 transition-opacity duration-500 motion-reduce:transition-none dark:border-border ${i ? "opacity-0" : "opacity-100"}`,
|
|
61
|
+
children: [
|
|
62
|
+
/* @__PURE__ */ m("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded bg-slate-100 dark:bg-muted", children: /* @__PURE__ */ m(F, { className: "h-4 w-4 text-slate-400 dark:text-muted-foreground" }) }),
|
|
63
|
+
/* @__PURE__ */ m("p", { className: "min-w-0 flex-1 truncate text-[12px] text-slate-500 line-through decoration-slate-300 dark:text-muted-foreground dark:decoration-border", children: t }),
|
|
64
|
+
/* @__PURE__ */ m("span", { className: "shrink-0 rounded bg-slate-100 px-1.5 py-0.5 text-[10px] font-medium text-slate-600 dark:bg-muted dark:text-muted-foreground", children: "Removed" })
|
|
65
|
+
]
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
export {
|
|
70
|
+
N as OWN_FILE_CHANGE_MS,
|
|
71
|
+
R as REMOVED_FADE_MS,
|
|
72
|
+
b as REMOVED_SHOW_MS,
|
|
73
|
+
j as RemovedFileRow,
|
|
74
|
+
_ as diffFileIds,
|
|
75
|
+
M as noteOwnFileChange,
|
|
76
|
+
O as useLiveFileList
|
|
77
|
+
};
|