vanspod 0.4.6 → 0.4.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/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.6.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.9.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.6` 為例:
49
+ 發版前同步 `package.json`、`package-lock.json` 與 `src/version.ts` 的版本;tag 必須等於 `v` 加版本號,否則流程失敗。以 `0.4.9` 為例:
50
50
 
51
51
  ```powershell
52
52
  git push origin master
53
- git tag -a v0.4.6 -m "VansPod 0.4.6"
54
- git push origin v0.4.6
53
+ git tag -a v0.4.9 -m "VansPod 0.4.9"
54
+ git push origin v0.4.9
55
55
  ```
56
56
 
57
57
  新版本使用新的版本號與 tag。相同 tag 的 Actions 重跑會更新該 Release 的產物。
@@ -26,6 +26,7 @@ const KEY_REJECTED_NOTICE = {
26
26
  invalid: "Classroom API Key 已失效,請按「清除連線」,再用老師給的新邀請碼重新兌換。",
27
27
  };
28
28
  const MODELS_UNLOADED_NOTICE = "無法載入課堂模型,請按「↻ 更新」再試。";
29
+ const VS_CODE_KEPT_NOTICE = "VS Code 的 VCRouter 已被修改,不再指向 VansPod,VansPod 沒有移除它。";
29
30
  const RESTORE_FETCH_ATTEMPTS = 3;
30
31
  const RESTORE_FETCH_RETRY_MS = 1_000;
31
32
  const INSTALL_UNAVAILABLE = "尚未指定專案資料夾,安裝不可用。";
@@ -815,7 +816,7 @@ class ClassroomApp {
815
816
  // Storage is committed: publish its identity before any client-file operation can fail.
816
817
  if (desiredVsCodeMode === "classroom") {
817
818
  try {
818
- await this.deps.vsCodeRouteSettings?.restore();
819
+ await this.restoreVsCodeRoute();
819
820
  }
820
821
  catch {
821
822
  this.clientRoutes.vsCodeChat.health = "red";
@@ -1020,9 +1021,10 @@ class ClassroomApp {
1020
1021
  route.mode = mode;
1021
1022
  try {
1022
1023
  await this.saveClientRoutePreferences();
1024
+ this.notice = undefined;
1023
1025
  const result = mode === "classroom"
1024
1026
  ? await this.deps.vsCodeRouteSettings?.publish({ providers: this.modelProviders, adapter: route.adapter, origin: this.vsCodeOrigin })
1025
- : await this.deps.vsCodeRouteSettings?.restore();
1027
+ : await this.restoreVsCodeRoute();
1026
1028
  if (mode === "classroom")
1027
1029
  this.settleVsCodePublish(result?.changed);
1028
1030
  else {
@@ -1031,7 +1033,6 @@ class ClassroomApp {
1031
1033
  if (result?.changed)
1032
1034
  this.noteModelRestart("vscode");
1033
1035
  }
1034
- this.notice = undefined;
1035
1036
  }
1036
1037
  catch (error) {
1037
1038
  this.clientRoutes.vsCodeChat = previous;
@@ -1322,7 +1323,7 @@ class ClassroomApp {
1322
1323
  }
1323
1324
  if (retryingNativeRecovery) {
1324
1325
  try {
1325
- await this.deps.vsCodeRouteSettings?.restore();
1326
+ await this.restoreVsCodeRoute();
1326
1327
  this.clientRoutes.vsCodeChat.health = "green";
1327
1328
  this.clientRoutes.vsCodeChat.restart = "ready";
1328
1329
  }
@@ -1347,7 +1348,8 @@ class ClassroomApp {
1347
1348
  if (this.clientRoutes.vsCodeChat.mode === "classroom")
1348
1349
  this.noteClassroomAwaitingModels("vsCodeChat");
1349
1350
  this.clientRoutes.vsCodeChat.mode = "native";
1350
- await this.deps.vsCodeRouteSettings?.initializeNative();
1351
+ if ((await this.deps.vsCodeRouteSettings?.initializeNative())?.kept)
1352
+ this.notice = VS_CODE_KEPT_NOTICE;
1351
1353
  this.clientRoutes.vsCodeChat.health = "green";
1352
1354
  this.clientRoutes.vsCodeChat.restart = "ready";
1353
1355
  }
@@ -1363,9 +1365,16 @@ class ClassroomApp {
1363
1365
  }
1364
1366
  catch { /* Route health remains visible. */ }
1365
1367
  }
1368
+ // 不再指向 VansPod 的 VCRouter 會留在 VS Code 裡,要讓學生知道(ADR-0005 2026-10-26 補充)。
1369
+ async restoreVsCodeRoute() {
1370
+ const result = await this.deps.vsCodeRouteSettings?.restore();
1371
+ if (result?.kept)
1372
+ this.notice = VS_CODE_KEPT_NOTICE;
1373
+ return result;
1374
+ }
1366
1375
  async failVsCodeRouteStart() {
1367
1376
  try {
1368
- await this.deps.vsCodeRouteSettings?.restore();
1377
+ await this.restoreVsCodeRoute();
1369
1378
  }
1370
1379
  catch { /* Journal remains available for retry. */ }
1371
1380
  this.clientRoutes.vsCodeChat = { ...this.clientRoutes.vsCodeChat, mode: "native", health: "red", restart: "ready" };
@@ -1581,7 +1590,7 @@ class ClassroomApp {
1581
1590
  this.clientRoutes.claudeCode.health = "red";
1582
1591
  }
1583
1592
  try {
1584
- await this.deps.vsCodeRouteSettings?.restore();
1593
+ await this.restoreVsCodeRoute();
1585
1594
  if (this.clientRoutes.vsCodeChat.health !== "red") {
1586
1595
  this.clientRoutes.vsCodeChat.health = this.detectedClients.vsCodeChat ? "green" : "gray";
1587
1596
  }
@@ -1751,7 +1760,7 @@ class ClassroomApp {
1751
1760
  this.clientRoutes.claudeCode.health = "red";
1752
1761
  }
1753
1762
  try {
1754
- await this.deps.vsCodeRouteSettings?.restore();
1763
+ await this.restoreVsCodeRoute();
1755
1764
  if (this.clientRoutes.vsCodeChat.health !== "red") {
1756
1765
  this.clientRoutes.vsCodeChat.health = this.detectedClients.vsCodeChat ? "green" : "gray";
1757
1766
  }
@@ -1910,7 +1919,7 @@ class ClassroomApp {
1910
1919
  }
1911
1920
  try {
1912
1921
  if (this.deps.clientRouteRuntime) {
1913
- await this.deps.vsCodeRouteSettings?.restore();
1922
+ await this.restoreVsCodeRoute();
1914
1923
  await this.deps.clientRouteRuntime.stop("vsCodeChat");
1915
1924
  }
1916
1925
  }
@@ -2,42 +2,118 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.lifecyclePage = lifecyclePage;
4
4
  const versionUpdateView_1 = require("./versionUpdateView");
5
+ const TRASH_ICON = `<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="1.8" stroke-linecap="round" stroke-linejoin="round"><path d="M4 7h16M10 11v6M14 11v6M6 7l1 12a2 2 0 0 0 2 2h6a2 2 0 0 0 2-2l1-12M9 7V4h6v3"/></svg>`;
6
+ // 完整移除的確認對話框:先列出會刪除/會保留,實際路徑由管理 API 的預覽填入。
7
+ const REMOVE_DIALOG = `<div class="power-modal" hidden><div class="power-dialog" role="dialog" aria-modal="true" aria-labelledby="power-remove-title"><h3 id="power-remove-title">移除 VansPod?</h3><p class="power-warn">只在不再使用這台電腦上課時移除。更新版本不需要移除,否則會清掉課堂資料。</p><p class="power-warn" data-uninstall-interruptions hidden></p><div class="power-split"><div class="drop"><h4>會刪除</h4><ul><li>課堂憑證(API Key)</li><li>偏好與模式記憶</li><li>日誌與暫存檔</li><li>VansPod 程式本身</li></ul></div><div class="keep"><h4>會保留</h4><ul><li>學生專案與作品</li><li>Node、Git、VS Code</li><li>個人設定</li></ul></div></div><details class="power-paths"><summary>查看實際路徑</summary><pre data-uninstall-preview>讀取中…</pre></details><div class="power-confirm" data-power-modal-confirm hidden></div><div class="power-actions"><button type="button" class="quiet" data-power-modal-close>取消</button><button type="button" class="danger" data-lifecycle-confirm="uninstall">${TRASH_ICON}<span>確認移除</span></button></div></div></div><!-- /power-modal -->`;
5
8
  function lifecyclePage(html, token) {
6
- const controls = `<div style="margin-top:16px"><button type="button" data-lifecycle="stop">結束 VansPod</button> <button type="button" data-lifecycle="uninstall">移除 VansPod</button><p role="status" data-lifecycle-message></p></div>`;
9
+ const stop = `<button type="button" class="power-stop" data-lifecycle="stop">結束 VansPod</button>`;
10
+ const remove = `<button type="button" class="power-remove" data-lifecycle="uninstall">移除 VansPod…</button>`;
7
11
  const script = `<script>
