@jait/gateway 0.1.256 → 0.1.258
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/dist/routes/preview.d.ts.map +1 -1
- package/dist/routes/preview.js +41 -2
- package/dist/routes/preview.js.map +1 -1
- package/dist/security/sandbox-manager.d.ts +8 -0
- package/dist/security/sandbox-manager.d.ts.map +1 -1
- package/dist/security/sandbox-manager.js +131 -2
- package/dist/security/sandbox-manager.js.map +1 -1
- package/dist/services/live-view-manager.d.ts +25 -0
- package/dist/services/live-view-manager.d.ts.map +1 -0
- package/dist/services/live-view-manager.js +178 -0
- package/dist/services/live-view-manager.js.map +1 -0
- package/dist/services/preview.d.ts +21 -2
- package/dist/services/preview.d.ts.map +1 -1
- package/dist/services/preview.js +140 -2
- package/dist/services/preview.js.map +1 -1
- package/dist/surfaces/browser.d.ts +51 -1
- package/dist/surfaces/browser.d.ts.map +1 -1
- package/dist/surfaces/browser.js +238 -20
- package/dist/surfaces/browser.js.map +1 -1
- package/dist/tools/preview-tools.d.ts.map +1 -1
- package/dist/tools/preview-tools.js +6 -3
- package/dist/tools/preview-tools.js.map +1 -1
- package/package.json +1 -1
- package/web-dist/assets/{_basePickBy-B5ojxQyY.js → _basePickBy-B1Q85huU.js} +1 -1
- package/web-dist/assets/{_baseUniq-BVcMC3e3.js → _baseUniq-xbSl0CM3.js} +1 -1
- package/web-dist/assets/{arc-B8rKyks5.js → arc-BPQiaftr.js} +1 -1
- package/web-dist/assets/{architectureDiagram-2XIMDMQ5-D5Rn0_M_.js → architectureDiagram-2XIMDMQ5-DAG0yXkD.js} +1 -1
- package/web-dist/assets/{blockDiagram-WCTKOSBZ-Dn0EedHT.js → blockDiagram-WCTKOSBZ-BHwTxFpO.js} +1 -1
- package/web-dist/assets/{c4Diagram-IC4MRINW-BYTFS9YT.js → c4Diagram-IC4MRINW-DSo8jOax.js} +1 -1
- package/web-dist/assets/channel-D0UG72Sd.js +1 -0
- package/web-dist/assets/{chunk-4BX2VUAB-c51Qw6zZ.js → chunk-4BX2VUAB-BvHzmUEU.js} +1 -1
- package/web-dist/assets/{chunk-55IACEB6-BLJEbYZY.js → chunk-55IACEB6-DRwUUfw9.js} +1 -1
- package/web-dist/assets/{chunk-FMBD7UC4-BTQRsQCz.js → chunk-FMBD7UC4-C-og1AV4.js} +1 -1
- package/web-dist/assets/{chunk-JSJVCQXG-BCQCgV3v.js → chunk-JSJVCQXG-DQ_Nx-12.js} +1 -1
- package/web-dist/assets/{chunk-KX2RTZJC-BdxNziNu.js → chunk-KX2RTZJC-DJt22pKX.js} +1 -1
- package/web-dist/assets/{chunk-NQ4KR5QH-DvtJCn0C.js → chunk-NQ4KR5QH-DwqccJna.js} +1 -1
- package/web-dist/assets/{chunk-QZHKN3VN-Bv5UUhJr.js → chunk-QZHKN3VN-t2Z5FHem.js} +1 -1
- package/web-dist/assets/{chunk-WL4C6EOR-DgCZzsOT.js → chunk-WL4C6EOR-DhnNywRj.js} +1 -1
- package/web-dist/assets/classDiagram-VBA2DB6C-Dnib5gxK.js +1 -0
- package/web-dist/assets/classDiagram-v2-RAHNMMFH-Dnib5gxK.js +1 -0
- package/web-dist/assets/clone-jMsfbHCu.js +1 -0
- package/web-dist/assets/{cose-bilkent-S5V4N54A-CmDdGIef.js → cose-bilkent-S5V4N54A-CLw8R8jY.js} +1 -1
- package/web-dist/assets/{dagre-KLK3FWXG-BzeF6p1D.js → dagre-KLK3FWXG-DG-8BOX_.js} +1 -1
- package/web-dist/assets/{diagram-E7M64L7V-lDeWArgl.js → diagram-E7M64L7V-I6Ok2sG0.js} +1 -1
- package/web-dist/assets/{diagram-IFDJBPK2-BguEZbUg.js → diagram-IFDJBPK2-ertAk1QG.js} +1 -1
- package/web-dist/assets/{diagram-P4PSJMXO-CnTxg2wa.js → diagram-P4PSJMXO-B9Yr9iab.js} +1 -1
- package/web-dist/assets/{erDiagram-INFDFZHY-D2aGee-H.js → erDiagram-INFDFZHY-BMva8gYu.js} +1 -1
- package/web-dist/assets/{flowDiagram-PKNHOUZH-DYPu_lOt.js → flowDiagram-PKNHOUZH-D1dJMWaL.js} +1 -1
- package/web-dist/assets/{ganttDiagram-A5KZAMGK-D-9aApiK.js → ganttDiagram-A5KZAMGK-qRDi6l_-.js} +1 -1
- package/web-dist/assets/{gitGraphDiagram-K3NZZRJ6-CGHZTbqZ.js → gitGraphDiagram-K3NZZRJ6-X8idci3H.js} +1 -1
- package/web-dist/assets/{graph-xl1n4wd4.js → graph-6RqPLKMD.js} +1 -1
- package/web-dist/assets/{index-CNdW3yYd.js → index-B0GgFn4l.js} +306 -306
- package/web-dist/assets/{index-qWyAYgAD.css → index-DFW3_r8A.css} +1 -1
- package/web-dist/assets/{infoDiagram-LFFYTUFH-JQ1DhuIN.js → infoDiagram-LFFYTUFH-CMk_Yj9c.js} +1 -1
- package/web-dist/assets/{ishikawaDiagram-PHBUUO56-BiQo9puY.js → ishikawaDiagram-PHBUUO56-CwBIr6E2.js} +1 -1
- package/web-dist/assets/{journeyDiagram-4ABVD52K-BWvVCFKb.js → journeyDiagram-4ABVD52K-BgD5iS1h.js} +1 -1
- package/web-dist/assets/{kanban-definition-K7BYSVSG-B1pZvgm7.js → kanban-definition-K7BYSVSG-CzjxHzou.js} +1 -1
- package/web-dist/assets/{layout-C_VnOnT4.js → layout-b5fe_UxD.js} +1 -1
- package/web-dist/assets/{linear-BeBoVpvX.js → linear-ChI_4a9O.js} +1 -1
- package/web-dist/assets/{mindmap-definition-YRQLILUH-B3U5ZJAw.js → mindmap-definition-YRQLILUH-e_vvWWg8.js} +1 -1
- package/web-dist/assets/{pieDiagram-SKSYHLDU-B9JMxGDx.js → pieDiagram-SKSYHLDU-CJtQ5J0D.js} +1 -1
- package/web-dist/assets/{quadrantDiagram-337W2JSQ-DNAEOevf.js → quadrantDiagram-337W2JSQ-Cf_x_2ej.js} +1 -1
- package/web-dist/assets/{requirementDiagram-Z7DCOOCP-Dcgzabvl.js → requirementDiagram-Z7DCOOCP-DCQvoqk_.js} +1 -1
- package/web-dist/assets/{sankeyDiagram-WA2Y5GQK-BDcQVCtL.js → sankeyDiagram-WA2Y5GQK-D2eB9_Im.js} +1 -1
- package/web-dist/assets/{sequenceDiagram-2WXFIKYE-5kY7GmoR.js → sequenceDiagram-2WXFIKYE-Ccyyepsb.js} +1 -1
- package/web-dist/assets/{stateDiagram-RAJIS63D-BwQlMlEC.js → stateDiagram-RAJIS63D-DPMGShy8.js} +1 -1
- package/web-dist/assets/stateDiagram-v2-FVOUBMTO-BmvKM7hT.js +1 -0
- package/web-dist/assets/{timeline-definition-YZTLITO2-BE0IDpJe.js → timeline-definition-YZTLITO2-CHBPr8N4.js} +1 -1
- package/web-dist/assets/{treemap-KZPCXAKY-CHwtWAgO.js → treemap-KZPCXAKY-DnqeIQgk.js} +1 -1
- package/web-dist/assets/{vennDiagram-LZ73GAT5-ByqFK92_.js → vennDiagram-LZ73GAT5-BRIzanhU.js} +1 -1
- package/web-dist/assets/{xychartDiagram-JWTSCODW-BdCa1f3c.js → xychartDiagram-JWTSCODW-qjjqxrk2.js} +1 -1
- package/web-dist/index.html +2 -2
- package/web-dist/noVNC/LICENSE.txt +62 -0
- package/web-dist/noVNC/app/error-handler.js +79 -0
- package/web-dist/noVNC/app/images/alt.svg +92 -0
- package/web-dist/noVNC/app/images/clipboard.svg +106 -0
- package/web-dist/noVNC/app/images/connect.svg +96 -0
- package/web-dist/noVNC/app/images/ctrl.svg +96 -0
- package/web-dist/noVNC/app/images/ctrlaltdel.svg +100 -0
- package/web-dist/noVNC/app/images/disconnect.svg +94 -0
- package/web-dist/noVNC/app/images/drag.svg +76 -0
- package/web-dist/noVNC/app/images/error.svg +81 -0
- package/web-dist/noVNC/app/images/esc.svg +92 -0
- package/web-dist/noVNC/app/images/expander.svg +69 -0
- package/web-dist/noVNC/app/images/fullscreen.svg +93 -0
- package/web-dist/noVNC/app/images/handle.svg +82 -0
- package/web-dist/noVNC/app/images/handle_bg.svg +172 -0
- package/web-dist/noVNC/app/images/icons/Makefile +42 -0
- package/web-dist/noVNC/app/images/icons/novnc-icon-sm.svg +163 -0
- package/web-dist/noVNC/app/images/icons/novnc-icon.svg +163 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-120.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-152.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-167.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-180.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-40.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-58.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-60.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-80.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-87.png +0 -0
- package/web-dist/noVNC/app/images/icons/novnc-ios-icon.svg +183 -0
- package/web-dist/noVNC/app/images/icons/novnc.ico +0 -0
- package/web-dist/noVNC/app/images/info.svg +81 -0
- package/web-dist/noVNC/app/images/keyboard.svg +88 -0
- package/web-dist/noVNC/app/images/power.svg +87 -0
- package/web-dist/noVNC/app/images/settings.svg +76 -0
- package/web-dist/noVNC/app/images/tab.svg +86 -0
- package/web-dist/noVNC/app/images/toggleextrakeys.svg +90 -0
- package/web-dist/noVNC/app/images/warning.svg +81 -0
- package/web-dist/noVNC/app/images/windows.svg +65 -0
- package/web-dist/noVNC/app/locale/README +1 -0
- package/web-dist/noVNC/app/locale/cs.json +71 -0
- package/web-dist/noVNC/app/locale/de.json +74 -0
- package/web-dist/noVNC/app/locale/el.json +100 -0
- package/web-dist/noVNC/app/locale/es.json +68 -0
- package/web-dist/noVNC/app/locale/fr.json +82 -0
- package/web-dist/noVNC/app/locale/hu.json +80 -0
- package/web-dist/noVNC/app/locale/it.json +68 -0
- package/web-dist/noVNC/app/locale/ja.json +81 -0
- package/web-dist/noVNC/app/locale/ko.json +70 -0
- package/web-dist/noVNC/app/locale/nl.json +95 -0
- package/web-dist/noVNC/app/locale/pl.json +80 -0
- package/web-dist/noVNC/app/locale/pt_BR.json +72 -0
- package/web-dist/noVNC/app/locale/ru.json +72 -0
- package/web-dist/noVNC/app/locale/sv.json +83 -0
- package/web-dist/noVNC/app/locale/tr.json +69 -0
- package/web-dist/noVNC/app/locale/uk.json +81 -0
- package/web-dist/noVNC/app/locale/zh_CN.json +93 -0
- package/web-dist/noVNC/app/locale/zh_TW.json +69 -0
- package/web-dist/noVNC/app/localization.js +206 -0
- package/web-dist/noVNC/app/sounds/CREDITS +4 -0
- package/web-dist/noVNC/app/sounds/bell.mp3 +0 -0
- package/web-dist/noVNC/app/sounds/bell.oga +0 -0
- package/web-dist/noVNC/app/styles/Orbitron700.ttf +0 -0
- package/web-dist/noVNC/app/styles/Orbitron700.woff +0 -0
- package/web-dist/noVNC/app/styles/base.css +927 -0
- package/web-dist/noVNC/app/styles/constants.css +30 -0
- package/web-dist/noVNC/app/styles/input.css +628 -0
- package/web-dist/noVNC/app/ui.js +1873 -0
- package/web-dist/noVNC/app/wakelock.js +199 -0
- package/web-dist/noVNC/app/webutil.js +250 -0
- package/web-dist/noVNC/core/base64.js +104 -0
- package/web-dist/noVNC/core/clipboard.js +72 -0
- package/web-dist/noVNC/core/crypto/aes.js +178 -0
- package/web-dist/noVNC/core/crypto/bigint.js +34 -0
- package/web-dist/noVNC/core/crypto/crypto.js +90 -0
- package/web-dist/noVNC/core/crypto/des.js +330 -0
- package/web-dist/noVNC/core/crypto/dh.js +55 -0
- package/web-dist/noVNC/core/crypto/md5.js +82 -0
- package/web-dist/noVNC/core/crypto/rsa.js +132 -0
- package/web-dist/noVNC/core/decoders/copyrect.js +27 -0
- package/web-dist/noVNC/core/decoders/h264.js +321 -0
- package/web-dist/noVNC/core/decoders/hextile.js +181 -0
- package/web-dist/noVNC/core/decoders/jpeg.js +161 -0
- package/web-dist/noVNC/core/decoders/raw.js +59 -0
- package/web-dist/noVNC/core/decoders/rre.js +44 -0
- package/web-dist/noVNC/core/decoders/tight.js +393 -0
- package/web-dist/noVNC/core/decoders/tightpng.js +27 -0
- package/web-dist/noVNC/core/decoders/zlib.js +51 -0
- package/web-dist/noVNC/core/decoders/zrle.js +185 -0
- package/web-dist/noVNC/core/deflator.js +84 -0
- package/web-dist/noVNC/core/display.js +578 -0
- package/web-dist/noVNC/core/encodings.js +54 -0
- package/web-dist/noVNC/core/inflator.js +65 -0
- package/web-dist/noVNC/core/input/domkeytable.js +311 -0
- package/web-dist/noVNC/core/input/fixedkeys.js +129 -0
- package/web-dist/noVNC/core/input/gesturehandler.js +567 -0
- package/web-dist/noVNC/core/input/keyboard.js +294 -0
- package/web-dist/noVNC/core/input/keysym.js +616 -0
- package/web-dist/noVNC/core/input/keysymdef.js +688 -0
- package/web-dist/noVNC/core/input/util.js +191 -0
- package/web-dist/noVNC/core/input/vkeys.js +116 -0
- package/web-dist/noVNC/core/input/xtscancodes.js +173 -0
- package/web-dist/noVNC/core/ra2.js +312 -0
- package/web-dist/noVNC/core/rfb.js +3426 -0
- package/web-dist/noVNC/core/util/browser.js +266 -0
- package/web-dist/noVNC/core/util/cursor.js +249 -0
- package/web-dist/noVNC/core/util/element.js +32 -0
- package/web-dist/noVNC/core/util/events.js +138 -0
- package/web-dist/noVNC/core/util/eventtarget.js +35 -0
- package/web-dist/noVNC/core/util/int.js +15 -0
- package/web-dist/noVNC/core/util/logging.js +56 -0
- package/web-dist/noVNC/core/util/strings.js +28 -0
- package/web-dist/noVNC/core/websock.js +369 -0
- package/web-dist/noVNC/defaults.json +1 -0
- package/web-dist/noVNC/mandatory.json +1 -0
- package/web-dist/noVNC/vendor/pako/LICENSE +21 -0
- package/web-dist/noVNC/vendor/pako/README.md +6 -0
- package/web-dist/noVNC/vendor/pako/lib/utils/common.js +45 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/adler32.js +27 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/constants.js +47 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/crc32.js +36 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/deflate.js +1846 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/gzheader.js +35 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/inffast.js +324 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/inflate.js +1527 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/inftrees.js +322 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/messages.js +11 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/trees.js +1195 -0
- package/web-dist/noVNC/vendor/pako/lib/zlib/zstream.js +24 -0
- package/web-dist/noVNC/vnc_lite.html +180 -0
- package/web-dist/assets/channel-DlBBaM6I.js +0 -1
- package/web-dist/assets/classDiagram-VBA2DB6C-DixDm16f.js +0 -1
- package/web-dist/assets/classDiagram-v2-RAHNMMFH-DixDm16f.js +0 -1
- package/web-dist/assets/clone-DEDCKaxV.js +0 -1
- package/web-dist/assets/stateDiagram-v2-FVOUBMTO-Bdpt0e9f.js +0 -1
|
@@ -0,0 +1,35 @@
|
|
|
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
|
+
export default class EventTargetMixin {
|
|
10
|
+
constructor() {
|
|
11
|
+
this._listeners = new Map();
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
addEventListener(type, callback) {
|
|
15
|
+
if (!this._listeners.has(type)) {
|
|
16
|
+
this._listeners.set(type, new Set());
|
|
17
|
+
}
|
|
18
|
+
this._listeners.get(type).add(callback);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
removeEventListener(type, callback) {
|
|
22
|
+
if (this._listeners.has(type)) {
|
|
23
|
+
this._listeners.get(type).delete(callback);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
dispatchEvent(event) {
|
|
28
|
+
if (!this._listeners.has(event.type)) {
|
|
29
|
+
return true;
|
|
30
|
+
}
|
|
31
|
+
this._listeners.get(event.type)
|
|
32
|
+
.forEach(callback => callback.call(this, event));
|
|
33
|
+
return !event.defaultPrevented;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
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
|
+
|
|
9
|
+
export function toUnsigned32bit(toConvert) {
|
|
10
|
+
return toConvert >>> 0;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export function toSigned32bit(toConvert) {
|
|
14
|
+
return toConvert | 0;
|
|
15
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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
|
+
/*
|
|
10
|
+
* Logging/debug routines
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
let _logLevel = 'warn';
|
|
14
|
+
|
|
15
|
+
let Debug = () => {};
|
|
16
|
+
let Info = () => {};
|
|
17
|
+
let Warn = () => {};
|
|
18
|
+
let Error = () => {};
|
|
19
|
+
|
|
20
|
+
export function initLogging(level) {
|
|
21
|
+
if (typeof level === 'undefined') {
|
|
22
|
+
level = _logLevel;
|
|
23
|
+
} else {
|
|
24
|
+
_logLevel = level;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
Debug = Info = Warn = Error = () => {};
|
|
28
|
+
|
|
29
|
+
if (typeof window.console !== "undefined") {
|
|
30
|
+
/* eslint-disable no-console, no-fallthrough */
|
|
31
|
+
switch (level) {
|
|
32
|
+
case 'debug':
|
|
33
|
+
Debug = console.debug.bind(window.console);
|
|
34
|
+
case 'info':
|
|
35
|
+
Info = console.info.bind(window.console);
|
|
36
|
+
case 'warn':
|
|
37
|
+
Warn = console.warn.bind(window.console);
|
|
38
|
+
case 'error':
|
|
39
|
+
Error = console.error.bind(window.console);
|
|
40
|
+
case 'none':
|
|
41
|
+
break;
|
|
42
|
+
default:
|
|
43
|
+
throw new window.Error("invalid logging type '" + level + "'");
|
|
44
|
+
}
|
|
45
|
+
/* eslint-enable no-console, no-fallthrough */
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
export function getLogging() {
|
|
50
|
+
return _logLevel;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export { Debug, Info, Warn, Error };
|
|
54
|
+
|
|
55
|
+
// Initialize logging level
|
|
56
|
+
initLogging();
|
|
@@ -0,0 +1,28 @@
|
|
|
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
|
+
// Decode from UTF-8
|
|
10
|
+
export function decodeUTF8(utf8string, allowLatin1=false) {
|
|
11
|
+
try {
|
|
12
|
+
return decodeURIComponent(escape(utf8string));
|
|
13
|
+
} catch (e) {
|
|
14
|
+
if (e instanceof URIError) {
|
|
15
|
+
if (allowLatin1) {
|
|
16
|
+
// If we allow Latin1 we can ignore any decoding fails
|
|
17
|
+
// and in these cases return the original string
|
|
18
|
+
return utf8string;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
throw e;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// Encode to UTF-8
|
|
26
|
+
export function encodeUTF8(DOMString) {
|
|
27
|
+
return unescape(encodeURIComponent(DOMString));
|
|
28
|
+
}
|
|
@@ -0,0 +1,369 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Websock: high-performance buffering wrapper
|
|
3
|
+
* Copyright (C) 2019 The noVNC authors
|
|
4
|
+
* Licensed under MPL 2.0 (see LICENSE.txt)
|
|
5
|
+
*
|
|
6
|
+
* Websock is similar to the standard WebSocket / RTCDataChannel object
|
|
7
|
+
* but with extra buffer handling.
|
|
8
|
+
*
|
|
9
|
+
* Websock has built-in receive queue buffering; the message event
|
|
10
|
+
* does not contain actual data but is simply a notification that
|
|
11
|
+
* there is new data available. Several rQ* methods are available to
|
|
12
|
+
* read binary data off of the receive queue.
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import * as Log from './util/logging.js';
|
|
16
|
+
|
|
17
|
+
// this has performance issues in some versions Chromium, and
|
|
18
|
+
// doesn't gain a tremendous amount of performance increase in Firefox
|
|
19
|
+
// at the moment. It may be valuable to turn it on in the future.
|
|
20
|
+
const MAX_RQ_GROW_SIZE = 40 * 1024 * 1024; // 40 MiB
|
|
21
|
+
|
|
22
|
+
// Constants pulled from RTCDataChannelState enum
|
|
23
|
+
// https://developer.mozilla.org/en-US/docs/Web/API/RTCDataChannel/readyState#RTCDataChannelState_enum
|
|
24
|
+
const DataChannel = {
|
|
25
|
+
CONNECTING: "connecting",
|
|
26
|
+
OPEN: "open",
|
|
27
|
+
CLOSING: "closing",
|
|
28
|
+
CLOSED: "closed"
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
const ReadyStates = {
|
|
32
|
+
CONNECTING: [WebSocket.CONNECTING, DataChannel.CONNECTING],
|
|
33
|
+
OPEN: [WebSocket.OPEN, DataChannel.OPEN],
|
|
34
|
+
CLOSING: [WebSocket.CLOSING, DataChannel.CLOSING],
|
|
35
|
+
CLOSED: [WebSocket.CLOSED, DataChannel.CLOSED],
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
// Properties a raw channel must have, WebSocket and RTCDataChannel are two examples
|
|
39
|
+
const rawChannelProps = [
|
|
40
|
+
"send",
|
|
41
|
+
"close",
|
|
42
|
+
"binaryType",
|
|
43
|
+
"onerror",
|
|
44
|
+
"onmessage",
|
|
45
|
+
"onopen",
|
|
46
|
+
"protocol",
|
|
47
|
+
"readyState",
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
export default class Websock {
|
|
51
|
+
constructor() {
|
|
52
|
+
this._websocket = null; // WebSocket or RTCDataChannel object
|
|
53
|
+
|
|
54
|
+
this._rQi = 0; // Receive queue index
|
|
55
|
+
this._rQlen = 0; // Next write position in the receive queue
|
|
56
|
+
this._rQbufferSize = 1024 * 1024 * 4; // Receive queue buffer size (4 MiB)
|
|
57
|
+
// called in init: this._rQ = new Uint8Array(this._rQbufferSize);
|
|
58
|
+
this._rQ = null; // Receive queue
|
|
59
|
+
|
|
60
|
+
this._sQbufferSize = 1024 * 10; // 10 KiB
|
|
61
|
+
// called in init: this._sQ = new Uint8Array(this._sQbufferSize);
|
|
62
|
+
this._sQlen = 0;
|
|
63
|
+
this._sQ = null; // Send queue
|
|
64
|
+
|
|
65
|
+
this._eventHandlers = {
|
|
66
|
+
message: () => {},
|
|
67
|
+
open: () => {},
|
|
68
|
+
close: () => {},
|
|
69
|
+
error: () => {}
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// Getters and setters
|
|
74
|
+
|
|
75
|
+
get readyState() {
|
|
76
|
+
let subState;
|
|
77
|
+
|
|
78
|
+
if (this._websocket === null) {
|
|
79
|
+
return "unused";
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
subState = this._websocket.readyState;
|
|
83
|
+
|
|
84
|
+
if (ReadyStates.CONNECTING.includes(subState)) {
|
|
85
|
+
return "connecting";
|
|
86
|
+
} else if (ReadyStates.OPEN.includes(subState)) {
|
|
87
|
+
return "open";
|
|
88
|
+
} else if (ReadyStates.CLOSING.includes(subState)) {
|
|
89
|
+
return "closing";
|
|
90
|
+
} else if (ReadyStates.CLOSED.includes(subState)) {
|
|
91
|
+
return "closed";
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
return "unknown";
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
// Receive queue
|
|
98
|
+
rQpeek8() {
|
|
99
|
+
return this._rQ[this._rQi];
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
rQskipBytes(bytes) {
|
|
103
|
+
this._rQi += bytes;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
rQshift8() {
|
|
107
|
+
return this._rQshift(1);
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
rQshift16() {
|
|
111
|
+
return this._rQshift(2);
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
rQshift32() {
|
|
115
|
+
return this._rQshift(4);
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
// TODO(directxman12): test performance with these vs a DataView
|
|
119
|
+
_rQshift(bytes) {
|
|
120
|
+
let res = 0;
|
|
121
|
+
for (let byte = bytes - 1; byte >= 0; byte--) {
|
|
122
|
+
res += this._rQ[this._rQi++] << (byte * 8);
|
|
123
|
+
}
|
|
124
|
+
return res >>> 0;
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
rQlen() {
|
|
128
|
+
return this._rQlen - this._rQi;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
rQshiftStr(len) {
|
|
132
|
+
let str = "";
|
|
133
|
+
// Handle large arrays in steps to avoid long strings on the stack
|
|
134
|
+
for (let i = 0; i < len; i += 4096) {
|
|
135
|
+
let part = this.rQshiftBytes(Math.min(4096, len - i), false);
|
|
136
|
+
str += String.fromCharCode.apply(null, part);
|
|
137
|
+
}
|
|
138
|
+
return str;
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
rQshiftBytes(len, copy=true) {
|
|
142
|
+
this._rQi += len;
|
|
143
|
+
if (copy) {
|
|
144
|
+
return this._rQ.slice(this._rQi - len, this._rQi);
|
|
145
|
+
} else {
|
|
146
|
+
return this._rQ.subarray(this._rQi - len, this._rQi);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
rQshiftTo(target, len) {
|
|
151
|
+
// TODO: make this just use set with views when using a ArrayBuffer to store the rQ
|
|
152
|
+
target.set(new Uint8Array(this._rQ.buffer, this._rQi, len));
|
|
153
|
+
this._rQi += len;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
rQpeekBytes(len, copy=true) {
|
|
157
|
+
if (copy) {
|
|
158
|
+
return this._rQ.slice(this._rQi, this._rQi + len);
|
|
159
|
+
} else {
|
|
160
|
+
return this._rQ.subarray(this._rQi, this._rQi + len);
|
|
161
|
+
}
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
// Check to see if we must wait for 'num' bytes (default to FBU.bytes)
|
|
165
|
+
// to be available in the receive queue. Return true if we need to
|
|
166
|
+
// wait (and possibly print a debug message), otherwise false.
|
|
167
|
+
rQwait(msg, num, goback) {
|
|
168
|
+
if (this._rQlen - this._rQi < num) {
|
|
169
|
+
if (goback) {
|
|
170
|
+
if (this._rQi < goback) {
|
|
171
|
+
throw new Error("rQwait cannot backup " + goback + " bytes");
|
|
172
|
+
}
|
|
173
|
+
this._rQi -= goback;
|
|
174
|
+
}
|
|
175
|
+
return true; // true means need more data
|
|
176
|
+
}
|
|
177
|
+
return false;
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
// Send queue
|
|
181
|
+
|
|
182
|
+
sQpush8(num) {
|
|
183
|
+
this._sQensureSpace(1);
|
|
184
|
+
this._sQ[this._sQlen++] = num;
|
|
185
|
+
}
|
|
186
|
+
|
|
187
|
+
sQpush16(num) {
|
|
188
|
+
this._sQensureSpace(2);
|
|
189
|
+
this._sQ[this._sQlen++] = (num >> 8) & 0xff;
|
|
190
|
+
this._sQ[this._sQlen++] = (num >> 0) & 0xff;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
sQpush32(num) {
|
|
194
|
+
this._sQensureSpace(4);
|
|
195
|
+
this._sQ[this._sQlen++] = (num >> 24) & 0xff;
|
|
196
|
+
this._sQ[this._sQlen++] = (num >> 16) & 0xff;
|
|
197
|
+
this._sQ[this._sQlen++] = (num >> 8) & 0xff;
|
|
198
|
+
this._sQ[this._sQlen++] = (num >> 0) & 0xff;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
sQpushString(str) {
|
|
202
|
+
let bytes = str.split('').map(chr => chr.charCodeAt(0));
|
|
203
|
+
this.sQpushBytes(new Uint8Array(bytes));
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
sQpushBytes(bytes) {
|
|
207
|
+
for (let offset = 0;offset < bytes.length;) {
|
|
208
|
+
this._sQensureSpace(1);
|
|
209
|
+
|
|
210
|
+
let chunkSize = this._sQbufferSize - this._sQlen;
|
|
211
|
+
if (chunkSize > bytes.length - offset) {
|
|
212
|
+
chunkSize = bytes.length - offset;
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
this._sQ.set(bytes.subarray(offset, offset + chunkSize), this._sQlen);
|
|
216
|
+
this._sQlen += chunkSize;
|
|
217
|
+
offset += chunkSize;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
flush() {
|
|
222
|
+
if (this._sQlen > 0 && this.readyState === 'open') {
|
|
223
|
+
this._websocket.send(new Uint8Array(this._sQ.buffer, 0, this._sQlen));
|
|
224
|
+
this._sQlen = 0;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
_sQensureSpace(bytes) {
|
|
229
|
+
if (this._sQbufferSize - this._sQlen < bytes) {
|
|
230
|
+
this.flush();
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
// Event handlers
|
|
235
|
+
off(evt) {
|
|
236
|
+
this._eventHandlers[evt] = () => {};
|
|
237
|
+
}
|
|
238
|
+
|
|
239
|
+
on(evt, handler) {
|
|
240
|
+
this._eventHandlers[evt] = handler;
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
_allocateBuffers() {
|
|
244
|
+
this._rQ = new Uint8Array(this._rQbufferSize);
|
|
245
|
+
this._sQ = new Uint8Array(this._sQbufferSize);
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
init() {
|
|
249
|
+
this._allocateBuffers();
|
|
250
|
+
this._rQi = 0;
|
|
251
|
+
this._websocket = null;
|
|
252
|
+
}
|
|
253
|
+
|
|
254
|
+
open(uri, protocols) {
|
|
255
|
+
this.attach(new WebSocket(uri, protocols));
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
attach(rawChannel) {
|
|
259
|
+
this.init();
|
|
260
|
+
|
|
261
|
+
// Must get object and class methods to be compatible with the tests.
|
|
262
|
+
const channelProps = [...Object.keys(rawChannel), ...Object.getOwnPropertyNames(Object.getPrototypeOf(rawChannel))];
|
|
263
|
+
for (let i = 0; i < rawChannelProps.length; i++) {
|
|
264
|
+
const prop = rawChannelProps[i];
|
|
265
|
+
if (channelProps.indexOf(prop) < 0) {
|
|
266
|
+
throw new Error('Raw channel missing property: ' + prop);
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
this._websocket = rawChannel;
|
|
271
|
+
this._websocket.binaryType = "arraybuffer";
|
|
272
|
+
this._websocket.onmessage = this._recvMessage.bind(this);
|
|
273
|
+
|
|
274
|
+
this._websocket.onopen = () => {
|
|
275
|
+
Log.Debug('>> WebSock.onopen');
|
|
276
|
+
if (this._websocket.protocol) {
|
|
277
|
+
Log.Info("Server choose sub-protocol: " + this._websocket.protocol);
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
this._eventHandlers.open();
|
|
281
|
+
Log.Debug("<< WebSock.onopen");
|
|
282
|
+
};
|
|
283
|
+
|
|
284
|
+
this._websocket.onclose = (e) => {
|
|
285
|
+
Log.Debug(">> WebSock.onclose");
|
|
286
|
+
this._eventHandlers.close(e);
|
|
287
|
+
Log.Debug("<< WebSock.onclose");
|
|
288
|
+
};
|
|
289
|
+
|
|
290
|
+
this._websocket.onerror = (e) => {
|
|
291
|
+
Log.Debug(">> WebSock.onerror: " + e);
|
|
292
|
+
this._eventHandlers.error(e);
|
|
293
|
+
Log.Debug("<< WebSock.onerror: " + e);
|
|
294
|
+
};
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
close() {
|
|
298
|
+
if (this._websocket) {
|
|
299
|
+
if (this.readyState === 'connecting' ||
|
|
300
|
+
this.readyState === 'open') {
|
|
301
|
+
Log.Info("Closing WebSocket connection");
|
|
302
|
+
this._websocket.close();
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
this._websocket.onmessage = () => {};
|
|
306
|
+
}
|
|
307
|
+
}
|
|
308
|
+
|
|
309
|
+
// private methods
|
|
310
|
+
|
|
311
|
+
// We want to move all the unread data to the start of the queue,
|
|
312
|
+
// e.g. compacting.
|
|
313
|
+
// The function also expands the receive que if needed, and for
|
|
314
|
+
// performance reasons we combine these two actions to avoid
|
|
315
|
+
// unnecessary copying.
|
|
316
|
+
_expandCompactRQ(minFit) {
|
|
317
|
+
// if we're using less than 1/8th of the buffer even with the incoming bytes, compact in place
|
|
318
|
+
// instead of resizing
|
|
319
|
+
const requiredBufferSize = (this._rQlen - this._rQi + minFit) * 8;
|
|
320
|
+
const resizeNeeded = this._rQbufferSize < requiredBufferSize;
|
|
321
|
+
|
|
322
|
+
if (resizeNeeded) {
|
|
323
|
+
// Make sure we always *at least* double the buffer size, and have at least space for 8x
|
|
324
|
+
// the current amount of data
|
|
325
|
+
this._rQbufferSize = Math.max(this._rQbufferSize * 2, requiredBufferSize);
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
// we don't want to grow unboundedly
|
|
329
|
+
if (this._rQbufferSize > MAX_RQ_GROW_SIZE) {
|
|
330
|
+
this._rQbufferSize = MAX_RQ_GROW_SIZE;
|
|
331
|
+
if (this._rQbufferSize - (this._rQlen - this._rQi) < minFit) {
|
|
332
|
+
throw new Error("Receive queue buffer exceeded " + MAX_RQ_GROW_SIZE + " bytes, and the new message could not fit");
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
if (resizeNeeded) {
|
|
337
|
+
const oldRQbuffer = this._rQ.buffer;
|
|
338
|
+
this._rQ = new Uint8Array(this._rQbufferSize);
|
|
339
|
+
this._rQ.set(new Uint8Array(oldRQbuffer, this._rQi, this._rQlen - this._rQi));
|
|
340
|
+
} else {
|
|
341
|
+
this._rQ.copyWithin(0, this._rQi, this._rQlen);
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
this._rQlen = this._rQlen - this._rQi;
|
|
345
|
+
this._rQi = 0;
|
|
346
|
+
}
|
|
347
|
+
|
|
348
|
+
// push arraybuffer values onto the end of the receive que
|
|
349
|
+
_recvMessage(e) {
|
|
350
|
+
if (this._rQlen == this._rQi) {
|
|
351
|
+
// All data has now been processed, this means we
|
|
352
|
+
// can reset the receive queue.
|
|
353
|
+
this._rQlen = 0;
|
|
354
|
+
this._rQi = 0;
|
|
355
|
+
}
|
|
356
|
+
const u8 = new Uint8Array(e.data);
|
|
357
|
+
if (u8.length > this._rQbufferSize - this._rQlen) {
|
|
358
|
+
this._expandCompactRQ(u8.length);
|
|
359
|
+
}
|
|
360
|
+
this._rQ.set(u8, this._rQlen);
|
|
361
|
+
this._rQlen += u8.length;
|
|
362
|
+
|
|
363
|
+
if (this._rQlen - this._rQi > 0) {
|
|
364
|
+
this._eventHandlers.message();
|
|
365
|
+
} else {
|
|
366
|
+
Log.Debug("Ignoring empty message");
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
(The MIT License)
|
|
2
|
+
|
|
3
|
+
Copyright (C) 2014-2016 by Vitaly Puzrin
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
This is an ES6-modules-compatible version of
|
|
2
|
+
https://github.com/nodeca/pako, based on pako version 1.0.3.
|
|
3
|
+
|
|
4
|
+
It's more-or-less a direct translation of the original, with unused parts
|
|
5
|
+
removed, and the dynamic support for non-typed arrays removed (since ES6
|
|
6
|
+
modules don't work well with dynamic exports).
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
// reduce buffer size, avoiding mem copy
|
|
2
|
+
export function shrinkBuf (buf, size) {
|
|
3
|
+
if (buf.length === size) { return buf; }
|
|
4
|
+
if (buf.subarray) { return buf.subarray(0, size); }
|
|
5
|
+
buf.length = size;
|
|
6
|
+
return buf;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
export function arraySet (dest, src, src_offs, len, dest_offs) {
|
|
11
|
+
if (src.subarray && dest.subarray) {
|
|
12
|
+
dest.set(src.subarray(src_offs, src_offs + len), dest_offs);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
// Fallback to ordinary array
|
|
16
|
+
for (var i = 0; i < len; i++) {
|
|
17
|
+
dest[dest_offs + i] = src[src_offs + i];
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Join array of chunks to single array.
|
|
22
|
+
export function flattenChunks (chunks) {
|
|
23
|
+
var i, l, len, pos, chunk, result;
|
|
24
|
+
|
|
25
|
+
// calculate data length
|
|
26
|
+
len = 0;
|
|
27
|
+
for (i = 0, l = chunks.length; i < l; i++) {
|
|
28
|
+
len += chunks[i].length;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// join chunks
|
|
32
|
+
result = new Uint8Array(len);
|
|
33
|
+
pos = 0;
|
|
34
|
+
for (i = 0, l = chunks.length; i < l; i++) {
|
|
35
|
+
chunk = chunks[i];
|
|
36
|
+
result.set(chunk, pos);
|
|
37
|
+
pos += chunk.length;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
return result;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export var Buf8 = Uint8Array;
|
|
44
|
+
export var Buf16 = Uint16Array;
|
|
45
|
+
export var Buf32 = Int32Array;
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
// Note: adler32 takes 12% for level 0 and 2% for level 6.
|
|
2
|
+
// It doesn't worth to make additional optimizationa as in original.
|
|
3
|
+
// Small size is preferable.
|
|
4
|
+
|
|
5
|
+
export default function adler32(adler, buf, len, pos) {
|
|
6
|
+
var s1 = (adler & 0xffff) |0,
|
|
7
|
+
s2 = ((adler >>> 16) & 0xffff) |0,
|
|
8
|
+
n = 0;
|
|
9
|
+
|
|
10
|
+
while (len !== 0) {
|
|
11
|
+
// Set limit ~ twice less than 5552, to keep
|
|
12
|
+
// s2 in 31-bits, because we force signed ints.
|
|
13
|
+
// in other case %= will fail.
|
|
14
|
+
n = len > 2000 ? 2000 : len;
|
|
15
|
+
len -= n;
|
|
16
|
+
|
|
17
|
+
do {
|
|
18
|
+
s1 = (s1 + buf[pos++]) |0;
|
|
19
|
+
s2 = (s2 + s1) |0;
|
|
20
|
+
} while (--n);
|
|
21
|
+
|
|
22
|
+
s1 %= 65521;
|
|
23
|
+
s2 %= 65521;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
return (s1 | (s2 << 16)) |0;
|
|
27
|
+
}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
export default {
|
|
2
|
+
|
|
3
|
+
/* Allowed flush values; see deflate() and inflate() below for details */
|
|
4
|
+
Z_NO_FLUSH: 0,
|
|
5
|
+
Z_PARTIAL_FLUSH: 1,
|
|
6
|
+
Z_SYNC_FLUSH: 2,
|
|
7
|
+
Z_FULL_FLUSH: 3,
|
|
8
|
+
Z_FINISH: 4,
|
|
9
|
+
Z_BLOCK: 5,
|
|
10
|
+
Z_TREES: 6,
|
|
11
|
+
|
|
12
|
+
/* Return codes for the compression/decompression functions. Negative values
|
|
13
|
+
* are errors, positive values are used for special but normal events.
|
|
14
|
+
*/
|
|
15
|
+
Z_OK: 0,
|
|
16
|
+
Z_STREAM_END: 1,
|
|
17
|
+
Z_NEED_DICT: 2,
|
|
18
|
+
Z_ERRNO: -1,
|
|
19
|
+
Z_STREAM_ERROR: -2,
|
|
20
|
+
Z_DATA_ERROR: -3,
|
|
21
|
+
//Z_MEM_ERROR: -4,
|
|
22
|
+
Z_BUF_ERROR: -5,
|
|
23
|
+
//Z_VERSION_ERROR: -6,
|
|
24
|
+
|
|
25
|
+
/* compression levels */
|
|
26
|
+
Z_NO_COMPRESSION: 0,
|
|
27
|
+
Z_BEST_SPEED: 1,
|
|
28
|
+
Z_BEST_COMPRESSION: 9,
|
|
29
|
+
Z_DEFAULT_COMPRESSION: -1,
|
|
30
|
+
|
|
31
|
+
|
|
32
|
+
Z_FILTERED: 1,
|
|
33
|
+
Z_HUFFMAN_ONLY: 2,
|
|
34
|
+
Z_RLE: 3,
|
|
35
|
+
Z_FIXED: 4,
|
|
36
|
+
Z_DEFAULT_STRATEGY: 0,
|
|
37
|
+
|
|
38
|
+
/* Possible values of the data_type field (though see inflate()) */
|
|
39
|
+
Z_BINARY: 0,
|
|
40
|
+
Z_TEXT: 1,
|
|
41
|
+
//Z_ASCII: 1, // = Z_TEXT (deprecated)
|
|
42
|
+
Z_UNKNOWN: 2,
|
|
43
|
+
|
|
44
|
+
/* The deflate compression method */
|
|
45
|
+
Z_DEFLATED: 8
|
|
46
|
+
//Z_NULL: null // Use -1 or null inline, depending on var type
|
|
47
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
// Note: we can't get significant speed boost here.
|
|
2
|
+
// So write code to minimize size - no pregenerated tables
|
|
3
|
+
// and array tools dependencies.
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
// Use ordinary array, since untyped makes no boost here
|
|
7
|
+
export default function makeTable() {
|
|
8
|
+
var c, table = [];
|
|
9
|
+
|
|
10
|
+
for (var n = 0; n < 256; n++) {
|
|
11
|
+
c = n;
|
|
12
|
+
for (var k = 0; k < 8; k++) {
|
|
13
|
+
c = ((c & 1) ? (0xEDB88320 ^ (c >>> 1)) : (c >>> 1));
|
|
14
|
+
}
|
|
15
|
+
table[n] = c;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
return table;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
// Create table on load. Just 255 signed longs. Not a problem.
|
|
22
|
+
var crcTable = makeTable();
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
function crc32(crc, buf, len, pos) {
|
|
26
|
+
var t = crcTable,
|
|
27
|
+
end = pos + len;
|
|
28
|
+
|
|
29
|
+
crc ^= -1;
|
|
30
|
+
|
|
31
|
+
for (var i = pos; i < end; i++) {
|
|
32
|
+
crc = (crc >>> 8) ^ t[(crc ^ buf[i]) & 0xFF];
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
return (crc ^ (-1)); // >>> 0;
|
|
36
|
+
}
|