@weitc/dfy-awesome-sidebar 0.0.0-stage → 1.0.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/CHANGELOG.md +4540 -0
- package/FEASIBILITY.md +250 -0
- package/INSTALL.md +93 -0
- package/LICENSE +43 -0
- package/README.md +170 -2
- package/assets/backgrounds/sidebar-default.jpg +0 -0
- package/assets/eggs/325/avatar.png +0 -0
- package/assets/eggs/325/baka-65-105-40s.webm +0 -0
- package/assets/eggs/325/stage.jpg +0 -0
- package/assets/eggs/347/avatar.png +0 -0
- package/assets/eggs/347/stage.jpg +0 -0
- package/assets/eggs/347/track-10-50-40s.webm +0 -0
- package/assets/themes/glass/actions-frame.css +90 -0
- package/assets/themes/glass/brand-frame.css +64 -0
- package/assets/themes/glass/footer-frame.css +111 -0
- package/assets/themes/glass/header-frame.css +285 -0
- package/assets/themes/glass/options-frame.css +129 -0
- package/assets/themes/glass/sidebar-outer.css +66 -0
- package/assets/themes/glass/topbar-frame.css +91 -0
- package/assets/themes/metal/actions-frame.css +90 -0
- package/assets/themes/metal/brand-frame.css +64 -0
- package/assets/themes/metal/footer-frame.css +111 -0
- package/assets/themes/metal/header-frame.css +300 -0
- package/assets/themes/metal/options-frame.css +129 -0
- package/assets/themes/metal/sidebar-outer.css +66 -0
- package/assets/themes/metal/topbar-frame.css +91 -0
- package/assets/themes/minimal/actions-frame.css +90 -0
- package/assets/themes/minimal/brand-frame.css +64 -0
- package/assets/themes/minimal/footer-frame.css +115 -0
- package/assets/themes/minimal/header-frame.css +271 -0
- package/assets/themes/minimal/options-frame.css +129 -0
- package/assets/themes/minimal/sidebar-outer.css +66 -0
- package/assets/themes/minimal/topbar-frame.css +91 -0
- package/assets/themes/neon/actions-frame.css +90 -0
- package/assets/themes/neon/brand-frame.css +64 -0
- package/assets/themes/neon/footer-frame.css +111 -0
- package/assets/themes/neon/header-frame.css +286 -0
- package/assets/themes/neon/options-frame.css +129 -0
- package/assets/themes/neon/sidebar-outer.css +66 -0
- package/assets/themes/neon/topbar-frame.css +91 -0
- package/assets/themes/ocean/actions-frame.css +90 -0
- package/assets/themes/ocean/brand-frame.css +64 -0
- package/assets/themes/ocean/footer-frame.css +111 -0
- package/assets/themes/ocean/header-frame.css +287 -0
- package/assets/themes/ocean/options-frame.css +129 -0
- package/assets/themes/ocean/sidebar-outer.css +66 -0
- package/assets/themes/ocean/topbar-frame.css +91 -0
- package/assets/themes/oldday/actions-frame.css +90 -0
- package/assets/themes/oldday/brand-frame.css +43 -0
- package/assets/themes/oldday/footer-frame.css +116 -0
- package/assets/themes/oldday/header-frame.css +142 -0
- package/assets/themes/oldday/options-frame.css +129 -0
- package/assets/themes/oldday/sidebar-outer.css +69 -0
- package/assets/themes/oldday/topbar-frame.css +91 -0
- package/assets/themes/pop/actions-frame.css +3 -0
- package/assets/themes/pop/brand-frame.css +3 -0
- package/assets/themes/pop/footer-frame.css +3 -0
- package/assets/themes/pop/header-frame.css +289 -0
- package/assets/themes/pop/options-frame.css +3 -0
- package/assets/themes/pop/pop-dust.css +37 -0
- package/assets/themes/pop/sidebar-outer.css +3 -0
- package/assets/themes/pop/topbar-frame.css +3 -0
- package/assets/themes/vaporwave/actions-frame.css +3 -0
- package/assets/themes/vaporwave/brand-frame.css +3 -0
- package/assets/themes/vaporwave/footer-frame.css +3 -0
- package/assets/themes/vaporwave/header-frame.css +436 -0
- package/assets/themes/vaporwave/options-frame.css +3 -0
- package/assets/themes/vaporwave/sidebar-outer.css +3 -0
- package/assets/themes/vaporwave/topbar-frame.css +3 -0
- package/assets/themes/vaporwave/vapor-dust.css +40 -0
- package/client.js +8116 -0
- package/cordis.patch.yml +6 -0
- package/docs/ACCEPTANCE-/345/244/264/345/203/217/351/242/204/350/247/210-20261201.md +42 -0
- package/docs/DETAIL.md +1 -0
- package/docs/DETAIL.zh.md +1 -0
- package/docs/pin-compare.png +0 -0
- package/docs/pin-modes.png +0 -0
- package/docs/preview.svg +84 -0
- package/docs/shot-fix7.png +0 -0
- package/docs/shot-frame-ocean.png +0 -0
- package/docs/shot-metal.png +0 -0
- package/docs/shot-stars.png +0 -0
- package/docs/shot-zones.png +0 -0
- package/icon.svg +5 -0
- package/index.js +2050 -0
- package/locale/en.json +7 -0
- package/locale/zh.json +7 -0
- package/package.json +58 -3
- package/pin.ps1 +172 -0
- package/rollback.ps1 +196 -0
- package/tools/__pycache__/pack-release.cpython-312.pyc +0 -0
- package/tools/_slice.txt +9 -0
- package/tools/boot.cjs +16 -0
- package/tools/build-frame-css.cjs +33 -0
- package/tools/check-docs.ps1 +41 -0
- package/tools/check-names.ps1 +35 -0
- package/tools/extract.cjs +28 -0
- package/tools/find-in-asar.cjs +43 -0
- package/tools/list-dir.cjs +21 -0
- package/tools/list-pkgs.cjs +10 -0
- package/tools/probe-delay.cjs +109 -0
- package/tools/probe-star-icon.cjs +164 -0
- package/tools/proof-glow-persist.cjs +102 -0
- package/tools/proof-migration.cjs +88 -0
- package/tools/proof-opacity.cjs +153 -0
- package/tools/proof-race.cjs +103 -0
- package/tools/run-asar.ps1 +53 -0
- package/tools/run.cmd +8 -0
- package/tools/scan.cjs +24 -0
- package/tools/smoke.cjs +179 -0
- package/tools/source-health.cjs +165 -0
- package/tools/splice.cjs +20 -0
- package/tools/test-account.cjs +74 -0
- package/tools/test-client.cjs +265 -0
- package/tools/test-dom.cjs +258 -0
- package/tools/test-host.cjs +500 -0
- package/tools/test-menu.cjs +591 -0
- package/tools/test-recharge.cjs +111 -0
- package/tools/test-v20.cjs +1793 -0
- package/workspace-pin.cmd +8 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// list-dir.js — 递归列出目录(层数可限),用于看 asar 里包结构
|
|
2
|
+
module.exports = function (args) {
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const root = args[0];
|
|
6
|
+
const depth = Number(args[1] || 2);
|
|
7
|
+
const max = Number(args[2] || 300);
|
|
8
|
+
let count = 0;
|
|
9
|
+
function walk(dir, d) {
|
|
10
|
+
let items;
|
|
11
|
+
try { items = fs.readdirSync(dir, { withFileTypes: true }); } catch (e) { console.log('ERR ' + dir + ' ' + e.message); return; }
|
|
12
|
+
for (const it of items) {
|
|
13
|
+
if (count++ >= max) { console.log('... truncated'); return; }
|
|
14
|
+
const p = path.join(dir, it.name);
|
|
15
|
+
console.log(' '.repeat(d) + (it.isDirectory() ? it.name + '/' : it.name));
|
|
16
|
+
if (it.isDirectory() && d + 1 < depth) walk(p, d + 1);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
walk(root, 0);
|
|
20
|
+
return 0;
|
|
21
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
// list-pkgs.js — 列出 asar 内 @deepseek-ai 下的包目录
|
|
2
|
+
module.exports = function (args) {
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const path = require('node:path');
|
|
5
|
+
const root = args[0] || 'D:\\Program Files\\DeepSeekHarness\\resources\\app.asar\\dsh\\node_modules\\@deepseek-ai';
|
|
6
|
+
let names;
|
|
7
|
+
try { names = fs.readdirSync(root); } catch (e) { console.error('ERR ' + e.message); return 1; }
|
|
8
|
+
for (const n of names) console.log(n);
|
|
9
|
+
return 0;
|
|
10
|
+
};
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// probe-delay.cjs — 模拟"状态异步到达":先空状态渲染,200ms 后 /state 才返回,看图标是否补亮。
|
|
2
|
+
module.exports = async function (args) {
|
|
3
|
+
const fs = require('node:fs');
|
|
4
|
+
const vm = require('node:vm');
|
|
5
|
+
const src = fs.readFileSync(args[0], 'utf8');
|
|
6
|
+
const DOC = { isDocument: true };
|
|
7
|
+
const observers = [];
|
|
8
|
+
const splitSelector = s => String(s).split(',').map(x => x.trim()).filter(Boolean);
|
|
9
|
+
function matchesOne(node, selector) {
|
|
10
|
+
let m = /^\[([\w-]+)\]$/.exec(selector); if (m) return node.hasAttribute(m[1]);
|
|
11
|
+
m = /^\[([\w-]+)\^="([^"]*)"\]$/.exec(selector); if (m) { const v = node.getAttribute(m[1]); return typeof v === 'string' && v.indexOf(m[2]) === 0; }
|
|
12
|
+
m = /^\[([\w-]+)\*="([^"]*)"\]$/.exec(selector); if (m) { const v = node.getAttribute(m[1]); return typeof v === 'string' && v.indexOf(m[2]) !== -1; }
|
|
13
|
+
m = /^\[([\w-]+)="([^"]*)"\]$/.exec(selector); if (m) return node.getAttribute(m[1]) === m[2];
|
|
14
|
+
m = /^#([\w-]+)$/.exec(selector); if (m) return node.getAttribute('id') === m[1];
|
|
15
|
+
m = /^([a-zA-Z][\w-]*)$/.exec(selector); if (m) return node.tagName === m[1].toUpperCase();
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
const matches = (node, sel) => splitSelector(sel).some(p => matchesOne(node, p));
|
|
19
|
+
class Node {
|
|
20
|
+
constructor(tag) { this.tagName = String(tag).toUpperCase(); this.children = []; this.attrs = {}; this.parentNode = null; this.style = {}; this.listeners = {}; this.text = ''; this.nodeType = 1; }
|
|
21
|
+
get isConnected() { let n = this; while (n) { if (n === DOC) return true; n = n.parentNode; } return false; }
|
|
22
|
+
appendChild(c) { if (c.parentNode) c.remove(); c.parentNode = this; this.children.push(c); return c; }
|
|
23
|
+
removeChild(c) { const i = this.children.indexOf(c); if (i !== -1) this.children.splice(i, 1); c.parentNode = null; }
|
|
24
|
+
remove() { if (this.parentNode) this.parentNode.removeChild(this); }
|
|
25
|
+
replaceChildren(...ns) { for (const c of this.children) c.parentNode = null; this.children = []; for (const n of ns) this.appendChild(n); }
|
|
26
|
+
setAttribute(k, v) { this.attrs[k] = String(v); }
|
|
27
|
+
getAttribute(k) { return k in this.attrs ? this.attrs[k] : null; }
|
|
28
|
+
hasAttribute(k) { return k in this.attrs; }
|
|
29
|
+
addEventListener(t, h) { (this.listeners[t] = this.listeners[t] || []).push(h); }
|
|
30
|
+
get id() { return this.attrs.id || ''; } set id(v) { this.attrs.id = String(v); }
|
|
31
|
+
get textContent() { return this.text || this.children.map(c => c.textContent).join(''); } set textContent(v) { this.text = String(v); this.children = []; }
|
|
32
|
+
walk(o) { for (const c of this.children) { o.push(c); c.walk(o); } return o; }
|
|
33
|
+
querySelectorAll(s) { return this.walk([]).filter(n => matches(n, s)); }
|
|
34
|
+
querySelector(s) { return this.querySelectorAll(s)[0] || null; }
|
|
35
|
+
}
|
|
36
|
+
class MO { constructor(cb) { this.cb = cb; observers.push(this); } observe() {} disconnect() {} }
|
|
37
|
+
const body = new Node('body'); body.parentNode = DOC;
|
|
38
|
+
const document = {
|
|
39
|
+
body,
|
|
40
|
+
createElement: t => new Node(t),
|
|
41
|
+
createElementNS: (_n, t) => new Node(t),
|
|
42
|
+
querySelector: s => body.querySelector(s),
|
|
43
|
+
querySelectorAll: s => body.querySelectorAll(s),
|
|
44
|
+
getElementById: id => body.querySelectorAll('[id]').find(n => n.getAttribute('id') === id) || null,
|
|
45
|
+
addEventListener() {}, removeEventListener() {},
|
|
46
|
+
};
|
|
47
|
+
const list = new Node('div'); list.setAttribute('data-sidebar-list-area', ''); body.appendChild(list);
|
|
48
|
+
function makeRow(kind, id, title) {
|
|
49
|
+
const r = new Node('div');
|
|
50
|
+
r.setAttribute('data-row-key', kind + ':' + id);
|
|
51
|
+
r.setAttribute('aria-label', title);
|
|
52
|
+
r.text = title;
|
|
53
|
+
const a = new Node('span'); a.setAttribute('class', 'Rows_rowActions__x');
|
|
54
|
+
const b = new Node('button'); b.setAttribute('aria-haspopup', 'menu');
|
|
55
|
+
a.appendChild(b); r.appendChild(a); list.appendChild(r);
|
|
56
|
+
return r;
|
|
57
|
+
}
|
|
58
|
+
const wsA = makeRow('workspace', 'w-a', '工作区 A');
|
|
59
|
+
const wsB = makeRow('workspace', 'w-b', '工作区 B');
|
|
60
|
+
const hasState = { pinnedWorkspaceId: 'w-a', starredWorkspaces: ['w-b'], starredSessions: [], workspaceIds: ['w-a', 'w-b'] };
|
|
61
|
+
const emptyState = { pinnedWorkspaceId: null, starredWorkspaces: [], starredSessions: [], workspaceIds: ['w-a', 'w-b'] };
|
|
62
|
+
const start = Date.now();
|
|
63
|
+
let failuresLeft = 2;
|
|
64
|
+
const entries = [];
|
|
65
|
+
const workspacesService = {
|
|
66
|
+
list: {
|
|
67
|
+
getSnapshot: () => ({ items: [{ workspaceId: 'w-a', sessionIds: [] }], pinnedSessionIds: [] }),
|
|
68
|
+
subscribe: () => () => {},
|
|
69
|
+
},
|
|
70
|
+
pinSession: async () => {},
|
|
71
|
+
unpinSession: async () => {},
|
|
72
|
+
};
|
|
73
|
+
const sandbox = {
|
|
74
|
+
console, URL, setTimeout, clearTimeout,
|
|
75
|
+
queueMicrotask: fn => Promise.resolve().then(fn),
|
|
76
|
+
requestAnimationFrame: fn => setTimeout(fn, 0),
|
|
77
|
+
MutationObserver: MO, document,
|
|
78
|
+
window: { __ModuleLoader__: { load: e => entries.push(e) }, location: { href: 'http://127.0.0.1:49696/?t=1' } },
|
|
79
|
+
fetch: async () => {
|
|
80
|
+
if (failuresLeft > 0) { failuresLeft -= 1; throw new Error('boom'); }
|
|
81
|
+
return { ok: true, status: 200, json: async () => hasState };
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
vm.createContext(sandbox);
|
|
85
|
+
vm.runInContext(src, sandbox, { filename: args[0] });
|
|
86
|
+
const React = { createElement: () => null };
|
|
87
|
+
const plugin = entries[0].factory(n => { if (n === 'react') return React; throw new Error(n); });
|
|
88
|
+
const ctx = {
|
|
89
|
+
effect(fn) { fn(); return () => {}; },
|
|
90
|
+
on() { return () => {}; },
|
|
91
|
+
get(name) { return name === 'workspaces' ? workspacesService : undefined; },
|
|
92
|
+
locale: { register: () => () => {}, bind: () => (k) => k },
|
|
93
|
+
slots: { inject(_n, f) { const p = f(); if (p && p.next) { for (const _ of p) { /* generator */ } } return () => {}; }, register() { return () => {}; } },
|
|
94
|
+
contextMenus: { register() { return () => {}; }, notify() {} },
|
|
95
|
+
};
|
|
96
|
+
plugin.apply(ctx);
|
|
97
|
+
const hostOf = (row) => Array.from(row.children).find(c => c.hasAttribute && c.hasAttribute('data-wp-host'));
|
|
98
|
+
const btn = (row, kind) => { const h2 = hostOf(row); return h2 && h2.children.find(c => c.getAttribute('data-wp') === kind); };
|
|
99
|
+
await new Promise(r => setTimeout(r, 60));
|
|
100
|
+
console.log('60ms pinA =', btn(wsA, 'pin') && btn(wsA, 'pin').getAttribute('data-on'));
|
|
101
|
+
console.log('60ms starB =', btn(wsB, 'star') && btn(wsB, 'star').getAttribute('data-on'));
|
|
102
|
+
await new Promise(r => setTimeout(r, 1600));
|
|
103
|
+
console.log('460ms pinA =', btn(wsA, 'pin') && btn(wsA, 'pin').getAttribute('data-on'));
|
|
104
|
+
console.log('460ms starB =', btn(wsB, 'star') && btn(wsB, 'star').getAttribute('data-on'));
|
|
105
|
+
const ok = btn(wsA, 'pin') && btn(wsA, 'pin').getAttribute('data-on') === '1'
|
|
106
|
+
&& btn(wsB, 'star') && btn(wsB, 'star').getAttribute('data-on') === '1';
|
|
107
|
+
console.log(ok ? 'PASS 异步状态能补亮' : 'FAIL 状态没有补亮到图标');
|
|
108
|
+
return ok ? 0 : 1;
|
|
109
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
// probe-star-icon.cjs — 把「会话选项栏 / 工作区选项栏」里那个星标图标的真实骨架打印出来。
|
|
2
|
+
// 目的:先确认它是谁渲染的(我们自己的 contextMenu.icon 槽 vs DSH 原生),再决定改法。
|
|
3
|
+
// 用法:run.cmd tools/probe-star-icon.cjs client.js
|
|
4
|
+
module.exports = async function (args) {
|
|
5
|
+
const fs = require('node:fs');
|
|
6
|
+
const vm = require('node:vm');
|
|
7
|
+
const src = fs.readFileSync(args[0], 'utf8');
|
|
8
|
+
|
|
9
|
+
const DOC = { isDocument: true };
|
|
10
|
+
const intervals = new Map();
|
|
11
|
+
let intervalSeq = 0;
|
|
12
|
+
const intervalsApi = {
|
|
13
|
+
setInterval: fn => { const id = ++intervalSeq; intervals.set(id, fn); return id; },
|
|
14
|
+
clearInterval: id => intervals.delete(id),
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
class Node {
|
|
18
|
+
constructor(tag) {
|
|
19
|
+
this.tagName = String(tag).toUpperCase();
|
|
20
|
+
this.children = []; this.attrs = {}; this.parentNode = null;
|
|
21
|
+
this.style = { v: {}, setProperty(k, x) { this.v[k] = String(x); }, removeProperty(k) { delete this.v[k]; }, getPropertyValue(k) { return this.v[k] || ''; } };
|
|
22
|
+
this.classList = { _l: [], add() {}, remove() {}, toggle() {}, contains() { return false; } };
|
|
23
|
+
this.listeners = {}; this.text = ''; this.nodeType = 1;
|
|
24
|
+
this.rect = { top: 0, bottom: 32, height: 32, width: 250, left: 0, right: 250 };
|
|
25
|
+
}
|
|
26
|
+
get isConnected() { return true; }
|
|
27
|
+
appendChild(c) { c.parentNode = this; this.children.push(c); return c; }
|
|
28
|
+
insertBefore(c) { c.parentNode = this; this.children.unshift(c); return c; }
|
|
29
|
+
removeChild(c) { const i = this.children.indexOf(c); if (i !== -1) this.children.splice(i, 1); c.parentNode = null; }
|
|
30
|
+
remove() { if (this.parentNode) this.parentNode.removeChild(this); }
|
|
31
|
+
contains() { return false; }
|
|
32
|
+
setAttribute(k, v) { this.attrs[k] = String(v); }
|
|
33
|
+
getAttribute(k) { return k in this.attrs ? this.attrs[k] : null; }
|
|
34
|
+
hasAttribute(k) { return k in this.attrs; }
|
|
35
|
+
removeAttribute(k) { delete this.attrs[k]; }
|
|
36
|
+
addEventListener() {} removeEventListener() {}
|
|
37
|
+
getBoundingClientRect() { return this.rect; }
|
|
38
|
+
matches() { return false; }
|
|
39
|
+
get id() { return this.attrs.id || ''; } set id(v) { this.attrs.id = String(v); }
|
|
40
|
+
get type() { return this.attrs.type || ''; } set type(v) { this.attrs.type = String(v); }
|
|
41
|
+
get value() { return this.attrs.value || ''; } set value(v) { this.attrs.value = String(v); }
|
|
42
|
+
get textContent() { return this.text; } set textContent(v) { this.text = String(v); this.children = []; }
|
|
43
|
+
querySelectorAll() { return []; } querySelector() { return null; }
|
|
44
|
+
}
|
|
45
|
+
const html = new Node('html');
|
|
46
|
+
const body = new Node('body');
|
|
47
|
+
html.appendChild(body);
|
|
48
|
+
const document = {
|
|
49
|
+
body, head: html, documentElement: html, nodeType: 9,
|
|
50
|
+
createElement: t => new Node(t), createElementNS: (_n, t) => new Node(t),
|
|
51
|
+
createTextNode: v => { const n = new Node('#text'); n.nodeType = 3; n.text = String(v); return n; },
|
|
52
|
+
querySelector: () => null, querySelectorAll: () => [], getElementById: () => null,
|
|
53
|
+
addEventListener() {}, removeEventListener() {},
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const slotRegistrations = [];
|
|
57
|
+
let entry = null;
|
|
58
|
+
const sandbox = {
|
|
59
|
+
console, URL, setTimeout, clearTimeout, queueMicrotask: fn => Promise.resolve().then(fn),
|
|
60
|
+
...intervalsApi, document, devicePixelRatio: 1,
|
|
61
|
+
MutationObserver: class { observe() {} disconnect() {} },
|
|
62
|
+
Image: class {}, FileReader: class {},
|
|
63
|
+
window: {
|
|
64
|
+
__ModuleLoader__: { load: e => { entry = e; } },
|
|
65
|
+
location: { href: 'http://127.0.0.1:58525/?t=1' },
|
|
66
|
+
innerWidth: 1280, innerHeight: 800, addEventListener() {}, removeEventListener() {},
|
|
67
|
+
},
|
|
68
|
+
fetch: async (url) => {
|
|
69
|
+
const remote = {
|
|
70
|
+
pinnedWorkspaceId: null, starredWorkspaces: ['ws-a'], starredSessions: ['s-1'],
|
|
71
|
+
workspaceIds: ['ws-a'], pinnedSessionByWorkspace: {}, sessionOwner: { 's-1': 'ws-a' },
|
|
72
|
+
settings: {
|
|
73
|
+
nativeSessionPin: 'plugin', workspaceStarColor: '#ff3224', sessionStarColor: '#24d3ff',
|
|
74
|
+
sessionTitleChars: 7, theme: 'minimal',
|
|
75
|
+
settingsTab: 1, workspaceOpacity: 50, sidebarBackground: '', showTokenBalance: false,
|
|
76
|
+
avatar: { enabled: false, workspace: {}, session: {} },
|
|
77
|
+
},
|
|
78
|
+
};
|
|
79
|
+
return { ok: true, status: 200, json: async () => remote };
|
|
80
|
+
},
|
|
81
|
+
};
|
|
82
|
+
vm.createContext(sandbox);
|
|
83
|
+
vm.runInContext(src, sandbox, { filename: args[0] });
|
|
84
|
+
|
|
85
|
+
// 假 React:只建 vnode 树,便于把 SVG 骨架序列化出来
|
|
86
|
+
const React = { createElement: (type, props, ...children) => ({ type, props: props || {}, children }) };
|
|
87
|
+
const plugin = entry.factory(n => { if (n === 'react') return React; throw new Error(n); });
|
|
88
|
+
|
|
89
|
+
const contextMenus = [];
|
|
90
|
+
const ctx = {
|
|
91
|
+
effect(fn) { fn(); return () => {}; }, on() { return () => {}; },
|
|
92
|
+
get() { return undefined; },
|
|
93
|
+
locale: { register: () => () => {}, bind: () => k => String(k) },
|
|
94
|
+
slots: {
|
|
95
|
+
inject(_name, factoryFn) {
|
|
96
|
+
const it = factoryFn();
|
|
97
|
+
if (it && it.next) { for (const _ of it) { /* drain */ } }
|
|
98
|
+
return () => {};
|
|
99
|
+
},
|
|
100
|
+
register(options, component) { slotRegistrations.push({ options, component }); return () => {}; },
|
|
101
|
+
},
|
|
102
|
+
contextMenus: { register(def) { contextMenus.push(def); return () => {}; }, notify() {} },
|
|
103
|
+
};
|
|
104
|
+
plugin.apply(ctx);
|
|
105
|
+
await new Promise(r => setTimeout(r, 80));
|
|
106
|
+
|
|
107
|
+
const esc = (s) => String(s).replace(/&/g, '&').replace(/</g, '<').replace(/"/g, '"');
|
|
108
|
+
function serialize(vnode) {
|
|
109
|
+
if (vnode === null || vnode === undefined || vnode === false) return '';
|
|
110
|
+
if (typeof vnode === 'string' || typeof vnode === 'number') return esc(vnode);
|
|
111
|
+
if (Array.isArray(vnode)) return vnode.map(serialize).join('');
|
|
112
|
+
const type = vnode.type;
|
|
113
|
+
if (typeof type === 'function') return serialize(type(vnode.props));
|
|
114
|
+
const props = vnode.props || {};
|
|
115
|
+
const attrs = [];
|
|
116
|
+
for (const [k, v] of Object.entries(props)) {
|
|
117
|
+
if (v === undefined || v === null || k === 'children') continue;
|
|
118
|
+
if (k === 'style' && v && typeof v === 'object') {
|
|
119
|
+
attrs.push('style="' + esc(Object.entries(v).map(([sk, sv]) => sk + ':' + sv).join(';')) + '"');
|
|
120
|
+
continue;
|
|
121
|
+
}
|
|
122
|
+
attrs.push(k + '="' + esc(v) + '"');
|
|
123
|
+
}
|
|
124
|
+
const kids = (vnode.children && vnode.children.length ? vnode.children : [props.children]).map(serialize).join('');
|
|
125
|
+
const name = String(type);
|
|
126
|
+
return '<' + name + (attrs.length ? ' ' + attrs.join(' ') : '') + '>' + kids + '</' + name + '>';
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
console.log('=== 挂载结构 ===');
|
|
130
|
+
console.log('contextMenu.icon 槽注册数 = ' + slotRegistrations.length);
|
|
131
|
+
console.log('菜单注册数 = ' + contextMenus.length + ' → ' + contextMenus.map(d => d.id + '(' + d.target + ')').join(', '));
|
|
132
|
+
console.log('插件是否注册了 sidebar.workspaces.session.row.action 槽 = ' +
|
|
133
|
+
slotRegistrations.some(r => r.options.name === 'sidebar.workspaces.session.row.action'));
|
|
134
|
+
console.log('');
|
|
135
|
+
|
|
136
|
+
console.log('=== contextMenu.icon 槽里的图标(这就是「选项栏里的星标」来源) ===');
|
|
137
|
+
for (const reg of slotRegistrations) {
|
|
138
|
+
const key = reg.options.key;
|
|
139
|
+
if (!/star|sparkle/.test(key)) continue;
|
|
140
|
+
const html2 = serialize(React.createElement(reg.component, {}));
|
|
141
|
+
console.log(' key = ' + key);
|
|
142
|
+
console.log(' ' + html2);
|
|
143
|
+
console.log('');
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
console.log('=== 当前设置里的星标色(假 Host 给的) ===');
|
|
147
|
+
console.log(' sessionStarColor = #24d3ff');
|
|
148
|
+
console.log(' workspaceStarColor = #ff3224');
|
|
149
|
+
console.log(' → 会话星标图标应当用 #24d3ff;工作区星标图标应当用 #ff3224');
|
|
150
|
+
console.log('');
|
|
151
|
+
console.log('=== 会话菜单实际用的图标 key ===');
|
|
152
|
+
const sessionMenu = contextMenus.find(d => d.id === 'workspace-pin.session');
|
|
153
|
+
if (sessionMenu) {
|
|
154
|
+
const remote = { pinnedWorkspaceId: null, starredWorkspaces: ['ws-a'], starredSessions: ['s-1'], pinnedSessionByWorkspace: {}, sessionOwner: { 's-1': 'ws-a' }, settings: {} };
|
|
155
|
+
const items = await sessionMenu.resolve(
|
|
156
|
+
{ sessionId: 's-1', displayTitle: '测试会话' },
|
|
157
|
+
new AbortController().signal,
|
|
158
|
+
);
|
|
159
|
+
for (const item of items) {
|
|
160
|
+
console.log(' ' + item.id + ' → icon.key = ' + (item.icon && item.icon.key));
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
return 0;
|
|
164
|
+
};
|
|
@@ -0,0 +1,102 @@
|
|
|
1
|
+
// proof-glow-persist.cjs — 用真实 index.js + 真实设置文件,验「光效开关」的持久值行为。
|
|
2
|
+
//
|
|
3
|
+
// 回答 CommanderT 的三个问题:
|
|
4
|
+
// ① 取消勾选 → useGlowAlert 是否真的写进文件
|
|
5
|
+
// ② 头像开启时强制生效,但**持久值不被覆盖**
|
|
6
|
+
// ③ 头像关掉后回到用户原选
|
|
7
|
+
//
|
|
8
|
+
// 用法:tools\run.cmd tools\proof-glow-persist.cjs index.js
|
|
9
|
+
module.exports = async function (args) {
|
|
10
|
+
const fs = require('node:fs');
|
|
11
|
+
const os = require('node:os');
|
|
12
|
+
const path = require('node:path');
|
|
13
|
+
const { pathToFileURL } = require('node:url');
|
|
14
|
+
|
|
15
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'wp-glow-'));
|
|
16
|
+
process.env.DSH_HOME = home;
|
|
17
|
+
const stateFile = path.join(home, 'workspace-pin.json');
|
|
18
|
+
const routes = [];
|
|
19
|
+
const ctx = {
|
|
20
|
+
effect(fn) { fn(); return () => {}; },
|
|
21
|
+
on() { return () => {}; },
|
|
22
|
+
get() { return undefined; },
|
|
23
|
+
webServer: { register(route) { routes.push(route); return () => {}; } },
|
|
24
|
+
workspaceRegistry: { list: () => [{ id: 'ws-a', path: 'D:\\a', title: 'A' }], async insertBefore() { return ['ws-a']; } },
|
|
25
|
+
};
|
|
26
|
+
const plugin = await import(pathToFileURL(path.resolve(args[0] || 'index.js')).href);
|
|
27
|
+
plugin.apply(ctx);
|
|
28
|
+
const route = (n) => routes.find((r) => r.path === '/workspace-pin/' + n);
|
|
29
|
+
|
|
30
|
+
function makeRes() {
|
|
31
|
+
const res = { statusCode: 0, body: '' };
|
|
32
|
+
res.writeHead = (c) => { res.statusCode = c; return res; };
|
|
33
|
+
res.end = (c) => { if (c !== undefined) res.body += c; return res; };
|
|
34
|
+
return res;
|
|
35
|
+
}
|
|
36
|
+
function makeReq(method, body) {
|
|
37
|
+
const chunks = body === undefined ? [] : [Buffer.from(JSON.stringify(body), 'utf8')];
|
|
38
|
+
return {
|
|
39
|
+
method,
|
|
40
|
+
headers: { host: '127.0.0.1:1' },
|
|
41
|
+
url: '/',
|
|
42
|
+
async *[Symbol.asyncIterator]() { for (const ch of chunks) yield ch; },
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
async function call(name, method, body) {
|
|
46
|
+
const res = makeRes();
|
|
47
|
+
await route(name).handler(makeReq(method, body), res);
|
|
48
|
+
let json = null;
|
|
49
|
+
try { json = JSON.parse(res.body); } catch { /* ignore */ }
|
|
50
|
+
return { code: res.statusCode, json };
|
|
51
|
+
}
|
|
52
|
+
const readFileSettings = () => {
|
|
53
|
+
if (!fs.existsSync(stateFile)) return null;
|
|
54
|
+
return JSON.parse(fs.readFileSync(stateFile, 'utf8')).settings;
|
|
55
|
+
};
|
|
56
|
+
const show = (tag) => {
|
|
57
|
+
const s = readFileSettings();
|
|
58
|
+
if (!s) { console.log( ); console.log(' 设置文件尚不存在(用户从未写过任何设置)'); return { present: false, value: undefined }; }
|
|
59
|
+
const present = Object.prototype.hasOwnProperty.call(s, 'useGlowAlert');
|
|
60
|
+
console.log(` ${tag}`);
|
|
61
|
+
console.log(` 文件里 useGlowAlert ${present ? '= ' + JSON.stringify(s.useGlowAlert) : '(键不存在)'}`);
|
|
62
|
+
console.log(` avatar.enabled = ${s.avatar && s.avatar.enabled}`);
|
|
63
|
+
return { present, value: s.useGlowAlert };
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
console.log('【0】初始(用户从未动过)');
|
|
67
|
+
show('默认状态');
|
|
68
|
+
|
|
69
|
+
console.log('');
|
|
70
|
+
console.log('【①】用户取消勾选');
|
|
71
|
+
const off = await call('setting', 'POST', { key: 'useGlowAlert', value: false });
|
|
72
|
+
console.log(` POST /setting useGlowAlert=false -> HTTP ${off.code}`);
|
|
73
|
+
const afterOff = show('取消勾选后');
|
|
74
|
+
|
|
75
|
+
console.log('');
|
|
76
|
+
console.log('【②】打开头像功能(强制生效,但持久值不许被改)');
|
|
77
|
+
const avOn = await call('setting', 'POST', { key: 'avatar', value: { enabled: true, workspace: {}, session: {} } });
|
|
78
|
+
console.log(` POST /setting avatar{enabled:true} -> HTTP ${avOn.code}`);
|
|
79
|
+
const afterAvatarOn = show('头像开启后(重点:useGlowAlert 应仍是 false)');
|
|
80
|
+
|
|
81
|
+
console.log('');
|
|
82
|
+
console.log('【③】关闭头像功能');
|
|
83
|
+
const avOff = await call('setting', 'POST', { key: 'avatar', value: { enabled: false, workspace: {}, session: {} } });
|
|
84
|
+
console.log(` POST /setting avatar{enabled:false} -> HTTP ${avOff.code}`);
|
|
85
|
+
const afterAvatarOff = show('关闭头像后(应回到用户原选 false)');
|
|
86
|
+
|
|
87
|
+
console.log('');
|
|
88
|
+
console.log('【④】用户重新勾选');
|
|
89
|
+
const on = await call('setting', 'POST', { key: 'useGlowAlert', value: true });
|
|
90
|
+
console.log(` POST /setting useGlowAlert=true -> HTTP ${on.code}`);
|
|
91
|
+
show('重新勾选后');
|
|
92
|
+
|
|
93
|
+
const ok = afterOff.present === true && afterOff.value === false
|
|
94
|
+
&& afterAvatarOn.present === true && afterAvatarOn.value === false
|
|
95
|
+
&& afterAvatarOff.present === true && afterAvatarOff.value === false
|
|
96
|
+
&& readFileSettings() && readFileSettings().useGlowAlert === true;
|
|
97
|
+
console.log('');
|
|
98
|
+
console.log(ok ? 'GLOW PERSIST PROOF PASS' : 'GLOW PERSIST PROOF FAIL');
|
|
99
|
+
|
|
100
|
+
fs.rmSync(home, { recursive: true, force: true });
|
|
101
|
+
return ok ? 0 : 1;
|
|
102
|
+
};
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// proof-migration.cjs — 用真实 index.js + 临时 DSH_HOME,演示 workspaceOpacity → areaOpacity 迁移全过程。
|
|
2
|
+
// 用法:run.cmd tools/proof-migration.cjs index.js
|
|
3
|
+
module.exports = async function (args) {
|
|
4
|
+
const fs = require('node:fs');
|
|
5
|
+
const os = require('node:os');
|
|
6
|
+
const path = require('node:path');
|
|
7
|
+
const { pathToFileURL } = require('node:url');
|
|
8
|
+
|
|
9
|
+
const pluginPath = path.resolve(args[0]);
|
|
10
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'wp-migrate-'));
|
|
11
|
+
process.env.DSH_HOME = home;
|
|
12
|
+
const stateFile = path.join(home, 'workspace-pin.json');
|
|
13
|
+
|
|
14
|
+
const routes = [];
|
|
15
|
+
const ctx = {
|
|
16
|
+
effect(fn) { fn(); return () => {}; },
|
|
17
|
+
on() { return () => {}; },
|
|
18
|
+
get() { return undefined; },
|
|
19
|
+
webServer: { register(route) { routes.push(route); return () => {}; } },
|
|
20
|
+
workspaceRegistry: { list: () => [{ id: 'ws-a', path: 'D:\\a', title: 'A' }], async insertBefore() { return ['ws-a']; } },
|
|
21
|
+
};
|
|
22
|
+
const plugin = await import(pathToFileURL(pluginPath).href);
|
|
23
|
+
plugin.apply(ctx);
|
|
24
|
+
const route = (n) => routes.find(r => r.path === '/workspace-pin/' + n);
|
|
25
|
+
function req(method, body) {
|
|
26
|
+
const chunks = body === undefined ? [] : [Buffer.from(JSON.stringify(body), 'utf8')];
|
|
27
|
+
return { method, headers: { host: '127.0.0.1:1' }, url: '/', async *[Symbol.asyncIterator]() { for (const c of chunks) yield c; } };
|
|
28
|
+
}
|
|
29
|
+
const resObj = () => { const r = { statusCode: 0, body: '' }; r.writeHead = (c) => { r.statusCode = c; return r; }; r.end = (b) => { if (b !== undefined) r.body += b; return r; }; return r; };
|
|
30
|
+
async function call(name, method, body) {
|
|
31
|
+
const res = resObj();
|
|
32
|
+
await route(name).handler(req(method, body), res);
|
|
33
|
+
let json = null; try { json = JSON.parse(res.body); } catch { /* ignore */ }
|
|
34
|
+
return { status: res.statusCode, json };
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ① 造一个「只有旧键」的历史文件
|
|
38
|
+
const legacy = { version: 4, pinnedWorkspaceId: null, starredWorkspaces: [], starredSessions: [], starPrev: {}, pinnedSessionByWorkspace: {}, settings: { workspaceOpacity: 37, theme: 'metal' }, updatedAt: '2026-11-24T00:00:00.000Z' };
|
|
39
|
+
fs.writeFileSync(stateFile, JSON.stringify(legacy, null, 2), 'utf8');
|
|
40
|
+
console.log('【① 迁移前】磁盘文件 settings =');
|
|
41
|
+
console.log(' ' + JSON.stringify(JSON.parse(fs.readFileSync(stateFile, 'utf8')).settings));
|
|
42
|
+
|
|
43
|
+
// ② 读一次 → 应把旧值搬到新键返回
|
|
44
|
+
const read = await call('state', 'GET');
|
|
45
|
+
console.log('【② 读到旧值】GET /state → settings.areaOpacity = ' + read.json.settings.areaOpacity
|
|
46
|
+
+ ',返回值里还有 workspaceOpacity 吗? ' + ('workspaceOpacity' in read.json.settings ? '有(错)' : '没有(对)'));
|
|
47
|
+
|
|
48
|
+
// ③ 触发一次写盘(改个无关设置也行;这里直接用 areaOpacity 写一遍)
|
|
49
|
+
const wrote = await call('setting', 'POST', { key: 'areaOpacity', value: 41 });
|
|
50
|
+
const after = JSON.parse(fs.readFileSync(stateFile, 'utf8'));
|
|
51
|
+
console.log('【③ 写新键】POST /setting {areaOpacity:41} → HTTP ' + wrote.status);
|
|
52
|
+
console.log('【④ 迁移后】磁盘文件 settings =');
|
|
53
|
+
console.log(' ' + JSON.stringify(after.settings));
|
|
54
|
+
console.log(' → 旧键 workspaceOpacity 在吗? ' + ('workspaceOpacity' in after.settings ? '在(错)' : '已删除(对)'));
|
|
55
|
+
console.log(' → 新键 areaOpacity = ' + after.settings.areaOpacity);
|
|
56
|
+
|
|
57
|
+
// ⑤ 旧键当别名也能写
|
|
58
|
+
const alias = await call('setting', 'POST', { key: 'workspaceOpacity', value: 12 });
|
|
59
|
+
const after2 = JSON.parse(fs.readFileSync(stateFile, 'utf8'));
|
|
60
|
+
console.log('【⑤ 旧键别名】POST /setting {workspaceOpacity:12} → HTTP ' + alias.status
|
|
61
|
+
+ ',落到的键 areaOpacity = ' + after2.settings.areaOpacity
|
|
62
|
+
+ ',文件里旧键 ' + ('workspaceOpacity' in after2.settings ? '仍在(错)' : '仍不存在(对)'));
|
|
63
|
+
|
|
64
|
+
const ok = after.settings.areaOpacity === 41 && !('workspaceOpacity' in after.settings)
|
|
65
|
+
&& alias.status === 200 && after2.settings.areaOpacity === 12;
|
|
66
|
+
fs.rmSync(home, { recursive: true, force: true });
|
|
67
|
+
console.log('');
|
|
68
|
+
console.log(ok ? 'MIGRATION PROOF PASS' : 'MIGRATION PROOF FAIL');
|
|
69
|
+
return ok ? 0 : 1;
|
|
70
|
+
};
|
|
71
|
+
// 直接 `node tools/<file> …` 时自动执行:以前只导出函数,直接跑会静默 exit 0(T-20261125-05)
|
|
72
|
+
if (require.main === module) {
|
|
73
|
+
process.on('uncaughtException', (error) => {
|
|
74
|
+
console.error(' ERROR uncaughtException: ' + ((error && error.stack) || error));
|
|
75
|
+
process.exit(1);
|
|
76
|
+
});
|
|
77
|
+
process.on('unhandledRejection', (error) => {
|
|
78
|
+
console.error(' ERROR unhandledRejection: ' + ((error && error.stack) || error));
|
|
79
|
+
process.exit(1);
|
|
80
|
+
});
|
|
81
|
+
Promise.resolve()
|
|
82
|
+
.then(() => module.exports(process.argv.slice(2)))
|
|
83
|
+
.then((code) => { process.exitCode = typeof code === 'number' ? code : 1; },
|
|
84
|
+
(error) => {
|
|
85
|
+
console.error(' ERROR ' + ((error && error.stack) || error));
|
|
86
|
+
process.exitCode = 1;
|
|
87
|
+
});
|
|
88
|
+
}
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
// proof-opacity.cjs — 用**真实的 index.js(Host 半插件)** + 临时 DSH_HOME,
|
|
2
|
+
// 复现 CommanderT 要求的三步验证,并打印 settings JSON 片段。
|
|
3
|
+
// 目的:把「代码对不对」和「运行中的进程是不是旧版」两件事分开取证。
|
|
4
|
+
// 用法:run.cmd tools/proof-opacity.cjs index.js
|
|
5
|
+
module.exports = async function (args) {
|
|
6
|
+
const fs = require('node:fs');
|
|
7
|
+
const os = require('node:os');
|
|
8
|
+
const path = require('node:path');
|
|
9
|
+
const { pathToFileURL } = require('node:url');
|
|
10
|
+
|
|
11
|
+
const pluginPath = path.resolve(args[0]);
|
|
12
|
+
const home = fs.mkdtempSync(path.join(os.tmpdir(), 'wp-proof-'));
|
|
13
|
+
process.env.DSH_HOME = home;
|
|
14
|
+
const stateFile = path.join(home, 'workspace-pin.json');
|
|
15
|
+
|
|
16
|
+
let order = ['ws-a', 'ws-b'];
|
|
17
|
+
const registry = {
|
|
18
|
+
list() { return order.map(id => ({ id, path: 'D:\\' + id, title: id })); },
|
|
19
|
+
async insertBefore() { return order.slice(); },
|
|
20
|
+
};
|
|
21
|
+
const routes = [];
|
|
22
|
+
const ctx = {
|
|
23
|
+
effect(fn) { fn(); return () => {}; },
|
|
24
|
+
on() { return () => {}; },
|
|
25
|
+
get() { return undefined; },
|
|
26
|
+
webServer: { register(route) { routes.push(route); return () => {}; } },
|
|
27
|
+
workspaceRegistry: registry,
|
|
28
|
+
};
|
|
29
|
+
const plugin = await import(pathToFileURL(pluginPath).href);
|
|
30
|
+
plugin.apply(ctx);
|
|
31
|
+
|
|
32
|
+
const route = (name) => routes.find(r => r.path === '/workspace-pin/' + name);
|
|
33
|
+
function fakeReq(method, body) {
|
|
34
|
+
const chunks = body === undefined ? [] : [Buffer.from(JSON.stringify(body), 'utf8')];
|
|
35
|
+
return {
|
|
36
|
+
method,
|
|
37
|
+
headers: { host: '127.0.0.1:58525' },
|
|
38
|
+
url: '/workspace-pin/' + (method === 'GET' ? 'state' : 'setting'),
|
|
39
|
+
async *[Symbol.asyncIterator]() { for (const c of chunks) yield c; },
|
|
40
|
+
};
|
|
41
|
+
}
|
|
42
|
+
function fakeRes() {
|
|
43
|
+
const res = { statusCode: 0, body: '' };
|
|
44
|
+
res.writeHead = (code) => { res.statusCode = code; return res; };
|
|
45
|
+
res.end = (chunk) => { if (chunk !== undefined) res.body += chunk; return res; };
|
|
46
|
+
return res;
|
|
47
|
+
}
|
|
48
|
+
async function call(name, method, body) {
|
|
49
|
+
const res = fakeRes();
|
|
50
|
+
await route(name).handler(fakeReq(method, body), res);
|
|
51
|
+
let json = null;
|
|
52
|
+
try { json = JSON.parse(res.body); } catch { /* 非 JSON */ }
|
|
53
|
+
return { status: res.statusCode, json };
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
console.log('DSH_HOME(临时) = ' + home);
|
|
57
|
+
console.log('状态文件 = ' + stateFile);
|
|
58
|
+
console.log('');
|
|
59
|
+
|
|
60
|
+
const settingsFragment = () => {
|
|
61
|
+
const raw = JSON.parse(fs.readFileSync(stateFile, 'utf8'));
|
|
62
|
+
const s = raw.settings;
|
|
63
|
+
return JSON.stringify({
|
|
64
|
+
settingsTab: s.settingsTab,
|
|
65
|
+
areaOpacity: s.areaOpacity,
|
|
66
|
+
sidebarBackground: s.sidebarBackground,
|
|
67
|
+
showTokenBalance: s.showTokenBalance,
|
|
68
|
+
avatar: s.avatar,
|
|
69
|
+
}, null, 2);
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
let failures = 0;
|
|
73
|
+
const check = (ok, msg) => { if (!ok) { failures += 1; console.log(' ✗ ' + msg); } else { console.log(' ✓ ' + msg); } };
|
|
74
|
+
|
|
75
|
+
for (const value of [30, 0, 100]) {
|
|
76
|
+
console.log('=== 步骤:拖到 ' + value + '% 后松手(change 事件) ===');
|
|
77
|
+
const posted = await call('setting', 'POST', { key: 'areaOpacity', value });
|
|
78
|
+
console.log(' POST /workspace-pin/setting {key:"areaOpacity", value:' + value + '} → HTTP ' + posted.status);
|
|
79
|
+
check(posted.status === 200, 'Host 接受写入(200,不是 400 unknown setting)');
|
|
80
|
+
check(posted.json && posted.json.settings && posted.json.settings.areaOpacity === value,
|
|
81
|
+
'返回快照里的 areaOpacity = ' + value);
|
|
82
|
+
console.log(' ~/.dsh/workspace-pin.json → settings 片段:');
|
|
83
|
+
console.log(settingsFragment().split('\n').map(line => ' ' + line).join('\n'));
|
|
84
|
+
// 步骤 3:模拟刷新页面(重新读盘,不依赖内存)
|
|
85
|
+
const reread = await call('state', 'GET');
|
|
86
|
+
check(reread.json.settings.areaOpacity === value,
|
|
87
|
+
'刷新后 /state 仍读到 areaOpacity = ' + value + '(实际 ' + reread.json.settings.areaOpacity + ')');
|
|
88
|
+
console.log('');
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/* ---------- 另外四个新键:是否也真的落盘 ---------- */
|
|
92
|
+
console.log('=== 同类检查:其余新键是否真的写进 settings ===');
|
|
93
|
+
const pixel = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAADUlEQVR42mP8z8BQDwAEhQGAhKmMIQAAAABJRU5ErkJggg==';
|
|
94
|
+
const wsAsset = await call('asset', 'POST', { kind: 'ws', id: 'ws-a', dataUrl: pixel });
|
|
95
|
+
const bgAsset = await call('asset', 'POST', { kind: 'sidebar', dataUrl: pixel });
|
|
96
|
+
check(wsAsset.status === 200 && !!wsAsset.json.path, 'POST /asset(ws) 落盘 → ' + (wsAsset.json && wsAsset.json.path));
|
|
97
|
+
check(bgAsset.status === 200 && !!bgAsset.json.path, 'POST /asset(sidebar) 落盘 → ' + (bgAsset.json && bgAsset.json.path));
|
|
98
|
+
|
|
99
|
+
await call('setting', 'POST', { key: 'settingsTab', value: 3 });
|
|
100
|
+
await call('setting', 'POST', { key: 'showTokenBalance', value: true });
|
|
101
|
+
await call('setting', 'POST', { key: 'sidebarBackground', value: bgAsset.json.path });
|
|
102
|
+
await call('setting', 'POST', {
|
|
103
|
+
key: 'avatar',
|
|
104
|
+
value: { enabled: true, workspace: { 'ws-a': wsAsset.json.path }, session: {} },
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const final = (await call('state', 'GET')).json.settings;
|
|
108
|
+
check(final.settingsTab === 3, 'settingsTab 落盘 = 3(实际 ' + final.settingsTab + ')');
|
|
109
|
+
check(final.areaOpacity === 100, 'areaOpacity 落盘 = 100(实际 ' + final.areaOpacity + ')');
|
|
110
|
+
check(final.showTokenBalance === true, 'showTokenBalance 落盘 = true(实际 ' + final.showTokenBalance + ')');
|
|
111
|
+
check(final.sidebarBackground === bgAsset.json.path, 'sidebarBackground 落盘 = 素材路径(实际 ' + final.sidebarBackground + ')');
|
|
112
|
+
check(final.avatar.enabled === true, 'avatar.enabled 落盘 = true');
|
|
113
|
+
check(final.avatar.workspace['ws-a'] === wsAsset.json.path, 'avatar.workspace[ws-a] 落盘 = 素材路径');
|
|
114
|
+
|
|
115
|
+
console.log('');
|
|
116
|
+
console.log('=== 最终 settings 片段(重新读盘) ===');
|
|
117
|
+
console.log(settingsFragment().split('\n').map(line => ' ' + line).join('\n'));
|
|
118
|
+
{
|
|
119
|
+
const raw = fs.readFileSync(stateFile, 'utf8');
|
|
120
|
+
check(raw.charCodeAt(0) !== 0xFEFF, '状态文件无 BOM');
|
|
121
|
+
check(raw.indexOf('base64') === -1, 'JSON 里没有 base64(图片只存路径)');
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
/* ---------- 账户路由 ---------- */
|
|
125
|
+
console.log('');
|
|
126
|
+
console.log('=== /workspace-pin/account(余额 / 今日 token) ===');
|
|
127
|
+
const account = await call('account', 'GET');
|
|
128
|
+
check(account.status === 200, 'GET /account 可用(不是 404)');
|
|
129
|
+
console.log(' body = ' + JSON.stringify(account.json));
|
|
130
|
+
|
|
131
|
+
fs.rmSync(home, { recursive: true, force: true });
|
|
132
|
+
console.log('');
|
|
133
|
+
console.log(failures === 0 ? 'PROOF PASS(0 失败)' : 'PROOF FAIL(' + failures + ' 项)');
|
|
134
|
+
return failures === 0 ? 0 : 1;
|
|
135
|
+
};
|
|
136
|
+
// 直接 `node tools/<file> …` 时自动执行:以前只导出函数,直接跑会静默 exit 0(T-20261125-05)
|
|
137
|
+
if (require.main === module) {
|
|
138
|
+
process.on('uncaughtException', (error) => {
|
|
139
|
+
console.error(' ERROR uncaughtException: ' + ((error && error.stack) || error));
|
|
140
|
+
process.exit(1);
|
|
141
|
+
});
|
|
142
|
+
process.on('unhandledRejection', (error) => {
|
|
143
|
+
console.error(' ERROR unhandledRejection: ' + ((error && error.stack) || error));
|
|
144
|
+
process.exit(1);
|
|
145
|
+
});
|
|
146
|
+
Promise.resolve()
|
|
147
|
+
.then(() => module.exports(process.argv.slice(2)))
|
|
148
|
+
.then((code) => { process.exitCode = typeof code === 'number' ? code : 1; },
|
|
149
|
+
(error) => {
|
|
150
|
+
console.error(' ERROR ' + ((error && error.stack) || error));
|
|
151
|
+
process.exitCode = 1;
|
|
152
|
+
});
|
|
153
|
+
}
|