@ququ-jiaxk/dsh-plugin-center 0.1.35 → 0.1.36
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/client.js +9 -2
- package/lib/index.js +42 -7
- package/package.json +1 -1
package/lib/client.js
CHANGED
|
@@ -30,7 +30,7 @@ __export(client_exports, {
|
|
|
30
30
|
module.exports = __toCommonJS(client_exports);
|
|
31
31
|
var import_react = require("react");
|
|
32
32
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
33
|
-
var PLUGIN_VERSION = true ? "0.1.
|
|
33
|
+
var PLUGIN_VERSION = true ? "0.1.36" : "0.0.0";
|
|
34
34
|
var PANEL_ID = "plugin-center";
|
|
35
35
|
var inject = ["slots", "remote", "remote.pluginManager"];
|
|
36
36
|
var hostCtx = null;
|
|
@@ -49,6 +49,7 @@ var selfUpdateTarget = null;
|
|
|
49
49
|
var selfUpdatePolling = false;
|
|
50
50
|
var selfUpdateNotified = false;
|
|
51
51
|
var lastSelfCheckAt = 0;
|
|
52
|
+
var selfUpdateRetried = false;
|
|
52
53
|
var selfUpdateInfo = { latest: null, checkedAt: 0, checking: false };
|
|
53
54
|
var selfUpdateSubscribers = /* @__PURE__ */ new Set();
|
|
54
55
|
var selfUpdateRequest = null;
|
|
@@ -304,9 +305,14 @@ function Panel() {
|
|
|
304
305
|
}
|
|
305
306
|
if (result.status === "not-updatable") {
|
|
306
307
|
setSelfUpdate({ phase: "idle" });
|
|
308
|
+
if (result.reason === "unreadable" && !manual && !selfUpdateRetried) {
|
|
309
|
+
selfUpdateRetried = true;
|
|
310
|
+
setTimeout(() => void checkSelfUpdate(false), 5e3);
|
|
311
|
+
return;
|
|
312
|
+
}
|
|
307
313
|
if (manual) {
|
|
308
314
|
setDialog({
|
|
309
|
-
title: "\u5F53\u524D\u5B89\u88C5\u65B9\u5F0F\u4E0D\u652F\u6301\u81EA\u66F4\u65B0",
|
|
315
|
+
title: result.reason === "local" ? "\u5F53\u524D\u5B89\u88C5\u65B9\u5F0F\u4E0D\u652F\u6301\u81EA\u66F4\u65B0" : "\u6682\u65F6\u65E0\u6CD5\u81EA\u66F4\u65B0",
|
|
310
316
|
description: String(result.hint ?? ""),
|
|
311
317
|
input: false,
|
|
312
318
|
confirmLabel: "\u77E5\u9053\u4E86",
|
|
@@ -315,6 +321,7 @@ function Panel() {
|
|
|
315
321
|
}
|
|
316
322
|
return;
|
|
317
323
|
}
|
|
324
|
+
selfUpdateRetried = false;
|
|
318
325
|
if (result.status === "unavailable") {
|
|
319
326
|
setSelfUpdate({ phase: "idle" });
|
|
320
327
|
if (manual) setError(`\u68C0\u67E5\u66F4\u65B0\u5931\u8D25\uFF1A${result.reason || result.problem || "\u672A\u77E5\u539F\u56E0"}`);
|
package/lib/index.js
CHANGED
|
@@ -123,11 +123,42 @@ function selfUpdateRecord(phase, extra = {}) {
|
|
|
123
123
|
}
|
|
124
124
|
}
|
|
125
125
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
126
|
+
/**
|
|
127
|
+
* DSH 拒绝升级时给出可执行的下一步。
|
|
128
|
+
* 注意:`updatable: false` 不只代表"本地包安装"——刚安装完、包还没落盘时也会是 false,
|
|
129
|
+
* 所以这里按来源和 bundle 状态区分,避免误导。
|
|
130
|
+
*/
|
|
131
|
+
function selfUpdateBlockedInfo(own) {
|
|
132
|
+
const reinstall = `dsh plugin remove ${SELF_PACKAGE} && dsh plugin add ${SELF_PACKAGE}@latest`
|
|
133
|
+
|
|
134
|
+
if (!own) {
|
|
135
|
+
return {
|
|
136
|
+
reason: 'unreadable',
|
|
137
|
+
hint: `DSH 没有列出面板自身的 bundle,通常是安装还没完成或需要重启。重启 DSH 后点标题旁的版本号重新检查;仍然不行就重装:${reinstall}。`,
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
const source = own.source ?? null
|
|
142
|
+
const local = !source || /(?:^|[^a-z0-9])(?:file|link):/iu.test(source)
|
|
143
|
+
if (local) {
|
|
144
|
+
return {
|
|
145
|
+
reason: 'local',
|
|
146
|
+
hint: `当前插件中心是按本地包安装的(${source ?? 'file:'}),DSH 无法原地升级。执行一次迁移后即可自动更新:${reinstall},然后重启 DSH。`,
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
if (own.availability !== 'profile' || own.error) {
|
|
151
|
+
const detail = own.error?.code ? `(DSH:${own.error.code})` : ''
|
|
152
|
+
return {
|
|
153
|
+
reason: 'unreadable',
|
|
154
|
+
hint: `DSH 现在读不到已安装的面板包${detail},通常是刚安装完还没完全落盘。重启 DSH 后点标题旁的版本号重新检查;仍然不行就重装:${reinstall}。`,
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
return {
|
|
159
|
+
reason: 'unrecognized',
|
|
160
|
+
hint: `DSH 没有把当前依赖识别成可原地升级的 registry 规格(来源:${source ?? '未记录'})。重启 DSH 后再检查一次;仍然不行就重装:${reinstall}。`,
|
|
161
|
+
}
|
|
131
162
|
}
|
|
132
163
|
|
|
133
164
|
async function findSelfBundle(manager) {
|
|
@@ -373,12 +404,14 @@ export function apply(ctx) {
|
|
|
373
404
|
const own = await findSelfBundle(manager)
|
|
374
405
|
const installedVersion = own?.version ?? HOST_VERSION
|
|
375
406
|
if (!own?.updatable) {
|
|
407
|
+
const blocked = selfUpdateBlockedInfo(own)
|
|
376
408
|
return send(res, 200, {
|
|
377
409
|
status: 'not-updatable',
|
|
378
410
|
version: HOST_VERSION,
|
|
379
411
|
installedVersion,
|
|
380
412
|
source: own?.source ?? null,
|
|
381
|
-
|
|
413
|
+
reason: blocked.reason,
|
|
414
|
+
hint: blocked.hint,
|
|
382
415
|
})
|
|
383
416
|
}
|
|
384
417
|
|
|
@@ -444,9 +477,11 @@ export function apply(ctx) {
|
|
|
444
477
|
|
|
445
478
|
const own = await findSelfBundle(manager)
|
|
446
479
|
if (!own?.updatable) {
|
|
480
|
+
const blocked = selfUpdateBlockedInfo(own)
|
|
447
481
|
return send(res, 409, {
|
|
448
|
-
error:
|
|
482
|
+
error: blocked.hint,
|
|
449
483
|
code: 'not-updatable',
|
|
484
|
+
reason: blocked.reason,
|
|
450
485
|
})
|
|
451
486
|
}
|
|
452
487
|
|