dsh-remote-vs 0.12.0 → 0.13.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/README.en.md +2 -1
- package/README.md +2 -1
- package/lib/client.js +199 -14
- package/lib/index.js +299 -11
- package/lib/p2-router-fs.js +1 -1
- package/lib/types/client/i18n.d.ts +1 -1
- package/lib/types/client/listing-requests.d.ts +45 -0
- package/lib/types/pool.d.ts +106 -0
- package/lib/types/sftp.d.ts +35 -0
- package/lib/{worlds-oj65Hic-.js → worlds-C6Xha1mQ.js} +413 -90
- package/package.json +1 -1
- package/src/client/DownloadDock.tsx +6 -2
- package/src/client/RemoteExplorer.tsx +137 -12
- package/src/client/downloads.ts +5 -1
- package/src/client/i18n.ts +6 -1
- package/src/client/listing-requests.ts +84 -0
- package/src/client/vsc/kit.tsx +30 -3
- package/src/pool.ts +377 -17
- package/src/sftp.ts +502 -108
package/README.en.md
CHANGED
|
@@ -91,7 +91,8 @@ extra configuration is needed.
|
|
|
91
91
|
|
|
92
92
|
| Capability | Notes |
|
|
93
93
|
| --- | --- |
|
|
94
|
-
| Explorer | Lazy tree +
|
|
94
|
+
| Explorer | Lazy tree + one click expands/collapses a directory + hidden-files toggle; **new: a 150 ms hover prefetches** that folder's listing (the expand paints from cache and revalidates in the background; if the prefetch is still in flight, the click waits for it and shows the loading line like a cold directory). On the Host every browse request shares **one long-lived SFTP session**, cutting a listing from two round trips to one (**the first one after a cold start or after the 2 idle minutes still pays the channel open**); context menu: new / rename / delete / copy / move / paste / find in folder / insert `@` reference / **download to local** (files stream to this machine; a directory **or a multi-selection** is archived on the remote host as one `.tar.gz` and streamed, so nothing is buffered in Host memory; a native **Save as** dialog picks the destination when the browser supports it, otherwise the browser's download folder; a bottom-right **download panel** shows live progress, allows cancel, and reports completion/failure; the search-hit menu offers it too); git status colours and folder roll-up marks |
|
|
95
|
+
| Transfer speed | Uploads/downloads use a **256 KiB × 32 in-flight window** over SSH (pipelined SFTP): single-file downloads and drag-and-drop uploads run ~8× faster than one stream, and the helper push (45 MB) uses parallel `fastPut` too; large uploads are no longer killed by a 60 s deadline (progress watchdog instead). A **download above 4 MiB gets a second dedicated SFTP channel** (one SSH channel caps its window at 2 MiB, so each extra channel adds a window): an interleaved same-process A/B measured **about 1.1–1.4×** (medians of 1.08–1.43× across samples, link-dependent; raw read probes 1.6–1.8× — the product opens two channels, not four); small files keep one channel and one less channel slot, and uploads stay single-channel (the remote write path is the bound, extra channels gain nothing) |
|
|
95
96
|
| Search | Two modes: **file names** (remote `find`) and **contents** (remote `grep`). Content mode has a scope folder, `Aa` (case) / `ab_` (whole word) / `.*` (regex), results grouped per file with match highlights, and clicking a hit jumps to that line |
|
|
96
97
|
| Source control | **Repository-folder picker** (for workspaces whose git repository lives in a sub-folder: browse the remote tree, one-click jump to any repository discovered inside the workspace, type a relative or absolute path, and see which repository each folder resolves to); changes / staged / untracked / ignored buckets; **untracked directory rows expand on click**; per-file AND **per-hunk** stage / unstage / discard (behind a confirm) / commit; branches, remotes and stash panes; sync (fetch/pull/push), with **push refspec support** (Gerrit style `HEAD:refs/for/<branch>`; empty = plain `git push`, a non-empty value is remembered); fetch/pull/push/sync get a **live output panel** (server-sent events showing git/remote output, a running clock, **cancel** that kills the remote process group, and the full log for copying afterwards; an older Host without the streaming route falls back to the one-shot result) |
|
|
97
98
|
| Session change review | The **collapsible** panel above the composer: what THIS SESSION changed (one row per file, file-type icon, `+a −b` on the right); clicking a file opens it in the remote editor with **line shading plus character-level inline diff**, `n/N ↑↓` jumps between change points, and hovering a changed line offers **Undo this change** (remote `git apply -R`). See "Session change review" below |
|
package/README.md
CHANGED
|
@@ -76,7 +76,8 @@ Host 转发(终端按 `__DSH_TRANSPORT__.streamBaseUrl` 解析地址),无
|
|
|
76
76
|
|
|
77
77
|
| 能力 | 说明 |
|
|
78
78
|
| --- | --- |
|
|
79
|
-
| 资源管理器 | 懒加载目录树 +
|
|
79
|
+
| 资源管理器 | 懒加载目录树 + 单击目录即展开/折叠 + 隐藏文件开关;**新增悬停 150 ms 预取**下一层列表(展开时先用缓存上屏、后台再校验;预取仍未返回时点开会等它,与冷启动一样显示加载行);Host 侧浏览请求复用**一条常驻 SFTP 会话**,一次列目录的往返从 2 个降到 1 个(**冷启动或空闲 2 分钟关闭后的第一次仍要开会话**);右键菜单:新建/改名/删除/复制/移动/粘贴/在此文件夹查找/插入 `@` 引用/**下载到本地**(文件流式下载、目录或**多选**在远端打包成 `.tar.gz` 流式下载,不占 Host 内存;浏览器支持时先弹**另存为**对话框选保存路径,不支持时落到默认下载目录;右下角**下载面板**显示实时进度、可取消,并提示完成/失败;搜索结果右键同样支持);git 状态色与文件夹聚合标记 |
|
|
80
|
+
| 传输性能 | 上传/下载走 SSH 的 **256 KiB × 32 并发窗口**(ssh2 pipelined SFTP):单文件下载与拖放上传比单流快约 8 倍,helper 推送(45 MB 包)同样走并行 `fastPut`;大文件上传不再被 60 秒期限误杀(改用进度看门狗)。**大于 4 MiB 的下载再开一条专用 SFTP 通道**(单条 SSH 通道的窗口上限是 2 MiB,多一条通道多一个窗口):同进程交错 A/B 实测**约 1.1–1.4×**(多次采样中位 1.08–1.43×,随链路波动;原始读探针 1.6–1.8×,产品只开两条通道,不开四条);小文件不开第二条,省一个通道槽。上传保持单通道(服务端写入是瓶颈,多通道无收益) |
|
|
80
81
|
| 搜索 | 两档:**文件名**(远端 `find`)与**内容**(远端 `grep`)。内容档带范围目录、`Aa`(大小写)/`ab_`(全字)/`.*`(正则)、结果按文件分组、命中高亮,点条目跳到该行 |
|
|
81
82
|
| 源代码管理 | **仓库目录选择器**(工作区里的 git 在子目录时用:浏览远端目录、一键跳到工作区内发现的仓库、手输相对/绝对路径,并逐目录提示会落在哪个仓库);变更/暂存/未跟踪/忽略分桶,**未跟踪目录行可点击展开**,逐文件与**逐 hunk** 暂存/还原、丢弃(带确认)、提交;分支/远程/stash 面板;同步(fetch/pull/push),**推送支持自定义 refspec**(如 Gerrit `HEAD:refs/for/<分支>`;留空 = 普通 `git push`,非空值会记住);fetch/pull/push/sync 有**实时输出面板**(SSE 流式显示 git/远端输出、运行计时、**可取消**(杀掉远端进程组)、完成后可复制完整输出;老 Host 无流式路由时自动回退到一次性结果) |
|
|
82
83
|
| 会话改动审阅 | 输入框上方的**可收纳**面板,按**会话**列出改了什么(一行一个文件、文件类型图标、右侧 `+a −b`);点文件在远程编辑器里打开并画**整行着色 + 行内字符级差异**,右上角 `n/N ↑↓` 跳改动点,悬浮改动行可**撤销**这处改动(远端 `git apply -R`)。详见下文「会话改动审阅」 |
|
package/lib/client.js
CHANGED
|
@@ -2357,6 +2357,7 @@ window.__ModuleLoader__.load({
|
|
|
2357
2357
|
"downloads.close": "关闭",
|
|
2358
2358
|
"downloads.browserDefault": "已保存到浏览器默认下载目录",
|
|
2359
2359
|
"downloads.indeterminate": "正在打包…",
|
|
2360
|
+
"downloads.sizeUnknown": "大小未知",
|
|
2360
2361
|
"downloads.tooMany": "选择项过多(最多 100 项),请改为下载所在目录",
|
|
2361
2362
|
"files.copied": "已复制",
|
|
2362
2363
|
"files.moved": "已移动",
|
|
@@ -2778,6 +2779,7 @@ window.__ModuleLoader__.load({
|
|
|
2778
2779
|
"downloads.close": "Dismiss",
|
|
2779
2780
|
"downloads.browserDefault": "Saved to the browser download folder",
|
|
2780
2781
|
"downloads.indeterminate": "Packaging…",
|
|
2782
|
+
"downloads.sizeUnknown": "size unknown",
|
|
2781
2783
|
"downloads.tooMany": "Too many entries (max 100); download the containing folder instead",
|
|
2782
2784
|
"files.copied": "Copied",
|
|
2783
2785
|
"files.moved": "Moved",
|
|
@@ -24228,6 +24230,13 @@ window.__ModuleLoader__.load({
|
|
|
24228
24230
|
})
|
|
24229
24231
|
});
|
|
24230
24232
|
}
|
|
24233
|
+
/**
|
|
24234
|
+
* Grace period after a menu appears during which a LEFT mousedown cannot close
|
|
24235
|
+
* it: the opening gesture itself may still deliver one (platform-dependent, and
|
|
24236
|
+
* a trackpad two-finger tap more often), and a panel re-render around the click
|
|
24237
|
+
* can shift where that event lands.
|
|
24238
|
+
*/
|
|
24239
|
+
const MENU_OPEN_GRACE_MS = 250;
|
|
24231
24240
|
/** Portal-rendered context menu, clamped to the viewport before paint. */
|
|
24232
24241
|
function ContextMenu(props) {
|
|
24233
24242
|
const boxRef = (0, react.useRef)(null);
|
|
@@ -24235,6 +24244,8 @@ window.__ModuleLoader__.load({
|
|
|
24235
24244
|
left: props.x,
|
|
24236
24245
|
top: props.y
|
|
24237
24246
|
});
|
|
24247
|
+
/** When this menu appeared (monotonic): see MENU_OPEN_GRACE_MS. */
|
|
24248
|
+
const openedAt = (0, react.useRef)(typeof performance === "undefined" ? 0 : performance.now());
|
|
24238
24249
|
(0, react.useLayoutEffect)(() => {
|
|
24239
24250
|
const box = boxRef.current;
|
|
24240
24251
|
if (box === null) return;
|
|
@@ -24260,22 +24271,29 @@ window.__ModuleLoader__.load({
|
|
|
24260
24271
|
});
|
|
24261
24272
|
(0, react.useEffect)(() => {
|
|
24262
24273
|
const onDown = (e) => {
|
|
24274
|
+
if (e.button === 2) return;
|
|
24275
|
+
if (performance.now() - openedAt.current < MENU_OPEN_GRACE_MS) return;
|
|
24263
24276
|
if (boxRef.current?.contains(e.target) === true) return;
|
|
24264
24277
|
onCloseRef.current();
|
|
24265
24278
|
};
|
|
24266
24279
|
const onKey = (e) => {
|
|
24267
24280
|
if (e.key === "Escape") onCloseRef.current();
|
|
24268
24281
|
};
|
|
24269
|
-
const
|
|
24282
|
+
const onResize = () => onCloseRef.current();
|
|
24283
|
+
const onScroll = (e) => {
|
|
24284
|
+
const target = e.target;
|
|
24285
|
+
if (target instanceof Node && target !== document && target !== document.documentElement && target !== document.body) return;
|
|
24286
|
+
onCloseRef.current();
|
|
24287
|
+
};
|
|
24270
24288
|
window.addEventListener("mousedown", onDown, true);
|
|
24271
24289
|
window.addEventListener("keydown", onKey);
|
|
24272
24290
|
window.addEventListener("scroll", onScroll, true);
|
|
24273
|
-
window.addEventListener("resize",
|
|
24291
|
+
window.addEventListener("resize", onResize);
|
|
24274
24292
|
return () => {
|
|
24275
24293
|
window.removeEventListener("mousedown", onDown, true);
|
|
24276
24294
|
window.removeEventListener("keydown", onKey);
|
|
24277
24295
|
window.removeEventListener("scroll", onScroll, true);
|
|
24278
|
-
window.removeEventListener("resize",
|
|
24296
|
+
window.removeEventListener("resize", onResize);
|
|
24279
24297
|
};
|
|
24280
24298
|
}, []);
|
|
24281
24299
|
if (typeof document === "undefined") return null;
|
|
@@ -39277,7 +39295,7 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
39277
39295
|
const primary = host.querySelectorAll("[class*=\"rvs-ck-\"]").length;
|
|
39278
39296
|
const fallback = host.querySelectorAll("span[class^=\"rvs-t-\"]").length;
|
|
39279
39297
|
const count = primary > 0 ? primary : fallback;
|
|
39280
|
-
console.info(`[dsh-remote-vs] build
|
|
39298
|
+
console.info(`[dsh-remote-vs] build 1031-0926 · ${source} · colored tokens: ${count} (${propsRef.current.path})`);
|
|
39281
39299
|
propsRef.current.onTokens?.(count);
|
|
39282
39300
|
};
|
|
39283
39301
|
const armFallback = () => {
|
|
@@ -44966,8 +44984,8 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
44966
44984
|
}),
|
|
44967
44985
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("span", {
|
|
44968
44986
|
className: "rvs-build",
|
|
44969
|
-
title: `dsh-remote-vs build
|
|
44970
|
-
children: "
|
|
44987
|
+
title: `dsh-remote-vs build 1031-0926`,
|
|
44988
|
+
children: "1031-0926"
|
|
44971
44989
|
}),
|
|
44972
44990
|
tokenCount !== void 0 && /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("span", {
|
|
44973
44991
|
className: "rvs-build",
|
|
@@ -45940,7 +45958,10 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
45940
45958
|
});
|
|
45941
45959
|
launch(id, controller, async (options) => {
|
|
45942
45960
|
const entry = await api.fileOp.stat(alias, path);
|
|
45943
|
-
patch(id, { directory:
|
|
45961
|
+
patch(id, entry.isDir ? { directory: true } : {
|
|
45962
|
+
directory: false,
|
|
45963
|
+
total: entry.size
|
|
45964
|
+
});
|
|
45944
45965
|
return entry.isDir ? await saveRemoteDir(alias, path, options) : await saveRemoteFile(alias, path, options);
|
|
45945
45966
|
});
|
|
45946
45967
|
return id;
|
|
@@ -45998,8 +46019,9 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
45998
46019
|
if (task.status === "cancelled") return t("downloads.cancelled");
|
|
45999
46020
|
if (task.status === "done") return task.via === "browserDefault" ? t("downloads.browserDefault") : t("downloads.done");
|
|
46000
46021
|
const loaded = formatByteCount(task.loaded);
|
|
46001
|
-
|
|
46002
|
-
return `${loaded} / ${formatByteCount(task.total)}`;
|
|
46022
|
+
const archive = task.directory || task.selection !== void 0;
|
|
46023
|
+
if (task.total !== void 0 && task.total > 0) return `${loaded} / ${formatByteCount(task.total)}`;
|
|
46024
|
+
return `${loaded} · ${t(archive ? "downloads.indeterminate" : "downloads.sizeUnknown")}`;
|
|
46003
46025
|
}
|
|
46004
46026
|
/** Percent for the bar, or `undefined` while the size is unknown (archives). */
|
|
46005
46027
|
function percentOf(task) {
|
|
@@ -46112,6 +46134,68 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
46112
46134
|
return `mv -- ${shQuote(assertAbsPath(from))} ${name === void 0 ? `${shQuote(assertAbsPath(intoDir))}/` : shQuote(joinAbs(intoDir, name))}`;
|
|
46113
46135
|
}
|
|
46114
46136
|
//#endregion
|
|
46137
|
+
//#region src/client/listing-requests.ts
|
|
46138
|
+
var ListingRequests = class {
|
|
46139
|
+
keyOf;
|
|
46140
|
+
load;
|
|
46141
|
+
store;
|
|
46142
|
+
inFlight = /* @__PURE__ */ new Map();
|
|
46143
|
+
/** Newest request per key: only its answer may be stored. */
|
|
46144
|
+
newest = /* @__PURE__ */ new Map();
|
|
46145
|
+
sequence = 0;
|
|
46146
|
+
/**
|
|
46147
|
+
* @param keyOf - cache key for one directory (host alias + absolute path).
|
|
46148
|
+
* @param load - performs the listing.
|
|
46149
|
+
* @param store - applies a listing whose request is still the newest for its
|
|
46150
|
+
* key; the component writes it into the listing cache.
|
|
46151
|
+
*/
|
|
46152
|
+
constructor(keyOf, load, store) {
|
|
46153
|
+
this.keyOf = keyOf;
|
|
46154
|
+
this.load = load;
|
|
46155
|
+
this.store = store;
|
|
46156
|
+
}
|
|
46157
|
+
/**
|
|
46158
|
+
* List one directory, or join the request a hover prefetch already started.
|
|
46159
|
+
*
|
|
46160
|
+
* @param dir - absolute remote directory.
|
|
46161
|
+
* @param revision - the explorer revision this read is meant to reflect. A
|
|
46162
|
+
* request issued at another revision is never joined.
|
|
46163
|
+
* @param fresh - start a new request even when one is in flight (a
|
|
46164
|
+
* revalidation after a write, where joining the older read would be wrong).
|
|
46165
|
+
*/
|
|
46166
|
+
request(dir, revision, fresh = false) {
|
|
46167
|
+
const key = this.keyOf(dir);
|
|
46168
|
+
const running = this.inFlight.get(key);
|
|
46169
|
+
if (!fresh && running !== void 0 && running.revision === revision) return running.promise;
|
|
46170
|
+
const sequence = this.sequence += 1;
|
|
46171
|
+
const promise = this.load(dir);
|
|
46172
|
+
const entry = {
|
|
46173
|
+
promise,
|
|
46174
|
+
revision
|
|
46175
|
+
};
|
|
46176
|
+
this.inFlight.set(key, entry);
|
|
46177
|
+
this.newest.set(key, sequence);
|
|
46178
|
+
const settle = () => {
|
|
46179
|
+
if (this.inFlight.get(key) === entry) this.inFlight.delete(key);
|
|
46180
|
+
};
|
|
46181
|
+
promise.then((entries) => {
|
|
46182
|
+
if (this.newest.get(key) === sequence) {
|
|
46183
|
+
this.newest.delete(key);
|
|
46184
|
+
this.store(key, entries);
|
|
46185
|
+
}
|
|
46186
|
+
settle();
|
|
46187
|
+
}, () => {
|
|
46188
|
+
if (this.newest.get(key) === sequence) this.newest.delete(key);
|
|
46189
|
+
settle();
|
|
46190
|
+
});
|
|
46191
|
+
return promise;
|
|
46192
|
+
}
|
|
46193
|
+
/** Whether a listing for `dir` is on the wire. */
|
|
46194
|
+
busy(dir) {
|
|
46195
|
+
return this.inFlight.has(this.keyOf(dir));
|
|
46196
|
+
}
|
|
46197
|
+
};
|
|
46198
|
+
//#endregion
|
|
46115
46199
|
//#region src/client/upload-plan.ts
|
|
46116
46200
|
/**
|
|
46117
46201
|
* Upload planning: what a drop (or a picked file list) turns into on the remote
|
|
@@ -46441,6 +46525,12 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
46441
46525
|
/** How many directory listings stay cached; each one is a whole directory. */
|
|
46442
46526
|
const LISTING_CACHE_KEEP = 50;
|
|
46443
46527
|
/**
|
|
46528
|
+
* Hover intent before a directory's listing is prefetched: long enough that
|
|
46529
|
+
* sweeping the pointer across the tree does not fire a request per row, short
|
|
46530
|
+
* enough that arriving at a folder and clicking it finds the listing warm.
|
|
46531
|
+
*/
|
|
46532
|
+
const PREFETCH_HOVER_MS = 150;
|
|
46533
|
+
/**
|
|
46444
46534
|
* Insert one listing as the newest, so "the first key is the oldest" stays
|
|
46445
46535
|
* true and `trimListings` can evict from the front.
|
|
46446
46536
|
*/
|
|
@@ -46478,6 +46568,16 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
46478
46568
|
const { t, alias, root, repoRoot, marks } = store;
|
|
46479
46569
|
const ctx = store.ctx;
|
|
46480
46570
|
const [listings, setListings] = (0, react.useState)({});
|
|
46571
|
+
/**
|
|
46572
|
+
* The same listings, readable synchronously. `prefetchDir` has to answer "is
|
|
46573
|
+
* this already cached?" at pointer time, and a state value would be one render
|
|
46574
|
+
* behind (asking again for a directory that was just listed).
|
|
46575
|
+
*/
|
|
46576
|
+
const listingsRef = (0, react.useRef)({});
|
|
46577
|
+
/** Set false on unmount so a listing that lands late does not touch state. */
|
|
46578
|
+
const alive = (0, react.useRef)(true);
|
|
46579
|
+
/** Hover-intent timer for prefetch; one pointer means one candidate. */
|
|
46580
|
+
const prefetchTimer = (0, react.useRef)(void 0);
|
|
46481
46581
|
const [loading, setLoading] = (0, react.useState)(/* @__PURE__ */ new Set());
|
|
46482
46582
|
const [expanded, setExpanded] = (0, react.useState)(/* @__PURE__ */ new Set());
|
|
46483
46583
|
const [selected, setSelected] = (0, react.useState)(/* @__PURE__ */ new Set());
|
|
@@ -46508,6 +46608,32 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
46508
46608
|
const chatTarget = useRemoteChatTarget(store.ctx);
|
|
46509
46609
|
const viewedAliasPath = store.workspace !== void 0 ? store.aliasPaths[store.workspace.id] : void 0;
|
|
46510
46610
|
const chatEnabled = chatTarget.sessionId !== void 0 && chatTarget.sessionWorkspacePath !== void 0 && viewedAliasPath !== void 0 && sameLocalDir(chatTarget.sessionWorkspacePath, viewedAliasPath);
|
|
46611
|
+
/**
|
|
46612
|
+
* The revision this component's listing traffic is labelled with.
|
|
46613
|
+
*
|
|
46614
|
+
* A ref, not a hook dependency: a revision bump must not re-create `loadDir`
|
|
46615
|
+
* (the reveal/refresh effects list it, and their identity churn would re-run
|
|
46616
|
+
* both). Only the request-time check in `ListingRequests` reads it. It is
|
|
46617
|
+
* written during render on purpose (an idempotent latest-value ref): an
|
|
46618
|
+
* effect-synced ref is one commit stale, so a read triggered from the same
|
|
46619
|
+
* commit as the write could still be labelled with the previous revision.
|
|
46620
|
+
*/
|
|
46621
|
+
const revisionRef = (0, react.useRef)(store.revision);
|
|
46622
|
+
revisionRef.current = store.revision;
|
|
46623
|
+
/** Current binding, for the late-answer guard below (the memo is per alias). */
|
|
46624
|
+
const aliasRef = (0, react.useRef)(alias);
|
|
46625
|
+
/**
|
|
46626
|
+
* The in-flight listing reads (see `ListingRequests`).
|
|
46627
|
+
*
|
|
46628
|
+
* A hover prefetch and the click that follows it are the same request, and so
|
|
46629
|
+
* are a double click and the reveal chain's level: without the shared map each
|
|
46630
|
+
* one opened its own SFTP listing for the same path. A request is only shared
|
|
46631
|
+
* when it started at the same revision, so a read AFTER a write never gets an
|
|
46632
|
+
* answer issued before it.
|
|
46633
|
+
*/
|
|
46634
|
+
const listingsApi = (0, react.useMemo)(() => new ListingRequests((dir) => dirKey(alias, dir), (dir) => api.fileOp.list(alias, dir), (key, entries) => {
|
|
46635
|
+
if (alive.current && aliasRef.current === alias) setListings((prev) => withListing(prev, key, entries));
|
|
46636
|
+
}), [alias]);
|
|
46511
46637
|
const loadDir = (0, react.useCallback)(async (dir, force = false) => {
|
|
46512
46638
|
if (alias === "") return;
|
|
46513
46639
|
const key = dirKey(alias, dir);
|
|
@@ -46517,8 +46643,7 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
46517
46643
|
return next;
|
|
46518
46644
|
});
|
|
46519
46645
|
try {
|
|
46520
|
-
|
|
46521
|
-
setListings((prev) => withListing(prev, key, entries));
|
|
46646
|
+
await listingsApi.request(dir, revisionRef.current, force);
|
|
46522
46647
|
} catch (error) {
|
|
46523
46648
|
toast(error instanceof Error ? error.message : String(error), true);
|
|
46524
46649
|
} finally {
|
|
@@ -46528,7 +46653,35 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
46528
46653
|
return next;
|
|
46529
46654
|
});
|
|
46530
46655
|
}
|
|
46531
|
-
}, [alias]);
|
|
46656
|
+
}, [alias, listingsApi]);
|
|
46657
|
+
/**
|
|
46658
|
+
* Warm the listing cache for a directory the pointer is resting on.
|
|
46659
|
+
*
|
|
46660
|
+
* The open itself still revalidates through `loadDir` (the explorer must show
|
|
46661
|
+
* writes made elsewhere), but with the rows already in memory the expand
|
|
46662
|
+
* paints immediately instead of showing a loading line for one round trip.
|
|
46663
|
+
* Speculative by nature, so a failure is not a toast — the real listing, when
|
|
46664
|
+
* the user opens it, still explains itself.
|
|
46665
|
+
*/
|
|
46666
|
+
const prefetchDir = (0, react.useCallback)((dir) => {
|
|
46667
|
+
if (alias === "") return;
|
|
46668
|
+
const key = dirKey(alias, dir);
|
|
46669
|
+
if (listingsRef.current[key] !== void 0) return;
|
|
46670
|
+
if (listingsApi.busy(dir)) return;
|
|
46671
|
+
listingsApi.request(dir, revisionRef.current).catch(() => void 0);
|
|
46672
|
+
}, [alias, listingsApi]);
|
|
46673
|
+
/** Hover intent: prefetch the row under the pointer after a short rest. */
|
|
46674
|
+
const hoverDir = (path) => {
|
|
46675
|
+
if (prefetchTimer.current !== void 0) {
|
|
46676
|
+
window.clearTimeout(prefetchTimer.current);
|
|
46677
|
+
prefetchTimer.current = void 0;
|
|
46678
|
+
}
|
|
46679
|
+
if (path === void 0) return;
|
|
46680
|
+
prefetchTimer.current = window.setTimeout(() => {
|
|
46681
|
+
prefetchTimer.current = void 0;
|
|
46682
|
+
prefetchDir(path);
|
|
46683
|
+
}, PREFETCH_HOVER_MS);
|
|
46684
|
+
};
|
|
46532
46685
|
/**
|
|
46533
46686
|
* "Show this folder in the tree" — raised by a search result's menu.
|
|
46534
46687
|
*
|
|
@@ -46575,6 +46728,10 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
46575
46728
|
loadDir
|
|
46576
46729
|
]);
|
|
46577
46730
|
const revision = store.revision;
|
|
46731
|
+
/** Keep the late-answer guard current for the NEXT commit's callbacks. */
|
|
46732
|
+
(0, react.useEffect)(() => {
|
|
46733
|
+
aliasRef.current = alias;
|
|
46734
|
+
}, [alias]);
|
|
46578
46735
|
/**
|
|
46579
46736
|
* The binding this tree was listed from and the revision it was listed at.
|
|
46580
46737
|
* A parked panel stays MOUNTED behind `display:none`, so a write made off
|
|
@@ -46615,6 +46772,18 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
46615
46772
|
alias,
|
|
46616
46773
|
listings
|
|
46617
46774
|
]);
|
|
46775
|
+
/** Keep the synchronous cache view in step (prefetch reads it at pointer time). */
|
|
46776
|
+
(0, react.useEffect)(() => {
|
|
46777
|
+
listingsRef.current = listings;
|
|
46778
|
+
}, [listings]);
|
|
46779
|
+
/** A hover prefetch / late listing must not fire or paint after the panel is gone. */
|
|
46780
|
+
(0, react.useEffect)(() => {
|
|
46781
|
+
alive.current = true;
|
|
46782
|
+
return () => {
|
|
46783
|
+
alive.current = false;
|
|
46784
|
+
if (prefetchTimer.current !== void 0) window.clearTimeout(prefetchTimer.current);
|
|
46785
|
+
};
|
|
46786
|
+
}, []);
|
|
46618
46787
|
const rowsOf = (0, react.useCallback)((dir) => {
|
|
46619
46788
|
const rows = listings[dirKey(alias, dir)];
|
|
46620
46789
|
if (rows === void 0) return void 0;
|
|
@@ -47440,7 +47609,17 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
47440
47609
|
onDoubleClick: () => {
|
|
47441
47610
|
if (!entry.isDir) store.openFile(entry.path);
|
|
47442
47611
|
},
|
|
47443
|
-
|
|
47612
|
+
onMouseEnter: () => {
|
|
47613
|
+
if (entry.isDir) hoverDir(entry.path);
|
|
47614
|
+
},
|
|
47615
|
+
onMouseLeave: () => hoverDir(void 0),
|
|
47616
|
+
onPointerDown: (e) => {
|
|
47617
|
+
if (e.button === 2) openMenu(e, entry);
|
|
47618
|
+
},
|
|
47619
|
+
onContextMenu: (e) => {
|
|
47620
|
+
e.preventDefault();
|
|
47621
|
+
if (menu.menu === void 0) openMenu(e, entry);
|
|
47622
|
+
},
|
|
47444
47623
|
onDragStart: (e) => {
|
|
47445
47624
|
dragPaths.current = selected.has(entry.path) ? [...selected] : [entry.path];
|
|
47446
47625
|
e.dataTransfer.effectAllowed = "move";
|
|
@@ -47667,7 +47846,13 @@ Integer Float Double Long Int32 Int64 Uint8 uint32_t int32_t uint64_t int64_t si
|
|
|
47667
47846
|
onDrop: (e) => handleDrop(root, e),
|
|
47668
47847
|
children: /* @__PURE__ */ (0, react_jsx_runtime.jsxs)("div", {
|
|
47669
47848
|
className: "rvs-tree",
|
|
47670
|
-
|
|
47849
|
+
onPointerDown: (e) => {
|
|
47850
|
+
if (e.button === 2) openMenu(e, void 0);
|
|
47851
|
+
},
|
|
47852
|
+
onContextMenu: (e) => {
|
|
47853
|
+
e.preventDefault();
|
|
47854
|
+
if (menu.menu === void 0) openMenu(e, void 0);
|
|
47855
|
+
},
|
|
47671
47856
|
children: [
|
|
47672
47857
|
/* @__PURE__ */ (0, react_jsx_runtime.jsx)("div", {
|
|
47673
47858
|
className: "rvs-empty",
|