vanspod 0.3.0 → 0.3.1
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/README.md +4 -4
- package/dist/desktop.js +32 -2
- package/dist/lifecyclePage.js +1 -0
- package/dist/start.js +12 -6
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -38,7 +38,7 @@ npm run dist
|
|
|
38
38
|
npm pack --pack-destination dist
|
|
39
39
|
```
|
|
40
40
|
|
|
41
|
-
exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.3.
|
|
41
|
+
exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.3.1.tgz`;可在 Windows 用 `npm install -g <套件路徑>` 安裝測試。圖片、favicon、系統匣與移除腳本均包含在發佈產物中。更新 logo 後執行 `powershell.exe -NoProfile -File scripts/build-icon.ps1` 重建多尺寸 Windows icon。
|
|
42
42
|
|
|
43
43
|
exe 發佈管道為本專案 GitHub Releases,npm 為公開 registry 的 [`vanspod`](https://www.npmjs.com/package/vanspod) 套件。更新時不要執行完整移除,否則會清除課堂資料。
|
|
44
44
|
|
|
@@ -46,12 +46,12 @@ exe 發佈管道為本專案 GitHub Releases,npm 為公開 registry 的 [`vans
|
|
|
46
46
|
|
|
47
47
|
一般 push 不發佈;推送 `v*` tag 會在 Windows runner 安裝 Node.js 24、檢查型別、執行測試、打包並驗證 exe/npm 生命週期,全部通過後才建立 GitHub Release,最後發佈 npm 套件。學生從 Release 下載 `VansPod.exe`,同頁提供 `SHA256SUMS.txt`。
|
|
48
48
|
|
|
49
|
-
發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.3.
|
|
49
|
+
發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.3.1` 為例:
|
|
50
50
|
|
|
51
51
|
```powershell
|
|
52
52
|
git push origin master
|
|
53
|
-
git tag -a v0.3.
|
|
54
|
-
git push origin v0.3.
|
|
53
|
+
git tag -a v0.3.1 -m "VansPod 0.3.1"
|
|
54
|
+
git push origin v0.3.1
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
新版本使用新的版本號與 tag。相同 tag 的 Actions 重跑會更新該 Release 的產物。
|
package/dist/desktop.js
CHANGED
|
@@ -6,7 +6,9 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
6
6
|
exports.openBrowser = openBrowser;
|
|
7
7
|
exports.asset = asset;
|
|
8
8
|
exports.writeTool = writeTool;
|
|
9
|
+
exports.materializeAsset = materializeAsset;
|
|
9
10
|
exports.startHiddenTool = startHiddenTool;
|
|
11
|
+
const node_crypto_1 = require("node:crypto");
|
|
10
12
|
const node_child_process_1 = require("node:child_process");
|
|
11
13
|
const node_sea_1 = require("node:sea");
|
|
12
14
|
const promises_1 = __importDefault(require("node:fs/promises"));
|
|
@@ -25,9 +27,37 @@ function asset(name) {
|
|
|
25
27
|
? Promise.resolve(Buffer.from((0, node_sea_1.getAsset)(name)))
|
|
26
28
|
: promises_1.default.readFile(node_path_1.default.join(__dirname, "..", name.startsWith("brand-") || name.startsWith("fadou-superhero") ? "media" : "scripts", name));
|
|
27
29
|
}
|
|
28
|
-
/**
|
|
30
|
+
/** 內嵌資產寫到磁碟時的內容;Windows PowerShell 5.1 需要 BOM 才會以 UTF-8 讀中文。 */
|
|
31
|
+
async function assetBytes(name) {
|
|
32
|
+
const bytes = await asset(name);
|
|
33
|
+
return name.endsWith(".ps1") ? Buffer.concat([Buffer.from([0xef, 0xbb, 0xbf]), bytes]) : bytes;
|
|
34
|
+
}
|
|
35
|
+
/** 把內嵌的 PowerShell 工具寫到指定位置。 */
|
|
29
36
|
async function writeTool(file, name) {
|
|
30
|
-
await promises_1.default.writeFile(file,
|
|
37
|
+
await promises_1.default.writeFile(file, await assetBytes(name));
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* 把內嵌資產寫到 directory,檔名帶內容雜湊;同名檔已存在就直接沿用。
|
|
41
|
+
* 檔案總管的縮圖程序(COM Surrogate)會把 .ico 對應進記憶體,之後這個檔案就無法覆寫。
|
|
42
|
+
*/
|
|
43
|
+
async function materializeAsset(directory, name) {
|
|
44
|
+
const bytes = await assetBytes(name);
|
|
45
|
+
const extension = node_path_1.default.extname(name);
|
|
46
|
+
const file = node_path_1.default.join(directory, `${node_path_1.default.basename(name, extension)}-${(0, node_crypto_1.createHash)("sha256").update(bytes).digest("hex").slice(0, 12)}${extension}`);
|
|
47
|
+
if (await promises_1.default.stat(file).catch(() => undefined))
|
|
48
|
+
return file;
|
|
49
|
+
const temporary = `${file}.${process.pid}.tmp`;
|
|
50
|
+
await promises_1.default.writeFile(temporary, bytes);
|
|
51
|
+
try {
|
|
52
|
+
await promises_1.default.rename(temporary, file);
|
|
53
|
+
}
|
|
54
|
+
catch (error) {
|
|
55
|
+
await promises_1.default.rm(temporary, { force: true });
|
|
56
|
+
// 另一個 VansPod 剛好同時寫好了同一份內容。
|
|
57
|
+
if (!await promises_1.default.stat(file).catch(() => undefined))
|
|
58
|
+
throw error;
|
|
59
|
+
}
|
|
60
|
+
return file;
|
|
31
61
|
}
|
|
32
62
|
/** 啟動一個在 VansPod 結束後仍會繼續執行的 PowerShell 工具,等它寫出 ready 檔才返回。 */
|
|
33
63
|
async function startHiddenTool(script, plan, ready, name) {
|
package/dist/lifecyclePage.js
CHANGED
|
@@ -34,6 +34,7 @@ function lifecyclePage(html, token) {
|
|
|
34
34
|
});
|
|
35
35
|
request('status').then(function (status) {
|
|
36
36
|
if (status.startupError) { document.querySelector('[data-lifecycle-message]').textContent = status.startupError; return; }
|
|
37
|
+
if (status.trayError) { document.querySelector('[data-lifecycle-message]').textContent = '右下角的系統匣圖示無法顯示,VansPod 仍在背景執行。要結束時請用這裡的「結束 VansPod」。'; return; }
|
|
37
38
|
if (status.launchVersion && status.launchVersion !== status.version) document.querySelector('[data-lifecycle-message]').textContent = '目前執行版本 ' + status.version + ',本次開啟版本 ' + status.launchVersion + '。換版請先結束 VansPod。';
|
|
38
39
|
}).catch(function () {});
|
|
39
40
|
})();
|
package/dist/start.js
CHANGED
|
@@ -259,10 +259,8 @@ function redirect(res, location = "/") {
|
|
|
259
259
|
async function openTray(url) {
|
|
260
260
|
const directory = node_path_1.default.join((0, instance_1.managementDirectory)(), "desktop-assets");
|
|
261
261
|
await promises_1.default.mkdir(directory, { recursive: true });
|
|
262
|
-
const script =
|
|
263
|
-
const icon =
|
|
264
|
-
await promises_1.default.writeFile(script, Buffer.concat([Buffer.from([0xef, 0xbb, 0xbf]), await (0, desktop_1.asset)("tray.ps1")]));
|
|
265
|
-
await promises_1.default.writeFile(icon, await (0, desktop_1.asset)("brand-icon.ico"));
|
|
262
|
+
const script = await (0, desktop_1.materializeAsset)(directory, "tray.ps1");
|
|
263
|
+
const icon = await (0, desktop_1.materializeAsset)(directory, "brand-icon.ico");
|
|
266
264
|
return (0, node_child_process_1.spawn)("powershell.exe", [
|
|
267
265
|
"-STA",
|
|
268
266
|
"-NoProfile",
|
|
@@ -394,6 +392,7 @@ async function main(instance) {
|
|
|
394
392
|
let ready = false;
|
|
395
393
|
let startupError;
|
|
396
394
|
let tray;
|
|
395
|
+
let trayError;
|
|
397
396
|
const exit = async () => {
|
|
398
397
|
tray?.kill();
|
|
399
398
|
await clientRouteRuntime.stop();
|
|
@@ -482,7 +481,7 @@ async function main(instance) {
|
|
|
482
481
|
}
|
|
483
482
|
const reply = (value) => { res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" }); res.end(JSON.stringify({ id: instance.id, ...value })); };
|
|
484
483
|
if (req.method === "GET" && pathname === "/_vanspod/status") {
|
|
485
|
-
reply({ running: true, ready, startupError, pid: process.pid, version: instance.version, origin: instance.origin, launchVersion, activeRequests: activeRequests.size, installing: app.view().commandRunning });
|
|
484
|
+
reply({ running: true, ready, startupError, pid: process.pid, version: instance.version, origin: instance.origin, launchVersion, trayError, activeRequests: activeRequests.size, installing: app.view().commandRunning });
|
|
486
485
|
return;
|
|
487
486
|
}
|
|
488
487
|
if (req.method === "POST" && pathname === "/_vanspod/open") {
|
|
@@ -851,7 +850,14 @@ async function main(instance) {
|
|
|
851
850
|
startupError += " 設定恢復未完成,服務已保留;修復後請重試 vanspod stop。";
|
|
852
851
|
}
|
|
853
852
|
versionUpdate.start();
|
|
854
|
-
|
|
853
|
+
// 系統匣起不來時 VansPod 仍要繼續;頁面會提示改用頁面上的「結束 VansPod」。
|
|
854
|
+
if (runtimeOptions.desktop && process.platform === "win32" && instance) {
|
|
855
|
+
tray = await openTray(home).catch((error) => {
|
|
856
|
+
trayError = error instanceof Error ? error.message : "系統匣無法啟動";
|
|
857
|
+
process.stderr.write(`系統匣圖示無法顯示:${trayError}\n`);
|
|
858
|
+
return undefined;
|
|
859
|
+
});
|
|
860
|
+
}
|
|
855
861
|
if (runtimeOptions.desktop && !process.env.VANSPOD_WORKER_TOKEN)
|
|
856
862
|
(0, desktop_1.openBrowser)(home);
|
|
857
863
|
const shutdown = () => {
|
package/dist/version.js
CHANGED