dsh-mobile-plugin 0.5.69 → 0.5.71

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.
@@ -8,6 +8,9 @@
8
8
  * 「要不要重启才生效」全由它判断。这里只做三件事:把它的结果削成手机要的形状、把手机
9
9
  * 发来的动作转过去、把一次安装的进度留在内存里给轮询。
10
10
  *
11
+ * 失败原因:宿主的错误对象可能把原文放在 `diagnostic`,也可能放在 `message`;两种都原样
12
+ * 带回给 App,别在投影里丢掉 —— 手机要能看到「为什么没装成」。
13
+ *
11
14
  * 能力面收在三条上(与桌面端同一个判据,不另开):
12
15
  * 1. **只经 typertGateway 走 `pluginManager`**,不走 shell、不碰系统设置;
13
16
  * 2. **卸载只对「宿主说它可卸」的包开放**:`/plugin/market/remove` 转 `removeBundle`,但
@@ -100,14 +103,20 @@ async function call(ctx, method, args, signal) {
100
103
  * `application` 说这一步到底生效没有:`applied` 当场生效、`restart-required` 要等电脑上
101
104
  * 下次启动 DSH、`failed` 失败、`cancelled` 被取消。手机不做二次判断,照它说。
102
105
  */
106
+ /** 宿主一次失败里带的原因原文:优先用 `diagnostic`,没有再退回 `message`(两处都可能承载)。 */
107
+ function errorDetailOf(error) {
108
+ if (!error || typeof error !== 'object') return '';
109
+ if (typeof error.diagnostic === 'string' && error.diagnostic) return error.diagnostic;
110
+ if (typeof error.message === 'string' && error.message) return error.message;
111
+ return '';
112
+ }
113
+
103
114
  function operationView(value) {
104
115
  if (!value || typeof value !== 'object') return null;
105
116
  const error = value.error && typeof value.error === 'object'
106
117
  ? {
107
118
  code: textOrNull(value.error.code, 64) || 'operation-error',
108
- message: typeof value.error.diagnostic === 'string' && value.error.diagnostic
109
- ? value.error.diagnostic
110
- : '',
119
+ message: errorDetailOf(value.error),
111
120
  }
112
121
  : null;
113
122
  return {
@@ -142,9 +151,7 @@ function normalizeBundle(row) {
142
151
  const error = row.error && typeof row.error === 'object'
143
152
  ? {
144
153
  code: textOrNull(row.error.code, 64) || 'operation-error',
145
- message: typeof row.error.diagnostic === 'string' && row.error.diagnostic
146
- ? row.error.diagnostic
147
- : '',
154
+ message: errorDetailOf(row.error),
148
155
  }
149
156
  : null;
150
157
  // icon 是宿主给的**图片 data URL**(包根 manifest 的 icon,或 `<specifier>/icon` 导出),