跳到主要内容

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

浏览文件

zlib.js

51 行 · 1.2 KB历史下载
1/*
2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2024 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
10import Inflator from "../inflator.js";
11
12export default class ZlibDecoder {
13 constructor() {
14 this._zlib = new Inflator();
15 this._length = 0;
16 }
17
18 decodeRect(x, y, width, height, sock, display, depth) {
19 if ((width === 0) || (height === 0)) {
20 return true;
21 }
22
23 if (this._length === 0) {
24 if (sock.rQwait("ZLIB", 4)) {
25 return false;
26 }
27
28 this._length = sock.rQshift32();
29 }
30
31 if (sock.rQwait("ZLIB", this._length)) {
32 return false;
33 }
34
35 let data = new Uint8Array(sock.rQshiftBytes(this._length, false));
36 this._length = 0;
37
38 this._zlib.setInput(data);
39 data = this._zlib.inflate(width * height * 4);
40 this._zlib.setInput(null);
41
42 // Max sure the image is fully opaque
43 for (let i = 0; i < width * height; i++) {
44 data[i * 4 + 3] = 255;
45 }
46
47 display.blitImage(x, y, width, height, data, 0);
48
49 return true;
50 }
51}