@linxin666/dsh-client-ui-plugin-manager 0.2.2 → 0.2.4

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/index.js CHANGED
@@ -668,16 +668,18 @@ function capture(chunk, buffer) {
668
668
  * @param binary - the dsh CLI path found by {@link findDshBinary}.
669
669
  * @param platform - process platform (test seam).
670
670
  * @param localNodeExists - existence probe (test seam).
671
+ * @param binJsExists - existence probe for the resolved bin script (test seam).
671
672
  * @returns the executable and the argument prefix to run the dsh bin script.
672
673
  */
673
- function dshSpawnCommand(binary, platform = process.platform, localNodeExists = existsSync) {
674
+ function dshSpawnCommand(binary, platform = process.platform, localNodeExists = existsSync, binJsExists = existsSync) {
674
675
  if (platform !== "win32") return {
675
676
  command: binary,
676
677
  argsPrefix: []
677
678
  };
678
679
  const dir = win32.dirname(binary);
679
680
  const localNode = win32.join(dir, "node.exe");
680
- const binJs = win32.join(dir, "node_modules", "@deepseek-ai", "dsh", "lib", "bin.js");
681
+ const binJsCandidates = [win32.join(dir, "node_modules", "@deepseek-ai", "dsh", "lib", "bin.js"), win32.join(dir, "..", "@deepseek-ai", "dsh", "lib", "bin.js")];
682
+ const binJs = binJsCandidates.find((candidate) => binJsExists(candidate)) ?? binJsCandidates[0];
681
683
  return {
682
684
  command: localNodeExists(localNode) ? localNode : process.execPath,
683
685
  argsPrefix: [binJs]
@@ -750,9 +752,21 @@ var CliGateway = class {
750
752
  this.env = env;
751
753
  this.deps = deps;
752
754
  }
753
- /** Chain one mutation onto the queue; a settled job never blocks the next one. */
755
+ /**
756
+ * Run one profile mutation after every mutation already queued. The returned
757
+ * promise keeps the task's own result or rejection, while the queue tail is
758
+ * always recovered so one failed write cannot block later work. Routes that
759
+ * edit profile files directly must use this seam so they cannot overlap the
760
+ * CLI install/remove writer.
761
+ */
762
+ withMutationLock(task) {
763
+ const result = this.queue.then(task);
764
+ this.queue = result.then(() => void 0, () => void 0);
765
+ return result;
766
+ }
767
+ /** Chain one fire-and-forget CLI mutation onto the shared queue. */
754
768
  enqueue(task) {
755
- this.queue = this.queue.then(task).catch(() => {});
769
+ this.withMutationLock(task).catch(() => {});
756
770
  }
757
771
  /** The dsh CLI path, through the test seam when present. */
758
772
  binary() {
@@ -1296,15 +1310,17 @@ function makeGatewayRoutes(deps) {
1296
1310
  sendJson(res, 400, { error: unsafeTarget });
1297
1311
  return;
1298
1312
  }
1299
- const patchText = await readPatchText(facts.patchPath);
1300
- const entries = (await readProfileManifest(facts.packageJsonPath)).dependencies[target] !== void 0 ? await claimedEntryRowsOf(facts, target) : [{
1301
- id: target,
1302
- name: target
1303
- }];
1304
- let next = patchText;
1305
- for (const entry of entries) next = setRowEnabled(next, facts.patchPath, entry.id, entry.name, enabled);
1306
- if (next !== patchText) await writePatchAtomic(facts.patchPath, next);
1307
- sendJson(res, 200, { plugin: (await snapshotGateway(facts, next)).plugins.find((item) => item.id === target) ?? {
1313
+ sendJson(res, 200, { plugin: await gateway.withMutationLock(async () => {
1314
+ const patchText = await readPatchText(facts.patchPath);
1315
+ const entries = (await readProfileManifest(facts.packageJsonPath)).dependencies[target] !== void 0 ? await claimedEntryRowsOf(facts, target) : [{
1316
+ id: target,
1317
+ name: target
1318
+ }];
1319
+ let next = patchText;
1320
+ for (const entry of entries) next = setRowEnabled(next, facts.patchPath, entry.id, entry.name, enabled);
1321
+ if (next !== patchText) await writePatchAtomic(facts.patchPath, next);
1322
+ return (await snapshotGateway(facts, next)).plugins.find((item) => item.id === target);
1323
+ }) ?? {
1308
1324
  id: target,
1309
1325
  name: target,
1310
1326
  version: "unknown",
@@ -48,9 +48,10 @@ export declare function findDshBinary(env?: NodeJS.ProcessEnv, platform?: string
48
48
  * @param binary - the dsh CLI path found by {@link findDshBinary}.
49
49
  * @param platform - process platform (test seam).
50
50
  * @param localNodeExists - existence probe (test seam).
51
+ * @param binJsExists - existence probe for the resolved bin script (test seam).
51
52
  * @returns the executable and the argument prefix to run the dsh bin script.
52
53
  */
53
- export declare function dshSpawnCommand(binary: string, platform?: string, localNodeExists?: (path: string) => boolean): {
54
+ export declare function dshSpawnCommand(binary: string, platform?: string, localNodeExists?: (path: string) => boolean, binJsExists?: (path: string) => boolean): {
54
55
  command: string;
55
56
  argsPrefix: string[];
56
57
  };
@@ -87,7 +88,15 @@ export declare class CliGateway {
87
88
  spawnImpl?: typeof spawnDsh;
88
89
  findBinary?: (env: NodeJS.ProcessEnv) => string | null;
89
90
  });
90
- /** Chain one mutation onto the queue; a settled job never blocks the next one. */
91
+ /**
92
+ * Run one profile mutation after every mutation already queued. The returned
93
+ * promise keeps the task's own result or rejection, while the queue tail is
94
+ * always recovered so one failed write cannot block later work. Routes that
95
+ * edit profile files directly must use this seam so they cannot overlap the
96
+ * CLI install/remove writer.
97
+ */
98
+ withMutationLock<T>(task: () => Promise<T>): Promise<T>;
99
+ /** Chain one fire-and-forget CLI mutation onto the shared queue. */
91
100
  private enqueue;
92
101
  /** The dsh CLI path, through the test seam when present. */
93
102
  private binary;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@linxin666/dsh-client-ui-plugin-manager",
3
3
  "description": "Plugin manager tab for the dsh web GUI Plugins settings section: installs plugins from npm or git through the official host channels, lists installed plugins with next-start enablement switches, surfaces install-time conflict actions with undo, and hands failures off to repair conversations.",
4
- "version": "0.2.2",
4
+ "version": "0.2.4",
5
5
  "type": "module",
6
6
  "main": "lib/index.js",
7
7
  "types": "lib/types/index.d.ts",
@@ -35,12 +35,12 @@
35
35
  },
36
36
  "devDependencies": {
37
37
  "@deepseek-ai/cordis": "^4.0.1",
38
- "@deepseek-ai/dsh-client-connection": "^0.1.0-rc.7",
39
- "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.7",
40
- "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.7",
41
- "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.7",
42
- "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.7",
43
- "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.7",
38
+ "@deepseek-ai/dsh-client-connection": "^0.1.0-rc.8",
39
+ "@deepseek-ai/dsh-client-locale": "^0.1.0-rc.8",
40
+ "@deepseek-ai/dsh-client-runtime": "^0.1.0-rc.8",
41
+ "@deepseek-ai/dsh-client-ui-primitives": "^0.1.0-rc.8",
42
+ "@deepseek-ai/dsh-client-ui-settings": "^0.1.0-rc.8",
43
+ "@deepseek-ai/dsh-client-ui-slots": "^0.1.0-rc.8",
44
44
  "@testing-library/react": "^16.1.0",
45
45
  "@types/node": "^22.20.0",
46
46
  "@types/react": "~18.3.1",
@@ -51,7 +51,7 @@
51
51
  "tsdown": "0.22.2",
52
52
  "typescript": "~5.7.2",
53
53
  "vitest": "^4.1.1",
54
- "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.7"
54
+ "@deepseek-ai/dsh-host-webserver": "^0.1.0-rc.8"
55
55
  },
56
56
  "files": [
57
57
  "lib",