vanspod 0.5.1 → 0.5.5
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/localCommands.js +13 -2
- package/dist/modelStatus.js +2 -1
- package/dist/page.js +73 -43
- 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.5.
|
|
41
|
+
exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.5.5.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`。Release 另附 brotli 壓縮的 `VansPod.exe.br`(約三分之一大小),程式內更新只下載這份,解壓後再比對 `VansPod.exe` 的 SHA-256;SHA256SUMS 沒列出它的舊版 Release 則下載完整 exe。
|
|
48
48
|
|
|
49
|
-
發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.5.
|
|
49
|
+
發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.5.5` 為例:
|
|
50
50
|
|
|
51
51
|
```powershell
|
|
52
52
|
git push origin master
|
|
53
|
-
git tag -a v0.5.
|
|
54
|
-
git push origin v0.5.
|
|
53
|
+
git tag -a v0.5.5 -m "VansPod 0.5.5"
|
|
54
|
+
git push origin v0.5.5
|
|
55
55
|
```
|
|
56
56
|
|
|
57
57
|
新版本使用新的版本號與 tag。相同 tag 的 Actions 重跑會更新該 Release 的產物。
|
package/dist/localCommands.js
CHANGED
|
@@ -95,11 +95,22 @@ let nextRun = 0;
|
|
|
95
95
|
*/
|
|
96
96
|
async function runBashCommand(bash, command, folder, signal, options) {
|
|
97
97
|
const timeoutMs = options.timeoutMs;
|
|
98
|
+
// The log shows the command as running from here, so 停止 must work at once:
|
|
99
|
+
// a stop that comes while VansPod reads the PATH keeps Git Bash from starting.
|
|
100
|
+
let stopNow;
|
|
101
|
+
let stoppedEarly = false;
|
|
102
|
+
options.stoppable(() => { if (stopNow)
|
|
103
|
+
stopNow();
|
|
104
|
+
else
|
|
105
|
+
stoppedEarly = true; });
|
|
98
106
|
const env = await (0, systemPath_1.envWithRegistryPath)();
|
|
99
|
-
// From here to the spawn nothing waits, so a listed running command can always be stopped.
|
|
100
107
|
const stdout = collector();
|
|
101
108
|
const stderr = collector();
|
|
102
109
|
const ended = await new Promise(resolve => {
|
|
110
|
+
if (stoppedEarly || signal.aborted) {
|
|
111
|
+
resolve({ why: stoppedEarly ? "stopped" : "cancelled" });
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
103
114
|
let why;
|
|
104
115
|
let settled = false;
|
|
105
116
|
// The command and the pid file go in the environment, so no Windows argument quoting or globbing changes them.
|
|
@@ -136,7 +147,7 @@ async function runBashCommand(bash, command, folder, signal, options) {
|
|
|
136
147
|
child.stderr.on("data", (chunk) => collect(stderr, chunk));
|
|
137
148
|
child.on("error", error => finish({ error: error.message }));
|
|
138
149
|
child.on("close", code => finish(code === null ? {} : { code }));
|
|
139
|
-
|
|
150
|
+
stopNow = () => end("stopped");
|
|
140
151
|
});
|
|
141
152
|
if (ended.error) {
|
|
142
153
|
options.ended({});
|
package/dist/modelStatus.js
CHANGED
|
@@ -51,7 +51,8 @@ exports.modelStatusScript = `
|
|
|
51
51
|
if (status.traffic) document.querySelectorAll("[data-client-flow]").forEach(function (flow) {
|
|
52
52
|
flow.classList.toggle("flowing", status.traffic[flow.getAttribute("data-client-flow")] === true);
|
|
53
53
|
});
|
|
54
|
-
|
|
54
|
+
// Before the student connects, the model card is hidden and the Connection Gate holds the restart reminder.
|
|
55
|
+
var card = document.querySelector('[data-setting="模型"]') || document.querySelector('[data-setting="連線"].connection-gate');
|
|
55
56
|
if (!card) return;
|
|
56
57
|
var banner = card.querySelector(".model-update");
|
|
57
58
|
var holder = document.createElement("template");
|
package/dist/page.js
CHANGED
|
@@ -68,10 +68,7 @@ function statusWord(view) {
|
|
|
68
68
|
function notices(view) {
|
|
69
69
|
const notice = view.notice && view.notice !== view.connectionNotice ? `<p class="notice">${(0, html_1.escapeHtml)(view.notice)}</p>` : "";
|
|
70
70
|
const running = view.commandRunning ? `<p class="running">執行中</p>` : "";
|
|
71
|
-
|
|
72
|
-
? `<p class="class-label">${(0, html_1.escapeHtml)(view.classLabel)}</p>`
|
|
73
|
-
: "";
|
|
74
|
-
return `${klass}${notice}${running}`;
|
|
71
|
+
return `${notice}${running}`;
|
|
75
72
|
}
|
|
76
73
|
function connectionFeedback(view) {
|
|
77
74
|
const original = view.connectionError || view.connectionNotice || (view.detail !== "Classroom API Key 已設定。" ? view.detail : "");
|
|
@@ -86,29 +83,44 @@ function authorizeLink(view) {
|
|
|
86
83
|
? `<p class="hint"><a href="${(0, html_1.escapeHtml)(view.authorizeUrl)}" target="_blank" rel="noopener">如果瀏覽器沒有打開,請點這裡</a></p>`
|
|
87
84
|
: "";
|
|
88
85
|
}
|
|
86
|
+
/** The 連線 card of a connected student. Before the student connects, connectionGate takes its place. */
|
|
89
87
|
function connectInner(view) {
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
if (!view.canCopyKey)
|
|
89
|
+
return "";
|
|
90
|
+
const off = locked(view);
|
|
91
|
+
return `<form method="post" action="/copy">
|
|
94
92
|
<button type="submit"${off}>複製 Classroom API Key</button>
|
|
95
93
|
</form>
|
|
96
94
|
<form method="post" action="/clear">
|
|
97
95
|
<button type="submit" class="quiet"${off}>清除連線</button>
|
|
98
|
-
</form>${authorizeLink(view)}${
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
96
|
+
</form>${authorizeLink(view)}${connectionFeedback(view)}`;
|
|
97
|
+
}
|
|
98
|
+
const CONNECTION_STEPS = `<ol class="connection-steps"><li>準備好老師給的<b>邀請碼</b></li><li>按「連線」,瀏覽器會打開登入頁</li><li>輸入邀請碼,選<b>暱稱</b>或 <b>Google</b> 登入</li></ol>`;
|
|
99
|
+
/**
|
|
100
|
+
* Before the student connects, the 連線 card fills the first row: the Connection Gate.
|
|
101
|
+
* The model card stays hidden, because every Client Route is Native until the student connects.
|
|
102
|
+
* The restart reminder stays here, so the student still sees it after 清除連線.
|
|
103
|
+
*/
|
|
104
|
+
/**
|
|
105
|
+
* Before the student connects, the model card shows only when something there needs the student:
|
|
106
|
+
* a failed (red) Client Route, or an adapter message. The card holds 重新載入 to retry.
|
|
107
|
+
*/
|
|
108
|
+
function modelCardNeeded(view) {
|
|
109
|
+
if (view.canCopyKey || view.adapterNotice)
|
|
110
|
+
return true;
|
|
111
|
+
return ["codex", "claude", "vscode"].some((client) => clientLight(view, client).health === "red");
|
|
112
|
+
}
|
|
113
|
+
function connectionGate(view) {
|
|
114
|
+
const feedback = connectionFeedback(view);
|
|
115
|
+
const body = view.connecting
|
|
116
|
+
? `<span class="connection-spinner" aria-hidden="true"></span><h2 class="connection-gate-title" role="status">請在瀏覽器完成登入</h2>${authorizeLink(view)}${feedback}`
|
|
117
|
+
: `<img class="connection-gate-mascot" src="/fadou-superhero.png" alt=""><h2 class="connection-gate-title">先連線課堂</h2>${feedback}${CONNECTION_STEPS}`;
|
|
118
|
+
const action = view.connecting
|
|
119
|
+
? `<form method="post" action="/connect-cancel"><button type="submit" class="quiet">取消</button></form>`
|
|
120
|
+
: `<form method="post" action="/connect"><button type="submit" class="go"${locked(view)}>連線</button></form>`;
|
|
121
|
+
// With the model card shown, the restart reminder stays there.
|
|
122
|
+
const restart = modelCardNeeded(view) ? "" : restartHtml(view);
|
|
123
|
+
return `<section class="tile settings-card connection-gate" data-setting="連線">${body}${restart}<div class="settings-actions">${action}</div></section>`;
|
|
112
124
|
}
|
|
113
125
|
function folderInner(view) {
|
|
114
126
|
const value = view.projectFolder ? ` value="${(0, html_1.escapeHtml)(view.projectFolder)}"` : "";
|
|
@@ -629,7 +641,7 @@ const CSS = `
|
|
|
629
641
|
letter-spacing: -0.03em;
|
|
630
642
|
margin: 1rem 0 0.35rem;
|
|
631
643
|
}
|
|
632
|
-
.detail, .notice
|
|
644
|
+
.detail, .notice { color: var(--text); }
|
|
633
645
|
.hint, .empty, .kind, .mode-line { color: var(--muted); }
|
|
634
646
|
.error, .restart { color: var(--stop); }
|
|
635
647
|
.running { color: var(--accent); font-weight: 700; }
|
|
@@ -1021,22 +1033,6 @@ function organizeSettings(html, view) {
|
|
|
1021
1033
|
body = body.replace('class="connection-mascot"', 'class="connection-mascot mascot-waiting mascot-speaking"')
|
|
1022
1034
|
.replace('<div class="mascot-traveler">', `${speech}<div class="mascot-traveler">`);
|
|
1023
1035
|
}
|
|
1024
|
-
if (!actions) {
|
|
1025
|
-
body = body.replace(/action="\/(connect|connect-cancel)"/, '$& id="settings-connect"');
|
|
1026
|
-
body = body.replace(/<button[\s\S]*?<\/button>/, (button) => {
|
|
1027
|
-
actions = button.replace('<button ', '<button form="settings-connect" ');
|
|
1028
|
-
return "";
|
|
1029
|
-
});
|
|
1030
|
-
const feedback = body.match(/<div class="connection-feedback">[\s\S]*?<\/div>(?=\s*<\/form>)/)?.[0] ?? '<div class="connection-feedback"></div>';
|
|
1031
|
-
body = body.replace(feedback, "");
|
|
1032
|
-
const quote = view.connecting
|
|
1033
|
-
? "我在這裡等你,去瀏覽器完成登入吧!"
|
|
1034
|
-
: !view.connectionError
|
|
1035
|
-
? "我披風都穿好了,按「連線」去瀏覽器登入吧!"
|
|
1036
|
-
: "連線這關還沒過,披風倒是先上班了。照下面的提示再試一次!";
|
|
1037
|
-
const speech = `<div class="mascot-speech"><p class="mascot-quote">${(0, html_1.escapeHtml)(quote)}</p>${feedback}</div>`;
|
|
1038
|
-
body += connectionMascot_1.connectionMascot.replace('class="connection-mascot"', 'class="connection-mascot mascot-waiting"').replace('<div class="mascot-traveler">', `${speech}<div class="mascot-traveler">`);
|
|
1039
|
-
}
|
|
1040
1036
|
}
|
|
1041
1037
|
else if (title === "模型") {
|
|
1042
1038
|
body = body.replace(/<div class="model-update"[\s\S]*?<\/div><\/div>/, (block) => {
|
|
@@ -1074,7 +1070,21 @@ function organizeSettings(html, view) {
|
|
|
1074
1070
|
});
|
|
1075
1071
|
if (cards.length !== 3)
|
|
1076
1072
|
return html;
|
|
1077
|
-
|
|
1073
|
+
const firstRow = view.canCopyKey ? cards.slice(0, 2).join("")
|
|
1074
|
+
: `${connectionGate(view)}${modelCardNeeded(view) ? cards[1] : ""}`;
|
|
1075
|
+
return updated.replace('<div class="modules">', `<div class="modules"><div class="settings-grid">${firstRow}</div>${projectFolderRow(view)}${cards[2]}`);
|
|
1076
|
+
}
|
|
1077
|
+
function loginMethodChip(view) {
|
|
1078
|
+
if (!view.loginMethod)
|
|
1079
|
+
return "";
|
|
1080
|
+
return `<span class="login-method">${view.loginMethod === "google" ? "Google 登入" : "暱稱登入"}</span>`;
|
|
1081
|
+
}
|
|
1082
|
+
/** Before the student connects, the page head says so. Once connected, the 連線 card shows who is connected. */
|
|
1083
|
+
function settingsHead(view) {
|
|
1084
|
+
const text = "<h2>教室設定</h2><p>連線、模型與開發環境。</p>";
|
|
1085
|
+
if (view.canCopyKey)
|
|
1086
|
+
return `<header class="page-head">${text}</header>`;
|
|
1087
|
+
return `<header class="page-head connection-head"><div>${text}</div><span class="connection-pill">${view.connecting ? "登入中…" : "未連線"}</span></header>`;
|
|
1078
1088
|
}
|
|
1079
1089
|
function renderPage(view) {
|
|
1080
1090
|
const tag = view.connected
|
|
@@ -1111,15 +1121,14 @@ function renderPage(view) {
|
|
|
1111
1121
|
.map((value) => `<span>${(0, html_1.escapeHtml)(value)}</span>`)
|
|
1112
1122
|
.join('<span class="connection-separator" aria-hidden="true">·</span>');
|
|
1113
1123
|
const identity = course || meta
|
|
1114
|
-
? `<div class="connection-identity">${course}${meta ? `<p class="connection-meta">${meta}</p>` : ""}</div>`
|
|
1124
|
+
? `<div class="connection-identity">${course}${meta ? `<p class="connection-meta">${meta}${loginMethodChip(view)}</p>` : ""}</div>`
|
|
1115
1125
|
: "";
|
|
1116
1126
|
const mascot = `<div class="classroom-update-home"><div class="classroom-update">${connectionMascot_1.connectionMascot}${(0, classroomUpdate_1.classroomUpdateControl)(view, restartHtml(view))}</div></div>`;
|
|
1117
1127
|
const block = `${identity}<div class="key-row"><p>API Key 已設定</p><form method="post" action="/copy"><button type="submit" class="connection-copy" aria-label="複製 Classroom API Key"${off}>${COPY_ICON}<span>複製</span></button></form></div>${mascot}<form method="post" action="/clear"><button type="submit" class="connection-clear"${off}>清除連線</button></form>`;
|
|
1118
1128
|
html = html.replace(/<form method="post" action="\/copy">[\s\S]*?<\/form>\s*<form method="post" action="\/clear">[\s\S]*?<\/form>/, block);
|
|
1119
|
-
html = html.replace(/<p class="class-label">[\s\S]*?<\/p>/, "");
|
|
1120
1129
|
html = html.replace(`<p class="detail">Classroom API Key 已設定。</p>`, "");
|
|
1121
1130
|
}
|
|
1122
|
-
html = html.replace(`<div class="modules">`,
|
|
1131
|
+
html = html.replace(`<div class="modules">`, `${settingsHead(view)}<div class="modules">`);
|
|
1123
1132
|
if (view.catalog?.actions.length) {
|
|
1124
1133
|
html = html.replace(/<table>[\s\S]*?<\/table>/, installActionCards(view));
|
|
1125
1134
|
}
|
|
@@ -1146,6 +1155,27 @@ function renderPage(view) {
|
|
|
1146
1155
|
.connection-meta { display: flex; align-items: baseline; flex-wrap: wrap; gap: 4px 8px; color: var(--muted); font-size: 13px; line-height: 1.6; }
|
|
1147
1156
|
.connection-meta > span { min-width: 0; overflow-wrap: anywhere; }
|
|
1148
1157
|
.connection-separator { opacity: 0.5; }
|
|
1158
|
+
.login-method { display: inline-flex; align-items: center; padding: 0 8px; border: 1px solid var(--line); border-radius: 999px; font-size: 11px; line-height: 20px; }
|
|
1159
|
+
.connection-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
|
|
1160
|
+
.connection-pill { flex-shrink: 0; margin-top: 4px; padding: 3px 10px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; }
|
|
1161
|
+
.settings-card.connection-gate { grid-column: 1 / -1; align-items: center; gap: 12px; padding: 32px 18px; text-align: center; }
|
|
1162
|
+
.connection-gate-mascot { width: 120px; height: 120px; object-fit: contain; }
|
|
1163
|
+
h2.connection-gate-title { color: var(--text); font-size: 18px; font-weight: 600; }
|
|
1164
|
+
.connection-gate .connection-feedback, .connection-gate .model-update { max-width: 28rem; text-align: left; }
|
|
1165
|
+
.connection-steps { margin: 0; padding-left: 1.3em; color: var(--muted); font-size: 13px; line-height: 1.9; text-align: left; }
|
|
1166
|
+
.connection-steps b { color: var(--text); }
|
|
1167
|
+
.connection-gate .settings-actions { justify-content: center; min-height: 0; padding-top: 4px; border-top: 0; }
|
|
1168
|
+
.connection-gate .settings-actions button { min-width: 180px; }
|
|
1169
|
+
.connection-gate ~ .settings-card { grid-column: 1 / -1; }
|
|
1170
|
+
.connection-spinner { width: 36px; height: 36px; border: 3px solid var(--line); border-top-color: var(--accent); border-radius: 50%; animation: connection-spin 0.8s linear infinite; }
|
|
1171
|
+
@keyframes connection-spin { to { transform: rotate(360deg); } }
|
|
1172
|
+
@media (prefers-reduced-motion: reduce) { .connection-spinner { animation-duration: 3s; } }
|
|
1173
|
+
/* The walking 法鬥超人 in the 連線 card is small, so the card is not much taller than the model card. */
|
|
1174
|
+
[data-setting="連線"] .classroom-update-home { min-height: 150px; padding-bottom: 8px; }
|
|
1175
|
+
[data-setting="連線"] .classroom-update-home .connection-mascot { height: 80px; min-height: 80px; flex-basis: 80px; }
|
|
1176
|
+
[data-setting="連線"] .classroom-update-home .connection-mascot.mascot-speaking { height: auto; flex-basis: auto; padding-bottom: 80px; }
|
|
1177
|
+
[data-setting="連線"] .mascot-traveler { width: 76px; }
|
|
1178
|
+
[data-setting="連線"] .connection-identity { margin-bottom: 0; }
|
|
1149
1179
|
.tool em { color: var(--text); }
|
|
1150
1180
|
.tool em.missing { color: var(--muted); }
|
|
1151
1181
|
.tool em.needs-repair { color: light-dark(#9a4a08, #fbbf24); }
|
package/dist/version.js
CHANGED