@xrxs-ai/dsh-xrxs-plugins-store 0.3.3 → 0.3.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/client.js CHANGED
@@ -848,14 +848,8 @@ function InstallButton(props) {
848
848
  size: props.size ?? "medium",
849
849
  variant,
850
850
  disabled: phase === "installing",
851
- title: phase === "installing" ? `${verb}\u4E2D\u2026` : compat.ok === null ? "\u517C\u5BB9\u6027\u672A\u77E5:\u65E0\u6CD5\u8BFB\u53D6\u672C\u673A dsh \u7248\u672C" : `${verb} ${props.pluginName}@${props.version}`,
852
- onClick: () => {
853
- if (compat.ok === null) {
854
- props.onToast("info", "\u65E0\u6CD5\u786E\u8BA4\u4E0E\u672C\u673A dsh \u7248\u672C\u7684\u517C\u5BB9\u6027");
855
- return;
856
- }
857
- setPhase("confirm");
858
- },
851
+ title: phase === "installing" ? `${verb}\u4E2D\u2026` : compat.ok === null ? `\u517C\u5BB9\u6027\u672A\u77E5(\u8BFB\u53D6\u672C\u673A dsh \u7248\u672C\u5931\u8D25),\u4ECD\u53EF${verb} ${props.pluginName}@${props.version}` : `${verb} ${props.pluginName}@${props.version}`,
852
+ onClick: () => setPhase("confirm"),
859
853
  children: phase === "installing" ? `${verb}\u4E2D\u2026` : verb
860
854
  }
861
855
  ) }),
@@ -1,7 +1,7 @@
1
1
  import { existsSync, readFileSync } from 'node:fs';
2
2
  import { createRequire } from 'node:module';
3
3
  import { homedir } from 'node:os';
4
- import { basename, join } from 'node:path';
4
+ import { basename, dirname, join } from 'node:path';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  export function detectDshHome(env = process.env, home = homedir()) {
7
7
  const explicit = env.DSH_HOME?.trim();
@@ -13,18 +13,56 @@ export function detectDshHome(env = process.env, home = homedir()) {
13
13
  return { dshHome: xsh, kind: 'cinlyn' };
14
14
  return { dshHome: join(home, '.dsh'), kind: 'dsh' };
15
15
  }
16
- /** 读取宿主应用内置 @deepseek-ai/dsh 版本。
17
- * 双宿主上的可读路径是实现期待核实项(设计文档 §7 风险 2),读不到一律返回 null。 */
18
- function readHostDshVersion() {
16
+ /** @deepseek-ai/dsh 的包名(宿主内置运行时,版本用于兼容性判定)。 */
17
+ const DSH_PACKAGE = '@deepseek-ai/dsh';
18
+ /**
19
+ * 枚举宿主内置 @deepseek-ai/dsh/package.json 的候选路径。
20
+ *
21
+ * 插件装在 <DSH_HOME>/profiles/<name>/node_modules 下,从插件目录向上解析根本到不了
22
+ * 宿主的 app/node_modules(mac 与 Windows 都一样);旧实现因此几乎恒为 null,UI 显示
23
+ * 「兼容性未知」。这里优先按 Electron 的 resources 目录找:
24
+ * - macOS: <App>.app/Contents/Resources/app[.asar]/node_modules/...
25
+ * - Windows: <安装目录>/resources/app[.asar]/node_modules/...
26
+ * 再保留从插件模块解析的兜底(某些 profile 会把 dsh 提升到可达位置)。
27
+ */
28
+ function dshManifestCandidates() {
29
+ const paths = new Set();
30
+ const add = (resources) => {
31
+ if (resources === undefined || resources === '')
32
+ return;
33
+ for (const appDir of ['app', 'app.asar', 'app.asar.unpacked']) {
34
+ paths.add(join(resources, appDir, 'node_modules', DSH_PACKAGE, 'package.json'));
35
+ }
36
+ };
37
+ const resourcesPath = process.resourcesPath;
38
+ if (typeof resourcesPath === 'string')
39
+ add(resourcesPath);
40
+ // resourcesPath 不可用时按可执行文件推:Windows 在安装根目录,macOS 在 Contents/MacOS
41
+ const execDir = dirname(process.execPath);
42
+ add(join(execDir, 'resources'));
43
+ add(join(execDir, '..', 'Resources'));
44
+ add(join(execDir, '..', '..', 'Resources'));
19
45
  try {
20
- const req = createRequire(import.meta.url);
21
- const pkgPath = req.resolve('@deepseek-ai/dsh/package.json');
22
- const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
23
- return typeof pkg.version === 'string' ? pkg.version : null;
46
+ paths.add(createRequire(import.meta.url).resolve(`${DSH_PACKAGE}/package.json`));
24
47
  }
25
48
  catch {
26
- return null;
49
+ // 解析不到就只用上面的物理路径
50
+ }
51
+ return [...paths];
52
+ }
53
+ /** 读取宿主应用内置 @deepseek-ai/dsh 版本;所有候选都读不到时为 null。 */
54
+ function readHostDshVersion() {
55
+ for (const pkgPath of dshManifestCandidates()) {
56
+ try {
57
+ const pkg = JSON.parse(readFileSync(pkgPath, 'utf8'));
58
+ if (pkg.name === DSH_PACKAGE && typeof pkg.version === 'string' && pkg.version !== '')
59
+ return pkg.version;
60
+ }
61
+ catch {
62
+ // 路径不存在/无权限/asar 结构不符:继续下一个候选
63
+ }
27
64
  }
65
+ return null;
28
66
  }
29
67
  /** file:URL → 文件路径;失败(非 file URL 等)回落原样字符串再试。 */
30
68
  function moduleUrlToPathSafe(moduleUrl) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@xrxs-ai/dsh-xrxs-plugins-store",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "DSH 私有插件市场插件(静态持久 bundle,双 face)",
5
5
  "type": "module",
6
6
  "license": "MIT",
@@ -25,6 +25,12 @@
25
25
  "icon.svg",
26
26
  "locale"
27
27
  ],
28
+ "scripts": {
29
+ "build": "tsc -p tsconfig.json && node scripts/build-client.mjs",
30
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json --noEmit",
31
+ "test": "node --test tests/*.test.ts",
32
+ "prepack": "pnpm run build"
33
+ },
28
34
  "dependencies": {
29
35
  "@deepseek-ai/schemastery": "^3.18.2",
30
36
  "yaml": "^2.9.1"
@@ -62,10 +68,5 @@
62
68
  "repository": {
63
69
  "type": "git",
64
70
  "url": "https://code.qijiayoudao.net/ai/dsh/dsh-xrxs-plugins-store.git"
65
- },
66
- "scripts": {
67
- "build": "tsc -p tsconfig.json && node scripts/build-client.mjs",
68
- "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.client.json --noEmit",
69
- "test": "node --test tests/*.test.ts"
70
71
  }
71
- }
72
+ }