跳到主要内容

Claude Cage · 面向 Claude 的隔离开发环境,支持桌面工作台、多账号、远程部署与移动端连接。上游 Lee-xeo/Claude-Cage 完整源码镜像,非灵栈原创;主许可 MIT,第三方组件遵循各自许可。来源:https://github.com/Lee-xeo/Claude-Cage 。手动同步,不附带 Release 安装包。

浏览文件

raw.js

59 行 · 1.6 KB历史下载
1/*
2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2019 The noVNC authors
4 * Licensed under MPL 2.0 (see LICENSE.txt)
5 *
6 * See README.md for usage and integration instructions.
7 *
8 */
9
10export default class RawDecoder {
11 constructor() {
12 this._lines = 0;
13 }
14
15 decodeRect(x, y, width, height, sock, display, depth) {
16 if ((width === 0) || (height === 0)) {
17 return true;
18 }
19
20 if (this._lines === 0) {
21 this._lines = height;
22 }
23
24 const pixelSize = depth == 8 ? 1 : 4;
25 const bytesPerLine = width * pixelSize;
26
27 while (this._lines > 0) {
28 if (sock.rQwait("RAW", bytesPerLine)) {
29 return false;
30 }
31
32 const curY = y + (height - this._lines);
33
34 let data = sock.rQshiftBytes(bytesPerLine, false);
35
36 // Convert data if needed
37 if (depth == 8) {
38 const newdata = new Uint8Array(width * 4);
39 for (let i = 0; i < width; i++) {
40 newdata[i * 4 + 0] = ((data[i] >> 0) & 0x3) * 255 / 3;
41 newdata[i * 4 + 1] = ((data[i] >> 2) & 0x3) * 255 / 3;
42 newdata[i * 4 + 2] = ((data[i] >> 4) & 0x3) * 255 / 3;
43 newdata[i * 4 + 3] = 255;
44 }
45 data = newdata;
46 }
47
48 // Max sure the image is fully opaque
49 for (let i = 0; i < width; i++) {
50 data[i * 4 + 3] = 255;
51 }
52
53 display.blitImage(x, curY, width, 1, data, 0);
54 this._lines--;
55 }
56
57 return true;
58 }
59}