dsh-plugin-update-center 1.0.4 → 1.0.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.
Files changed (2) hide show
  1. package/index.js +33 -7
  2. package/package.json +1 -4
package/index.js CHANGED
@@ -15,7 +15,7 @@ import { createResidueService } from './lib/residue.js'
15
15
  import { createRestartService } from './lib/restart.js'
16
16
 
17
17
  export const name = 'dsh-plugin-update-center'
18
- export const inject = ['connection', 'pluginManager']
18
+ export const inject = ['connection']
19
19
 
20
20
  function readActivity(ctx) {
21
21
  try {
@@ -37,14 +37,40 @@ function readActivity(ctx) {
37
37
  }
38
38
 
39
39
  export function apply(ctx) {
40
- const manager = ctx.pluginManager
40
+ let manager = ctx.pluginManager
41
+ try {
42
+ manager = ctx.get?.('pluginManager') ?? manager
43
+ } catch {
44
+ // A profile without the service still loads the plugin in fallback mode.
45
+ }
41
46
  const connection = ctx.connection
42
- if (
43
- typeof manager?.listBundles !== 'function'
44
- || typeof manager?.installBundle !== 'function'
45
- || typeof manager?.removeBundle !== 'function'
46
- ) return
47
47
  if (typeof connection?.fetch?.register !== 'function') return
48
+ const hasManager = Boolean(manager)
49
+ && typeof manager.listBundles === 'function'
50
+ && typeof manager.installBundle === 'function'
51
+ && typeof manager.removeBundle === 'function'
52
+ if (!hasManager) {
53
+ // Minimal/headless profiles (for example dsh.so's L5 profile) do not mount
54
+ // the profile plugin manager. Still load the plugin and answer its route so
55
+ // the web boot and the endpoint check pass; the UI reports that updates are
56
+ // unavailable in this profile.
57
+ ctx.effect(
58
+ () => connection.fetch.register({
59
+ path: ROUTE,
60
+ methods: ['POST'],
61
+ requestBody: 'streaming',
62
+ fetch: async () => new Response(JSON.stringify({ ok: false, code: 'service-unavailable' }), {
63
+ status: 200,
64
+ headers: {
65
+ 'content-type': 'application/json; charset=utf-8',
66
+ 'cache-control': 'no-store',
67
+ },
68
+ }),
69
+ }),
70
+ 'dsh-plugin-update-center: unavailable route',
71
+ )
72
+ return
73
+ }
48
74
 
49
75
  const profile = ctx.get?.('profileContext')
50
76
  const profileDir = typeof profile?.dir === 'string' && profile.dir !== '' ? profile.dir : undefined
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-plugin-update-center",
3
- "version": "1.0.4",
3
+ "version": "1.0.5",
4
4
  "description": "尊重 DSH 原始风格的插件更新插件:在侧边栏检查、排队更新已安装插件,支持快照回滚、安装后校验、卸载残留清理与离线恢复。 A DSH-native plugin update center for the sidebar with snapshots, rollback, queued updates and leftover cleanup.",
5
5
  "keywords": [
6
6
  "dsh",
@@ -44,9 +44,6 @@
44
44
  "client": {
45
45
  "platform": "web",
46
46
  "immediately": true,
47
- "inject": [
48
- "@deepseek-ai/dsh-client-ui-sidebar"
49
- ],
50
47
  "external": [
51
48
  "@deepseek-ai/dsh-client-ui-primitives"
52
49
  ]