dsh-quick-restart 0.1.2 → 0.1.3

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/lib/index.js +18 -0
  2. package/package.json +5 -2
package/lib/index.js CHANGED
@@ -11,6 +11,24 @@ import { existsSync, readFileSync } from 'node:fs'
11
11
 
12
12
  export const name = 'dsh-quick-restart'
13
13
 
14
+ // 把 dsh-hot-restart 当作内置引擎:它是本包的依赖,直接 import 后调用它的 apply。
15
+ // 这样用户只装 dsh-quick-restart 一个包,「重启」就能用;
16
+ // 如果用户另外也装了 dsh-hot-restart,路由可能重复注册,这里忽略冲突即可。
17
+ async function embedHotRestart(ctx, log) {
18
+ try {
19
+ const mod = await import('dsh-hot-restart')
20
+ const plugin = (mod && mod.default) || mod
21
+ const apply = plugin && (plugin.apply || (plugin.default && plugin.default.apply))
22
+ if (typeof apply !== 'function') { log('内置重启引擎没有 apply,跳过'); return false }
23
+ await apply(ctx)
24
+ log('内置重启引擎(dsh-hot-restart)已启动')
25
+ return true
26
+ } catch (e) {
27
+ log('内置重启引擎加载失败(重启按钮会不可用): ' + String((e && e.message) || e))
28
+ return false
29
+ }
30
+ }
31
+
14
32
  const HERE = dirname(fileURLToPath(import.meta.url))
15
33
  const SELF = 'dsh-quick-restart'
16
34
  const CLIENT_ROUTE = '/dsh-quick-restart/client.js'
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-quick-restart",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "type": "module",
5
5
  "description": "DeepSeek Harness 插件:标题栏加两个按钮——重载第三方插件(不用重启宿主)、重启 DSH。",
6
6
  "keywords": [
@@ -40,5 +40,8 @@
40
40
  "bugs": {
41
41
  "url": "https://github.com/a994903574/dsh-quick-restart/issues"
42
42
  },
43
- "author": "a994903574"
43
+ "author": "a994903574",
44
+ "dependencies": {
45
+ "dsh-hot-restart": "^0.3.16"
46
+ }
44
47
  }