@michengai/dsh-codex-ui 0.2.67 → 0.2.68

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 (2) hide show
  1. package/dist/index.mjs +12 -5
  2. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -333,16 +333,16 @@ function runDshPlugin(args) {
333
333
  /** 并发安装互斥:pnpm 锁文件竞争会触发 EPERM/EBUSY,同一时间只允许一个安装进程。 */
334
334
  let installing = false;
335
335
  /** 仅允许安装固定依赖,避免把浏览器输入转成任意命令。 */
336
- async function installDependency(id) {
336
+ async function installDependency(id, requestHotUpdate = requestDesktopHotUpdate) {
337
337
  if (installing) throw new Error("已有依赖安装正在进行,请等待完成后再试。");
338
338
  installing = true;
339
339
  try {
340
- return await installDependencyLocked(id);
340
+ return await installDependencyLocked(id, requestHotUpdate);
341
341
  } finally {
342
342
  installing = false;
343
343
  }
344
344
  }
345
- async function installDependencyLocked(id) {
345
+ async function installDependencyLocked(id, requestHotUpdate) {
346
346
  const dependency = managedDependency(id);
347
347
  if (dependency === void 0) throw new Error("不支持安装该依赖。");
348
348
  const latestVersion = await npmLatestVersion(dependency.packageName);
@@ -356,7 +356,7 @@ async function installDependencyLocked(id) {
356
356
  await ensureLatestReleaseAllowed(target, targetVersion);
357
357
  if (!isOfficialRuntimePackage(target)) await recordDeclaredVersion(target, targetVersion);
358
358
  await recordPendingUpdate(target, targetVersion);
359
- if (requestDesktopHotUpdate()) return dependencyStatuses();
359
+ if (requestHotUpdate()) return dependencyStatuses();
360
360
  try {
361
361
  await runDshPlugin([
362
362
  "add",
@@ -497,7 +497,11 @@ function apply(ctx) {
497
497
  response.end(JSON.stringify({ error: "已拒绝跨站请求。" }));
498
498
  return;
499
499
  }
500
- const dependencies = await installDependency(url.searchParams.get("dependency"));
500
+ let restartAfterResponse = false;
501
+ const dependencies = await installDependency(url.searchParams.get("dependency"), () => {
502
+ restartAfterResponse = typeof process.send === "function";
503
+ return restartAfterResponse;
504
+ });
501
505
  response.writeHead(200, {
502
506
  "content-type": "application/json; charset=utf-8",
503
507
  "cache-control": "no-store"
@@ -506,6 +510,9 @@ function apply(ctx) {
506
510
  dependencies,
507
511
  restartRequired: true
508
512
  }));
513
+ if (restartAfterResponse) setTimeout(() => {
514
+ requestDesktopHotUpdate();
515
+ }, 150).unref?.();
509
516
  return;
510
517
  }
511
518
  response.writeHead(405);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@michengai/dsh-codex-ui",
3
- "version": "0.2.67",
3
+ "version": "0.2.68",
4
4
  "description": "以 Codex 风格重构 DSH Web 侧栏的独立客户端插件",
5
5
  "license": "Apache-2.0",
6
6
  "publishConfig": {