dsh-code-server-app 0.1.19 → 0.1.20

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/package.json CHANGED
@@ -1,52 +1,56 @@
1
- {
2
- "name": "dsh-code-server-app",
3
- "version": "0.1.19",
4
- "description": "Integrate code-server (VS Code in the browser) into DSH Web: floating ball entry + fullscreen overlay, host-side process lifecycle over a /code-server JSON API (motion-based spring window animations).",
5
- "homepage": "https://github.com/jinsiyu/dsh-code-server-app",
6
- "repository": {
7
- "type": "git",
8
- "url": "git+https://github.com/jinsiyu/dsh-code-server-app.git"
9
- },
10
- "type": "module",
11
- "main": "lib/index.js",
12
- "exports": {
13
- ".": "./lib/index.js",
14
- "./client": "./lib/client.js",
15
- "./package.json": "./package.json"
16
- },
17
- "dsh": {
18
- "bundle": {
19
- "patch": "./cordis.patch.yml"
20
- },
21
- "client": {
22
- "platform": "web",
23
- "inject": [
24
- "@deepseek-ai/dsh-client-connection",
25
- "@deepseek-ai/dsh-client-runtime",
26
- "@deepseek-ai/dsh-client-ui-settings"
27
- ]
28
- }
29
- },
30
- "files": [
31
- "lib/index.js",
32
- "lib/client.js",
33
- "scripts/setup-code-server.mjs",
34
- "cordis.patch.yml",
35
- "README.md"
36
- ],
37
- "scripts": {
38
- "postinstall": "node scripts/setup-code-server.mjs",
39
- "setup:code-server": "node scripts/setup-code-server.mjs",
40
- "build:client": "node scripts/build-client.mjs"
41
- },
42
- "devDependencies": {
43
- "esbuild": "^0.25.0",
44
- "motion": "^12.0.0"
45
- },
46
- "license": "MIT",
47
- "allowScripts": {
48
- "code-server": false,
49
- "argon2@0.44.0": true,
50
- "unrs-resolver@1.11.1": true
51
- }
52
- }
1
+ {
2
+ "name": "dsh-code-server-app",
3
+ "version": "0.1.20",
4
+ "description": "Integrate code-server (VS Code in the browser) into DSH Web: floating ball entry + fullscreen overlay, host-side process lifecycle over a /code-server JSON API (motion-based spring window animations).",
5
+ "homepage": "https://github.com/jinsiyu/dsh-code-server-app",
6
+ "repository": {
7
+ "type": "git",
8
+ "url": "git+https://github.com/jinsiyu/dsh-code-server-app.git"
9
+ },
10
+ "type": "module",
11
+ "main": "lib/index.js",
12
+ "exports": {
13
+ ".": "./lib/index.js",
14
+ "./client": "./lib/client.js",
15
+ "./package.json": "./package.json"
16
+ },
17
+ "dsh": {
18
+ "bundle": {
19
+ "patch": "./cordis.patch.yml"
20
+ },
21
+ "client": {
22
+ "platform": "web",
23
+ "inject": [
24
+ "@deepseek-ai/dsh-client-connection",
25
+ "@deepseek-ai/dsh-client-runtime",
26
+ "@deepseek-ai/dsh-client-ui-settings"
27
+ ]
28
+ }
29
+ },
30
+ "files": [
31
+ "lib/index.js",
32
+ "lib/client.js",
33
+ "assets/favicon.ico",
34
+ "assets/favicon.svg",
35
+ "assets/extensions/dshcs-open-file",
36
+ "scripts/setup-code-server.mjs",
37
+ "cordis.patch.yml",
38
+ "LICENSE",
39
+ "README.md"
40
+ ],
41
+ "scripts": {
42
+ "postinstall": "node scripts/setup-code-server.mjs",
43
+ "setup:code-server": "node scripts/setup-code-server.mjs",
44
+ "build:client": "node scripts/build-client.mjs"
45
+ },
46
+ "devDependencies": {
47
+ "esbuild": "^0.25.0",
48
+ "motion": "^12.0.0"
49
+ },
50
+ "license": "MIT",
51
+ "allowScripts": {
52
+ "code-server": false,
53
+ "argon2@0.44.0": true,
54
+ "unrs-resolver@1.11.1": true
55
+ }
56
+ }
@@ -1,155 +1,155 @@
1
- // scripts/setup-code-server.mjs — 方案 D:插件包内 npm 自装 code-server(Windows 兼容)。
2
- //
3
- // 背景:code-server 的官方 postinstall 是 `sh ./postinstall.sh`(依赖 bash/symlink),
4
- // Windows 无 sh 会直接失败;pnpm 的 build-scripts 许可只认宿主根 pnpm-workspace.yaml,
5
- // 依赖包声明无效。因此把 code-server 从 dependencies 移除,改由本脚本在插件包
6
- // postinstall 内用 **npm** 安装:
7
- // - npm 读取包内 package.json 的 allowScripts(code-server:false 跳过 sh;argon2/unrs
8
- // true 构建 native)——无需 --ignore-scripts,无需改宿主配置,零报错;
9
- // - 安装落在 **包内 node_modules**(--prefix 钉死),不写全局、不动 profile 顶层。
10
- //
11
- // 幂等:code-server 已实例化(entry + VS Code 内部依赖 + argon2 native 均在)则跳过;
12
- // pnpm 重装插件后会重跑 postinstall → 自动重新自装(自愈)。
13
- import { spawnSync } from 'node:child_process';
14
- import { existsSync, mkdirSync, writeFileSync, copyFileSync, readdirSync } from 'node:fs';
15
- import { dirname, join } from 'node:path';
16
- import { fileURLToPath } from 'node:url';
17
-
18
- const here = dirname(fileURLToPath(import.meta.url)); // .../dsh-code-server/scripts
19
- const pkgRoot = join(here, '..'); // <profile>\node_modules\dsh-code-server
20
-
21
- const CODE_SERVER_VERSION = '4.134.0';
22
-
23
- function run(cmd, args, cwd) {
24
- const useShell = process.platform === 'win32';
25
- const res = spawnSync(cmd, args, { cwd, stdio: 'inherit', shell: useShell });
26
- if (res.status !== 0) throw new Error(`${cmd} ${args.join(' ')} failed (${res.status})`);
27
- }
28
-
29
- function npm(cmdArgs, cwd) {
30
- run(process.platform === 'win32' ? 'npm.cmd' : 'npm', cmdArgs, cwd);
31
- }
32
-
33
- function ensureNpmDeps(dir) {
34
- if (!existsSync(join(dir, 'package.json'))) return;
35
- // --omit=dev:只装生产依赖(native 模块在依赖 postinstall 内建)
36
- npm(['install', '--omit=dev', '--no-audit', '--no-fund'], dir);
37
- }
38
-
39
- /** 专用安装根:<profile>\.code-server-app(如 C:\Users\User\.dsh\profiles\web\.code-server-app),
40
- * 与 profile 依赖树隔离(避免 npm 在 profile 根解析其他插件依赖触发 ERESOLVE)。
41
- * 最终 code-server 位于:<profile>\.code-server-app\node_modules\code-server */
42
- const APP_DIR_NAME = '.code-server-app';
43
-
44
- function profileRootOf() {
45
- // pkgRoot = <profile>\node_modules\dsh-code-server;向上两级 = <profile> 根;
46
- // 上层存在 node_modules + package.json 视为 profile 布局
47
- const profileRoot = join(pkgRoot, '..', '..');
48
- const isProfileLayout = existsSync(join(profileRoot, 'node_modules')) && existsSync(join(profileRoot, 'package.json'));
49
- return isProfileLayout ? profileRoot : null;
50
- }
51
-
52
- function findCodeServer() {
53
- // 布局候选(与安装目标同顺序):
54
- // 1. profile 专用目录:profileRoot\code-server-app\node_modules\code-server
55
- // 2. 包内:pkgRoot/node_modules/code-server(开发期 link:/独立目录)
56
- const profileRoot = profileRootOf();
57
- const cands = [];
58
- if (profileRoot !== null) {
59
- cands.push(join(profileRoot, APP_DIR_NAME, 'node_modules', 'code-server'));
60
- }
61
- cands.push(join(pkgRoot, 'node_modules', 'code-server'));
62
- for (const cand of cands) {
63
- if (existsSync(cand)) return cand;
64
- }
65
- return null;
66
- }
67
-
68
- function isComplete(cs) {
69
- return existsSync(join(cs, 'out', 'node', 'entry.js')) &&
70
- existsSync(join(cs, 'lib', 'vscode', 'node_modules', '@vscode', 'ripgrep')) &&
71
- (existsSync(join(cs, 'node_modules', 'argon2', 'build', 'Release', 'argon2.node')) ||
72
- existsSync(join(cs, 'node_modules', 'argon2', 'prebuilds')));
73
- }
74
-
75
- /** 安装目标:
76
- * 1. profile 布局 → <profile>\code-server-app(npm --prefix 装到
77
- * <profile>\code-server-app\node_modules\code-server,独立项目,无 ERESOLVE);
78
- * 2. 否则回退包内(工作区/独立目录场景)。 */
79
- function installPrefix() {
80
- const profileRoot = profileRootOf();
81
- return profileRoot !== null ? join(profileRoot, APP_DIR_NAME) : pkgRoot;
82
- }
83
-
84
- function installCodeServer() {
85
- const prefix = installPrefix();
86
- console.log(`[setup-code-server] npm 自装 code-server@${CODE_SERVER_VERSION}(target: ${prefix} → node_modules/code-server)${
87
- prefix === pkgRoot ? '(包内回退)' : '(profile 专用目录)'}…`);
88
- // npm 读取 prefix 项目自己的 package.json 的 allowScripts;在安装根写一个最小配置,
89
- // 让 code-server:false(跳过官方 sh postinstall)、argon2/unrs:true(native 构建)生效。
90
- const appPkg = join(prefix, 'package.json');
91
- if (!existsSync(appPkg)) {
92
- try {
93
- mkdirSync(prefix, { recursive: true });
94
- writeFileSync(appPkg, JSON.stringify({
95
- name: 'dsh-code-server-app',
96
- private: true,
97
- version: '0.0.0',
98
- allowScripts: { 'code-server': false, 'argon2@0.44.0': true, 'unrs-resolver@1.11.1': true },
99
- }, null, 2), 'utf8');
100
- } catch (e) {
101
- console.warn('[setup-code-server] 安装根 package.json 写入失败(allowScripts 可能不生效):', e.message);
102
- }
103
- }
104
- npm([
105
- 'install', `code-server@${CODE_SERVER_VERSION}`,
106
- '--no-save', '--no-audit', '--no-fund', '--prefix', prefix,
107
- ], prefix);
108
- }
109
-
110
- function main() {
111
- let cs = findCodeServer();
112
- if (cs !== null && isComplete(cs)) {
113
- console.log('[setup-code-server] code-server 已实例化(entry + 内部依赖 + native 均在),跳过');
114
- return;
115
- }
116
- if (cs === null || !existsSync(join(cs, 'out', 'node', 'entry.js'))) {
117
- installCodeServer();
118
- cs = findCodeServer();
119
- }
120
- if (cs === null) {
121
- console.warn('[setup-code-server] code-server 安装失败(未找到);请检查网络/npm 环境');
122
- return;
123
- }
124
-
125
- console.log('[setup-code-server] 补装 VS Code 内部依赖与原生模块…');
126
- const vscode = join(cs, 'lib', 'vscode');
127
- ensureNpmDeps(vscode);
128
- ensureNpmDeps(join(vscode, 'extensions'));
129
-
130
- // bin 入口:Windows 上官方 postinstall 是 mklink /J;此处用 cmdshim 拷贝兜底
131
- try {
132
- const bin = join(cs, 'bin');
133
- mkdirSync(bin, { recursive: true });
134
- const scriptsDir = join(cs, 'lib', 'vscode', 'bin');
135
- const remote = join(scriptsDir, 'remote-cli');
136
- if (existsSync(remote)) {
137
- for (const name of readdirSync(remote)) {
138
- if (name.endsWith('.cmd')) {
139
- copyFileSync(join(remote, name), join(bin, 'code-server.cmd'));
140
- console.log(`[setup-code-server] bin/code-server.cmd <- ${name}`);
141
- }
142
- }
143
- }
144
- } catch (e) {
145
- console.warn('[setup-code-server] bin 入口建立失败(不影响 runtime 启动,host 走 entry.js):', e.message);
146
- }
147
- console.log('[setup-code-server] 完成;entry:', existsSync(join(cs, 'out', 'node', 'entry.js')));
148
- }
149
-
150
- try {
151
- main();
152
- } catch (e) {
153
- console.error('[setup-code-server] 安装失败(插件仍可启动;README 有恢复指引):', e.message);
154
- process.exitCode = 0; // 不阻断 pnpm/npm install
155
- }
1
+ // scripts/setup-code-server.mjs — 方案 D:插件包内 npm 自装 code-server(Windows 兼容)。
2
+ //
3
+ // 背景:code-server 的官方 postinstall 是 `sh ./postinstall.sh`(依赖 bash/symlink),
4
+ // Windows 无 sh 会直接失败;pnpm 的 build-scripts 许可只认宿主根 pnpm-workspace.yaml,
5
+ // 依赖包声明无效。因此把 code-server 从 dependencies 移除,改由本脚本在插件包
6
+ // postinstall 内用 **npm** 安装:
7
+ // - npm 读取包内 package.json 的 allowScripts(code-server:false 跳过 sh;argon2/unrs
8
+ // true 构建 native)——无需 --ignore-scripts,无需改宿主配置,零报错;
9
+ // - 安装落在 **包内 node_modules**(--prefix 钉死),不写全局、不动 profile 顶层。
10
+ //
11
+ // 幂等:code-server 已实例化(entry + VS Code 内部依赖 + argon2 native 均在)则跳过;
12
+ // pnpm 重装插件后会重跑 postinstall → 自动重新自装(自愈)。
13
+ import { spawnSync } from 'node:child_process';
14
+ import { existsSync, mkdirSync, writeFileSync, copyFileSync, readdirSync } from 'node:fs';
15
+ import { dirname, join } from 'node:path';
16
+ import { fileURLToPath } from 'node:url';
17
+
18
+ const here = dirname(fileURLToPath(import.meta.url)); // .../dsh-code-server/scripts
19
+ const pkgRoot = join(here, '..'); // <profile>\node_modules\dsh-code-server
20
+
21
+ const CODE_SERVER_VERSION = '4.134.0';
22
+
23
+ function run(cmd, args, cwd) {
24
+ const useShell = process.platform === 'win32';
25
+ const res = spawnSync(cmd, args, { cwd, stdio: 'inherit', shell: useShell });
26
+ if (res.status !== 0) throw new Error(`${cmd} ${args.join(' ')} failed (${res.status})`);
27
+ }
28
+
29
+ function npm(cmdArgs, cwd) {
30
+ run(process.platform === 'win32' ? 'npm.cmd' : 'npm', cmdArgs, cwd);
31
+ }
32
+
33
+ function ensureNpmDeps(dir) {
34
+ if (!existsSync(join(dir, 'package.json'))) return;
35
+ // --omit=dev:只装生产依赖(native 模块在依赖 postinstall 内建)
36
+ npm(['install', '--omit=dev', '--no-audit', '--no-fund'], dir);
37
+ }
38
+
39
+ /** 专用安装根:<profile>\.code-server-app(如 C:\Users\User\.dsh\profiles\web\.code-server-app),
40
+ * 与 profile 依赖树隔离(避免 npm 在 profile 根解析其他插件依赖触发 ERESOLVE)。
41
+ * 最终 code-server 位于:<profile>\.code-server-app\node_modules\code-server */
42
+ const APP_DIR_NAME = '.code-server-app';
43
+
44
+ function profileRootOf() {
45
+ // pkgRoot = <profile>\node_modules\dsh-code-server;向上两级 = <profile> 根;
46
+ // 上层存在 node_modules + package.json 视为 profile 布局
47
+ const profileRoot = join(pkgRoot, '..', '..');
48
+ const isProfileLayout = existsSync(join(profileRoot, 'node_modules')) && existsSync(join(profileRoot, 'package.json'));
49
+ return isProfileLayout ? profileRoot : null;
50
+ }
51
+
52
+ function findCodeServer() {
53
+ // 布局候选(与安装目标同顺序):
54
+ // 1. profile 专用目录:profileRoot\code-server-app\node_modules\code-server
55
+ // 2. 包内:pkgRoot/node_modules/code-server(开发期 link:/独立目录)
56
+ const profileRoot = profileRootOf();
57
+ const cands = [];
58
+ if (profileRoot !== null) {
59
+ cands.push(join(profileRoot, APP_DIR_NAME, 'node_modules', 'code-server'));
60
+ }
61
+ cands.push(join(pkgRoot, 'node_modules', 'code-server'));
62
+ for (const cand of cands) {
63
+ if (existsSync(cand)) return cand;
64
+ }
65
+ return null;
66
+ }
67
+
68
+ function isComplete(cs) {
69
+ return existsSync(join(cs, 'out', 'node', 'entry.js')) &&
70
+ existsSync(join(cs, 'lib', 'vscode', 'node_modules', '@vscode', 'ripgrep')) &&
71
+ (existsSync(join(cs, 'node_modules', 'argon2', 'build', 'Release', 'argon2.node')) ||
72
+ existsSync(join(cs, 'node_modules', 'argon2', 'prebuilds')));
73
+ }
74
+
75
+ /** 安装目标:
76
+ * 1. profile 布局 → <profile>\code-server-app(npm --prefix 装到
77
+ * <profile>\code-server-app\node_modules\code-server,独立项目,无 ERESOLVE);
78
+ * 2. 否则回退包内(工作区/独立目录场景)。 */
79
+ function installPrefix() {
80
+ const profileRoot = profileRootOf();
81
+ return profileRoot !== null ? join(profileRoot, APP_DIR_NAME) : pkgRoot;
82
+ }
83
+
84
+ function installCodeServer() {
85
+ const prefix = installPrefix();
86
+ console.log(`[setup-code-server] npm 自装 code-server@${CODE_SERVER_VERSION}(target: ${prefix} → node_modules/code-server)${
87
+ prefix === pkgRoot ? '(包内回退)' : '(profile 专用目录)'}…`);
88
+ // npm 读取 prefix 项目自己的 package.json 的 allowScripts;在安装根写一个最小配置,
89
+ // 让 code-server:false(跳过官方 sh postinstall)、argon2/unrs:true(native 构建)生效。
90
+ const appPkg = join(prefix, 'package.json');
91
+ if (!existsSync(appPkg)) {
92
+ try {
93
+ mkdirSync(prefix, { recursive: true });
94
+ writeFileSync(appPkg, JSON.stringify({
95
+ name: 'dsh-code-server-app',
96
+ private: true,
97
+ version: '0.0.0',
98
+ allowScripts: { 'code-server': false, 'argon2@0.44.0': true, 'unrs-resolver@1.11.1': true },
99
+ }, null, 2), 'utf8');
100
+ } catch (e) {
101
+ console.warn('[setup-code-server] 安装根 package.json 写入失败(allowScripts 可能不生效):', e.message);
102
+ }
103
+ }
104
+ npm([
105
+ 'install', `code-server@${CODE_SERVER_VERSION}`,
106
+ '--no-save', '--no-audit', '--no-fund', '--prefix', prefix,
107
+ ], prefix);
108
+ }
109
+
110
+ function main() {
111
+ let cs = findCodeServer();
112
+ if (cs !== null && isComplete(cs)) {
113
+ console.log('[setup-code-server] code-server 已实例化(entry + 内部依赖 + native 均在),跳过');
114
+ return;
115
+ }
116
+ if (cs === null || !existsSync(join(cs, 'out', 'node', 'entry.js'))) {
117
+ installCodeServer();
118
+ cs = findCodeServer();
119
+ }
120
+ if (cs === null) {
121
+ console.warn('[setup-code-server] code-server 安装失败(未找到);请检查网络/npm 环境');
122
+ return;
123
+ }
124
+
125
+ console.log('[setup-code-server] 补装 VS Code 内部依赖与原生模块…');
126
+ const vscode = join(cs, 'lib', 'vscode');
127
+ ensureNpmDeps(vscode);
128
+ ensureNpmDeps(join(vscode, 'extensions'));
129
+
130
+ // bin 入口:Windows 上官方 postinstall 是 mklink /J;此处用 cmdshim 拷贝兜底
131
+ try {
132
+ const bin = join(cs, 'bin');
133
+ mkdirSync(bin, { recursive: true });
134
+ const scriptsDir = join(cs, 'lib', 'vscode', 'bin');
135
+ const remote = join(scriptsDir, 'remote-cli');
136
+ if (existsSync(remote)) {
137
+ for (const name of readdirSync(remote)) {
138
+ if (name.endsWith('.cmd')) {
139
+ copyFileSync(join(remote, name), join(bin, 'code-server.cmd'));
140
+ console.log(`[setup-code-server] bin/code-server.cmd <- ${name}`);
141
+ }
142
+ }
143
+ }
144
+ } catch (e) {
145
+ console.warn('[setup-code-server] bin 入口建立失败(不影响 runtime 启动,host 走 entry.js):', e.message);
146
+ }
147
+ console.log('[setup-code-server] 完成;entry:', existsSync(join(cs, 'out', 'node', 'entry.js')));
148
+ }
149
+
150
+ try {
151
+ main();
152
+ } catch (e) {
153
+ console.error('[setup-code-server] 安装失败(插件仍可启动;README 有恢复指引):', e.message);
154
+ process.exitCode = 0; // 不阻断 pnpm/npm install
155
+ }