@tangle-network/agent-app 0.61.4 → 0.62.0
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/{DesignCanvas-L6J72JQ2.js → DesignCanvas-IQKYAEC4.js} +3 -2
- package/dist/{DesignCanvasEditor-QFQD63MR.js → DesignCanvasEditor-O7OCZTGC.js} +5 -4
- package/dist/{TimelineEditor-7KBPJQLT.js → TimelineEditor-VB2UJ34D.js} +4 -2
- package/dist/VaultPane-AYW7CO33.js +8 -0
- package/dist/agent-profiles/d1.js +1 -1
- package/dist/agent-profiles/index.d.ts +0 -82
- package/dist/agent-profiles/index.js +1 -21
- package/dist/agent-profiles/self-management.d.ts +0 -55
- package/dist/alerting/index.d.ts +1 -1
- package/dist/alerting/index.js +1 -3
- package/dist/alerting/slack.d.ts +6 -79
- package/dist/app-auth/drizzle.d.ts +17 -271
- package/dist/app-auth/drizzle.js +6 -2
- package/dist/app-auth/drizzle.js.map +1 -1
- package/dist/app-auth/index.js +3 -3
- package/dist/assets/types.d.ts +2 -1
- package/dist/assistant/AssistantPanel.d.ts +1 -1
- package/dist/assistant/index.js +635 -392
- package/dist/assistant/index.js.map +1 -1
- package/dist/billing/identity-locks.d.ts +5 -0
- package/dist/billing/index.js +1 -1
- package/dist/brand-extraction/index.js.map +1 -1
- package/dist/brand-extraction/types.d.ts +2 -1
- package/dist/chat-react/index.js +6 -5
- package/dist/chat-routes/attachment-write-safety.d.ts +4 -0
- package/dist/chat-routes/draft-persistence.d.ts +2 -14
- package/dist/chat-routes/index.d.ts +1 -0
- package/dist/chat-routes/index.js +853 -773
- package/dist/chat-routes/index.js.map +1 -1
- package/dist/chat-routes/sandbox-model-source.d.ts +20 -0
- package/dist/chat-routes/stored-attachments.d.ts +18 -0
- package/dist/chat-routes/turn-admission.d.ts +1 -1
- package/dist/chat-routes/turn-execution.d.ts +2 -2
- package/dist/chat-routes/turn-route-contracts.d.ts +3 -29
- package/dist/chat-store/core.d.ts +19 -1
- package/dist/chat-store/index.js.map +1 -1
- package/dist/chat-store/store.d.ts +3 -29
- package/dist/{chunk-ATQQCG4I.js → chunk-2VJLLRVV.js} +2 -2
- package/dist/{chunk-R4X5474U.js → chunk-52SDU43B.js} +12 -27
- package/dist/chunk-52SDU43B.js.map +1 -0
- package/dist/{chunk-MDRH3SDA.js → chunk-54YIL7WM.js} +3 -3
- package/dist/{chunk-6QJ3GB3A.js → chunk-5GSZGTPJ.js} +2 -2
- package/dist/{chunk-5IM2CLYX.js → chunk-6JEDSKFH.js} +232 -218
- package/dist/chunk-6JEDSKFH.js.map +1 -0
- package/dist/{chunk-6PRQ45QE.js → chunk-6OG4244Y.js} +1 -1
- package/dist/chunk-6OG4244Y.js.map +1 -0
- package/dist/{chunk-ZDPUC6CM.js → chunk-6ZVSMA4T.js} +3 -3
- package/dist/{chunk-TXUAGSFR.js → chunk-76MPX7JQ.js} +47 -1
- package/dist/chunk-76MPX7JQ.js.map +1 -0
- package/dist/{chunk-BOQ4HVVH.js → chunk-7ISHKBAD.js} +61 -52
- package/dist/chunk-7ISHKBAD.js.map +1 -0
- package/dist/chunk-7PULOECS.js +22 -0
- package/dist/chunk-7PULOECS.js.map +1 -0
- package/dist/{chunk-KJODHPWM.js → chunk-CPVGRQ43.js} +511 -339
- package/dist/chunk-CPVGRQ43.js.map +1 -0
- package/dist/{chunk-LO6VQ35O.js → chunk-CQZVJVME.js} +2 -2
- package/dist/{chunk-Y43PXON2.js → chunk-EFQUAWWF.js} +577 -546
- package/dist/chunk-EFQUAWWF.js.map +1 -0
- package/dist/{chunk-FPNZMIAW.js → chunk-ELX5YITO.js} +1 -1
- package/dist/chunk-ELX5YITO.js.map +1 -0
- package/dist/chunk-FGAROAUF.js +19 -0
- package/dist/chunk-FGAROAUF.js.map +1 -0
- package/dist/{chunk-HN6MZ2XL.js → chunk-FTNGGR37.js} +641 -466
- package/dist/chunk-FTNGGR37.js.map +1 -0
- package/dist/{chunk-G4F2NWZH.js → chunk-FZ3ZFVAC.js} +4 -4
- package/dist/{chunk-UCCSJX64.js → chunk-GIEUZBQQ.js} +1112 -644
- package/dist/chunk-GIEUZBQQ.js.map +1 -0
- package/dist/{chunk-MEKOWH5E.js → chunk-IVBREL7A.js} +785 -526
- package/dist/chunk-IVBREL7A.js.map +1 -0
- package/dist/{chunk-WSEXFTN4.js → chunk-JBXNU5WD.js} +26 -26
- package/dist/chunk-JBXNU5WD.js.map +1 -0
- package/dist/{chunk-F2VX6TTJ.js → chunk-JRCZHDRG.js} +2 -41
- package/dist/chunk-JRCZHDRG.js.map +1 -0
- package/dist/{chunk-LXYQOOXU.js → chunk-JRW6LCIA.js} +552 -302
- package/dist/chunk-JRW6LCIA.js.map +1 -0
- package/dist/{chunk-TVPH5T4F.js → chunk-KS4I7KVC.js} +16 -22
- package/dist/{chunk-TVPH5T4F.js.map → chunk-KS4I7KVC.js.map} +1 -1
- package/dist/{chunk-J2BBYVGF.js → chunk-MRZP65DZ.js} +1 -117
- package/dist/chunk-MRZP65DZ.js.map +1 -0
- package/dist/{chunk-4ZSLX3LY.js → chunk-OODZCBSM.js} +1 -1
- package/dist/chunk-OODZCBSM.js.map +1 -0
- package/dist/chunk-P4RRC4AO.js +47 -0
- package/dist/chunk-P4RRC4AO.js.map +1 -0
- package/dist/{chunk-ORQD4AUO.js → chunk-PCAY23GS.js} +1 -6
- package/dist/chunk-PCAY23GS.js.map +1 -0
- package/dist/{chunk-NMZUW6VJ.js → chunk-PEJ5OP5B.js} +3 -3
- package/dist/chunk-PEJ5OP5B.js.map +1 -0
- package/dist/{chunk-NHYRIM4I.js → chunk-PIPNDZ6H.js} +304 -194
- package/dist/chunk-PIPNDZ6H.js.map +1 -0
- package/dist/{chunk-L7LQRJGD.js → chunk-TCJ4TMOW.js} +37 -33
- package/dist/{chunk-L7LQRJGD.js.map → chunk-TCJ4TMOW.js.map} +1 -1
- package/dist/chunk-UHSUY6H6.js +79 -0
- package/dist/chunk-UHSUY6H6.js.map +1 -0
- package/dist/{chunk-PDD5A43Y.js → chunk-UTL6TEN6.js} +3 -3
- package/dist/{chunk-VJBFCNAU.js → chunk-UW2DKTEM.js} +123 -130
- package/dist/chunk-UW2DKTEM.js.map +1 -0
- package/dist/{chunk-S27DKRI6.js → chunk-VDYEVCQQ.js} +2 -2
- package/dist/{chunk-UFQM46NV.js → chunk-VK3F4N4U.js} +2 -2
- package/dist/{chunk-6ZIC6OG5.js → chunk-VYBTQK25.js} +126 -122
- package/dist/chunk-VYBTQK25.js.map +1 -0
- package/dist/{chunk-RL3Z747H.js → chunk-W2BV2XOC.js} +1491 -700
- package/dist/chunk-W2BV2XOC.js.map +1 -0
- package/dist/{chunk-FUZETA6Z.js → chunk-X6SZGQTK.js} +2 -2
- package/dist/{chunk-CD2LQXY6.js → chunk-XOHE6SKU.js} +14 -16
- package/dist/{chunk-CD2LQXY6.js.map → chunk-XOHE6SKU.js.map} +1 -1
- package/dist/{chunk-ZBB5KQ6B.js → chunk-Y3GO6SG3.js} +73 -66
- package/dist/chunk-Y3GO6SG3.js.map +1 -0
- package/dist/chunk-ZAMHLXNS.js +56 -0
- package/dist/chunk-ZAMHLXNS.js.map +1 -0
- package/dist/{chunk-RHFN7TUV.js → chunk-ZDHCV462.js} +47 -44
- package/dist/{chunk-RHFN7TUV.js.map → chunk-ZDHCV462.js.map} +1 -1
- package/dist/chunk-ZOS3D26Z.js +72 -0
- package/dist/chunk-ZOS3D26Z.js.map +1 -0
- package/dist/design-canvas/index.js +32 -32
- package/dist/design-canvas/index.js.map +1 -1
- package/dist/design-canvas-react/components/DesignCanvas.d.ts +1 -1
- package/dist/design-canvas-react/components/Workspace.d.ts +1 -1
- package/dist/design-canvas-react/components/glyphs.d.ts +31 -40
- package/dist/design-canvas-react/components/transform-math.d.ts +0 -8
- package/dist/design-canvas-react/components/use-workspace-keyboard.d.ts +2 -2
- package/dist/design-canvas-react/contracts.d.ts +2 -2
- package/dist/design-canvas-react/engine.js +1 -1
- package/dist/design-canvas-react/index.js +9 -7
- package/dist/design-canvas-react/index.js.map +1 -1
- package/dist/design-canvas-react/lazy.js +1 -1
- package/dist/eval/calibration.d.ts +1 -38
- package/dist/eval/index.d.ts +2 -4
- package/dist/eval/index.js +0 -84
- package/dist/eval/index.js.map +1 -1
- package/dist/harness/index.d.ts +1 -1
- package/dist/harness/index.js +1 -1
- package/dist/harness/session-selection.d.ts +2 -2
- package/dist/hub-approvals/index.js +1 -1
- package/dist/hub-approvals/result.d.ts +1 -1
- package/dist/hub-approvals-react/index.js +4 -4
- package/dist/hub-approvals-react/index.js.map +1 -1
- package/dist/hub-approvals-react/parts.d.ts +1 -1
- package/dist/launch-invariants/cli.js +4 -4
- package/dist/launch-invariants/index.js +3 -3
- package/dist/launch-invariants/testing.js +4 -4
- package/dist/legibility/cli.js +1 -1
- package/dist/legibility/index.js +1 -1
- package/dist/{mention-editor-B23OMFT2.js → mention-editor-4BKBMWIK.js} +83 -57
- package/dist/mention-editor-4BKBMWIK.js.map +1 -0
- package/dist/missions/index.js +144 -137
- package/dist/missions/index.js.map +1 -1
- package/dist/operator/index.js +1 -1
- package/dist/peer-floors/check.js +1 -1
- package/dist/peer-floors/cli.js +6 -14
- package/dist/peer-floors/cli.js.map +1 -1
- package/dist/peer-floors/source-entries.d.ts +6 -0
- package/dist/platform/index.js +10 -10
- package/dist/preset-cloudflare/index.js +1 -1
- package/dist/profile/index.d.ts +0 -1
- package/dist/profile/index.js +1 -422
- package/dist/profile/index.js.map +1 -1
- package/dist/profile-editor/server.d.ts +0 -1
- package/dist/profile-editor/server.js +0 -1
- package/dist/profile-editor/server.js.map +1 -1
- package/dist/public-consultation/index.d.ts +2 -2
- package/dist/public-consultation/index.js +6 -6
- package/dist/record/drizzle.js +156 -148
- package/dist/record/drizzle.js.map +1 -1
- package/dist/runtime/index.js +4 -4
- package/dist/runtime/router-turn.js +3 -3
- package/dist/sandbox/index.js +5 -5
- package/dist/sequences/drizzle.js +5 -15
- package/dist/sequences/drizzle.js.map +1 -1
- package/dist/sequences/index.d.ts +1 -0
- package/dist/sequences/index.js +18 -14
- package/dist/sequences/index.js.map +1 -1
- package/dist/sequences/row-mapping.d.ts +7 -0
- package/dist/sequences-react/components/TimelineEditor.d.ts +0 -40
- package/dist/sequences-react/components/TimelineHistory.d.ts +31 -0
- package/dist/sequences-react/components/glyphs.d.ts +12 -21
- package/dist/sequences-react/components/index.d.ts +0 -2
- package/dist/sequences-react/components/interaction-math.d.ts +3 -3
- package/dist/sequences-react/contracts.d.ts +1 -1
- package/dist/sequences-react/engine/snap.d.ts +2 -2
- package/dist/sequences-react/index.js +4 -4
- package/dist/sequences-react/index.js.map +1 -1
- package/dist/settings-react/index.js +13 -30
- package/dist/settings-react/index.js.map +1 -1
- package/dist/settings-react/timezone-picker.d.ts +0 -6
- package/dist/signoff/browser-budget.d.ts +6 -1
- package/dist/signoff/cli.d.ts +0 -7
- package/dist/signoff/cli.js +1 -2
- package/dist/signoff/cli.js.map +1 -1
- package/dist/signoff/index.js +1 -1
- package/dist/skills/index.d.ts +1 -1
- package/dist/skills/index.js +5 -25
- package/dist/skills/marketplace.d.ts +1 -75
- package/dist/skills-placement/box.js +3 -4
- package/dist/skills-placement/box.js.map +1 -1
- package/dist/skills-placement/index.js +3 -4
- package/dist/spend/cli-args.d.ts +1 -1
- package/dist/spend/cli.js +3 -3
- package/dist/spend/cli.js.map +1 -1
- package/dist/spend/index.js +1 -1
- package/dist/stories/design-canvas/fixtures.d.ts +1 -14
- package/dist/stream/index.js +17 -17
- package/dist/studio/generation.d.ts +1 -1
- package/dist/studio/index.js +1 -1
- package/dist/studio-react/index.js +353 -184
- package/dist/studio-react/index.js.map +1 -1
- package/dist/studio-react/studio-composer.d.ts +1 -5
- package/dist/studio-react/studio-history-screen.d.ts +1 -1
- package/dist/teams/invitations-api.d.ts +3 -3
- package/dist/teams/invitations-api.js +74 -72
- package/dist/teams/invitations-api.js.map +1 -1
- package/dist/teams/member-sync.d.ts +2 -0
- package/dist/teams/members-api.d.ts +2 -2
- package/dist/teams/members-api.js +1 -1
- package/dist/teams-react/index.js +28 -45
- package/dist/teams-react/index.js.map +1 -1
- package/dist/tools/index.js +1 -1
- package/dist/tools/mcp-arguments.d.ts +1 -1
- package/dist/trace/index.d.ts +1 -18
- package/dist/trace/index.js +1 -36
- package/dist/trace/index.js.map +1 -1
- package/dist/trace/mission-flow.d.ts +1 -59
- package/dist/turn-health/index.d.ts +1 -1
- package/dist/turn-health/index.js +2 -2
- package/dist/turn-health/sink.d.ts +2 -1
- package/dist/turn-trace/index.js +2 -4
- package/dist/turn-trace/recorder.d.ts +0 -2
- package/dist/vault/VaultPane.d.ts +0 -20
- package/dist/vault/VaultPaneOperations.d.ts +318 -0
- package/dist/vault/index.js +2 -1
- package/dist/vault/index.js.map +1 -1
- package/dist/vault/lazy.js +1 -1
- package/dist/web-react/agent-profile-editor.d.ts +1 -2
- package/dist/web-react/agent-profile-editor.js +6 -5
- package/dist/web-react/chat-composer.d.ts +1 -1
- package/dist/web-react/durable-plan-flow.d.ts +6 -1
- package/dist/web-react/editor-glyphs.d.ts +12 -0
- package/dist/web-react/focus-navigation.d.ts +12 -0
- package/dist/web-react/history-controls.d.ts +37 -0
- package/dist/web-react/index.js +36 -34
- package/dist/web-react/interaction-question-card.d.ts +1 -1
- package/dist/web-react/record-grid-writes.d.ts +31 -0
- package/dist/web-react/record-grid.d.ts +1 -48
- package/dist/web-react/session-history-panel.d.ts +1 -9
- package/dist/web-react/use-document-dark.d.ts +1 -0
- package/dist/workspace-export/engine.d.ts +1 -6
- package/dist/workspace-export/index.js +198 -185
- package/dist/workspace-export/index.js.map +1 -1
- package/dist/workspace-export/routes.d.ts +1 -1
- package/dist/workspace-react/index.js +9 -8
- package/dist/workspace-react/index.js.map +1 -1
- package/package.json +1 -11
- package/dist/VaultPane-RXL3WLA2.js +0 -7
- package/dist/agent-profiles/reaper.d.ts +0 -31
- package/dist/agent-profiles/reaper.js +0 -29
- package/dist/agent-profiles/reaper.js.map +0 -1
- package/dist/chunk-4ZSLX3LY.js.map +0 -1
- package/dist/chunk-5IM2CLYX.js.map +0 -1
- package/dist/chunk-6OSJNJA2.js +0 -251
- package/dist/chunk-6OSJNJA2.js.map +0 -1
- package/dist/chunk-6PRQ45QE.js.map +0 -1
- package/dist/chunk-6ZIC6OG5.js.map +0 -1
- package/dist/chunk-BDEBQ4WO.js +0 -38
- package/dist/chunk-BDEBQ4WO.js.map +0 -1
- package/dist/chunk-BOQ4HVVH.js.map +0 -1
- package/dist/chunk-F2VX6TTJ.js.map +0 -1
- package/dist/chunk-FPNZMIAW.js.map +0 -1
- package/dist/chunk-HN6MZ2XL.js.map +0 -1
- package/dist/chunk-J2BBYVGF.js.map +0 -1
- package/dist/chunk-KJODHPWM.js.map +0 -1
- package/dist/chunk-LTWJYNEC.js +0 -100
- package/dist/chunk-LTWJYNEC.js.map +0 -1
- package/dist/chunk-LXYQOOXU.js.map +0 -1
- package/dist/chunk-MEKOWH5E.js.map +0 -1
- package/dist/chunk-NHYRIM4I.js.map +0 -1
- package/dist/chunk-NMZUW6VJ.js.map +0 -1
- package/dist/chunk-ORQD4AUO.js.map +0 -1
- package/dist/chunk-R4X5474U.js.map +0 -1
- package/dist/chunk-RL3Z747H.js.map +0 -1
- package/dist/chunk-TXUAGSFR.js.map +0 -1
- package/dist/chunk-UCCSJX64.js.map +0 -1
- package/dist/chunk-VJBFCNAU.js.map +0 -1
- package/dist/chunk-WSEXFTN4.js.map +0 -1
- package/dist/chunk-Y43PXON2.js.map +0 -1
- package/dist/chunk-ZBB5KQ6B.js.map +0 -1
- package/dist/eval/parity.d.ts +0 -74
- package/dist/mention-editor-B23OMFT2.js.map +0 -1
- package/dist/profile/humanizer-skill.d.ts +0 -23
- package/dist/profile/humanizer-skill.vendored.d.ts +0 -4
- package/dist/sequences-react/components/BrandMark.d.ts +0 -10
- package/dist/skills/marketplace-drizzle.d.ts +0 -121
- package/dist/skills/marketplace-drizzle.js +0 -34
- package/dist/skills/marketplace-drizzle.js.map +0 -1
- package/dist/teams-react/components/BrandMark.d.ts +0 -10
- /package/dist/{DesignCanvas-L6J72JQ2.js.map → DesignCanvas-IQKYAEC4.js.map} +0 -0
- /package/dist/{DesignCanvasEditor-QFQD63MR.js.map → DesignCanvasEditor-O7OCZTGC.js.map} +0 -0
- /package/dist/{TimelineEditor-7KBPJQLT.js.map → TimelineEditor-VB2UJ34D.js.map} +0 -0
- /package/dist/{VaultPane-RXL3WLA2.js.map → VaultPane-AYW7CO33.js.map} +0 -0
- /package/dist/{chunk-ATQQCG4I.js.map → chunk-2VJLLRVV.js.map} +0 -0
- /package/dist/{chunk-MDRH3SDA.js.map → chunk-54YIL7WM.js.map} +0 -0
- /package/dist/{chunk-6QJ3GB3A.js.map → chunk-5GSZGTPJ.js.map} +0 -0
- /package/dist/{chunk-ZDPUC6CM.js.map → chunk-6ZVSMA4T.js.map} +0 -0
- /package/dist/{chunk-LO6VQ35O.js.map → chunk-CQZVJVME.js.map} +0 -0
- /package/dist/{chunk-G4F2NWZH.js.map → chunk-FZ3ZFVAC.js.map} +0 -0
- /package/dist/{chunk-PDD5A43Y.js.map → chunk-UTL6TEN6.js.map} +0 -0
- /package/dist/{chunk-S27DKRI6.js.map → chunk-VDYEVCQQ.js.map} +0 -0
- /package/dist/{chunk-UFQM46NV.js.map → chunk-VK3F4N4U.js.map} +0 -0
- /package/dist/{chunk-FUZETA6Z.js.map → chunk-X6SZGQTK.js.map} +0 -0
|
@@ -1,10 +1,746 @@
|
|
|
1
|
+
import {
|
|
2
|
+
containDialogTab
|
|
3
|
+
} from "./chunk-ZAMHLXNS.js";
|
|
4
|
+
|
|
5
|
+
// src/vault/VaultPaneStates.tsx
|
|
6
|
+
import { Component, useId } from "react";
|
|
7
|
+
import { FileText, Plus } from "lucide-react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
function operationMessage(error, fallback) {
|
|
10
|
+
return error instanceof Error && error.message ? error.message : fallback;
|
|
11
|
+
}
|
|
12
|
+
function treeFailureMessage(failure, label) {
|
|
13
|
+
if (failure.phase !== "post-mutation-refresh") return failure.message;
|
|
14
|
+
const completed = failure.operation === "create" ? "created" : "deleted";
|
|
15
|
+
return `The file was ${completed}, but ${label} couldn't refresh. ${failure.message}`;
|
|
16
|
+
}
|
|
17
|
+
var EditorErrorBoundary = class extends Component {
|
|
18
|
+
state = { error: null };
|
|
19
|
+
static getDerivedStateFromError(error) {
|
|
20
|
+
return { error };
|
|
21
|
+
}
|
|
22
|
+
componentDidCatch(error, info) {
|
|
23
|
+
console.error("Vault crashed:", error, info);
|
|
24
|
+
}
|
|
25
|
+
render() {
|
|
26
|
+
if (this.state.error) {
|
|
27
|
+
const msg = this.state.error instanceof Error ? this.state.error.message : typeof this.state.error === "string" ? this.state.error : `${this.props.label} did not load. Reload the page to try again.`;
|
|
28
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-1 flex-col items-center justify-center p-8 text-center", children: [
|
|
29
|
+
/* @__PURE__ */ jsxs("h3", { className: "mb-1 text-sm font-medium text-foreground", children: [
|
|
30
|
+
this.props.label,
|
|
31
|
+
" failed to load"
|
|
32
|
+
] }),
|
|
33
|
+
/* @__PURE__ */ jsx("p", { className: "mb-4 max-w-xs text-xs text-muted-foreground", children: String(msg) }),
|
|
34
|
+
/* @__PURE__ */ jsx(
|
|
35
|
+
"button",
|
|
36
|
+
{
|
|
37
|
+
type: "button",
|
|
38
|
+
onClick: () => {
|
|
39
|
+
this.setState({ error: null });
|
|
40
|
+
this.props.onReset?.();
|
|
41
|
+
},
|
|
42
|
+
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
43
|
+
children: "Try again"
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
] });
|
|
47
|
+
}
|
|
48
|
+
return this.props.children;
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
function SkeletonRegion({ label, className, children }) {
|
|
52
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
53
|
+
/* @__PURE__ */ jsx("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: "sr-only", children: label }),
|
|
54
|
+
/* @__PURE__ */ jsx("div", { className, "aria-hidden": "true", children })
|
|
55
|
+
] });
|
|
56
|
+
}
|
|
57
|
+
function TreeSkeleton() {
|
|
58
|
+
return /* @__PURE__ */ jsx(SkeletonRegion, { label: "Loading files\u2026", className: "space-y-2 p-4", children: [32, 48, 40, 52].map((w, i) => /* @__PURE__ */ jsx("div", { className: "h-4 animate-pulse rounded bg-muted", style: { width: `${w * 4}px` } }, i)) });
|
|
59
|
+
}
|
|
60
|
+
function EditorSkeleton() {
|
|
61
|
+
return /* @__PURE__ */ jsxs(SkeletonRegion, { label: "Loading file\u2026", className: "space-y-3 p-8", children: [
|
|
62
|
+
/* @__PURE__ */ jsx("div", { className: "h-5 w-1/2 animate-pulse rounded bg-muted" }),
|
|
63
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-full animate-pulse rounded bg-muted" }),
|
|
64
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-3/4 animate-pulse rounded bg-muted" }),
|
|
65
|
+
/* @__PURE__ */ jsx("div", { className: "h-4 w-2/3 animate-pulse rounded bg-muted" })
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
function RetryButton({ onRetry }) {
|
|
69
|
+
return /* @__PURE__ */ jsx(
|
|
70
|
+
"button",
|
|
71
|
+
{
|
|
72
|
+
type: "button",
|
|
73
|
+
onClick: onRetry,
|
|
74
|
+
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
75
|
+
children: "Retry"
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}
|
|
79
|
+
function ReadErrorState({ message: message2, onRetry }) {
|
|
80
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-8 text-center", children: [
|
|
81
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
82
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-foreground", children: "Couldn't open this file" }),
|
|
83
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 max-w-md text-xs text-muted-foreground", children: message2 })
|
|
84
|
+
] }),
|
|
85
|
+
/* @__PURE__ */ jsx(RetryButton, { onRetry })
|
|
86
|
+
] });
|
|
87
|
+
}
|
|
88
|
+
function TreeErrorState({ label, message: message2, onRetry }) {
|
|
89
|
+
return /* @__PURE__ */ jsxs("div", { role: "alert", className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
|
|
90
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
91
|
+
/* @__PURE__ */ jsxs("h3", { className: "text-sm font-medium text-foreground", children: [
|
|
92
|
+
"Couldn't load ",
|
|
93
|
+
label
|
|
94
|
+
] }),
|
|
95
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: message2 })
|
|
96
|
+
] }),
|
|
97
|
+
/* @__PURE__ */ jsx(RetryButton, { onRetry })
|
|
98
|
+
] });
|
|
99
|
+
}
|
|
100
|
+
function TreeEmptyState({ canCreate, onCreate }) {
|
|
101
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
|
|
102
|
+
/* @__PURE__ */ jsxs("div", { children: [
|
|
103
|
+
/* @__PURE__ */ jsx("h3", { className: "text-sm font-medium text-foreground", children: "No files yet" }),
|
|
104
|
+
/* @__PURE__ */ jsx("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: canCreate ? "Create a file to start." : "Files appear here once they are added." })
|
|
105
|
+
] }),
|
|
106
|
+
canCreate && /* @__PURE__ */ jsxs(
|
|
107
|
+
"button",
|
|
108
|
+
{
|
|
109
|
+
type: "button",
|
|
110
|
+
onClick: onCreate,
|
|
111
|
+
className: "inline-flex h-8 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",
|
|
112
|
+
children: [
|
|
113
|
+
/* @__PURE__ */ jsx(Plus, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
|
|
114
|
+
"New file"
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
)
|
|
118
|
+
] });
|
|
119
|
+
}
|
|
120
|
+
function TreeNoMatchState({ query, onClear }) {
|
|
121
|
+
return /* @__PURE__ */ jsxs("div", { className: "flex flex-col items-center gap-3 p-6 text-center", children: [
|
|
122
|
+
/* @__PURE__ */ jsxs("p", { className: "max-w-xs break-words text-xs text-muted-foreground", children: [
|
|
123
|
+
"No files match \u201C",
|
|
124
|
+
query,
|
|
125
|
+
"\u201D."
|
|
126
|
+
] }),
|
|
127
|
+
/* @__PURE__ */ jsx(
|
|
128
|
+
"button",
|
|
129
|
+
{
|
|
130
|
+
type: "button",
|
|
131
|
+
onClick: onClear,
|
|
132
|
+
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
133
|
+
children: "Clear search"
|
|
134
|
+
}
|
|
135
|
+
)
|
|
136
|
+
] });
|
|
137
|
+
}
|
|
138
|
+
function OperationErrorAlert({
|
|
139
|
+
message: message2,
|
|
140
|
+
retryLabel,
|
|
141
|
+
onRetry,
|
|
142
|
+
onDismiss
|
|
143
|
+
}) {
|
|
144
|
+
return /* @__PURE__ */ jsxs(
|
|
145
|
+
"div",
|
|
146
|
+
{
|
|
147
|
+
role: "alert",
|
|
148
|
+
className: "flex shrink-0 items-center justify-between gap-3 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-[var(--surface-danger-text)]",
|
|
149
|
+
children: [
|
|
150
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1", children: message2 }),
|
|
151
|
+
/* @__PURE__ */ jsxs("div", { className: "flex shrink-0 items-center gap-3", children: [
|
|
152
|
+
/* @__PURE__ */ jsx("button", { type: "button", "aria-label": retryLabel, onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Retry" }),
|
|
153
|
+
/* @__PURE__ */ jsx("button", { type: "button", onClick: onDismiss, className: "underline-offset-2 hover:underline", children: "Dismiss" })
|
|
154
|
+
] })
|
|
155
|
+
]
|
|
156
|
+
}
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
function DocumentEmptyState({ label, recent, onOpen }) {
|
|
160
|
+
const recentHeadingId = useId();
|
|
161
|
+
return /* @__PURE__ */ jsx("div", { "data-vault-document-empty": true, className: "flex h-full items-center justify-center overflow-y-auto p-8", children: /* @__PURE__ */ jsxs("div", { className: "w-full max-w-sm text-center", children: [
|
|
162
|
+
/* @__PURE__ */ jsx("span", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx(FileText, { className: "size-5", "aria-hidden": "true" }) }),
|
|
163
|
+
/* @__PURE__ */ jsx("h3", { className: "mt-4 text-base font-semibold text-foreground", children: "Select a file" }),
|
|
164
|
+
/* @__PURE__ */ jsxs("p", { className: "mt-1 text-sm text-muted-foreground", children: [
|
|
165
|
+
"Choose a file in ",
|
|
166
|
+
label,
|
|
167
|
+
" to open it here."
|
|
168
|
+
] }),
|
|
169
|
+
recent.length > 0 && /* @__PURE__ */ jsxs("section", { "aria-labelledby": recentHeadingId, className: "mt-8 text-left", children: [
|
|
170
|
+
/* @__PURE__ */ jsx("h4", { id: recentHeadingId, className: "text-xs font-medium text-muted-foreground", children: "Recently opened" }),
|
|
171
|
+
/* @__PURE__ */ jsx("ul", { className: "mt-2 overflow-hidden rounded-xl border border-border bg-card shadow-raised", children: recent.map((path) => {
|
|
172
|
+
const slash = path.lastIndexOf("/");
|
|
173
|
+
return /* @__PURE__ */ jsx("li", { className: "border-b border-border last:border-b-0", children: /* @__PURE__ */ jsxs(
|
|
174
|
+
"button",
|
|
175
|
+
{
|
|
176
|
+
type: "button",
|
|
177
|
+
onClick: () => onOpen(path),
|
|
178
|
+
title: path,
|
|
179
|
+
className: "flex min-h-10 w-full items-center gap-2.5 px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
|
180
|
+
children: [
|
|
181
|
+
/* @__PURE__ */ jsx(FileText, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
182
|
+
/* @__PURE__ */ jsx("span", { className: "min-w-0 truncate font-medium", children: path.slice(slash + 1) }),
|
|
183
|
+
slash > 0 && /* @__PURE__ */ jsx("span", { className: "ml-auto min-w-0 shrink truncate text-xs text-muted-foreground", children: path.slice(0, slash) })
|
|
184
|
+
]
|
|
185
|
+
}
|
|
186
|
+
) }, path);
|
|
187
|
+
}) })
|
|
188
|
+
] })
|
|
189
|
+
] }) });
|
|
190
|
+
}
|
|
191
|
+
|
|
192
|
+
// src/vault/vault-tree-paths.ts
|
|
193
|
+
function collectTreePaths(nodes, into) {
|
|
194
|
+
for (const node of nodes) {
|
|
195
|
+
if (node.type === "file") into.files.add(node.path);
|
|
196
|
+
else into.directories.add(node.path);
|
|
197
|
+
if (node.children) collectTreePaths(node.children, into);
|
|
198
|
+
}
|
|
199
|
+
return into;
|
|
200
|
+
}
|
|
201
|
+
function resolveFilePath(rawPath, filePaths) {
|
|
202
|
+
if (filePaths.has(rawPath)) return rawPath;
|
|
203
|
+
const path = rawPath.replace(/^\/+|\/+$/g, "");
|
|
204
|
+
return filePaths.has(path) ? path : null;
|
|
205
|
+
}
|
|
206
|
+
function resolveTreePath(rawPath, paths) {
|
|
207
|
+
const file = resolveFilePath(rawPath, paths.files);
|
|
208
|
+
if (file) return { path: file, type: "file" };
|
|
209
|
+
if (paths.directories.has(rawPath)) return { path: rawPath, type: "directory" };
|
|
210
|
+
const trimmed = rawPath.replace(/^\/+|\/+$/g, "");
|
|
211
|
+
return paths.directories.has(trimmed) ? { path: trimmed, type: "directory" } : null;
|
|
212
|
+
}
|
|
213
|
+
function findDirectory(nodes, path) {
|
|
214
|
+
for (const node of nodes) {
|
|
215
|
+
if (node.type === "directory" && node.path === path) return node;
|
|
216
|
+
const found = node.children ? findDirectory(node.children, path) : null;
|
|
217
|
+
if (found) return found;
|
|
218
|
+
}
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
// src/vault/VaultPaneOperations.ts
|
|
223
|
+
function finishVaultPendingOpen(opened, clearNavigation = true, {
|
|
224
|
+
pendingOpenRef,
|
|
225
|
+
setPendingNav
|
|
226
|
+
}) {
|
|
227
|
+
const pending = pendingOpenRef.current;
|
|
228
|
+
if (!pending) return;
|
|
229
|
+
pendingOpenRef.current = null;
|
|
230
|
+
if (!opened && clearNavigation) {
|
|
231
|
+
setPendingNav((current) => current?.request === pending ? null : current);
|
|
232
|
+
}
|
|
233
|
+
pending.resolve(opened);
|
|
234
|
+
}
|
|
235
|
+
function commitVaultPath(next, {
|
|
236
|
+
controlled,
|
|
237
|
+
onSelectedPathChange,
|
|
238
|
+
setInternalPath
|
|
239
|
+
}) {
|
|
240
|
+
if (controlled) {
|
|
241
|
+
const decision = onSelectedPathChange?.(next);
|
|
242
|
+
return decision !== false;
|
|
243
|
+
}
|
|
244
|
+
setInternalPath(next);
|
|
245
|
+
onSelectedPathChange?.(next);
|
|
246
|
+
return true;
|
|
247
|
+
}
|
|
248
|
+
function reportVaultOperationFailure(operation, phase, error, fallback, path, { onOperationErrorRef }) {
|
|
249
|
+
const failure = {
|
|
250
|
+
operation,
|
|
251
|
+
phase,
|
|
252
|
+
path,
|
|
253
|
+
message: operationMessage(error, fallback),
|
|
254
|
+
cause: error
|
|
255
|
+
};
|
|
256
|
+
try {
|
|
257
|
+
onOperationErrorRef.current?.(failure);
|
|
258
|
+
} catch (callbackError) {
|
|
259
|
+
console.error("Vault onOperationError callback failed:", callbackError);
|
|
260
|
+
}
|
|
261
|
+
return failure;
|
|
262
|
+
}
|
|
263
|
+
async function refreshVaultTree(context = {
|
|
264
|
+
operation: "list",
|
|
265
|
+
phase: "operation"
|
|
266
|
+
}, {
|
|
267
|
+
treeRequestRef,
|
|
268
|
+
setTreeLoading,
|
|
269
|
+
setTreeError,
|
|
270
|
+
port,
|
|
271
|
+
setTree,
|
|
272
|
+
setTreeLoaded,
|
|
273
|
+
reportFailure,
|
|
274
|
+
label
|
|
275
|
+
}) {
|
|
276
|
+
const request = ++treeRequestRef.current;
|
|
277
|
+
setTreeLoading(true);
|
|
278
|
+
setTreeError(null);
|
|
279
|
+
try {
|
|
280
|
+
const nextTree = await port.listTree();
|
|
281
|
+
if (request !== treeRequestRef.current) return false;
|
|
282
|
+
setTree(nextTree);
|
|
283
|
+
setTreeLoaded(true);
|
|
284
|
+
return true;
|
|
285
|
+
} catch (error) {
|
|
286
|
+
if (request !== treeRequestRef.current) return false;
|
|
287
|
+
const failure = reportFailure(
|
|
288
|
+
context.operation,
|
|
289
|
+
context.phase,
|
|
290
|
+
error,
|
|
291
|
+
`Failed to load ${label}`,
|
|
292
|
+
context.path
|
|
293
|
+
);
|
|
294
|
+
setTreeError({ failure, context });
|
|
295
|
+
return false;
|
|
296
|
+
} finally {
|
|
297
|
+
if (request === treeRequestRef.current) setTreeLoading(false);
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
function openVaultFile(rawPath, resolve, {
|
|
301
|
+
treePaths,
|
|
302
|
+
finishPendingOpen,
|
|
303
|
+
setPendingNav,
|
|
304
|
+
selectedPath,
|
|
305
|
+
selectedFile,
|
|
306
|
+
displayReadyPath,
|
|
307
|
+
showDocument,
|
|
308
|
+
pendingOpenRef,
|
|
309
|
+
fileLoading,
|
|
310
|
+
readError,
|
|
311
|
+
treeError,
|
|
312
|
+
treeLoaded,
|
|
313
|
+
setReloadNonce,
|
|
314
|
+
isDirty,
|
|
315
|
+
commitPath
|
|
316
|
+
}) {
|
|
317
|
+
const target = resolveTreePath(rawPath, treePaths);
|
|
318
|
+
if (!rawPath.trim() || target?.type === "directory") {
|
|
319
|
+
resolve?.(false);
|
|
320
|
+
return;
|
|
321
|
+
}
|
|
322
|
+
const path = target?.path ?? rawPath;
|
|
323
|
+
finishPendingOpen(false);
|
|
324
|
+
setPendingNav(null);
|
|
325
|
+
if (path === selectedPath && selectedFile?.path === path && displayReadyPath === path) {
|
|
326
|
+
showDocument();
|
|
327
|
+
resolve?.(true);
|
|
328
|
+
return;
|
|
329
|
+
}
|
|
330
|
+
if (resolve) {
|
|
331
|
+
const pending = {
|
|
332
|
+
path,
|
|
333
|
+
fromPath: selectedPath,
|
|
334
|
+
resolve,
|
|
335
|
+
loaded: false,
|
|
336
|
+
selected: path === selectedPath
|
|
337
|
+
};
|
|
338
|
+
pendingOpenRef.current = pending;
|
|
339
|
+
}
|
|
340
|
+
if (path === selectedPath) {
|
|
341
|
+
showDocument();
|
|
342
|
+
if (!fileLoading && (readError || treeError && !treeLoaded)) setReloadNonce((nonce) => nonce + 1);
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (isDirty) {
|
|
346
|
+
setPendingNav({ path, request: resolve ? pendingOpenRef.current ?? void 0 : void 0 });
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
showDocument();
|
|
350
|
+
if (commitPath(path) === false) finishPendingOpen(false);
|
|
351
|
+
}
|
|
352
|
+
function discardVaultDraft({
|
|
353
|
+
pendingNav,
|
|
354
|
+
setPendingNav,
|
|
355
|
+
pendingOpenRef,
|
|
356
|
+
commitPath,
|
|
357
|
+
finishPendingOpen,
|
|
358
|
+
setIsDirty,
|
|
359
|
+
showDocument
|
|
360
|
+
}) {
|
|
361
|
+
const nav = pendingNav;
|
|
362
|
+
setPendingNav(null);
|
|
363
|
+
if (!nav) return;
|
|
364
|
+
if (nav.request && pendingOpenRef.current !== nav.request) return;
|
|
365
|
+
if (!commitPath(nav.path)) {
|
|
366
|
+
finishPendingOpen(false);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
setIsDirty(false);
|
|
370
|
+
showDocument();
|
|
371
|
+
}
|
|
372
|
+
function showVaultRichMode({
|
|
373
|
+
setEditorMode,
|
|
374
|
+
activeCodec,
|
|
375
|
+
sourceDraft,
|
|
376
|
+
draftContentRef,
|
|
377
|
+
dirtyRef,
|
|
378
|
+
savedContentRef,
|
|
379
|
+
editorModeRef,
|
|
380
|
+
setRichDraft,
|
|
381
|
+
setIsDirty
|
|
382
|
+
}) {
|
|
383
|
+
setEditorMode((mode) => {
|
|
384
|
+
if (mode === "rich") return mode;
|
|
385
|
+
const rich = activeCodec.parse(sourceDraft);
|
|
386
|
+
const content = activeCodec.serialize(rich);
|
|
387
|
+
draftContentRef.current = content;
|
|
388
|
+
dirtyRef.current = content !== savedContentRef.current;
|
|
389
|
+
editorModeRef.current = "rich";
|
|
390
|
+
setRichDraft(rich);
|
|
391
|
+
setIsDirty(dirtyRef.current);
|
|
392
|
+
return "rich";
|
|
393
|
+
});
|
|
394
|
+
}
|
|
395
|
+
function showVaultSourceMode({
|
|
396
|
+
setEditorMode,
|
|
397
|
+
isDirty,
|
|
398
|
+
activeCodec,
|
|
399
|
+
richDraft,
|
|
400
|
+
savedContentRef,
|
|
401
|
+
draftContentRef,
|
|
402
|
+
dirtyRef,
|
|
403
|
+
editorModeRef,
|
|
404
|
+
setSourceDraft,
|
|
405
|
+
setIsDirty
|
|
406
|
+
}) {
|
|
407
|
+
setEditorMode((mode) => {
|
|
408
|
+
if (mode === "source") return mode;
|
|
409
|
+
const content = isDirty ? activeCodec.serialize(richDraft) : savedContentRef.current;
|
|
410
|
+
draftContentRef.current = content;
|
|
411
|
+
dirtyRef.current = content !== savedContentRef.current;
|
|
412
|
+
editorModeRef.current = "source";
|
|
413
|
+
setSourceDraft(content);
|
|
414
|
+
setIsDirty(dirtyRef.current);
|
|
415
|
+
return "source";
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
function changeVaultSource(next, {
|
|
419
|
+
mountedRef,
|
|
420
|
+
editorModeRef,
|
|
421
|
+
saveScopeRef,
|
|
422
|
+
saveScopeKey,
|
|
423
|
+
draftContentRef,
|
|
424
|
+
dirtyRef,
|
|
425
|
+
savedContentRef,
|
|
426
|
+
setSourceDraft,
|
|
427
|
+
setIsDirty
|
|
428
|
+
}) {
|
|
429
|
+
if (!mountedRef.current || editorModeRef.current !== "source" || saveScopeRef.current.key !== saveScopeKey || !saveScopeRef.current.canWrite || saveScopeRef.current.historyOpen) return;
|
|
430
|
+
draftContentRef.current = next;
|
|
431
|
+
dirtyRef.current = next !== savedContentRef.current;
|
|
432
|
+
setSourceDraft(next);
|
|
433
|
+
setIsDirty(dirtyRef.current);
|
|
434
|
+
}
|
|
435
|
+
function changeVaultRichDraft(next, {
|
|
436
|
+
mountedRef,
|
|
437
|
+
editorModeRef,
|
|
438
|
+
saveScopeRef,
|
|
439
|
+
saveScopeKey,
|
|
440
|
+
draftContentRef,
|
|
441
|
+
activeCodec,
|
|
442
|
+
dirtyRef,
|
|
443
|
+
savedContentRef,
|
|
444
|
+
setRichDraft,
|
|
445
|
+
setIsDirty
|
|
446
|
+
}) {
|
|
447
|
+
if (!mountedRef.current || editorModeRef.current !== "rich" || saveScopeRef.current.key !== saveScopeKey || !saveScopeRef.current.canWrite || saveScopeRef.current.historyOpen) return;
|
|
448
|
+
draftContentRef.current = activeCodec.serialize(next);
|
|
449
|
+
dirtyRef.current = draftContentRef.current !== savedContentRef.current;
|
|
450
|
+
setRichDraft(next);
|
|
451
|
+
setIsDirty(dirtyRef.current);
|
|
452
|
+
}
|
|
453
|
+
async function saveVaultFile({
|
|
454
|
+
saveScopeRef,
|
|
455
|
+
mountedRef,
|
|
456
|
+
selectedFile,
|
|
457
|
+
dirtyRef,
|
|
458
|
+
saveScopeKey,
|
|
459
|
+
port,
|
|
460
|
+
saveRequestRef,
|
|
461
|
+
draftContentRef,
|
|
462
|
+
setSaving,
|
|
463
|
+
setSaveError,
|
|
464
|
+
savedContentRef,
|
|
465
|
+
savedResultRef,
|
|
466
|
+
setSelectedFile,
|
|
467
|
+
setIsDirty,
|
|
468
|
+
setSourceDraft,
|
|
469
|
+
setRichDraft,
|
|
470
|
+
activeCodec,
|
|
471
|
+
reportFailure,
|
|
472
|
+
loadedPathRef
|
|
473
|
+
}) {
|
|
474
|
+
const scope = saveScopeRef.current;
|
|
475
|
+
if (!mountedRef.current || !selectedFile || !scope.canWrite || scope.historyOpen || !dirtyRef.current || scope.key !== saveScopeKey || scope.port !== port || scope.path !== selectedFile.path || saveRequestRef.current) return;
|
|
476
|
+
const content = draftContentRef.current;
|
|
477
|
+
const request = {};
|
|
478
|
+
saveRequestRef.current = request;
|
|
479
|
+
const isCurrent = () => mountedRef.current && saveRequestRef.current === request && saveScopeRef.current.key === saveScopeKey && saveScopeRef.current.port === port && saveScopeRef.current.path === selectedFile.path && saveScopeRef.current.canWrite;
|
|
480
|
+
setSaving(true);
|
|
481
|
+
setSaveError(null);
|
|
482
|
+
try {
|
|
483
|
+
await port.writeFile(selectedFile.path, content);
|
|
484
|
+
if (!isCurrent()) return;
|
|
485
|
+
savedContentRef.current = content;
|
|
486
|
+
const savedFile = { ...selectedFile, content };
|
|
487
|
+
savedResultRef.current = savedFile;
|
|
488
|
+
setSelectedFile(savedFile);
|
|
489
|
+
const dirty = draftContentRef.current !== content;
|
|
490
|
+
dirtyRef.current = dirty;
|
|
491
|
+
setIsDirty(dirty);
|
|
492
|
+
if (!dirty) {
|
|
493
|
+
setSourceDraft(content);
|
|
494
|
+
setRichDraft(activeCodec.parse(content));
|
|
495
|
+
}
|
|
496
|
+
} catch (error) {
|
|
497
|
+
if (isCurrent()) setSaveError(reportFailure("save", "operation", error, "Failed to save file", selectedFile.path));
|
|
498
|
+
} finally {
|
|
499
|
+
if (saveRequestRef.current === request) {
|
|
500
|
+
saveRequestRef.current = null;
|
|
501
|
+
if (saveScopeRef.current.path !== selectedFile.path && loadedPathRef.current === selectedFile.path) {
|
|
502
|
+
dirtyRef.current = false;
|
|
503
|
+
setIsDirty(false);
|
|
504
|
+
}
|
|
505
|
+
setSaving(false);
|
|
506
|
+
}
|
|
507
|
+
}
|
|
508
|
+
}
|
|
509
|
+
async function createVaultFile({
|
|
510
|
+
newPath,
|
|
511
|
+
setCreating,
|
|
512
|
+
setCreateError,
|
|
513
|
+
port,
|
|
514
|
+
setCreateOpen,
|
|
515
|
+
setNewPath,
|
|
516
|
+
refresh,
|
|
517
|
+
commitPath,
|
|
518
|
+
reportFailure
|
|
519
|
+
}) {
|
|
520
|
+
const trimmed = newPath.trim();
|
|
521
|
+
if (!trimmed || !trimmed.split("/").pop()?.trim()) return;
|
|
522
|
+
setCreating(true);
|
|
523
|
+
setCreateError(null);
|
|
524
|
+
try {
|
|
525
|
+
const created = await port.createFile(trimmed);
|
|
526
|
+
setCreateOpen(false);
|
|
527
|
+
setNewPath("");
|
|
528
|
+
const refreshed = await refresh({
|
|
529
|
+
operation: "create",
|
|
530
|
+
phase: "post-mutation-refresh",
|
|
531
|
+
path: created,
|
|
532
|
+
selectAfterRecovery: created
|
|
533
|
+
});
|
|
534
|
+
if (refreshed) commitPath(created);
|
|
535
|
+
} catch (error) {
|
|
536
|
+
setCreateError(reportFailure("create", "operation", error, "Failed to create file", trimmed));
|
|
537
|
+
} finally {
|
|
538
|
+
setCreating(false);
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
async function deleteVaultFile({
|
|
542
|
+
selectedFile,
|
|
543
|
+
setDeleting,
|
|
544
|
+
setDeleteError,
|
|
545
|
+
port,
|
|
546
|
+
setDeleteOpen,
|
|
547
|
+
setIsDirty,
|
|
548
|
+
commitPath,
|
|
549
|
+
setSelectedFile,
|
|
550
|
+
refresh,
|
|
551
|
+
reportFailure
|
|
552
|
+
}) {
|
|
553
|
+
if (!selectedFile) return;
|
|
554
|
+
const path = selectedFile.path;
|
|
555
|
+
setDeleting(true);
|
|
556
|
+
setDeleteError(null);
|
|
557
|
+
try {
|
|
558
|
+
await port.deleteFile(path);
|
|
559
|
+
setDeleteOpen(false);
|
|
560
|
+
setIsDirty(false);
|
|
561
|
+
commitPath(null);
|
|
562
|
+
setSelectedFile(null);
|
|
563
|
+
await refresh({ operation: "delete", phase: "post-mutation-refresh", path });
|
|
564
|
+
} catch (error) {
|
|
565
|
+
setDeleteError(reportFailure("delete", "operation", error, "Failed to delete file", path));
|
|
566
|
+
} finally {
|
|
567
|
+
setDeleting(false);
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
async function restoreVaultRevision(content, {
|
|
571
|
+
saveScopeRef,
|
|
572
|
+
mountedRef,
|
|
573
|
+
selectedFile,
|
|
574
|
+
saveScopeKey,
|
|
575
|
+
port,
|
|
576
|
+
dirtyRef,
|
|
577
|
+
saveRequestRef,
|
|
578
|
+
setSaving,
|
|
579
|
+
setHistoryOpen,
|
|
580
|
+
setReloadNonce
|
|
581
|
+
}) {
|
|
582
|
+
const scope = saveScopeRef.current;
|
|
583
|
+
if (!mountedRef.current || !selectedFile || !scope.canWrite || !scope.historyOpen || scope.key !== saveScopeKey || scope.port !== port || scope.path !== selectedFile.path || dirtyRef.current || saveRequestRef.current) {
|
|
584
|
+
throw new Error("This file is no longer available to restore.");
|
|
585
|
+
}
|
|
586
|
+
const request = {};
|
|
587
|
+
saveRequestRef.current = request;
|
|
588
|
+
setSaving(true);
|
|
589
|
+
try {
|
|
590
|
+
await port.writeFile(selectedFile.path, content);
|
|
591
|
+
if (!mountedRef.current || saveRequestRef.current !== request || saveScopeRef.current.key !== saveScopeKey) return;
|
|
592
|
+
setHistoryOpen(false);
|
|
593
|
+
setReloadNonce((n) => n + 1);
|
|
594
|
+
} finally {
|
|
595
|
+
if (saveRequestRef.current === request) {
|
|
596
|
+
saveRequestRef.current = null;
|
|
597
|
+
setSaving(false);
|
|
598
|
+
}
|
|
599
|
+
}
|
|
600
|
+
}
|
|
601
|
+
function readVaultSelectedFile({
|
|
602
|
+
selectedPath,
|
|
603
|
+
setSelectedFile,
|
|
604
|
+
setFileLoading,
|
|
605
|
+
setReadError,
|
|
606
|
+
loadedPathRef,
|
|
607
|
+
treeError,
|
|
608
|
+
pendingOpenRef,
|
|
609
|
+
treeLoading,
|
|
610
|
+
treeLoaded,
|
|
611
|
+
isDirty,
|
|
612
|
+
saving,
|
|
613
|
+
resolvedSelectedPath,
|
|
614
|
+
finishPendingOpen,
|
|
615
|
+
commitPath,
|
|
616
|
+
port,
|
|
617
|
+
dirtyRef,
|
|
618
|
+
reportFailure
|
|
619
|
+
}) {
|
|
620
|
+
if (!selectedPath) {
|
|
621
|
+
setSelectedFile(null);
|
|
622
|
+
setFileLoading(false);
|
|
623
|
+
setReadError(null);
|
|
624
|
+
loadedPathRef.current = null;
|
|
625
|
+
return;
|
|
626
|
+
}
|
|
627
|
+
const explicitOpenAfterTreeError = !!treeError && pendingOpenRef.current?.path === selectedPath;
|
|
628
|
+
if (treeLoading || !treeLoaded && !explicitOpenAfterTreeError || isDirty || saving) return;
|
|
629
|
+
if (!resolvedSelectedPath) {
|
|
630
|
+
finishPendingOpen(false);
|
|
631
|
+
commitPath(null);
|
|
632
|
+
setSelectedFile(null);
|
|
633
|
+
setFileLoading(false);
|
|
634
|
+
setReadError(null);
|
|
635
|
+
loadedPathRef.current = null;
|
|
636
|
+
return;
|
|
637
|
+
}
|
|
638
|
+
let cancelled = false;
|
|
639
|
+
const path = resolvedSelectedPath;
|
|
640
|
+
if (path !== selectedPath) commitPath(path);
|
|
641
|
+
setFileLoading(true);
|
|
642
|
+
setReadError(null);
|
|
643
|
+
void (async () => {
|
|
644
|
+
try {
|
|
645
|
+
const file = await port.readFile(path);
|
|
646
|
+
if (file.path !== path) throw new Error(`Vault returned ${file.path} for ${path}`);
|
|
647
|
+
if (!cancelled && !dirtyRef.current) {
|
|
648
|
+
const pending = pendingOpenRef.current;
|
|
649
|
+
if (pending?.path === path) pending.loaded = true;
|
|
650
|
+
setSelectedFile(file);
|
|
651
|
+
} else if (!cancelled && pendingOpenRef.current?.path === path) {
|
|
652
|
+
finishPendingOpen(false);
|
|
653
|
+
}
|
|
654
|
+
} catch (err) {
|
|
655
|
+
if (!cancelled) {
|
|
656
|
+
if (pendingOpenRef.current?.path === path) finishPendingOpen(false);
|
|
657
|
+
const failure = reportFailure("read", "operation", err, "Failed to read file", path);
|
|
658
|
+
setSelectedFile((current) => current?.path === path ? current : null);
|
|
659
|
+
setReadError(failure.message);
|
|
660
|
+
}
|
|
661
|
+
} finally {
|
|
662
|
+
if (!cancelled) setFileLoading(false);
|
|
663
|
+
}
|
|
664
|
+
})();
|
|
665
|
+
return () => {
|
|
666
|
+
cancelled = true;
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
function reconcileVaultSelectedFile({
|
|
670
|
+
selectedFile,
|
|
671
|
+
loadedPathRef,
|
|
672
|
+
setDisplayReadyPath,
|
|
673
|
+
savedContentRef,
|
|
674
|
+
draftContentRef,
|
|
675
|
+
setRichDraft,
|
|
676
|
+
setSourceDraft,
|
|
677
|
+
setEditorMode,
|
|
678
|
+
setIsDirty,
|
|
679
|
+
setSaveError,
|
|
680
|
+
savedResultRef,
|
|
681
|
+
activeCodec,
|
|
682
|
+
setDockOpen
|
|
683
|
+
}) {
|
|
684
|
+
if (!selectedFile) {
|
|
685
|
+
loadedPathRef.current = null;
|
|
686
|
+
setDisplayReadyPath(null);
|
|
687
|
+
savedContentRef.current = "";
|
|
688
|
+
draftContentRef.current = "";
|
|
689
|
+
setRichDraft("");
|
|
690
|
+
setSourceDraft("");
|
|
691
|
+
setEditorMode("rich");
|
|
692
|
+
setIsDirty(false);
|
|
693
|
+
setSaveError(null);
|
|
694
|
+
return;
|
|
695
|
+
}
|
|
696
|
+
if (savedResultRef.current === selectedFile) {
|
|
697
|
+
savedResultRef.current = null;
|
|
698
|
+
return;
|
|
699
|
+
}
|
|
700
|
+
const pathChanged = loadedPathRef.current !== selectedFile.path;
|
|
701
|
+
loadedPathRef.current = selectedFile.path;
|
|
702
|
+
setDisplayReadyPath(selectedFile.path);
|
|
703
|
+
savedContentRef.current = selectedFile.content;
|
|
704
|
+
draftContentRef.current = selectedFile.content;
|
|
705
|
+
setRichDraft(activeCodec.parse(selectedFile.content));
|
|
706
|
+
setSourceDraft(selectedFile.content);
|
|
707
|
+
if (pathChanged) setEditorMode("rich");
|
|
708
|
+
setIsDirty(false);
|
|
709
|
+
setSaveError(null);
|
|
710
|
+
setDockOpen(false);
|
|
711
|
+
}
|
|
712
|
+
function completeVaultPendingOpen({
|
|
713
|
+
pendingOpenRef,
|
|
714
|
+
selectedPath,
|
|
715
|
+
selectedFile,
|
|
716
|
+
displayReadyPath,
|
|
717
|
+
sourceDraft,
|
|
718
|
+
fileLoading,
|
|
719
|
+
finishPendingOpen
|
|
720
|
+
}) {
|
|
721
|
+
const pending = pendingOpenRef.current;
|
|
722
|
+
if (pending?.loaded && pending.path === selectedPath && selectedFile?.path === pending.path && displayReadyPath === pending.path && sourceDraft === selectedFile.content && !fileLoading) {
|
|
723
|
+
finishPendingOpen(true);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
async function retryVaultTreeRefresh({
|
|
727
|
+
treeError,
|
|
728
|
+
refresh,
|
|
729
|
+
commitPath
|
|
730
|
+
}) {
|
|
731
|
+
if (!treeError) return;
|
|
732
|
+
const { context } = treeError;
|
|
733
|
+
const recovered = await refresh(context);
|
|
734
|
+
if (recovered && context.selectAfterRecovery) commitPath(context.selectAfterRecovery);
|
|
735
|
+
}
|
|
736
|
+
|
|
1
737
|
// src/vault/VaultPane.tsx
|
|
2
738
|
import { forwardRef, useCallback as useCallback2, useEffect as useEffect4, useImperativeHandle, useId as useId4, useMemo as useMemo2, useRef as useRef3, useState as useState4 } from "react";
|
|
3
739
|
import { VaultTree } from "@tangle-network/sandbox-ui/vault-tree";
|
|
4
740
|
|
|
5
741
|
// src/vault/ConfirmDialog.tsx
|
|
6
742
|
import { useEffect, useRef } from "react";
|
|
7
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
743
|
+
import { jsx as jsx2, jsxs as jsxs2 } from "react/jsx-runtime";
|
|
8
744
|
function ConfirmDialog({
|
|
9
745
|
open,
|
|
10
746
|
title,
|
|
@@ -36,30 +772,16 @@ function ConfirmDialog({
|
|
|
36
772
|
onConfirm();
|
|
37
773
|
return;
|
|
38
774
|
}
|
|
39
|
-
|
|
40
|
-
const focusable = panelRef.current?.querySelectorAll(
|
|
41
|
-
'button:not([disabled]), input:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])'
|
|
42
|
-
);
|
|
43
|
-
if (!focusable || focusable.length === 0) return;
|
|
44
|
-
const first = focusable[0];
|
|
45
|
-
const last = focusable[focusable.length - 1];
|
|
46
|
-
const active = document.activeElement;
|
|
47
|
-
if (event.shiftKey && active === first) {
|
|
48
|
-
event.preventDefault();
|
|
49
|
-
last?.focus();
|
|
50
|
-
} else if (!event.shiftKey && active === last) {
|
|
51
|
-
event.preventDefault();
|
|
52
|
-
first?.focus();
|
|
53
|
-
}
|
|
775
|
+
containDialogTab(event, panelRef.current);
|
|
54
776
|
}
|
|
55
|
-
return /* @__PURE__ */
|
|
777
|
+
return /* @__PURE__ */ jsx2(
|
|
56
778
|
"div",
|
|
57
779
|
{
|
|
58
780
|
className: "fixed inset-0 z-50 flex items-center justify-center bg-black/50 p-4",
|
|
59
781
|
onMouseDown: (e) => {
|
|
60
782
|
if (e.target === e.currentTarget) onCancel();
|
|
61
783
|
},
|
|
62
|
-
children: /* @__PURE__ */
|
|
784
|
+
children: /* @__PURE__ */ jsxs2(
|
|
63
785
|
"div",
|
|
64
786
|
{
|
|
65
787
|
ref: panelRef,
|
|
@@ -69,11 +791,11 @@ function ConfirmDialog({
|
|
|
69
791
|
onKeyDown,
|
|
70
792
|
className: "w-full max-w-md rounded-lg border border-border bg-card p-5 shadow-lg",
|
|
71
793
|
children: [
|
|
72
|
-
/* @__PURE__ */
|
|
73
|
-
description && /* @__PURE__ */
|
|
74
|
-
children && /* @__PURE__ */
|
|
75
|
-
/* @__PURE__ */
|
|
76
|
-
/* @__PURE__ */
|
|
794
|
+
/* @__PURE__ */ jsx2("h2", { className: "text-sm font-semibold text-foreground", children: title }),
|
|
795
|
+
description && /* @__PURE__ */ jsx2("p", { className: "mt-1.5 text-xs text-muted-foreground", children: description }),
|
|
796
|
+
children && /* @__PURE__ */ jsx2("div", { className: "mt-3", children }),
|
|
797
|
+
/* @__PURE__ */ jsxs2("div", { className: "mt-5 flex justify-end gap-2", children: [
|
|
798
|
+
/* @__PURE__ */ jsx2(
|
|
77
799
|
"button",
|
|
78
800
|
{
|
|
79
801
|
type: "button",
|
|
@@ -82,7 +804,7 @@ function ConfirmDialog({
|
|
|
82
804
|
children: cancelLabel
|
|
83
805
|
}
|
|
84
806
|
),
|
|
85
|
-
/* @__PURE__ */
|
|
807
|
+
/* @__PURE__ */ jsx2(
|
|
86
808
|
"button",
|
|
87
809
|
{
|
|
88
810
|
ref: confirmRef,
|
|
@@ -102,7 +824,7 @@ function ConfirmDialog({
|
|
|
102
824
|
}
|
|
103
825
|
|
|
104
826
|
// src/vault/SourceEditor.tsx
|
|
105
|
-
import { jsx as
|
|
827
|
+
import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
|
|
106
828
|
function SourceEditor({
|
|
107
829
|
path,
|
|
108
830
|
content,
|
|
@@ -111,11 +833,11 @@ function SourceEditor({
|
|
|
111
833
|
onChange,
|
|
112
834
|
onSave
|
|
113
835
|
}) {
|
|
114
|
-
return /* @__PURE__ */
|
|
115
|
-
/* @__PURE__ */
|
|
116
|
-
/* @__PURE__ */
|
|
117
|
-
/* @__PURE__ */
|
|
118
|
-
/* @__PURE__ */
|
|
836
|
+
return /* @__PURE__ */ jsxs3("div", { className: "flex h-full min-h-0 flex-col bg-background", children: [
|
|
837
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex items-center justify-between gap-2 border-b border-border px-4 py-2", children: [
|
|
838
|
+
/* @__PURE__ */ jsx3("p", { className: "truncate font-mono text-sm text-muted-foreground", children: path }),
|
|
839
|
+
/* @__PURE__ */ jsxs3("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
840
|
+
/* @__PURE__ */ jsx3(
|
|
119
841
|
"span",
|
|
120
842
|
{
|
|
121
843
|
role: "status",
|
|
@@ -124,7 +846,7 @@ function SourceEditor({
|
|
|
124
846
|
children: saving ? "Saving\u2026" : dirty ? "Unsaved changes" : "Saved"
|
|
125
847
|
}
|
|
126
848
|
),
|
|
127
|
-
(dirty || saving) && /* @__PURE__ */
|
|
849
|
+
(dirty || saving) && /* @__PURE__ */ jsx3(
|
|
128
850
|
"button",
|
|
129
851
|
{
|
|
130
852
|
type: "button",
|
|
@@ -137,7 +859,7 @@ function SourceEditor({
|
|
|
137
859
|
)
|
|
138
860
|
] })
|
|
139
861
|
] }),
|
|
140
|
-
/* @__PURE__ */
|
|
862
|
+
/* @__PURE__ */ jsx3(
|
|
141
863
|
"textarea",
|
|
142
864
|
{
|
|
143
865
|
value: content,
|
|
@@ -157,9 +879,9 @@ function SourceEditor({
|
|
|
157
879
|
}
|
|
158
880
|
|
|
159
881
|
// src/vault/VaultHistoryPanel.tsx
|
|
160
|
-
import { useCallback, useEffect as useEffect2, useId, useState } from "react";
|
|
882
|
+
import { useCallback, useEffect as useEffect2, useId as useId2, useState } from "react";
|
|
161
883
|
import { History, X } from "lucide-react";
|
|
162
|
-
import { jsx as
|
|
884
|
+
import { jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
|
|
163
885
|
function message(error, fallback) {
|
|
164
886
|
return error instanceof Error && error.message ? error.message : fallback;
|
|
165
887
|
}
|
|
@@ -177,7 +899,7 @@ function VaultHistoryPanel({
|
|
|
177
899
|
onRestore,
|
|
178
900
|
onClose
|
|
179
901
|
}) {
|
|
180
|
-
const listId =
|
|
902
|
+
const listId = useId2();
|
|
181
903
|
const [revisions, setRevisions] = useState({ status: "loading" });
|
|
182
904
|
const [listNonce, setListNonce] = useState(0);
|
|
183
905
|
const [selectedId, setSelectedId] = useState(null);
|
|
@@ -236,25 +958,25 @@ function VaultHistoryPanel({
|
|
|
236
958
|
setRestoring(false);
|
|
237
959
|
}
|
|
238
960
|
};
|
|
239
|
-
return /* @__PURE__ */
|
|
240
|
-
/* @__PURE__ */
|
|
961
|
+
return /* @__PURE__ */ jsxs4("div", { "data-vault-history": true, className: "flex h-full min-h-0 flex-col @[60rem]/vault:flex-row", children: [
|
|
962
|
+
/* @__PURE__ */ jsxs4(
|
|
241
963
|
"nav",
|
|
242
964
|
{
|
|
243
965
|
"aria-labelledby": listId,
|
|
244
966
|
className: "flex max-h-56 shrink-0 flex-col border-b border-border @[60rem]/vault:max-h-none @[60rem]/vault:w-64 @[60rem]/vault:border-b-0 @[60rem]/vault:border-r",
|
|
245
967
|
children: [
|
|
246
|
-
/* @__PURE__ */
|
|
247
|
-
/* @__PURE__ */
|
|
968
|
+
/* @__PURE__ */ jsxs4("h3", { id: listId, className: "flex items-center gap-2 px-4 pb-2 pt-3 text-sm font-semibold text-foreground", children: [
|
|
969
|
+
/* @__PURE__ */ jsx4(History, { className: "size-4 text-muted-foreground", "aria-hidden": "true" }),
|
|
248
970
|
"Saved versions"
|
|
249
971
|
] }),
|
|
250
|
-
/* @__PURE__ */
|
|
251
|
-
revisions.status === "loading" && /* @__PURE__ */
|
|
252
|
-
revisions.status === "error" && /* @__PURE__ */
|
|
253
|
-
/* @__PURE__ */
|
|
254
|
-
/* @__PURE__ */
|
|
972
|
+
/* @__PURE__ */ jsxs4("div", { className: "min-h-0 flex-1 overflow-y-auto px-2 pb-2", children: [
|
|
973
|
+
revisions.status === "loading" && /* @__PURE__ */ jsx4("p", { role: "status", className: "px-2 py-1 text-sm text-muted-foreground", children: "Loading versions\u2026" }),
|
|
974
|
+
revisions.status === "error" && /* @__PURE__ */ jsxs4("div", { role: "alert", className: "space-y-2 px-2 py-1 text-sm text-[var(--surface-danger-text)]", children: [
|
|
975
|
+
/* @__PURE__ */ jsx4("p", { children: revisions.message }),
|
|
976
|
+
/* @__PURE__ */ jsx4("button", { type: "button", onClick: () => setListNonce((n) => n + 1), className: "font-medium underline-offset-2 hover:underline", children: "Try again" })
|
|
255
977
|
] }),
|
|
256
|
-
revisions.status === "ready" && list.length === 0 && /* @__PURE__ */
|
|
257
|
-
/* @__PURE__ */
|
|
978
|
+
revisions.status === "ready" && list.length === 0 && /* @__PURE__ */ jsx4("p", { className: "px-2 py-1 text-sm text-muted-foreground", children: "No earlier versions are saved for this file." }),
|
|
979
|
+
/* @__PURE__ */ jsx4("ul", { className: "space-y-0.5", children: list.map((revision) => /* @__PURE__ */ jsx4("li", { children: /* @__PURE__ */ jsxs4(
|
|
258
980
|
"button",
|
|
259
981
|
{
|
|
260
982
|
type: "button",
|
|
@@ -262,11 +984,11 @@ function VaultHistoryPanel({
|
|
|
262
984
|
"aria-pressed": revision.id === selectedId,
|
|
263
985
|
className: `w-full rounded-md px-2 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring ${revision.id === selectedId ? "bg-muted" : "hover:bg-muted"}`,
|
|
264
986
|
children: [
|
|
265
|
-
/* @__PURE__ */
|
|
987
|
+
/* @__PURE__ */ jsxs4("span", { className: "flex items-center gap-2 text-sm font-medium text-foreground", children: [
|
|
266
988
|
savedAtLabel(revision.savedAt),
|
|
267
|
-
revision.current && /* @__PURE__ */
|
|
989
|
+
revision.current && /* @__PURE__ */ jsx4("span", { className: "rounded-full border border-border px-2 text-sm font-normal text-muted-foreground", children: "Current" })
|
|
268
990
|
] }),
|
|
269
|
-
revision.author && /* @__PURE__ */
|
|
991
|
+
revision.author && /* @__PURE__ */ jsx4("span", { className: "mt-0.5 block text-sm text-muted-foreground", children: revision.author })
|
|
270
992
|
]
|
|
271
993
|
}
|
|
272
994
|
) }, revision.id)) })
|
|
@@ -274,11 +996,11 @@ function VaultHistoryPanel({
|
|
|
274
996
|
]
|
|
275
997
|
}
|
|
276
998
|
),
|
|
277
|
-
/* @__PURE__ */
|
|
278
|
-
/* @__PURE__ */
|
|
279
|
-
/* @__PURE__ */
|
|
280
|
-
/* @__PURE__ */
|
|
281
|
-
restorable && /* @__PURE__ */
|
|
999
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex min-h-0 min-w-0 flex-1 flex-col", children: [
|
|
1000
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex flex-wrap items-center justify-between gap-2 border-b border-border px-4 py-2", children: [
|
|
1001
|
+
/* @__PURE__ */ jsx4("p", { className: "min-w-0 text-sm text-muted-foreground", children: selected ? selected.current ? "This is the version the file holds now." : `Saved ${savedAtLabel(selected.savedAt)}${selected.author ? ` by ${selected.author}` : ""}. Read only.` : "Choose a version to see it." }),
|
|
1002
|
+
/* @__PURE__ */ jsxs4("div", { className: "flex shrink-0 items-center gap-2", children: [
|
|
1003
|
+
restorable && /* @__PURE__ */ jsx4(
|
|
282
1004
|
"button",
|
|
283
1005
|
{
|
|
284
1006
|
type: "button",
|
|
@@ -290,27 +1012,27 @@ function VaultHistoryPanel({
|
|
|
290
1012
|
children: "Restore this version"
|
|
291
1013
|
}
|
|
292
1014
|
),
|
|
293
|
-
/* @__PURE__ */
|
|
1015
|
+
/* @__PURE__ */ jsxs4(
|
|
294
1016
|
"button",
|
|
295
1017
|
{
|
|
296
1018
|
type: "button",
|
|
297
1019
|
onClick: onClose,
|
|
298
1020
|
className: "inline-flex h-8 items-center gap-1.5 rounded-md border border-border px-3 text-sm text-foreground transition-colors hover:bg-muted",
|
|
299
1021
|
children: [
|
|
300
|
-
/* @__PURE__ */
|
|
1022
|
+
/* @__PURE__ */ jsx4(X, { className: "size-4", "aria-hidden": "true" }),
|
|
301
1023
|
"Close history"
|
|
302
1024
|
]
|
|
303
1025
|
}
|
|
304
1026
|
)
|
|
305
1027
|
] })
|
|
306
1028
|
] }),
|
|
307
|
-
restoreError && /* @__PURE__ */
|
|
308
|
-
/* @__PURE__ */
|
|
309
|
-
/* @__PURE__ */
|
|
310
|
-
/* @__PURE__ */
|
|
311
|
-
] }) : selectedId ? /* @__PURE__ */
|
|
1029
|
+
restoreError && /* @__PURE__ */ jsx4("p", { role: "alert", className: "border-b border-destructive/30 bg-destructive/10 px-4 py-2 text-sm text-[var(--surface-danger-text)]", children: restoreError }),
|
|
1030
|
+
/* @__PURE__ */ jsx4("div", { className: "min-h-0 flex-1 overflow-hidden", children: content?.status === "ready" && selected ? renderPreview(content.value, selected) : content?.status === "error" ? /* @__PURE__ */ jsxs4("div", { role: "alert", className: "space-y-2 p-6 text-sm text-[var(--surface-danger-text)]", children: [
|
|
1031
|
+
/* @__PURE__ */ jsx4("p", { children: content.message }),
|
|
1032
|
+
/* @__PURE__ */ jsx4("button", { type: "button", onClick: () => selectedId && loadContent(selectedId), className: "font-medium underline-offset-2 hover:underline", children: "Try again" })
|
|
1033
|
+
] }) : selectedId ? /* @__PURE__ */ jsx4("p", { role: "status", className: "p-6 text-sm text-muted-foreground", children: "Loading this version\u2026" }) : null })
|
|
312
1034
|
] }),
|
|
313
|
-
/* @__PURE__ */
|
|
1035
|
+
/* @__PURE__ */ jsx4(
|
|
314
1036
|
ConfirmDialog,
|
|
315
1037
|
{
|
|
316
1038
|
open: confirming && restorable,
|
|
@@ -326,9 +1048,9 @@ function VaultHistoryPanel({
|
|
|
326
1048
|
}
|
|
327
1049
|
|
|
328
1050
|
// src/vault/VaultContentResults.tsx
|
|
329
|
-
import { useId as
|
|
330
|
-
import { FileText } from "lucide-react";
|
|
331
|
-
import { jsx as
|
|
1051
|
+
import { useId as useId3 } from "react";
|
|
1052
|
+
import { FileText as FileText2 } from "lucide-react";
|
|
1053
|
+
import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
332
1054
|
function highlight(text, query) {
|
|
333
1055
|
const needle = query.toLowerCase();
|
|
334
1056
|
const haystack = text.toLowerCase();
|
|
@@ -337,7 +1059,7 @@ function highlight(text, query) {
|
|
|
337
1059
|
for (let at = haystack.indexOf(needle); needle && at >= 0; at = haystack.indexOf(needle, from)) {
|
|
338
1060
|
if (at > from) parts.push(text.slice(from, at));
|
|
339
1061
|
parts.push(
|
|
340
|
-
/* @__PURE__ */
|
|
1062
|
+
/* @__PURE__ */ jsx5("mark", { className: "rounded-sm bg-[var(--surface-warning-bg)] px-0.5 text-[var(--surface-warning-text)]", children: text.slice(at, at + needle.length) }, at)
|
|
341
1063
|
);
|
|
342
1064
|
from = at + needle.length;
|
|
343
1065
|
}
|
|
@@ -350,19 +1072,19 @@ function VaultContentResults({
|
|
|
350
1072
|
onOpen,
|
|
351
1073
|
onRetry
|
|
352
1074
|
}) {
|
|
353
|
-
const headingId =
|
|
354
|
-
return /* @__PURE__ */
|
|
355
|
-
/* @__PURE__ */
|
|
356
|
-
state.status === "error" ? /* @__PURE__ */
|
|
357
|
-
/* @__PURE__ */
|
|
1075
|
+
const headingId = useId3();
|
|
1076
|
+
return /* @__PURE__ */ jsxs5("section", { "aria-labelledby": headingId, "data-vault-content-results": true, className: "mt-2 border-t border-border px-1.5 pt-3", children: [
|
|
1077
|
+
/* @__PURE__ */ jsx5("h3", { id: headingId, className: "px-1.5 text-sm font-medium text-foreground", children: "In file contents" }),
|
|
1078
|
+
state.status === "error" ? /* @__PURE__ */ jsxs5("div", { role: "alert", className: "mt-2 space-y-2 px-1.5 text-sm text-[var(--surface-danger-text)]", children: [
|
|
1079
|
+
/* @__PURE__ */ jsxs5("p", { children: [
|
|
358
1080
|
"Couldn't search file contents. ",
|
|
359
1081
|
state.message
|
|
360
1082
|
] }),
|
|
361
|
-
/* @__PURE__ */
|
|
362
|
-
] }) : state.matches.length === 0 ? /* @__PURE__ */
|
|
1083
|
+
/* @__PURE__ */ jsx5("button", { type: "button", onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Try again" })
|
|
1084
|
+
] }) : state.matches.length === 0 ? /* @__PURE__ */ jsx5("p", { role: "status", className: "mt-2 px-1.5 text-sm text-muted-foreground", children: state.status === "loading" ? "Searching file contents\u2026" : `No file contains \u201C${state.query}\u201D.` }) : /* @__PURE__ */ jsx5("ul", { className: "mt-1.5 space-y-0.5", "aria-busy": state.status === "loading", children: state.matches.map((match) => {
|
|
363
1085
|
const slash = match.path.lastIndexOf("/");
|
|
364
1086
|
const selected = match.path === selectedPath;
|
|
365
|
-
return /* @__PURE__ */
|
|
1087
|
+
return /* @__PURE__ */ jsx5("li", { children: /* @__PURE__ */ jsxs5(
|
|
366
1088
|
"button",
|
|
367
1089
|
{
|
|
368
1090
|
type: "button",
|
|
@@ -371,12 +1093,12 @@ function VaultContentResults({
|
|
|
371
1093
|
"aria-current": selected ? "true" : void 0,
|
|
372
1094
|
className: `w-full rounded-md px-2 py-2 text-left transition-colors focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring ${selected ? "bg-muted" : "hover:bg-muted"}`,
|
|
373
1095
|
children: [
|
|
374
|
-
/* @__PURE__ */
|
|
375
|
-
/* @__PURE__ */
|
|
376
|
-
/* @__PURE__ */
|
|
377
|
-
slash > 0 && /* @__PURE__ */
|
|
1096
|
+
/* @__PURE__ */ jsxs5("span", { className: "flex min-w-0 items-center gap-2", children: [
|
|
1097
|
+
/* @__PURE__ */ jsx5(FileText2, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
1098
|
+
/* @__PURE__ */ jsx5("span", { className: "min-w-0 truncate text-sm font-medium text-foreground", children: match.path.slice(slash + 1) }),
|
|
1099
|
+
slash > 0 && /* @__PURE__ */ jsx5("span", { className: "ml-auto min-w-0 shrink truncate text-sm text-muted-foreground", children: match.path.slice(0, slash) })
|
|
378
1100
|
] }),
|
|
379
|
-
/* @__PURE__ */
|
|
1101
|
+
/* @__PURE__ */ jsx5("span", { className: "mt-1 line-clamp-2 block text-sm text-muted-foreground", children: highlight(match.snippet, state.query) })
|
|
380
1102
|
]
|
|
381
1103
|
}
|
|
382
1104
|
) }, match.path);
|
|
@@ -384,193 +1106,6 @@ function VaultContentResults({
|
|
|
384
1106
|
] });
|
|
385
1107
|
}
|
|
386
1108
|
|
|
387
|
-
// src/vault/VaultPaneStates.tsx
|
|
388
|
-
import { Component, useId as useId3 } from "react";
|
|
389
|
-
import { FileText as FileText2, Plus } from "lucide-react";
|
|
390
|
-
import { Fragment, jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
391
|
-
function operationMessage(error, fallback) {
|
|
392
|
-
return error instanceof Error && error.message ? error.message : fallback;
|
|
393
|
-
}
|
|
394
|
-
function treeFailureMessage(failure, label) {
|
|
395
|
-
if (failure.phase !== "post-mutation-refresh") return failure.message;
|
|
396
|
-
const completed = failure.operation === "create" ? "created" : "deleted";
|
|
397
|
-
return `The file was ${completed}, but ${label} couldn't refresh. ${failure.message}`;
|
|
398
|
-
}
|
|
399
|
-
var EditorErrorBoundary = class extends Component {
|
|
400
|
-
state = { error: null };
|
|
401
|
-
static getDerivedStateFromError(error) {
|
|
402
|
-
return { error };
|
|
403
|
-
}
|
|
404
|
-
componentDidCatch(error, info) {
|
|
405
|
-
console.error("Vault crashed:", error, info);
|
|
406
|
-
}
|
|
407
|
-
render() {
|
|
408
|
-
if (this.state.error) {
|
|
409
|
-
const msg = this.state.error instanceof Error ? this.state.error.message : typeof this.state.error === "string" ? this.state.error : `${this.props.label} did not load. Reload the page to try again.`;
|
|
410
|
-
return /* @__PURE__ */ jsxs5("div", { className: "flex h-full flex-1 flex-col items-center justify-center p-8 text-center", children: [
|
|
411
|
-
/* @__PURE__ */ jsxs5("h3", { className: "mb-1 text-sm font-medium text-foreground", children: [
|
|
412
|
-
this.props.label,
|
|
413
|
-
" failed to load"
|
|
414
|
-
] }),
|
|
415
|
-
/* @__PURE__ */ jsx5("p", { className: "mb-4 max-w-xs text-xs text-muted-foreground", children: String(msg) }),
|
|
416
|
-
/* @__PURE__ */ jsx5(
|
|
417
|
-
"button",
|
|
418
|
-
{
|
|
419
|
-
type: "button",
|
|
420
|
-
onClick: () => {
|
|
421
|
-
this.setState({ error: null });
|
|
422
|
-
this.props.onReset?.();
|
|
423
|
-
},
|
|
424
|
-
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
425
|
-
children: "Try again"
|
|
426
|
-
}
|
|
427
|
-
)
|
|
428
|
-
] });
|
|
429
|
-
}
|
|
430
|
-
return this.props.children;
|
|
431
|
-
}
|
|
432
|
-
};
|
|
433
|
-
function SkeletonRegion({ label, className, children }) {
|
|
434
|
-
return /* @__PURE__ */ jsxs5(Fragment, { children: [
|
|
435
|
-
/* @__PURE__ */ jsx5("span", { role: "status", "aria-live": "polite", "aria-busy": true, className: "sr-only", children: label }),
|
|
436
|
-
/* @__PURE__ */ jsx5("div", { className, "aria-hidden": "true", children })
|
|
437
|
-
] });
|
|
438
|
-
}
|
|
439
|
-
function TreeSkeleton() {
|
|
440
|
-
return /* @__PURE__ */ jsx5(SkeletonRegion, { label: "Loading files\u2026", className: "space-y-2 p-4", children: [32, 48, 40, 52].map((w, i) => /* @__PURE__ */ jsx5("div", { className: "h-4 animate-pulse rounded bg-muted", style: { width: `${w * 4}px` } }, i)) });
|
|
441
|
-
}
|
|
442
|
-
function EditorSkeleton() {
|
|
443
|
-
return /* @__PURE__ */ jsxs5(SkeletonRegion, { label: "Loading file\u2026", className: "space-y-3 p-8", children: [
|
|
444
|
-
/* @__PURE__ */ jsx5("div", { className: "h-5 w-1/2 animate-pulse rounded bg-muted" }),
|
|
445
|
-
/* @__PURE__ */ jsx5("div", { className: "h-4 w-full animate-pulse rounded bg-muted" }),
|
|
446
|
-
/* @__PURE__ */ jsx5("div", { className: "h-4 w-3/4 animate-pulse rounded bg-muted" }),
|
|
447
|
-
/* @__PURE__ */ jsx5("div", { className: "h-4 w-2/3 animate-pulse rounded bg-muted" })
|
|
448
|
-
] });
|
|
449
|
-
}
|
|
450
|
-
function RetryButton({ onRetry }) {
|
|
451
|
-
return /* @__PURE__ */ jsx5(
|
|
452
|
-
"button",
|
|
453
|
-
{
|
|
454
|
-
type: "button",
|
|
455
|
-
onClick: onRetry,
|
|
456
|
-
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
457
|
-
children: "Retry"
|
|
458
|
-
}
|
|
459
|
-
);
|
|
460
|
-
}
|
|
461
|
-
function ReadErrorState({ message: message2, onRetry }) {
|
|
462
|
-
return /* @__PURE__ */ jsxs5("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-8 text-center", children: [
|
|
463
|
-
/* @__PURE__ */ jsxs5("div", { children: [
|
|
464
|
-
/* @__PURE__ */ jsx5("h3", { className: "text-sm font-medium text-foreground", children: "Couldn't open this file" }),
|
|
465
|
-
/* @__PURE__ */ jsx5("p", { className: "mt-1 max-w-md text-xs text-muted-foreground", children: message2 })
|
|
466
|
-
] }),
|
|
467
|
-
/* @__PURE__ */ jsx5(RetryButton, { onRetry })
|
|
468
|
-
] });
|
|
469
|
-
}
|
|
470
|
-
function TreeErrorState({ label, message: message2, onRetry }) {
|
|
471
|
-
return /* @__PURE__ */ jsxs5("div", { role: "alert", className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
|
|
472
|
-
/* @__PURE__ */ jsxs5("div", { children: [
|
|
473
|
-
/* @__PURE__ */ jsxs5("h3", { className: "text-sm font-medium text-foreground", children: [
|
|
474
|
-
"Couldn't load ",
|
|
475
|
-
label
|
|
476
|
-
] }),
|
|
477
|
-
/* @__PURE__ */ jsx5("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: message2 })
|
|
478
|
-
] }),
|
|
479
|
-
/* @__PURE__ */ jsx5(RetryButton, { onRetry })
|
|
480
|
-
] });
|
|
481
|
-
}
|
|
482
|
-
function TreeEmptyState({ canCreate, onCreate }) {
|
|
483
|
-
return /* @__PURE__ */ jsxs5("div", { className: "flex h-full flex-col items-center justify-center gap-3 p-6 text-center", children: [
|
|
484
|
-
/* @__PURE__ */ jsxs5("div", { children: [
|
|
485
|
-
/* @__PURE__ */ jsx5("h3", { className: "text-sm font-medium text-foreground", children: "No files yet" }),
|
|
486
|
-
/* @__PURE__ */ jsx5("p", { className: "mt-1 max-w-xs text-xs text-muted-foreground", children: canCreate ? "Create a file to start." : "Files appear here once they are added." })
|
|
487
|
-
] }),
|
|
488
|
-
canCreate && /* @__PURE__ */ jsxs5(
|
|
489
|
-
"button",
|
|
490
|
-
{
|
|
491
|
-
type: "button",
|
|
492
|
-
onClick: onCreate,
|
|
493
|
-
className: "inline-flex h-8 items-center gap-1.5 rounded-md bg-primary px-3 text-xs font-medium text-primary-foreground transition-colors hover:bg-primary/90",
|
|
494
|
-
children: [
|
|
495
|
-
/* @__PURE__ */ jsx5(Plus, { className: "h-3.5 w-3.5", "aria-hidden": "true" }),
|
|
496
|
-
"New file"
|
|
497
|
-
]
|
|
498
|
-
}
|
|
499
|
-
)
|
|
500
|
-
] });
|
|
501
|
-
}
|
|
502
|
-
function TreeNoMatchState({ query, onClear }) {
|
|
503
|
-
return /* @__PURE__ */ jsxs5("div", { className: "flex flex-col items-center gap-3 p-6 text-center", children: [
|
|
504
|
-
/* @__PURE__ */ jsxs5("p", { className: "max-w-xs break-words text-xs text-muted-foreground", children: [
|
|
505
|
-
"No files match \u201C",
|
|
506
|
-
query,
|
|
507
|
-
"\u201D."
|
|
508
|
-
] }),
|
|
509
|
-
/* @__PURE__ */ jsx5(
|
|
510
|
-
"button",
|
|
511
|
-
{
|
|
512
|
-
type: "button",
|
|
513
|
-
onClick: onClear,
|
|
514
|
-
className: "inline-flex h-8 items-center rounded-md border border-border px-3 text-xs font-medium text-foreground transition-colors hover:bg-muted",
|
|
515
|
-
children: "Clear search"
|
|
516
|
-
}
|
|
517
|
-
)
|
|
518
|
-
] });
|
|
519
|
-
}
|
|
520
|
-
function OperationErrorAlert({
|
|
521
|
-
message: message2,
|
|
522
|
-
retryLabel,
|
|
523
|
-
onRetry,
|
|
524
|
-
onDismiss
|
|
525
|
-
}) {
|
|
526
|
-
return /* @__PURE__ */ jsxs5(
|
|
527
|
-
"div",
|
|
528
|
-
{
|
|
529
|
-
role: "alert",
|
|
530
|
-
className: "flex shrink-0 items-center justify-between gap-3 border-b border-destructive/30 bg-destructive/10 px-3 py-2 text-xs text-[var(--surface-danger-text)]",
|
|
531
|
-
children: [
|
|
532
|
-
/* @__PURE__ */ jsx5("span", { className: "min-w-0 flex-1", children: message2 }),
|
|
533
|
-
/* @__PURE__ */ jsxs5("div", { className: "flex shrink-0 items-center gap-3", children: [
|
|
534
|
-
/* @__PURE__ */ jsx5("button", { type: "button", "aria-label": retryLabel, onClick: onRetry, className: "font-medium underline-offset-2 hover:underline", children: "Retry" }),
|
|
535
|
-
/* @__PURE__ */ jsx5("button", { type: "button", onClick: onDismiss, className: "underline-offset-2 hover:underline", children: "Dismiss" })
|
|
536
|
-
] })
|
|
537
|
-
]
|
|
538
|
-
}
|
|
539
|
-
);
|
|
540
|
-
}
|
|
541
|
-
function DocumentEmptyState({ label, recent, onOpen }) {
|
|
542
|
-
const recentHeadingId = useId3();
|
|
543
|
-
return /* @__PURE__ */ jsx5("div", { "data-vault-document-empty": true, className: "flex h-full items-center justify-center overflow-y-auto p-8", children: /* @__PURE__ */ jsxs5("div", { className: "w-full max-w-sm text-center", children: [
|
|
544
|
-
/* @__PURE__ */ jsx5("span", { className: "mx-auto flex size-12 items-center justify-center rounded-full bg-muted text-muted-foreground", children: /* @__PURE__ */ jsx5(FileText2, { className: "size-5", "aria-hidden": "true" }) }),
|
|
545
|
-
/* @__PURE__ */ jsx5("h3", { className: "mt-4 text-base font-semibold text-foreground", children: "Select a file" }),
|
|
546
|
-
/* @__PURE__ */ jsxs5("p", { className: "mt-1 text-sm text-muted-foreground", children: [
|
|
547
|
-
"Choose a file in ",
|
|
548
|
-
label,
|
|
549
|
-
" to open it here."
|
|
550
|
-
] }),
|
|
551
|
-
recent.length > 0 && /* @__PURE__ */ jsxs5("section", { "aria-labelledby": recentHeadingId, className: "mt-8 text-left", children: [
|
|
552
|
-
/* @__PURE__ */ jsx5("h4", { id: recentHeadingId, className: "text-xs font-medium text-muted-foreground", children: "Recently opened" }),
|
|
553
|
-
/* @__PURE__ */ jsx5("ul", { className: "mt-2 overflow-hidden rounded-xl border border-border bg-card shadow-raised", children: recent.map((path) => {
|
|
554
|
-
const slash = path.lastIndexOf("/");
|
|
555
|
-
return /* @__PURE__ */ jsx5("li", { className: "border-b border-border last:border-b-0", children: /* @__PURE__ */ jsxs5(
|
|
556
|
-
"button",
|
|
557
|
-
{
|
|
558
|
-
type: "button",
|
|
559
|
-
onClick: () => onOpen(path),
|
|
560
|
-
title: path,
|
|
561
|
-
className: "flex min-h-10 w-full items-center gap-2.5 px-3 py-2 text-left text-sm text-foreground transition-colors hover:bg-muted focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-inset focus-visible:ring-ring",
|
|
562
|
-
children: [
|
|
563
|
-
/* @__PURE__ */ jsx5(FileText2, { className: "size-4 shrink-0 text-muted-foreground", "aria-hidden": "true" }),
|
|
564
|
-
/* @__PURE__ */ jsx5("span", { className: "min-w-0 truncate font-medium", children: path.slice(slash + 1) }),
|
|
565
|
-
slash > 0 && /* @__PURE__ */ jsx5("span", { className: "ml-auto min-w-0 shrink truncate text-xs text-muted-foreground", children: path.slice(0, slash) })
|
|
566
|
-
]
|
|
567
|
-
}
|
|
568
|
-
) }, path);
|
|
569
|
-
}) })
|
|
570
|
-
] })
|
|
571
|
-
] }) });
|
|
572
|
-
}
|
|
573
|
-
|
|
574
1109
|
// src/vault/VaultDocumentToolbar.tsx
|
|
575
1110
|
import { Download, History as History2, Trash2 } from "lucide-react";
|
|
576
1111
|
import { ShellHeader } from "@tangle-network/sandbox-ui/workspace";
|
|
@@ -873,56 +1408,26 @@ function storage(key) {
|
|
|
873
1408
|
return null;
|
|
874
1409
|
}
|
|
875
1410
|
}
|
|
876
|
-
function readRecentFiles(key) {
|
|
877
|
-
const store = storage(key);
|
|
878
|
-
if (!store) return [];
|
|
879
|
-
try {
|
|
880
|
-
const parsed = JSON.parse(store.getItem(PREFIX + key) ?? "[]");
|
|
881
|
-
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
882
|
-
} catch {
|
|
883
|
-
return [];
|
|
884
|
-
}
|
|
885
|
-
}
|
|
886
|
-
function recordRecentFile(key, path) {
|
|
887
|
-
const next = [path, ...readRecentFiles(key).filter((item) => item !== path)].slice(0, RECENT_FILE_LIMIT);
|
|
888
|
-
const store = storage(key);
|
|
889
|
-
if (store) {
|
|
890
|
-
try {
|
|
891
|
-
store.setItem(PREFIX + key, JSON.stringify(next));
|
|
892
|
-
} catch {
|
|
893
|
-
}
|
|
894
|
-
}
|
|
895
|
-
return next;
|
|
896
|
-
}
|
|
897
|
-
|
|
898
|
-
// src/vault/vault-tree-paths.ts
|
|
899
|
-
function collectTreePaths(nodes, into) {
|
|
900
|
-
for (const node of nodes) {
|
|
901
|
-
if (node.type === "file") into.files.add(node.path);
|
|
902
|
-
else into.directories.add(node.path);
|
|
903
|
-
if (node.children) collectTreePaths(node.children, into);
|
|
904
|
-
}
|
|
905
|
-
return into;
|
|
906
|
-
}
|
|
907
|
-
function resolveFilePath(rawPath, filePaths) {
|
|
908
|
-
if (filePaths.has(rawPath)) return rawPath;
|
|
909
|
-
const path = rawPath.replace(/^\/+|\/+$/g, "");
|
|
910
|
-
return filePaths.has(path) ? path : null;
|
|
911
|
-
}
|
|
912
|
-
function resolveTreePath(rawPath, paths) {
|
|
913
|
-
const file = resolveFilePath(rawPath, paths.files);
|
|
914
|
-
if (file) return { path: file, type: "file" };
|
|
915
|
-
if (paths.directories.has(rawPath)) return { path: rawPath, type: "directory" };
|
|
916
|
-
const trimmed = rawPath.replace(/^\/+|\/+$/g, "");
|
|
917
|
-
return paths.directories.has(trimmed) ? { path: trimmed, type: "directory" } : null;
|
|
918
|
-
}
|
|
919
|
-
function findDirectory(nodes, path) {
|
|
920
|
-
for (const node of nodes) {
|
|
921
|
-
if (node.type === "directory" && node.path === path) return node;
|
|
922
|
-
const found = node.children ? findDirectory(node.children, path) : null;
|
|
923
|
-
if (found) return found;
|
|
1411
|
+
function readRecentFiles(key) {
|
|
1412
|
+
const store = storage(key);
|
|
1413
|
+
if (!store) return [];
|
|
1414
|
+
try {
|
|
1415
|
+
const parsed = JSON.parse(store.getItem(PREFIX + key) ?? "[]");
|
|
1416
|
+
return Array.isArray(parsed) ? parsed.filter((item) => typeof item === "string") : [];
|
|
1417
|
+
} catch {
|
|
1418
|
+
return [];
|
|
924
1419
|
}
|
|
925
|
-
|
|
1420
|
+
}
|
|
1421
|
+
function recordRecentFile(key, path) {
|
|
1422
|
+
const next = [path, ...readRecentFiles(key).filter((item) => item !== path)].slice(0, RECENT_FILE_LIMIT);
|
|
1423
|
+
const store = storage(key);
|
|
1424
|
+
if (store) {
|
|
1425
|
+
try {
|
|
1426
|
+
store.setItem(PREFIX + key, JSON.stringify(next));
|
|
1427
|
+
} catch {
|
|
1428
|
+
}
|
|
1429
|
+
}
|
|
1430
|
+
return next;
|
|
926
1431
|
}
|
|
927
1432
|
|
|
928
1433
|
// src/vault/VaultPane.tsx
|
|
@@ -931,9 +1436,8 @@ var IDENTITY_CODEC = {
|
|
|
931
1436
|
parse: (raw) => raw,
|
|
932
1437
|
serialize: (parts) => typeof parts === "string" ? parts : String(parts ?? "")
|
|
933
1438
|
};
|
|
934
|
-
var LIST_CONTEXT = { operation: "list", phase: "operation" };
|
|
935
1439
|
var RECENT_SHOWN = 5;
|
|
936
|
-
|
|
1440
|
+
function useVaultPaneViewState(props, ref) {
|
|
937
1441
|
const {
|
|
938
1442
|
port,
|
|
939
1443
|
renderTree,
|
|
@@ -981,26 +1485,31 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
981
1485
|
useEffect4(() => {
|
|
982
1486
|
setFilesOpen(false);
|
|
983
1487
|
}, [selectedPath]);
|
|
984
|
-
const showDocument =
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1488
|
+
const { showDocument } = useVaultDocumentFocus({ setFilesOpen, documentRef });
|
|
1489
|
+
const {
|
|
1490
|
+
selectedFile,
|
|
1491
|
+
setSelectedFile,
|
|
1492
|
+
displayReadyPath,
|
|
1493
|
+
setDisplayReadyPath,
|
|
1494
|
+
fileLoading,
|
|
1495
|
+
setFileLoading,
|
|
1496
|
+
readError,
|
|
1497
|
+
setReadError,
|
|
1498
|
+
reloadNonce,
|
|
1499
|
+
setReloadNonce,
|
|
1500
|
+
saving,
|
|
1501
|
+
setSaving,
|
|
1502
|
+
saveError,
|
|
1503
|
+
setSaveError,
|
|
1504
|
+
editorMode,
|
|
1505
|
+
setEditorMode,
|
|
1506
|
+
richDraft,
|
|
1507
|
+
setRichDraft,
|
|
1508
|
+
sourceDraft,
|
|
1509
|
+
setSourceDraft,
|
|
1510
|
+
isDirty,
|
|
1511
|
+
setIsDirty
|
|
1512
|
+
} = useVaultDocumentState();
|
|
1004
1513
|
const [createOpen, setCreateOpen] = useState4(false);
|
|
1005
1514
|
const [newPath, setNewPath] = useState4("");
|
|
1006
1515
|
const [creating, setCreating] = useState4(false);
|
|
@@ -1042,98 +1551,45 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1042
1551
|
onOperationErrorRef.current = onOperationError;
|
|
1043
1552
|
const pendingOpenRef = useRef3(null);
|
|
1044
1553
|
const previousPortRef = useRef3(port);
|
|
1045
|
-
const finishPendingOpen =
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
},
|
|
1059
|
-
useEffect4(() => {
|
|
1060
|
-
const pending = pendingOpenRef.current;
|
|
1061
|
-
if (!pending) return;
|
|
1062
|
-
if (selectedPath === pending.path) pending.selected = true;
|
|
1063
|
-
else if (pending.selected || selectedPath !== pending.fromPath) finishPendingOpen(false);
|
|
1064
|
-
}, [selectedPath, finishPendingOpen]);
|
|
1065
|
-
const treePaths = useMemo2(
|
|
1066
|
-
() => collectTreePaths(tree, { files: /* @__PURE__ */ new Set(), directories: /* @__PURE__ */ new Set() }),
|
|
1067
|
-
[tree]
|
|
1068
|
-
);
|
|
1069
|
-
const resolvedSelectedPath = useMemo2(() => {
|
|
1070
|
-
if (!selectedPath) return null;
|
|
1071
|
-
const listed = resolveTreePath(selectedPath, treePaths);
|
|
1072
|
-
if (listed?.type === "directory") return null;
|
|
1073
|
-
return listed?.path ?? selectedPath;
|
|
1074
|
-
}, [selectedPath, treePaths]);
|
|
1075
|
-
const activeFolderNode = useMemo2(
|
|
1076
|
-
() => folderPath ? findDirectory(tree, folderPath) : null,
|
|
1077
|
-
[tree, folderPath]
|
|
1078
|
-
);
|
|
1079
|
-
const activeFolder = activeFolderNode?.path ?? null;
|
|
1080
|
-
const treeRoot = useMemo2(
|
|
1081
|
-
() => ({ name: label, path: "", type: "directory", children: tree }),
|
|
1082
|
-
[tree, label]
|
|
1083
|
-
);
|
|
1084
|
-
const { query, onQueryChange, visibleRoot, canSearchContent, contentResults, retry: retryContentSearch } = useVaultSearch({ port, treeRoot });
|
|
1554
|
+
const { finishPendingOpen } = useVaultPendingOpenCompletion({ pendingOpenRef, setPendingNav, previousPortRef, port, selectedPath });
|
|
1555
|
+
const {
|
|
1556
|
+
treePaths,
|
|
1557
|
+
resolvedSelectedPath,
|
|
1558
|
+
activeFolderNode,
|
|
1559
|
+
activeFolder,
|
|
1560
|
+
treeRoot,
|
|
1561
|
+
query,
|
|
1562
|
+
onQueryChange,
|
|
1563
|
+
visibleRoot,
|
|
1564
|
+
canSearchContent,
|
|
1565
|
+
contentResults,
|
|
1566
|
+
retryContentSearch
|
|
1567
|
+
} = useVaultTreeProjection({ tree, selectedPath, folderPath, label, port });
|
|
1085
1568
|
const commitPath = useCallback2(
|
|
1086
|
-
(next) => {
|
|
1087
|
-
if (controlled) {
|
|
1088
|
-
const decision = onSelectedPathChange?.(next);
|
|
1089
|
-
return decision !== false;
|
|
1090
|
-
}
|
|
1091
|
-
setInternalPath(next);
|
|
1092
|
-
onSelectedPathChange?.(next);
|
|
1093
|
-
return true;
|
|
1094
|
-
},
|
|
1569
|
+
(next) => commitVaultPath(next, { controlled, onSelectedPathChange, setInternalPath }),
|
|
1095
1570
|
[controlled, onSelectedPathChange]
|
|
1096
1571
|
);
|
|
1097
|
-
const reportFailure = useCallback2((operation, phase, error, fallback, path) =>
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
try {
|
|
1117
|
-
const nextTree = await port.listTree();
|
|
1118
|
-
if (request !== treeRequestRef.current) return false;
|
|
1119
|
-
setTree(nextTree);
|
|
1120
|
-
setTreeLoaded(true);
|
|
1121
|
-
return true;
|
|
1122
|
-
} catch (error) {
|
|
1123
|
-
if (request !== treeRequestRef.current) return false;
|
|
1124
|
-
const failure = reportFailure(
|
|
1125
|
-
context.operation,
|
|
1126
|
-
context.phase,
|
|
1127
|
-
error,
|
|
1128
|
-
`Failed to load ${label}`,
|
|
1129
|
-
context.path
|
|
1130
|
-
);
|
|
1131
|
-
setTreeError({ failure, context });
|
|
1132
|
-
return false;
|
|
1133
|
-
} finally {
|
|
1134
|
-
if (request === treeRequestRef.current) setTreeLoading(false);
|
|
1572
|
+
const reportFailure = useCallback2((operation, phase, error, fallback, path) => reportVaultOperationFailure(
|
|
1573
|
+
operation,
|
|
1574
|
+
phase,
|
|
1575
|
+
error,
|
|
1576
|
+
fallback,
|
|
1577
|
+
path,
|
|
1578
|
+
{ onOperationErrorRef }
|
|
1579
|
+
), []);
|
|
1580
|
+
const refresh = useCallback2((context) => refreshVaultTree(
|
|
1581
|
+
context,
|
|
1582
|
+
{
|
|
1583
|
+
treeRequestRef,
|
|
1584
|
+
setTreeLoading,
|
|
1585
|
+
setTreeError,
|
|
1586
|
+
port,
|
|
1587
|
+
setTree,
|
|
1588
|
+
setTreeLoaded,
|
|
1589
|
+
reportFailure,
|
|
1590
|
+
label
|
|
1135
1591
|
}
|
|
1136
|
-
|
|
1592
|
+
), [port, reportFailure, label]);
|
|
1137
1593
|
useEffect4(() => {
|
|
1138
1594
|
setTree([]);
|
|
1139
1595
|
setTreeLoaded(false);
|
|
@@ -1146,133 +1602,104 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1146
1602
|
treeRequestRef.current += 1;
|
|
1147
1603
|
};
|
|
1148
1604
|
}, [refresh, refreshKey]);
|
|
1149
|
-
const retryTree = useCallback2(
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
}, [
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
finishPendingOpen(false);
|
|
1248
|
-
setPendingNav(null);
|
|
1249
|
-
if (path === selectedPath && selectedFile?.path === path && displayReadyPath === path) {
|
|
1250
|
-
showDocument();
|
|
1251
|
-
resolve?.(true);
|
|
1252
|
-
return;
|
|
1253
|
-
}
|
|
1254
|
-
if (resolve) {
|
|
1255
|
-
const pending = {
|
|
1256
|
-
path,
|
|
1257
|
-
fromPath: selectedPath,
|
|
1258
|
-
resolve,
|
|
1259
|
-
loaded: false,
|
|
1260
|
-
selected: path === selectedPath
|
|
1261
|
-
};
|
|
1262
|
-
pendingOpenRef.current = pending;
|
|
1263
|
-
}
|
|
1264
|
-
if (path === selectedPath) {
|
|
1265
|
-
showDocument();
|
|
1266
|
-
if (!fileLoading && (readError || treeError && !treeLoaded)) setReloadNonce((nonce) => nonce + 1);
|
|
1267
|
-
return;
|
|
1268
|
-
}
|
|
1269
|
-
if (isDirty) {
|
|
1270
|
-
setPendingNav({ path, request: resolve ? pendingOpenRef.current ?? void 0 : void 0 });
|
|
1271
|
-
return;
|
|
1272
|
-
}
|
|
1273
|
-
showDocument();
|
|
1274
|
-
if (commitPath(path) === false) finishPendingOpen(false);
|
|
1275
|
-
}, [finishPendingOpen, treePaths, selectedPath, selectedFile, displayReadyPath, fileLoading, showDocument, readError, treeError, treeLoaded, isDirty, commitPath]);
|
|
1605
|
+
const retryTree = useCallback2(() => retryVaultTreeRefresh({ treeError, refresh, commitPath }), [treeError, refresh, commitPath]);
|
|
1606
|
+
useEffect4(() => readVaultSelectedFile({
|
|
1607
|
+
selectedPath,
|
|
1608
|
+
setSelectedFile,
|
|
1609
|
+
setFileLoading,
|
|
1610
|
+
setReadError,
|
|
1611
|
+
loadedPathRef,
|
|
1612
|
+
treeError,
|
|
1613
|
+
pendingOpenRef,
|
|
1614
|
+
treeLoading,
|
|
1615
|
+
treeLoaded,
|
|
1616
|
+
isDirty,
|
|
1617
|
+
saving,
|
|
1618
|
+
resolvedSelectedPath,
|
|
1619
|
+
finishPendingOpen,
|
|
1620
|
+
commitPath,
|
|
1621
|
+
port,
|
|
1622
|
+
dirtyRef,
|
|
1623
|
+
reportFailure
|
|
1624
|
+
}), [
|
|
1625
|
+
port,
|
|
1626
|
+
selectedPath,
|
|
1627
|
+
resolvedSelectedPath,
|
|
1628
|
+
treeLoading,
|
|
1629
|
+
treeLoaded,
|
|
1630
|
+
treeError,
|
|
1631
|
+
isDirty,
|
|
1632
|
+
saving,
|
|
1633
|
+
reloadNonce,
|
|
1634
|
+
commitPath,
|
|
1635
|
+
reportFailure,
|
|
1636
|
+
finishPendingOpen
|
|
1637
|
+
]);
|
|
1638
|
+
useEffect4(() => reconcileVaultSelectedFile({
|
|
1639
|
+
selectedFile,
|
|
1640
|
+
loadedPathRef,
|
|
1641
|
+
setDisplayReadyPath,
|
|
1642
|
+
savedContentRef,
|
|
1643
|
+
draftContentRef,
|
|
1644
|
+
setRichDraft,
|
|
1645
|
+
setSourceDraft,
|
|
1646
|
+
setEditorMode,
|
|
1647
|
+
setIsDirty,
|
|
1648
|
+
setSaveError,
|
|
1649
|
+
savedResultRef,
|
|
1650
|
+
activeCodec,
|
|
1651
|
+
setDockOpen
|
|
1652
|
+
}), [
|
|
1653
|
+
selectedFile?.path,
|
|
1654
|
+
selectedFile?.content,
|
|
1655
|
+
activeCodec
|
|
1656
|
+
]);
|
|
1657
|
+
useEffect4(() => completeVaultPendingOpen({
|
|
1658
|
+
pendingOpenRef,
|
|
1659
|
+
selectedPath,
|
|
1660
|
+
selectedFile,
|
|
1661
|
+
displayReadyPath,
|
|
1662
|
+
sourceDraft,
|
|
1663
|
+
fileLoading,
|
|
1664
|
+
finishPendingOpen
|
|
1665
|
+
}), [
|
|
1666
|
+
selectedPath,
|
|
1667
|
+
selectedFile,
|
|
1668
|
+
displayReadyPath,
|
|
1669
|
+
sourceDraft,
|
|
1670
|
+
fileLoading,
|
|
1671
|
+
finishPendingOpen
|
|
1672
|
+
]);
|
|
1673
|
+
const guardedOpen = useCallback2((rawPath, resolve) => openVaultFile(rawPath, resolve, {
|
|
1674
|
+
treePaths,
|
|
1675
|
+
finishPendingOpen,
|
|
1676
|
+
setPendingNav,
|
|
1677
|
+
selectedPath,
|
|
1678
|
+
selectedFile,
|
|
1679
|
+
displayReadyPath,
|
|
1680
|
+
showDocument,
|
|
1681
|
+
pendingOpenRef,
|
|
1682
|
+
fileLoading,
|
|
1683
|
+
readError,
|
|
1684
|
+
treeError,
|
|
1685
|
+
treeLoaded,
|
|
1686
|
+
setReloadNonce,
|
|
1687
|
+
isDirty,
|
|
1688
|
+
commitPath
|
|
1689
|
+
}), [
|
|
1690
|
+
finishPendingOpen,
|
|
1691
|
+
treePaths,
|
|
1692
|
+
selectedPath,
|
|
1693
|
+
selectedFile,
|
|
1694
|
+
displayReadyPath,
|
|
1695
|
+
fileLoading,
|
|
1696
|
+
showDocument,
|
|
1697
|
+
readError,
|
|
1698
|
+
treeError,
|
|
1699
|
+
treeLoaded,
|
|
1700
|
+
isDirty,
|
|
1701
|
+
commitPath
|
|
1702
|
+
]);
|
|
1276
1703
|
useImperativeHandle(ref, () => ({
|
|
1277
1704
|
openFile: (path) => new Promise((resolve) => guardedOpen(path, resolve))
|
|
1278
1705
|
}), [guardedOpen]);
|
|
@@ -1297,133 +1724,81 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1297
1724
|
toggleFolder(target.path);
|
|
1298
1725
|
};
|
|
1299
1726
|
const handleTreeSelect = useCallback2((path) => selectFileRef.current(path), []);
|
|
1300
|
-
const confirmDiscard = useCallback2(() => {
|
|
1301
|
-
|
|
1302
|
-
setPendingNav
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
if (isCurrent()) setSaveError(reportFailure("save", "operation", error, "Failed to save file", selectedFile.path));
|
|
1376
|
-
} finally {
|
|
1377
|
-
if (saveRequestRef.current === request) {
|
|
1378
|
-
saveRequestRef.current = null;
|
|
1379
|
-
if (saveScopeRef.current.path !== selectedFile.path && loadedPathRef.current === selectedFile.path) {
|
|
1380
|
-
dirtyRef.current = false;
|
|
1381
|
-
setIsDirty(false);
|
|
1382
|
-
}
|
|
1383
|
-
setSaving(false);
|
|
1384
|
-
}
|
|
1385
|
-
}
|
|
1386
|
-
}, [selectedFile, activeCodec, port, reportFailure, saveScopeKey]);
|
|
1387
|
-
const handleCreate = useCallback2(async () => {
|
|
1388
|
-
const trimmed = newPath.trim();
|
|
1389
|
-
if (!trimmed || !trimmed.split("/").pop()?.trim()) return;
|
|
1390
|
-
setCreating(true);
|
|
1391
|
-
setCreateError(null);
|
|
1392
|
-
try {
|
|
1393
|
-
const created = await port.createFile(trimmed);
|
|
1394
|
-
setCreateOpen(false);
|
|
1395
|
-
setNewPath("");
|
|
1396
|
-
const refreshed = await refresh({
|
|
1397
|
-
operation: "create",
|
|
1398
|
-
phase: "post-mutation-refresh",
|
|
1399
|
-
path: created,
|
|
1400
|
-
selectAfterRecovery: created
|
|
1401
|
-
});
|
|
1402
|
-
if (refreshed) commitPath(created);
|
|
1403
|
-
} catch (error) {
|
|
1404
|
-
setCreateError(reportFailure("create", "operation", error, "Failed to create file", trimmed));
|
|
1405
|
-
} finally {
|
|
1406
|
-
setCreating(false);
|
|
1407
|
-
}
|
|
1408
|
-
}, [newPath, port, refresh, commitPath, reportFailure]);
|
|
1409
|
-
const handleDelete = useCallback2(async () => {
|
|
1410
|
-
if (!selectedFile) return;
|
|
1411
|
-
const path = selectedFile.path;
|
|
1412
|
-
setDeleting(true);
|
|
1413
|
-
setDeleteError(null);
|
|
1414
|
-
try {
|
|
1415
|
-
await port.deleteFile(path);
|
|
1416
|
-
setDeleteOpen(false);
|
|
1417
|
-
setIsDirty(false);
|
|
1418
|
-
commitPath(null);
|
|
1419
|
-
setSelectedFile(null);
|
|
1420
|
-
await refresh({ operation: "delete", phase: "post-mutation-refresh", path });
|
|
1421
|
-
} catch (error) {
|
|
1422
|
-
setDeleteError(reportFailure("delete", "operation", error, "Failed to delete file", path));
|
|
1423
|
-
} finally {
|
|
1424
|
-
setDeleting(false);
|
|
1425
|
-
}
|
|
1426
|
-
}, [selectedFile, port, refresh, commitPath, reportFailure]);
|
|
1727
|
+
const confirmDiscard = useCallback2(() => discardVaultDraft({
|
|
1728
|
+
pendingNav,
|
|
1729
|
+
setPendingNav,
|
|
1730
|
+
pendingOpenRef,
|
|
1731
|
+
commitPath,
|
|
1732
|
+
finishPendingOpen,
|
|
1733
|
+
setIsDirty,
|
|
1734
|
+
showDocument
|
|
1735
|
+
}), [
|
|
1736
|
+
pendingNav,
|
|
1737
|
+
commitPath,
|
|
1738
|
+
showDocument,
|
|
1739
|
+
finishPendingOpen
|
|
1740
|
+
]);
|
|
1741
|
+
const {
|
|
1742
|
+
showRichMode,
|
|
1743
|
+
showSourceMode,
|
|
1744
|
+
onSourceChange,
|
|
1745
|
+
onRichChange,
|
|
1746
|
+
saveCurrent
|
|
1747
|
+
} = useVaultDraftEditing({
|
|
1748
|
+
setEditorMode,
|
|
1749
|
+
activeCodec,
|
|
1750
|
+
sourceDraft,
|
|
1751
|
+
draftContentRef,
|
|
1752
|
+
dirtyRef,
|
|
1753
|
+
savedContentRef,
|
|
1754
|
+
editorModeRef,
|
|
1755
|
+
setRichDraft,
|
|
1756
|
+
setIsDirty,
|
|
1757
|
+
isDirty,
|
|
1758
|
+
richDraft,
|
|
1759
|
+
setSourceDraft,
|
|
1760
|
+
mountedRef,
|
|
1761
|
+
saveScopeRef,
|
|
1762
|
+
saveScopeKey,
|
|
1763
|
+
selectedFile,
|
|
1764
|
+
port,
|
|
1765
|
+
saveRequestRef,
|
|
1766
|
+
setSaving,
|
|
1767
|
+
setSaveError,
|
|
1768
|
+
savedResultRef,
|
|
1769
|
+
setSelectedFile,
|
|
1770
|
+
reportFailure,
|
|
1771
|
+
loadedPathRef
|
|
1772
|
+
});
|
|
1773
|
+
const handleCreate = useCallback2(() => createVaultFile({
|
|
1774
|
+
newPath,
|
|
1775
|
+
setCreating,
|
|
1776
|
+
setCreateError,
|
|
1777
|
+
port,
|
|
1778
|
+
setCreateOpen,
|
|
1779
|
+
setNewPath,
|
|
1780
|
+
refresh,
|
|
1781
|
+
commitPath,
|
|
1782
|
+
reportFailure
|
|
1783
|
+
}), [
|
|
1784
|
+
newPath,
|
|
1785
|
+
port,
|
|
1786
|
+
refresh,
|
|
1787
|
+
commitPath,
|
|
1788
|
+
reportFailure
|
|
1789
|
+
]);
|
|
1790
|
+
const handleDelete = useCallback2(() => deleteVaultFile({
|
|
1791
|
+
selectedFile,
|
|
1792
|
+
setDeleting,
|
|
1793
|
+
setDeleteError,
|
|
1794
|
+
port,
|
|
1795
|
+
setDeleteOpen,
|
|
1796
|
+
setIsDirty,
|
|
1797
|
+
commitPath,
|
|
1798
|
+
setSelectedFile,
|
|
1799
|
+
refresh,
|
|
1800
|
+
reportFailure
|
|
1801
|
+
}), [selectedFile, port, refresh, commitPath, reportFailure]);
|
|
1427
1802
|
const historyPath = selectedFile?.path ?? null;
|
|
1428
1803
|
useEffect4(() => {
|
|
1429
1804
|
setHistoryOpen(false);
|
|
@@ -1431,26 +1806,21 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1431
1806
|
const canShowHistory = typeof port.listRevisions === "function" && typeof port.readRevision === "function";
|
|
1432
1807
|
const listRevisions = useCallback2((path) => port.listRevisions(path), [port]);
|
|
1433
1808
|
const readRevision = useCallback2((path, id) => port.readRevision(path, id), [port]);
|
|
1434
|
-
const restoreRevision = useCallback2(
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
setHistoryOpen
|
|
1446
|
-
setReloadNonce
|
|
1447
|
-
} finally {
|
|
1448
|
-
if (saveRequestRef.current === request) {
|
|
1449
|
-
saveRequestRef.current = null;
|
|
1450
|
-
setSaving(false);
|
|
1451
|
-
}
|
|
1809
|
+
const restoreRevision = useCallback2((content) => restoreVaultRevision(
|
|
1810
|
+
content,
|
|
1811
|
+
{
|
|
1812
|
+
saveScopeRef,
|
|
1813
|
+
mountedRef,
|
|
1814
|
+
selectedFile,
|
|
1815
|
+
saveScopeKey,
|
|
1816
|
+
port,
|
|
1817
|
+
dirtyRef,
|
|
1818
|
+
saveRequestRef,
|
|
1819
|
+
setSaving,
|
|
1820
|
+
setHistoryOpen,
|
|
1821
|
+
setReloadNonce
|
|
1452
1822
|
}
|
|
1453
|
-
|
|
1823
|
+
), [port, selectedFile, saveScopeKey]);
|
|
1454
1824
|
const shownPath = selectedFile?.path ?? null;
|
|
1455
1825
|
useEffect4(() => {
|
|
1456
1826
|
if (!shownPath || !treeStateKey) return;
|
|
@@ -1481,6 +1851,215 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1481
1851
|
setNewPath("");
|
|
1482
1852
|
setCreateError(null);
|
|
1483
1853
|
};
|
|
1854
|
+
return {
|
|
1855
|
+
treeLoaded,
|
|
1856
|
+
treeLoading,
|
|
1857
|
+
treeError,
|
|
1858
|
+
label,
|
|
1859
|
+
retryTree,
|
|
1860
|
+
noun,
|
|
1861
|
+
setTreeError,
|
|
1862
|
+
vaultEmpty,
|
|
1863
|
+
trimmedQuery,
|
|
1864
|
+
treeEmptyState,
|
|
1865
|
+
canCreate,
|
|
1866
|
+
openCreate,
|
|
1867
|
+
nameMatches,
|
|
1868
|
+
contentResults,
|
|
1869
|
+
onQueryChange,
|
|
1870
|
+
renderTree,
|
|
1871
|
+
visibleRoot,
|
|
1872
|
+
resolvedSelectedPath,
|
|
1873
|
+
handleTreeSelect,
|
|
1874
|
+
activeFolder,
|
|
1875
|
+
handleFolderToggle,
|
|
1876
|
+
treeStateKey,
|
|
1877
|
+
guardedOpen,
|
|
1878
|
+
retryContentSearch,
|
|
1879
|
+
commitPath,
|
|
1880
|
+
setSelectedFile,
|
|
1881
|
+
rootRef,
|
|
1882
|
+
className,
|
|
1883
|
+
selectedPath,
|
|
1884
|
+
showFiles,
|
|
1885
|
+
showFileList,
|
|
1886
|
+
showDocument,
|
|
1887
|
+
treeHeadingId,
|
|
1888
|
+
headerActions,
|
|
1889
|
+
refresh,
|
|
1890
|
+
setFolderPath,
|
|
1891
|
+
query,
|
|
1892
|
+
canSearchContent,
|
|
1893
|
+
searchRef,
|
|
1894
|
+
documentRef,
|
|
1895
|
+
selectedFile,
|
|
1896
|
+
pathBarClassName,
|
|
1897
|
+
canWrite,
|
|
1898
|
+
isMarkdownCapable,
|
|
1899
|
+
editorMode,
|
|
1900
|
+
showRichMode,
|
|
1901
|
+
showSourceMode,
|
|
1902
|
+
canShowHistory,
|
|
1903
|
+
historyOpen,
|
|
1904
|
+
isDirty,
|
|
1905
|
+
setHistoryOpen,
|
|
1906
|
+
renderDock,
|
|
1907
|
+
persistentDock,
|
|
1908
|
+
dockInline,
|
|
1909
|
+
dockButtonLabel,
|
|
1910
|
+
dockOpen,
|
|
1911
|
+
dockBlockedByDraft,
|
|
1912
|
+
dockLabel,
|
|
1913
|
+
dockToggleCfg,
|
|
1914
|
+
setDockOpen,
|
|
1915
|
+
onDownloadFile,
|
|
1916
|
+
canDelete,
|
|
1917
|
+
setDeleteError,
|
|
1918
|
+
setDeleteOpen,
|
|
1919
|
+
fileActions,
|
|
1920
|
+
saveError,
|
|
1921
|
+
saveCurrent,
|
|
1922
|
+
setSaveError,
|
|
1923
|
+
readError,
|
|
1924
|
+
setReloadNonce,
|
|
1925
|
+
setReadError,
|
|
1926
|
+
fileLoading,
|
|
1927
|
+
listRevisions,
|
|
1928
|
+
readRevision,
|
|
1929
|
+
renderArtifact,
|
|
1930
|
+
activeCodec,
|
|
1931
|
+
restoreRevision,
|
|
1932
|
+
sourceDraft,
|
|
1933
|
+
saving,
|
|
1934
|
+
onSourceChange,
|
|
1935
|
+
richDraft,
|
|
1936
|
+
savedRichDraft,
|
|
1937
|
+
onRichChange,
|
|
1938
|
+
emptyState,
|
|
1939
|
+
recentToOffer,
|
|
1940
|
+
createOpen,
|
|
1941
|
+
newPath,
|
|
1942
|
+
creating,
|
|
1943
|
+
createError,
|
|
1944
|
+
setNewPath,
|
|
1945
|
+
handleCreate,
|
|
1946
|
+
cancelCreate,
|
|
1947
|
+
deleteOpen,
|
|
1948
|
+
deleting,
|
|
1949
|
+
handleDelete,
|
|
1950
|
+
deleteError,
|
|
1951
|
+
pendingNav,
|
|
1952
|
+
confirmDiscard,
|
|
1953
|
+
finishPendingOpen,
|
|
1954
|
+
setPendingNav
|
|
1955
|
+
};
|
|
1956
|
+
}
|
|
1957
|
+
var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
1958
|
+
const view = useVaultPaneViewState(props, ref);
|
|
1959
|
+
return /* @__PURE__ */ jsx10(VaultPaneView, { ...view });
|
|
1960
|
+
});
|
|
1961
|
+
function VaultPaneView({
|
|
1962
|
+
treeLoaded,
|
|
1963
|
+
treeLoading,
|
|
1964
|
+
treeError,
|
|
1965
|
+
label,
|
|
1966
|
+
retryTree,
|
|
1967
|
+
noun,
|
|
1968
|
+
setTreeError,
|
|
1969
|
+
vaultEmpty,
|
|
1970
|
+
trimmedQuery,
|
|
1971
|
+
treeEmptyState,
|
|
1972
|
+
canCreate,
|
|
1973
|
+
openCreate,
|
|
1974
|
+
nameMatches,
|
|
1975
|
+
contentResults,
|
|
1976
|
+
onQueryChange,
|
|
1977
|
+
renderTree,
|
|
1978
|
+
visibleRoot,
|
|
1979
|
+
resolvedSelectedPath,
|
|
1980
|
+
handleTreeSelect,
|
|
1981
|
+
activeFolder,
|
|
1982
|
+
handleFolderToggle,
|
|
1983
|
+
treeStateKey,
|
|
1984
|
+
guardedOpen,
|
|
1985
|
+
retryContentSearch,
|
|
1986
|
+
commitPath,
|
|
1987
|
+
setSelectedFile,
|
|
1988
|
+
rootRef,
|
|
1989
|
+
className,
|
|
1990
|
+
selectedPath,
|
|
1991
|
+
showFiles,
|
|
1992
|
+
showFileList,
|
|
1993
|
+
showDocument,
|
|
1994
|
+
treeHeadingId,
|
|
1995
|
+
headerActions,
|
|
1996
|
+
refresh,
|
|
1997
|
+
setFolderPath,
|
|
1998
|
+
query,
|
|
1999
|
+
canSearchContent,
|
|
2000
|
+
searchRef,
|
|
2001
|
+
documentRef,
|
|
2002
|
+
selectedFile,
|
|
2003
|
+
pathBarClassName,
|
|
2004
|
+
canWrite,
|
|
2005
|
+
isMarkdownCapable,
|
|
2006
|
+
editorMode,
|
|
2007
|
+
showRichMode,
|
|
2008
|
+
showSourceMode,
|
|
2009
|
+
canShowHistory,
|
|
2010
|
+
historyOpen,
|
|
2011
|
+
isDirty,
|
|
2012
|
+
setHistoryOpen,
|
|
2013
|
+
renderDock,
|
|
2014
|
+
persistentDock,
|
|
2015
|
+
dockInline,
|
|
2016
|
+
dockButtonLabel,
|
|
2017
|
+
dockOpen,
|
|
2018
|
+
dockBlockedByDraft,
|
|
2019
|
+
dockLabel,
|
|
2020
|
+
dockToggleCfg,
|
|
2021
|
+
setDockOpen,
|
|
2022
|
+
onDownloadFile,
|
|
2023
|
+
canDelete,
|
|
2024
|
+
setDeleteError,
|
|
2025
|
+
setDeleteOpen,
|
|
2026
|
+
fileActions,
|
|
2027
|
+
saveError,
|
|
2028
|
+
saveCurrent,
|
|
2029
|
+
setSaveError,
|
|
2030
|
+
readError,
|
|
2031
|
+
setReloadNonce,
|
|
2032
|
+
setReadError,
|
|
2033
|
+
fileLoading,
|
|
2034
|
+
listRevisions,
|
|
2035
|
+
readRevision,
|
|
2036
|
+
renderArtifact,
|
|
2037
|
+
activeCodec,
|
|
2038
|
+
restoreRevision,
|
|
2039
|
+
sourceDraft,
|
|
2040
|
+
saving,
|
|
2041
|
+
onSourceChange,
|
|
2042
|
+
richDraft,
|
|
2043
|
+
savedRichDraft,
|
|
2044
|
+
onRichChange,
|
|
2045
|
+
emptyState,
|
|
2046
|
+
recentToOffer,
|
|
2047
|
+
createOpen,
|
|
2048
|
+
newPath,
|
|
2049
|
+
creating,
|
|
2050
|
+
createError,
|
|
2051
|
+
setNewPath,
|
|
2052
|
+
handleCreate,
|
|
2053
|
+
cancelCreate,
|
|
2054
|
+
deleteOpen,
|
|
2055
|
+
deleting,
|
|
2056
|
+
handleDelete,
|
|
2057
|
+
deleteError,
|
|
2058
|
+
pendingNav,
|
|
2059
|
+
confirmDiscard,
|
|
2060
|
+
finishPendingOpen,
|
|
2061
|
+
setPendingNav
|
|
2062
|
+
}) {
|
|
1484
2063
|
let treeContent;
|
|
1485
2064
|
if (!treeLoaded && (treeLoading || !treeError)) {
|
|
1486
2065
|
treeContent = /* @__PURE__ */ jsx10(TreeSkeleton, {});
|
|
@@ -1669,10 +2248,222 @@ var VaultPane = forwardRef(function VaultPane2(props, ref) {
|
|
|
1669
2248
|
}
|
|
1670
2249
|
)
|
|
1671
2250
|
] }) });
|
|
1672
|
-
}
|
|
2251
|
+
}
|
|
2252
|
+
function useVaultTreeProjection({
|
|
2253
|
+
tree,
|
|
2254
|
+
selectedPath,
|
|
2255
|
+
folderPath,
|
|
2256
|
+
label,
|
|
2257
|
+
port
|
|
2258
|
+
}) {
|
|
2259
|
+
const treePaths = useMemo2(
|
|
2260
|
+
() => collectTreePaths(tree, { files: /* @__PURE__ */ new Set(), directories: /* @__PURE__ */ new Set() }),
|
|
2261
|
+
[tree]
|
|
2262
|
+
);
|
|
2263
|
+
const resolvedSelectedPath = useMemo2(() => {
|
|
2264
|
+
if (!selectedPath) return null;
|
|
2265
|
+
const listed = resolveTreePath(selectedPath, treePaths);
|
|
2266
|
+
if (listed?.type === "directory") return null;
|
|
2267
|
+
return listed?.path ?? selectedPath;
|
|
2268
|
+
}, [selectedPath, treePaths]);
|
|
2269
|
+
const activeFolderNode = useMemo2(
|
|
2270
|
+
() => folderPath ? findDirectory(tree, folderPath) : null,
|
|
2271
|
+
[tree, folderPath]
|
|
2272
|
+
);
|
|
2273
|
+
const activeFolder = activeFolderNode?.path ?? null;
|
|
2274
|
+
const treeRoot = useMemo2(
|
|
2275
|
+
() => ({ name: label, path: "", type: "directory", children: tree }),
|
|
2276
|
+
[tree, label]
|
|
2277
|
+
);
|
|
2278
|
+
const { query, onQueryChange, visibleRoot, canSearchContent, contentResults, retry: retryContentSearch } = useVaultSearch({ port, treeRoot });
|
|
2279
|
+
return {
|
|
2280
|
+
treePaths,
|
|
2281
|
+
resolvedSelectedPath,
|
|
2282
|
+
activeFolderNode,
|
|
2283
|
+
activeFolder,
|
|
2284
|
+
treeRoot,
|
|
2285
|
+
query,
|
|
2286
|
+
onQueryChange,
|
|
2287
|
+
visibleRoot,
|
|
2288
|
+
canSearchContent,
|
|
2289
|
+
contentResults,
|
|
2290
|
+
retryContentSearch
|
|
2291
|
+
};
|
|
2292
|
+
}
|
|
2293
|
+
function useVaultDocumentFocus({ setFilesOpen, documentRef }) {
|
|
2294
|
+
const showDocument = useCallback2(() => {
|
|
2295
|
+
const focused = document.activeElement;
|
|
2296
|
+
setFilesOpen(false);
|
|
2297
|
+
requestAnimationFrame(() => {
|
|
2298
|
+
if (document.activeElement === focused || document.activeElement === document.body) {
|
|
2299
|
+
documentRef.current?.focus({ preventScroll: true });
|
|
2300
|
+
}
|
|
2301
|
+
});
|
|
2302
|
+
}, []);
|
|
2303
|
+
return { showDocument };
|
|
2304
|
+
}
|
|
2305
|
+
function useVaultPendingOpenCompletion({
|
|
2306
|
+
pendingOpenRef,
|
|
2307
|
+
setPendingNav,
|
|
2308
|
+
previousPortRef,
|
|
2309
|
+
port,
|
|
2310
|
+
selectedPath
|
|
2311
|
+
}) {
|
|
2312
|
+
const finishPendingOpen = useCallback2((opened, clearNavigation = true) => finishVaultPendingOpen(opened, clearNavigation, {
|
|
2313
|
+
pendingOpenRef,
|
|
2314
|
+
setPendingNav
|
|
2315
|
+
}), []);
|
|
2316
|
+
useEffect4(() => () => finishPendingOpen(false, false), [finishPendingOpen]);
|
|
2317
|
+
useEffect4(() => {
|
|
2318
|
+
if (previousPortRef.current !== port) finishPendingOpen(false);
|
|
2319
|
+
previousPortRef.current = port;
|
|
2320
|
+
}, [port, finishPendingOpen]);
|
|
2321
|
+
useEffect4(() => {
|
|
2322
|
+
const pending = pendingOpenRef.current;
|
|
2323
|
+
if (!pending) return;
|
|
2324
|
+
if (selectedPath === pending.path) pending.selected = true;
|
|
2325
|
+
else if (pending.selected || selectedPath !== pending.fromPath) finishPendingOpen(false);
|
|
2326
|
+
}, [selectedPath, finishPendingOpen]);
|
|
2327
|
+
return { finishPendingOpen };
|
|
2328
|
+
}
|
|
2329
|
+
function useVaultDraftEditing({
|
|
2330
|
+
setEditorMode,
|
|
2331
|
+
activeCodec,
|
|
2332
|
+
sourceDraft,
|
|
2333
|
+
draftContentRef,
|
|
2334
|
+
dirtyRef,
|
|
2335
|
+
savedContentRef,
|
|
2336
|
+
editorModeRef,
|
|
2337
|
+
setRichDraft,
|
|
2338
|
+
setIsDirty,
|
|
2339
|
+
isDirty,
|
|
2340
|
+
richDraft,
|
|
2341
|
+
setSourceDraft,
|
|
2342
|
+
mountedRef,
|
|
2343
|
+
saveScopeRef,
|
|
2344
|
+
saveScopeKey,
|
|
2345
|
+
selectedFile,
|
|
2346
|
+
port,
|
|
2347
|
+
saveRequestRef,
|
|
2348
|
+
setSaving,
|
|
2349
|
+
setSaveError,
|
|
2350
|
+
savedResultRef,
|
|
2351
|
+
setSelectedFile,
|
|
2352
|
+
reportFailure,
|
|
2353
|
+
loadedPathRef
|
|
2354
|
+
}) {
|
|
2355
|
+
const showRichMode = useCallback2(() => showVaultRichMode({
|
|
2356
|
+
setEditorMode,
|
|
2357
|
+
activeCodec,
|
|
2358
|
+
sourceDraft,
|
|
2359
|
+
draftContentRef,
|
|
2360
|
+
dirtyRef,
|
|
2361
|
+
savedContentRef,
|
|
2362
|
+
editorModeRef,
|
|
2363
|
+
setRichDraft,
|
|
2364
|
+
setIsDirty
|
|
2365
|
+
}), [activeCodec, sourceDraft]);
|
|
2366
|
+
const showSourceMode = useCallback2(() => showVaultSourceMode({
|
|
2367
|
+
setEditorMode,
|
|
2368
|
+
isDirty,
|
|
2369
|
+
activeCodec,
|
|
2370
|
+
richDraft,
|
|
2371
|
+
savedContentRef,
|
|
2372
|
+
draftContentRef,
|
|
2373
|
+
dirtyRef,
|
|
2374
|
+
editorModeRef,
|
|
2375
|
+
setSourceDraft,
|
|
2376
|
+
setIsDirty
|
|
2377
|
+
}), [activeCodec, isDirty, richDraft]);
|
|
2378
|
+
const onSourceChange = useCallback2((next) => changeVaultSource(next, {
|
|
2379
|
+
mountedRef,
|
|
2380
|
+
editorModeRef,
|
|
2381
|
+
saveScopeRef,
|
|
2382
|
+
saveScopeKey,
|
|
2383
|
+
draftContentRef,
|
|
2384
|
+
dirtyRef,
|
|
2385
|
+
savedContentRef,
|
|
2386
|
+
setSourceDraft,
|
|
2387
|
+
setIsDirty
|
|
2388
|
+
}), [saveScopeKey]);
|
|
2389
|
+
const onRichChange = useCallback2((next) => changeVaultRichDraft(
|
|
2390
|
+
next,
|
|
2391
|
+
{
|
|
2392
|
+
mountedRef,
|
|
2393
|
+
editorModeRef,
|
|
2394
|
+
saveScopeRef,
|
|
2395
|
+
saveScopeKey,
|
|
2396
|
+
draftContentRef,
|
|
2397
|
+
activeCodec,
|
|
2398
|
+
dirtyRef,
|
|
2399
|
+
savedContentRef,
|
|
2400
|
+
setRichDraft,
|
|
2401
|
+
setIsDirty
|
|
2402
|
+
}
|
|
2403
|
+
), [activeCodec, saveScopeKey]);
|
|
2404
|
+
const saveCurrent = useCallback2(() => saveVaultFile({
|
|
2405
|
+
saveScopeRef,
|
|
2406
|
+
mountedRef,
|
|
2407
|
+
selectedFile,
|
|
2408
|
+
dirtyRef,
|
|
2409
|
+
saveScopeKey,
|
|
2410
|
+
port,
|
|
2411
|
+
saveRequestRef,
|
|
2412
|
+
draftContentRef,
|
|
2413
|
+
setSaving,
|
|
2414
|
+
setSaveError,
|
|
2415
|
+
savedContentRef,
|
|
2416
|
+
savedResultRef,
|
|
2417
|
+
setSelectedFile,
|
|
2418
|
+
setIsDirty,
|
|
2419
|
+
setSourceDraft,
|
|
2420
|
+
setRichDraft,
|
|
2421
|
+
activeCodec,
|
|
2422
|
+
reportFailure,
|
|
2423
|
+
loadedPathRef
|
|
2424
|
+
}), [selectedFile, activeCodec, port, reportFailure, saveScopeKey]);
|
|
2425
|
+
return { showRichMode, showSourceMode, onSourceChange, onRichChange, saveCurrent };
|
|
2426
|
+
}
|
|
2427
|
+
function useVaultDocumentState() {
|
|
2428
|
+
const [selectedFile, setSelectedFile] = useState4(null);
|
|
2429
|
+
const [displayReadyPath, setDisplayReadyPath] = useState4(null);
|
|
2430
|
+
const [fileLoading, setFileLoading] = useState4(false);
|
|
2431
|
+
const [readError, setReadError] = useState4(null);
|
|
2432
|
+
const [reloadNonce, setReloadNonce] = useState4(0);
|
|
2433
|
+
const [saving, setSaving] = useState4(false);
|
|
2434
|
+
const [saveError, setSaveError] = useState4(null);
|
|
2435
|
+
const [editorMode, setEditorMode] = useState4("rich");
|
|
2436
|
+
const [richDraft, setRichDraft] = useState4("");
|
|
2437
|
+
const [sourceDraft, setSourceDraft] = useState4("");
|
|
2438
|
+
const [isDirty, setIsDirty] = useState4(false);
|
|
2439
|
+
return {
|
|
2440
|
+
selectedFile,
|
|
2441
|
+
setSelectedFile,
|
|
2442
|
+
displayReadyPath,
|
|
2443
|
+
setDisplayReadyPath,
|
|
2444
|
+
fileLoading,
|
|
2445
|
+
setFileLoading,
|
|
2446
|
+
readError,
|
|
2447
|
+
setReadError,
|
|
2448
|
+
reloadNonce,
|
|
2449
|
+
setReloadNonce,
|
|
2450
|
+
saving,
|
|
2451
|
+
setSaving,
|
|
2452
|
+
saveError,
|
|
2453
|
+
setSaveError,
|
|
2454
|
+
editorMode,
|
|
2455
|
+
setEditorMode,
|
|
2456
|
+
richDraft,
|
|
2457
|
+
setRichDraft,
|
|
2458
|
+
sourceDraft,
|
|
2459
|
+
setSourceDraft,
|
|
2460
|
+
isDirty,
|
|
2461
|
+
setIsDirty
|
|
2462
|
+
};
|
|
2463
|
+
}
|
|
1673
2464
|
|
|
1674
2465
|
export {
|
|
1675
2466
|
ConfirmDialog,
|
|
1676
2467
|
VaultPane
|
|
1677
2468
|
};
|
|
1678
|
-
//# sourceMappingURL=chunk-
|
|
2469
|
+
//# sourceMappingURL=chunk-W2BV2XOC.js.map
|