8
12
  (function () {
9
13
  var token = ${JSON.stringify(token)};
14
+ var toggle = document.querySelector('[data-power-toggle]');
15
+ var message = document.querySelector('[data-lifecycle-message]');
16
+ var modal = document.querySelector('.power-modal');
10
17
  async function request(action, body) {
11
18
  var response = await fetch('/_vanspod/' + action, {method: body ? 'POST' : 'GET', headers: {'Authorization': 'Bearer ' + token, 'Content-Type': 'application/json'}, body: body ? JSON.stringify(body) : undefined});
12
19
  if (!response.ok) throw new Error('無法完成操作,請重新開啟 VansPod。');
13
20
  return response.json();
14
21
  }
22
+ // 訊息寫在面板裡;不是成功訊息時,電源鈕亮黃點提醒學生打開看。
23
+ function say(text, ok) {
24
+ message.textContent = text || '';
25
+ message.classList.toggle('ok', !!ok);
26
+ toggle.classList.toggle('has-message', !!text && !ok);
27
+ }
28
+ // 中斷安裝或模型回答前,在面板/對話框裡再問一次,預設停在「取消」。
29
+ // 面板或對話框被關掉時當作取消,按鈕才不會一直停在停用。
30
+ var pending = null;
31
+ function cancelPending(records) {
32
+ if (pending && records.some(function (record) { return record.target.hidden; })) pending(false);
33
+ }
34
+ var watchHidden = new MutationObserver(cancelPending);
35
+ watchHidden.observe(document.getElementById('power-panel'), {attributes: true, attributeFilter: ['hidden']});
36
+ watchHidden.observe(modal, {attributes: true, attributeFilter: ['hidden']});
37
+ function ask(box, text, label) {
38
+ return new Promise(function (resolve) {
39
+ box.textContent = '';
40
+ var question = document.createElement('p'); question.textContent = text;
41
+ var actions = document.createElement('div'); actions.className = 'power-actions';
42
+ var cancel = document.createElement('button'); cancel.type = 'button'; cancel.className = 'quiet'; cancel.textContent = '取消';
43
+ var go = document.createElement('button'); go.type = 'button'; go.className = 'danger'; go.textContent = label;
44
+ actions.append(cancel, go); box.append(question, actions); box.hidden = false; cancel.focus();
45
+ function done(value) { pending = null; box.hidden = true; box.textContent = ''; resolve(value); }
46
+ pending = done;
47
+ cancel.onclick = function () { done(false); };
48
+ go.onclick = function () { done(true); };
49
+ });
50
+ }
51
+ async function run(action, body, box, label) {
52
+ var result = await request(action, body);
53
+ if (!result.confirmation) return result;
54
+ if (!(await ask(box, result.message, label))) return null;
55
+ return request(action, Object.assign({}, body, {confirmed: true, interruptConfirmed: true}));
56
+ }
57
+ function setModal(open) {
58
+ if (modal.hidden === !open) return;
59
+ modal.hidden = !open;
60
+ if (open) modal.querySelector('[data-power-modal-close]').focus();
61
+ else document.querySelector('[data-lifecycle="uninstall"]').focus();
62
+ }
63
+ // 預覽回來前不能確認:學生要先看到會刪除什麼、會中止哪些工作。
64
+ async function openRemoval() {
65
+ var paths = modal.querySelector('[data-uninstall-preview]');
66
+ var interruptions = modal.querySelector('[data-uninstall-interruptions]');
67
+ var confirm = modal.querySelector('[data-lifecycle-confirm="uninstall"]');
68
+ paths.textContent = '讀取中…';
69
+ interruptions.hidden = true;
70
+ confirm.disabled = true;
71
+ setModal(true);
72
+ var preview = await request('uninstall-preview');
73
+ if (!preview.ok) { setModal(false); say(preview.message); return; }
74
+ paths.textContent = preview.message;
75
+ interruptions.textContent = preview.interruptions || '';
76
+ interruptions.hidden = !preview.interruptions;
77
+ confirm.disabled = false;
78
+ }
79
+ async function remove() {
80
+ var result = await run('uninstall', {confirmed: true}, modal.querySelector('[data-power-modal-confirm]'), '仍要移除');
81
+ if (!result) return;
82
+ setModal(false);
83
+ say(result.message || '操作未完成,請重試。', result.ok);
84
+ }
85
+ async function stop() {
86
+ var result = await run('stop', {confirmed: false}, document.querySelector('[data-power-confirm]'), '仍要結束');
87
+ if (!result) return;
88
+ say(result.message || (result.ok ? 'VansPod 已結束,可關閉此分頁。' : '操作未完成,請重試。'), result.ok);
89
+ if (result.ok) document.querySelector('.power-head').textContent = 'VansPod 已結束';
90
+ }
15
91
  document.addEventListener('click', async function (event) {
16
- var button = event.target.closest && event.target.closest('[data-lifecycle]');
92
+ var target = event.target;
93
+ if (!target || !target.closest) return;
94
+ if (target.closest('[data-power-modal-close]') || target === modal) { setModal(false); return; }
95
+ var button = target.closest('[data-lifecycle], [data-lifecycle-confirm]');
17
96
  if (!button) return;
18
- var message = document.querySelector('[data-lifecycle-message]');
19
97
  button.disabled = true;
20
98
  try {
21
- var action = button.dataset.lifecycle;
22
- var confirmed = false;
23
- if (action === 'uninstall') {
24
- var preview = await request('uninstall-preview');
25
- if (!preview.ok) { message.textContent = preview.message; return; }
26
- confirmed = window.confirm(preview.message + '\\n\\n確定完整移除 VansPod?');
27
- if (!confirmed) return;
28
- }
29
- var result = await request(action, {confirmed: confirmed});
30
- if (result.confirmation && window.confirm(result.message)) result = await request(action, {confirmed: true, interruptConfirmed: true});
31
- message.textContent = result.message || (result.ok ? 'VansPod 已結束,可關閉此分頁。' : '操作未完成,請重試。');
32
- } catch (error) { message.textContent = error.message; }
99
+ if (button.dataset.lifecycle === 'stop') await stop();
100
+ else if (button.dataset.lifecycle === 'uninstall') await openRemoval();
101
+ else await remove();
102
+ } catch (error) { setModal(false); say(error.message); }
33
103
  finally { button.disabled = false; }
34
104
  });
105
+ document.addEventListener('keydown', function (event) {
106
+ if (event.key === 'Escape' && !modal.hidden) setModal(false);
107
+ });
35
108
  request('status').then(function (status) {
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; }
38
- if (status.launchVersion && status.launchVersion !== status.version) document.querySelector('[data-lifecycle-message]').textContent = '目前執行版本 ' + status.version + ',本次開啟版本 ' + status.launchVersion + '。換版請先結束 VansPod。';
109
+ if (status.startupError) { say(status.startupError); return; }
110
+ if (status.trayError) { say('右下角的系統匣圖示無法顯示,VansPod 仍在背景執行。要結束時請用側欄底部的電源鈕。'); return; }
111
+ if (status.launchVersion && status.launchVersion !== status.version) say('目前執行版本 ' + status.version + ',本次開啟版本 ' + status.launchVersion + '。換版請先結束 VansPod。');
39
112
  }).catch(function () {});
40
113
  })();
41
114
  </script>`;
42
- return html.replace(/<form method="post" action="\/stop">[\s\S]*?<\/form>/, controls).replace('</body>', `${script}${(0, versionUpdateView_1.versionUpdateScript)(token)}</body>`);
115
+ return html
116
+ .replace(/<form method="post" action="\/stop">[\s\S]*?<\/form>/, stop)
117
+ .replace("<!-- /power-panel -->", `${remove}<!-- /power-panel -->`)
118
+ .replace("</body>", `${REMOVE_DIALOG}${script}${(0, versionUpdateView_1.versionUpdateScript)(token)}</body>`);
43
119
  }
package/dist/page.js CHANGED
@@ -3,7 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.modelStatus = modelStatus;
4
4
  exports.environmentStageText = environmentStageText;
5
5
  exports.environmentStatus = environmentStatus;
6
- exports.classroomBlocks = classroomBlocks;
7
6
  exports.renderPage = renderPage;
8
7
  exports.renderInspectorPage = renderInspectorPage;
9
8
  const version_1 = require("./version");
@@ -20,6 +19,7 @@ const classroomApp_1 = require("./classroomApp");
20
19
  const promptCapture_1 = require("./promptCapture");
21
20
  const inspectorView_1 = require("./inspectorView");
22
21
  const versionUpdateView_1 = require("./versionUpdateView");
22
+ const powerMenuView_1 = require("./powerMenuView");
23
23
  const courseCatalog_1 = require("./courseCatalog");
24
24
  const PRODUCT = "VansPod";
25
25
  const VERSION = `v${version_1.VERSION}`;
@@ -312,9 +312,6 @@ function catalogTable(view) {
312
312
  const snippetBlock = snippets ? `<h3>本課片段</h3>${snippets}` : "";
313
313
  return `${head}${table}${snippetBlock}`;
314
314
  }
315
- function stopForm() {
316
- return `<form method="post" action="/stop"><button type="submit" class="stop">停止</button></form>`;
317
- }
318
315
  function tile(title, body, wide = false) {
319
316
  return `<section class="tile${wide ? " wide" : ""}"><h2>${title}</h2>${body}</section>`;
320
317
  }
@@ -608,19 +605,6 @@ function appearanceScript() {
608
605
  });
609
606
  `;
