@mcp-b/react-components 0.69.0 → 0.71.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/AgentComputer-CpS9R2KG.d.ts +305 -0
- package/dist/{AgentComputer-CFJxjMFE.js → AgentComputer-DZCyQkcE.js} +1850 -478
- package/dist/CommandPalette-DDctKdpC.d.ts +53 -0
- package/dist/ComputerCalendar-Ci7tLASe.js +1360 -0
- package/dist/ComputerCustomWallpaper-CnGQYHp0.js +518 -0
- package/dist/ComputerCustomWallpaper-D4lgwj2k.d.ts +18 -0
- package/dist/ComputerNotifications-q7eeELZ8.d.ts +41 -0
- package/dist/ComputerPresentation-BEQKYAjc.js +888 -0
- package/dist/Context-CYUxZrwW.js +918 -0
- package/dist/{ExecutionResult-C7SzVquo.js → ExecutionResult-CXnGcmM4.js} +1 -1
- package/dist/{WorkspaceBrowser-ojoZy0uO.js → WorkspaceBrowser-mRScUczT.js} +5 -5
- package/dist/WorkspaceFileTransfer-D2cOoVyO.js +1625 -0
- package/dist/{WorkspaceMessageResponse-BoeeltJM.js → WorkspaceMessageResponse-CXGOQgpo.js} +1 -1
- package/dist/components/agents-sdk/AgentComputer.d.ts +2 -276
- package/dist/components/agents-sdk/AgentComputer.js +1 -1
- package/dist/components/agents-sdk/BrowserReplay.js +1 -1
- package/dist/components/agents-sdk/ComputerAutomations.d.ts +5 -15
- package/dist/components/agents-sdk/ComputerAutomations.js +164 -145
- package/dist/components/agents-sdk/ComputerCalendar.d.ts +1 -1
- package/dist/components/agents-sdk/ComputerCalendar.js +1 -1344
- package/dist/components/agents-sdk/ComputerCustomWallpaper.d.ts +2 -39
- package/dist/components/agents-sdk/ComputerCustomWallpaper.js +2 -522
- package/dist/components/agents-sdk/ComputerFiles.d.ts +18 -81
- package/dist/components/agents-sdk/ComputerFiles.js +365 -89
- package/dist/components/agents-sdk/ComputerHome.d.ts +6 -11
- package/dist/components/agents-sdk/ComputerHome.js +1 -89
- package/dist/components/agents-sdk/ComputerHost.d.ts +43 -0
- package/dist/components/agents-sdk/ComputerHost.js +97 -0
- package/dist/components/agents-sdk/ComputerLayout.d.ts +1 -1
- package/dist/components/agents-sdk/ComputerNotifications.d.ts +2 -54
- package/dist/components/agents-sdk/ComputerNotifications.js +1 -668
- package/dist/components/agents-sdk/ComputerPresentation.d.ts +2 -0
- package/dist/components/agents-sdk/ComputerPresentation.js +2 -0
- package/dist/components/agents-sdk/ComputerScreen.d.ts +14 -14
- package/dist/components/agents-sdk/ComputerScreen.js +109 -50
- package/dist/components/agents-sdk/ComputerSettings.d.ts +12 -40
- package/dist/components/agents-sdk/ComputerSettings.js +249 -1038
- package/dist/components/agents-sdk/ComputerSpotlight.d.ts +13 -15
- package/dist/components/agents-sdk/ComputerSpotlight.js +1 -231
- package/dist/components/agents-sdk/ComputerViewer.d.ts +13 -17
- package/dist/components/agents-sdk/ComputerViewer.js +176 -187
- package/dist/components/agents-sdk/ComputerWallpapers.d.ts +1 -1
- package/dist/components/agents-sdk/EmployeeChat.js +2 -2
- package/dist/components/agents-sdk/EmployeeChrome.js +3 -3
- package/dist/components/agents-sdk/EmployeeSchedules.js +2 -2
- package/dist/components/agents-sdk/ExecutionBoard.js +1 -1
- package/dist/components/agents-sdk/ManagerOffice.js +1 -1
- package/dist/components/agents-sdk/ManagerOfficeScreens.js +2 -2
- package/dist/components/agents-sdk/McpPluginCatalog.js +1 -1
- package/dist/components/agents-sdk/ThinkChat.js +1 -1
- package/dist/components/agents-sdk/ThinkChatToolPanels.js +3 -3
- package/dist/components/agents-sdk/ThinkExecutionDetail.js +1 -1
- package/dist/components/agents-sdk/ThinkExecutionWorkbench.js +2 -2
- package/dist/components/agents-sdk/ThinkScheduleActions.js +1 -1
- package/dist/components/agents-sdk/ThinkScheduleBrowser.js +1 -1
- package/dist/components/agents-sdk/ThinkScheduleDetail.js +4 -4
- package/dist/components/agents-sdk/ThinkScheduleForm.js +3 -3
- package/dist/components/agents-sdk/WorkspaceAutomation.js +3 -3
- package/dist/components/agents-sdk/WorkspaceAutomationTable.js +1 -1
- package/dist/components/agents-sdk/WorkspaceBrowser.js +1 -1
- package/dist/components/agents-sdk/WorkspaceDesktop.d.ts +1 -5
- package/dist/components/agents-sdk/WorkspaceDesktop.js +53 -41
- package/dist/components/agents-sdk/WorkspaceExplorer.js +3 -3
- package/dist/components/agents-sdk/WorkspaceFileCommands.js +1 -924
- package/dist/components/agents-sdk/WorkspaceFileDetails.js +1 -1
- package/dist/components/agents-sdk/WorkspaceFileTransfer.js +1 -504
- package/dist/components/agents-sdk/WorkspaceFileView.js +6 -6
- package/dist/components/agents-sdk/WorkspaceLink.js +1 -1
- package/dist/components/agents-sdk/WorkspaceLive.d.ts +9 -0
- package/dist/components/agents-sdk/WorkspaceLive.js +2 -177
- package/dist/components/agents-sdk/WorkspaceMessageResponse.js +1 -1
- package/dist/components/agents-sdk/WorkspaceMountManager.js +1 -1
- package/dist/components/ai-sdk/Context.js +1 -842
- package/dist/components/ai-sdk/Plan.d.ts +33 -9
- package/dist/components/ai-sdk/Plan.js +336 -107
- package/dist/components/ai-sdk/PromptInput.js +1 -1
- package/dist/components/extension/FirstRunSetup.js +2 -2
- package/dist/components/foundations/ThemeProvider.d.ts +2 -0
- package/dist/components/foundations/ThemeProvider.js +2 -1
- package/dist/components/general-purpose/CommandPalette.d.ts +2 -52
- package/dist/components/general-purpose/ResponsiveSidebarShell.js +1 -1
- package/dist/components/general-purpose/WallpaperPicker.d.ts +33 -2
- package/dist/components/nanites/AgentConnection.js +1 -1
- package/dist/components/nanites/AgentToolDetail.js +1 -1
- package/dist/context-BWJpR084.js +94 -0
- package/dist/{parts-CPVz9l31.js → parts-DuT5-rDz.js} +1 -1
- package/dist/styles/agent-computer.css +16 -0
- package/dist/styles/computer-files.css +5 -0
- package/dist/styles/computer-notifications.css +1 -0
- package/dist/styles/plan.css +160 -23
- package/dist/{workspace-drag-B6hMXUNt.js → workspace-drag-BNhZIN8F.js} +1 -1
- package/dist/{workspace-quick-look-DODjsfhH.js → workspace-quick-look-8cbGu1Xf.js} +2 -2
- package/package.json +2 -2
- package/dist/WallpaperPicker-C-FItmDS.d.ts +0 -34
- package/dist/automations-host-DPORjdc7.js +0 -17
- package/dist/context-Ddsp8HgD.js +0 -43
- package/dist/minute-clock-CXpRGCMF.js +0 -35
- package/dist/progress-ring-BO649JA9.js +0 -79
- package/dist/{ManagerOffice-kSK7vTBl.js → ManagerOffice-BJ2vs-Lr.js} +2 -2
- package/dist/{WorkspaceLink-DK9kdMUH.js → WorkspaceLink-DDkj-Tq5.js} +1 -1
|
@@ -0,0 +1,1625 @@
|
|
|
1
|
+
import { o as formatOperationError } from "./format-DL7f2rqp.js";
|
|
2
|
+
import { Button } from "./components/foundations/Button.js";
|
|
3
|
+
import { AlertDialog } from "./components/foundations/AlertDialog.js";
|
|
4
|
+
import { a as workspaceDirname, i as workspaceBasename, n as isWorkspacePathWithinRoot, r as joinWorkspacePath } from "./workspace-path-TZggP-u4.js";
|
|
5
|
+
import { refreshWorkspaceFileQueries, workspaceFileQueryKey } from "./components/agents-sdk/Workspace.js";
|
|
6
|
+
import { invalidateWorkspaceConceptQueries, workspacePathsOverlap } from "./components/agents-sdk/WorkspaceConcept.js";
|
|
7
|
+
import { c } from "react/compiler-runtime";
|
|
8
|
+
import * as React from "react";
|
|
9
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
10
|
+
import { useQuery, useQueryClient } from "@tanstack/react-query";
|
|
11
|
+
//#region src/components/agents-sdk/WorkspaceFileCommands.tsx
|
|
12
|
+
/**
|
|
13
|
+
* Every file shortcut, first one per command shown in menus. macOS's own key
|
|
14
|
+
* is used wherever Chrome lets a page have it; New Folder (⇧⌘N, which opens
|
|
15
|
+
* an Incognito window) takes ⌥⌘N instead.
|
|
16
|
+
*/
|
|
17
|
+
const SHORTCUTS = [
|
|
18
|
+
{
|
|
19
|
+
command: "open",
|
|
20
|
+
key: "KeyO",
|
|
21
|
+
mod: true,
|
|
22
|
+
glyph: "⌘O",
|
|
23
|
+
aria: "Meta+O"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
command: "open",
|
|
27
|
+
key: "ArrowDown",
|
|
28
|
+
mod: true,
|
|
29
|
+
glyph: "⌘↓",
|
|
30
|
+
aria: "Meta+ArrowDown"
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
command: "quick-look",
|
|
34
|
+
key: "KeyY",
|
|
35
|
+
mod: true,
|
|
36
|
+
glyph: "⌘Y",
|
|
37
|
+
aria: "Meta+Y"
|
|
38
|
+
},
|
|
39
|
+
{
|
|
40
|
+
command: "trash",
|
|
41
|
+
key: "Backspace",
|
|
42
|
+
mod: true,
|
|
43
|
+
glyph: "⌘⌫",
|
|
44
|
+
aria: "Meta+Backspace"
|
|
45
|
+
},
|
|
46
|
+
{
|
|
47
|
+
command: "trash",
|
|
48
|
+
key: "Delete",
|
|
49
|
+
mod: true,
|
|
50
|
+
glyph: "⌘⌦",
|
|
51
|
+
aria: "Meta+Delete"
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
command: "put-back",
|
|
55
|
+
key: "Backspace",
|
|
56
|
+
mod: true,
|
|
57
|
+
glyph: "⌘⌫",
|
|
58
|
+
aria: "Meta+Backspace"
|
|
59
|
+
},
|
|
60
|
+
{
|
|
61
|
+
command: "empty-trash",
|
|
62
|
+
key: "Backspace",
|
|
63
|
+
mod: true,
|
|
64
|
+
shift: true,
|
|
65
|
+
glyph: "⇧⌘⌫",
|
|
66
|
+
aria: "Shift+Meta+Backspace"
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
command: "get-info",
|
|
70
|
+
key: "KeyI",
|
|
71
|
+
mod: true,
|
|
72
|
+
glyph: "⌘I",
|
|
73
|
+
aria: "Meta+I"
|
|
74
|
+
},
|
|
75
|
+
{
|
|
76
|
+
command: "rename",
|
|
77
|
+
key: "Enter",
|
|
78
|
+
mod: false,
|
|
79
|
+
glyph: "↩",
|
|
80
|
+
aria: "Enter"
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
command: "duplicate",
|
|
84
|
+
key: "KeyD",
|
|
85
|
+
mod: true,
|
|
86
|
+
glyph: "⌘D",
|
|
87
|
+
aria: "Meta+D"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
command: "cut",
|
|
91
|
+
key: "KeyX",
|
|
92
|
+
mod: true,
|
|
93
|
+
glyph: "⌘X",
|
|
94
|
+
aria: "Meta+X"
|
|
95
|
+
},
|
|
96
|
+
{
|
|
97
|
+
command: "copy",
|
|
98
|
+
key: "KeyC",
|
|
99
|
+
mod: true,
|
|
100
|
+
glyph: "⌘C",
|
|
101
|
+
aria: "Meta+C"
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
command: "paste",
|
|
105
|
+
key: "KeyV",
|
|
106
|
+
mod: true,
|
|
107
|
+
glyph: "⌘V",
|
|
108
|
+
aria: "Meta+V"
|
|
109
|
+
},
|
|
110
|
+
{
|
|
111
|
+
command: "move-here",
|
|
112
|
+
key: "KeyV",
|
|
113
|
+
mod: true,
|
|
114
|
+
alt: true,
|
|
115
|
+
glyph: "⌥⌘V",
|
|
116
|
+
aria: "Alt+Meta+V"
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
command: "new-folder",
|
|
120
|
+
key: "KeyN",
|
|
121
|
+
mod: true,
|
|
122
|
+
alt: true,
|
|
123
|
+
glyph: "⌥⌘N",
|
|
124
|
+
aria: "Alt+Meta+N"
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
command: "select-all",
|
|
128
|
+
key: "KeyA",
|
|
129
|
+
mod: true,
|
|
130
|
+
glyph: "⌘A",
|
|
131
|
+
aria: "Meta+A"
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
command: "undo",
|
|
135
|
+
key: "KeyZ",
|
|
136
|
+
mod: true,
|
|
137
|
+
glyph: "⌘Z",
|
|
138
|
+
aria: "Meta+Z"
|
|
139
|
+
},
|
|
140
|
+
{
|
|
141
|
+
command: "redo",
|
|
142
|
+
key: "KeyZ",
|
|
143
|
+
mod: true,
|
|
144
|
+
shift: true,
|
|
145
|
+
glyph: "⇧⌘Z",
|
|
146
|
+
aria: "Shift+Meta+Z"
|
|
147
|
+
}
|
|
148
|
+
];
|
|
149
|
+
/**
|
|
150
|
+
* A command's shortcut, for a host menu bar's item that runs it through
|
|
151
|
+
* `WorkspaceBrowserActions`: the glyphs it shows and its `aria-keyshortcuts`.
|
|
152
|
+
*/
|
|
153
|
+
function workspaceFileShortcut(command) {
|
|
154
|
+
return SHORTCUTS.find((shortcut) => shortcut.command === command);
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* The command a keydown names, or null. Command and Control both count as
|
|
158
|
+
* the modifier, so the same keys work off a Mac. Keys typed into a field, or
|
|
159
|
+
* mid-composition, are never commands.
|
|
160
|
+
*/
|
|
161
|
+
function workspaceFileCommandForKey(event) {
|
|
162
|
+
if (event.isComposing) return null;
|
|
163
|
+
const target = event.target;
|
|
164
|
+
if (target instanceof Element && target.closest("input, textarea, select, [contenteditable]:not([contenteditable='false'])")) return null;
|
|
165
|
+
const mod = event.metaKey || event.ctrlKey;
|
|
166
|
+
return SHORTCUTS.find((shortcut) => (shortcut.key === event.code || shortcut.key === event.key) && shortcut.mod === mod && Boolean(shortcut.shift) === event.shiftKey && Boolean(shortcut.alt) === event.altKey)?.command ?? null;
|
|
167
|
+
}
|
|
168
|
+
/** The folder each workspace volume keeps its Trash in. */
|
|
169
|
+
const WORKSPACE_TRASH = "/.Trash";
|
|
170
|
+
/** Where the Trash records each item's original location, so Put Back survives a reload. */
|
|
171
|
+
const PUT_BACK_RECORD = `${WORKSPACE_TRASH}/.put-back.json`;
|
|
172
|
+
/** Finder hides names that start with a dot, the Trash among them. */
|
|
173
|
+
function isHiddenWorkspaceEntry(entry) {
|
|
174
|
+
return entry.name.startsWith(".");
|
|
175
|
+
}
|
|
176
|
+
/** Whether `path` is in the Trash (the Trash itself excluded). */
|
|
177
|
+
function isInWorkspaceTrash(path) {
|
|
178
|
+
return path.startsWith(`${WORKSPACE_TRASH}/`);
|
|
179
|
+
}
|
|
180
|
+
/** The Trash's record of where each item came from, by its name in the Trash. */
|
|
181
|
+
async function readPutBackRecord(source) {
|
|
182
|
+
const text = await source.readFile(PUT_BACK_RECORD);
|
|
183
|
+
if (!text) return {};
|
|
184
|
+
try {
|
|
185
|
+
const parsed = JSON.parse(text);
|
|
186
|
+
return parsed && typeof parsed === "object" ? parsed : {};
|
|
187
|
+
} catch {
|
|
188
|
+
return {};
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
async function writePutBackRecord(source, record) {
|
|
192
|
+
await source.writeFile(PUT_BACK_RECORD, JSON.stringify(record), "application/json");
|
|
193
|
+
}
|
|
194
|
+
/** Whether a volume's Trash is full, as the Dock's bin shows it. */
|
|
195
|
+
function workspaceTrashQueryKey(sourceKey) {
|
|
196
|
+
return [
|
|
197
|
+
"workspace",
|
|
198
|
+
sourceKey,
|
|
199
|
+
"trash"
|
|
200
|
+
];
|
|
201
|
+
}
|
|
202
|
+
/** Whether the volume's Trash holds anything: the Dock's full or empty Trash. */
|
|
203
|
+
async function workspaceTrashIsFull(source) {
|
|
204
|
+
if (!await source.exists("/.Trash")) return false;
|
|
205
|
+
return (await source.readDir(WORKSPACE_TRASH)).some((entry) => !isHiddenWorkspaceEntry(entry));
|
|
206
|
+
}
|
|
207
|
+
/** Deletes everything in the Trash for good. */
|
|
208
|
+
async function emptyWorkspaceTrash(source) {
|
|
209
|
+
if (!await source.exists("/.Trash")) return;
|
|
210
|
+
for (const entry of await source.readDir(WORKSPACE_TRASH)) await source.rm(entry.path, {
|
|
211
|
+
recursive: true,
|
|
212
|
+
force: true
|
|
213
|
+
});
|
|
214
|
+
}
|
|
215
|
+
async function runOperation(source, operation) {
|
|
216
|
+
const folder = async (path) => (await source.stat(path))?.type === "directory";
|
|
217
|
+
if (operation.kind === "move") {
|
|
218
|
+
const { from, to } = operation;
|
|
219
|
+
if (!await source.exists(from)) throw new Error(`“${workspaceBasename(from)}” is no longer available.`);
|
|
220
|
+
if (await source.exists(to)) throw new Error(`An item named “${workspaceBasename(to)}” already exists in this location.`);
|
|
221
|
+
await source.mv(from, to, { recursive: true });
|
|
222
|
+
return {
|
|
223
|
+
kind: "move",
|
|
224
|
+
from: to,
|
|
225
|
+
to: from
|
|
226
|
+
};
|
|
227
|
+
}
|
|
228
|
+
if (operation.kind === "trash") {
|
|
229
|
+
const { path } = operation;
|
|
230
|
+
if (!await source.exists(path)) throw new Error(`“${workspaceBasename(path)}” is no longer available.`);
|
|
231
|
+
await source.mkdir(WORKSPACE_TRASH, { recursive: true });
|
|
232
|
+
const to = await availableWorkspacePath(source, WORKSPACE_TRASH, workspaceBasename(path), {
|
|
233
|
+
folder: await folder(path),
|
|
234
|
+
copy: false
|
|
235
|
+
});
|
|
236
|
+
await source.mv(path, to, { recursive: true });
|
|
237
|
+
const record = await readPutBackRecord(source);
|
|
238
|
+
record[workspaceBasename(to)] = path;
|
|
239
|
+
await writePutBackRecord(source, record);
|
|
240
|
+
return {
|
|
241
|
+
kind: "put-back",
|
|
242
|
+
path: to
|
|
243
|
+
};
|
|
244
|
+
}
|
|
245
|
+
const { path } = operation;
|
|
246
|
+
if (!await source.exists(path)) throw new Error(`“${workspaceBasename(path)}” is no longer in the Trash.`);
|
|
247
|
+
const record = await readPutBackRecord(source);
|
|
248
|
+
const origin = record[workspaceBasename(path)] ?? joinWorkspacePath("/", workspaceBasename(path));
|
|
249
|
+
const directory = workspaceDirname(origin);
|
|
250
|
+
await source.mkdir(directory, { recursive: true });
|
|
251
|
+
const to = await source.exists(origin) ? await availableWorkspacePath(source, directory, workspaceBasename(origin), {
|
|
252
|
+
folder: await folder(path),
|
|
253
|
+
copy: false
|
|
254
|
+
}) : origin;
|
|
255
|
+
await source.mv(path, to, { recursive: true });
|
|
256
|
+
delete record[workspaceBasename(path)];
|
|
257
|
+
await writePutBackRecord(source, record);
|
|
258
|
+
return {
|
|
259
|
+
kind: "trash",
|
|
260
|
+
path: to
|
|
261
|
+
};
|
|
262
|
+
}
|
|
263
|
+
/**
|
|
264
|
+
* Applies `operations` in order and resolves to the operations that reverse
|
|
265
|
+
* them, already in the order to apply: undoing is running the result, and
|
|
266
|
+
* redoing is running what that run returns. Stops at the first failure,
|
|
267
|
+
* with the operations before it applied.
|
|
268
|
+
*/
|
|
269
|
+
async function runWorkspaceFileOperations(source, operations) {
|
|
270
|
+
const inverses = [];
|
|
271
|
+
for (const operation of operations) inverses.unshift(await runOperation(source, operation));
|
|
272
|
+
return inverses;
|
|
273
|
+
}
|
|
274
|
+
/**
|
|
275
|
+
* Where the objects are after a run, read from the operations that run
|
|
276
|
+
* returned (its inverses): what to select afterwards.
|
|
277
|
+
*/
|
|
278
|
+
/** Every path an operation reads or writes; a trash lands in the Trash's own listing. */
|
|
279
|
+
function changedPaths(operation) {
|
|
280
|
+
switch (operation.kind) {
|
|
281
|
+
case "move": return [operation.from, operation.to];
|
|
282
|
+
case "trash": return [operation.path, joinWorkspacePath(WORKSPACE_TRASH, workspaceBasename(operation.path))];
|
|
283
|
+
case "put-back": return [operation.path];
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
function workspaceFileOperationPaths(operations) {
|
|
287
|
+
return operations.flatMap((operation) => operation.kind === "move" ? [operation.from] : operation.kind === "trash" ? [operation.path] : []);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Where a rename lands, checked as the Finder checks it. Rejects with the
|
|
291
|
+
* alert's words for a name that cannot be used or is taken.
|
|
292
|
+
*/
|
|
293
|
+
async function workspaceRenameTarget(source, path, name) {
|
|
294
|
+
const trimmed = name.trim();
|
|
295
|
+
if (!trimmed) throw new Error("A name can’t be empty.");
|
|
296
|
+
if (trimmed.includes("/")) throw new Error("A name can’t contain “/”.");
|
|
297
|
+
if (trimmed.startsWith(".")) throw new Error("Names that begin with a dot are reserved for the system.");
|
|
298
|
+
const to = joinWorkspacePath(workspaceDirname(path), trimmed);
|
|
299
|
+
if (to === path) return null;
|
|
300
|
+
if (await source.exists(to)) throw new Error(`The name “${trimmed}” is already taken. Please choose a different name.`);
|
|
301
|
+
return to;
|
|
302
|
+
}
|
|
303
|
+
/** Whether `path` is `folder` or inside it. */
|
|
304
|
+
function isWithin(path, folder) {
|
|
305
|
+
return folder === "/" || path === folder || path.startsWith(`${folder}/`);
|
|
306
|
+
}
|
|
307
|
+
/** "untitled folder", or the first free "untitled folder 2"… in `directory`. */
|
|
308
|
+
function newWorkspaceFolderPath(source, directory) {
|
|
309
|
+
return availableWorkspacePath(source, directory, "untitled folder", {
|
|
310
|
+
folder: true,
|
|
311
|
+
copy: false
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
const IMAGE = /\.(png|jpe?g|gif|webp|svg)$/i;
|
|
315
|
+
/** “name” for one object, "N Items" for more: the Finder's menu subject. */
|
|
316
|
+
function subject(paths) {
|
|
317
|
+
return paths.length === 1 ? `“${workspaceBasename(paths[0])}”` : `${paths.length} Items`;
|
|
318
|
+
}
|
|
319
|
+
/** An image file as PNG, the one image type Chrome writes to the system clipboard. */
|
|
320
|
+
async function pngOf(source, path) {
|
|
321
|
+
const info = await source.stat(path);
|
|
322
|
+
const bytes = await source.readFileBytes(path);
|
|
323
|
+
if (!info || !bytes) throw new Error("The image is no longer available.");
|
|
324
|
+
const blob = new Blob([Uint8Array.from(bytes).buffer], { type: info.mimeType });
|
|
325
|
+
if (info.mimeType === "image/png") return blob;
|
|
326
|
+
const url = URL.createObjectURL(blob);
|
|
327
|
+
const image = new Image();
|
|
328
|
+
image.src = url;
|
|
329
|
+
await image.decode().finally(() => URL.revokeObjectURL(url));
|
|
330
|
+
const canvas = new OffscreenCanvas(image.naturalWidth || 512, image.naturalHeight || 512);
|
|
331
|
+
canvas.getContext("2d").drawImage(image, 0, 0, canvas.width, canvas.height);
|
|
332
|
+
return canvas.convertToBlob({ type: "image/png" });
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* What the computer's clipboard can carry from a copy: the names as text, and
|
|
336
|
+
* one image as PNG. Must run in the copy's own event, which grants the write.
|
|
337
|
+
*/
|
|
338
|
+
function writeSystemClipboard(source, paths) {
|
|
339
|
+
const names = paths.map(workspaceBasename).join("\n");
|
|
340
|
+
const image = paths.length === 1 && IMAGE.test(paths[0]);
|
|
341
|
+
const item = new ClipboardItem(image ? {
|
|
342
|
+
"text/plain": names,
|
|
343
|
+
"image/png": pngOf(source, paths[0])
|
|
344
|
+
} : { "text/plain": names });
|
|
345
|
+
navigator.clipboard.write([item]).catch(() => image ? navigator.clipboard.writeText(names) : void 0).catch(() => void 0);
|
|
346
|
+
}
|
|
347
|
+
/**
|
|
348
|
+
* One computer's file commands, shared by its desktop and every browser
|
|
349
|
+
* window: the clipboard, Undo and Redo, the Trash, and the alerts they ask.
|
|
350
|
+
* Drops, pastes and imports run through {@link useWorkspaceTransfer}, so a
|
|
351
|
+
* drag, a shortcut and a menu item do the same thing.
|
|
352
|
+
*
|
|
353
|
+
* ```tsx
|
|
354
|
+
* const files = useWorkspaceFileCommands({ home, openFolder });
|
|
355
|
+
* <WorkspaceDesktop commands={files.commands(home, "desktop")} … />
|
|
356
|
+
* {files.dialogs}
|
|
357
|
+
* ```
|
|
358
|
+
*/
|
|
359
|
+
function useWorkspaceFileCommands(t0) {
|
|
360
|
+
const $ = c(112);
|
|
361
|
+
const { home, readOnly: t1, openFolder, getInfo, onStatus } = t0;
|
|
362
|
+
let t2;
|
|
363
|
+
if ($[0] !== t1) {
|
|
364
|
+
t2 = t1 === void 0 ? [] : t1;
|
|
365
|
+
$[0] = t1;
|
|
366
|
+
$[1] = t2;
|
|
367
|
+
} else t2 = $[1];
|
|
368
|
+
const readOnly = t2;
|
|
369
|
+
const queryClient = useQueryClient();
|
|
370
|
+
let t3;
|
|
371
|
+
if ($[2] !== onStatus) {
|
|
372
|
+
t3 = { onStatus };
|
|
373
|
+
$[2] = onStatus;
|
|
374
|
+
$[3] = t3;
|
|
375
|
+
} else t3 = $[3];
|
|
376
|
+
const transfer = useWorkspaceTransfer(t3);
|
|
377
|
+
const [clipboard, setClipboard] = React.useState(null);
|
|
378
|
+
let t4;
|
|
379
|
+
if ($[4] === Symbol.for("react.memo_cache_sentinel")) {
|
|
380
|
+
t4 = [];
|
|
381
|
+
$[4] = t4;
|
|
382
|
+
} else t4 = $[4];
|
|
383
|
+
const [undoStack, setUndoStack] = React.useState(t4);
|
|
384
|
+
let t5;
|
|
385
|
+
if ($[5] === Symbol.for("react.memo_cache_sentinel")) {
|
|
386
|
+
t5 = [];
|
|
387
|
+
$[5] = t5;
|
|
388
|
+
} else t5 = $[5];
|
|
389
|
+
const [redoStack, setRedoStack] = React.useState(t5);
|
|
390
|
+
const [confirm, setConfirm] = React.useState(null);
|
|
391
|
+
const busy = React.useRef(false);
|
|
392
|
+
const trashFull = useQuery({
|
|
393
|
+
queryKey: workspaceTrashQueryKey(home.sourceKey),
|
|
394
|
+
queryFn: () => workspaceTrashIsFull(home.source),
|
|
395
|
+
staleTime: Infinity
|
|
396
|
+
}).data ?? false;
|
|
397
|
+
let t6;
|
|
398
|
+
if ($[6] !== home.sourceKey || $[7] !== readOnly) {
|
|
399
|
+
t6 = (volume, path) => volume.sourceKey === home.sourceKey && readOnly.some((folder) => isWithin(path, folder));
|
|
400
|
+
$[6] = home.sourceKey;
|
|
401
|
+
$[7] = readOnly;
|
|
402
|
+
$[8] = t6;
|
|
403
|
+
} else t6 = $[8];
|
|
404
|
+
const locked = t6;
|
|
405
|
+
let t7;
|
|
406
|
+
if ($[9] !== queryClient) {
|
|
407
|
+
t7 = (volume_0, operations, inverse) => invalidateWorkspacePaths(queryClient, volume_0.sourceKey, inverse && [...operations, ...inverse].flatMap(changedPaths));
|
|
408
|
+
$[9] = queryClient;
|
|
409
|
+
$[10] = t7;
|
|
410
|
+
} else t7 = $[10];
|
|
411
|
+
const refresh = t7;
|
|
412
|
+
let t8;
|
|
413
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
414
|
+
t8 = function record(entry) {
|
|
415
|
+
if (!entry.operations.length) return;
|
|
416
|
+
setUndoStack((stack) => [...stack, entry]);
|
|
417
|
+
setRedoStack([]);
|
|
418
|
+
};
|
|
419
|
+
$[11] = t8;
|
|
420
|
+
} else t8 = $[11];
|
|
421
|
+
const record = t8;
|
|
422
|
+
let t9;
|
|
423
|
+
if ($[12] === Symbol.for("react.memo_cache_sentinel")) {
|
|
424
|
+
t9 = function ask(question) {
|
|
425
|
+
return new Promise((resolve) => setConfirm({
|
|
426
|
+
...question,
|
|
427
|
+
resolve
|
|
428
|
+
}));
|
|
429
|
+
};
|
|
430
|
+
$[12] = t9;
|
|
431
|
+
} else t9 = $[12];
|
|
432
|
+
const ask = t9;
|
|
433
|
+
let t10;
|
|
434
|
+
if ($[13] !== confirm) {
|
|
435
|
+
t10 = function answer(confirmed) {
|
|
436
|
+
confirm?.resolve(confirmed);
|
|
437
|
+
setConfirm(null);
|
|
438
|
+
};
|
|
439
|
+
$[13] = confirm;
|
|
440
|
+
$[14] = t10;
|
|
441
|
+
} else t10 = $[14];
|
|
442
|
+
const answer = t10;
|
|
443
|
+
let t11;
|
|
444
|
+
if ($[15] !== transfer) {
|
|
445
|
+
t11 = async function exclusive(title, work) {
|
|
446
|
+
if (busy.current) return;
|
|
447
|
+
busy.current = true;
|
|
448
|
+
const result = await work().then(_temp$2, _temp2$1);
|
|
449
|
+
busy.current = false;
|
|
450
|
+
if ("error" in result) {
|
|
451
|
+
transfer.alert({
|
|
452
|
+
title,
|
|
453
|
+
detail: formatOperationError(result.error)
|
|
454
|
+
});
|
|
455
|
+
return;
|
|
456
|
+
}
|
|
457
|
+
return result.value;
|
|
458
|
+
};
|
|
459
|
+
$[15] = transfer;
|
|
460
|
+
$[16] = t11;
|
|
461
|
+
} else t11 = $[16];
|
|
462
|
+
const exclusive = t11;
|
|
463
|
+
let t12;
|
|
464
|
+
if ($[17] !== exclusive || $[18] !== refresh) {
|
|
465
|
+
t12 = async function apply(volume_1, label, operations_0) {
|
|
466
|
+
const inverse_0 = await exclusive(`${label} couldn’t be completed`, () => runWorkspaceFileOperations(volume_1.source, operations_0));
|
|
467
|
+
await refresh(volume_1, operations_0, inverse_0);
|
|
468
|
+
if (!inverse_0) return [];
|
|
469
|
+
record({
|
|
470
|
+
label,
|
|
471
|
+
volume: volume_1,
|
|
472
|
+
operations: inverse_0
|
|
473
|
+
});
|
|
474
|
+
return workspaceFileOperationPaths(inverse_0);
|
|
475
|
+
};
|
|
476
|
+
$[17] = exclusive;
|
|
477
|
+
$[18] = refresh;
|
|
478
|
+
$[19] = t12;
|
|
479
|
+
} else t12 = $[19];
|
|
480
|
+
const apply = t12;
|
|
481
|
+
let t13;
|
|
482
|
+
if ($[20] !== apply || $[21] !== exclusive || $[22] !== locked || $[23] !== queryClient) {
|
|
483
|
+
t13 = async function trash(volume_2, all) {
|
|
484
|
+
const paths = all.filter((path_0) => !locked(volume_2, path_0));
|
|
485
|
+
if (!paths.length) return;
|
|
486
|
+
if (!volume_2.linked) {
|
|
487
|
+
await apply(volume_2, `Move of ${subject(paths)}`, paths.map(_temp3));
|
|
488
|
+
return;
|
|
489
|
+
}
|
|
490
|
+
if (!await ask({
|
|
491
|
+
title: paths.length === 1 ? `Are you sure you want to delete ${subject(paths)}?` : `Are you sure you want to delete these ${paths.length} items?`,
|
|
492
|
+
detail: `${paths.length === 1 ? "This item" : "These items"} will be deleted immediately. You can’t undo this action.`,
|
|
493
|
+
action: "Delete"
|
|
494
|
+
})) return;
|
|
495
|
+
await exclusive("The items couldn’t be deleted", async () => {
|
|
496
|
+
for (const path_2 of paths) await volume_2.source.rm(path_2, {
|
|
497
|
+
recursive: true,
|
|
498
|
+
force: true
|
|
499
|
+
});
|
|
500
|
+
});
|
|
501
|
+
await invalidateWorkspacePaths(queryClient, volume_2.sourceKey, paths);
|
|
502
|
+
};
|
|
503
|
+
$[20] = apply;
|
|
504
|
+
$[21] = exclusive;
|
|
505
|
+
$[22] = locked;
|
|
506
|
+
$[23] = queryClient;
|
|
507
|
+
$[24] = t13;
|
|
508
|
+
} else t13 = $[24];
|
|
509
|
+
const trash = t13;
|
|
510
|
+
let t14;
|
|
511
|
+
if ($[25] !== exclusive || $[26] !== home.source || $[27] !== home.sourceKey || $[28] !== queryClient) {
|
|
512
|
+
t14 = async function emptyTrash() {
|
|
513
|
+
if (!await ask({
|
|
514
|
+
title: "Are you sure you want to permanently erase the items in the Trash?",
|
|
515
|
+
detail: "You can’t undo this action.",
|
|
516
|
+
action: "Empty Trash"
|
|
517
|
+
})) return;
|
|
518
|
+
await exclusive("The Trash couldn’t be emptied", () => emptyWorkspaceTrash(home.source));
|
|
519
|
+
await invalidateWorkspacePaths(queryClient, home.sourceKey, [WORKSPACE_TRASH]);
|
|
520
|
+
};
|
|
521
|
+
$[25] = exclusive;
|
|
522
|
+
$[26] = home.source;
|
|
523
|
+
$[27] = home.sourceKey;
|
|
524
|
+
$[28] = queryClient;
|
|
525
|
+
$[29] = t14;
|
|
526
|
+
} else t14 = $[29];
|
|
527
|
+
const emptyTrash = t14;
|
|
528
|
+
let t15;
|
|
529
|
+
if ($[30] !== home || $[31] !== locked || $[32] !== transfer || $[33] !== trash) {
|
|
530
|
+
t15 = async function drop(volume_3, dropped, directory, requested, label_0) {
|
|
531
|
+
if (locked(volume_3, directory)) return [];
|
|
532
|
+
const operation = dropped.kind === "workspace" && dropped.sourceKey === home.sourceKey && dropped.paths.some((path_3) => locked(home, path_3)) ? "copy" : requested;
|
|
533
|
+
if (dropped.kind === "workspace" && dropped.sourceKey === volume_3.sourceKey && !volume_3.linked && directory === "/.Trash") {
|
|
534
|
+
await trash(volume_3, dropped.paths);
|
|
535
|
+
return [];
|
|
536
|
+
}
|
|
537
|
+
const result_0 = await transfer.run({
|
|
538
|
+
drop: dropped,
|
|
539
|
+
destination: volume_3.source,
|
|
540
|
+
destinationKey: volume_3.sourceKey,
|
|
541
|
+
directory,
|
|
542
|
+
operation
|
|
543
|
+
});
|
|
544
|
+
if (!result_0) return [];
|
|
545
|
+
const moved = dropped.kind === "workspace" && dropped.sourceKey === volume_3.sourceKey;
|
|
546
|
+
const operations_1 = result_0.landed.flatMap((t16) => {
|
|
547
|
+
const { from, path: path_4 } = t16;
|
|
548
|
+
return moved && operation === "move" && from ? [{
|
|
549
|
+
kind: "move",
|
|
550
|
+
from: path_4,
|
|
551
|
+
to: from
|
|
552
|
+
}] : volume_3.linked ? [] : [{
|
|
553
|
+
kind: "trash",
|
|
554
|
+
path: path_4
|
|
555
|
+
}];
|
|
556
|
+
});
|
|
557
|
+
const paths_0 = result_0.landed.map(_temp4);
|
|
558
|
+
record({
|
|
559
|
+
label: label_0 ?? `${moved && operation === "move" ? "Move" : "Copy"} of ${subject(paths_0)}`,
|
|
560
|
+
volume: volume_3,
|
|
561
|
+
operations: operations_1.toReversed()
|
|
562
|
+
});
|
|
563
|
+
return paths_0;
|
|
564
|
+
};
|
|
565
|
+
$[30] = home;
|
|
566
|
+
$[31] = locked;
|
|
567
|
+
$[32] = transfer;
|
|
568
|
+
$[33] = trash;
|
|
569
|
+
$[34] = t15;
|
|
570
|
+
} else t15 = $[34];
|
|
571
|
+
const drop = t15;
|
|
572
|
+
let t16;
|
|
573
|
+
if ($[35] !== exclusive || $[36] !== redoStack || $[37] !== refresh || $[38] !== undoStack) {
|
|
574
|
+
t16 = async function step(direction) {
|
|
575
|
+
const [from_0, setFrom, setTo] = direction === "undo" ? [
|
|
576
|
+
undoStack,
|
|
577
|
+
setUndoStack,
|
|
578
|
+
setRedoStack
|
|
579
|
+
] : [
|
|
580
|
+
redoStack,
|
|
581
|
+
setRedoStack,
|
|
582
|
+
setUndoStack
|
|
583
|
+
];
|
|
584
|
+
const entry_0 = from_0.at(-1);
|
|
585
|
+
if (!entry_0) return [];
|
|
586
|
+
const inverse_1 = await exclusive(`${direction === "undo" ? "Undo" : "Redo"} ${entry_0.label} couldn’t be completed`, () => runWorkspaceFileOperations(entry_0.volume.source, entry_0.operations));
|
|
587
|
+
await refresh(entry_0.volume, entry_0.operations, inverse_1);
|
|
588
|
+
setFrom(_temp5);
|
|
589
|
+
if (!inverse_1) return [];
|
|
590
|
+
setTo((stack_1) => [...stack_1, {
|
|
591
|
+
...entry_0,
|
|
592
|
+
operations: inverse_1
|
|
593
|
+
}]);
|
|
594
|
+
return workspaceFileOperationPaths(inverse_1);
|
|
595
|
+
};
|
|
596
|
+
$[35] = exclusive;
|
|
597
|
+
$[36] = redoStack;
|
|
598
|
+
$[37] = refresh;
|
|
599
|
+
$[38] = undoStack;
|
|
600
|
+
$[39] = t16;
|
|
601
|
+
} else t16 = $[39];
|
|
602
|
+
const step = t16;
|
|
603
|
+
let t17;
|
|
604
|
+
if ($[40] !== apply || $[41] !== clipboard || $[42] !== drop || $[43] !== emptyTrash || $[44] !== exclusive || $[45] !== getInfo || $[46] !== locked || $[47] !== openFolder || $[48] !== queryClient || $[49] !== redoStack.length || $[50] !== step || $[51] !== transfer || $[52] !== trash || $[53] !== trashFull || $[54] !== undoStack.length) {
|
|
605
|
+
t17 = function commands(volume_4, surface) {
|
|
606
|
+
const canRun = (command, target) => {
|
|
607
|
+
const inTrash = !volume_4.linked && target.directory === "/.Trash";
|
|
608
|
+
const some = target.paths.length > 0;
|
|
609
|
+
const fixed = target.paths.some((path_6) => locked(volume_4, path_6));
|
|
610
|
+
const closed = locked(volume_4, target.directory);
|
|
611
|
+
switch (command) {
|
|
612
|
+
case "open":
|
|
613
|
+
case "quick-look":
|
|
614
|
+
case "copy": return some;
|
|
615
|
+
case "cut": return some && !fixed;
|
|
616
|
+
case "get-info": return getInfo !== void 0;
|
|
617
|
+
case "select-all": return true;
|
|
618
|
+
case "rename": return target.paths.length === 1 && !inTrash && !fixed;
|
|
619
|
+
case "duplicate": return some && !inTrash && !closed;
|
|
620
|
+
case "trash": return some && !inTrash && !fixed;
|
|
621
|
+
case "paste": return !inTrash && !closed && (clipboard !== null || Boolean(target.files?.length));
|
|
622
|
+
case "move-here": return !inTrash && !closed && clipboard !== null;
|
|
623
|
+
case "new-folder": return !inTrash && !closed;
|
|
624
|
+
case "put-back": return some && inTrash;
|
|
625
|
+
case "empty-trash": return inTrash && trashFull;
|
|
626
|
+
case "show-in-finder": return surface === "desktop" && some;
|
|
627
|
+
case "undo": return undoStack.length > 0;
|
|
628
|
+
case "redo": return redoStack.length > 0;
|
|
629
|
+
}
|
|
630
|
+
};
|
|
631
|
+
return {
|
|
632
|
+
canRun,
|
|
633
|
+
pasteLabel: clipboard ? `Paste ${clipboard.paths.length === 1 ? "Item" : `${clipboard.paths.length} Items`}` : null,
|
|
634
|
+
rename: async (path_7, name) => {
|
|
635
|
+
if (locked(volume_4, path_7)) return path_7;
|
|
636
|
+
const to = await workspaceRenameTarget(volume_4.source, path_7, name).catch((error_0) => {
|
|
637
|
+
transfer.alert({
|
|
638
|
+
title: "That name can’t be used",
|
|
639
|
+
detail: formatOperationError(error_0)
|
|
640
|
+
});
|
|
641
|
+
throw error_0;
|
|
642
|
+
});
|
|
643
|
+
if (!to) return path_7;
|
|
644
|
+
return (await apply(volume_4, "Rename", [{
|
|
645
|
+
kind: "move",
|
|
646
|
+
from: path_7,
|
|
647
|
+
to
|
|
648
|
+
}])).length ? to : path_7;
|
|
649
|
+
},
|
|
650
|
+
run: async (command_0, target_0) => {
|
|
651
|
+
if (!canRun(command_0, target_0)) return;
|
|
652
|
+
const { paths: paths_1, directory: directory_0 } = target_0;
|
|
653
|
+
switch (command_0) {
|
|
654
|
+
case "copy":
|
|
655
|
+
case "cut":
|
|
656
|
+
writeSystemClipboard(volume_4.source, paths_1);
|
|
657
|
+
setClipboard({
|
|
658
|
+
volume: volume_4,
|
|
659
|
+
paths: paths_1,
|
|
660
|
+
cut: command_0 === "cut"
|
|
661
|
+
});
|
|
662
|
+
return;
|
|
663
|
+
case "paste":
|
|
664
|
+
case "move-here": {
|
|
665
|
+
if (target_0.files?.length) return drop(volume_4, {
|
|
666
|
+
kind: "files",
|
|
667
|
+
items: target_0.files.map(_temp6)
|
|
668
|
+
}, directory_0, "copy");
|
|
669
|
+
if (!clipboard) return;
|
|
670
|
+
const move = command_0 === "move-here" || clipboard.cut;
|
|
671
|
+
const landed = await drop(volume_4, {
|
|
672
|
+
kind: "workspace",
|
|
673
|
+
...clipboard.volume,
|
|
674
|
+
paths: clipboard.paths
|
|
675
|
+
}, directory_0, move ? "move" : "copy");
|
|
676
|
+
if (move) setClipboard(null);
|
|
677
|
+
return landed;
|
|
678
|
+
}
|
|
679
|
+
case "duplicate": return drop(volume_4, {
|
|
680
|
+
kind: "workspace",
|
|
681
|
+
...volume_4,
|
|
682
|
+
paths: paths_1
|
|
683
|
+
}, directory_0, "copy", `Duplicate of ${subject(paths_1)}`);
|
|
684
|
+
case "new-folder": {
|
|
685
|
+
const path_10 = await exclusive("The folder couldn’t be created", async () => {
|
|
686
|
+
const path_9 = await newWorkspaceFolderPath(volume_4.source, directory_0);
|
|
687
|
+
await volume_4.source.mkdir(path_9);
|
|
688
|
+
return path_9;
|
|
689
|
+
});
|
|
690
|
+
await invalidateWorkspacePaths(queryClient, volume_4.sourceKey, path_10 ? [path_10] : void 0);
|
|
691
|
+
if (!path_10) return;
|
|
692
|
+
if (!volume_4.linked) record({
|
|
693
|
+
label: "New Folder",
|
|
694
|
+
volume: volume_4,
|
|
695
|
+
operations: [{
|
|
696
|
+
kind: "trash",
|
|
697
|
+
path: path_10
|
|
698
|
+
}]
|
|
699
|
+
});
|
|
700
|
+
return [path_10];
|
|
701
|
+
}
|
|
702
|
+
case "trash": return trash(volume_4, paths_1);
|
|
703
|
+
case "put-back": return apply(volume_4, "Put Back", paths_1.map(_temp7));
|
|
704
|
+
case "empty-trash": return emptyTrash();
|
|
705
|
+
case "get-info": return getInfo?.(volume_4, paths_1.length ? paths_1 : [directory_0]);
|
|
706
|
+
case "show-in-finder":
|
|
707
|
+
openFolder(workspaceDirname(paths_1.at(-1)));
|
|
708
|
+
return;
|
|
709
|
+
case "undo":
|
|
710
|
+
case "redo": return step(command_0);
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
};
|
|
714
|
+
};
|
|
715
|
+
$[40] = apply;
|
|
716
|
+
$[41] = clipboard;
|
|
717
|
+
$[42] = drop;
|
|
718
|
+
$[43] = emptyTrash;
|
|
719
|
+
$[44] = exclusive;
|
|
720
|
+
$[45] = getInfo;
|
|
721
|
+
$[46] = locked;
|
|
722
|
+
$[47] = openFolder;
|
|
723
|
+
$[48] = queryClient;
|
|
724
|
+
$[49] = redoStack.length;
|
|
725
|
+
$[50] = step;
|
|
726
|
+
$[51] = transfer;
|
|
727
|
+
$[52] = trash;
|
|
728
|
+
$[53] = trashFull;
|
|
729
|
+
$[54] = undoStack.length;
|
|
730
|
+
$[55] = t17;
|
|
731
|
+
} else t17 = $[55];
|
|
732
|
+
const commands = t17;
|
|
733
|
+
const t18 = confirm !== null;
|
|
734
|
+
let t19;
|
|
735
|
+
if ($[56] !== answer) {
|
|
736
|
+
t19 = (open) => !open && answer(false);
|
|
737
|
+
$[56] = answer;
|
|
738
|
+
$[57] = t19;
|
|
739
|
+
} else t19 = $[57];
|
|
740
|
+
let t20;
|
|
741
|
+
if ($[58] === Symbol.for("react.memo_cache_sentinel")) {
|
|
742
|
+
t20 = /* @__PURE__ */ jsx(AlertDialog.Backdrop, {});
|
|
743
|
+
$[58] = t20;
|
|
744
|
+
} else t20 = $[58];
|
|
745
|
+
const t21 = confirm?.title;
|
|
746
|
+
let t22;
|
|
747
|
+
if ($[59] !== t21) {
|
|
748
|
+
t22 = /* @__PURE__ */ jsx(AlertDialog.Title, { children: t21 });
|
|
749
|
+
$[59] = t21;
|
|
750
|
+
$[60] = t22;
|
|
751
|
+
} else t22 = $[60];
|
|
752
|
+
const t23 = confirm?.detail;
|
|
753
|
+
let t24;
|
|
754
|
+
if ($[61] !== t23) {
|
|
755
|
+
t24 = /* @__PURE__ */ jsx(AlertDialog.Description, { children: t23 });
|
|
756
|
+
$[61] = t23;
|
|
757
|
+
$[62] = t24;
|
|
758
|
+
} else t24 = $[62];
|
|
759
|
+
let t25;
|
|
760
|
+
if ($[63] !== t22 || $[64] !== t24) {
|
|
761
|
+
t25 = /* @__PURE__ */ jsxs(AlertDialog.Header, { children: [t22, t24] });
|
|
762
|
+
$[63] = t22;
|
|
763
|
+
$[64] = t24;
|
|
764
|
+
$[65] = t25;
|
|
765
|
+
} else t25 = $[65];
|
|
766
|
+
let t26;
|
|
767
|
+
if ($[66] === Symbol.for("react.memo_cache_sentinel")) {
|
|
768
|
+
t26 = /* @__PURE__ */ jsx(AlertDialog.Close, { children: "Cancel" });
|
|
769
|
+
$[66] = t26;
|
|
770
|
+
} else t26 = $[66];
|
|
771
|
+
let t27;
|
|
772
|
+
if ($[67] !== answer) {
|
|
773
|
+
t27 = () => answer(true);
|
|
774
|
+
$[67] = answer;
|
|
775
|
+
$[68] = t27;
|
|
776
|
+
} else t27 = $[68];
|
|
777
|
+
const t28 = confirm?.action;
|
|
778
|
+
let t29;
|
|
779
|
+
if ($[69] !== t27 || $[70] !== t28) {
|
|
780
|
+
t29 = /* @__PURE__ */ jsxs(AlertDialog.Footer, { children: [t26, /* @__PURE__ */ jsx(Button, {
|
|
781
|
+
color: "destructive",
|
|
782
|
+
onClick: t27,
|
|
783
|
+
children: t28
|
|
784
|
+
})] });
|
|
785
|
+
$[69] = t27;
|
|
786
|
+
$[70] = t28;
|
|
787
|
+
$[71] = t29;
|
|
788
|
+
} else t29 = $[71];
|
|
789
|
+
let t30;
|
|
790
|
+
if ($[72] !== t25 || $[73] !== t29) {
|
|
791
|
+
t30 = /* @__PURE__ */ jsxs(AlertDialog.Portal, { children: [t20, /* @__PURE__ */ jsx(AlertDialog.Viewport, { children: /* @__PURE__ */ jsxs(AlertDialog.Popup, {
|
|
792
|
+
size: "sm",
|
|
793
|
+
children: [t25, t29]
|
|
794
|
+
}) })] });
|
|
795
|
+
$[72] = t25;
|
|
796
|
+
$[73] = t29;
|
|
797
|
+
$[74] = t30;
|
|
798
|
+
} else t30 = $[74];
|
|
799
|
+
let t31;
|
|
800
|
+
if ($[75] !== t18 || $[76] !== t19 || $[77] !== t30) {
|
|
801
|
+
t31 = /* @__PURE__ */ jsx(AlertDialog.Root, {
|
|
802
|
+
open: t18,
|
|
803
|
+
onOpenChange: t19,
|
|
804
|
+
children: t30
|
|
805
|
+
});
|
|
806
|
+
$[75] = t18;
|
|
807
|
+
$[76] = t19;
|
|
808
|
+
$[77] = t30;
|
|
809
|
+
$[78] = t31;
|
|
810
|
+
} else t31 = $[78];
|
|
811
|
+
let t32;
|
|
812
|
+
if ($[79] !== t31 || $[80] !== transfer.dialogs) {
|
|
813
|
+
t32 = /* @__PURE__ */ jsxs(Fragment, { children: [transfer.dialogs, t31] });
|
|
814
|
+
$[79] = t31;
|
|
815
|
+
$[80] = transfer.dialogs;
|
|
816
|
+
$[81] = t32;
|
|
817
|
+
} else t32 = $[81];
|
|
818
|
+
const dialogs = t32;
|
|
819
|
+
let t33;
|
|
820
|
+
if ($[82] !== undoStack) {
|
|
821
|
+
t33 = undoStack.at(-1)?.label ?? null;
|
|
822
|
+
$[82] = undoStack;
|
|
823
|
+
$[83] = t33;
|
|
824
|
+
} else t33 = $[83];
|
|
825
|
+
let t34;
|
|
826
|
+
if ($[84] !== redoStack) {
|
|
827
|
+
t34 = redoStack.at(-1)?.label ?? null;
|
|
828
|
+
$[84] = redoStack;
|
|
829
|
+
$[85] = t34;
|
|
830
|
+
} else t34 = $[85];
|
|
831
|
+
let t35;
|
|
832
|
+
let t36;
|
|
833
|
+
if ($[86] !== step) {
|
|
834
|
+
t35 = () => void step("undo");
|
|
835
|
+
t36 = () => void step("redo");
|
|
836
|
+
$[86] = step;
|
|
837
|
+
$[87] = t35;
|
|
838
|
+
$[88] = t36;
|
|
839
|
+
} else {
|
|
840
|
+
t35 = $[87];
|
|
841
|
+
t36 = $[88];
|
|
842
|
+
}
|
|
843
|
+
let t37;
|
|
844
|
+
if ($[89] !== emptyTrash) {
|
|
845
|
+
t37 = () => void emptyTrash();
|
|
846
|
+
$[89] = emptyTrash;
|
|
847
|
+
$[90] = t37;
|
|
848
|
+
} else t37 = $[90];
|
|
849
|
+
let t38;
|
|
850
|
+
if ($[91] !== home.source || $[92] !== openFolder) {
|
|
851
|
+
t38 = () => void home.source.mkdir(WORKSPACE_TRASH, { recursive: true }).then(() => openFolder(WORKSPACE_TRASH));
|
|
852
|
+
$[91] = home.source;
|
|
853
|
+
$[92] = openFolder;
|
|
854
|
+
$[93] = t38;
|
|
855
|
+
} else t38 = $[93];
|
|
856
|
+
let t39;
|
|
857
|
+
if ($[94] !== home || $[95] !== trash) {
|
|
858
|
+
t39 = (t40) => {
|
|
859
|
+
const { sourceKey, paths: paths_2 } = t40;
|
|
860
|
+
if (sourceKey === home.sourceKey) trash(home, paths_2);
|
|
861
|
+
};
|
|
862
|
+
$[94] = home;
|
|
863
|
+
$[95] = trash;
|
|
864
|
+
$[96] = t39;
|
|
865
|
+
} else t39 = $[96];
|
|
866
|
+
let t40;
|
|
867
|
+
if ($[97] !== commands || $[98] !== dialogs || $[99] !== drop || $[100] !== home || $[101] !== t33 || $[102] !== t34 || $[103] !== t35 || $[104] !== t36 || $[105] !== t37 || $[106] !== t38 || $[107] !== t39 || $[108] !== transfer.cancel || $[109] !== transfer.transferring || $[110] !== trashFull) {
|
|
868
|
+
t40 = {
|
|
869
|
+
home,
|
|
870
|
+
commands,
|
|
871
|
+
drop,
|
|
872
|
+
undoLabel: t33,
|
|
873
|
+
redoLabel: t34,
|
|
874
|
+
undo: t35,
|
|
875
|
+
redo: t36,
|
|
876
|
+
trashFull,
|
|
877
|
+
emptyTrash: t37,
|
|
878
|
+
openTrash: t38,
|
|
879
|
+
trashDrop: t39,
|
|
880
|
+
transferring: transfer.transferring,
|
|
881
|
+
cancelTransfer: transfer.cancel,
|
|
882
|
+
dialogs
|
|
883
|
+
};
|
|
884
|
+
$[97] = commands;
|
|
885
|
+
$[98] = dialogs;
|
|
886
|
+
$[99] = drop;
|
|
887
|
+
$[100] = home;
|
|
888
|
+
$[101] = t33;
|
|
889
|
+
$[102] = t34;
|
|
890
|
+
$[103] = t35;
|
|
891
|
+
$[104] = t36;
|
|
892
|
+
$[105] = t37;
|
|
893
|
+
$[106] = t38;
|
|
894
|
+
$[107] = t39;
|
|
895
|
+
$[108] = transfer.cancel;
|
|
896
|
+
$[109] = transfer.transferring;
|
|
897
|
+
$[110] = trashFull;
|
|
898
|
+
$[111] = t40;
|
|
899
|
+
} else t40 = $[111];
|
|
900
|
+
return t40;
|
|
901
|
+
}
|
|
902
|
+
function _temp7(path_8) {
|
|
903
|
+
return {
|
|
904
|
+
kind: "put-back",
|
|
905
|
+
path: path_8
|
|
906
|
+
};
|
|
907
|
+
}
|
|
908
|
+
function _temp6(file) {
|
|
909
|
+
return {
|
|
910
|
+
kind: "file",
|
|
911
|
+
name: file.name,
|
|
912
|
+
file
|
|
913
|
+
};
|
|
914
|
+
}
|
|
915
|
+
function _temp5(stack_0) {
|
|
916
|
+
return stack_0.slice(0, -1);
|
|
917
|
+
}
|
|
918
|
+
function _temp4(t0) {
|
|
919
|
+
const { path: path_5 } = t0;
|
|
920
|
+
return path_5;
|
|
921
|
+
}
|
|
922
|
+
function _temp3(path_1) {
|
|
923
|
+
return {
|
|
924
|
+
kind: "trash",
|
|
925
|
+
path: path_1
|
|
926
|
+
};
|
|
927
|
+
}
|
|
928
|
+
function _temp2$1(error) {
|
|
929
|
+
return { error };
|
|
930
|
+
}
|
|
931
|
+
function _temp$2(value) {
|
|
932
|
+
return { value };
|
|
933
|
+
}
|
|
934
|
+
//#endregion
|
|
935
|
+
//#region src/components/agents-sdk/WorkspaceLive.ts
|
|
936
|
+
const DEFAULT_DEBOUNCE_MS = 200;
|
|
937
|
+
/**
|
|
938
|
+
* Listings the host's root does not own: a Finder folder, Recents and a
|
|
939
|
+
* search each read under a root of their own (a dot root for the queries), so
|
|
940
|
+
* a change refreshes the source's info (the volume's and each Get Info
|
|
941
|
+
* file's), the listings of the changed folders, every query root's listings
|
|
942
|
+
* since any change can move them, and whether the Trash is full when the
|
|
943
|
+
* Trash changed. Without `directories`, every listing of the source and the
|
|
944
|
+
* Trash refresh.
|
|
945
|
+
*/
|
|
946
|
+
function invalidateEveryRoot(queryClient, sourceKey, directories) {
|
|
947
|
+
return queryClient.invalidateQueries({
|
|
948
|
+
queryKey: ["workspace", sourceKey],
|
|
949
|
+
predicate: ({ queryKey: [, , root, segment, path] }) => root === "info" || root === "trash" && (!directories || directories.has("/.Trash")) || segment === "directory" && (!directories || typeof root === "string" && root.startsWith("/.") || typeof path === "string" && directories.has(path))
|
|
950
|
+
});
|
|
951
|
+
}
|
|
952
|
+
/**
|
|
953
|
+
* What a change to `paths` in one source can have touched, under every root:
|
|
954
|
+
* the listings above, the concept queries whose scope overlaps a path, and
|
|
955
|
+
* the open files at or under one. File commands call it once a change lands,
|
|
956
|
+
* as the change feed does when its frames arrive. Without `paths`, every
|
|
957
|
+
* query of the source refreshes.
|
|
958
|
+
*/
|
|
959
|
+
function invalidateWorkspacePaths(queryClient, sourceKey, paths) {
|
|
960
|
+
if (!paths) return queryClient.invalidateQueries({ queryKey: ["workspace", sourceKey] });
|
|
961
|
+
const touches = (scope) => typeof scope === "string" && paths.some((path) => workspacePathsOverlap(scope, path));
|
|
962
|
+
return Promise.all([invalidateEveryRoot(queryClient, sourceKey, new Set(paths.map(workspaceDirname))), queryClient.invalidateQueries({
|
|
963
|
+
queryKey: ["workspace", sourceKey],
|
|
964
|
+
predicate: ({ queryKey: [, , , segment, path, scope] }) => segment === "concept" && touches(scope) || segment === "file" && touches(path)
|
|
965
|
+
})]);
|
|
966
|
+
}
|
|
967
|
+
async function invalidateWorkspaceResources(queryClient, sourceKey, root, source, selectedPath, resolveFileAsset, maxInlineAssetBytes, paths) {
|
|
968
|
+
if (!source || !selectedPath || paths && !paths.some((path) => workspacePathsOverlap(selectedPath, path))) return;
|
|
969
|
+
await queryClient.cancelQueries({ queryKey: workspaceFileQueryKey(sourceKey, root, selectedPath) });
|
|
970
|
+
await refreshWorkspaceFileQueries(queryClient, {
|
|
971
|
+
source,
|
|
972
|
+
sourceKey,
|
|
973
|
+
root,
|
|
974
|
+
selectedPath,
|
|
975
|
+
resolveFileAsset,
|
|
976
|
+
maxInlineAssetBytes
|
|
977
|
+
}).catch(() => {});
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Synchronize external workspace freshness with the design system's Query
|
|
981
|
+
* resources. This is the one external-system effect: native observer events
|
|
982
|
+
* and host revision ticks both land here as targeted invalidation against
|
|
983
|
+
* stable query keys. Hosts only supply events; neither layer adds another
|
|
984
|
+
* watcher.
|
|
985
|
+
*/
|
|
986
|
+
function useWorkspaceLiveQueries(t0) {
|
|
987
|
+
const $ = c(32);
|
|
988
|
+
const { changes, maxInlineAssetBytes, resolveFileAsset, selectedPath, source, sourceKey, root, revision } = t0;
|
|
989
|
+
const queryClient = useQueryClient();
|
|
990
|
+
let t1;
|
|
991
|
+
if ($[0] !== maxInlineAssetBytes || $[1] !== queryClient || $[2] !== resolveFileAsset || $[3] !== root || $[4] !== selectedPath || $[5] !== source || $[6] !== sourceKey) {
|
|
992
|
+
t1 = (paths) => {
|
|
993
|
+
if (!sourceKey) return;
|
|
994
|
+
invalidateWorkspaceResources(queryClient, sourceKey, root, source, selectedPath, resolveFileAsset, maxInlineAssetBytes, paths);
|
|
995
|
+
};
|
|
996
|
+
$[0] = maxInlineAssetBytes;
|
|
997
|
+
$[1] = queryClient;
|
|
998
|
+
$[2] = resolveFileAsset;
|
|
999
|
+
$[3] = root;
|
|
1000
|
+
$[4] = selectedPath;
|
|
1001
|
+
$[5] = source;
|
|
1002
|
+
$[6] = sourceKey;
|
|
1003
|
+
$[7] = t1;
|
|
1004
|
+
} else t1 = $[7];
|
|
1005
|
+
const refreshResources = React.useEffectEvent(t1);
|
|
1006
|
+
const previousRevisionRef = React.useRef(void 0);
|
|
1007
|
+
let t2;
|
|
1008
|
+
if ($[8] !== changes || $[9] !== queryClient || $[10] !== refreshResources || $[11] !== revision || $[12] !== root || $[13] !== sourceKey) {
|
|
1009
|
+
t2 = () => {
|
|
1010
|
+
if (!sourceKey || revision === void 0) return;
|
|
1011
|
+
const previous = previousRevisionRef.current;
|
|
1012
|
+
previousRevisionRef.current = {
|
|
1013
|
+
sourceKey,
|
|
1014
|
+
root,
|
|
1015
|
+
revision
|
|
1016
|
+
};
|
|
1017
|
+
if (previous?.sourceKey === sourceKey && previous.root === root && previous.revision === revision) return;
|
|
1018
|
+
if (changes?.live?.()) return;
|
|
1019
|
+
invalidateEveryRoot(queryClient, sourceKey);
|
|
1020
|
+
invalidateWorkspaceConceptQueries(queryClient, sourceKey, root);
|
|
1021
|
+
refreshResources();
|
|
1022
|
+
};
|
|
1023
|
+
$[8] = changes;
|
|
1024
|
+
$[9] = queryClient;
|
|
1025
|
+
$[10] = refreshResources;
|
|
1026
|
+
$[11] = revision;
|
|
1027
|
+
$[12] = root;
|
|
1028
|
+
$[13] = sourceKey;
|
|
1029
|
+
$[14] = t2;
|
|
1030
|
+
} else t2 = $[14];
|
|
1031
|
+
let t3;
|
|
1032
|
+
if ($[15] !== changes || $[16] !== queryClient || $[17] !== revision || $[18] !== root || $[19] !== sourceKey) {
|
|
1033
|
+
t3 = [
|
|
1034
|
+
changes,
|
|
1035
|
+
queryClient,
|
|
1036
|
+
revision,
|
|
1037
|
+
root,
|
|
1038
|
+
sourceKey
|
|
1039
|
+
];
|
|
1040
|
+
$[15] = changes;
|
|
1041
|
+
$[16] = queryClient;
|
|
1042
|
+
$[17] = revision;
|
|
1043
|
+
$[18] = root;
|
|
1044
|
+
$[19] = sourceKey;
|
|
1045
|
+
$[20] = t3;
|
|
1046
|
+
} else t3 = $[20];
|
|
1047
|
+
React.useEffect(t2, t3);
|
|
1048
|
+
let t4;
|
|
1049
|
+
if ($[21] !== changes || $[22] !== queryClient || $[23] !== refreshResources || $[24] !== root || $[25] !== sourceKey) {
|
|
1050
|
+
t4 = () => {
|
|
1051
|
+
if (!changes || !sourceKey) return;
|
|
1052
|
+
Promise.resolve().then(() => changes.start?.()).catch(_temp$1);
|
|
1053
|
+
const pendingDirectories = /* @__PURE__ */ new Set();
|
|
1054
|
+
const pendingPaths = /* @__PURE__ */ new Set();
|
|
1055
|
+
let refreshAll = false;
|
|
1056
|
+
let timer;
|
|
1057
|
+
const flush = () => {
|
|
1058
|
+
timer = void 0;
|
|
1059
|
+
if (refreshAll) {
|
|
1060
|
+
refreshAll = false;
|
|
1061
|
+
pendingDirectories.clear();
|
|
1062
|
+
pendingPaths.clear();
|
|
1063
|
+
invalidateEveryRoot(queryClient, sourceKey);
|
|
1064
|
+
invalidateWorkspaceConceptQueries(queryClient, sourceKey, root);
|
|
1065
|
+
refreshResources();
|
|
1066
|
+
return;
|
|
1067
|
+
}
|
|
1068
|
+
invalidateEveryRoot(queryClient, sourceKey, new Set(pendingDirectories));
|
|
1069
|
+
const paths_0 = [...pendingPaths];
|
|
1070
|
+
pendingDirectories.clear();
|
|
1071
|
+
pendingPaths.clear();
|
|
1072
|
+
invalidateWorkspaceConceptQueries(queryClient, sourceKey, root, paths_0);
|
|
1073
|
+
refreshResources(paths_0);
|
|
1074
|
+
};
|
|
1075
|
+
const unsubscribe = changes.subscribe((change) => {
|
|
1076
|
+
if (change.type === "unknown") refreshAll = true;
|
|
1077
|
+
else {
|
|
1078
|
+
pendingDirectories.add(workspaceDirname(change.path));
|
|
1079
|
+
pendingPaths.add(change.path);
|
|
1080
|
+
if (change.movedFrom) {
|
|
1081
|
+
pendingDirectories.add(workspaceDirname(change.movedFrom));
|
|
1082
|
+
pendingPaths.add(change.movedFrom);
|
|
1083
|
+
}
|
|
1084
|
+
}
|
|
1085
|
+
if (timer === void 0) timer = setTimeout(flush, DEFAULT_DEBOUNCE_MS);
|
|
1086
|
+
});
|
|
1087
|
+
return () => {
|
|
1088
|
+
unsubscribe();
|
|
1089
|
+
if (timer !== void 0) clearTimeout(timer);
|
|
1090
|
+
};
|
|
1091
|
+
};
|
|
1092
|
+
$[21] = changes;
|
|
1093
|
+
$[22] = queryClient;
|
|
1094
|
+
$[23] = refreshResources;
|
|
1095
|
+
$[24] = root;
|
|
1096
|
+
$[25] = sourceKey;
|
|
1097
|
+
$[26] = t4;
|
|
1098
|
+
} else t4 = $[26];
|
|
1099
|
+
let t5;
|
|
1100
|
+
if ($[27] !== changes || $[28] !== queryClient || $[29] !== root || $[30] !== sourceKey) {
|
|
1101
|
+
t5 = [
|
|
1102
|
+
changes,
|
|
1103
|
+
queryClient,
|
|
1104
|
+
root,
|
|
1105
|
+
sourceKey
|
|
1106
|
+
];
|
|
1107
|
+
$[27] = changes;
|
|
1108
|
+
$[28] = queryClient;
|
|
1109
|
+
$[29] = root;
|
|
1110
|
+
$[30] = sourceKey;
|
|
1111
|
+
$[31] = t5;
|
|
1112
|
+
} else t5 = $[31];
|
|
1113
|
+
React.useEffect(t4, t5);
|
|
1114
|
+
}
|
|
1115
|
+
function _temp$1(error) {
|
|
1116
|
+
console.error("The workspace change source failed to start.", error);
|
|
1117
|
+
}
|
|
1118
|
+
//#endregion
|
|
1119
|
+
//#region src/components/agents-sdk/WorkspaceFileTransfer.tsx
|
|
1120
|
+
/**
|
|
1121
|
+
* Moving files between a workspace and this computer, and between folders:
|
|
1122
|
+
* import a browser `File`, Save As through the native picker, hand a download
|
|
1123
|
+
* to the browser, and land a drag and drop as the Finder does.
|
|
1124
|
+
*
|
|
1125
|
+
* A view of workspace objects reads its own drops (see `WorkspaceDragAndDrop`)
|
|
1126
|
+
* and hands each one over as workspace paths or the computer's files and
|
|
1127
|
+
* folders; {@link transferIntoWorkspace} lands either one in a folder.
|
|
1128
|
+
*
|
|
1129
|
+
* Every file is capped at {@link WORKSPACE_TRANSFER_MAX_BYTES} and checked
|
|
1130
|
+
* before any bytes are buffered. Transfers never clobber silently: the caller
|
|
1131
|
+
* chooses what a name collision does, and "keep both" retries an atomic
|
|
1132
|
+
* create so a concurrent writer cannot be overwritten either.
|
|
1133
|
+
*/
|
|
1134
|
+
/** The largest file one transfer moves: 32 MiB. */
|
|
1135
|
+
const WORKSPACE_TRANSFER_MAX_BYTES = 33554432;
|
|
1136
|
+
function splitExtension(name, folder) {
|
|
1137
|
+
const dot = name.lastIndexOf(".");
|
|
1138
|
+
return folder || dot <= 0 ? [name, ""] : [name.slice(0, dot), name.slice(dot)];
|
|
1139
|
+
}
|
|
1140
|
+
/**
|
|
1141
|
+
* The first free name in `directory`, as the Finder chooses it: "name 2" for
|
|
1142
|
+
* an item that keeps both, "name copy" then "name copy 2" for a duplicate.
|
|
1143
|
+
* A file's extension stays at the end.
|
|
1144
|
+
*/
|
|
1145
|
+
async function availableWorkspacePath(source, directory, name, { folder, copy }) {
|
|
1146
|
+
const [stem, extension] = splitExtension(name, folder);
|
|
1147
|
+
const first = copy ? `${stem} copy${extension}` : name;
|
|
1148
|
+
if (!await source.exists(joinWorkspacePath(directory, first))) return joinWorkspacePath(directory, first);
|
|
1149
|
+
for (let number = 2; number < 1e4; number += 1) {
|
|
1150
|
+
const candidate = `${stem}${copy ? " copy" : ""} ${number}${extension}`;
|
|
1151
|
+
if (!await source.exists(joinWorkspacePath(directory, candidate))) return joinWorkspacePath(directory, candidate);
|
|
1152
|
+
}
|
|
1153
|
+
throw new Error(`Couldn’t find an available name for “${name}”.`);
|
|
1154
|
+
}
|
|
1155
|
+
function throwIfCancelled(signal) {
|
|
1156
|
+
if (signal?.aborted) throw new DOMException("The transfer was cancelled.", "AbortError");
|
|
1157
|
+
}
|
|
1158
|
+
function assertTransferSize(name, size) {
|
|
1159
|
+
if (size <= 33554432) return;
|
|
1160
|
+
const sizeMiB = Math.ceil(size / 1048576);
|
|
1161
|
+
throw new Error(`“${name}” is ${sizeMiB.toLocaleString()} MiB. Files are limited to 32 MiB per transfer.`);
|
|
1162
|
+
}
|
|
1163
|
+
async function boundedExportInfo(source, path) {
|
|
1164
|
+
const info = await source.stat(path);
|
|
1165
|
+
const name = workspaceBasename(path);
|
|
1166
|
+
if (!info || info.type !== "file") throw new Error(`“${name}” is no longer available.`);
|
|
1167
|
+
assertTransferSize(name, info.size);
|
|
1168
|
+
return info;
|
|
1169
|
+
}
|
|
1170
|
+
/** Reads one workspace file as a browser `File`, checking the transfer limit first. */
|
|
1171
|
+
async function readWorkspaceFile(source, path) {
|
|
1172
|
+
const info = await boundedExportInfo(source, path);
|
|
1173
|
+
const bytes = await source.readFileBytes(path);
|
|
1174
|
+
if (!bytes) throw new Error(`“${info.name}” is no longer available.`);
|
|
1175
|
+
assertTransferSize(info.name, bytes.byteLength);
|
|
1176
|
+
return new File([Uint8Array.from(bytes).buffer], info.name, {
|
|
1177
|
+
type: info.mimeType || "application/octet-stream",
|
|
1178
|
+
lastModified: info.updatedAt
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
function extensionFor(name) {
|
|
1182
|
+
const dot = name.lastIndexOf(".");
|
|
1183
|
+
return dot < 0 ? "" : name.slice(dot);
|
|
1184
|
+
}
|
|
1185
|
+
/**
|
|
1186
|
+
* Save As is a confirmed write only after close() resolves. Its portable
|
|
1187
|
+
* fallback starts a browser download and deliberately reports the weaker fact.
|
|
1188
|
+
*/
|
|
1189
|
+
async function saveWorkspaceFileAs(source, path, ownerWindow = window) {
|
|
1190
|
+
const name = workspaceBasename(path);
|
|
1191
|
+
const pickerWindow = ownerWindow;
|
|
1192
|
+
if (!pickerWindow.showSaveFilePicker) {
|
|
1193
|
+
await downloadWorkspaceFile(source, path, ownerWindow);
|
|
1194
|
+
return "download-started";
|
|
1195
|
+
}
|
|
1196
|
+
try {
|
|
1197
|
+
const extension = extensionFor(name);
|
|
1198
|
+
const handle = await pickerWindow.showSaveFilePicker({
|
|
1199
|
+
suggestedName: name,
|
|
1200
|
+
types: extension ? [{
|
|
1201
|
+
description: "Workspace file",
|
|
1202
|
+
accept: { "application/octet-stream": [extension] }
|
|
1203
|
+
}] : void 0
|
|
1204
|
+
});
|
|
1205
|
+
await boundedExportInfo(source, path);
|
|
1206
|
+
const bytes = await source.readFileBytes(path);
|
|
1207
|
+
if (!bytes) throw new Error("The file is no longer available.");
|
|
1208
|
+
assertTransferSize(name, bytes.byteLength);
|
|
1209
|
+
const writable = await handle.createWritable();
|
|
1210
|
+
await writable.write(bytes);
|
|
1211
|
+
await writable.close();
|
|
1212
|
+
return "saved";
|
|
1213
|
+
} catch (error) {
|
|
1214
|
+
if (error instanceof DOMException && error.name === "AbortError") return "cancelled";
|
|
1215
|
+
throw error;
|
|
1216
|
+
}
|
|
1217
|
+
}
|
|
1218
|
+
/** Start a browser-controlled download; this cannot confirm a disk write. */
|
|
1219
|
+
async function downloadWorkspaceFile(source, path, ownerWindow = window) {
|
|
1220
|
+
const info = await boundedExportInfo(source, path);
|
|
1221
|
+
const name = workspaceBasename(path);
|
|
1222
|
+
const bytes = await source.readFileBytes(path);
|
|
1223
|
+
if (!bytes) throw new Error(`“${name}” is no longer available.`);
|
|
1224
|
+
assertTransferSize(name, bytes.byteLength);
|
|
1225
|
+
const url = URL.createObjectURL(new Blob([Uint8Array.from(bytes).buffer], { type: info.mimeType || "application/octet-stream" }));
|
|
1226
|
+
const anchor = ownerWindow.document.createElement("a");
|
|
1227
|
+
anchor.href = url;
|
|
1228
|
+
anchor.download = name;
|
|
1229
|
+
anchor.hidden = true;
|
|
1230
|
+
ownerWindow.document.body.append(anchor);
|
|
1231
|
+
anchor.click();
|
|
1232
|
+
anchor.remove();
|
|
1233
|
+
ownerWindow.setTimeout(() => URL.revokeObjectURL(url), 0);
|
|
1234
|
+
}
|
|
1235
|
+
async function writeDroppedItem(destination, path, item, signal) {
|
|
1236
|
+
throwIfCancelled(signal);
|
|
1237
|
+
if (item.kind === "file") {
|
|
1238
|
+
assertTransferSize(item.name, item.file.size);
|
|
1239
|
+
const bytes = new Uint8Array(await item.file.arrayBuffer());
|
|
1240
|
+
throwIfCancelled(signal);
|
|
1241
|
+
if (!await destination.createFileIfAbsent(path, bytes, item.file.type || void 0)) throw new Error(`“${item.name}” appeared while it was being copied.`);
|
|
1242
|
+
return;
|
|
1243
|
+
}
|
|
1244
|
+
await destination.mkdir(path, { recursive: true });
|
|
1245
|
+
for (const child of item.children) await writeDroppedItem(destination, joinWorkspacePath(path, child.name), child, signal);
|
|
1246
|
+
}
|
|
1247
|
+
/** Reads a workspace object into the same shape a drop from the computer has. */
|
|
1248
|
+
async function readWorkspaceItem(source, path, signal) {
|
|
1249
|
+
throwIfCancelled(signal);
|
|
1250
|
+
const info = await source.stat(path);
|
|
1251
|
+
if (!info) throw new Error(`“${workspaceBasename(path)}” is no longer available.`);
|
|
1252
|
+
if (info.type !== "directory") return {
|
|
1253
|
+
kind: "file",
|
|
1254
|
+
name: info.name,
|
|
1255
|
+
file: await readWorkspaceFile(source, path)
|
|
1256
|
+
};
|
|
1257
|
+
const children = [];
|
|
1258
|
+
for (const entry of await source.readDir(path)) children.push(await readWorkspaceItem(source, entry.path, signal));
|
|
1259
|
+
return {
|
|
1260
|
+
kind: "directory",
|
|
1261
|
+
name: info.name,
|
|
1262
|
+
children
|
|
1263
|
+
};
|
|
1264
|
+
}
|
|
1265
|
+
/**
|
|
1266
|
+
* Lands a drop in `directory`, one top-level item at a time, as the Finder
|
|
1267
|
+
* does. Within one workspace a move or copy is the workspace's own `mv` or
|
|
1268
|
+
* `cp`: moving an item to the folder it is already in does nothing, and
|
|
1269
|
+
* copying it there adds "name copy", as Duplicate does. Across workspaces, and from the
|
|
1270
|
+
* computer, items are copied file by file — a folder with everything in it —
|
|
1271
|
+
* under the per-file transfer limit. A name already taken asks `ask`, whose
|
|
1272
|
+
* choice applies to that item; "cancel" stops the run.
|
|
1273
|
+
*/
|
|
1274
|
+
async function transferIntoWorkspace({ drop, destination, destinationKey, directory, operation, ask, signal }) {
|
|
1275
|
+
const sameWorkspace = drop.kind === "workspace" && drop.sourceKey === destinationKey;
|
|
1276
|
+
const names = drop.kind === "workspace" ? drop.paths.map(workspaceBasename) : drop.items.map((i) => i.name);
|
|
1277
|
+
const result = {
|
|
1278
|
+
landed: [],
|
|
1279
|
+
skipped: 0,
|
|
1280
|
+
total: names.length,
|
|
1281
|
+
cancelled: false,
|
|
1282
|
+
failure: null
|
|
1283
|
+
};
|
|
1284
|
+
for (const [index, name] of names.entries()) {
|
|
1285
|
+
if (signal?.aborted) {
|
|
1286
|
+
result.cancelled = true;
|
|
1287
|
+
break;
|
|
1288
|
+
}
|
|
1289
|
+
try {
|
|
1290
|
+
const from = drop.kind === "workspace" ? drop.paths[index] : "";
|
|
1291
|
+
const sameFolder = sameWorkspace && workspaceDirname(from) === directory;
|
|
1292
|
+
if (sameFolder && operation === "move") continue;
|
|
1293
|
+
if (sameWorkspace && isWorkspacePathWithinRoot(directory, from)) throw new Error(`“${name}” can’t be put inside itself.`);
|
|
1294
|
+
const target = joinWorkspacePath(directory, name);
|
|
1295
|
+
const choice = !await destination.exists(target) ? null : sameFolder ? "keep-both" : await ask(name);
|
|
1296
|
+
throwIfCancelled(signal);
|
|
1297
|
+
if (choice === "cancel") {
|
|
1298
|
+
result.cancelled = true;
|
|
1299
|
+
break;
|
|
1300
|
+
}
|
|
1301
|
+
if (choice === "skip") {
|
|
1302
|
+
result.skipped += 1;
|
|
1303
|
+
continue;
|
|
1304
|
+
}
|
|
1305
|
+
const item = drop.kind === "files" ? drop.items[index] : sameWorkspace ? null : await readWorkspaceItem(drop.source, from, signal);
|
|
1306
|
+
const folder = item ? item.kind === "directory" : (await destination.stat(from))?.type === "directory";
|
|
1307
|
+
let path = target;
|
|
1308
|
+
if (choice === "keep-both") path = await availableWorkspacePath(destination, directory, name, {
|
|
1309
|
+
folder,
|
|
1310
|
+
copy: sameFolder
|
|
1311
|
+
});
|
|
1312
|
+
if (choice === "replace") {
|
|
1313
|
+
if (sameWorkspace && isWorkspacePathWithinRoot(from, target)) throw new Error(`“${name}” can’t replace the folder it is in.`);
|
|
1314
|
+
await destination.rm(target, { recursive: true });
|
|
1315
|
+
}
|
|
1316
|
+
if (item) await writeDroppedItem(destination, path, item, signal);
|
|
1317
|
+
else if (operation === "move") await destination.mv(from, path, { recursive: true });
|
|
1318
|
+
else await destination.cp(from, path, { recursive: true });
|
|
1319
|
+
result.landed.push({
|
|
1320
|
+
from: drop.kind === "workspace" ? from : null,
|
|
1321
|
+
path
|
|
1322
|
+
});
|
|
1323
|
+
} catch (error) {
|
|
1324
|
+
if (error instanceof DOMException && error.name === "AbortError") result.cancelled = true;
|
|
1325
|
+
else result.failure = {
|
|
1326
|
+
name,
|
|
1327
|
+
error
|
|
1328
|
+
};
|
|
1329
|
+
break;
|
|
1330
|
+
}
|
|
1331
|
+
}
|
|
1332
|
+
return result;
|
|
1333
|
+
}
|
|
1334
|
+
const items = (count) => `${count} ${count === 1 ? "item" : "items"}`;
|
|
1335
|
+
/** "Import", "Move" or "Copy", and its past tense, for what a transfer does. */
|
|
1336
|
+
function transferVerbs({ drop, destinationKey, operation }) {
|
|
1337
|
+
if (drop.kind === "files") return ["Import", "imported"];
|
|
1338
|
+
return drop.sourceKey === destinationKey && operation === "move" ? ["Move", "moved"] : ["Copy", "copied"];
|
|
1339
|
+
}
|
|
1340
|
+
/** The status line a finished transfer leaves, including a cancel's or a failure's. */
|
|
1341
|
+
function transferSummary(result, [verb, past]) {
|
|
1342
|
+
const landed = items(result.landed.length);
|
|
1343
|
+
if (result.failure) return `${verb} stopped. ${landed} ${past} of ${result.total}.`;
|
|
1344
|
+
if (result.cancelled) return `${verb} cancelled. ${landed} ${past}.`;
|
|
1345
|
+
return `${landed} ${past}${result.skipped ? `; ${result.skipped} skipped` : ""}.`;
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Runs drops and imports into a workspace folder, one at a time, as the
|
|
1349
|
+
* Finder does: a taken name asks Replace, Keep both or Skip, and a failure is
|
|
1350
|
+
* an alert naming the item. Progress and the outcome go to `onStatus`.
|
|
1351
|
+
*/
|
|
1352
|
+
function useWorkspaceTransfer(t0) {
|
|
1353
|
+
const $ = c(58);
|
|
1354
|
+
let t1;
|
|
1355
|
+
if ($[0] !== t0) {
|
|
1356
|
+
t1 = t0 === void 0 ? {} : t0;
|
|
1357
|
+
$[0] = t0;
|
|
1358
|
+
$[1] = t1;
|
|
1359
|
+
} else t1 = $[1];
|
|
1360
|
+
const { onStatus } = t1;
|
|
1361
|
+
const queryClient = useQueryClient();
|
|
1362
|
+
const [conflict, setConflict] = React.useState(null);
|
|
1363
|
+
const [alert, setAlert] = React.useState(null);
|
|
1364
|
+
const [transferring, setTransferring] = React.useState(false);
|
|
1365
|
+
const running = React.useRef(null);
|
|
1366
|
+
let t2;
|
|
1367
|
+
if ($[2] !== onStatus || $[3] !== queryClient) {
|
|
1368
|
+
t2 = async function run(options) {
|
|
1369
|
+
if (running.current) return null;
|
|
1370
|
+
const controller = new AbortController();
|
|
1371
|
+
running.current = controller;
|
|
1372
|
+
const [verb, past] = transferVerbs(options);
|
|
1373
|
+
const total = options.drop.kind === "files" ? options.drop.items.length : options.drop.paths.length;
|
|
1374
|
+
setTransferring(true);
|
|
1375
|
+
setAlert(null);
|
|
1376
|
+
onStatus?.(`${verb === "Copy" ? "Copying" : `${verb.slice(0, -1)}ing`} ${items(total)}…`);
|
|
1377
|
+
const release = options.destination.hold?.();
|
|
1378
|
+
const result = await transferIntoWorkspace({
|
|
1379
|
+
...options,
|
|
1380
|
+
signal: controller.signal,
|
|
1381
|
+
ask: (name) => new Promise((resolve) => setConflict({
|
|
1382
|
+
name,
|
|
1383
|
+
resolve
|
|
1384
|
+
}))
|
|
1385
|
+
}).finally(release);
|
|
1386
|
+
running.current = null;
|
|
1387
|
+
setConflict(null);
|
|
1388
|
+
setTransferring(false);
|
|
1389
|
+
onStatus?.(transferSummary(result, [verb, past]));
|
|
1390
|
+
if (result.failure) setAlert({
|
|
1391
|
+
title: `“${result.failure.name}” couldn’t be ${past}`,
|
|
1392
|
+
detail: `${formatOperationError(result.failure.error)} ${items(result.landed.length)} ${past} before it stopped (${result.landed.length} of ${result.total}).`
|
|
1393
|
+
});
|
|
1394
|
+
const scoped = !result.failure;
|
|
1395
|
+
const landed = result.landed.map(_temp);
|
|
1396
|
+
const from_0 = options.operation === "move" ? result.landed.flatMap(_temp2) : [];
|
|
1397
|
+
if (options.drop.kind === "workspace" && options.drop.sourceKey !== options.destinationKey) await Promise.all([invalidateWorkspacePaths(queryClient, options.destinationKey, scoped ? landed : void 0), invalidateWorkspacePaths(queryClient, options.drop.sourceKey, scoped ? from_0 : void 0)]);
|
|
1398
|
+
else await invalidateWorkspacePaths(queryClient, options.destinationKey, scoped ? [...landed, ...from_0] : void 0);
|
|
1399
|
+
return result;
|
|
1400
|
+
};
|
|
1401
|
+
$[2] = onStatus;
|
|
1402
|
+
$[3] = queryClient;
|
|
1403
|
+
$[4] = t2;
|
|
1404
|
+
} else t2 = $[4];
|
|
1405
|
+
const run = t2;
|
|
1406
|
+
let t3;
|
|
1407
|
+
if ($[5] !== conflict) {
|
|
1408
|
+
t3 = function cancel() {
|
|
1409
|
+
running.current?.abort();
|
|
1410
|
+
conflict?.resolve("cancel");
|
|
1411
|
+
setConflict(null);
|
|
1412
|
+
};
|
|
1413
|
+
$[5] = conflict;
|
|
1414
|
+
$[6] = t3;
|
|
1415
|
+
} else t3 = $[6];
|
|
1416
|
+
const cancel = t3;
|
|
1417
|
+
let t4;
|
|
1418
|
+
if ($[7] !== conflict) {
|
|
1419
|
+
t4 = function resolve(choice) {
|
|
1420
|
+
if (!conflict) return;
|
|
1421
|
+
setConflict(null);
|
|
1422
|
+
conflict.resolve(choice);
|
|
1423
|
+
};
|
|
1424
|
+
$[7] = conflict;
|
|
1425
|
+
$[8] = t4;
|
|
1426
|
+
} else t4 = $[8];
|
|
1427
|
+
const resolve_0 = t4;
|
|
1428
|
+
const t5 = conflict !== null;
|
|
1429
|
+
let t6;
|
|
1430
|
+
if ($[9] !== resolve_0) {
|
|
1431
|
+
t6 = (open) => !open && resolve_0("cancel");
|
|
1432
|
+
$[9] = resolve_0;
|
|
1433
|
+
$[10] = t6;
|
|
1434
|
+
} else t6 = $[10];
|
|
1435
|
+
let t7;
|
|
1436
|
+
if ($[11] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1437
|
+
t7 = /* @__PURE__ */ jsx(AlertDialog.Backdrop, {});
|
|
1438
|
+
$[11] = t7;
|
|
1439
|
+
} else t7 = $[11];
|
|
1440
|
+
const t8 = conflict?.name;
|
|
1441
|
+
let t9;
|
|
1442
|
+
if ($[12] !== t8) {
|
|
1443
|
+
t9 = /* @__PURE__ */ jsxs(AlertDialog.Title, { children: [
|
|
1444
|
+
"“",
|
|
1445
|
+
t8,
|
|
1446
|
+
"” already exists"
|
|
1447
|
+
] });
|
|
1448
|
+
$[12] = t8;
|
|
1449
|
+
$[13] = t9;
|
|
1450
|
+
} else t9 = $[13];
|
|
1451
|
+
let t10;
|
|
1452
|
+
if ($[14] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1453
|
+
t10 = /* @__PURE__ */ jsx(AlertDialog.Description, { children: "Replace overwrites the one here. Keep both adds a numbered copy." });
|
|
1454
|
+
$[14] = t10;
|
|
1455
|
+
} else t10 = $[14];
|
|
1456
|
+
let t11;
|
|
1457
|
+
if ($[15] !== t9) {
|
|
1458
|
+
t11 = /* @__PURE__ */ jsxs(AlertDialog.Header, { children: [t9, t10] });
|
|
1459
|
+
$[15] = t9;
|
|
1460
|
+
$[16] = t11;
|
|
1461
|
+
} else t11 = $[16];
|
|
1462
|
+
let t12;
|
|
1463
|
+
if ($[17] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1464
|
+
t12 = /* @__PURE__ */ jsx(AlertDialog.Close, { children: "Cancel" });
|
|
1465
|
+
$[17] = t12;
|
|
1466
|
+
} else t12 = $[17];
|
|
1467
|
+
let t13;
|
|
1468
|
+
if ($[18] !== resolve_0) {
|
|
1469
|
+
t13 = /* @__PURE__ */ jsx(Button, {
|
|
1470
|
+
variant: "ghost",
|
|
1471
|
+
color: "neutral",
|
|
1472
|
+
onClick: () => resolve_0("skip"),
|
|
1473
|
+
children: "Skip"
|
|
1474
|
+
});
|
|
1475
|
+
$[18] = resolve_0;
|
|
1476
|
+
$[19] = t13;
|
|
1477
|
+
} else t13 = $[19];
|
|
1478
|
+
let t14;
|
|
1479
|
+
if ($[20] !== resolve_0) {
|
|
1480
|
+
t14 = /* @__PURE__ */ jsx(Button, {
|
|
1481
|
+
variant: "ghost",
|
|
1482
|
+
color: "neutral",
|
|
1483
|
+
onClick: () => resolve_0("keep-both"),
|
|
1484
|
+
children: "Keep both"
|
|
1485
|
+
});
|
|
1486
|
+
$[20] = resolve_0;
|
|
1487
|
+
$[21] = t14;
|
|
1488
|
+
} else t14 = $[21];
|
|
1489
|
+
let t15;
|
|
1490
|
+
if ($[22] !== resolve_0) {
|
|
1491
|
+
t15 = /* @__PURE__ */ jsx(Button, {
|
|
1492
|
+
color: "destructive",
|
|
1493
|
+
onClick: () => resolve_0("replace"),
|
|
1494
|
+
children: "Replace"
|
|
1495
|
+
});
|
|
1496
|
+
$[22] = resolve_0;
|
|
1497
|
+
$[23] = t15;
|
|
1498
|
+
} else t15 = $[23];
|
|
1499
|
+
let t16;
|
|
1500
|
+
if ($[24] !== t13 || $[25] !== t14 || $[26] !== t15) {
|
|
1501
|
+
t16 = /* @__PURE__ */ jsxs(AlertDialog.Footer, { children: [
|
|
1502
|
+
t12,
|
|
1503
|
+
t13,
|
|
1504
|
+
t14,
|
|
1505
|
+
t15
|
|
1506
|
+
] });
|
|
1507
|
+
$[24] = t13;
|
|
1508
|
+
$[25] = t14;
|
|
1509
|
+
$[26] = t15;
|
|
1510
|
+
$[27] = t16;
|
|
1511
|
+
} else t16 = $[27];
|
|
1512
|
+
let t17;
|
|
1513
|
+
if ($[28] !== t11 || $[29] !== t16) {
|
|
1514
|
+
t17 = /* @__PURE__ */ jsxs(AlertDialog.Portal, { children: [t7, /* @__PURE__ */ jsx(AlertDialog.Viewport, { children: /* @__PURE__ */ jsxs(AlertDialog.Popup, {
|
|
1515
|
+
size: "sm",
|
|
1516
|
+
children: [t11, t16]
|
|
1517
|
+
}) })] });
|
|
1518
|
+
$[28] = t11;
|
|
1519
|
+
$[29] = t16;
|
|
1520
|
+
$[30] = t17;
|
|
1521
|
+
} else t17 = $[30];
|
|
1522
|
+
let t18;
|
|
1523
|
+
if ($[31] !== t17 || $[32] !== t5 || $[33] !== t6) {
|
|
1524
|
+
t18 = /* @__PURE__ */ jsx(AlertDialog.Root, {
|
|
1525
|
+
open: t5,
|
|
1526
|
+
onOpenChange: t6,
|
|
1527
|
+
children: t17
|
|
1528
|
+
});
|
|
1529
|
+
$[31] = t17;
|
|
1530
|
+
$[32] = t5;
|
|
1531
|
+
$[33] = t6;
|
|
1532
|
+
$[34] = t18;
|
|
1533
|
+
} else t18 = $[34];
|
|
1534
|
+
const t19 = alert !== null;
|
|
1535
|
+
let t20;
|
|
1536
|
+
if ($[35] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1537
|
+
t20 = (open_0) => !open_0 && setAlert(null);
|
|
1538
|
+
$[35] = t20;
|
|
1539
|
+
} else t20 = $[35];
|
|
1540
|
+
let t21;
|
|
1541
|
+
if ($[36] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1542
|
+
t21 = /* @__PURE__ */ jsx(AlertDialog.Backdrop, {});
|
|
1543
|
+
$[36] = t21;
|
|
1544
|
+
} else t21 = $[36];
|
|
1545
|
+
const t22 = alert?.title;
|
|
1546
|
+
let t23;
|
|
1547
|
+
if ($[37] !== t22) {
|
|
1548
|
+
t23 = /* @__PURE__ */ jsx(AlertDialog.Title, { children: t22 });
|
|
1549
|
+
$[37] = t22;
|
|
1550
|
+
$[38] = t23;
|
|
1551
|
+
} else t23 = $[38];
|
|
1552
|
+
const t24 = alert?.detail;
|
|
1553
|
+
let t25;
|
|
1554
|
+
if ($[39] !== t24) {
|
|
1555
|
+
t25 = /* @__PURE__ */ jsx(AlertDialog.Description, { children: t24 });
|
|
1556
|
+
$[39] = t24;
|
|
1557
|
+
$[40] = t25;
|
|
1558
|
+
} else t25 = $[40];
|
|
1559
|
+
let t26;
|
|
1560
|
+
if ($[41] !== t23 || $[42] !== t25) {
|
|
1561
|
+
t26 = /* @__PURE__ */ jsxs(AlertDialog.Header, { children: [t23, t25] });
|
|
1562
|
+
$[41] = t23;
|
|
1563
|
+
$[42] = t25;
|
|
1564
|
+
$[43] = t26;
|
|
1565
|
+
} else t26 = $[43];
|
|
1566
|
+
let t27;
|
|
1567
|
+
if ($[44] === Symbol.for("react.memo_cache_sentinel")) {
|
|
1568
|
+
t27 = /* @__PURE__ */ jsx(AlertDialog.Footer, { children: /* @__PURE__ */ jsx(AlertDialog.Close, { children: "OK" }) });
|
|
1569
|
+
$[44] = t27;
|
|
1570
|
+
} else t27 = $[44];
|
|
1571
|
+
let t28;
|
|
1572
|
+
if ($[45] !== t26) {
|
|
1573
|
+
t28 = /* @__PURE__ */ jsxs(AlertDialog.Portal, { children: [t21, /* @__PURE__ */ jsx(AlertDialog.Viewport, { children: /* @__PURE__ */ jsxs(AlertDialog.Popup, {
|
|
1574
|
+
size: "sm",
|
|
1575
|
+
children: [t26, t27]
|
|
1576
|
+
}) })] });
|
|
1577
|
+
$[45] = t26;
|
|
1578
|
+
$[46] = t28;
|
|
1579
|
+
} else t28 = $[46];
|
|
1580
|
+
let t29;
|
|
1581
|
+
if ($[47] !== t19 || $[48] !== t28) {
|
|
1582
|
+
t29 = /* @__PURE__ */ jsx(AlertDialog.Root, {
|
|
1583
|
+
open: t19,
|
|
1584
|
+
onOpenChange: t20,
|
|
1585
|
+
children: t28
|
|
1586
|
+
});
|
|
1587
|
+
$[47] = t19;
|
|
1588
|
+
$[48] = t28;
|
|
1589
|
+
$[49] = t29;
|
|
1590
|
+
} else t29 = $[49];
|
|
1591
|
+
let t30;
|
|
1592
|
+
if ($[50] !== t18 || $[51] !== t29) {
|
|
1593
|
+
t30 = /* @__PURE__ */ jsxs(Fragment, { children: [t18, t29] });
|
|
1594
|
+
$[50] = t18;
|
|
1595
|
+
$[51] = t29;
|
|
1596
|
+
$[52] = t30;
|
|
1597
|
+
} else t30 = $[52];
|
|
1598
|
+
const dialogs = t30;
|
|
1599
|
+
let t31;
|
|
1600
|
+
if ($[53] !== cancel || $[54] !== dialogs || $[55] !== run || $[56] !== transferring) {
|
|
1601
|
+
t31 = {
|
|
1602
|
+
run,
|
|
1603
|
+
cancel,
|
|
1604
|
+
transferring,
|
|
1605
|
+
alert: setAlert,
|
|
1606
|
+
dialogs
|
|
1607
|
+
};
|
|
1608
|
+
$[53] = cancel;
|
|
1609
|
+
$[54] = dialogs;
|
|
1610
|
+
$[55] = run;
|
|
1611
|
+
$[56] = transferring;
|
|
1612
|
+
$[57] = t31;
|
|
1613
|
+
} else t31 = $[57];
|
|
1614
|
+
return t31;
|
|
1615
|
+
}
|
|
1616
|
+
function _temp2(t0) {
|
|
1617
|
+
const { from } = t0;
|
|
1618
|
+
return from === null ? [] : [from];
|
|
1619
|
+
}
|
|
1620
|
+
function _temp(t0) {
|
|
1621
|
+
const { path } = t0;
|
|
1622
|
+
return path;
|
|
1623
|
+
}
|
|
1624
|
+
//#endregion
|
|
1625
|
+
export { workspaceFileShortcut as _, saveWorkspaceFileAs as a, invalidateWorkspacePaths as c, isHiddenWorkspaceEntry as d, isInWorkspaceTrash as f, workspaceFileCommandForKey as g, useWorkspaceFileCommands as h, readWorkspaceFile as i, useWorkspaceLiveQueries as l, runWorkspaceFileOperations as m, availableWorkspacePath as n, transferIntoWorkspace as o, isWithin as p, downloadWorkspaceFile as r, useWorkspaceTransfer as s, WORKSPACE_TRANSFER_MAX_BYTES as t, WORKSPACE_TRASH as u, workspaceRenameTarget as v, workspaceTrashIsFull as y };
|