@walkhi/code-relax 0.1.0-beta.106 → 0.1.0-beta.108

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.
@@ -1 +1 @@
1
- {"layout":"npm-platform-packages","version":"0.1.0-beta.106"}
1
+ {"layout":"npm-platform-packages","version":"0.1.0-beta.108"}
@@ -1,4 +1,4 @@
1
- export const FILE_READ_LIMIT = 20 * 1024 * 1024;
1
+ export const FILE_READ_LIMIT = 50 * 1024 * 1024;
2
2
  export const FILE_PART_BYTES = 256 * 1024;
3
3
  export class FileRangeError extends Error {
4
4
  constructor(statusCode, message) { super(message); this.statusCode = statusCode; }
@@ -2,9 +2,9 @@ import crypto from 'node:crypto';
2
2
  import fs from 'node:fs/promises';
3
3
  import path from 'node:path';
4
4
 
5
- export const MAX_FILE_BYTES = 20 * 1024 * 1024;
5
+ export const MAX_FILE_BYTES = 50 * 1024 * 1024;
6
6
  export const MAX_FILE_COUNT = 4;
7
- export const MAX_TOTAL_BYTES = 40 * 1024 * 1024;
7
+ export const MAX_TOTAL_BYTES = MAX_FILE_BYTES;
8
8
  export const FILE_CHUNK_BYTES = 256 * 1024;
9
9
 
10
10
  function validName(value) {
@@ -63,8 +63,8 @@ export function createFileUploadSession(root) {
63
63
  // and commit after a direct connection has been replaced.
64
64
  if (relayed) {
65
65
  const originals = [...files.values()].filter(file => !file.previewOf);
66
- if (originals.some(file => file.size > MAX_FILE_BYTES)) throw new Error('服务器转发仅支持单个文件不超过 20 MiB,请使用局域网或 RTC 直连');
67
- if (originals.reduce((sum, file) => sum + file.size, 0) > MAX_TOTAL_BYTES) throw new Error('服务器转发仅支持每批合计不超过 40 MiB,请使用局域网或 RTC 直连');
66
+ if (originals.some(file => file.size > MAX_FILE_BYTES)) throw new Error('服务器转发仅支持单个文件不超过 50 MiB,请使用局域网或 RTC 直连');
67
+ if (originals.reduce((sum, file) => sum + file.size, 0) > MAX_TOTAL_BYTES) throw new Error('服务器转发仅支持每批合计不超过 50 MiB,请使用局域网或 RTC 直连');
68
68
  }
69
69
  if (message.type === 'commit') {
70
70
  if (upload) throw new Error('文件尚未上传完成');
@@ -96,11 +96,11 @@ export function createFileUploadSession(root) {
96
96
  if (!Number.isSafeInteger(message.size) || message.size < 1) {
97
97
  throw new Error('文件大小无效');
98
98
  }
99
- if (relayed && message.size > MAX_FILE_BYTES) throw new Error('服务器转发仅支持单个文件不超过 20 MiB,请使用局域网或 RTC 直连');
99
+ if (relayed && message.size > MAX_FILE_BYTES) throw new Error('服务器转发仅支持单个文件不超过 50 MiB,请使用局域网或 RTC 直连');
100
100
  const parent = message.previewOf ? completed.get(message.previewOf) : null;
101
101
  if (message.previewOf && (!parent || parent.preview || message.size > FILE_CHUNK_BYTES)) throw new Error('预览图关联无效或超过 256 KiB');
102
102
  if (!parent && completed.size >= MAX_FILE_COUNT) throw new Error('每条消息最多 4 个文件');
103
- if (!parent && relayed && completedBytes + message.size > MAX_TOTAL_BYTES) throw new Error('服务器转发仅支持每批合计不超过 40 MiB,请使用局域网或 RTC 直连');
103
+ if (!parent && relayed && completedBytes + message.size > MAX_TOTAL_BYTES) throw new Error('服务器转发仅支持每批合计不超过 50 MiB,请使用局域网或 RTC 直连');
104
104
  const id = crypto.randomUUID();
105
105
  await fs.mkdir(directory, { recursive: true });
106
106
  const partial = path.join(directory, `.upload-${id}`);
@@ -150,7 +150,7 @@ export function attachLanSocket(server, { token, dispatch, authorizeDevice = ()
150
150
  json(status, body) { reply({ type: 'error', status, error: body?.error || '文件读取失败' }); },
151
151
  filePart(metadata, data) {
152
152
  if (stopped || ws.readyState !== WebSocket.OPEN) return;
153
- if (fileRelay && metadata.size > FILE_READ_LIMIT) throw new Error('服务器转发仅支持下载不超过 20 MiB 的文件,请使用局域网或 RTC 直连');
153
+ if (fileRelay && metadata.size > FILE_READ_LIMIT) throw new Error('服务器转发仅支持下载不超过 50 MiB 的文件,请使用局域网或 RTC 直连');
154
154
  if (!Buffer.isBuffer(data) || data.length > FILE_CHUNK_BYTES || ws.bufferedAmount > 1024 * 1024) throw new Error('文件接收过慢或分片无效');
155
155
  reply({ type: 'part', ...metadata, length: data.length });
156
156
  ws.send(data);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@walkhi/code-relax",
3
- "version": "0.1.0-beta.106",
3
+ "version": "0.1.0-beta.108",
4
4
  "private": false,
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -41,6 +41,7 @@ function runStage(entry, stage, args, formatOutput = value => value) {
41
41
  stdio: ['inherit', 'pipe', 'pipe'] });
42
42
  if (output) { process.stdout.write(formatOutput(output)); appendLog(`[${stage}] stdout\n${output.trimEnd()}`); }
43
43
  appendLog(`[${stage}] success`);
44
+ return output;
44
45
  } catch (error) {
45
46
  if (error?.stdout) { process.stdout.write(error.stdout); appendLog(`[${stage}] stdout\n${String(error.stdout).trimEnd()}`); }
46
47
  if (error?.stderr) { process.stderr.write(error.stderr); appendLog(`[${stage}] stderr\n${String(error.stderr).trimEnd()}`); }
@@ -152,18 +153,30 @@ if (invokedDirectly && process.env.npm_config_global === 'true') {
152
153
  const { prepareNativePackage } = await import('../dist/src/platform/native-package.mjs');
153
154
  prepareNativePackage(fileURLToPath(new URL('../', import.meta.url)));
154
155
  setupStarted = true;
155
- runStage(entry, 'setup', ['setup', '--json'], output => formatSetupOutput(output));
156
+ const setupOutput = runStage(entry, 'setup', ['setup', '--json'], formatSetupOutput);
156
157
  try {
157
158
  runStage(entry, 'doctor', ['doctor']);
158
- console.log('Code Relax 自动安装成功:setup 与安装后健康检查均已通过,无需重复执行 setup。');
159
- console.log('npm 的脚本安全提示与安装结果分别判断;本次安装脚本已实际执行,未修改 npm 安全配置。');
160
159
  }
161
160
  catch (error) {
162
161
  console.error('服务安装已完成,但安装后健康检查未通过;请查看上方诊断与安装日志。');
163
162
  process.exitCode = Number.isInteger(error?.status) && error.status > 0 ? error.status : 1;
164
163
  }
164
+ let desktopHelperReady = true;
165
+ if (!process.exitCode && process.platform === 'win32') {
166
+ try {
167
+ if (JSON.parse(setupOutput).desktopHelper?.running !== true) {
168
+ console.log('正在启用桌面操作辅助服务,请在这台电脑确认 Windows 权限提示。');
169
+ runStage(entry, 'desktop-helper-install', ['desktop-helper-install']);
170
+ }
171
+ } catch {
172
+ desktopHelperReady = false;
173
+ process.exitCode = 1;
174
+ console.error('Code Relax 安装失败:桌面操作辅助服务未就绪。请查看安装日志。');
175
+ }
176
+ }
177
+ if (!process.exitCode && desktopHelperReady) console.log('Code Relax 自动安装成功:工作站健康检查与所需组件均已就绪。');
165
178
  console.log(`安装日志:${installLog}`);
166
- appendLog(process.exitCode ? '[postinstall] failed stage=doctor' : '[postinstall] success');
179
+ appendLog(!desktopHelperReady ? '[postinstall] failed stage=desktop-helper' : process.exitCode ? '[postinstall] failed stage=doctor' : '[postinstall] success');
167
180
  } catch (error) {
168
181
  const current = installationSnapshot();
169
182
  if (!setupStarted) console.error(`平台组件检查失败:${error.message}`);