vanspod 0.3.0 → 0.3.2
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/classroomApp.js +10 -2
- package/dist/desktop.js +32 -2
- package/dist/lifecyclePage.js +1 -0
- package/dist/page.js +3 -3
- package/dist/start.js +16 -9
- package/dist/version.js +1 -1
- package/dist/versionUpdateView.js +3 -2
- 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.2.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.2` 為例:
|
|
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.2 -m "VansPod 0.3.2"
|
|
54
|
+
git push origin v0.3.2
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
新版本使用新的版本號與 tag。相同 tag 的 Actions 重跑會更新該 Release 的產物。
|
package/dist/classroomApp.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ClassroomApp = exports.ENVIRONMENT_TOOLS = void 0;
|
|
3
|
+
exports.ClassroomApp = exports.COPIED_KEY_NOTICE = exports.ENVIRONMENT_TOOLS = void 0;
|
|
4
4
|
const secureStorage_1 = require("./secureStorage");
|
|
5
5
|
const storageErrors_1 = require("./storageErrors");
|
|
6
6
|
const adapterSettings_1 = require("./adapterSettings");
|
|
@@ -16,6 +16,7 @@ const ENVIRONMENT_LABEL = {
|
|
|
16
16
|
pwsh: "PowerShell 7",
|
|
17
17
|
};
|
|
18
18
|
const LOCAL_LIST_NOTE = "這是本機清單。";
|
|
19
|
+
exports.COPIED_KEY_NOTICE = "已複製 Classroom API Key。請勿分享給不信任的人。";
|
|
19
20
|
const INSTALL_UNAVAILABLE = "尚未指定專案資料夾,安裝不可用。";
|
|
20
21
|
const REOPEN_TERMINAL = "請重開終端機再重新檢查。";
|
|
21
22
|
const ENVIRONMENT_ABORTED = "已中止安裝。系統安裝程式可能仍在執行,請等待結束或稍後重新安裝。";
|
|
@@ -86,6 +87,13 @@ class ClassroomApp {
|
|
|
86
87
|
this.connectionOperations = next.catch(() => { });
|
|
87
88
|
return next;
|
|
88
89
|
}
|
|
90
|
+
// 整頁畫面用這個:複製成功的提示只出現一次,重新整理就不會再讓法鬥說一遍。
|
|
91
|
+
pageView() {
|
|
92
|
+
const view = this.view();
|
|
93
|
+
if (this.notice === exports.COPIED_KEY_NOTICE)
|
|
94
|
+
this.notice = this.connectionNotice = undefined;
|
|
95
|
+
return view;
|
|
96
|
+
}
|
|
89
97
|
view() {
|
|
90
98
|
const view = {
|
|
91
99
|
connected: this.connected,
|
|
@@ -1442,7 +1450,7 @@ class ClassroomApp {
|
|
|
1442
1450
|
this.notice = this.connectionNotice = "無法複製 Classroom API Key。請重新連線後再試。";
|
|
1443
1451
|
return;
|
|
1444
1452
|
}
|
|
1445
|
-
this.notice = this.connectionNotice =
|
|
1453
|
+
this.notice = this.connectionNotice = exports.COPIED_KEY_NOTICE;
|
|
1446
1454
|
}
|
|
1447
1455
|
async copySnippet(snippetId) {
|
|
1448
1456
|
const snippet = this.catalog?.snippets?.find((item) => item.id === snippetId);
|
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/page.js
CHANGED
|
@@ -13,6 +13,7 @@ const classroomUpdate_1 = require("./classroomUpdate");
|
|
|
13
13
|
const connectionMascot_1 = require("./connectionMascot");
|
|
14
14
|
const clientIcons_1 = require("./clientIcons");
|
|
15
15
|
const environmentIcons_1 = require("./environmentIcons");
|
|
16
|
+
const classroomApp_1 = require("./classroomApp");
|
|
16
17
|
const promptCapture_1 = require("./promptCapture");
|
|
17
18
|
const inspectorView_1 = require("./inspectorView");
|
|
18
19
|
const versionUpdateView_1 = require("./versionUpdateView");
|
|
@@ -69,10 +70,9 @@ function notices(view) {
|
|
|
69
70
|
: "";
|
|
70
71
|
return `${klass}${notice}${running}`;
|
|
71
72
|
}
|
|
72
|
-
const COPY_KEY_NOTICE = "已複製 Classroom API Key。請勿分享給不信任的人。";
|
|
73
73
|
function connectionFeedback(view) {
|
|
74
74
|
const original = view.connectionError || view.connectionNotice || (view.detail !== "Classroom API Key 已設定。" ? view.detail : "");
|
|
75
|
-
const message = original ===
|
|
75
|
+
const message = original === classroomApp_1.COPIED_KEY_NOTICE
|
|
76
76
|
? "複製好了!API Key 不是群組伴手禮,別發給不信任的人喔。" : original;
|
|
77
77
|
const feedback = `<div class="connection-feedback">${message ? `<div class="${view.connectionError ? "connection-error" : "connection-message"}" role="${view.connectionError ? "alert" : "status"}"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8"><circle cx="12" cy="12" r="9"/><path d="M12 7v6M12 15v2"/></svg><p>${escapeHtml(message)}</p></div>` : ""}</div>`;
|
|
78
78
|
return feedback;
|
|
@@ -806,7 +806,7 @@ function organizeSettings(html, view) {
|
|
|
806
806
|
};
|
|
807
807
|
if (title === "連線") {
|
|
808
808
|
moveForm("clear");
|
|
809
|
-
if (actions && !view.connectionError && view.connectionNotice ===
|
|
809
|
+
if (actions && !view.connectionError && view.connectionNotice === classroomApp_1.COPIED_KEY_NOTICE) {
|
|
810
810
|
const feedback = connectionFeedback(view);
|
|
811
811
|
body = body.replace(feedback, "");
|
|
812
812
|
const speech = `<div class="mascot-speech">${feedback}<button type="button" class="mascot-speech-close" aria-label="收起法鬥台詞">知道啦</button></div>`;
|
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();
|
|
@@ -463,7 +462,8 @@ async function main(instance) {
|
|
|
463
462
|
const goHome = (params) => {
|
|
464
463
|
if (req.headers["x-classroom-settings"] === "1") {
|
|
465
464
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
|
|
466
|
-
|
|
465
|
+
const html = (0, page_1.renderPage)(app.pageView());
|
|
466
|
+
res.end(instance ? (0, lifecyclePage_1.lifecyclePage)(html, instance.token) : html);
|
|
467
467
|
return;
|
|
468
468
|
}
|
|
469
469
|
const variant = params?.get("prototype_variant") ?? "";
|
|
@@ -482,7 +482,7 @@ async function main(instance) {
|
|
|
482
482
|
}
|
|
483
483
|
const reply = (value) => { res.writeHead(200, { "Content-Type": "application/json", "Cache-Control": "no-store" }); res.end(JSON.stringify({ id: instance.id, ...value })); };
|
|
484
484
|
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 });
|
|
485
|
+
reply({ running: true, ready, startupError, pid: process.pid, version: instance.version, origin: instance.origin, launchVersion, trayError, activeRequests: activeRequests.size, installing: app.view().commandRunning });
|
|
486
486
|
return;
|
|
487
487
|
}
|
|
488
488
|
if (req.method === "POST" && pathname === "/_vanspod/open") {
|
|
@@ -579,8 +579,8 @@ async function main(instance) {
|
|
|
579
579
|
if (req.method === "GET" && (pathname === "/" || pathname === "/index.html")) {
|
|
580
580
|
const variant = parsed.searchParams.get("variant") ?? "";
|
|
581
581
|
const html = process.env.NODE_ENV !== "production" && (0, pagePrototype_1.isPrototypeVariant)(variant)
|
|
582
|
-
? (0, pagePrototype_1.renderPrototypePage)(app.
|
|
583
|
-
: (0, page_1.renderPage)(app.
|
|
582
|
+
? (0, pagePrototype_1.renderPrototypePage)(app.pageView(), variant)
|
|
583
|
+
: (0, page_1.renderPage)(app.pageView());
|
|
584
584
|
res.writeHead(200, {
|
|
585
585
|
"Content-Type": "text/html; charset=utf-8",
|
|
586
586
|
"Cache-Control": "no-store",
|
|
@@ -851,7 +851,14 @@ async function main(instance) {
|
|
|
851
851
|
startupError += " 設定恢復未完成,服務已保留;修復後請重試 vanspod stop。";
|
|
852
852
|
}
|
|
853
853
|
versionUpdate.start();
|
|
854
|
-
|
|
854
|
+
// 系統匣起不來時 VansPod 仍要繼續;頁面會提示改用頁面上的「結束 VansPod」。
|
|
855
|
+
if (runtimeOptions.desktop && process.platform === "win32" && instance) {
|
|
856
|
+
tray = await openTray(home).catch((error) => {
|
|
857
|
+
trayError = error instanceof Error ? error.message : "系統匣無法啟動";
|
|
858
|
+
process.stderr.write(`系統匣圖示無法顯示:${trayError}\n`);
|
|
859
|
+
return undefined;
|
|
860
|
+
});
|
|
861
|
+
}
|
|
855
862
|
if (runtimeOptions.desktop && !process.env.VANSPOD_WORKER_TOKEN)
|
|
856
863
|
(0, desktop_1.openBrowser)(home);
|
|
857
864
|
const shutdown = () => {
|
package/dist/version.js
CHANGED
|
@@ -7,11 +7,12 @@ const DOWNLOAD_ICON = `<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" s
|
|
|
7
7
|
exports.UPDATE_BUTTON = `<button type="button" class="update-button" data-version-update hidden aria-label="檢查更新" title="檢查更新">${DOWNLOAD_ICON}<span class="update-dot"></span></button>`;
|
|
8
8
|
exports.VERSION_UPDATE_STYLES = `
|
|
9
9
|
.bar .side-foot { margin-top: auto; display: flex; align-items: center; gap: 6px; }
|
|
10
|
-
.
|
|
10
|
+
.bar .side-foot > button { align-self: center; }
|
|
11
|
+
.update-button { position: relative; display: grid; place-items: center; width: 2.75rem; height: 2.75rem; min-height: 2.75rem; flex: 0 0 auto; padding: 0; border-radius: 999px; border: 1px solid var(--line); background: transparent; color: var(--muted); cursor: pointer; }
|
|
11
12
|
.update-button[hidden] { display: none; }
|
|
12
13
|
.update-button:hover { color: var(--text); background: light-dark(rgba(13, 13, 13, 0.04), rgba(255, 255, 255, 0.06)); }
|
|
13
14
|
.update-button:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
|
|
14
|
-
.update-button svg { width:
|
|
15
|
+
.update-button svg { width: 1.25rem; height: 1.25rem; }
|
|
15
16
|
.update-button .update-dot { display: none; position: absolute; top: 3px; right: 3px; width: 7px; height: 7px; border-radius: 999px; background: #2563eb; box-shadow: 0 0 0 2px var(--bg); }
|
|
16
17
|
.update-button.available { color: #2563eb; border-color: rgba(37, 99, 235, 0.45); background: rgba(37, 99, 235, 0.08); }
|
|
17
18
|
.update-button.available .update-dot { display: block; }
|