vanspod 0.4.4 → 0.4.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 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.4.4.tgz`;可在 Windows 用 `npm install -g <套件路徑>` 安裝測試。圖片、favicon、系統匣與移除腳本均包含在發佈產物中。更新 logo 後執行 `powershell.exe -NoProfile -File scripts/build-icon.ps1` 重建多尺寸 Windows icon。
41
+ exe 產物為 `dist/VansPod.exe`,本機套件為 `dist/vanspod-0.4.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`。
48
48
 
49
- 發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.4.4` 為例:
49
+ 發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.4.5` 為例:
50
50
 
51
51
  ```powershell
52
52
  git push origin master
53
- git tag -a v0.4.4 -m "VansPod 0.4.4"
54
- git push origin v0.4.4
53
+ git tag -a v0.4.5 -m "VansPod 0.4.5"
54
+ git push origin v0.4.5
55
55
  ```
56
56
 
57
57
  新版本使用新的版本號與 tag。相同 tag 的 Actions 重跑會更新該 Release 的產物。
@@ -24,6 +24,8 @@ const KEY_REJECTED_NOTICE = {
24
24
  expired: "Classroom API Key 已過期,請按「清除連線」,再用老師給的新邀請碼重新兌換。",
25
25
  invalid: "Classroom API Key 已失效,請按「清除連線」,再用老師給的新邀請碼重新兌換。",
26
26
  };
27
+ const RESTORE_CATALOG_ATTEMPTS = 3;
28
+ const RESTORE_CATALOG_RETRY_MS = 1_000;
27
29
  const INSTALL_UNAVAILABLE = "尚未指定專案資料夾,安裝不可用。";
28
30
  const ENVIRONMENT_ABORTED = "已中止安裝。系統安裝程式可能仍在執行,請等待結束或稍後重新安裝。";
29
31
  const PROXY_CLIENTS = ["codex", "claude", "copilot"];
@@ -1792,7 +1794,8 @@ class ClassroomApp {
1792
1794
  this.hiddenKeys.add(connection.apiKey);
1793
1795
  this.applyConnectionIdentity(connection);
1794
1796
  this.mode = "native";
1795
- await this.loadCatalog();
1797
+ // 版本更新後重新啟動時網路可能還沒穩;恢復 Classroom Connection 時抓不到 Course Catalog 就稍候再試,才退回本機的 classroom-installs.yaml。
1798
+ await this.loadCatalog(RESTORE_CATALOG_ATTEMPTS);
1796
1799
  await this.loadModels(connection.apiKey);
1797
1800
  if (this.keyRejection)
1798
1801
  this.showKeyRejection(this.keyRejection);
@@ -1873,7 +1876,7 @@ class ClassroomApp {
1873
1876
  closeWindow() {
1874
1877
  // 關分頁不停止代理,也不改路由。
1875
1878
  }
1876
- async loadCatalog() {
1879
+ async loadCatalog(attempts = 1) {
1877
1880
  if (!this.connected) {
1878
1881
  return;
1879
1882
  }
@@ -1885,17 +1888,23 @@ class ClassroomApp {
1885
1888
  return;
1886
1889
  }
1887
1890
  let body;
1888
- try {
1889
- body = await this.deps.catalog.fetchCourseCatalog(apiKey);
1890
- }
1891
- catch (error) {
1892
- // The refused key is reported with the allowlist; the last catalog stays on screen.
1893
- if (error instanceof classroomKeyRejection_1.ClassroomKeyRejectedError) {
1894
- this.keyRejection = error.reason;
1895
- return;
1891
+ for (let attempt = 1;; attempt++) {
1892
+ try {
1893
+ body = await this.deps.catalog.fetchCourseCatalog(apiKey);
1894
+ break;
1895
+ }
1896
+ catch (error) {
1897
+ // The refused key is reported with the allowlist; the last catalog stays on screen.
1898
+ if (error instanceof classroomKeyRejection_1.ClassroomKeyRejectedError) {
1899
+ this.keyRejection = error.reason;
1900
+ return;
1901
+ }
1902
+ if (attempt >= attempts) {
1903
+ await this.loadLocalCatalog();
1904
+ return;
1905
+ }
1906
+ await new Promise(resolve => setTimeout(resolve, RESTORE_CATALOG_RETRY_MS));
1896
1907
  }
1897
- await this.loadLocalCatalog();
1898
- return;
1899
1908
  }
1900
1909
  const yaml = usableCatalogYaml(body?.course_catalog_yaml);
1901
1910
  if (yaml === undefined) {
package/dist/start.js CHANGED
@@ -166,6 +166,8 @@ function isEnvironmentTool(value) {
166
166
  const MAC_PWSH_PAGE = "https://learn.microsoft.com/powershell/scripting/install/installing-powershell-on-macos";
167
167
  // VS Code 的直接下載安裝只做 Windows;macOS 開啟官方下載頁,由學生自己安裝。
168
168
  const MAC_VSCODE_PAGE = "https://code.visualstudio.com/download";
169
+ /** 首頁最多等啟動這麼久;涵蓋 Course Catalog 重試與 Session Model Allowlist 的抓取。 */
170
+ const PAGE_STARTUP_WAIT_MS = 30_000;
169
171
  /** macOS 維持原本的偵測:找得到且有輸出版本就算已就緒(ADR-0008:第一版只完整支援 Windows)。 */
170
172
  function probeMacEnvironment(tool) {
171
173
  return (0, commandRunner_1.collectOutput)(tool === "vscode" ? "code" : tool, ["--version"]).then((result) => {
@@ -371,6 +373,9 @@ async function main(instance) {
371
373
  },
372
374
  });
373
375
  let ready = false;
376
+ // 和 ready 不同:啟動失敗但服務保留時也會放行,頁面才能顯示 startupError。
377
+ let settleStartup;
378
+ const startupSettled = new Promise(resolve => { settleStartup = resolve; });
374
379
  let startupError;
375
380
  let tray;
376
381
  let trayError;
@@ -565,6 +570,9 @@ async function main(instance) {
565
570
  return;
566
571
  }
567
572
  if (req.method === "GET" && (pathname === "/" || pathname === "/index.html")) {
573
+ // 版本更新後重新啟動時,舊分頁一拿到首頁就重新整理頁面;
574
+ // 等 Classroom Connection 恢復、Course Catalog 載入後才給頁面,免得課程安裝停在尚未載入的狀態。
575
+ await startupSettled;
568
576
  const variant = parsed.searchParams.get("variant") ?? "";
569
577
  const html = process.env.NODE_ENV !== "production" && (0, pagePrototype_1.isPrototypeVariant)(variant)
570
578
  ? (0, pagePrototype_1.renderPrototypePage)(app.pageView(), variant)
@@ -831,6 +839,8 @@ async function main(instance) {
831
839
  await clientRouteRuntime.stop();
832
840
  throw error;
833
841
  }
842
+ // 啟動卡住時不讓首頁無限等待;顯示未完成的頁面總比一直轉圈好。
843
+ setTimeout(settleStartup, PAGE_STARTUP_WAIT_MS).unref();
834
844
  try {
835
845
  await app.start();
836
846
  ready = true;
@@ -852,6 +862,9 @@ async function main(instance) {
852
862
  }
853
863
  startupError += " 設定恢復未完成,服務已保留;修復後請重試 vanspod stop。";
854
864
  }
865
+ finally {
866
+ settleStartup();
867
+ }
855
868
  versionUpdate.start();
856
869
  // 系統匣起不來時 VansPod 仍要繼續;頁面會提示改用頁面上的「結束 VansPod」。
857
870
  if (runtimeOptions.desktop && process.platform === "win32" && instance) {
package/dist/version.js CHANGED
@@ -1,4 +1,4 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = "0.4.4";
4
+ exports.VERSION = "0.4.5";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanspod",
3
- "version": "0.4.4",
3
+ "version": "0.4.5",
4
4
  "bin": { "vanspod": "bin/vanspod.cjs" },
5
5
  "engines": { "node": ">=24" },
6
6
  "os": ["win32"],