610
607
  }
611
- function classroomBlocks(view) {
612
- return {
613
- status: statusWord(view),
614
- notices: notices(view),
615
- connect: connectInner(view),
616
- folder: folderInner(view),
617
- model: modelInner(view),
618
- environment: environmentInner(view),
619
- command: commandInner(view),
620
- catalog: catalogTable(view),
621
- stop: stopForm(),
622
- };
623
- }
624
608
  const SIDE_PAGES = [
625
609
  {
626
610
  id: "settings",
@@ -639,7 +623,7 @@ const BRAND = `<div class="brand"><div class="logo-badge"><img src="/brand-logo.
639
623
  /** 兩頁共用的側欄:行動版頂列、抽屜遮罩、選單與外觀切換。 */
640
624
  function sideMenu(current) {
641
625
  const items = SIDE_PAGES.map((page) => `<a class="side-item" href="${page.href}"${page.id === current ? ' aria-current="page"' : ""}>${page.icon}<span>${page.label}</span></a>`).join("");
642
- return `<div class="mobile-top"><button type="button" class="menu-toggle" aria-label="開啟選單" aria-expanded="false" aria-controls="side-menu"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 7h16M4 12h16M4 17h16"/></svg></button>${BRAND}</div><button type="button" class="drawer-scrim" aria-label="關閉選單"></button><header class="bar" id="side-menu">${BRAND}<nav aria-label="選單">${items}</nav><div class="side-foot"><button type="button" data-appearance-toggle aria-label="切換外觀"></button>${versionUpdateView_1.UPDATE_BUTTON}</div></header>`;
626
+ return `<div class="mobile-top"><button type="button" class="menu-toggle" aria-label="開啟選單" aria-expanded="false" aria-controls="side-menu"><svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M4 7h16M4 12h16M4 17h16"/></svg></button>${BRAND}</div><button type="button" class="drawer-scrim" aria-label="關閉選單"></button><header class="bar" id="side-menu">${BRAND}<nav aria-label="選單">${items}</nav><div class="side-foot"><button type="button" data-appearance-toggle aria-label="切換外觀"></button>${versionUpdateView_1.UPDATE_BUTTON}${(0, powerMenuView_1.powerMenu)(VERSION)}</div></header>`;
643
627
  }
644
628
  /** 兩頁共用的頁殼版面:側欄、行動版抽屜。 */
645
629
  const SHELL_LAYOUT_STYLES = `
@@ -657,6 +641,7 @@ const SHELL_LAYOUT_STYLES = `
657
641
  .side-item:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
658
642
  .side-item svg { width: 18px; height: 18px; flex-shrink: 0; }
659
643
  ${versionUpdateView_1.VERSION_UPDATE_STYLES}
644
+ ${powerMenuView_1.POWER_MENU_STYLES}
660
645
  .mobile-top, .drawer-scrim, .menu-toggle { display: none; }
661
646
  main { justify-self: center; width: min(52rem, 100%); }
662
647
  @media (max-width: 760px) {
@@ -718,7 +703,6 @@ function basePage(view) {
718
703
  ${tile("環境", environmentInner(view))}
719
704
  ${tile("指令", commandInner(view), true)}
720
705
  ${tile("課程", catalogTable(view), true)}
721
- ${tile("離開", stopForm(), true)}
722
706
  </div>
723
707
  </main>
724
708
  </body>
@@ -1114,7 +1098,7 @@ function renderPage(view) {
1114
1098
  main button.connection-clear:hover:not(:disabled) { color: light-dark(#b91c1c, #f87171); }
1115
1099
  ${classroomUpdate_1.classroomUpdateStyles}
1116
1100
  </style>
1117
- <script>${drawerScript()}${installProgress_1.installProgressScript}${environmentProgress_1.environmentProgressScript}${snippetCopyScript()}${courseSectionScript()}${connectionMascot_1.connectionMascotScript}${classroomUpdate_1.classroomUpdateScript}${settingsActions_1.settingsActionsScript}${modelStatus_1.modelStatusScript}
1101
+ <script>${drawerScript()}${powerMenuView_1.powerMenuScript}${installProgress_1.installProgressScript}${environmentProgress_1.environmentProgressScript}${snippetCopyScript()}${courseSectionScript()}${connectionMascot_1.connectionMascotScript}${classroomUpdate_1.classroomUpdateScript}${settingsActions_1.settingsActionsScript}${modelStatus_1.modelStatusScript}
1118
1102
  </script>`;
1119
1103
  return html.replace("</body>", `${extra}</body>`);
1120
1104
  }
@@ -1186,7 +1170,7 @@ function renderInspectorPage(view) {
1186
1170
  ${inspectorView_1.INSPECTOR_STYLES}
1187
1171
  </style>
1188
1172
  ${headPatrol.sheet}
1189
- <script>${drawerScript()}${connectionMascot_1.connectionMascotScript}${headPatrol.script}${recorderActionsScript}${(0, inspectorView_1.inspectorScript)()}</script>
1173
+ <script>${drawerScript()}${powerMenuView_1.powerMenuScript}${connectionMascot_1.connectionMascotScript}${headPatrol.script}${recorderActionsScript}${(0, inspectorView_1.inspectorScript)()}</script>
1190
1174
  </body>
1191
1175
  </html>`;
1192
1176
  }
@@ -0,0 +1,78 @@
1
+ "use strict";
2
+ // 側欄底部最右邊的電源鈕(原型 F)。只放 icon,點了先開面板說明後果,不會直接結束。
3
+ // 面板裡的「結束」是 /stop 表單;有管理 API 時由 lifecyclePage 換成生命週期按鈕並加上完整移除。
4
+ Object.defineProperty(exports, "__esModule", { value: true });
5
+ exports.powerMenuScript = exports.POWER_MENU_STYLES = void 0;
6
+ exports.powerMenu = powerMenu;
7
+ const POWER_ICON = `<svg viewBox="0 0 24 24" aria-hidden="true" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round"><path d="M12 3v8"/><path d="M6.3 6.8a8 8 0 1 0 11.4 0"/></svg>`;
8
+ function powerMenu(version) {
9
+ return `<div class="power-menu"><button type="button" class="power-toggle" data-power-toggle aria-label="結束或移除 VansPod" title="結束 VansPod" aria-haspopup="dialog" aria-expanded="false" aria-controls="power-panel">${POWER_ICON}<span class="power-dot" aria-hidden="true"></span></button><div class="power-panel" id="power-panel" role="dialog" aria-label="結束 VansPod" hidden><div class="power-head"><span class="power-live" aria-hidden="true"></span><strong>VansPod ${version} 執行中</strong></div><p class="power-message" role="status" data-lifecycle-message></p><p class="power-note">下課時再結束。課堂連線會中斷,各工具設定恢復原狀;課堂資料保留,下次開啟可接續。</p><div class="power-confirm" data-power-confirm hidden></div><div class="power-actions"><button type="button" class="quiet" data-power-close>取消</button><form method="post" action="/stop"><button type="submit" class="power-stop">結束 VansPod</button></form></div><!-- /power-panel --></div></div>`;
10
+ }
11
+ exports.POWER_MENU_STYLES = `
12
+ .bar .side-foot { position: relative; }
13
+ .power-menu { margin-left: auto; padding-left: 10px; border-left: 1px solid var(--line); display: flex; }
14
+ .power-toggle { 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; }
15
+ .power-toggle svg { width: 1.2rem; height: 1.2rem; }
16
+ .power-toggle:hover, .power-toggle[aria-expanded="true"] { color: light-dark(#b91c1c, #f87171); border-color: light-dark(rgba(185, 28, 28, 0.35), rgba(248, 113, 113, 0.35)); background: light-dark(rgba(185, 28, 28, 0.05), rgba(248, 113, 113, 0.08)); }
17
+ .power-toggle:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
18
+ .power-dot { display: none; position: absolute; top: 3px; right: 3px; width: 8px; height: 8px; border-radius: 999px; background: #f59e0b; box-shadow: 0 0 0 2px var(--bg); }
19
+ .power-toggle.has-message .power-dot { display: block; }
20
+ .power-panel { position: absolute; left: 0; bottom: calc(100% + 10px); z-index: 50; width: min(300px, calc(100vw - 32px)); display: flex; flex-direction: column; gap: 10px; padding: 14px; border-radius: 14px; border: 1px solid var(--line); background: var(--tile); box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25); color: var(--text); font-size: 13px; }
21
+ .power-panel[hidden] { display: none; }
22
+ .power-head { display: flex; align-items: center; gap: 8px; }
23
+ .power-live { width: 8px; height: 8px; border-radius: 999px; background: light-dark(#10a37f, #4ecb9d); box-shadow: 0 0 0 3px light-dark(rgba(16, 163, 127, 0.15), rgba(78, 203, 157, 0.15)); }
24
+ .power-note { color: var(--muted); line-height: 1.6; }
25
+ .power-message:empty { display: none; }
26
+ .power-message { padding: 10px 12px; border-radius: 10px; background: light-dark(#fff7ed, #3b3024); color: light-dark(#9a3412, #fed7aa); line-height: 1.6; white-space: pre-line; }
27
+ .power-message.ok { background: light-dark(rgba(16, 163, 127, 0.10), rgba(78, 203, 157, 0.13)); color: light-dark(#0a7d5c, #4ecb9d); }
28
+ .power-confirm { display: flex; flex-direction: column; gap: 10px; padding: 12px; border-radius: 10px; border: 1px solid light-dark(rgba(185, 28, 28, 0.30), rgba(248, 113, 113, 0.30)); background: light-dark(rgba(185, 28, 28, 0.04), rgba(248, 113, 113, 0.06)); line-height: 1.6; white-space: pre-line; }
29
+ .power-confirm[hidden] { display: none; }
30
+ .power-actions { display: flex; justify-content: flex-end; align-items: center; gap: 8px; flex-wrap: wrap; }
31
+ .power-panel button, .power-dialog button { min-height: 34px; padding: 8px 16px; border-radius: 999px; border: 1px solid transparent; background: var(--accent); color: var(--on-accent); font-size: 13px; font-weight: 500; }
32
+ .power-panel button.quiet, .power-dialog button.quiet { background: transparent; color: var(--text); border-color: var(--line); }
33
+ .power-panel button.danger, .power-dialog button.danger { display: inline-flex; align-items: center; gap: 6px; background: light-dark(#b91c1c, #f87171); color: light-dark(#ffffff, #1c1c1e); }
34
+ .power-dialog button.danger svg { width: 15px; height: 15px; }
35
+ .power-panel .power-remove { width: 100%; min-height: 0; padding: 10px 0 0; border: 0; border-top: 1px solid var(--line); border-radius: 0; background: transparent; color: var(--muted); font-size: 12px; text-align: left; }
36
+ .power-panel .power-remove:hover { color: light-dark(#b91c1c, #f87171); }
37
+ .power-modal { position: fixed; inset: 0; z-index: 96; display: grid; place-items: center; padding: 24px; background: light-dark(rgba(20, 20, 20, 0.32), rgba(0, 0, 0, 0.52)); }
38
+ .power-modal[hidden] { display: none; }
39
+ .power-dialog { width: min(34rem, 100%); max-height: calc(100dvh - 48px); overflow: auto; display: flex; flex-direction: column; gap: 12px; padding: 18px; border-radius: 16px; border: 1px solid var(--line); background: var(--tile); color: var(--text); font-size: 13px; }
40
+ .power-dialog > h3 { margin: 0; font-size: 18px; font-weight: 600; }
41
+ .power-warn { padding: 10px 12px; border-radius: 10px; background: light-dark(#fff7ed, #3b3024); color: light-dark(#9a3412, #fed7aa); line-height: 1.6; }
42
+ .power-split { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
43
+ .power-split > div { padding: 10px 12px; border-radius: 10px; background: var(--input); }
44
+ .power-split h4 { margin: 0 0 6px; font-size: 12px; font-weight: 600; }
45
+ .power-split .drop h4 { color: light-dark(#b91c1c, #f87171); }
46
+ .power-split .keep h4 { color: light-dark(#0a7d5c, #4ecb9d); }
47
+ .power-split ul { margin: 0; padding-left: 18px; line-height: 1.7; }
48
+ .power-paths summary { width: fit-content; cursor: pointer; color: var(--muted); font-size: 12px; }
49
+ .power-paths pre { margin: 6px 0 0; padding: 10px 12px; border-radius: 8px; background: var(--input); font-size: 12px; line-height: 1.6; }
50
+ @media (max-width: 40rem) { .power-split { grid-template-columns: 1fr; } }
51
+ @media (max-width: 760px) { .power-panel { width: 100%; } }`;
52
+ /** 面板開關:點電源鈕切換,取消/Esc/點面板外關閉。完整移除的對話框開著時不收面板。 */
53
+ exports.powerMenuScript = `
54
+ (function () {
55
+ var toggle = document.querySelector("[data-power-toggle]");
56
+ var panel = document.getElementById("power-panel");
57
+ if (!toggle || !panel) return;
58
+ function setOpen(open) {
59
+ panel.hidden = !open;
60
+ toggle.setAttribute("aria-expanded", open ? "true" : "false");
61
+ if (open) panel.querySelector("[data-power-close]").focus();
62
+ }
63
+ document.addEventListener("click", function (event) {
64
+ var target = event.target;
65
+ if (!target || !target.closest) return;
66
+ if (target.closest("[data-power-toggle]")) { setOpen(panel.hidden); return; }
67
+ if (target.closest("[data-power-close]")) { setOpen(false); toggle.focus(); return; }
68
+ if (!panel.hidden && !target.closest(".power-menu") && !target.closest(".power-modal")) setOpen(false);
69
+ });
70
+ document.addEventListener("keydown", function (event) {
71
+ if (event.key !== "Escape" || panel.hidden) return;
72
+ var modal = document.querySelector(".power-modal");
73
+ if (modal && !modal.hidden) return;
74
+ setOpen(false);
75
+ toggle.focus();
76
+ });
77
+ })();
78
+ `;
package/dist/start.js CHANGED
@@ -21,7 +21,6 @@ const commandRunner_1 = require("./commandRunner");
21
21
  const windowsEnvironment_1 = require("./windowsEnvironment");
22
22
  const windowsEnvironmentSystem_1 = require("./windowsEnvironmentSystem");
23
23
  const exitGuard_1 = require("./exitGuard");
24
- const pagePrototype_1 = require("./pagePrototype");
25
24
  const routeFiles_1 = require("./routeFiles");
26
25
  const responsesChat_1 = require("./responsesChat");
27
26
  const adapterSettings_1 = require("./adapterSettings");
@@ -42,6 +41,7 @@ const version_1 = require("./version");
42
41
  const runtimeOptions = (0, runtimeOptions_1.readRuntimeOptions)(process.env);
43
42
  const port = runtimeOptions.port;
44
43
  const pageUrl = `http://127.0.0.1:${port}/`;
44
+ const CLIENT_ROUTE_LABELS = { codex: "Codex", claudeCode: "Claude Code", vsCodeChat: "VS Code Chat" };
45
45
  const responseSlot = new node_async_hooks_1.AsyncLocalStorage();
46
46
  const activeRequests = new Set();
47
47
  function abortRequests() { for (const controller of activeRequests)
@@ -444,18 +444,13 @@ async function main(instance) {
444
444
  }
445
445
  const parsed = new URL(req.url ?? "/", `http://127.0.0.1:${port}`);
446
446
  const pathname = parsed.pathname;
447
- const goHome = (params) => {
447
+ const goHome = () => {
448
448
  if (req.headers["x-classroom-settings"] === "1") {
449
449
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8", "Cache-Control": "no-store" });
450
450
  const html = (0, page_1.renderPage)(app.pageView());
451
451
  res.end(instance ? (0, lifecyclePage_1.lifecyclePage)(html, instance.token) : html);
452
452
  return;
453
453
  }
454
- const variant = params?.get("prototype_variant") ?? "";
455
- if (process.env.NODE_ENV !== "production" && (0, pagePrototype_1.isPrototypeVariant)(variant)) {
456
- redirect(res, `/?variant=${variant}`);
457
- return;
458
- }
459
454
  redirect(res);
460
455
  };
461
456
  try {
@@ -486,7 +481,8 @@ async function main(instance) {
486
481
  return;
487
482
  }
488
483
  if (req.method === "GET" && pathname === "/_vanspod/uninstall-preview") {
489
- reply({ ok: true, message: `${await (0, removal_1.removalPreview)()}${(0, exitGuard_1.removalInterruptions)(exitWork())}` });
484
+ const interruptions = (0, exitGuard_1.removalInterruptions)(exitWork());
485
+ reply({ ok: true, message: `${await (0, removal_1.removalPreview)()}${interruptions}`, interruptions: interruptions.trim() });
490
486
  return;
491
487
  }
492
488
  if (req.method === "POST" && (pathname === "/_vanspod/stop" || pathname === "/_vanspod/uninstall")) {
@@ -513,7 +509,7 @@ async function main(instance) {
513
509
  res.once("finish", () => { void exit(); });
514
510
  }
515
511
  else
516
- reply({ ok: false, message: handed.restored ? `移除未完成:${handed.error instanceof Error ? handed.error.message : "移除工具啟動失敗"}。請重試移除。` : `客戶端設定恢復失敗(${Object.entries(app.view().clientRoutes ?? {}).filter(([, route]) => route.health === "red").map(([id]) => id).join("、")}),備份已保留,請重試結束。` });
512
+ reply({ ok: false, message: handed.restored ? `移除未完成:${handed.error instanceof Error ? handed.error.message : "移除工具啟動失敗"}。請重試移除。` : `客戶端設定恢復失敗(${Object.entries(app.view().clientRoutes ?? {}).filter(([, route]) => route.health === "red").map(([id]) => CLIENT_ROUTE_LABELS[id] ?? id).join("、")}):${handed.error instanceof Error ? handed.error.message : "原因不明"}。備份已保留,請重試結束。` });
517
513
  return;
518
514
  }
519
515
  reply({ ok: false, message: "管理操作無效。" });
@@ -573,10 +569,7 @@ async function main(instance) {
573
569
  // 版本更新後重新啟動時,舊分頁一拿到首頁就重新整理頁面;
574
570
  // 等 Classroom Connection 恢復、Course Catalog 載入後才給頁面,免得課程安裝停在尚未載入的狀態。
575
571
  await startupSettled;
576
- const variant = parsed.searchParams.get("variant") ?? "";
577
- const html = process.env.NODE_ENV !== "production" && (0, pagePrototype_1.isPrototypeVariant)(variant)
578
- ? (0, pagePrototype_1.renderPrototypePage)(app.pageView(), variant)
579
- : (0, page_1.renderPage)(app.pageView());
572
+ const html = (0, page_1.renderPage)(app.pageView());
580
573
  res.writeHead(200, {
581
574
  "Content-Type": "text/html; charset=utf-8",
582
575
  "Cache-Control": "no-store",
@@ -596,7 +589,7 @@ async function main(instance) {
596
589
  if (req.method === "POST" && pathname === "/redeem") {
597
590
  const params = new URLSearchParams(await readBody(req));
598
591
  await app.redeem(params.get("invite_code") ?? "", params.get("nickname") ?? "");
599
- goHome(params);
592
+ goHome();
600
593
  return;
601
594
  }
602
595
  if (req.method === "POST" && pathname === "/pick-folder") {
@@ -604,7 +597,7 @@ async function main(instance) {
604
597
  const picked = await (0, folderPicker_1.pickProjectFolder)();
605
598
  if (picked)
606
599
  await app.setProjectFolder(picked);
607
- goHome(params);
600
+ goHome();
608
601
  return;
609
602
  }
610
603
  if (req.method === "POST" && pathname === "/project-folder") {
@@ -616,7 +609,7 @@ async function main(instance) {
616
609
  else {
617
610
  app.rejectProjectFolder();
618
611
  }
619
- goHome(params);
612
+ goHome();
620
613
  return;
621
614
  }
622
615
  if (req.method === "POST" && pathname === "/prepare") {
@@ -628,7 +621,7 @@ async function main(instance) {
628
621
  res.end((0, page_1.renderPage)(view));
629
622
  return;
630
623
  }
631
- goHome(params);
624
+ goHome();
632
625
  return;
633
626
  }
634
627
  if (req.method === "POST" && pathname === "/confirm") {
@@ -640,7 +633,7 @@ async function main(instance) {
640
633
  res.end(JSON.stringify({ succeeded: view.commandSucceeded, aborted: view.commandAborted === true, output: view.commandOutput ?? "", installedActionIds: view.installedActionIds ?? [] }));
641
634
  return;
642
635
  }
643
- goHome(params);
636
+ goHome();
644
637
  return;
645
638
  }
646
639
  if (req.method === "POST" && pathname === "/cancel") {
@@ -652,7 +645,7 @@ async function main(instance) {
652
645
  res.end(JSON.stringify({ canceled }));
653
646
  return;
654
647
  }
655
- goHome(params);
648
+ goHome();
656
649
  return;
657
650
  }
658
651
  if (req.method === "POST" && pathname === "/abort-install") {
@@ -663,25 +656,25 @@ async function main(instance) {
663
656
  res.end(JSON.stringify({ aborted: true }));
664
657
  return;
665
658
  }
666
- goHome(params);
659
+ goHome();
667
660
  return;
668
661
  }
669
662
  if (req.method === "POST" && pathname === "/environment-check") {
670
663
  const params = new URLSearchParams(await readBody(req));
671
664
  await app.checkEnvironment();
672
- goHome(params);
665
+ goHome();
673
666
  return;
674
667
  }
675
668
  if (req.method === "POST" && pathname === "/environment-log") {
676
669
  const params = new URLSearchParams(await readBody(req));
677
670
  await app.openEnvironmentLog();
678
- goHome(params);
671
+ goHome();
679
672
  return;
680
673
  }
681
674
  if (req.method === "POST" && pathname === "/open-vscode") {
682
675
  const params = new URLSearchParams(await readBody(req));
683
676
  await app.openVsCode().catch(() => { });
684
- goHome(params);
677
+ goHome();
685
678
  return;
686
679
  }
687
680
  if (req.method === "POST" && pathname === "/environment") {
@@ -693,13 +686,13 @@ async function main(instance) {
693
686
  // 背景安裝:請求立刻回來,頁面輪詢 /environment-status。commandRunning 在 confirmEnvironment 同步開頭就設好,
694
687
  // 轉回首頁時已顯示進行中,exit guard、版本更新與移除也照常看得到這次安裝。
695
688
  void app.confirmEnvironment().catch(() => { });
696
- goHome(params);
689
+ goHome();
697
690
  return;
698
691
  }
699
692
  if (req.method === "POST" && pathname === "/copy") {
700
693
  const params = new URLSearchParams(await readBody(req));
701
694
  await app.copyKey();
702
- goHome(params);
695
+ goHome();
703
696
  return;
704
697
  }
705
698
  if (req.method === "POST" && pathname === "/copy-snippet") {
@@ -712,7 +705,7 @@ async function main(instance) {
712
705
  if (req.method === "POST" && pathname === "/clear") {
713
706
  const params = new URLSearchParams(await readBody(req));
714
707
  await app.clearConnection();
715
- goHome(params);
708
+ goHome();
716
709
  return;
717
710
  }
718
711
  if (req.method === "POST" && pathname === "/switch") {
@@ -727,7 +720,7 @@ async function main(instance) {
727
720
  }
728
721
  await app.setSwitch(mode, client ?? undefined);
729
722
  }
730
- goHome(params);
723
+ goHome();
731
724
  return;
732
725
  }
733
726
  if (req.method === "POST" && pathname === "/adapter") {
@@ -739,14 +732,14 @@ async function main(instance) {
739
732
  return;
740
733
  }
741
734
  await app.setAdapter(client, params.get("adapter") ?? "");
742
- goHome(params);
735
+ goHome();
743
736
  return;
744
737
  }
745
738
  if (req.method === "POST" && pathname === "/reload") {
746
739
  const params = new URLSearchParams(await readBody(req));
747
740
  await app.reloadCatalog();
748
741
  await app.reloadAllowlist();
749
- goHome(params);
742
+ goHome();
750
743
  return;
751
744
  }
752
745
  if ((req.method === "POST" || req.method === "PUT") &&
@@ -803,7 +796,7 @@ async function main(instance) {
803
796
  }
804
797
  const params = new URLSearchParams(await readBody(req));
805
798
  await app.stop();
806
- goHome(params);
799
+ goHome();
807
800
  return;
808
801
  }
809
802
  if (req.method === "POST" && pathname === "/close") {
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.6";
4
+ exports.VERSION = "0.4.9";
@@ -79,6 +79,15 @@ function namedIndexes(providers) {
79
79
  });
80
80
  return result;
81
81
  }
82
+ // VansPod 的 provider 以代理網址辨認,不比對整份內容:VS Code 會自己加欄位(例如推理強度的 settings)。
83
+ // 沒有模型可比網址時,只認得與寫入時完全相同的內容。
84
+ function pointsAtVansPod(journal) {
85
+ const urls = new Set((journal.intended.models ?? []).map(model => model?.url).filter((url) => typeof url === "string"));
86
+ return provider => (0, node_util_1.isDeepStrictEqual)(provider, journal.intended) ||
87
+ provider.name === "VCRouter" && provider.vendor === "customendpoint" &&
88
+ Array.isArray(provider.models) && provider.models.length > 0 &&
89
+ provider.models.every(model => !!model && typeof model === "object" && urls.has(model.url));
90
+ }
82
91
  function containsOldExtensionSecret(provider) {
83
92
  return JSON.stringify(provider).includes("${input:chat.lm.secret.");
84
93
  }
@@ -136,19 +145,19 @@ function intendedProvider(template, adapter, origin) {
136
145
  return provider;
137
146
  }
138
147
  function createVsCodeRouteSettings(options) {
148
+ // 只移除仍指向 VansPod 代理的 VCRouter;已被移除或改成別的網址的,視為不再由 VansPod 接管。
139
149
  const restore = async () => {
140
150
  const journal = await readJournal(options.journalFile);
141
151
  if (!journal)
142
152
  return { changed: false };
143
153
  const current = await readProviders(options.settingsFile);
144
- const indexes = namedIndexes(current);
145
- if (indexes.length !== 1 || !(0, node_util_1.isDeepStrictEqual)(current[indexes[0]], journal.intended)) {
146
- throw new Error("VS Code 的 VCRouter provider 已被其他程式修改,VansPod 不會覆寫。");
147
- }
148
- const next = current.filter((_provider, index) => index !== indexes[0]);
149
- await atomicJson(options.settingsFile, next);
154
+ const owned = pointsAtVansPod(journal);
155
+ const next = current.filter(provider => !owned(provider));
156
+ const changed = next.length !== current.length;
157
+ if (changed)
158
+ await atomicJson(options.settingsFile, next);
150
159
  await promises_1.default.rm(options.journalFile, { force: true });
151
- return { changed: true };
160
+ return namedIndexes(next).length ? { changed, kept: true } : { changed };
152
161
  };
153
162
  return {
154
163
  async publish({ providers, adapter, origin }) {
@@ -157,16 +166,14 @@ function createVsCodeRouteSettings(options) {
157
166
  const journal = await readJournal(options.journalFile);
158
167
  let original = null;
159
168
  let next;
160
- if (journal) {
161
- const indexes = namedIndexes(current);
162
- if (indexes.length !== 1 || !(0, node_util_1.isDeepStrictEqual)(current[indexes[0]], journal.intended)) {
163
- throw new Error("VS Code 的 VCRouter provider 已被其他程式修改,VansPod 不會覆寫。");
164
- }
169
+ const existing = namedIndexes(current).map(index => current[index]);
170
+ if (journal && existing.length === 1 && pointsAtVansPod(journal)(existing[0])) {
171
+ // VS Code 或學生加上的欄位(例如推理強度)保留;VansPod 寫過的欄位才覆寫。
172
+ const added = Object.fromEntries(Object.entries(existing[0]).filter(([key]) => !(key in journal.intended) && !(key in intended)));
165
173
  original = journal.original;
166
- next = current.map((provider, index) => index === indexes[0] ? intended : provider);
174
+ next = current.map(provider => provider === existing[0] ? { ...intended, ...added } : provider);
167
175
  }
168
176
  else {
169
- const existing = namedIndexes(current).map(index => current[index]);
170
177
  if (existing.some(containsOldExtensionSecret)) {
171
178
  throw new Error("偵測到舊擴充的 VCRouter provider。請先在舊擴充清除舊擴充的 Classroom Connection,再回到 VansPod 重新載入。");
172
179
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "vanspod",
3
- "version": "0.4.6",
3
+ "version": "0.4.9",
4
4
  "bin": { "vanspod": "bin/vanspod.cjs" },
5
5
  "engines": { "node": ">=24" },
6
6
  "os": ["win32"],
@@ -1,528 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.PROTOTYPE_VARIANTS = void 0;
4
- exports.isPrototypeVariant = isPrototypeVariant;
5
- exports.renderPrototypePage = renderPrototypePage;
6
- const page_1 = require("./page");
7
- const PRODUCT = "VansPod";
8
- exports.PROTOTYPE_VARIANTS = ["A", "B", "C", "D"];
9
- const VARIANT_NAME = {
10
- A: "側欄控制台",
11
- B: "設定清單",
12
- C: "工作區",
13
- D: "原本",
14
- };
15
- const SECTIONS = [
16
- { id: "connect", label: "連線" },
17
- { id: "folder", label: "資料夾" },
18
- { id: "model", label: "模型" },
19
- { id: "environment", label: "環境" },
20
- { id: "command", label: "指令" },
21
- { id: "catalog", label: "課程" },
22
- ];
23
- function isPrototypeVariant(value) {
24
- return exports.PROTOTYPE_VARIANTS.includes(value);
25
- }
26
- function stamp(html, variant) {
27
- if (!variant)
28
- return html;
29
- return html.replaceAll(/<form\b([^>]*)>/g, `<form$1><input type="hidden" name="prototype_variant" value="${variant}">`);
30
- }
31
- function stateText(view) {
32
- return JSON.stringify({
33
- connected: view.connected,
34
- mode: view.mode,
35
- modelId: view.modelId ?? null,
36
- classLabel: view.classLabel ?? null,
37
- detail: view.detail,
38
- notice: view.notice ?? null,
39
- projectFolder: view.projectFolder ?? null,
40
- installAvailable: view.installAvailable,
41
- commandRunning: view.commandRunning,
42
- pendingCommand: view.pendingCommand ?? null,
43
- catalogError: view.catalogError ?? null,
44
- actions: view.catalog?.actions.length ?? 0,
45
- snippets: view.catalog?.snippets?.length ?? 0,
46
- tools: view.tools.map((tool) => ({
47
- id: tool.id,
48
- readiness: tool.readiness,
49
- selected: tool.selected,
50
- })),
51
- mustRestart: view.mustRestart ?? [],
52
- }, null, 2);
53
- }
54
- const CSS = `
55
- :root {
56
- color-scheme: light dark;
57
- --bg: light-dark(#ffffff, #212121);
58
- --rail: light-dark(#f9f9f9, #171717);
59
- --surface: light-dark(#ffffff, #262626);
60
- --raised: light-dark(#f4f4f4, #303030);
61
- --border: light-dark(#e6e6e6, #3d3d3d);
62
- --border-soft: light-dark(#f0f0f0, #333333);
63
- --text: light-dark(#0d0d0d, #ececec);
64
- --muted: light-dark(#6e6e6e, #a6a6a6);
65
- --faint: light-dark(#707070, #9a9a9a);
66
- --accent: light-dark(#0d0d0d, #ececec);
67
- --accent-hover: light-dark(#3d3d3d, #ffffff);
68
- --accent-ink: light-dark(#ffffff, #0d0d0d);
69
- --accent-soft: light-dark(rgba(13, 13, 13, 0.06), rgba(255, 255, 255, 0.09));
70
- --accent-ring: light-dark(rgba(0, 0, 0, 0.5), rgba(255, 255, 255, 0.38));
71
- --green: light-dark(#0a7d5c, #4ecb9d);
72
- --green-soft: light-dark(rgba(16, 163, 127, 0.10), rgba(78, 203, 157, 0.13));
73
- --red: light-dark(#b91c1c, #f87171);
74
- --red-soft: light-dark(rgba(185, 28, 28, 0.09), rgba(248, 113, 113, 0.13));
75
- --amber: light-dark(#9a4a08, #fbbf24);
76
- --glass-rail: light-dark(rgba(249, 249, 249, 0.66), rgba(23, 23, 23, 0.62));
77
- --radius: 12px;
78
- --radius-sm: 8px;
79
- --radius-pill: 999px;
80
- --font-ui: "Segoe UI", "Microsoft JhengHei", system-ui, sans-serif;
81
- --font-code: ui-monospace, "Cascadia Code", Consolas, monospace;
82
- }
83
- :root[data-theme="light"] { color-scheme: light; }
84
- :root[data-theme="dark"] { color-scheme: dark; }
85
- * { box-sizing: border-box; }
86
- html, body { margin: 0; min-height: 100%; }
87
- body {
88
- background: transparent;
89
- color: var(--text);
90
- font-family: var(--font-ui);
91
- font-size: 14px;
92
- line-height: 1.5;
93
- }
94
- body::before {
95
- content: "";
96
- position: fixed;
97
- inset: -20%;
98
- z-index: -1;
99
- pointer-events: none;
100
- background:
101
- radial-gradient(42% 38% at 12% 6%, light-dark(rgba(164, 196, 255, 0.42), rgba(96, 130, 200, 0.16)), transparent 70%),
102
- radial-gradient(46% 42% at 88% 18%, light-dark(rgba(168, 226, 197, 0.38), rgba(88, 160, 130, 0.13)), transparent 70%),
103
- radial-gradient(40% 36% at 70% 92%, light-dark(rgba(255, 224, 194, 0.30), rgba(180, 140, 100, 0.08)), transparent 72%),
104
- var(--bg);
105
- filter: blur(70px);
106
- }
107
- button, input { font: inherit; color: inherit; }
108
- button { cursor: pointer; }
109
- button:disabled { opacity: 0.55; cursor: default; }
110
- h1, h2, h3, p { margin: 0; }
111
- pre, code { white-space: pre-wrap; overflow-wrap: anywhere; font-family: var(--font-code); font-size: 12px; }
112
- .hint, .empty, .mode-line { color: var(--muted); font-size: 13px; }
113
- .error, .restart { color: var(--red); font-size: 13px; }
114
- .running { color: var(--green); font-weight: 600; font-size: 13px; }
115
- .detail, .notice, .class-label { font-size: 14px; }
116
- .proto button:not(.nav-item):not(.theme-btn) {
117
- display: inline-flex;
118
- align-items: center;
119
- justify-content: center;
120
- min-height: 34px;
121
- padding: 8px 16px;
122
- border: 1px solid transparent;
123
- border-radius: var(--radius-pill);
124
- background: var(--accent);
125
- color: var(--accent-ink);
126
- font-size: 13px;
127
- font-weight: 500;
128
- }
129
- .proto button.quiet {
130
- background: var(--bg);
131
- color: var(--text);
132
- border-color: var(--border);
133
- }
134
- .proto button.stop {
135
- background: transparent;
136
- color: var(--red);
137
- border-color: transparent;
138
- }
139
- .proto .modes {
140
- display: flex;
141
- gap: 2px;
142
- padding: 2px;
143
- border-radius: var(--radius-pill);
144
- background: var(--raised);
145
- border: 1px solid var(--border);
146
- }
147
- .proto .modes button {
148
- flex: 1;
149
- background: transparent;
150
- color: var(--muted);
151
- border-color: transparent;
152
- }
153
- .proto .modes button.on {
154
- background: var(--accent);
155
- color: var(--accent-ink);
156
- }
157
- .proto input:not([type="checkbox"]):not([type="hidden"]) {
158
- width: 100%;
159
- min-height: 34px;
160
- border: 1px solid var(--border);
161
- border-radius: var(--radius-sm);
162
- background: var(--bg);
163
- padding: 0 10px;
164
- font-size: 13px;
165
- }
166
- .proto label { display: flex; flex-direction: column; gap: 6px; font-size: 12px; color: var(--muted); }
167
- .proto form.stack, .proto .tools { display: flex; flex-direction: column; gap: 10px; }
168
- .proto .tool { flex-direction: row; align-items: center; gap: 8px; color: var(--text); font-size: 13px; }
169
- .proto .tool em { margin-left: auto; font-style: normal; color: var(--muted); font-size: 12px; }
170
- .proto table { width: 100%; border-collapse: collapse; }
171
- .proto th, .proto td { text-align: left; vertical-align: top; padding: 10px 12px 10px 0; border-bottom: 1px solid var(--border-soft); }
172
- .proto th { font-size: 12px; font-weight: 500; color: var(--muted); }
173
- .proto .choices { display: flex; gap: 8px; align-items: center; }
174
- .proto .pending, .proto pre {
175
- margin: 0;
176
- padding: 12px;
177
- background: var(--raised);
178
- border: 1px solid var(--border-soft);
179
- border-radius: var(--radius-sm);
180
- }
181
- .badge {
182
- display: inline-flex;
183
- align-items: center;
184
- min-height: 22px;
185
- padding: 0 8px;
186
- border-radius: var(--radius-pill);
187
- background: var(--green-soft);
188
- color: var(--green);
189
- font-size: 12px;
190
- font-weight: 600;
191
- }
192
- .badge.off { background: var(--raised); color: var(--muted); }
193
- .brand-row { display: flex; align-items: center; gap: 10px; min-width: 0; }
194
- .mark {
195
- width: 26px; height: 26px; border-radius: 6px; overflow: hidden; flex: 0 0 auto;
196
- border: 1px solid var(--border); background: var(--surface);
197
- }
198
- .mark img { width: 100%; height: 100%; object-fit: contain; }
199
- .brand-name { font-size: 16px; font-weight: 600; letter-spacing: 0; }
200
- .theme-btn {
201
- width: 34px; height: 34px; padding: 0; border-radius: 999px;
202
- background: var(--surface); color: var(--text); border: 1px solid var(--border);
203
- }
204
- .notices { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 18px; max-width: 70ch; }
205
-
206
- .shell { display: grid; grid-template-columns: 232px minmax(0, 1fr); min-height: 100dvh; }
207
- .sidebar {
208
- position: sticky; top: 0; height: 100dvh;
209
- display: flex; flex-direction: column; gap: 4px;
210
- padding: 18px 14px;
211
- border-right: 1px solid var(--border);
212
- background: var(--glass-rail);
213
- backdrop-filter: saturate(1.6) blur(22px);
214
- }
215
- .sidebar nav { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
216
- .nav-item {
217
- display: flex; align-items: center; width: 100%;
218
- padding: 8px 10px; border: 0; border-radius: var(--radius-sm);
219
- background: none; color: var(--muted); font-size: 13px; font-weight: 500;
220
- text-align: left;
221
- }
222
- .nav-item.active { background: var(--accent-soft); color: var(--text); font-weight: 600; }
223
- .sidebar-foot { margin-top: auto; display: flex; flex-direction: column; gap: 8px; padding-top: 12px; }
224
- .main { min-width: 0; }
225
- .main-inner { max-width: 980px; margin: 0 auto; padding: 32px 36px 96px; }
226
- .page-head { display: flex; align-items: center; justify-content: space-between; gap: 16px; }
227
- .page-head h2 { font-size: 20px; font-weight: 600; }
228
- .panel { display: none; }
229
- .panel.on { display: block; }
230
-
231
- .sheet { max-width: 880px; margin: 0 auto; padding: 28px 28px 120px; }
232
- .sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 8px; }
233
- .set-list { margin-top: 12px; border-top: 1px solid var(--border); }
234
- .set-row {
235
- display: grid;
236
- grid-template-columns: 180px minmax(0, 1fr);
237
- gap: 20px;
238
- padding: 18px 0;
239
- border-bottom: 1px solid var(--border);
240
- }
241
- .set-label h2 { font-size: 14px; font-weight: 600; }
242
- .set-label p { margin-top: 4px; color: var(--muted); font-size: 12px; }
243
- .sheet-block { padding: 22px 0 8px; }
244
- .sheet-block h2 { font-size: 14px; font-weight: 600; margin-bottom: 12px; }
245
-
246
- .workspace { min-height: 100dvh; display: flex; flex-direction: column; }
247
- .topbar {
248
- display: flex; align-items: center; justify-content: space-between; gap: 12px;
249
- padding: 14px 20px; border-bottom: 1px solid var(--border);
250
- background: var(--glass-rail); backdrop-filter: saturate(1.6) blur(22px);
251
- position: sticky; top: 0;
252
- }
253
- .split { display: grid; grid-template-columns: 320px minmax(0, 1fr); gap: 0; flex: 1; }
254
- .rail-actions { border-right: 1px solid var(--border); padding: 16px; display: flex; flex-direction: column; gap: 12px; }
255
- .rail-actions section { border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; background: var(--surface); }
256
- .rail-actions h2 { font-size: 12px; font-weight: 500; color: var(--muted); margin-bottom: 10px; }
257
- .detail { padding: 20px 24px 110px; min-width: 0; }
258
- .detail h2 { font-size: 12px; font-weight: 500; color: var(--muted); margin: 18px 0 8px; }
259
- .detail h2:first-child { margin-top: 0; }
260
- .terminal { background: var(--rail); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; min-height: 180px; }
261
-
262
- .proto-bar {
263
- position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
264
- z-index: 80; width: min(440px, calc(100% - 24px));
265
- display: flex; flex-direction: column; gap: 6px; align-items: center;
266
- }
267
- .proto-state {
268
- width: 100%; max-height: 88px; overflow: auto; margin: 0;
269
- padding: 8px 10px; border-radius: 10px;
270
- background: #111; color: #f4f4f4; border: 2px solid #f5c518;
271
- font-size: 10px; line-height: 1.35;
272
- }
273
- .proto-pill {
274
- display: flex; align-items: center; gap: 8px;
275
- padding: 6px 8px; border-radius: 999px;
276
- background: #111; color: #fff; border: 2px solid #f5c518;
277
- box-shadow: 0 8px 24px rgba(0,0,0,0.28);
278
- }
279
- .proto-pill button {
280
- width: 32px; height: 32px; min-height: 32px; padding: 0; border-radius: 999px;
281
- background: #f5c518; color: #111; border: 0; font-weight: 700;
282
- align-self: auto;
283
- }
284
- .proto-pill span { font-size: 13px; font-weight: 600; min-width: 9rem; text-align: center; }
285
- @media (max-width: 760px) {
286
- .shell, .split, .set-row { grid-template-columns: 1fr; }
287
- .sidebar { position: relative; height: auto; border-right: 0; border-bottom: 1px solid var(--border); }
288
- .rail-actions { border-right: 0; border-bottom: 1px solid var(--border); }
289
- .main-inner, .sheet { padding-inline: 16px; }
290
- }
291
- @media (prefers-reduced-motion: reduce) {
292
- * { transition: none !important; }
293
- }
294
- `;
295
- function themeButton() {
296
- return `<button type="button" class="theme-btn" data-appearance-toggle aria-label="切換外觀">◐</button>`;
297
- }
298
- function brand() {
299
- return `<div class="brand-row">
300
- <div class="mark"><img src="/brand-logo.png" alt=""></div>
301
- <div class="brand-name">${PRODUCT}</div>
302
- </div>`;
303
- }
304
- function badge(status, connected) {
305
- return `<span class="badge${connected ? "" : " off"}">${status}</span>`;
306
- }
307
- function switcher(variant, state) {
308
- const index = exports.PROTOTYPE_VARIANTS.indexOf(variant);
309
- const prev = exports.PROTOTYPE_VARIANTS[(index + exports.PROTOTYPE_VARIANTS.length - 1) % exports.PROTOTYPE_VARIANTS.length];
310
- const next = exports.PROTOTYPE_VARIANTS[(index + 1) % exports.PROTOTYPE_VARIANTS.length];
311
- return `<div class="proto-bar" data-proto-bar>
312
- <pre class="proto-state">${state.replaceAll("<", "&lt;")}</pre>
313
- <div class="proto-pill">
314
- <button type="button" data-proto-go="${prev}" aria-label="上一個版本">‹</button>
315
- <span>${variant} · ${VARIANT_NAME[variant]}</span>
316
- <button type="button" data-proto-go="${next}" aria-label="下一個版本">›</button>
317
- </div>
318
- </div>`;
319
- }
320
- function variantA(blocks, view, variant) {
321
- const nav = SECTIONS.map((section, index) => `<button type="button" class="nav-item${index === 0 ? " active" : ""}" data-nav="${section.id}">${section.label}</button>`).join("");
322
- const panels = SECTIONS.map((section, index) => {
323
- const body = stamp(blocks[section.id], variant);
324
- return `<section class="panel${index === 0 ? " on" : ""}" data-panel="${section.id}">${body}</section>`;
325
- }).join("");
326
- return `<div class="shell">
327
- <aside class="sidebar">
328
- ${brand()}
329
- <nav aria-label="區段">${nav}</nav>
330
- <div class="sidebar-foot">
331
- ${badge(blocks.status, view.connected)}
332
- ${stamp(blocks.stop, variant)}
333
- ${themeButton()}
334
- </div>
335
- </aside>
336
- <main class="main">
337
- <div class="main-inner">
338
- <div class="page-head">
339
- <h2 data-page-title>連線</h2>
340
- ${badge(blocks.status, view.connected)}
341
- </div>
342
- <div class="notices">${blocks.notices}</div>
343
- ${panels}
344
- </div>
345
- </main>
346
- </div>`;
347
- }
348
- function variantB(blocks, view, variant) {
349
- const rows = [
350
- ["連線", "邀請碼、暱稱,或複製已兌換的 key。", blocks.connect],
351
- ["資料夾", "安裝課程檔案時寫入的專案路徑。", blocks.folder],
352
- ["模型", "Classroom 與 Native 的切換。", blocks.model],
353
- ["環境", "這台電腦還缺哪些工具。", blocks.environment],
354
- ];
355
- const list = rows
356
- .map(([title, hint, body]) => `<section class="set-row">
357
- <div class="set-label"><h2>${title}</h2><p>${hint}</p></div>
358
- <div class="set-control">${stamp(body, variant)}</div>
359
- </section>`)
360
- .join("");
361
- return `<div class="sheet">
362
- <header class="sheet-head">
363
- ${brand()}
364
- <div class="brand-row">${badge(blocks.status, view.connected)}${themeButton()}</div>
365
- </header>
366
- <div class="notices">${blocks.notices}</div>
367
- <div class="set-list">${list}</div>
368
- <section class="sheet-block">
369
- <h2>指令</h2>
370
- ${stamp(blocks.command, variant)}
371
- </section>
372
- <section class="sheet-block">
373
- <h2>課程</h2>
374
- ${stamp(blocks.catalog, variant)}
375
- </section>
376
- <section class="sheet-block">${stamp(blocks.stop, variant)}</section>
377
- </div>`;
378
- }
379
- function variantC(blocks, view, variant) {
380
- const rail = [
381
- ["連線", blocks.connect],
382
- ["資料夾", blocks.folder],
383
- ["模型", blocks.model],
384
- ["環境", blocks.environment],
385
- ]
386
- .map(([title, body]) => `<section><h2>${title}</h2>${stamp(body, variant)}</section>`)
387
- .join("");
388
- return `<div class="workspace">
389
- <header class="topbar">
390
- ${brand()}
391
- <div class="brand-row">${badge(blocks.status, view.connected)}${themeButton()}${stamp(blocks.stop, variant)}</div>
392
- </header>
393
- <div class="notices" style="padding: 12px 20px 0;">${blocks.notices}</div>
394
- <div class="split">
395
- <div class="rail-actions">${rail}</div>
396
- <div class="detail">
397
- <h2>指令</h2>
398
- <div class="terminal">${stamp(blocks.command, variant)}</div>
399
- <h2>課程</h2>
400
- ${stamp(blocks.catalog, variant)}
401
- </div>
402
- </div>
403
- </div>`;
404
- }
405
- function clientScript(variant) {
406
- return `
407
- var appearanceKey = "classroom-appearance";
408
- function systemDark() {
409
- return window.matchMedia("(prefers-color-scheme: dark)").matches;
410
- }
411
- function paintTheme() {
412
- var stored = null;
413
- try { stored = localStorage.getItem(appearanceKey); } catch (error) {}
414
- var appearance = stored === "light" || stored === "dark" ? stored : (systemDark() ? "dark" : "light");
415
- document.documentElement.dataset.theme = appearance;
416
- var button = document.querySelector("[data-appearance-toggle]");
417
- if (button) button.setAttribute("aria-label", appearance === "dark" ? "切換到淺色" : "切換到深色");
418
- }
419
- paintTheme();
420
- document.addEventListener("click", function (event) {
421
- var target = event.target;
422
- if (!target || !target.closest) return;
423
- if (target.closest("[data-appearance-toggle]")) {
424
- var current = document.documentElement.dataset.theme === "dark" ? "dark" : "light";
425
- var next = current === "dark" ? "light" : "dark";
426
- try { localStorage.setItem(appearanceKey, next); } catch (error) {}
427
- paintTheme();
428
- }
429
- var jump = target.closest("[data-proto-go]");
430
- if (jump) {
431
- var url = new URL(location.href);
432
- url.searchParams.set("variant", jump.getAttribute("data-proto-go"));
433
- location.assign(url.pathname + url.search + url.hash);
434
- }
435
- var nav = target.closest("[data-nav]");
436
- if (nav) {
437
- var id = nav.getAttribute("data-nav");
438
- document.querySelectorAll("[data-nav]").forEach(function (item) {
439
- item.classList.toggle("active", item.getAttribute("data-nav") === id);
440
- });
441
- document.querySelectorAll("[data-panel]").forEach(function (panel) {
442
- panel.classList.toggle("on", panel.getAttribute("data-panel") === id);
443
- });
444
- var title = document.querySelector("[data-page-title]");
445
- if (title) title.textContent = nav.textContent;
446
- history.replaceState(null, "", "#" + id);
447
- }
448
- });
449
- var first = (location.hash || "#connect").slice(1);
450
- var start = document.querySelector('[data-nav="' + first + '"]');
451
- if (start) start.click();
452
- window.addEventListener("keydown", function (event) {
453
- var tag = event.target && event.target.tagName;
454
- if (tag === "INPUT" || tag === "TEXTAREA" || (event.target && event.target.isContentEditable)) return;
455
- if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
456
- var order = ${JSON.stringify(exports.PROTOTYPE_VARIANTS)};
457
- var current = ${JSON.stringify(variant)};
458
- var index = order.indexOf(current);
459
- var step = event.key === "ArrowRight" ? 1 : -1;
460
- var next = order[(index + step + order.length) % order.length];
461
- var url = new URL(location.href);
462
- url.searchParams.set("variant", next);
463
- location.assign(url.pathname + url.search);
464
- });
465
- window.addEventListener("pagehide", function () {
466
- navigator.sendBeacon("/close");
467
- });
468
- `;
469
- }
470
- function variantD(view) {
471
- const html = stamp((0, page_1.renderPage)(view), "D");
472
- const bar = `<style>
473
- .proto-bar { position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%); z-index: 80; width: min(440px, calc(100% - 24px)); display: flex; flex-direction: column; gap: 6px; align-items: center; }
474
- .proto-state { width: 100%; max-height: 88px; overflow: auto; margin: 0; padding: 8px 10px; border-radius: 10px; background: #111; color: #f4f4f4; border: 2px solid #f5c518; font-size: 10px; line-height: 1.35; }
475
- .proto-pill { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border-radius: 999px; background: #111; color: #fff; border: 2px solid #f5c518; box-shadow: 0 8px 24px rgba(0,0,0,0.28); }
476
- .proto-pill button { width: 32px; height: 32px; min-height: 32px; padding: 0; border: 0; border-radius: 999px; background: #f5c518; color: #111; font-weight: 700; }
477
- .proto-pill span { font-size: 13px; font-weight: 600; min-width: 9rem; text-align: center; }
478
- </style>
479
- ${switcher("D", stateText(view))}
480
- <script>
481
- document.addEventListener("click", function (event) {
482
- var target = event.target;
483
- if (!target || !target.closest) return;
484
- var jump = target.closest("[data-proto-go]");
485
- if (!jump) return;
486
- var url = new URL(location.href);
487
- url.searchParams.set("variant", jump.getAttribute("data-proto-go"));
488
- location.assign(url.pathname + url.search);
489
- });
490
- window.addEventListener("keydown", function (event) {
491
- var tag = event.target && event.target.tagName;
492
- if (tag === "INPUT" || tag === "TEXTAREA" || (event.target && event.target.isContentEditable)) return;
493
- if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
494
- var order = ${JSON.stringify(exports.PROTOTYPE_VARIANTS)};
495
- var index = order.indexOf("D");
496
- var step = event.key === "ArrowRight" ? 1 : -1;
497
- var next = order[(index + step + order.length) % order.length];
498
- var url = new URL(location.href);
499
- url.searchParams.set("variant", next);
500
- location.assign(url.pathname + url.search);
501
- });
502
- </script>`;
503
- return html.replace("</body>", `${bar}</body>`);
504
- }
505
- function renderPrototypePage(view, variant) {
506
- if (variant === "D")
507
- return variantD(view);
508
- const blocks = (0, page_1.classroomBlocks)(view);
509
- const body = variant === "A"
510
- ? variantA(blocks, view, variant)
511
- : variant === "B"
512
- ? variantB(blocks, view, variant)
513
- : variantC(blocks, view, variant);
514
- return `<!DOCTYPE html>
515
- <html lang="zh-Hant">
516
- <head>
517
- <meta charset="utf-8">
518
- <meta name="viewport" content="width=device-width, initial-scale=1">
519
- <title>${PRODUCT}</title>
520
- <style>${CSS}</style>
521
- </head>
522
- <body>
523
- <div class="proto">${body}</div>
524
- ${switcher(variant, stateText(view))}
525
- <script>${clientScript(variant)}</script>
526
- </body>
527
- </html>`;
528
- }