@nivaro/react 0.2.53 → 0.2.55
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/full.css +1 -1
- package/dist/hooks/useSessionRecorder.js +99 -98
- package/dist/index.d.ts +452 -4
- package/dist/index.js +644 -618
- package/dist/layout-editor.d.ts +252 -2
- package/dist/shared/components/BackgroundRunOffer.js +117 -0
- package/dist/shared/components/BroadcastView.js +214 -213
- package/dist/shared/components/CollectionBrowserView.js +2592 -2695
- package/dist/shared/components/FormWhatsNew.js +60 -0
- package/dist/shared/components/ItemEditForm.js +3968 -3618
- package/dist/shared/components/JobsTray.js +100 -55
- package/dist/shared/components/MyWorkView.js +91 -89
- package/dist/shared/components/NotificationBell.js +80 -79
- package/dist/shared/components/ProfileView.js +568 -520
- package/dist/shared/components/RecordCompare.js +254 -0
- package/dist/shared/components/RecordReadView.js +598 -543
- package/dist/shared/components/ReportView.js +578 -543
- package/dist/shared/components/RowPresence.js +91 -0
- package/dist/shared/components/TipLayer.js +27 -27
- package/dist/shared/components/WidgetSlot.js +474 -458
- package/dist/shared/components/ai/AiAnalyticsView.js +16 -6
- package/dist/shared/components/ai/AskPanel.js +139 -119
- package/dist/shared/components/ai/FirstWeekCard.js +126 -0
- package/dist/shared/components/bulk/BulkFieldUpdate.js +289 -0
- package/dist/shared/components/bulk/bulk-field-options.js +45 -0
- package/dist/shared/components/charts/CumulativeFlowChart.js +176 -0
- package/dist/shared/components/chat/ChannelArchive.js +326 -0
- package/dist/shared/components/chat/ChannelExtras.js +141 -121
- package/dist/shared/components/chat/ChatAnalyticsView.js +112 -110
- package/dist/shared/components/chat/ChatPanel.js +1695 -1733
- package/dist/shared/components/chat/Composer.js +357 -303
- package/dist/shared/components/chat/MessageActions.js +92 -0
- package/dist/shared/components/chat/MessageFormat.js +290 -264
- package/dist/shared/components/chat/OutboxBubbles.js +146 -0
- package/dist/shared/components/chat/RequestIdCard.js +135 -0
- package/dist/shared/components/chat/RoomHeaderMenu.js +202 -0
- package/dist/shared/components/chat/RoomParts.js +213 -274
- package/dist/shared/components/chat/ScreenClip.js +184 -0
- package/dist/shared/components/chat/chat-core.js +402 -483
- package/dist/shared/components/chat/chat-drafts.js +59 -0
- package/dist/shared/components/chat/chat-emoji.js +348 -0
- package/dist/shared/components/chat/chat-local-time.js +41 -0
- package/dist/shared/components/chat/chat-outbox.js +303 -0
- package/dist/shared/components/chat/chat-window.js +163 -0
- package/dist/shared/components/chat/huddle/HuddleControls.js +143 -0
- package/dist/shared/components/chat/huddle/HuddleStage.js +164 -0
- package/dist/shared/components/chat/huddle/huddle-store.js +342 -0
- package/dist/shared/components/chat/huddle/useHuddle.js +58 -0
- package/dist/shared/components/help-videos/api.js +80 -67
- package/dist/shared/components/help-videos/editor/DetailsTab.js +147 -130
- package/dist/shared/components/item-edit/CatalogPickerField.js +113 -112
- package/dist/shared/components/item-edit/ChangeReasonDialog.js +13 -13
- package/dist/shared/components/item-edit/FieldAffordances.js +9 -8
- package/dist/shared/components/item-edit/FieldRenderer.js +248 -245
- package/dist/shared/components/item-edit/FieldRow.js +382 -320
- package/dist/shared/components/item-edit/FormHelpVideoButton.js +59 -0
- package/dist/shared/components/item-edit/GroupSection.js +786 -639
- package/dist/shared/components/item-edit/HeaderTools.js +59 -56
- package/dist/shared/components/item-edit/InlineTableField.js +3 -1
- package/dist/shared/components/item-edit/LayoutContentBlock.js +47 -24
- package/dist/shared/components/item-edit/RelationCombobox.js +186 -176
- package/dist/shared/components/item-edit/entry/EntryStrip.js +54 -0
- package/dist/shared/components/item-edit/entry/entry-keys.js +27 -0
- package/dist/shared/components/item-edit/entry/useEntryKeyboard.js +70 -0
- package/dist/shared/components/item-edit/entry/useEntryMode.js +59 -0
- package/dist/shared/components/item-edit/form-structure-ui.js +105 -0
- package/dist/shared/components/item-edit/lazy-sections.js +36 -0
- package/dist/shared/components/item-edit/lock-why.js +94 -0
- package/dist/shared/components/item-edit/picker-miss.js +26 -0
- package/dist/shared/components/item-edit/placement-behaviour.js +196 -0
- package/dist/shared/components/item-edit/useFormUsageBeacon.js +65 -0
- package/dist/shared/components/layout-editor/AddPanel.js +226 -151
- package/dist/shared/components/layout-editor/ArrangeButton.js +34 -0
- package/dist/shared/components/layout-editor/AutoArrange.js +86 -0
- package/dist/shared/components/layout-editor/CanvasCompare.js +79 -0
- package/dist/shared/components/layout-editor/ChangeNote.js +147 -0
- package/dist/shared/components/layout-editor/CollabParts.js +175 -0
- package/dist/shared/components/layout-editor/DesignNode.js +311 -116
- package/dist/shared/components/layout-editor/EditorCanvas.js +30 -26
- package/dist/shared/components/layout-editor/EditorTopBar.js +463 -175
- package/dist/shared/components/layout-editor/FindReplace.js +188 -0
- package/dist/shared/components/layout-editor/FormMapButton.js +141 -0
- package/dist/shared/components/layout-editor/HistoryPanel.js +250 -109
- package/dist/shared/components/layout-editor/LayoutEditor.js +1196 -305
- package/dist/shared/components/layout-editor/LayoutsRail.js +94 -67
- package/dist/shared/components/layout-editor/NoteMarker.js +38 -0
- package/dist/shared/components/layout-editor/PlacementsTable.js +187 -0
- package/dist/shared/components/layout-editor/RestorePiece.js +143 -0
- package/dist/shared/components/layout-editor/ScheduleChange.js +106 -0
- package/dist/shared/components/layout-editor/SessionHistory.js +84 -0
- package/dist/shared/components/layout-editor/StagedChip.js +22 -0
- package/dist/shared/components/layout-editor/StructureMenu.js +464 -0
- package/dist/shared/components/layout-editor/UnsavedConfirm.js +103 -0
- package/dist/shared/components/layout-editor/ai/AiToolsButton.js +625 -0
- package/dist/shared/components/layout-editor/ai/ChangeCheck.js +153 -0
- package/dist/shared/components/layout-editor/ai/ai-tools-api.js +80 -0
- package/dist/shared/components/layout-editor/ai/assist-ops.js +38 -0
- package/dist/shared/components/layout-editor/ai/autofill-ops.js +73 -0
- package/dist/shared/components/layout-editor/ai/canvas-capture.js +41 -0
- package/dist/shared/components/layout-editor/ai-forms/AiComposer.js +271 -0
- package/dist/shared/components/layout-editor/ai-forms/AiFormsButton.js +182 -0
- package/dist/shared/components/layout-editor/ai-forms/MeaningSuggestions.js +109 -0
- package/dist/shared/components/layout-editor/ai-forms/SlimPanel.js +170 -0
- package/dist/shared/components/layout-editor/ai-forms/ai-forms-api.js +40 -0
- package/dist/shared/components/layout-editor/ai-forms/pending.js +25 -0
- package/dist/shared/components/layout-editor/ai-forms/plan.js +263 -0
- package/dist/shared/components/layout-editor/ai-rules/AiAskPopover.js +160 -0
- package/dist/shared/components/layout-editor/ai-rules/CascadeWriter.js +175 -0
- package/dist/shared/components/layout-editor/ai-rules/FieldRuleWriter.js +97 -0
- package/dist/shared/components/layout-editor/ai-rules/RuleWriter.js +94 -0
- package/dist/shared/components/layout-editor/ai-rules/ValidationSuggest.js +153 -0
- package/dist/shared/components/layout-editor/ai-rules/api.js +6 -0
- package/dist/shared/components/layout-editor/ai-text/AiTextTools.js +383 -0
- package/dist/shared/components/layout-editor/ai-text/text-ops.js +125 -0
- package/dist/shared/components/layout-editor/assist/AskPanel.js +278 -0
- package/dist/shared/components/layout-editor/assist/ExplainDiff.js +93 -0
- package/dist/shared/components/layout-editor/assist/ProposalsButton.js +150 -0
- package/dist/shared/components/layout-editor/assist/assist-api.js +63 -0
- package/dist/shared/components/layout-editor/assist/jump.js +142 -0
- package/dist/shared/components/layout-editor/assist/settings-index.js +118 -0
- package/dist/shared/components/layout-editor/auto-arrange.js +101 -0
- package/dist/shared/components/layout-editor/bulk/BulkChangesButton.js +221 -0
- package/dist/shared/components/layout-editor/bulk/BulkRun.js +237 -0
- package/dist/shared/components/layout-editor/bulk/MacrosPanel.js +230 -0
- package/dist/shared/components/layout-editor/bulk/bulk-api.js +65 -0
- package/dist/shared/components/layout-editor/bulk/field-labels.js +22 -0
- package/dist/shared/components/layout-editor/bulk/macro-record.js +142 -0
- package/dist/shared/components/layout-editor/bulk/useMacroRecorder.js +65 -0
- package/dist/shared/components/layout-editor/bundle-to-active.js +1 -0
- package/dist/shared/components/layout-editor/canvas-diff.js +157 -0
- package/dist/shared/components/layout-editor/collab/FormFollowShare.js +388 -0
- package/dist/shared/components/layout-editor/collab/collab-api.js +80 -0
- package/dist/shared/components/layout-editor/commands/CommandPalette.js +221 -0
- package/dist/shared/components/layout-editor/commands/intents.js +214 -0
- package/dist/shared/components/layout-editor/commands/parse.js +242 -0
- package/dist/shared/components/layout-editor/design-context.js +26 -6
- package/dist/shared/components/layout-editor/dnd/LayoutDndProvider.js +181 -164
- package/dist/shared/components/layout-editor/dnd/collision.js +25 -23
- package/dist/shared/components/layout-editor/dnd/node.js +69 -57
- package/dist/shared/components/layout-editor/dnd/rail-drop.js +56 -0
- package/dist/shared/components/layout-editor/draft-recovery.js +131 -0
- package/dist/shared/components/layout-editor/editor-notes.js +78 -0
- package/dist/shared/components/layout-editor/editors/swap-config.js +1 -0
- package/dist/shared/components/layout-editor/entry/PlacementPresets.js +149 -0
- package/dist/shared/components/layout-editor/entry/entry-editor-context.js +10 -0
- package/dist/shared/components/layout-editor/entry/presets.js +71 -0
- package/dist/shared/components/layout-editor/entry/tab-order.js +110 -0
- package/dist/shared/components/layout-editor/entry/theme-preview.js +37 -0
- package/dist/shared/components/layout-editor/explain/CanvasRules.js +142 -0
- package/dist/shared/components/layout-editor/explain/default-ghosts.js +81 -0
- package/dist/shared/components/layout-editor/explain/driver-hover.js +62 -0
- package/dist/shared/components/layout-editor/explain/field-sources.js +246 -0
- package/dist/shared/components/layout-editor/explain/rule-graph.js +215 -0
- package/dist/shared/components/layout-editor/explain/use-explain.js +132 -0
- package/dist/shared/components/layout-editor/field-zones.js +116 -0
- package/dist/shared/components/layout-editor/form-map.js +138 -0
- package/dist/shared/components/layout-editor/grid-guides.js +142 -0
- package/dist/shared/components/layout-editor/history-api.js +87 -0
- package/dist/shared/components/layout-editor/inheritance.js +55 -0
- package/dist/shared/components/layout-editor/inspect/inspect-api.js +66 -0
- package/dist/shared/components/layout-editor/inspect/picker-preview.js +48 -0
- package/dist/shared/components/layout-editor/inspect/width-fit.js +87 -0
- package/dist/shared/components/layout-editor/inspector/AiFillSetting.js +85 -0
- package/dist/shared/components/layout-editor/inspector/BehaviourSettings.js +402 -0
- package/dist/shared/components/layout-editor/inspector/Breadcrumb.js +36 -0
- package/dist/shared/components/layout-editor/inspector/BulkInspector.js +179 -0
- package/dist/shared/components/layout-editor/inspector/ColumnFit.js +112 -0
- package/dist/shared/components/layout-editor/inspector/GroupInspector.js +291 -141
- package/dist/shared/components/layout-editor/inspector/HelpTab.js +174 -0
- package/dist/shared/components/layout-editor/inspector/Inspector.js +282 -180
- package/dist/shared/components/layout-editor/inspector/LookTab.js +166 -109
- package/dist/shared/components/layout-editor/inspector/OverrideNotice.js +61 -0
- package/dist/shared/components/layout-editor/inspector/PickerMisses.js +129 -0
- package/dist/shared/components/layout-editor/inspector/PickerPreview.js +134 -0
- package/dist/shared/components/layout-editor/inspector/PickerTab.js +146 -118
- package/dist/shared/components/layout-editor/inspector/RulesTab.js +162 -111
- package/dist/shared/components/layout-editor/inspector/Translations.js +156 -0
- package/dist/shared/components/layout-editor/inspector/kit.js +71 -70
- package/dist/shared/components/layout-editor/inspector/tab-request.js +21 -0
- package/dist/shared/components/layout-editor/is-typing.js +9 -0
- package/dist/shared/components/layout-editor/keyboard-move.js +66 -0
- package/dist/shared/components/layout-editor/lint/LintPanel.js +190 -0
- package/dist/shared/components/layout-editor/lint/lint-api.js +52 -0
- package/dist/shared/components/layout-editor/load-error.js +37 -0
- package/dist/shared/components/layout-editor/matrix/FieldStateMatrix.js +305 -0
- package/dist/shared/components/layout-editor/matrix/MatrixGrid.js +181 -0
- package/dist/shared/components/layout-editor/matrix/RoleSectionMatrix.js +147 -0
- package/dist/shared/components/layout-editor/matrix/matrix-api.js +48 -0
- package/dist/shared/components/layout-editor/matrix/role-matrix.js +36 -0
- package/dist/shared/components/layout-editor/matrix/state-matrix.js +145 -0
- package/dist/shared/components/layout-editor/nav/FindPanel.js +109 -0
- package/dist/shared/components/layout-editor/nav/NavTools.js +114 -0
- package/dist/shared/components/layout-editor/nav/OutlinePanel.js +228 -0
- package/dist/shared/components/layout-editor/nav/ShortcutSheet.js +31 -0
- package/dist/shared/components/layout-editor/nav/find.js +20 -0
- package/dist/shared/components/layout-editor/nav/tree.js +142 -0
- package/dist/shared/components/layout-editor/nav/useEditorNav.js +101 -0
- package/dist/shared/components/layout-editor/nav/view-prefs.js +34 -0
- package/dist/shared/components/layout-editor/ops/ChangeRequestsPanel.js +143 -0
- package/dist/shared/components/layout-editor/ops/DependencyDiagram.js +179 -0
- package/dist/shared/components/layout-editor/ops/LayoutOpsBlocks.js +92 -0
- package/dist/shared/components/layout-editor/ops/PromotePanel.js +287 -0
- package/dist/shared/components/layout-editor/ops/ops-api.js +122 -0
- package/dist/shared/components/layout-editor/outputs/OutputsButton.js +254 -0
- package/dist/shared/components/layout-editor/outputs/help-sheet.js +154 -0
- package/dist/shared/components/layout-editor/outputs/output-api.js +61 -0
- package/dist/shared/components/layout-editor/overview/OverviewActions.js +15 -3
- package/dist/shared/components/layout-editor/overview/describe-conditions.js +24 -14
- package/dist/shared/components/layout-editor/overview/overview-api.js +105 -88
- package/dist/shared/components/layout-editor/overview/purpose.js +15 -13
- package/dist/shared/components/layout-editor/panel-style.js +8 -7
- package/dist/shared/components/layout-editor/parity-keys.json.js +4 -0
- package/dist/shared/components/layout-editor/pin.js +25 -0
- package/dist/shared/components/layout-editor/presence.js +111 -0
- package/dist/shared/components/layout-editor/preview/PreviewModes.js +224 -0
- package/dist/shared/components/layout-editor/preview/PreviewPanes.js +262 -0
- package/dist/shared/components/layout-editor/preview/preview-api.js +57 -0
- package/dist/shared/components/layout-editor/preview/preview-model.js +157 -0
- package/dist/shared/components/layout-editor/restore-piece.js +192 -0
- package/dist/shared/components/layout-editor/reuse/FieldMapStep.js +70 -0
- package/dist/shared/components/layout-editor/reuse/FormMoreMenu.js +127 -0
- package/dist/shared/components/layout-editor/reuse/LibraryRows.js +150 -0
- package/dist/shared/components/layout-editor/reuse/NewFormStart.js +20 -0
- package/dist/shared/components/layout-editor/reuse/SectionReuseActions.js +291 -0
- package/dist/shared/components/layout-editor/reuse/field-match.js +77 -0
- package/dist/shared/components/layout-editor/reuse/reuse-api.js +73 -0
- package/dist/shared/components/layout-editor/reuse/seed.js +13 -0
- package/dist/shared/components/layout-editor/reuse/useFormFromRecord.js +43 -0
- package/dist/shared/components/layout-editor/reuse/useRailCopy.js +34 -0
- package/dist/shared/components/layout-editor/section-structure.js +241 -0
- package/dist/shared/components/layout-editor/settings/EntrySection.js +296 -0
- package/dist/shared/components/layout-editor/settings/FormSettings.js +125 -103
- package/dist/shared/components/layout-editor/settings/InheritanceSection.js +1 -1
- package/dist/shared/components/layout-editor/settings/ResolveSettings.js +255 -0
- package/dist/shared/components/layout-editor/settings/ToolsSection.js +215 -105
- package/dist/shared/components/layout-editor/settings/WhoSection.js +139 -100
- package/dist/shared/components/layout-editor/settings/controls.js +8 -8
- package/dist/shared/components/layout-editor/settings/settings-registry.js +142 -21
- package/dist/shared/components/layout-editor/shortcuts.js +88 -0
- package/dist/shared/components/layout-editor/show-when.js +35 -0
- package/dist/shared/components/layout-editor/slot-names.js +4 -3
- package/dist/shared/components/layout-editor/staged-api.js +64 -0
- package/dist/shared/components/layout-editor/structure-ops.js +403 -0
- package/dist/shared/components/layout-editor/testing/CostLimitSetting.js +42 -0
- package/dist/shared/components/layout-editor/testing/TestingPanels.js +556 -0
- package/dist/shared/components/layout-editor/testing/testing-api.js +67 -0
- package/dist/shared/components/layout-editor/testing/testing-model.js +406 -0
- package/dist/shared/components/layout-editor/testing/use-record-check.js +44 -0
- package/dist/shared/components/layout-editor/toolbar-kit.js +242 -0
- package/dist/shared/components/layout-editor/unsaved-marks.js +72 -0
- package/dist/shared/components/layout-editor/usage/AbTestSection.js +355 -0
- package/dist/shared/components/layout-editor/usage/FillChip.js +27 -0
- package/dist/shared/components/layout-editor/usage/UsagePanel.js +232 -0
- package/dist/shared/components/layout-editor/usage/ab-api.js +86 -0
- package/dist/shared/components/layout-editor/usage/suggest-collapse.js +32 -0
- package/dist/shared/components/layout-editor/usage/suggest-sections.js +55 -0
- package/dist/shared/components/layout-editor/usage/usage-api.js +104 -0
- package/dist/shared/components/layout-editor/useLayoutDraft.js +573 -306
- package/dist/shared/components/notifications/NotificationAnalyticsView.js +148 -77
- package/dist/shared/components/panels/ErpFailureBanner.js +18 -17
- package/dist/shared/components/panels/ExternalRequestsChip.js +63 -62
- package/dist/shared/components/pipeline/PipelineEditorView.js +106 -104
- package/dist/shared/components/profile/AgentsPanel.js +479 -0
- package/dist/shared/components/queue/QueueWorklist.js +1026 -1040
- package/dist/shared/components/support/SuggestFormChange.js +143 -0
- package/dist/shared/components/support/SupportAnalytics.js +171 -0
- package/dist/shared/components/support/SupportView.js +75 -73
- package/dist/shared/lib/ai-fill.js +37 -0
- package/dist/shared/lib/background-runs.js +150 -0
- package/dist/shared/lib/delivery-ack.js +9 -0
- package/dist/shared/lib/entry-badge-style.js +13 -0
- package/dist/shared/lib/entry-config.js +71 -0
- package/dist/shared/lib/form-sections.js +64 -0
- package/dist/shared/lib/form-structure.js +99 -0
- package/dist/shared/lib/form-usage-beacon.js +133 -0
- package/dist/shared/lib/jobs-tray.js +25 -23
- package/dist/shared/lib/keyset-pager.js +37 -0
- package/dist/shared/lib/layout-i18n.js +66 -0
- package/dist/shared/lib/layout-lint.js +490 -0
- package/dist/shared/lib/layout-ops.js +116 -110
- package/dist/shared/lib/layout-resolve.js +113 -0
- package/dist/shared/lib/placement-behaviour.js +144 -0
- package/dist/shared/lib/prefetch.js +149 -0
- package/dist/shared/lib/presence-hooks.js +199 -0
- package/dist/shared/lib/record-outbox.js +82 -81
- package/dist/shared/lib/replay-socket.js +93 -0
- package/dist/shared/lib/request-gate.js +51 -50
- package/dist/shared/lib/room-gaps.js +96 -0
- package/dist/shared/lib/screenshot.js +54 -28
- package/dist/shared/lib/search-log.js +27 -0
- package/dist/shared/lib/socket-realtime.js +101 -80
- package/dist/shared/lib/visible-when.js +34 -0
- package/dist/shared/lib/worker-socket.js +200 -0
- package/package.json +1 -1
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
import { useQueryClient as
|
|
5
|
-
import { useRef as
|
|
6
|
-
import { toast as
|
|
7
|
-
import { useNivaroClient as
|
|
8
|
-
import { get as
|
|
9
|
-
import { applyLayoutOps as
|
|
10
|
-
const
|
|
11
|
-
bundle: (
|
|
12
|
-
versions: (
|
|
13
|
-
},
|
|
1
|
+
var V = Object.defineProperty;
|
|
2
|
+
var B = (n, e, t) => e in n ? V(n, e, { enumerable: !0, configurable: !0, writable: !0, value: t }) : n[e] = t;
|
|
3
|
+
var c = (n, e, t) => B(n, typeof e != "symbol" ? e + "" : e, t);
|
|
4
|
+
import { useQueryClient as P, useQuery as z } from "@tanstack/react-query";
|
|
5
|
+
import { useState as Q, useRef as Y, useSyncExternalStore as G, useEffect as b, useCallback as p } from "react";
|
|
6
|
+
import { toast as H } from "sonner";
|
|
7
|
+
import { useNivaroClient as M } from "../../context.js";
|
|
8
|
+
import { get as J, post as X } from "../../lib/commands.js";
|
|
9
|
+
import { applyLayoutOps as f, isCanvasSlot as Z, GROUP_PATCH_KEYS as ee, PLACEMENT_PATCH_KEYS as te } from "../../lib/layout-ops.js";
|
|
10
|
+
const C = {
|
|
11
|
+
bundle: (n) => ["layout-editor", "bundle", n],
|
|
12
|
+
versions: (n) => ["layout-editor", "versions", n]
|
|
13
|
+
}, se = /* @__PURE__ */ new Set([
|
|
14
14
|
"name",
|
|
15
15
|
"slug",
|
|
16
16
|
"create_label",
|
|
@@ -23,291 +23,437 @@ const E = {
|
|
|
23
23
|
"parent_layout_id",
|
|
24
24
|
"tab_mode"
|
|
25
25
|
]);
|
|
26
|
-
function
|
|
27
|
-
return
|
|
28
|
-
(
|
|
26
|
+
function qe(n) {
|
|
27
|
+
return n ? n.some(
|
|
28
|
+
(e) => e.op === "layout_update" && Object.keys(e.patch ?? {}).some((t) => se.has(t))
|
|
29
29
|
) : !0;
|
|
30
30
|
}
|
|
31
|
-
const
|
|
32
|
-
function
|
|
33
|
-
|
|
34
|
-
if (
|
|
35
|
-
const e =
|
|
36
|
-
return
|
|
31
|
+
const re = 600, ne = "Someone else changed this layout — reloaded", ie = (n) => `Someone else saved — your ${n} ${n === 1 ? "change was" : "changes were"} kept on top; Save again`, oe = "Someone else saved this layout and some of your changes no longer fit", ae = (n) => `Someone else saved — your ${n === 1 ? "change was" : `${n} changes were`} replayed on top of theirs`, E = (n, e) => `Someone else saved — ${n} of your changes kept, ${e} no longer ${e === 1 ? "fits" : "fit"}: redo ${e === 1 ? "it" : "them"} by hand`, w = 250;
|
|
32
|
+
function $(n) {
|
|
33
|
+
if (n.length === 0) return "Save";
|
|
34
|
+
if (n.length === 1) return n[0].slice(0, w);
|
|
35
|
+
const e = `${n.length} changes: ${n.join(", ")}`;
|
|
36
|
+
return e.length > w ? `${e.slice(0, w - 1)}…` : e;
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
|
|
38
|
+
const ue = 100;
|
|
39
|
+
function q(n) {
|
|
40
|
+
const e = (s) => !!s && typeof s == "object" && Array.isArray(s.groups) && Array.isArray(s.placements) && typeof s.rev == "string";
|
|
41
|
+
if (e(n)) return n;
|
|
42
|
+
const t = n == null ? void 0 : n.data;
|
|
43
|
+
return e(t) ? t : null;
|
|
40
44
|
}
|
|
41
|
-
function
|
|
42
|
-
|
|
43
|
-
const e = s, r = (e == null ? void 0 : e.status) ?? ((i = e == null ? void 0 : e.response) == null ? void 0 : i.status) ?? null, n = ((u = e == null ? void 0 : e.response) == null ? void 0 : u.data) ?? (e == null ? void 0 : e.response), o = typeof (n == null ? void 0 : n.error) == "string" && n.error || typeof (n == null ? void 0 : n.message) == "string" && n.message || typeof (e == null ? void 0 : e.message) == "string" && e.message || t;
|
|
44
|
-
return { status: r, message: z(o), bundle: w(n == null ? void 0 : n.bundle) };
|
|
45
|
+
function he(n) {
|
|
46
|
+
return /^No group "/.test(n) ? "That section is no longer on this form" : /^"[^"]*" is not placed in /.test(n) ? "That field is no longer where it was" : /^"[^"]*" is already in /.test(n) ? "That field is already there" : /^"[^"]*" is not on this form/.test(n) ? "That item is no longer on this form" : /^"[^"]*" is not a container/.test(n) ? "Tabs can only go inside a tab group" : /^"[^"]*" is a reserved name/.test(n) ? "That name is reserved" : /^A group "[^"]*" already exists/.test(n) ? "A section with that key already exists" : /^Unknown setting "/.test(n) ? "That setting can’t be saved on this form" : n;
|
|
45
47
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const t =
|
|
49
|
-
|
|
50
|
-
return t;
|
|
48
|
+
function F(n, e = "The layout could not be saved") {
|
|
49
|
+
var o, u;
|
|
50
|
+
const t = n, s = (t == null ? void 0 : t.status) ?? ((o = t == null ? void 0 : t.response) == null ? void 0 : o.status) ?? null, r = ((u = t == null ? void 0 : t.response) == null ? void 0 : u.data) ?? (t == null ? void 0 : t.response), a = typeof (r == null ? void 0 : r.error) == "string" && r.error || typeof (r == null ? void 0 : r.message) == "string" && r.message || typeof (t == null ? void 0 : t.message) == "string" && t.message || e;
|
|
51
|
+
return { status: s, message: he(a), bundle: q(r == null ? void 0 : r.bundle) };
|
|
51
52
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
53
|
+
const ce = (n) => f(n, [{ op: "layout_update", patch: {} }]), S = (n, e) => n.placements.find((t) => t.field === e.field && t.group_key === (e.group_key ?? null));
|
|
54
|
+
function A(n) {
|
|
55
|
+
const e = {};
|
|
56
|
+
for (const t of te) e[t] = n[t];
|
|
57
|
+
return e;
|
|
56
58
|
}
|
|
57
|
-
function
|
|
59
|
+
function de(n) {
|
|
58
60
|
const e = {};
|
|
59
|
-
for (const
|
|
61
|
+
for (const t of ee) e[t] = n[t];
|
|
60
62
|
return e;
|
|
61
63
|
}
|
|
62
|
-
function
|
|
63
|
-
|
|
64
|
+
function x(n, e) {
|
|
65
|
+
const t = {};
|
|
66
|
+
for (const s of Object.keys(e)) t[s] = n[s] === void 0 ? null : n[s];
|
|
67
|
+
return t;
|
|
68
|
+
}
|
|
69
|
+
function le(n, e) {
|
|
70
|
+
switch (e.op) {
|
|
64
71
|
case "place":
|
|
65
|
-
return [{ op: "remove", at: { field:
|
|
72
|
+
return [{ op: "remove", at: { field: e.field, group_key: e.group_key ?? null } }];
|
|
66
73
|
case "move": {
|
|
67
|
-
const
|
|
68
|
-
return
|
|
74
|
+
const t = S(n, e.from);
|
|
75
|
+
return t ? [
|
|
69
76
|
{
|
|
70
77
|
op: "move",
|
|
71
|
-
from: { field:
|
|
72
|
-
to_group_key:
|
|
73
|
-
index:
|
|
78
|
+
from: { field: t.field, group_key: e.to_group_key ?? null },
|
|
79
|
+
to_group_key: t.group_key,
|
|
80
|
+
index: t.sort
|
|
74
81
|
}
|
|
75
82
|
] : [];
|
|
76
83
|
}
|
|
77
84
|
case "update_placement": {
|
|
78
|
-
const
|
|
79
|
-
return
|
|
85
|
+
const t = S(n, e.at);
|
|
86
|
+
return t ? [
|
|
80
87
|
{
|
|
81
88
|
op: "update_placement",
|
|
82
|
-
at:
|
|
83
|
-
patch:
|
|
89
|
+
at: e.at,
|
|
90
|
+
patch: x(t, e.patch ?? {})
|
|
84
91
|
}
|
|
85
92
|
] : [];
|
|
86
93
|
}
|
|
87
94
|
case "remove": {
|
|
88
|
-
const
|
|
89
|
-
return
|
|
95
|
+
const t = S(n, e.at);
|
|
96
|
+
return t ? [
|
|
90
97
|
{
|
|
91
98
|
op: "place",
|
|
92
|
-
field:
|
|
93
|
-
group_key:
|
|
94
|
-
index:
|
|
95
|
-
patch:
|
|
99
|
+
field: t.field,
|
|
100
|
+
group_key: t.group_key,
|
|
101
|
+
index: t.sort,
|
|
102
|
+
patch: A(t)
|
|
96
103
|
}
|
|
97
104
|
] : [];
|
|
98
105
|
}
|
|
99
106
|
case "group_create":
|
|
100
|
-
return [{ op: "group_remove", key:
|
|
107
|
+
return [{ op: "group_remove", key: e.key, placements: "delete" }];
|
|
101
108
|
case "group_update": {
|
|
102
|
-
const
|
|
103
|
-
return
|
|
109
|
+
const t = n.groups.find((s) => s.key === e.key);
|
|
110
|
+
return t ? [
|
|
104
111
|
{
|
|
105
112
|
op: "group_update",
|
|
106
|
-
key:
|
|
107
|
-
patch:
|
|
113
|
+
key: e.key,
|
|
114
|
+
patch: x(t, e.patch ?? {})
|
|
108
115
|
}
|
|
109
116
|
] : [];
|
|
110
117
|
}
|
|
111
118
|
case "group_move": {
|
|
112
|
-
const
|
|
113
|
-
if (
|
|
114
|
-
const
|
|
115
|
-
return
|
|
119
|
+
const t = n.groups.find((r) => r.key === e.key);
|
|
120
|
+
if (t) return [{ op: "group_move", key: e.key, parent_key: t.parent_key, index: t.sort }];
|
|
121
|
+
const s = n.placements.find((r) => r.field === e.key && Z(r));
|
|
122
|
+
return s ? [{ op: "group_move", key: e.key, parent_key: null, index: s.sort }] : [];
|
|
116
123
|
}
|
|
117
124
|
case "group_remove": {
|
|
118
|
-
const
|
|
119
|
-
if (!
|
|
120
|
-
const
|
|
125
|
+
const t = n.groups.find((o) => o.key === e.key);
|
|
126
|
+
if (!t) return [];
|
|
127
|
+
const s = [
|
|
121
128
|
{
|
|
122
129
|
op: "group_create",
|
|
123
|
-
key:
|
|
124
|
-
label:
|
|
125
|
-
group_type:
|
|
126
|
-
parent_key:
|
|
127
|
-
index:
|
|
128
|
-
patch:
|
|
130
|
+
key: t.key,
|
|
131
|
+
label: t.label,
|
|
132
|
+
group_type: t.type,
|
|
133
|
+
parent_key: t.parent_key,
|
|
134
|
+
index: t.sort,
|
|
135
|
+
patch: de(t)
|
|
129
136
|
}
|
|
130
137
|
];
|
|
131
|
-
return
|
|
132
|
-
|
|
133
|
-
}),
|
|
134
|
-
const
|
|
135
|
-
|
|
136
|
-
|
|
138
|
+
return n.groups.filter((o) => o.parent_key === t.key).sort((o, u) => o.sort - u.sort).forEach((o, u) => {
|
|
139
|
+
s.push({ op: "group_move", key: o.key, parent_key: t.key, index: u });
|
|
140
|
+
}), n.placements.filter((o) => o.group_key === t.key).sort((o, u) => o.sort - u.sort).forEach((o, u) => {
|
|
141
|
+
const i = e.placements === "ungroup" && !n.placements.some((h) => h.field === o.field && h.group_key === null);
|
|
142
|
+
s.push(
|
|
143
|
+
i ? {
|
|
137
144
|
op: "move",
|
|
138
|
-
from: { field:
|
|
139
|
-
to_group_key:
|
|
145
|
+
from: { field: o.field, group_key: null },
|
|
146
|
+
to_group_key: t.key,
|
|
140
147
|
index: u
|
|
141
|
-
} : { op: "place", field:
|
|
148
|
+
} : { op: "place", field: o.field, group_key: t.key, index: u, patch: A(o) }
|
|
142
149
|
);
|
|
143
|
-
}),
|
|
150
|
+
}), s;
|
|
144
151
|
}
|
|
145
152
|
case "layout_update":
|
|
146
|
-
return [{ op: "layout_update", patch:
|
|
153
|
+
return [{ op: "layout_update", patch: x(n.layout, e.patch ?? {}) }];
|
|
147
154
|
default:
|
|
148
155
|
return [];
|
|
149
156
|
}
|
|
150
157
|
}
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
158
|
+
const pe = (n, e) => JSON.stringify(n ?? null) === JSON.stringify(e ?? null), T = (n, e) => Object.entries(e ?? {}).every(([t, s]) => pe(n[t], s));
|
|
159
|
+
function fe(n, e) {
|
|
160
|
+
return e.length === 0 ? !1 : e.every((t) => {
|
|
161
|
+
if (t.op === "update_placement") {
|
|
162
|
+
const s = S(n, t.at);
|
|
163
|
+
return !!s && T(s, t.patch);
|
|
164
|
+
}
|
|
165
|
+
if (t.op === "group_update") {
|
|
166
|
+
const s = n.groups.find((r) => r.key === t.key);
|
|
167
|
+
return !!s && T(s, t.patch);
|
|
168
|
+
}
|
|
169
|
+
return t.op === "layout_update" ? T(n.layout, t.patch) : !1;
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
function g(n, e) {
|
|
173
|
+
let t = ce(n), s = [];
|
|
174
|
+
for (const r of e)
|
|
175
|
+
s = [...le(t, r), ...s], t = f(t, [r]);
|
|
176
|
+
return s;
|
|
156
177
|
}
|
|
157
|
-
function
|
|
158
|
-
const
|
|
159
|
-
for (const
|
|
160
|
-
if (
|
|
161
|
-
for (const [
|
|
162
|
-
|
|
163
|
-
key: `p\0${
|
|
164
|
-
op: { op: "update_placement", at:
|
|
178
|
+
function ve(n) {
|
|
179
|
+
const e = [];
|
|
180
|
+
for (const t of n)
|
|
181
|
+
if (t.op === "update_placement")
|
|
182
|
+
for (const [s, r] of Object.entries(t.patch ?? {}))
|
|
183
|
+
e.push({
|
|
184
|
+
key: `p\0${t.at.field}\0${t.at.group_key ?? ""}\0${s}`,
|
|
185
|
+
op: { op: "update_placement", at: t.at, patch: { [s]: r } }
|
|
165
186
|
});
|
|
166
|
-
else if (
|
|
167
|
-
for (const [
|
|
168
|
-
|
|
169
|
-
key: `g\0${
|
|
170
|
-
op: { op: "group_update", key:
|
|
187
|
+
else if (t.op === "group_update")
|
|
188
|
+
for (const [s, r] of Object.entries(t.patch ?? {}))
|
|
189
|
+
e.push({
|
|
190
|
+
key: `g\0${t.key}\0${s}`,
|
|
191
|
+
op: { op: "group_update", key: t.key, patch: { [s]: r } }
|
|
171
192
|
});
|
|
172
|
-
else if (
|
|
173
|
-
for (const [
|
|
174
|
-
|
|
193
|
+
else if (t.op === "layout_update")
|
|
194
|
+
for (const [s, r] of Object.entries(t.patch ?? {}))
|
|
195
|
+
e.push({ key: `l\0${s}`, op: { op: "layout_update", patch: { [s]: r } } });
|
|
175
196
|
else return null;
|
|
176
|
-
return
|
|
197
|
+
return e;
|
|
177
198
|
}
|
|
178
|
-
const y = (
|
|
179
|
-
class
|
|
180
|
-
constructor(t) {
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
a
|
|
195
|
-
|
|
199
|
+
const y = (n) => n instanceof Error ? n.message : String(n);
|
|
200
|
+
class ke {
|
|
201
|
+
constructor(e, t = {}) {
|
|
202
|
+
c(this, "server", null);
|
|
203
|
+
c(this, "draft", null);
|
|
204
|
+
c(this, "queue", []);
|
|
205
|
+
/** Manual mode: steps folded into the draft, not sent yet (oldest first). */
|
|
206
|
+
c(this, "unsaved", []);
|
|
207
|
+
c(this, "inFlight", !1);
|
|
208
|
+
c(this, "text", /* @__PURE__ */ new Map());
|
|
209
|
+
c(this, "undoStack", []);
|
|
210
|
+
c(this, "redoStack", []);
|
|
211
|
+
c(this, "outcome", "idle");
|
|
212
|
+
c(this, "error", null);
|
|
213
|
+
/** Undo / redo as they were when the first unsaved step was made: Discard puts them back. */
|
|
214
|
+
c(this, "checkpoint", null);
|
|
215
|
+
/** Labels of steps a rebase could not replay (#2652). */
|
|
216
|
+
c(this, "dropped", []);
|
|
217
|
+
c(this, "autosave");
|
|
218
|
+
c(this, "nextId", 1);
|
|
219
|
+
c(this, "listeners", /* @__PURE__ */ new Set());
|
|
220
|
+
c(this, "idleWaiters", []);
|
|
221
|
+
c(this, "view");
|
|
222
|
+
c(this, "subscribe", (e) => (this.listeners.add(e), () => {
|
|
223
|
+
this.listeners.delete(e);
|
|
196
224
|
}));
|
|
197
|
-
|
|
198
|
-
this.transport = t, this.view = this.buildView();
|
|
225
|
+
c(this, "getView", () => this.view);
|
|
226
|
+
this.transport = e, this.autosave = t.autosave ?? !1, this.view = this.buildView();
|
|
199
227
|
}
|
|
200
228
|
/**
|
|
201
|
-
* A fetched bundle. Ignored while anything is pending, so typing
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
229
|
+
* A fetched bundle. Ignored while anything is pending or unsaved, so typing
|
|
230
|
+
* and unsaved steps are never overwritten (Save rebases them on a 409). Our
|
|
231
|
+
* own saves arrive here with the rev we already hold; a new rev means
|
|
232
|
+
* someone else saved, and the undo steps (index-based inverses of the old
|
|
233
|
+
* state) would undo over their change — so the history goes.
|
|
205
234
|
*/
|
|
206
|
-
receive(
|
|
207
|
-
this.
|
|
208
|
-
}
|
|
209
|
-
apply(
|
|
210
|
-
if (!this.draft ||
|
|
211
|
-
const
|
|
212
|
-
if (
|
|
213
|
-
this.flushText();
|
|
214
|
-
const
|
|
215
|
-
let
|
|
235
|
+
receive(e) {
|
|
236
|
+
this.isBusy() || this.server && this.server.rev === e.rev || (this.server && (this.undoStack = [], this.redoStack = []), this.server = e, this.draft = e, this.emit());
|
|
237
|
+
}
|
|
238
|
+
apply(e, t) {
|
|
239
|
+
if (!this.draft || e.length === 0) return;
|
|
240
|
+
const s = (t == null ? void 0 : t.label) ?? "Edit", r = t != null && t.text ? ve(e) : null;
|
|
241
|
+
if (r) return this.autosave ? this.applyText(r, s) : this.stageText(r, s);
|
|
242
|
+
this.flushText(), this.markCheckpoint();
|
|
243
|
+
const a = this.draft;
|
|
244
|
+
let o;
|
|
216
245
|
try {
|
|
217
|
-
|
|
218
|
-
} catch (
|
|
219
|
-
this.fail(y(
|
|
246
|
+
f(a, e), o = g(a, e);
|
|
247
|
+
} catch (i) {
|
|
248
|
+
this.fail(y(i));
|
|
220
249
|
return;
|
|
221
250
|
}
|
|
222
251
|
this.clearOutcome();
|
|
223
|
-
const u = this.
|
|
224
|
-
(
|
|
252
|
+
const u = this.add("do", e, s);
|
|
253
|
+
(t == null ? void 0 : t.undoable) !== !1 && (this.pushUndo({ label: s, forward: e, inverse: o, batchId: u.id }), this.redoStack = []), this.refresh();
|
|
225
254
|
}
|
|
226
255
|
// Undo / redo pop the step before checking it still applies: a step that no
|
|
227
256
|
// longer fits the draft is discarded with an error, not retried.
|
|
228
257
|
undo() {
|
|
229
|
-
this.flushText();
|
|
230
|
-
const
|
|
231
|
-
if (!
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
258
|
+
this.flushText(), this.markCheckpoint();
|
|
259
|
+
const e = this.undoStack.pop();
|
|
260
|
+
if (!e || !this.draft) return;
|
|
261
|
+
const t = this.unsaved[this.unsaved.length - 1];
|
|
262
|
+
if (!this.autosave && t && t.id === e.batchId) {
|
|
263
|
+
this.unsaved.pop(), this.clearOutcome(), this.redoStack.push(e), this.refresh();
|
|
264
|
+
return;
|
|
265
|
+
}
|
|
266
|
+
try {
|
|
267
|
+
f(this.draft, e.inverse);
|
|
268
|
+
} catch (s) {
|
|
269
|
+
this.fail(`Could not undo: ${y(s)}`);
|
|
270
|
+
return;
|
|
239
271
|
}
|
|
272
|
+
this.clearOutcome(), e.batchId = this.add("undo", e.inverse, `Undo ${e.label}`).id, this.redoStack.push(e), this.refresh();
|
|
240
273
|
}
|
|
241
274
|
redo() {
|
|
242
|
-
this.flushText();
|
|
243
|
-
const
|
|
244
|
-
if (!(!
|
|
275
|
+
this.flushText(), this.markCheckpoint();
|
|
276
|
+
const e = this.redoStack.pop();
|
|
277
|
+
if (!(!e || !this.draft)) {
|
|
245
278
|
try {
|
|
246
|
-
|
|
247
|
-
} catch (
|
|
248
|
-
this.fail(`Could not redo: ${y(
|
|
279
|
+
f(this.draft, e.forward), e.inverse = g(this.draft, e.forward);
|
|
280
|
+
} catch (t) {
|
|
281
|
+
this.fail(`Could not redo: ${y(t)}`);
|
|
249
282
|
return;
|
|
250
283
|
}
|
|
251
|
-
this.clearOutcome(),
|
|
284
|
+
this.clearOutcome(), e.batchId = this.add("redo", e.forward, `Redo ${e.label}`).id, this.undoStack.push(e), this.refresh();
|
|
252
285
|
}
|
|
253
286
|
}
|
|
254
|
-
/**
|
|
287
|
+
/** -n undoes n steps, +n redoes n; stops early when a step no longer applies. */
|
|
288
|
+
jump(e) {
|
|
289
|
+
for (let t = 0; t < Math.abs(e); t++)
|
|
290
|
+
if ((e < 0 ? this.undoStack : this.redoStack).length === 0 || (e < 0 ? this.undo() : this.redo(), this.outcome === "error")) return;
|
|
291
|
+
}
|
|
292
|
+
/** Send every pending text edit now (blur, unmount, before another op). Manual
|
|
293
|
+
* mode: ends the open text burst, so the next keystroke is a new step. */
|
|
255
294
|
flushText() {
|
|
256
|
-
|
|
295
|
+
this.closeText();
|
|
296
|
+
for (const e of [...this.text.keys()]) this.flushTextKey(e);
|
|
257
297
|
}
|
|
258
|
-
/** Anything typed, queued or
|
|
298
|
+
/** Anything typed, queued, in flight or unsaved (an engine worth keeping). */
|
|
259
299
|
isBusy() {
|
|
260
|
-
return this.pending();
|
|
261
|
-
}
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
300
|
+
return this.pending() || this.unsaved.length > 0;
|
|
301
|
+
}
|
|
302
|
+
setAutosave(e) {
|
|
303
|
+
e !== this.autosave && (this.flushText(), this.autosave = e, e && this.unsaved.length > 0 ? this.save() : this.emit());
|
|
304
|
+
}
|
|
305
|
+
unsavedOps() {
|
|
306
|
+
return this.unsaved.flatMap((e) => e.ops);
|
|
307
|
+
}
|
|
308
|
+
/**
|
|
309
|
+
* Every unsaved step as one batch against the current rev. Resolves once
|
|
310
|
+
* nothing is in flight (saved, failed or rebased alike) — `unsavedOps()` is
|
|
311
|
+
* empty afterwards only when it landed.
|
|
312
|
+
*/
|
|
313
|
+
save(e) {
|
|
314
|
+
if (this.flushText(), this.unsaved.length > 0) {
|
|
315
|
+
const t = this.unsaved;
|
|
316
|
+
this.unsaved = [], this.checkpoint = null;
|
|
317
|
+
const s = this.queue.length > (this.inFlight ? 1 : 0) ? this.queue[this.queue.length - 1] : void 0;
|
|
318
|
+
if ((s == null ? void 0 : s.kind) === "save") {
|
|
319
|
+
const r = [...s.parts ?? [], ...t];
|
|
320
|
+
s.parts = r, s.ops = r.flatMap((a) => a.ops), s.note = $(r.map((a) => a.note)), e && (s.meta = e);
|
|
321
|
+
} else
|
|
322
|
+
this.queue.push({
|
|
323
|
+
id: this.nextId++,
|
|
324
|
+
kind: "save",
|
|
325
|
+
ops: t.flatMap((r) => r.ops),
|
|
326
|
+
note: $(t.map((r) => r.note)),
|
|
327
|
+
parts: t,
|
|
328
|
+
meta: e
|
|
329
|
+
});
|
|
330
|
+
this.clearOutcome(), this.refresh();
|
|
331
|
+
}
|
|
332
|
+
return this.whenIdle(6e4);
|
|
333
|
+
}
|
|
334
|
+
/** Drop the unsaved steps: the draft, Undo and Redo go back to the last save. */
|
|
335
|
+
discard() {
|
|
336
|
+
if (this.closeText(), !(this.unsaved.length === 0 && this.dropped.length === 0)) {
|
|
337
|
+
if (this.checkpoint)
|
|
338
|
+
this.undoStack = this.checkpoint.undo, this.redoStack = this.checkpoint.redo, this.checkpoint = null;
|
|
339
|
+
else for (const e of [...this.unsaved].reverse()) this.rollback(e);
|
|
340
|
+
this.unsaved = [], this.dropped = [], this.outcome = "idle", this.error = null, this.refresh();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
clearDropped() {
|
|
344
|
+
this.dropped.length !== 0 && (this.dropped = [], this.emit());
|
|
345
|
+
}
|
|
346
|
+
/**
|
|
347
|
+
* Steps from a recovered draft (#2653), applied as new changes in order. A
|
|
348
|
+
* step that no longer fits the layout is skipped and listed in `dropped`.
|
|
349
|
+
* Returns how many were applied.
|
|
350
|
+
*/
|
|
351
|
+
restore(e) {
|
|
352
|
+
let t = 0;
|
|
353
|
+
for (const s of e) {
|
|
354
|
+
if (!this.draft) break;
|
|
355
|
+
try {
|
|
356
|
+
f(this.draft, s.ops);
|
|
357
|
+
} catch {
|
|
358
|
+
this.dropped = [...this.dropped, s.label];
|
|
359
|
+
continue;
|
|
360
|
+
}
|
|
361
|
+
this.apply(s.ops, { label: s.label }), t += 1;
|
|
362
|
+
}
|
|
363
|
+
return this.emit(), t;
|
|
364
|
+
}
|
|
365
|
+
whenIdle(e = 15e3) {
|
|
366
|
+
return this.flushText(), this.pending() ? new Promise((t) => {
|
|
367
|
+
let s = !1;
|
|
368
|
+
const r = () => {
|
|
369
|
+
s || (s = !0, clearTimeout(a), t());
|
|
370
|
+
}, a = setTimeout(() => {
|
|
371
|
+
this.idleWaiters = this.idleWaiters.filter((o) => o !== r), r();
|
|
372
|
+
}, e);
|
|
373
|
+
this.idleWaiters.push(r);
|
|
271
374
|
}) : Promise.resolve();
|
|
272
375
|
}
|
|
273
|
-
applyText(
|
|
274
|
-
const
|
|
376
|
+
applyText(e, t) {
|
|
377
|
+
const s = this.draft;
|
|
275
378
|
try {
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
379
|
+
f(
|
|
380
|
+
s,
|
|
381
|
+
e.map((r) => r.op)
|
|
279
382
|
);
|
|
280
|
-
} catch (
|
|
281
|
-
this.fail(y(
|
|
383
|
+
} catch (r) {
|
|
384
|
+
this.fail(y(r));
|
|
282
385
|
return;
|
|
283
386
|
}
|
|
284
387
|
this.clearOutcome();
|
|
285
|
-
for (const { key:
|
|
286
|
-
const
|
|
287
|
-
|
|
288
|
-
const u = setTimeout(() => this.flushTextKey(
|
|
289
|
-
this.text.set(
|
|
388
|
+
for (const { key: r, op: a } of e) {
|
|
389
|
+
const o = this.text.get(r);
|
|
390
|
+
o && clearTimeout(o.timer);
|
|
391
|
+
const u = setTimeout(() => this.flushTextKey(r), re), i = (o == null ? void 0 : o.inverse) ?? g(s, [a])[0];
|
|
392
|
+
this.text.set(r, { op: a, inverse: i, label: t, timer: u });
|
|
290
393
|
}
|
|
291
394
|
this.redoStack = [], this.refresh();
|
|
292
395
|
}
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
396
|
+
/**
|
|
397
|
+
* Manual-mode typing folds at once. Keystrokes in the same box(es) replace
|
|
398
|
+
* the open step's ops, so a burst is one unsaved change and one undo step,
|
|
399
|
+
* back to the value before its first keystroke.
|
|
400
|
+
*/
|
|
401
|
+
stageText(e, t) {
|
|
402
|
+
const s = this.draft, r = e.map((i) => i.op);
|
|
403
|
+
this.markCheckpoint();
|
|
404
|
+
const a = e.map((i) => i.key).join("");
|
|
405
|
+
try {
|
|
406
|
+
f(s, r);
|
|
407
|
+
} catch (i) {
|
|
408
|
+
this.fail(y(i));
|
|
409
|
+
return;
|
|
410
|
+
}
|
|
411
|
+
this.clearOutcome();
|
|
412
|
+
const o = this.unsaved[this.unsaved.length - 1], u = this.undoStack[this.undoStack.length - 1];
|
|
413
|
+
if ((o == null ? void 0 : o.textKey) === a && (u == null ? void 0 : u.batchId) === o.id)
|
|
414
|
+
o.ops = r, u.forward = r;
|
|
415
|
+
else {
|
|
416
|
+
this.closeText();
|
|
417
|
+
const i = this.add("do", r, t);
|
|
418
|
+
i.textKey = a, this.pushUndo({ label: t, forward: r, inverse: g(s, r), batchId: i.id });
|
|
419
|
+
}
|
|
420
|
+
this.redoStack = [], this.refresh();
|
|
421
|
+
}
|
|
422
|
+
/** Before the first unsaved step changes Undo / Redo: remember them for Discard. */
|
|
423
|
+
markCheckpoint() {
|
|
424
|
+
this.autosave || this.unsaved.length > 0 || (this.checkpoint = {
|
|
425
|
+
undo: this.undoStack.map((e) => ({ ...e })),
|
|
426
|
+
redo: this.redoStack.map((e) => ({ ...e }))
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
closeText() {
|
|
430
|
+
const e = this.unsaved[this.unsaved.length - 1];
|
|
431
|
+
e != null && e.textKey && (e.textKey = void 0);
|
|
432
|
+
}
|
|
433
|
+
flushTextKey(e) {
|
|
434
|
+
const t = this.text.get(e);
|
|
435
|
+
if (!t) return;
|
|
436
|
+
clearTimeout(t.timer), this.text.delete(e);
|
|
437
|
+
const s = this.enqueue("do", [t.op], t.label);
|
|
298
438
|
this.pushUndo({
|
|
299
|
-
label:
|
|
300
|
-
forward: [
|
|
301
|
-
inverse:
|
|
302
|
-
batchId:
|
|
439
|
+
label: t.label,
|
|
440
|
+
forward: [t.op],
|
|
441
|
+
inverse: t.inverse ? [t.inverse] : [],
|
|
442
|
+
batchId: s.id
|
|
303
443
|
}), this.refresh();
|
|
304
444
|
}
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
return this.
|
|
445
|
+
/** A step: sent now (autosave) or held as unsaved (manual). */
|
|
446
|
+
add(e, t, s) {
|
|
447
|
+
if (this.autosave) return this.enqueue(e, t, s);
|
|
448
|
+
const r = { id: this.nextId++, kind: e, ops: t, note: s };
|
|
449
|
+
return this.unsaved.push(r), r;
|
|
308
450
|
}
|
|
309
|
-
|
|
310
|
-
this.
|
|
451
|
+
enqueue(e, t, s) {
|
|
452
|
+
const r = { id: this.nextId++, kind: e, ops: t, note: s };
|
|
453
|
+
return this.queue.push(r), r;
|
|
454
|
+
}
|
|
455
|
+
pushUndo(e) {
|
|
456
|
+
this.undoStack.push(e), this.undoStack.length > ue && this.undoStack.shift();
|
|
311
457
|
}
|
|
312
458
|
pending() {
|
|
313
459
|
return this.inFlight || this.queue.length > 0 || this.text.size > 0;
|
|
@@ -315,160 +461,281 @@ class X {
|
|
|
315
461
|
clearOutcome() {
|
|
316
462
|
this.error = null, (this.outcome === "error" || this.outcome === "conflict") && (this.outcome = "idle");
|
|
317
463
|
}
|
|
318
|
-
fail(
|
|
319
|
-
this.error =
|
|
464
|
+
fail(e) {
|
|
465
|
+
this.error = e, this.outcome = "error", this.emit();
|
|
320
466
|
}
|
|
321
467
|
/** A batch the server refused: forget its step (or hand an undo/redo back). */
|
|
322
|
-
rollback(
|
|
323
|
-
|
|
324
|
-
const
|
|
325
|
-
return
|
|
468
|
+
rollback(e) {
|
|
469
|
+
if (e.kind === "save") {
|
|
470
|
+
for (const s of [...e.parts ?? []].reverse()) this.rollback(s);
|
|
471
|
+
return;
|
|
472
|
+
}
|
|
473
|
+
const t = (s) => {
|
|
474
|
+
const r = s.findIndex((a) => a.batchId === e.id);
|
|
475
|
+
return r < 0 ? null : s.splice(r, 1)[0];
|
|
326
476
|
};
|
|
327
|
-
if (
|
|
328
|
-
else if (
|
|
329
|
-
const
|
|
330
|
-
|
|
477
|
+
if (e.kind === "do") t(this.undoStack);
|
|
478
|
+
else if (e.kind === "undo") {
|
|
479
|
+
const s = t(this.redoStack);
|
|
480
|
+
s && this.undoStack.push(s);
|
|
331
481
|
} else {
|
|
332
|
-
const
|
|
333
|
-
|
|
482
|
+
const s = t(this.undoStack);
|
|
483
|
+
s && this.redoStack.push(s);
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
/**
|
|
487
|
+
* Fold `batches` onto `fresh` one by one: the ones that still fit (with
|
|
488
|
+
* their inverses relative to it) and the ones that no longer do.
|
|
489
|
+
*/
|
|
490
|
+
refold(e, t) {
|
|
491
|
+
const s = [], r = [], a = /* @__PURE__ */ new Map();
|
|
492
|
+
let o = e;
|
|
493
|
+
for (const u of t)
|
|
494
|
+
try {
|
|
495
|
+
const i = g(o, u.ops);
|
|
496
|
+
o = f(o, u.ops), a.set(u.id, i), s.push(u);
|
|
497
|
+
} catch {
|
|
498
|
+
r.push(u);
|
|
499
|
+
}
|
|
500
|
+
return { kept: s, dropped: r, inverses: a };
|
|
501
|
+
}
|
|
502
|
+
/**
|
|
503
|
+
* After a rebase onto `fresh`: kept steps undo with their new inverses; a
|
|
504
|
+
* step saved before keeps its undo only while every value it set still
|
|
505
|
+
* stands (stillMine). Redo goes — it was relative to the old layout.
|
|
506
|
+
*/
|
|
507
|
+
rebaseUndo(e, t, s) {
|
|
508
|
+
this.undoStack = this.undoStack.filter(
|
|
509
|
+
(r) => t.has(r.batchId) || !s.has(r.batchId) && fe(e, r.forward)
|
|
510
|
+
);
|
|
511
|
+
for (const r of this.undoStack) r.inverse = t.get(r.batchId) ?? r.inverse;
|
|
512
|
+
this.redoStack = [];
|
|
513
|
+
}
|
|
514
|
+
/**
|
|
515
|
+
* Autosave: a batch refused as stale. Every queued batch (the refused one
|
|
516
|
+
* first) is replayed on the server's layout and sent again; one that no
|
|
517
|
+
* longer fits is dropped and listed. Without the server's layout: reload.
|
|
518
|
+
*/
|
|
519
|
+
conflict(e) {
|
|
520
|
+
if (!e) {
|
|
521
|
+
for (const s of this.text.values()) clearTimeout(s.timer);
|
|
522
|
+
this.text.clear(), this.queue = [], this.undoStack = [], this.redoStack = [], this.transport.reload(), this.outcome = "conflict", this.error = null, this.transport.notify(ne);
|
|
523
|
+
return;
|
|
334
524
|
}
|
|
525
|
+
const t = this.refold(e, this.queue);
|
|
526
|
+
this.queue = t.kept, this.server = e, this.transport.saved(e, null), this.rebaseUndo(e, t.inverses, new Set(t.dropped.map((s) => s.id))), this.dropped = [...this.dropped, ...t.dropped.map((s) => s.note)], this.outcome = "idle", this.error = null, this.transport.notify(
|
|
527
|
+
t.dropped.length === 0 ? ae(t.kept.length) : E(t.kept.length, t.dropped.length)
|
|
528
|
+
);
|
|
335
529
|
}
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
530
|
+
/**
|
|
531
|
+
* A Save refused as stale: fold every step it (and anything queued after it)
|
|
532
|
+
* carried onto the server's layout, one by one. The ones that fit stay
|
|
533
|
+
* unsaved on top of it, with fresh inverses, for another Save; the ones
|
|
534
|
+
* that no longer fit are dropped and listed for the admin to redo by hand.
|
|
535
|
+
*/
|
|
536
|
+
rebase(e) {
|
|
537
|
+
const t = [
|
|
538
|
+
...this.queue.flatMap((r) => r.kind === "save" ? r.parts ?? [] : [r]),
|
|
539
|
+
...this.unsaved
|
|
540
|
+
];
|
|
541
|
+
if (this.queue = [], this.unsaved = t, this.checkpoint = null, this.closeText(), !e) {
|
|
542
|
+
this.transport.reload(), this.outcome = "conflict", this.error = oe;
|
|
543
|
+
return;
|
|
544
|
+
}
|
|
545
|
+
const s = this.refold(e, t);
|
|
546
|
+
this.unsaved = s.kept, this.server = e, this.transport.saved(e, null), this.rebaseUndo(e, s.inverses, new Set(s.dropped.map((r) => r.id))), this.dropped = [...this.dropped, ...s.dropped.map((r) => r.note)], this.outcome = "idle", this.error = null, this.transport.notify(
|
|
547
|
+
s.dropped.length === 0 ? ie(s.kept.length) : E(s.kept.length, s.dropped.length)
|
|
548
|
+
);
|
|
339
549
|
}
|
|
340
|
-
/** Draft = server bundle + queued batches + typed text; then send the next batch. */
|
|
550
|
+
/** Draft = server bundle + queued batches + unsaved steps + typed text; then send the next batch. */
|
|
341
551
|
refresh() {
|
|
342
552
|
this.recompute(), this.pump(), this.emit();
|
|
343
553
|
}
|
|
344
554
|
recompute() {
|
|
345
555
|
if (!this.server) return;
|
|
346
|
-
let
|
|
347
|
-
const
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
556
|
+
let e = this.server;
|
|
557
|
+
const t = (r, a) => {
|
|
558
|
+
const o = [], u = [];
|
|
559
|
+
for (const [i, h] of r.entries())
|
|
560
|
+
try {
|
|
561
|
+
e = f(e, h.ops), o.push(h);
|
|
562
|
+
} catch (v) {
|
|
563
|
+
i === 0 && a ? o.push(h) : h.kind === "save" ? u.push(...h.parts ?? []) : (this.rollback(h), this.error ?? (this.error = y(v)), this.outcome = "error");
|
|
564
|
+
}
|
|
565
|
+
return { kept: o, restored: u };
|
|
566
|
+
}, s = t(this.queue, this.inFlight);
|
|
567
|
+
this.queue = s.kept, this.unsaved = t([...s.restored, ...this.unsaved], !1).kept;
|
|
568
|
+
for (const [r, a] of this.text)
|
|
356
569
|
try {
|
|
357
|
-
|
|
570
|
+
e = f(e, [a.op]);
|
|
358
571
|
} catch {
|
|
359
|
-
clearTimeout(
|
|
572
|
+
clearTimeout(a.timer), this.text.delete(r);
|
|
360
573
|
}
|
|
361
|
-
this.draft =
|
|
574
|
+
this.draft = e;
|
|
362
575
|
}
|
|
363
576
|
pump() {
|
|
364
577
|
if (this.inFlight || !this.server || this.queue.length === 0) return;
|
|
365
|
-
const
|
|
366
|
-
this.inFlight = !0, this.transport.send(
|
|
367
|
-
this.server =
|
|
368
|
-
}).catch((
|
|
369
|
-
const
|
|
370
|
-
|
|
578
|
+
const e = this.queue[0];
|
|
579
|
+
this.inFlight = !0, this.transport.send(e.ops, this.server.rev, e.note, e.meta).then((t) => {
|
|
580
|
+
this.server = t, this.queue.shift(), this.transport.saved(t, e.ops), this.outcome !== "error" && (this.outcome = "saved");
|
|
581
|
+
}).catch((t) => {
|
|
582
|
+
const s = F(t);
|
|
583
|
+
s.status === 409 && e.kind === "save" ? this.rebase(s.bundle) : s.status === 409 ? this.conflict(s.bundle) : e.kind === "save" ? (this.queue.shift(), this.unsaved = [...e.parts ?? [], ...this.unsaved], this.error = s.message, this.outcome = "error") : (this.queue.shift(), this.rollback(e), this.error = s.message, this.outcome = "error");
|
|
371
584
|
}).finally(() => {
|
|
372
585
|
this.inFlight = !1, this.refresh();
|
|
373
586
|
});
|
|
374
587
|
}
|
|
588
|
+
sessionSteps() {
|
|
589
|
+
const e = new Set(this.unsaved.map((s) => s.id)), t = /* @__PURE__ */ new Set();
|
|
590
|
+
for (const s of this.queue) {
|
|
591
|
+
t.add(s.id);
|
|
592
|
+
for (const r of s.parts ?? []) t.add(r.id);
|
|
593
|
+
}
|
|
594
|
+
return {
|
|
595
|
+
done: this.undoStack.map((s) => ({
|
|
596
|
+
label: s.label,
|
|
597
|
+
state: e.has(s.batchId) ? "unsaved" : t.has(s.batchId) ? "saving" : "saved"
|
|
598
|
+
})),
|
|
599
|
+
undone: [...this.redoStack].reverse().map((s) => ({ label: s.label }))
|
|
600
|
+
};
|
|
601
|
+
}
|
|
375
602
|
buildView() {
|
|
376
|
-
var r;
|
|
377
|
-
const
|
|
603
|
+
var s, r;
|
|
604
|
+
const e = this.undoStack[this.undoStack.length - 1], t = [...this.text.values()].pop();
|
|
378
605
|
return {
|
|
379
606
|
bundle: this.draft,
|
|
607
|
+
autosave: this.autosave,
|
|
608
|
+
unsavedCount: this.unsaved.length,
|
|
609
|
+
unsavedSteps: this.unsaved.map((a) => ({ label: a.note, ops: a.ops })),
|
|
610
|
+
baseRev: ((s = this.server) == null ? void 0 : s.rev) ?? null,
|
|
611
|
+
dropped: this.dropped,
|
|
612
|
+
dirty: this.unsaved.length > 0,
|
|
380
613
|
canUndo: this.undoStack.length > 0 || this.text.size > 0,
|
|
381
614
|
canRedo: this.redoStack.length > 0,
|
|
382
|
-
undoLabel: (
|
|
615
|
+
undoLabel: (t == null ? void 0 : t.label) ?? (e == null ? void 0 : e.label) ?? null,
|
|
383
616
|
redoLabel: ((r = this.redoStack[this.redoStack.length - 1]) == null ? void 0 : r.label) ?? null,
|
|
617
|
+
session: this.sessionSteps(),
|
|
384
618
|
status: this.pending() ? "saving" : this.outcome,
|
|
385
619
|
error: this.error
|
|
386
620
|
};
|
|
387
621
|
}
|
|
388
622
|
emit() {
|
|
389
623
|
this.view = this.buildView();
|
|
390
|
-
for (const
|
|
624
|
+
for (const e of this.listeners) e();
|
|
391
625
|
if (this.idleWaiters.length > 0 && !this.pending()) {
|
|
392
|
-
const
|
|
626
|
+
const e = this.idleWaiters;
|
|
393
627
|
this.idleWaiters = [];
|
|
394
|
-
for (const
|
|
628
|
+
for (const t of e) t();
|
|
395
629
|
}
|
|
396
630
|
}
|
|
397
631
|
}
|
|
398
|
-
const
|
|
399
|
-
function
|
|
400
|
-
let
|
|
401
|
-
|
|
402
|
-
const r =
|
|
632
|
+
const I = /* @__PURE__ */ new WeakMap();
|
|
633
|
+
function ye(n, e, t) {
|
|
634
|
+
let s = I.get(e.qc);
|
|
635
|
+
s || (s = /* @__PURE__ */ new Map(), I.set(e.qc, s));
|
|
636
|
+
const r = s.get(n);
|
|
403
637
|
if (r != null && r.engine.isBusy()) return r;
|
|
404
|
-
const
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
638
|
+
const a = C.bundle(n), o = { current: e }, i = { engine: new ke(
|
|
639
|
+
{
|
|
640
|
+
send: async (h, v, k, d) => {
|
|
641
|
+
const _ = await o.current.client.request(
|
|
642
|
+
X(`/collection-layouts/${n}/ops`, {
|
|
643
|
+
ops: h,
|
|
644
|
+
base_rev: v,
|
|
645
|
+
note: k,
|
|
646
|
+
...d ? { reason: d.reason, ticket: d.ticket ?? null } : {},
|
|
647
|
+
...d != null && d.freeze_override ? { freeze_override: d.freeze_override } : {}
|
|
648
|
+
})
|
|
649
|
+
), m = q(_);
|
|
650
|
+
if (!m) throw new Error("The server answered without the saved layout");
|
|
651
|
+
return m;
|
|
652
|
+
},
|
|
653
|
+
saved: (h, v) => {
|
|
654
|
+
var k, d;
|
|
655
|
+
o.current.qc.setQueryData(a, h), (d = (k = o.current).onSaved) == null || d.call(k, h, v);
|
|
656
|
+
},
|
|
657
|
+
reload: () => {
|
|
658
|
+
o.current.qc.invalidateQueries({ queryKey: a });
|
|
659
|
+
},
|
|
660
|
+
notify: (h) => {
|
|
661
|
+
H.warning(h);
|
|
662
|
+
}
|
|
418
663
|
},
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
}), live: o };
|
|
423
|
-
return e.set(s, u), u;
|
|
664
|
+
{ autosave: t }
|
|
665
|
+
), live: o };
|
|
666
|
+
return s.set(n, i), i;
|
|
424
667
|
}
|
|
425
|
-
function
|
|
426
|
-
const
|
|
427
|
-
return
|
|
428
|
-
queryKey:
|
|
668
|
+
function ge(n, e = !0) {
|
|
669
|
+
const t = M();
|
|
670
|
+
return z({
|
|
671
|
+
queryKey: C.bundle(n ?? 0),
|
|
429
672
|
queryFn: async () => {
|
|
430
|
-
const
|
|
431
|
-
if (!
|
|
432
|
-
return
|
|
673
|
+
const s = await t.request(J(`/collection-layouts/${n}/bundle`)), r = q(s);
|
|
674
|
+
if (!r) throw new Error("The layout could not be read");
|
|
675
|
+
return r;
|
|
433
676
|
},
|
|
434
|
-
enabled:
|
|
677
|
+
enabled: e && n != null,
|
|
435
678
|
staleTime: 15e3,
|
|
436
679
|
refetchOnWindowFocus: !1
|
|
437
680
|
});
|
|
438
681
|
}
|
|
439
|
-
function
|
|
440
|
-
const
|
|
441
|
-
(!
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
n.
|
|
445
|
-
},
|
|
446
|
-
const
|
|
447
|
-
|
|
682
|
+
function Oe(n, e = {}) {
|
|
683
|
+
const t = M(), s = P(), r = ge(n), [a, o] = Q(e.autosave ?? !1), u = Y(null);
|
|
684
|
+
(!u.current || u.current.id !== n || u.current.qc !== s) && (u.current = {
|
|
685
|
+
id: n,
|
|
686
|
+
qc: s,
|
|
687
|
+
...ye(n, { client: t, qc: s, onSaved: e.onSaved }, a)
|
|
688
|
+
}), u.current.live.current = { client: t, qc: s, onSaved: e.onSaved };
|
|
689
|
+
const i = u.current.engine, h = G(i.subscribe, i.getView, i.getView);
|
|
690
|
+
b(() => {
|
|
691
|
+
r.data && i.receive(r.data);
|
|
692
|
+
}, [i, r.data]), b(() => {
|
|
693
|
+
i.setAutosave(a);
|
|
694
|
+
}, [i, a]), b(() => () => i.flushText(), [i]);
|
|
695
|
+
const v = p(
|
|
696
|
+
(l, W) => i.apply(l, W),
|
|
697
|
+
[i]
|
|
698
|
+
), k = p(() => i.undo(), [i]), d = p(() => i.redo(), [i]), _ = p(() => i.flushText(), [i]), m = p((l) => i.whenIdle(l), [i]), K = p(
|
|
699
|
+
(l) => {
|
|
700
|
+
o(l), i.setAutosave(l);
|
|
701
|
+
},
|
|
448
702
|
[i]
|
|
449
|
-
), l = p(() => i.
|
|
703
|
+
), U = p(() => i.unsavedOps(), [i]), L = p((l) => i.save(l), [i]), j = p(() => i.discard(), [i]), D = p(() => i.clearDropped(), [i]), N = p((l) => i.restore(l), [i]), R = p((l) => i.jump(l), [i]), O = !h.bundle && r.error != null;
|
|
450
704
|
return {
|
|
451
|
-
...
|
|
452
|
-
status:
|
|
453
|
-
error:
|
|
454
|
-
apply:
|
|
455
|
-
undo:
|
|
705
|
+
...h,
|
|
706
|
+
status: O ? "error" : h.status,
|
|
707
|
+
error: h.error ?? (O ? F(r.error, "The layout could not be read").message : null),
|
|
708
|
+
apply: v,
|
|
709
|
+
undo: k,
|
|
456
710
|
redo: d,
|
|
457
|
-
flush:
|
|
458
|
-
whenIdle:
|
|
459
|
-
|
|
711
|
+
flush: _,
|
|
712
|
+
whenIdle: m,
|
|
713
|
+
setAutosave: K,
|
|
714
|
+
unsavedOps: U,
|
|
715
|
+
save: L,
|
|
716
|
+
discard: j,
|
|
717
|
+
clearDropped: D,
|
|
718
|
+
restore: N,
|
|
719
|
+
jump: R,
|
|
720
|
+
isLoading: r.isLoading
|
|
460
721
|
};
|
|
461
722
|
}
|
|
462
723
|
export {
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
724
|
+
ne as CONFLICT_MESSAGE,
|
|
725
|
+
ke as LayoutDraftEngine,
|
|
726
|
+
oe as REBASE_FAILED_MESSAGE,
|
|
727
|
+
re as TEXT_DEBOUNCE_MS,
|
|
728
|
+
he as humanizeOpError,
|
|
729
|
+
g as inverseOps,
|
|
730
|
+
C as layoutDraftKeys,
|
|
731
|
+
q as parseBundle,
|
|
732
|
+
F as parseSaveFailure,
|
|
733
|
+
E as partlyRebasedMessage,
|
|
734
|
+
ie as rebasedMessage,
|
|
735
|
+
ae as replayedMessage,
|
|
736
|
+
$ as saveNote,
|
|
737
|
+
fe as stillMine,
|
|
738
|
+
qe as touchesOverview,
|
|
739
|
+
ge as useLayoutBundle,
|
|
740
|
+
Oe as useLayoutDraft
|
|
474
741
|
};
|