@dsh-xhl/dsh-file-explorer 0.1.6 → 0.1.7

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.
Files changed (3) hide show
  1. package/README.md +6 -1
  2. package/lib/client.js +33 -23
  3. package/package.json +2 -2
package/README.md CHANGED
@@ -8,7 +8,7 @@
8
8
  - **Hero / 新建会话页 ButtonGroup**:同一浮层位置由插件定位到会话列右上角(hero 阶段显示,有记录后由标题栏图标接管,无重复);hero 上为**左主按钮 + 右下拉**的组合:
9
9
  - **编辑器**(默认):点击打开文件预览 / 编辑弹窗(Ctrl+P 亦可)
10
10
  - **文件夹**:点击直接打开会话工作区所在的**系统文件夹**(Windows `explorer` / macOS `open` / Linux `xdg-open`)
11
- - **VSCode**:点击用 `code` 命令行在 **VS Code** 中打开会话工作区(自动探测安装位置 / PATH;未安装则该项自动隐藏)
11
+ - **VSCode**:点击用 `code` 命令行在 **VS Code** 中打开会话工作区(自动探测安装位置 / PATH;宿主明确报告未安装时该项自动隐藏,探测请求本身失败则保持可见并退避重试)
12
12
  - 选择记忆在 localStorage,点击后底部提示确认打开的路径;下拉选中某项会先切换默认打开方式,随后立即执行对应的打开动作
13
13
  - 纯插件实现,不改动框架代码(详见 `docs/hero-filex-button.md`)
14
14
  - **对话内点击文件 → 编辑器预览**:聊天里的文件路径链接(工具行、产物行、正文提及)默认用系统程序打开;插件拦截 `remote.session.openWorkspacePath` 与 `workspaces.openPath` 两条通道,改为在编辑器弹窗中预览(目录或 cwd 外的路径仍落回系统打开)
@@ -44,6 +44,11 @@ pnpm install
44
44
  pnpm build # lib/index.js(host)+ lib/client.js(client bundle,CodeMirror 内联)
45
45
  ```
46
46
 
47
+ > 构建采用**原地覆盖**(不再先删除 `lib/`)。宿主半在进程启动时载入内存,而 profile
48
+ > 若 link 到本工作区则会直读磁盘:构建中途清空目录会让 HMR 读到空 bundle,导致
49
+ > `/filex` 路由与客户端 import 瞬时失败(表现为 `unknown filex API method ...`)。
50
+ > 改动客户端后无需重启,宿主半的改动需重启 DSH 进程。
51
+
47
52
  ## 安装 / 挂载(desktop profile 示例)
48
53
 
49
54
  ```bash
package/lib/client.js CHANGED
@@ -38242,31 +38242,41 @@ window.__ModuleLoader__.load({
38242
38242
  } catch {}
38243
38243
  }
38244
38244
  /**
38245
- * Probe the host once per activation for VS Code availability and hide the
38246
- * VSCode option (falling back to the editor) when it is missing the user
38247
- * explicitly wants the entry hidden rather than shown-but-broken.
38248
- */
38249
- function probeVscode() {
38245
+ * Probe the host for VS Code availability and hide the VSCode option when the
38246
+ * host positively reports it missing (a `{ vscode: false }` answer), so the
38247
+ * entry never shows as broken when the CLI is genuinely absent.
38248
+ *
38249
+ * A FAILED probe is not an answer: the host may simply be mid-reload (its
38250
+ * routes vanish for a moment while the bundle is rewritten), and latching
38251
+ * "unavailable" then would hide VSCode for the rest of the page's life over a
38252
+ * transient hiccup. Failures therefore keep the option visible and retry a few
38253
+ * times; picking it without a CLI still surfaces the host's own
38254
+ * 「未找到 VS Code 命令行工具」 error, which is the honest report.
38255
+ */
38256
+ function probeVscode(attempt = 0) {
38250
38257
  api.fsCapabilities().then((result) => {
38251
- store = {
38252
- ...store,
38253
- vscode: result.vscode
38254
- };
38255
- if (!result.vscode && store.mode === "vscode") store = {
38256
- ...store,
38257
- mode: "editor"
38258
- };
38259
- emit();
38258
+ if (result.vscode === false) {
38259
+ store = {
38260
+ ...store,
38261
+ vscode: false
38262
+ };
38263
+ if (store.mode === "vscode") store = {
38264
+ ...store,
38265
+ mode: "editor"
38266
+ };
38267
+ emit();
38268
+ return;
38269
+ }
38270
+ if (!store.vscode) {
38271
+ store = {
38272
+ ...store,
38273
+ vscode: true
38274
+ };
38275
+ emit();
38276
+ }
38260
38277
  }).catch(() => {
38261
- store = {
38262
- ...store,
38263
- vscode: false
38264
- };
38265
- if (store.mode === "vscode") store = {
38266
- ...store,
38267
- mode: "editor"
38268
- };
38269
- emit();
38278
+ if (attempt >= 4) return;
38279
+ window.setTimeout(() => probeVscode(attempt + 1), 1e3 * (attempt + 1));
38270
38280
  });
38271
38281
  }
38272
38282
  const MODE_ITEMS = [
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dsh-xhl/dsh-file-explorer",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "DSH 外部编译型插件:工作区文件预览 / 编辑(CodeMirror 6 编辑器 + 文件树 + 全文搜索 + Markdown/HTML/图片/PDF 预览)。移植自同目录下的动态 Cordis 插件版本。",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
@@ -41,7 +41,7 @@
41
41
  "README.md"
42
42
  ],
43
43
  "scripts": {
44
- "build": "node -e \"fs.rmSync('lib',{recursive:true,force:true})\" && tsc -p tsconfig.build.json && tsdown",
44
+ "build": "tsc -p tsconfig.build.json && tsdown",
45
45
  "typecheck": "tsc --noEmit",
46
46
  "bundle": "tsdown",
47
47
  "prepare": "tsdown"