dsh-status-bar-plugin 0.2.7 → 0.2.9
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/runtime.js +26 -1
- package/package.json +2 -2
package/lib/runtime.js
CHANGED
|
@@ -25,6 +25,15 @@ export function runtimeUrl(config, root) {
|
|
|
25
25
|
const url = explicit ?? advertised ?? DEFAULT_RUNTIME_URL;
|
|
26
26
|
return !explicit && url === DEFAULT_RUNTIME_URL ? `https://github.com/wfz2006/dsh-status-bar/releases/download/v${packageVersion(root)}/dsh-status-bar.tgz` : url;
|
|
27
27
|
}
|
|
28
|
+
/** The npm-hosted runtime is the primary source; the release asset stays as a
|
|
29
|
+
* fallback for networks where one of the two is unreachable. An explicitly
|
|
30
|
+
* configured address is used alone, so operators keep full control. */
|
|
31
|
+
export function runtimeUrls(config, root) {
|
|
32
|
+
const primary = runtimeUrl(config, root);
|
|
33
|
+
if (config.downloadUrl ?? process.env.DSH_STATUS_BAR_RUNTIME_URL ?? process.env.DSH_GLASS_RUNTIME_URL) return [primary];
|
|
34
|
+
const fallback = `https://github.com/wfz2006/dsh-status-bar/releases/download/v${packageVersion(root)}/dsh-status-bar.tgz`;
|
|
35
|
+
return primary === fallback ? [primary] : [primary, fallback];
|
|
36
|
+
}
|
|
28
37
|
function binary(dist) {
|
|
29
38
|
const name = process.platform === 'win32' ? 'electron.exe' : process.platform === 'darwin' ? join('Electron.app', 'Contents', 'MacOS', 'Electron') : 'electron';
|
|
30
39
|
return firstFile([join(dist, name)]);
|
|
@@ -90,6 +99,22 @@ function removeOwned(path, root) {
|
|
|
90
99
|
if (dirname(path) !== dirname(root) || !basename(path).startsWith(`${basename(root)}.`)) throw new Error('缓存临时路径无效。');
|
|
91
100
|
rmSync(path, { recursive: true, force: true });
|
|
92
101
|
}
|
|
102
|
+
async function downloadWithFallback(config, pluginRoot, part, { signal, onProgress }) {
|
|
103
|
+
const urls = runtimeUrls(config, pluginRoot);
|
|
104
|
+
let lastError;
|
|
105
|
+
for (const url of urls) {
|
|
106
|
+
try {
|
|
107
|
+
await downloadArchive(url, part, { signal, onProgress });
|
|
108
|
+
return;
|
|
109
|
+
} catch (error) {
|
|
110
|
+
if (error?.name === 'AbortError') throw error;
|
|
111
|
+
checkAbort(signal);
|
|
112
|
+
lastError = error;
|
|
113
|
+
if (url !== urls.at(-1)) onProgress({ phase: 'downloading', message: '这个下载源不可用,正在改用备用源。' });
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
throw lastError ?? new Error('运行时下载失败。');
|
|
117
|
+
}
|
|
93
118
|
export async function ensureRuntime(config, pluginRoot, { signal, onProgress = () => {} } = {}) {
|
|
94
119
|
const version = packageVersion(pluginRoot); const base = cacheBase(config); const root = join(base, `runtime-${version}`);
|
|
95
120
|
const cached = cachedRuntime(root, version); if (cached) return cached;
|
|
@@ -101,7 +126,7 @@ export async function ensureRuntime(config, pluginRoot, { signal, onProgress = (
|
|
|
101
126
|
// The exclusive lock proves that no other preparer owns these generated
|
|
102
127
|
// staging folders. An abrupt Host exit must not leave one unpack per retry.
|
|
103
128
|
for (const name of readdirSync(base)) if (name.startsWith(`${basename(root)}.staging-`) && /^[0-9a-f-]{36}$/.test(name.slice(`${basename(root)}.staging-`.length))) removeOwned(join(base, name), root);
|
|
104
|
-
await
|
|
129
|
+
await downloadWithFallback(config, pluginRoot, part, { signal, onProgress }); checkAbort(signal);
|
|
105
130
|
onProgress({ phase: 'unpacking', message: '下载完成,正在校验并解压运行时。' });
|
|
106
131
|
let entries;
|
|
107
132
|
try { entries = await run('tar', ['-tvzf', part], signal, true); }
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-status-bar-plugin",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.9",
|
|
4
4
|
"description": "Floating glass status bar for DeepSeek Harness: a frameless always-on-top window that shows session progress, pending approvals and questions.",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "wfz2006",
|
|
@@ -44,7 +44,7 @@
|
|
|
44
44
|
"patch": "./cordis.patch.yml"
|
|
45
45
|
},
|
|
46
46
|
"statusBar": {
|
|
47
|
-
"runtime": "https://
|
|
47
|
+
"runtime": "https://registry.npmjs.org/dsh-status-bar-runtime/-/dsh-status-bar-runtime-0.2.9.tgz"
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
50
|
}
|