跳到主要内容

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

浏览文件

inflator.js

65 行 · 1.9 KB历史下载
1/*
2 * noVNC: HTML5 VNC client
3 * Copyright (C) 2020 The noVNC authors
4 * Licensed under MPL 2.0 (see LICENSE.txt)
5 *
6 * See README.md for usage and integration instructions.
7 */
8
9import { inflateInit, inflate, inflateReset } from "../vendor/pako/lib/zlib/inflate.js";
10import ZStream from "../vendor/pako/lib/zlib/zstream.js";
11
12export default class Inflate {
13 constructor() {
14 this.strm = new ZStream();
15 this.chunkSize = 1024 * 10 * 10;
16 this.strm.output = new Uint8Array(this.chunkSize);
17
18 inflateInit(this.strm);
19 }
20
21 setInput(data) {
22 if (!data) {
23 //FIXME: flush remaining data.
24 /* eslint-disable camelcase */
25 this.strm.input = null;
26 this.strm.avail_in = 0;
27 this.strm.next_in = 0;
28 } else {
29 this.strm.input = data;
30 this.strm.avail_in = this.strm.input.length;
31 this.strm.next_in = 0;
32 /* eslint-enable camelcase */
33 }
34 }
35
36 inflate(expected) {
37 // resize our output buffer if it's too small
38 // (we could just use multiple chunks, but that would cause an extra
39 // allocation each time to flatten the chunks)
40 if (expected > this.chunkSize) {
41 this.chunkSize = expected;
42 this.strm.output = new Uint8Array(this.chunkSize);
43 }
44
45 /* eslint-disable camelcase */
46 this.strm.next_out = 0;
47 this.strm.avail_out = expected;
48 /* eslint-enable camelcase */
49
50 let ret = inflate(this.strm, 0); // Flush argument not used.
51 if (ret < 0) {
52 throw new Error("zlib inflate failed");
53 }
54
55 if (this.strm.next_out != expected) {
56 throw new Error("Incomplete zlib block");
57 }
58
59 return new Uint8Array(this.strm.output.buffer, 0, this.strm.next_out);
60 }
61
62 reset() {
63 inflateReset(this.strm);
64 }
65}