@ququ-jiaxk/dsh-plugin-center 0.1.37 → 0.1.39
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 +3 -2
- package/lib/index.js +50 -18
- 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.39" : "0.0.0";
|
|
34
34
|
var PANEL_ID = "plugin-center";
|
|
35
35
|
var inject = ["slots", "remote", "remote.pluginManager"];
|
|
36
36
|
var hostCtx = null;
|
|
@@ -75,7 +75,8 @@ async function fetchSelfUpdateInfo() {
|
|
|
75
75
|
selfUpdateRequest = (async () => {
|
|
76
76
|
try {
|
|
77
77
|
const response = await fetch("/plugin-center/api/self/update-check", {
|
|
78
|
-
|
|
78
|
+
// listVersions 会走一次 registry 查询,慢网络下 15s 不够。
|
|
79
|
+
signal: typeof AbortSignal !== "undefined" && AbortSignal.timeout ? AbortSignal.timeout(45e3) : void 0
|
|
79
80
|
});
|
|
80
81
|
if (!response.ok) throw new Error(`HTTP ${response.status}`);
|
|
81
82
|
const data = await response.json();
|
package/lib/index.js
CHANGED
|
@@ -402,6 +402,10 @@ export function apply(ctx) {
|
|
|
402
402
|
installedVersion: own.version ?? HOST_VERSION,
|
|
403
403
|
updatable: Boolean(own.updatable),
|
|
404
404
|
source: own.source ?? null,
|
|
405
|
+
availability: own.availability ?? null,
|
|
406
|
+
readOnlyReason: own.readOnlyReason ?? null,
|
|
407
|
+
official: Boolean(own.official),
|
|
408
|
+
error: own.error ?? null,
|
|
405
409
|
}
|
|
406
410
|
}
|
|
407
411
|
} catch {
|
|
@@ -435,17 +439,6 @@ export function apply(ctx) {
|
|
|
435
439
|
|
|
436
440
|
const own = await findSelfBundle(manager)
|
|
437
441
|
const installedVersion = own?.version ?? HOST_VERSION
|
|
438
|
-
if (!own?.updatable) {
|
|
439
|
-
const blocked = selfUpdateBlockedInfo(own)
|
|
440
|
-
return send(res, 200, {
|
|
441
|
-
status: 'not-updatable',
|
|
442
|
-
version: HOST_VERSION,
|
|
443
|
-
installedVersion,
|
|
444
|
-
source: own?.source ?? null,
|
|
445
|
-
reason: blocked.reason,
|
|
446
|
-
hint: blocked.hint,
|
|
447
|
-
})
|
|
448
|
-
}
|
|
449
442
|
|
|
450
443
|
let list
|
|
451
444
|
try {
|
|
@@ -453,6 +446,34 @@ export function apply(ctx) {
|
|
|
453
446
|
} catch (error) {
|
|
454
447
|
return send(res, 502, { error: error?.message ?? '检查更新失败' })
|
|
455
448
|
}
|
|
449
|
+
|
|
450
|
+
if (list?.status === 'refused') {
|
|
451
|
+
// 旧版 DSH 的 BundleInfo 没有 updatable 字段,只有 listVersions 能给出权威结论。
|
|
452
|
+
if (list.problem === 'not-updatable') {
|
|
453
|
+
const blocked = selfUpdateBlockedInfo(own)
|
|
454
|
+
const detail = list.reason ? String(list.reason) : null
|
|
455
|
+
return send(res, 200, {
|
|
456
|
+
status: 'not-updatable',
|
|
457
|
+
version: HOST_VERSION,
|
|
458
|
+
installedVersion,
|
|
459
|
+
source: own?.source ?? null,
|
|
460
|
+
reason: blocked.reason,
|
|
461
|
+
detail,
|
|
462
|
+
availability: own?.availability ?? null,
|
|
463
|
+
readOnlyReason: own?.readOnlyReason ?? null,
|
|
464
|
+
official: own?.official ?? null,
|
|
465
|
+
error: own?.error ?? null,
|
|
466
|
+
hint: detail ? `${blocked.hint}(DSH 判断:${detail})` : blocked.hint,
|
|
467
|
+
})
|
|
468
|
+
}
|
|
469
|
+
return send(res, 200, {
|
|
470
|
+
status: 'unavailable',
|
|
471
|
+
problem: list.problem ?? 'unknown',
|
|
472
|
+
reason: list.reason ?? '',
|
|
473
|
+
installedVersion,
|
|
474
|
+
})
|
|
475
|
+
}
|
|
476
|
+
|
|
456
477
|
if (list?.status !== 'listed') {
|
|
457
478
|
return send(res, 200, {
|
|
458
479
|
status: 'unavailable',
|
|
@@ -518,13 +539,24 @@ export function apply(ctx) {
|
|
|
518
539
|
}
|
|
519
540
|
|
|
520
541
|
const own = await findSelfBundle(manager)
|
|
521
|
-
if (
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
542
|
+
if (own?.updatable !== true) {
|
|
543
|
+
// 旧版 DSH 没有 updatable 字段;用 listVersions 的权威结论判断能否升级。
|
|
544
|
+
let refused = null
|
|
545
|
+
try {
|
|
546
|
+
refused = await manager.listVersions(SELF_PACKAGE)
|
|
547
|
+
} catch {
|
|
548
|
+
refused = null
|
|
549
|
+
}
|
|
550
|
+
if (refused?.status === 'refused' && refused.problem === 'not-updatable') {
|
|
551
|
+
const blocked = selfUpdateBlockedInfo(own)
|
|
552
|
+
const detail = refused.reason ? String(refused.reason) : null
|
|
553
|
+
return send(res, 409, {
|
|
554
|
+
error: detail ? `${blocked.hint}(DSH 判断:${detail})` : blocked.hint,
|
|
555
|
+
code: 'not-updatable',
|
|
556
|
+
reason: blocked.reason,
|
|
557
|
+
detail,
|
|
558
|
+
})
|
|
559
|
+
}
|
|
528
560
|
}
|
|
529
561
|
|
|
530
562
|
// updateBundle 在 HMR 下会先卸载面板,这条请求可能拿不到后续响应,所以先回 202,
|