@uniqbit/mate-core 1.0.0-canary.2 → 1.0.0-canary.5
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/claude-capability-plugins/companion-mentions/.claude-plugin/plugin.json +1 -1
- package/claude-plugin/hooks/hooks.json +21 -1
- package/claude-plugin/hooks/session-attention.mjs +10 -0
- package/claude-plugin/hooks/session-end.mjs +9 -0
- package/claude-plugin/hooks/session-guidance.mjs +1 -1
- package/opencode-plugin/src/server.ts +13 -2
- package/opencode-plugin/src/tui.tsx +1 -1
- package/opencode-plugin/tui.tsx +2 -1
- package/package.json +1 -1
- package/src/cli/commands/artifact/delivery/archive.ts +2 -2
- package/src/cli/commands/artifact/delivery/link.ts +22 -5
- package/src/cli/commands/artifact/delivery/output.ts +9 -1
- package/src/cli/commands/artifact/finish/openspec.ts +1 -3
- package/src/cli/commands/companion/companion.ts +1 -1
- package/src/cli/commands/companion/link.ts +36 -4
- package/src/cli/commands/companion/open.ts +40 -12
- package/src/cli/commands/doctor.ts +122 -0
- package/src/cli/commands/session/prepare.ts +32 -4
- package/src/cli/commands/session/registry.ts +90 -0
- package/src/cli/commands/studio/companion-removal.ts +79 -0
- package/src/cli/commands/studio/mate-inventory.ts +1 -1
- package/src/cli/commands/studio/payload.ts +12 -1
- package/src/cli/commands/studio/server.ts +39 -16
- package/src/cli/commands/studio/services.ts +20 -0
- package/src/cli/commands/studio/skill-files.ts +133 -0
- package/src/cli/commands/studio/vault.ts +218 -44
- package/src/cli/commands/studio/views/model.ts +0 -5
- package/src/cli/commands/studio/views/vault/markdown-tree.ts +255 -4
- package/src/cli/commands/unwrap.ts +8 -0
- package/src/cli/commands/update.ts +26 -8
- package/src/cli/commands/vscode/setup.ts +155 -0
- package/src/cli/commands/vscode/vsix.ts +73 -0
- package/src/cli/commands/working/cleanup.ts +34 -10
- package/src/cli/commands/working/worktree.ts +58 -8
- package/src/cli/commands/wrap.ts +33 -7
- package/src/cli/main.ts +9 -2
- package/src/cli/usage.ts +6 -1
- package/src/hooks/companion-instructions.ts +19 -11
- package/src/hooks/hook-io.ts +15 -0
- package/src/hooks/session-banner.ts +5 -3
- package/src/hooks/session-end.ts +10 -0
- package/src/hooks/session-guidance.ts +10 -6
- package/src/hooks/session-prepare.ts +47 -31
- package/src/hooks/session-register.ts +199 -0
- package/src/hooks/tokensave-route.ts +7 -3
- package/src/hooks/validate-artifact-path.ts +9 -2
- package/src/lib/delivery/archive-change.ts +0 -1
- package/src/lib/delivery/branches.ts +15 -0
- package/src/lib/delivery/record-delivery.ts +94 -39
- package/src/lib/delivery/record.ts +30 -28
- package/src/lib/delivery/refresh.ts +37 -17
- package/src/lib/delivery/resolve-branch.ts +258 -37
- package/src/lib/factory/outcomes/index.ts +11 -1
- package/src/lib/factory/runtime.ts +10 -1
- package/src/lib/opencode-server.ts +238 -0
- package/src/lib/orchestrator/adapters/claude.ts +147 -2
- package/src/lib/orchestrator/adapters/opencode.ts +53 -2
- package/src/lib/orchestrator/checkout-adoption.ts +125 -0
- package/src/lib/orchestrator/companion-registry-store.ts +6 -2
- package/src/lib/orchestrator/editor.ts +2 -2
- package/src/lib/orchestrator/framework-context.ts +26 -14
- package/src/lib/orchestrator/global-config-store.ts +11 -0
- package/src/lib/orchestrator/launcher.ts +15 -2
- package/src/lib/orchestrator/projection-claude-links.ts +52 -5
- package/src/lib/orchestrator/projection-claude-skills.ts +28 -2
- package/src/lib/orchestrator/projection-companion-link.ts +12 -1
- package/src/lib/orchestrator/registry-checkouts.ts +177 -0
- package/src/lib/orchestrator/repository-link.ts +216 -57
- package/src/lib/orchestrator/serving-claude-wrap.ts +43 -0
- package/src/lib/orchestrator/session-context-link.ts +11 -5
- package/src/lib/orchestrator/session-prepare.ts +36 -6
- package/src/lib/orchestrator/types.ts +5 -0
- package/src/lib/orchestrator/workspace-inventory.ts +5 -1
- package/src/lib/public-npm.ts +17 -0
- package/src/lib/session-attribution.ts +52 -0
- package/src/lib/session-state.ts +285 -0
- package/src/lib/session-stop.ts +64 -0
- package/src/lib/workset/record.ts +20 -0
- package/src/lib/workset/worktree.ts +85 -17
- package/src/opencode/background-server.ts +145 -0
- package/src/opencode/companion-hooks.ts +3 -1
- package/src/opencode/companion-policy.ts +2 -2
- package/src/opencode/projected-guidance.ts +2 -1
- package/src/opencode/session-register.ts +176 -0
- package/src/opencode/tui.tsx +19 -29
- package/src/runtime/claude-delivery-plan.ts +14 -3
- package/src/runtime/current-branch.ts +10 -0
- package/src/runtime/env.ts +13 -7
- package/src/runtime/git-layout.ts +164 -17
- package/src/runtime/launch-env-guard.ts +65 -0
- package/src/runtime/opencode-server-record.ts +136 -0
- package/src/runtime/projection.ts +40 -6
- package/src/runtime/repo-local.ts +6 -1
- package/src/runtime/serving-claude-wrap.ts +28 -0
- package/src/runtime/session-context.ts +4 -3
- package/src/runtime/session-registry.ts +434 -0
- package/src/runtime/tokensave-route.ts +10 -5
- package/src/runtime/wrap-state.ts +31 -0
- package/src/studio.ts +2 -0
- package/src/templates/mate-skills/agents/mate-apply-change/SKILL.md +49 -21
- package/src/templates/mate-skills/agents/mate-archive-change/SKILL.md +0 -5
- package/src/templates/mate-skills/agents/mate-propose-change/SKILL.md +2 -8
- package/src/templates/mate-skills/agents/mate-propose-change/references/mate-revise.md +1 -3
- package/src/templates/mate-skills/agents/mate-publish-artifact/SKILL.md +2 -4
- package/src/templates/mate-skills/claude/mate-apply-change/SKILL.md +49 -21
- package/src/templates/mate-skills/claude/mate-archive-change/SKILL.md +0 -5
- package/src/templates/mate-skills/claude/mate-propose-change/SKILL.md +2 -8
- package/src/templates/mate-skills/claude/mate-propose-change/references/mate-revise.md +1 -3
- package/src/templates/mate-skills/claude/mate-publish-artifact/SKILL.md +2 -4
- package/src/tools/setup/__snapshots__/runtime-surface-golden.test.ts.snap +404 -30
- package/src/tools/setup/dynamic-plugins/hydrate.ts +4 -3
- package/src/tools/setup/providers/claude-plugin-hooks.ts +26 -0
- package/src/tools/setup/providers/claude.ts +21 -1
- package/studio-dist/client/assets/app-CdPiFv59.css +2 -0
- package/studio-dist/client/assets/button-BIIHE0EQ.js +3 -0
- package/studio-dist/client/assets/companion-view-DM6YyXaR.js +1 -0
- package/studio-dist/client/assets/delivery-path-DELxj0Av.js +1 -0
- package/studio-dist/client/assets/factory-BZy0E8ty.js +4 -0
- package/studio-dist/client/assets/index-B3wkMzjA.js +40 -0
- package/studio-dist/client/assets/markdown-view-pQ2Qp_i5.js +1 -0
- package/studio-dist/client/assets/panel-CbajlC3p.js +1 -0
- package/studio-dist/client/assets/{prepaint-CD5OpmTM.js → prepaint-CwSrpdFA.js} +7 -4
- package/studio-dist/client/assets/react-CN2GSx7x.js +1 -0
- package/studio-dist/client/assets/reports-DllhYQ5_.js +1 -0
- package/studio-dist/client/assets/routes-COm-G3mK.js +1 -0
- package/studio-dist/client/assets/skills-DmWAy-jZ.js +1 -0
- package/studio-dist/client/assets/specs-BG3Wi3ln.js +1 -0
- package/studio-dist/client/assets/steps-DFsH3Neu.js +1 -0
- package/studio-dist/client/assets/vault-B2q1nBY5.js +1 -0
- package/studio-dist/client/assets/warnings-BSXIyuSQ.js +1 -0
- package/studio-dist/client/assets/workflow-DlsQD6Hc.js +1 -0
- package/studio-dist/server/assets/{__23tanstack-start-server-fn-resolver-BQKuMdJW.js → __23tanstack-start-server-fn-resolver-M2GBs8s3.js} +179 -9
- package/studio-dist/server/assets/_tanstack-start-manifest_v.js +35 -25
- package/studio-dist/server/assets/button-CIJqAhni.js +11929 -0
- package/studio-dist/server/assets/{companion-view-aBady57v.js → companion-view-DISASvdJ.js} +13 -7
- package/studio-dist/server/assets/companions-BYbHWKOZ.js +15 -0
- package/studio-dist/server/assets/delivery-path-C29fBynY.js +654 -0
- package/studio-dist/server/assets/{factory-DT3UzHlh.js → factory-DGPmNGbo.js} +1 -0
- package/studio-dist/server/assets/{factory-D6xnjedJ.js → factory-DUTa0eDs.js} +317 -530
- package/studio-dist/server/assets/markdown-view-Bn7xPdks.js +86 -0
- package/studio-dist/server/assets/panel-3Jmn4awF.js +169 -0
- package/studio-dist/server/assets/{prepaint-BMke0fo1.js → prepaint-DJfTQ_VH.js} +6 -2
- package/studio-dist/server/assets/{react-COs0LHn-.js → react-Ce6dj15C.js} +4 -9
- package/studio-dist/server/assets/reports-C06RXVE2.js +18 -0
- package/studio-dist/server/assets/reports-D6YMqhnO.js +142 -0
- package/studio-dist/server/assets/router-C8MGqlAY.js +13713 -0
- package/studio-dist/server/assets/routes-BcFgvqf7.js +622 -0
- package/studio-dist/server/assets/{shell-CboT2f66.js → shell-DS3wUexh.js} +1 -0
- package/studio-dist/server/assets/skills-BEnOxiDl.js +266 -0
- package/studio-dist/server/assets/skills-CtrBAtX3.js +28 -0
- package/studio-dist/server/assets/specs-C8rv34-5.js +211 -0
- package/studio-dist/server/assets/{start-BW5ovN0k.js → start-h3ICWwd2.js} +4 -1
- package/studio-dist/server/assets/steps-Dq_CwY_s.js +181 -0
- package/studio-dist/server/assets/{vault-BGulVoNh.js → vault-BmWnryh3.js} +16 -1
- package/studio-dist/server/assets/vault-Fvxt2Tzl.js +1032 -0
- package/studio-dist/server/assets/{views-Bd7cRr27.js → views-BgYa-za2.js} +1 -3
- package/studio-dist/server/assets/warnings-DzR6fyZh.js +23 -0
- package/studio-dist/server/assets/workflow-liRYecHk.js +73 -0
- package/studio-dist/server/server.js +3 -157
- package/studio-dist/client/assets/companion-view-Csva26Ir.js +0 -1
- package/studio-dist/client/assets/delivery-path-DJMpRmiY.js +0 -1
- package/studio-dist/client/assets/factory-B7l9ZQyx.js +0 -4
- package/studio-dist/client/assets/index-n6uo_92S.js +0 -40
- package/studio-dist/client/assets/queries-CN3JwMBX.js +0 -1
- package/studio-dist/client/assets/react-CabXf2Ds.js +0 -1
- package/studio-dist/client/assets/report-time-Dc-KOqQu.js +0 -1
- package/studio-dist/client/assets/reports-C01RsnMA.js +0 -1
- package/studio-dist/client/assets/routes-4pbC-2Hj.js +0 -1
- package/studio-dist/client/assets/skills-CihQganl.js +0 -1
- package/studio-dist/client/assets/spec-areas-C2L48N4C.js +0 -1
- package/studio-dist/client/assets/specs-D24_35_K.js +0 -1
- package/studio-dist/client/assets/studio-DKxfi691.css +0 -1
- package/studio-dist/client/assets/studio-queries-rvbJupCy.js +0 -3
- package/studio-dist/client/assets/vault-Bd4CQiTK.js +0 -1
- package/studio-dist/client/assets/warnings-V_Ys51wJ.js +0 -1
- package/studio-dist/client/assets/workflow-BJejeVwQ.js +0 -1
- package/studio-dist/server/assets/delivery-path-BkKNjgkf.js +0 -778
- package/studio-dist/server/assets/queries-Ag2iL8q2.js +0 -107
- package/studio-dist/server/assets/report-time-DAfzln-N.js +0 -8
- package/studio-dist/server/assets/reports-BnUNJVtx.js +0 -126
- package/studio-dist/server/assets/router-BH--drIx.js +0 -4298
- package/studio-dist/server/assets/routes-khSDK1bV.js +0 -361
- package/studio-dist/server/assets/skills-MWYnWoKs.js +0 -106
- package/studio-dist/server/assets/spec-areas-DcnO6vW-.js +0 -16
- package/studio-dist/server/assets/specs-DE3w8hZP.js +0 -155
- package/studio-dist/server/assets/studio-queries-CLnP9kGu.js +0 -3365
- package/studio-dist/server/assets/vault-CuyyhLyB.js +0 -832
- package/studio-dist/server/assets/warnings-BH05rOuG.js +0 -15
- package/studio-dist/server/assets/workflow-BSuIKWqH.js +0 -42
|
@@ -0,0 +1,1032 @@
|
|
|
1
|
+
import { i as __toESM } from "./rolldown-runtime-DYf_mQCB.js";
|
|
2
|
+
import { B as useMutation, L as useVaultUi, S as useMediaQuery, V as useSuspenseQuery, r as Route, x as ViewPlaceholder, z as Tooltip } from "./router-C8MGqlAY.js";
|
|
3
|
+
import { Ar as cn, Bi as Link, Gr as vaultChildrenQuery, Ii as useQueryClient, Jr as getVault, Kr as vaultMatchesQuery, Lr as afterVaultFileChange, Rr as afterVaultRefresh, Ur as shellQuery, Vi as useNavigate, Xr as saveVaultFile, Yr as previewVaultFile, fi as useQuery, n as buttonVariants, nt as ListCard, qr as vaultQuery, r as Icon, st as ROW, t as Button } from "./button-CIJqAhni.js";
|
|
4
|
+
import { c as useRouter, j as require_react, u as require_jsx_runtime } from "./__23tanstack-start-server-fn-resolver-M2GBs8s3.js";
|
|
5
|
+
import { t as MarkdownView } from "./markdown-view-Bn7xPdks.js";
|
|
6
|
+
// ../../node_modules/.bun/@tanstack+react-router@1.170.46+7492c01c6988791b/node_modules/@tanstack/react-router/dist/esm/useBlocker.js
|
|
7
|
+
var import_react = /* @__PURE__ */ __toESM(require_react(), 1);
|
|
8
|
+
function _resolveBlockerOpts(opts, condition) {
|
|
9
|
+
if (opts === void 0) return {
|
|
10
|
+
shouldBlockFn: () => true,
|
|
11
|
+
withResolver: false
|
|
12
|
+
};
|
|
13
|
+
if ("shouldBlockFn" in opts) return opts;
|
|
14
|
+
if (typeof opts === "function") {
|
|
15
|
+
const shouldBlock = Boolean(condition ?? true);
|
|
16
|
+
const _customBlockerFn = async () => {
|
|
17
|
+
if (shouldBlock) return await opts();
|
|
18
|
+
return false;
|
|
19
|
+
};
|
|
20
|
+
return {
|
|
21
|
+
shouldBlockFn: _customBlockerFn,
|
|
22
|
+
enableBeforeUnload: shouldBlock,
|
|
23
|
+
withResolver: false
|
|
24
|
+
};
|
|
25
|
+
}
|
|
26
|
+
const shouldBlock = Boolean(opts.condition ?? true);
|
|
27
|
+
const fn = opts.blockerFn;
|
|
28
|
+
const _customBlockerFn = async () => {
|
|
29
|
+
if (shouldBlock && fn !== void 0) return await fn();
|
|
30
|
+
return shouldBlock;
|
|
31
|
+
};
|
|
32
|
+
return {
|
|
33
|
+
shouldBlockFn: _customBlockerFn,
|
|
34
|
+
enableBeforeUnload: shouldBlock,
|
|
35
|
+
withResolver: fn === void 0
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
function useBlocker(opts, condition) {
|
|
39
|
+
const { shouldBlockFn, enableBeforeUnload = true, disabled = false, withResolver = false } = _resolveBlockerOpts(opts, condition);
|
|
40
|
+
const router = useRouter();
|
|
41
|
+
const { history } = router;
|
|
42
|
+
const [resolver, setResolver] = import_react.useState({
|
|
43
|
+
status: "idle",
|
|
44
|
+
current: void 0,
|
|
45
|
+
next: void 0,
|
|
46
|
+
action: void 0,
|
|
47
|
+
proceed: void 0,
|
|
48
|
+
reset: void 0
|
|
49
|
+
});
|
|
50
|
+
import_react.useEffect(() => {
|
|
51
|
+
const blockerFnComposed = async (blockerFnArgs) => {
|
|
52
|
+
function getLocation(location) {
|
|
53
|
+
const parsedLocation = router.parseLocation(location);
|
|
54
|
+
const [, rawParams, foundRoute] = router.getMatchedRoutes(parsedLocation.pathname);
|
|
55
|
+
if (foundRoute === void 0) return {
|
|
56
|
+
routeId: "__notFound__",
|
|
57
|
+
fullPath: parsedLocation.pathname,
|
|
58
|
+
pathname: parsedLocation.pathname,
|
|
59
|
+
params: rawParams,
|
|
60
|
+
search: router.options.parseSearch(location.search)
|
|
61
|
+
};
|
|
62
|
+
return {
|
|
63
|
+
routeId: foundRoute.id,
|
|
64
|
+
fullPath: foundRoute.fullPath,
|
|
65
|
+
pathname: parsedLocation.pathname,
|
|
66
|
+
params: rawParams,
|
|
67
|
+
search: router.options.parseSearch(location.search)
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
const current = getLocation(blockerFnArgs.currentLocation);
|
|
71
|
+
const next = getLocation(blockerFnArgs.nextLocation);
|
|
72
|
+
if (current.routeId === "__notFound__" && next.routeId !== "__notFound__") return false;
|
|
73
|
+
const shouldBlock = await shouldBlockFn({
|
|
74
|
+
action: blockerFnArgs.action,
|
|
75
|
+
current,
|
|
76
|
+
next
|
|
77
|
+
});
|
|
78
|
+
if (!withResolver) return shouldBlock;
|
|
79
|
+
if (!shouldBlock) return false;
|
|
80
|
+
const canNavigateAsync = await new Promise((resolve) => {
|
|
81
|
+
setResolver({
|
|
82
|
+
status: "blocked",
|
|
83
|
+
current,
|
|
84
|
+
next,
|
|
85
|
+
action: blockerFnArgs.action,
|
|
86
|
+
proceed: () => resolve(false),
|
|
87
|
+
reset: () => resolve(true)
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
setResolver({
|
|
91
|
+
status: "idle",
|
|
92
|
+
current: void 0,
|
|
93
|
+
next: void 0,
|
|
94
|
+
action: void 0,
|
|
95
|
+
proceed: void 0,
|
|
96
|
+
reset: void 0
|
|
97
|
+
});
|
|
98
|
+
return canNavigateAsync;
|
|
99
|
+
};
|
|
100
|
+
return disabled ? void 0 : history.block({
|
|
101
|
+
blockerFn: blockerFnComposed,
|
|
102
|
+
enableBeforeUnload
|
|
103
|
+
});
|
|
104
|
+
}, [
|
|
105
|
+
shouldBlockFn,
|
|
106
|
+
enableBeforeUnload,
|
|
107
|
+
disabled,
|
|
108
|
+
withResolver,
|
|
109
|
+
history,
|
|
110
|
+
router
|
|
111
|
+
]);
|
|
112
|
+
return resolver;
|
|
113
|
+
}
|
|
114
|
+
// src/views/vault/vault-file.tsx
|
|
115
|
+
var import_jsx_runtime = require_jsx_runtime();
|
|
116
|
+
var eventsUrl = (companion, path) => `/api/vault/events?${new URLSearchParams({
|
|
117
|
+
companion,
|
|
118
|
+
path
|
|
119
|
+
})}`;
|
|
120
|
+
/** Follows the open file on disk for as long as it is shown. */
|
|
121
|
+
function useFileEvents(companion, path, onEvent) {
|
|
122
|
+
const handler = (0, import_react.useRef)(onEvent);
|
|
123
|
+
(0, import_react.useEffect)(() => {
|
|
124
|
+
handler.current = onEvent;
|
|
125
|
+
});
|
|
126
|
+
(0, import_react.useEffect)(() => {
|
|
127
|
+
if (typeof EventSource === "undefined") return;
|
|
128
|
+
const source = new EventSource(eventsUrl(companion, path));
|
|
129
|
+
source.onmessage = (message) => {
|
|
130
|
+
try {
|
|
131
|
+
handler.current(JSON.parse(message.data));
|
|
132
|
+
} catch {}
|
|
133
|
+
};
|
|
134
|
+
return () => source.close();
|
|
135
|
+
}, [companion, path]);
|
|
136
|
+
}
|
|
137
|
+
/** The document column's toolbar: where the file is, then its controls. Stays in view. */
|
|
138
|
+
function VaultToolbar({ crumbs, children }) {
|
|
139
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
140
|
+
className: "vault-bar sticky top-0 z-2 flex min-h-[52px] items-center gap-2 border-b border-rule-soft bg-[color-mix(in_srgb,var(--bg)_88%,transparent)] px-6 py-2 backdrop-blur-md max-sm:px-3",
|
|
141
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
142
|
+
className: "mr-auto flex min-w-0 items-center gap-1",
|
|
143
|
+
children: crumbs
|
|
144
|
+
}), children]
|
|
145
|
+
});
|
|
146
|
+
}
|
|
147
|
+
/** The centred reading column of a rendered file. */
|
|
148
|
+
var PROSE = "vault-prose prose mx-auto w-full max-w-[68ch] px-10 pt-10 pb-28 max-sm:px-4";
|
|
149
|
+
var MODE_LINK = buttonVariants({
|
|
150
|
+
variant: "default",
|
|
151
|
+
size: "sm"
|
|
152
|
+
});
|
|
153
|
+
function CopyPath({ path }) {
|
|
154
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("button", {
|
|
155
|
+
type: "button",
|
|
156
|
+
className: buttonVariants({
|
|
157
|
+
variant: "ghost",
|
|
158
|
+
size: "sm"
|
|
159
|
+
}),
|
|
160
|
+
"data-copy": path,
|
|
161
|
+
"data-copy-label": "path",
|
|
162
|
+
"aria-label": "Copy path",
|
|
163
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
164
|
+
name: "copy",
|
|
165
|
+
className: "size-3.5"
|
|
166
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
167
|
+
className: "@max-[1000px]:hidden",
|
|
168
|
+
children: "Copy path"
|
|
169
|
+
})]
|
|
170
|
+
});
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* An open file, read rendered or edited raw. Without the write path a file is only ever read,
|
|
174
|
+
* whatever the address names. Saving returns to read; leaving edit with unsaved text asks.
|
|
175
|
+
*/
|
|
176
|
+
function VaultFile({ companion, data, writable, search, crumbs }) {
|
|
177
|
+
const open = data.open;
|
|
178
|
+
if (!open) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(VaultToolbar, { crumbs }), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
179
|
+
className: PROSE,
|
|
180
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
|
|
181
|
+
className: "text-xl",
|
|
182
|
+
children: data.refusal ? "File refused" : "Open a markdown file"
|
|
183
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
184
|
+
className: data.refusal ? "vault-warning text-warn" : "empty text-muted",
|
|
185
|
+
children: data.refusal ?? "Choose a file from the tree to begin."
|
|
186
|
+
})]
|
|
187
|
+
})] });
|
|
188
|
+
return writable && search.mode === "edit" ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Editor, {
|
|
189
|
+
companion,
|
|
190
|
+
data,
|
|
191
|
+
crumbs
|
|
192
|
+
}, `${open.path}:edit`) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Reader, {
|
|
193
|
+
companion,
|
|
194
|
+
data,
|
|
195
|
+
writable,
|
|
196
|
+
crumbs
|
|
197
|
+
}, `${open.path}:read`);
|
|
198
|
+
}
|
|
199
|
+
var fileName = (path) => path.split("/").at(-1) ?? path;
|
|
200
|
+
/** Rendered; a change on disk shows at once, a removal is stated. */
|
|
201
|
+
function Reader({ companion, data, writable, crumbs }) {
|
|
202
|
+
const open = data.open;
|
|
203
|
+
const queryClient = useQueryClient();
|
|
204
|
+
const [status, setStatus] = (0, import_react.useState)("");
|
|
205
|
+
useFileEvents(companion, open.path, (event) => {
|
|
206
|
+
if (event.kind === "removed") setStatus("this file no longer exists on disk");
|
|
207
|
+
else afterVaultFileChange(queryClient, companion);
|
|
208
|
+
});
|
|
209
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
210
|
+
"data-vault-root": true,
|
|
211
|
+
"data-vault-mode": "read",
|
|
212
|
+
"data-vault-path": open.path,
|
|
213
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(VaultToolbar, {
|
|
214
|
+
crumbs,
|
|
215
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(CopyPath, { path: open.path }), writable ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
|
|
216
|
+
className: MODE_LINK,
|
|
217
|
+
id: "vault-mode-edit",
|
|
218
|
+
to: "/vault",
|
|
219
|
+
search: (previous) => ({
|
|
220
|
+
...previous,
|
|
221
|
+
mode: "edit"
|
|
222
|
+
}),
|
|
223
|
+
"data-vault-mode-link": true,
|
|
224
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
225
|
+
name: "pencil",
|
|
226
|
+
className: "size-3.5"
|
|
227
|
+
}), "Edit"]
|
|
228
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
229
|
+
className: "text-xs text-muted",
|
|
230
|
+
title: "Start Studio with --writable to edit.",
|
|
231
|
+
children: "Read only"
|
|
232
|
+
})]
|
|
233
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("article", {
|
|
234
|
+
className: PROSE,
|
|
235
|
+
"aria-label": fileName(open.path),
|
|
236
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownView, { nodes: open.markdown }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
237
|
+
id: "vault-status",
|
|
238
|
+
className: "text-sm text-warn",
|
|
239
|
+
"aria-live": "polite",
|
|
240
|
+
children: status
|
|
241
|
+
})]
|
|
242
|
+
})]
|
|
243
|
+
});
|
|
244
|
+
}
|
|
245
|
+
/**
|
|
246
|
+
* The editor's text rendered as it would be saved, a moment after typing stops. Unchanged text
|
|
247
|
+
* reuses the opened file's rendering; a preview hidden by a narrow window asks for nothing.
|
|
248
|
+
*/
|
|
249
|
+
function Preview({ companion, open, text }) {
|
|
250
|
+
const [settled, setSettled] = (0, import_react.useState)(text);
|
|
251
|
+
(0, import_react.useEffect)(() => {
|
|
252
|
+
const timer = setTimeout(() => setSettled(text), 250);
|
|
253
|
+
return () => clearTimeout(timer);
|
|
254
|
+
}, [text]);
|
|
255
|
+
const shown = useMediaQuery("(min-width: 64rem)");
|
|
256
|
+
const unchanged = settled === open.content;
|
|
257
|
+
const preview = useQuery({
|
|
258
|
+
queryKey: [
|
|
259
|
+
"vault-preview",
|
|
260
|
+
companion,
|
|
261
|
+
open.path,
|
|
262
|
+
settled
|
|
263
|
+
],
|
|
264
|
+
queryFn: () => previewVaultFile({ data: {
|
|
265
|
+
companion,
|
|
266
|
+
path: open.path,
|
|
267
|
+
content: settled
|
|
268
|
+
} }),
|
|
269
|
+
placeholderData: (previous) => previous,
|
|
270
|
+
enabled: shown && !unchanged,
|
|
271
|
+
gcTime: 0
|
|
272
|
+
});
|
|
273
|
+
const nodes = unchanged ? open.markdown : preview.data;
|
|
274
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
275
|
+
className: "vault-preview min-h-0 overflow-auto max-lg:hidden",
|
|
276
|
+
"aria-label": "Preview",
|
|
277
|
+
role: "region",
|
|
278
|
+
"data-vault-preview": true,
|
|
279
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
280
|
+
className: "m-0 px-7 pt-3 text-xs font-semibold text-muted",
|
|
281
|
+
children: "Preview"
|
|
282
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
283
|
+
className: "prose px-7 pt-2 pb-16 text-sm",
|
|
284
|
+
children: nodes ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(MarkdownView, { nodes }) : null
|
|
285
|
+
})]
|
|
286
|
+
});
|
|
287
|
+
}
|
|
288
|
+
/** The raw editor with an explicit save; unsaved text is never replaced by a version from disk. */
|
|
289
|
+
function Editor({ companion, data, crumbs }) {
|
|
290
|
+
const open = data.open;
|
|
291
|
+
const queryClient = useQueryClient();
|
|
292
|
+
const navigate = useNavigate();
|
|
293
|
+
const [text, setText] = (0, import_react.useState)(open.content);
|
|
294
|
+
const [original, setOriginal] = (0, import_react.useState)(open.content);
|
|
295
|
+
const [token, setToken] = (0, import_react.useState)(open.token);
|
|
296
|
+
const [status, setStatus] = (0, import_react.useState)("");
|
|
297
|
+
const [incoming, setIncoming] = (0, import_react.useState)(null);
|
|
298
|
+
const dirty = text !== original;
|
|
299
|
+
const unsaved = (0, import_react.useRef)(dirty);
|
|
300
|
+
(0, import_react.useEffect)(() => {
|
|
301
|
+
unsaved.current = dirty;
|
|
302
|
+
}, [dirty]);
|
|
303
|
+
const setDirty = useVaultUi((state) => state.setDirty);
|
|
304
|
+
(0, import_react.useEffect)(() => setDirty(dirty), [dirty, setDirty]);
|
|
305
|
+
(0, import_react.useEffect)(() => () => setDirty(false), [setDirty]);
|
|
306
|
+
useBlocker({
|
|
307
|
+
shouldBlockFn: () => unsaved.current && !window.confirm("Discard unsaved changes?"),
|
|
308
|
+
enableBeforeUnload: () => unsaved.current
|
|
309
|
+
});
|
|
310
|
+
useFileEvents(companion, open.path, (event) => {
|
|
311
|
+
if (event.kind === "removed") {
|
|
312
|
+
setStatus("this file no longer exists on disk");
|
|
313
|
+
return;
|
|
314
|
+
}
|
|
315
|
+
const version = {
|
|
316
|
+
content: event.content ?? "",
|
|
317
|
+
token: event.token ?? ""
|
|
318
|
+
};
|
|
319
|
+
if (event.kind === "overwritten") {
|
|
320
|
+
setIncoming(version);
|
|
321
|
+
setStatus("a version was overwritten; its content is available below");
|
|
322
|
+
} else if (dirty) {
|
|
323
|
+
setIncoming(version);
|
|
324
|
+
setStatus("the file changed on disk; unsaved content is still in the editor");
|
|
325
|
+
} else {
|
|
326
|
+
setText(version.content);
|
|
327
|
+
setOriginal(version.content);
|
|
328
|
+
setToken(version.token);
|
|
329
|
+
setStatus("updated from disk");
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
const save = useMutation({
|
|
333
|
+
mutationFn: () => saveVaultFile({ data: {
|
|
334
|
+
companion,
|
|
335
|
+
path: open.path,
|
|
336
|
+
content: text,
|
|
337
|
+
token
|
|
338
|
+
} }),
|
|
339
|
+
onSuccess: (result) => {
|
|
340
|
+
if (result.kind === "conflict") {
|
|
341
|
+
setIncoming({
|
|
342
|
+
content: result.content,
|
|
343
|
+
token: result.token
|
|
344
|
+
});
|
|
345
|
+
setStatus(result.reason || "save refused");
|
|
346
|
+
return;
|
|
347
|
+
}
|
|
348
|
+
setToken(result.token);
|
|
349
|
+
setOriginal(text);
|
|
350
|
+
unsaved.current = false;
|
|
351
|
+
setDirty(false);
|
|
352
|
+
setStatus("saved");
|
|
353
|
+
afterVaultFileChange(queryClient, companion);
|
|
354
|
+
navigate({
|
|
355
|
+
to: "/vault",
|
|
356
|
+
search: (previous) => ({
|
|
357
|
+
...previous,
|
|
358
|
+
mode: void 0
|
|
359
|
+
}),
|
|
360
|
+
resetScroll: false
|
|
361
|
+
});
|
|
362
|
+
},
|
|
363
|
+
onError: (error) => setStatus(error.message || "save failed")
|
|
364
|
+
});
|
|
365
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
366
|
+
className: "flex h-full min-h-0 flex-col",
|
|
367
|
+
"data-vault-root": true,
|
|
368
|
+
"data-vault-mode": "edit",
|
|
369
|
+
"data-vault-path": open.path,
|
|
370
|
+
children: [
|
|
371
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(VaultToolbar, {
|
|
372
|
+
crumbs,
|
|
373
|
+
children: [
|
|
374
|
+
dirty ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("span", {
|
|
375
|
+
className: "inline-flex items-center gap-1.5 text-xs text-warn",
|
|
376
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
377
|
+
className: "size-[7px] rounded-full bg-current",
|
|
378
|
+
"aria-hidden": "true"
|
|
379
|
+
}), "Unsaved"]
|
|
380
|
+
}) : null,
|
|
381
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
|
|
382
|
+
className: MODE_LINK,
|
|
383
|
+
id: "vault-mode-read",
|
|
384
|
+
to: "/vault",
|
|
385
|
+
search: (previous) => ({
|
|
386
|
+
...previous,
|
|
387
|
+
mode: void 0
|
|
388
|
+
}),
|
|
389
|
+
"data-vault-mode-link": true,
|
|
390
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
391
|
+
name: "eye",
|
|
392
|
+
className: "size-3.5"
|
|
393
|
+
}), "Read"]
|
|
394
|
+
}),
|
|
395
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
396
|
+
variant: "primary",
|
|
397
|
+
size: "sm",
|
|
398
|
+
id: "vault-save",
|
|
399
|
+
onClick: () => save.mutate(),
|
|
400
|
+
disabled: save.isPending,
|
|
401
|
+
children: "Save"
|
|
402
|
+
})
|
|
403
|
+
]
|
|
404
|
+
}),
|
|
405
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
406
|
+
className: status || incoming ? "grid gap-2 border-b border-rule-soft px-6 py-2.5 text-sm" : "sr-only",
|
|
407
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
408
|
+
id: "vault-status",
|
|
409
|
+
className: "m-0 text-warn",
|
|
410
|
+
"aria-live": "polite",
|
|
411
|
+
children: status
|
|
412
|
+
}), incoming ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
413
|
+
id: "vault-incoming",
|
|
414
|
+
className: "grid gap-2",
|
|
415
|
+
children: [
|
|
416
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
|
|
417
|
+
id: "vault-incoming-title",
|
|
418
|
+
className: "text-sm",
|
|
419
|
+
children: "Incoming version"
|
|
420
|
+
}),
|
|
421
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("pre", {
|
|
422
|
+
id: "vault-incoming-content",
|
|
423
|
+
className: "m-0 max-h-40 overflow-auto rounded-control border border-rule bg-surface p-3 font-mono text-xs whitespace-pre-wrap",
|
|
424
|
+
children: incoming.content
|
|
425
|
+
}),
|
|
426
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
427
|
+
size: "sm",
|
|
428
|
+
id: "vault-recover",
|
|
429
|
+
className: "justify-self-start",
|
|
430
|
+
onClick: () => {
|
|
431
|
+
setText(incoming.content);
|
|
432
|
+
setOriginal(incoming.content);
|
|
433
|
+
if (incoming.token) setToken(incoming.token);
|
|
434
|
+
setIncoming(null);
|
|
435
|
+
setStatus("incoming version loaded into the editor");
|
|
436
|
+
},
|
|
437
|
+
children: "Put incoming content back"
|
|
438
|
+
})
|
|
439
|
+
]
|
|
440
|
+
}) : null]
|
|
441
|
+
}),
|
|
442
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
443
|
+
className: "grid min-h-0 flex-1 grid-cols-2 max-lg:grid-cols-1",
|
|
444
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", {
|
|
445
|
+
id: "vault-editor",
|
|
446
|
+
"data-vault-editor": true,
|
|
447
|
+
"data-vault-path": open.path,
|
|
448
|
+
"aria-label": `Markdown source of ${fileName(open.path)}`,
|
|
449
|
+
spellCheck: false,
|
|
450
|
+
value: text,
|
|
451
|
+
onChange: (event) => setText(event.target.value),
|
|
452
|
+
className: cn("min-h-[60vh] resize-none border-0 border-r border-rule-soft bg-transparent px-6 pt-4 pb-10 font-mono text-[0.86rem] leading-[1.75] text-text outline-none focus-visible:outline-none max-lg:border-r-0")
|
|
453
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Preview, {
|
|
454
|
+
companion,
|
|
455
|
+
open,
|
|
456
|
+
text
|
|
457
|
+
})]
|
|
458
|
+
})
|
|
459
|
+
]
|
|
460
|
+
});
|
|
461
|
+
}
|
|
462
|
+
// src/views/vault/vault-view.tsx
|
|
463
|
+
var segments = (relative) => relative.split("/").filter(Boolean);
|
|
464
|
+
var TREE_ROW = "flex w-full min-w-0 items-center gap-2 rounded-[6px] border-0 bg-transparent px-2.5 py-1.5 text-left text-sm text-text no-underline hover:bg-surface aria-[current=page]:bg-accent-soft aria-[current=page]:font-semibold";
|
|
465
|
+
/** A file entry is a link to the file's address; it opens in read. */
|
|
466
|
+
function FileLink({ entry, current, label }) {
|
|
467
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
|
|
468
|
+
to: "/vault",
|
|
469
|
+
search: (previous) => ({
|
|
470
|
+
...previous,
|
|
471
|
+
path: entry.path,
|
|
472
|
+
dir: void 0,
|
|
473
|
+
mode: void 0
|
|
474
|
+
}),
|
|
475
|
+
className: cn(TREE_ROW, "vault-file"),
|
|
476
|
+
"data-vault-entry": entry.path,
|
|
477
|
+
"aria-current": current ? "page" : void 0,
|
|
478
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
479
|
+
name: "doc",
|
|
480
|
+
className: cn("size-3.5", current ? "text-accent" : "text-muted")
|
|
481
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
482
|
+
className: "min-w-0 flex-1 truncate",
|
|
483
|
+
children: label ?? entry.name
|
|
484
|
+
})]
|
|
485
|
+
});
|
|
486
|
+
}
|
|
487
|
+
/** Opens a folder's listing; a breadcrumb step or a listing row. */
|
|
488
|
+
function FolderLink({ dir, className, children }) {
|
|
489
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Link, {
|
|
490
|
+
to: "/vault",
|
|
491
|
+
search: (previous) => ({
|
|
492
|
+
...previous,
|
|
493
|
+
path: void 0,
|
|
494
|
+
dir: dir ?? void 0,
|
|
495
|
+
mode: void 0
|
|
496
|
+
}),
|
|
497
|
+
className,
|
|
498
|
+
children
|
|
499
|
+
});
|
|
500
|
+
}
|
|
501
|
+
function TreeEntry({ entry, companion, search }) {
|
|
502
|
+
if (entry.kind === "file") return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileLink, {
|
|
503
|
+
entry,
|
|
504
|
+
current: search.path === entry.path
|
|
505
|
+
});
|
|
506
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeFolder, {
|
|
507
|
+
entry,
|
|
508
|
+
companion,
|
|
509
|
+
search
|
|
510
|
+
});
|
|
511
|
+
}
|
|
512
|
+
/** Collapsed unless on the open path; a collapsed folder asks for its entries when first opened. */
|
|
513
|
+
function TreeFolder({ entry, companion, search }) {
|
|
514
|
+
const [open, setOpen] = (0, import_react.useState)(entry.children !== void 0);
|
|
515
|
+
const children = useQuery({
|
|
516
|
+
...vaultChildrenQuery(companion, entry.path),
|
|
517
|
+
enabled: open && entry.children === void 0
|
|
518
|
+
});
|
|
519
|
+
const entries = entry.children ?? children.data?.entries;
|
|
520
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("details", {
|
|
521
|
+
className: "vault-directory group/dir",
|
|
522
|
+
open,
|
|
523
|
+
"data-vault-dir": entry.path,
|
|
524
|
+
onToggle: (event) => setOpen(event.currentTarget.open),
|
|
525
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("summary", {
|
|
526
|
+
className: cn(TREE_ROW, "cursor-pointer list-none font-semibold [&::-webkit-details-marker]:hidden"),
|
|
527
|
+
"aria-current": search.dir === entry.path ? "page" : void 0,
|
|
528
|
+
children: [
|
|
529
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
530
|
+
name: "right",
|
|
531
|
+
className: "size-3 text-muted transition-transform group-open/dir:rotate-90"
|
|
532
|
+
}),
|
|
533
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
534
|
+
name: "folder",
|
|
535
|
+
className: "size-3.5 text-muted"
|
|
536
|
+
}),
|
|
537
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
538
|
+
className: "min-w-0 flex-1 truncate",
|
|
539
|
+
children: entry.name
|
|
540
|
+
})
|
|
541
|
+
]
|
|
542
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
543
|
+
className: "vault-children grid gap-px pl-3.5",
|
|
544
|
+
children: [open && entries ? entries.map((child) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeEntry, {
|
|
545
|
+
entry: child,
|
|
546
|
+
companion,
|
|
547
|
+
search
|
|
548
|
+
}, child.path)) : null, children.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
549
|
+
className: "vault-warning m-0 px-2.5 py-1 text-xs text-warn",
|
|
550
|
+
children: children.error.message
|
|
551
|
+
}) : null]
|
|
552
|
+
})]
|
|
553
|
+
});
|
|
554
|
+
}
|
|
555
|
+
var NOTE = "m-0 px-2.5 py-1.5 text-sm text-muted";
|
|
556
|
+
var WARNING = "vault-warning m-0 px-2.5 py-1.5 text-xs text-warn";
|
|
557
|
+
function TreeSlot({ data, companion, search }) {
|
|
558
|
+
if (data.failure) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
559
|
+
"data-vault-slot": "tree",
|
|
560
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
561
|
+
className: WARNING,
|
|
562
|
+
children: ["The files could not be listed: ", data.failure]
|
|
563
|
+
})
|
|
564
|
+
});
|
|
565
|
+
if (data.tree === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
566
|
+
"data-vault-slot": "tree",
|
|
567
|
+
"aria-busy": "true",
|
|
568
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
569
|
+
className: cn(NOTE, "empty"),
|
|
570
|
+
children: "Listing files…"
|
|
571
|
+
})
|
|
572
|
+
});
|
|
573
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
574
|
+
"data-vault-slot": "tree",
|
|
575
|
+
"data-vault-generation": data.generation ?? void 0,
|
|
576
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeStaleNote, { data }), data.tree.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
577
|
+
className: cn(NOTE, "empty"),
|
|
578
|
+
children: "This companion has no markdown files."
|
|
579
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
|
|
580
|
+
className: "vault-tree grid gap-px",
|
|
581
|
+
"aria-label": "Markdown files",
|
|
582
|
+
children: data.tree.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeEntry, {
|
|
583
|
+
entry,
|
|
584
|
+
companion,
|
|
585
|
+
search
|
|
586
|
+
}, entry.path))
|
|
587
|
+
})]
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
function TreeStaleNote({ data }) {
|
|
591
|
+
if (data.warning) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
592
|
+
className: WARNING,
|
|
593
|
+
children: [data.warning, ". The tree may be out of date."]
|
|
594
|
+
});
|
|
595
|
+
if (data.watching) return null;
|
|
596
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
597
|
+
className: WARNING,
|
|
598
|
+
children: "The tree may be out of date."
|
|
599
|
+
});
|
|
600
|
+
}
|
|
601
|
+
/** Name matches over the whole listed tree, bounded by the server. */
|
|
602
|
+
function FilterResults({ companion, query, search }) {
|
|
603
|
+
const [settled, setSettled] = (0, import_react.useState)(query);
|
|
604
|
+
(0, import_react.useEffect)(() => {
|
|
605
|
+
const timer = setTimeout(() => setSettled(query), 150);
|
|
606
|
+
return () => clearTimeout(timer);
|
|
607
|
+
}, [query]);
|
|
608
|
+
const matches = useQuery({
|
|
609
|
+
...vaultMatchesQuery(companion, settled),
|
|
610
|
+
enabled: settled.trim().length > 0
|
|
611
|
+
});
|
|
612
|
+
if (!matches.data) return null;
|
|
613
|
+
const { shown, total } = matches.data;
|
|
614
|
+
const more = total - shown.length;
|
|
615
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
616
|
+
"data-vault-filter-results": true,
|
|
617
|
+
children: [shown.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
618
|
+
className: cn(NOTE, "empty"),
|
|
619
|
+
children: "No files match."
|
|
620
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
|
|
621
|
+
className: "vault-tree vault-results grid gap-px",
|
|
622
|
+
"aria-label": "Matching files",
|
|
623
|
+
children: shown.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FileLink, {
|
|
624
|
+
entry,
|
|
625
|
+
current: search.path === entry.path,
|
|
626
|
+
label: entry.path
|
|
627
|
+
}, entry.path))
|
|
628
|
+
}), more > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
629
|
+
className: NOTE,
|
|
630
|
+
"data-vault-more": true,
|
|
631
|
+
children: [
|
|
632
|
+
more,
|
|
633
|
+
" more match",
|
|
634
|
+
more === 1 ? "" : "es",
|
|
635
|
+
"; refine the filter."
|
|
636
|
+
]
|
|
637
|
+
}) : null]
|
|
638
|
+
});
|
|
639
|
+
}
|
|
640
|
+
var CRUMB = "vault-crumb rounded-[6px] px-1.5 py-0.5 text-sm text-muted no-underline hover:bg-surface hover:text-text";
|
|
641
|
+
/** Built from the address alone, so it shows before the tree is listed. */
|
|
642
|
+
function Breadcrumb({ rootName, search }) {
|
|
643
|
+
const parts = segments(search.path ?? search.dir ?? "");
|
|
644
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("nav", {
|
|
645
|
+
className: "vault-breadcrumb min-w-0",
|
|
646
|
+
"aria-label": "Breadcrumb",
|
|
647
|
+
"data-vault-crumb": true,
|
|
648
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ol", {
|
|
649
|
+
className: "m-0 flex min-w-0 list-none items-center gap-0.5 overflow-hidden p-0 text-sm text-muted",
|
|
650
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", {
|
|
651
|
+
className: "flex-none",
|
|
652
|
+
children: parts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
653
|
+
"aria-current": "page",
|
|
654
|
+
className: "px-1.5 font-semibold text-text",
|
|
655
|
+
children: rootName
|
|
656
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FolderLink, {
|
|
657
|
+
dir: null,
|
|
658
|
+
className: CRUMB,
|
|
659
|
+
children: rootName
|
|
660
|
+
})
|
|
661
|
+
}), parts.map((name, index) => {
|
|
662
|
+
const dir = parts.slice(0, index + 1).join("/");
|
|
663
|
+
const last = index === parts.length - 1;
|
|
664
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("li", {
|
|
665
|
+
className: cn("flex items-center gap-0.5", last ? "min-w-0" : "flex-none max-md:hidden"),
|
|
666
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
667
|
+
"aria-hidden": "true",
|
|
668
|
+
children: "/"
|
|
669
|
+
}), last ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
670
|
+
"aria-current": "page",
|
|
671
|
+
className: "truncate px-1.5 font-semibold text-text",
|
|
672
|
+
children: name
|
|
673
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FolderLink, {
|
|
674
|
+
dir,
|
|
675
|
+
className: CRUMB,
|
|
676
|
+
children: name
|
|
677
|
+
})]
|
|
678
|
+
}, dir);
|
|
679
|
+
})]
|
|
680
|
+
})
|
|
681
|
+
});
|
|
682
|
+
}
|
|
683
|
+
function findEntries(tree, dir) {
|
|
684
|
+
let level = tree;
|
|
685
|
+
for (const name of segments(dir)) {
|
|
686
|
+
const folder = level?.find((entry) => entry.kind === "directory" && entry.name === name);
|
|
687
|
+
if (!folder) return null;
|
|
688
|
+
level = folder.children;
|
|
689
|
+
}
|
|
690
|
+
return level ?? null;
|
|
691
|
+
}
|
|
692
|
+
/** With no file open: the open folder's entries as a list card, folders first. */
|
|
693
|
+
function Listing({ data, rootName }) {
|
|
694
|
+
const body = (() => {
|
|
695
|
+
if (data.failure) return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("p", {
|
|
696
|
+
className: WARNING,
|
|
697
|
+
children: ["The files could not be listed: ", data.failure]
|
|
698
|
+
});
|
|
699
|
+
if (data.tree === null) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
700
|
+
className: cn(NOTE, "empty"),
|
|
701
|
+
children: "Listing files…"
|
|
702
|
+
});
|
|
703
|
+
return null;
|
|
704
|
+
})();
|
|
705
|
+
const parts = data.dir ? segments(data.dir) : [];
|
|
706
|
+
const title = parts.at(-1) ?? rootName;
|
|
707
|
+
if (body) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
708
|
+
"data-vault-slot": "listing",
|
|
709
|
+
className: "vault-listing mx-auto w-full max-w-[820px] px-10 py-8",
|
|
710
|
+
"aria-busy": data.tree === null,
|
|
711
|
+
children: body
|
|
712
|
+
});
|
|
713
|
+
const entries = (data.dir ? findEntries(data.tree, data.dir) : null) ?? data.tree;
|
|
714
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
715
|
+
"data-vault-slot": "listing",
|
|
716
|
+
className: "vault-listing mx-auto grid w-full max-w-[820px] gap-4 px-10 py-8 max-sm:px-4",
|
|
717
|
+
children: [
|
|
718
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h1", {
|
|
719
|
+
className: "m-0 text-xl font-semibold",
|
|
720
|
+
children: title
|
|
721
|
+
}),
|
|
722
|
+
data.dirMissing ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
723
|
+
className: WARNING,
|
|
724
|
+
children: "That folder is not in the tree; showing the root."
|
|
725
|
+
}) : null,
|
|
726
|
+
entries.length === 0 && parts.length === 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
727
|
+
className: cn(NOTE, "empty"),
|
|
728
|
+
children: "This companion has no markdown files."
|
|
729
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ListCard, {
|
|
730
|
+
title: "In this folder",
|
|
731
|
+
count: entries.length,
|
|
732
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("ul", {
|
|
733
|
+
className: "vault-rows m-0 list-none p-0",
|
|
734
|
+
"aria-label": "Folder contents",
|
|
735
|
+
children: [parts.length > 0 ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FolderLink, {
|
|
736
|
+
dir: parts.length > 1 ? parts.slice(0, -1).join("/") : null,
|
|
737
|
+
className: cn(ROW, "vault-row py-1.5"),
|
|
738
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
739
|
+
name: "left",
|
|
740
|
+
className: "text-muted"
|
|
741
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: ".." })]
|
|
742
|
+
}) }) : null, entries.map((entry) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: entry.kind === "directory" ? /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(FolderLink, {
|
|
743
|
+
dir: entry.path,
|
|
744
|
+
className: cn(ROW, "vault-row py-1.5 font-semibold"),
|
|
745
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
746
|
+
name: "folder",
|
|
747
|
+
className: "text-muted"
|
|
748
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
749
|
+
className: "truncate",
|
|
750
|
+
children: entry.name
|
|
751
|
+
})]
|
|
752
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(Link, {
|
|
753
|
+
to: "/vault",
|
|
754
|
+
search: (previous) => ({
|
|
755
|
+
...previous,
|
|
756
|
+
path: entry.path,
|
|
757
|
+
dir: void 0,
|
|
758
|
+
mode: void 0
|
|
759
|
+
}),
|
|
760
|
+
className: cn(ROW, "vault-row py-1.5"),
|
|
761
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
762
|
+
name: "doc",
|
|
763
|
+
className: "text-muted"
|
|
764
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", {
|
|
765
|
+
className: "truncate",
|
|
766
|
+
children: entry.name
|
|
767
|
+
})]
|
|
768
|
+
}) }, entry.path))]
|
|
769
|
+
})
|
|
770
|
+
})
|
|
771
|
+
]
|
|
772
|
+
});
|
|
773
|
+
}
|
|
774
|
+
/** The plain text of a rendered markdown node. */
|
|
775
|
+
function textOf(node) {
|
|
776
|
+
return typeof node === "string" ? node : (node.c ?? []).map(textOf).join("");
|
|
777
|
+
}
|
|
778
|
+
/** The open file's second-level headings, in document order. */
|
|
779
|
+
function headingsOf(markdown) {
|
|
780
|
+
return (markdown ?? []).filter((node) => typeof node !== "string" && node.t === "h2").map((node, index) => ({
|
|
781
|
+
index,
|
|
782
|
+
text: textOf(node)
|
|
783
|
+
}));
|
|
784
|
+
}
|
|
785
|
+
var headingElements = (root) => [...root?.querySelectorAll("article .markdown-body h2") ?? []];
|
|
786
|
+
/** Which heading is in view, followed as the document scrolls; the first until then. */
|
|
787
|
+
function useCurrentHeading(scroller, markdown, count) {
|
|
788
|
+
const [current, setCurrent] = (0, import_react.useState)(null);
|
|
789
|
+
(0, import_react.useEffect)(() => {
|
|
790
|
+
if (!markdown) return;
|
|
791
|
+
const root = scroller.current;
|
|
792
|
+
const elements = headingElements(root);
|
|
793
|
+
if (elements.length === 0 || typeof IntersectionObserver === "undefined") return;
|
|
794
|
+
const observer = new IntersectionObserver((entries) => {
|
|
795
|
+
const visible = entries.find((entry) => entry.isIntersecting);
|
|
796
|
+
if (visible) setCurrent(elements.indexOf(visible.target));
|
|
797
|
+
}, {
|
|
798
|
+
root,
|
|
799
|
+
rootMargin: "-60px 0px -70% 0px"
|
|
800
|
+
});
|
|
801
|
+
for (const element of elements) observer.observe(element);
|
|
802
|
+
return () => observer.disconnect();
|
|
803
|
+
}, [scroller, markdown]);
|
|
804
|
+
const go = (index) => {
|
|
805
|
+
headingElements(scroller.current)[index]?.scrollIntoView({
|
|
806
|
+
behavior: "smooth",
|
|
807
|
+
block: "start"
|
|
808
|
+
});
|
|
809
|
+
setCurrent(index);
|
|
810
|
+
};
|
|
811
|
+
return {
|
|
812
|
+
current: current !== null && current < count ? current : 0,
|
|
813
|
+
go
|
|
814
|
+
};
|
|
815
|
+
}
|
|
816
|
+
function Outline({ headings, current, go }) {
|
|
817
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("nav", {
|
|
818
|
+
className: "vault-outline min-h-0 overflow-auto border-l border-rule-soft px-5 pt-[72px] pb-6 @max-[1080px]:hidden",
|
|
819
|
+
"aria-label": "Outline",
|
|
820
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("h2", {
|
|
821
|
+
className: "m-0 mb-2 text-xs font-semibold text-muted",
|
|
822
|
+
children: "On this page"
|
|
823
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("ol", {
|
|
824
|
+
className: "m-0 grid list-none gap-0.5 p-0",
|
|
825
|
+
children: headings.map((heading) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("li", { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)("button", {
|
|
826
|
+
type: "button",
|
|
827
|
+
className: cn("block w-full truncate rounded-r-[8px] border-0 bg-transparent px-2.5 py-1 text-left text-sm text-text hover:bg-surface", current === heading.index && "font-semibold text-accent shadow-[inset_2px_0_0_var(--accent)]"),
|
|
828
|
+
"aria-current": current === heading.index ? "location" : void 0,
|
|
829
|
+
onClick: () => go(heading.index),
|
|
830
|
+
children: heading.text
|
|
831
|
+
}) }, heading.index))
|
|
832
|
+
})]
|
|
833
|
+
});
|
|
834
|
+
}
|
|
835
|
+
var NO_HEADINGS = [];
|
|
836
|
+
var columns = (tree, outline) => [
|
|
837
|
+
tree ? "272px" : null,
|
|
838
|
+
"minmax(0,1fr)",
|
|
839
|
+
outline ? "232px" : null
|
|
840
|
+
].filter(Boolean).join(" ");
|
|
841
|
+
/** The tree column: refresh, the stale notice, the name filter and the tree or its matches. */
|
|
842
|
+
function FilesPanel({ data, companion, search, stale, refresh, filter, setFilter, hidden }) {
|
|
843
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("aside", {
|
|
844
|
+
hidden,
|
|
845
|
+
className: "vault-tree-panel flex min-h-0 flex-col border-r border-rule @max-[720px]:max-h-[40vh] @max-[720px]:border-r-0 @max-[720px]:border-b",
|
|
846
|
+
id: "vault-tree-panel",
|
|
847
|
+
"aria-label": "Files",
|
|
848
|
+
children: [
|
|
849
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", {
|
|
850
|
+
className: "flex items-center justify-between pt-3 pr-2.5 pb-2 pl-5",
|
|
851
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)("strong", {
|
|
852
|
+
className: "text-sm",
|
|
853
|
+
children: "Files"
|
|
854
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
|
|
855
|
+
label: "Refresh tree",
|
|
856
|
+
side: "bottom",
|
|
857
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
858
|
+
size: "icon-sm",
|
|
859
|
+
variant: "ghost",
|
|
860
|
+
"aria-label": refresh.isPending ? "Refreshing…" : "Refresh tree",
|
|
861
|
+
onClick: () => refresh.mutate(),
|
|
862
|
+
disabled: refresh.isPending,
|
|
863
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
864
|
+
name: "refresh",
|
|
865
|
+
className: refresh.isPending ? "animate-spin" : void 0
|
|
866
|
+
})
|
|
867
|
+
})
|
|
868
|
+
})]
|
|
869
|
+
}),
|
|
870
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
871
|
+
id: "vault-stale",
|
|
872
|
+
className: WARNING + " mx-2.5",
|
|
873
|
+
role: "status",
|
|
874
|
+
hidden: !stale,
|
|
875
|
+
children: "Files changed — refresh tree."
|
|
876
|
+
}),
|
|
877
|
+
refresh.error ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("p", {
|
|
878
|
+
className: WARNING + " mx-2.5",
|
|
879
|
+
role: "status",
|
|
880
|
+
children: refresh.error.message
|
|
881
|
+
}) : null,
|
|
882
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", {
|
|
883
|
+
className: "mx-3.5 mb-2 flex h-[34px] items-center gap-2 rounded-control border border-rule bg-surface pr-2 pl-2.5 text-muted focus-within:border-accent",
|
|
884
|
+
children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, {
|
|
885
|
+
name: "search",
|
|
886
|
+
className: "size-3.5"
|
|
887
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", {
|
|
888
|
+
type: "search",
|
|
889
|
+
id: "vault-filter",
|
|
890
|
+
className: "vault-filter min-w-0 flex-1 border-0 bg-transparent text-sm text-text outline-none placeholder:text-muted",
|
|
891
|
+
placeholder: "Go to file",
|
|
892
|
+
"aria-label": "Go to file",
|
|
893
|
+
value: filter,
|
|
894
|
+
onChange: (event) => setFilter(event.target.value),
|
|
895
|
+
onKeyDown: (event) => {
|
|
896
|
+
if (event.key === "Escape") setFilter("");
|
|
897
|
+
}
|
|
898
|
+
})]
|
|
899
|
+
}),
|
|
900
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
901
|
+
className: "min-h-0 flex-1 overflow-auto px-2.5 pb-6",
|
|
902
|
+
children: filter.trim() ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilterResults, {
|
|
903
|
+
companion,
|
|
904
|
+
query: filter,
|
|
905
|
+
search
|
|
906
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)(TreeSlot, {
|
|
907
|
+
data,
|
|
908
|
+
companion,
|
|
909
|
+
search
|
|
910
|
+
})
|
|
911
|
+
})
|
|
912
|
+
]
|
|
913
|
+
});
|
|
914
|
+
}
|
|
915
|
+
/**
|
|
916
|
+
* The vault: a full-height workspace of tree, document and outline, each scrolling on its own.
|
|
917
|
+
* The tree holds only the top level and the open path; it fills in when it was not listed yet.
|
|
918
|
+
*/
|
|
919
|
+
function VaultLayout({ companion, rootName, writable, search }) {
|
|
920
|
+
const queryClient = useQueryClient();
|
|
921
|
+
const view = useQuery(vaultQuery(companion, search));
|
|
922
|
+
const data = useQuery({
|
|
923
|
+
...vaultQuery(companion, search, true),
|
|
924
|
+
enabled: Boolean(view.data && view.data.tree === null && !view.data.failure)
|
|
925
|
+
}).data ?? view.data;
|
|
926
|
+
const [filter, setFilter] = (0, import_react.useState)("");
|
|
927
|
+
const latest = useVaultUi((state) => state.latestGeneration);
|
|
928
|
+
const treeHidden = useVaultUi((state) => state.treeHidden);
|
|
929
|
+
const toggleTree = useVaultUi((state) => state.toggleTree);
|
|
930
|
+
const hydrate = useVaultUi((state) => state.hydrate);
|
|
931
|
+
(0, import_react.useEffect)(hydrate, [hydrate]);
|
|
932
|
+
const refresh = useMutation({
|
|
933
|
+
mutationFn: () => getVault({ data: {
|
|
934
|
+
companion,
|
|
935
|
+
path: search.path,
|
|
936
|
+
dir: search.dir,
|
|
937
|
+
refresh: true,
|
|
938
|
+
wait: true
|
|
939
|
+
} }),
|
|
940
|
+
onSuccess: (fresh) => void afterVaultRefresh(queryClient, companion, search, fresh)
|
|
941
|
+
});
|
|
942
|
+
const scroller = (0, import_react.useRef)(null);
|
|
943
|
+
const reading = Boolean(data?.open) && search.mode !== "edit";
|
|
944
|
+
const headings = reading ? headingsOf(data?.open?.markdown) : NO_HEADINGS;
|
|
945
|
+
const outline = useCurrentHeading(scroller, reading ? data?.open?.markdown : void 0, headings.length);
|
|
946
|
+
if (!data) return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(ViewPlaceholder, {});
|
|
947
|
+
const stale = latest !== null && data.generation !== null && latest > data.generation;
|
|
948
|
+
const showOutline = headings.length > 0;
|
|
949
|
+
const crumbs = /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(Tooltip, {
|
|
950
|
+
label: treeHidden ? "Show files" : "Hide files",
|
|
951
|
+
side: "bottom",
|
|
952
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Button, {
|
|
953
|
+
size: "icon-sm",
|
|
954
|
+
variant: "ghost",
|
|
955
|
+
id: "vault-tree-toggle",
|
|
956
|
+
"aria-controls": "vault-tree-panel",
|
|
957
|
+
"aria-expanded": !treeHidden,
|
|
958
|
+
"aria-label": treeHidden ? "Show files" : "Hide files",
|
|
959
|
+
onClick: toggleTree,
|
|
960
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Icon, { name: "sidebar" })
|
|
961
|
+
})
|
|
962
|
+
}), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Breadcrumb, {
|
|
963
|
+
rootName,
|
|
964
|
+
search
|
|
965
|
+
})] });
|
|
966
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
967
|
+
className: "@container flex min-h-0 flex-1 flex-col",
|
|
968
|
+
children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("section", {
|
|
969
|
+
className: "vault-layout grid min-h-0 flex-1 border-t border-rule @max-[720px]:grid-cols-1!",
|
|
970
|
+
style: {
|
|
971
|
+
"--vault-wide": columns(true, showOutline),
|
|
972
|
+
"--vault-wide-bare": columns(false, showOutline),
|
|
973
|
+
"--vault-narrow": columns(true, false),
|
|
974
|
+
"--vault-narrow-bare": columns(false, false)
|
|
975
|
+
},
|
|
976
|
+
"data-vault-layout": true,
|
|
977
|
+
children: [
|
|
978
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(FilesPanel, {
|
|
979
|
+
data,
|
|
980
|
+
companion,
|
|
981
|
+
search,
|
|
982
|
+
stale,
|
|
983
|
+
refresh,
|
|
984
|
+
filter,
|
|
985
|
+
setFilter,
|
|
986
|
+
hidden: treeHidden
|
|
987
|
+
}),
|
|
988
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("div", {
|
|
989
|
+
ref: scroller,
|
|
990
|
+
className: "vault-main min-h-0 min-w-0 overflow-auto scroll-smooth",
|
|
991
|
+
"data-vault-main": true,
|
|
992
|
+
"data-vault-pane": true,
|
|
993
|
+
children: search.path || data.open || data.refusal ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VaultFile, {
|
|
994
|
+
companion,
|
|
995
|
+
data,
|
|
996
|
+
writable,
|
|
997
|
+
search,
|
|
998
|
+
crumbs
|
|
999
|
+
}) : /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_jsx_runtime.Fragment, { children: [/* @__PURE__ */ (0, import_jsx_runtime.jsx)(VaultToolbar, { crumbs }), /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Listing, {
|
|
1000
|
+
data,
|
|
1001
|
+
rootName
|
|
1002
|
+
})] })
|
|
1003
|
+
}),
|
|
1004
|
+
showOutline ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)(Outline, {
|
|
1005
|
+
headings,
|
|
1006
|
+
...outline
|
|
1007
|
+
}) : null
|
|
1008
|
+
]
|
|
1009
|
+
})
|
|
1010
|
+
});
|
|
1011
|
+
}
|
|
1012
|
+
// src/routes/vault.tsx?tsr-split=component
|
|
1013
|
+
function VaultRoute() {
|
|
1014
|
+
const search = Route.useSearch();
|
|
1015
|
+
const { data: shell } = useSuspenseQuery(shellQuery({
|
|
1016
|
+
companion: search.companion,
|
|
1017
|
+
studioMode: search.studioMode
|
|
1018
|
+
}));
|
|
1019
|
+
if (!search.companion || !shell.selected) return null;
|
|
1020
|
+
const rootName = shell.selected.path.split(/[\\/]/).findLast(Boolean) ?? "companion";
|
|
1021
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(VaultLayout, {
|
|
1022
|
+
companion: search.companion,
|
|
1023
|
+
rootName,
|
|
1024
|
+
writable: shell.writable,
|
|
1025
|
+
search: {
|
|
1026
|
+
path: search.path,
|
|
1027
|
+
dir: search.dir,
|
|
1028
|
+
mode: search.mode
|
|
1029
|
+
}
|
|
1030
|
+
});
|
|
1031
|
+
}
|
|
1032
|
+
export { VaultRoute as component };
|