From 921441191694c82f9a474d46defdc3db81d56c2b Mon Sep 17 00:00:00 2001 From: dgflash Date: Thu, 14 Aug 2025 14:41:49 +0800 Subject: [PATCH] =?UTF-8?q?1.=E4=BC=98=E5=8C=96MVVM=E6=A1=86=E6=9E=B6?= =?UTF-8?q?=E4=BB=A3=E7=A0=81=202.MVVM=E7=BB=84=E4=BB=B6=E6=94=AF=E6=8C=81?= =?UTF-8?q?=E8=84=9A=E6=9C=AC=E7=BB=91=E5=AE=9A=E6=95=B0=E6=8D=AE=203.VMLa?= =?UTF-8?q?bel=E7=BB=84=E4=BB=B6=E6=94=AF=E6=8C=81=E6=97=B6=E9=97=B4?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/libs/extension/DateExt.ts | 15 +- assets/libs/model-view/StringFormat.ts | 74 +- assets/libs/model-view/VMCompsEdit.ts | 26 +- assets/libs/model-view/VMCustom.ts | 3 +- assets/libs/model-view/VMEnv.ts | 3 +- assets/libs/model-view/VMEvent.ts | 6 +- assets/libs/model-view/VMLabel.ts | 2 +- assets/libs/model-view/VMModify.ts | 2 +- assets/libs/model-view/VMParent.ts | 6 +- assets/libs/model-view/VMProgress.ts | 2 +- assets/libs/model-view/VMState.ts | 2 +- assets/libs/model-view/ViewModel.ts | 9 +- assets/libs/model-view/ui/BhvRollNumber.ts | 4 +- assets/libs/model-view/ui/BhvSwitchPage.ts | 14 +- assets/libs/network.meta | 9 + assets/libs/network/.network.md | 3 + assets/libs/network/HttpRequest.ts | 317 ++ assets/libs/network/HttpRequest.ts.meta | 9 + assets/libs/network/NetInterface.ts | 92 + assets/libs/network/NetInterface.ts.meta | 11 + assets/libs/network/NetManager.ts | 148 + assets/libs/network/NetManager.ts.meta | 11 + assets/libs/network/NetNode.ts | 491 +++ assets/libs/network/NetNode.ts.meta | 11 + assets/libs/network/NetProtocolPako.ts | 69 + assets/libs/network/NetProtocolPako.ts.meta | 9 + assets/libs/network/WebSock.ts | 84 + assets/libs/network/WebSock.ts.meta | 11 + assets/libs/network/protocol.meta | 12 + assets/libs/network/protocol/pako.min.js | 3424 +++++++++++++++++ assets/libs/network/protocol/pako.min.js.meta | 17 + 31 files changed, 4818 insertions(+), 78 deletions(-) create mode 100644 assets/libs/network.meta create mode 100644 assets/libs/network/.network.md create mode 100644 assets/libs/network/HttpRequest.ts create mode 100644 assets/libs/network/HttpRequest.ts.meta create mode 100644 assets/libs/network/NetInterface.ts create mode 100644 assets/libs/network/NetInterface.ts.meta create mode 100644 assets/libs/network/NetManager.ts create mode 100644 assets/libs/network/NetManager.ts.meta create mode 100644 assets/libs/network/NetNode.ts create mode 100644 assets/libs/network/NetNode.ts.meta create mode 100644 assets/libs/network/NetProtocolPako.ts create mode 100644 assets/libs/network/NetProtocolPako.ts.meta create mode 100644 assets/libs/network/WebSock.ts create mode 100644 assets/libs/network/WebSock.ts.meta create mode 100644 assets/libs/network/protocol.meta create mode 100644 assets/libs/network/protocol/pako.min.js create mode 100644 assets/libs/network/protocol/pako.min.js.meta diff --git a/assets/libs/extension/DateExt.ts b/assets/libs/extension/DateExt.ts index 466ba7c..4120fec 100644 --- a/assets/libs/extension/DateExt.ts +++ b/assets/libs/extension/DateExt.ts @@ -12,14 +12,27 @@ Date.prototype.format = function (format: string): string { const hours: number = this.getHours(); const minutes: number = this.getMinutes(); const seconds: number = this.getSeconds(); + const milliseconds: number = this.getMilliseconds(); - return format + let r = format .replace('yy', year.toString()) .replace('mm', (month < 10 ? '0' : '') + month) .replace('dd', (day < 10 ? '0' : '') + day) .replace('hh', (hours < 10 ? '0' : '') + hours) .replace('mm', (minutes < 10 ? '0' : '') + minutes) .replace('ss', (seconds < 10 ? '0' : '') + seconds); + + if (milliseconds < 10) { + r = r.replace('ms', '00' + milliseconds); + } + else if (milliseconds < 100) { + r = r.replace('ms', '0' + milliseconds); + } + else { + r = r.replace('ms', milliseconds.toString()); + } + + return r; }; export { }; diff --git a/assets/libs/model-view/StringFormat.ts b/assets/libs/model-view/StringFormat.ts index aa31c5a..4e99922 100644 --- a/assets/libs/model-view/StringFormat.ts +++ b/assets/libs/model-view/StringFormat.ts @@ -1,8 +1,6 @@ -/** - * 数值格式化函数, 通过语义解析自动设置值的范围 - * //整数 - * 1:def(0)//显示一个默认值 - */ +import { oops } from "../../core/Oops"; + +/** 数值格式化函数, 通过语义解析自动设置值的范围 */ class StringFormat { deal(value: number | string, format: string): string { if (format === '') return value as string; @@ -21,58 +19,58 @@ class StringFormat { switch (func) { case 'int': res = this.int(value); break; case 'fix': res = this.fix(value, num); break; - case 'kmbt': res = this.KMBT(value); break; + case 'kmbt': res = this.kmbt(value); break; case 'per': res = this.per(value, num); break; case 'sep': res = this.sep(value); break; - default: - break; - } + case 'tstamp': res = this.time_stamp(value); break; + case 'tm': res = this.time_m(value); break; + case 'ts': res = this.time_s(value); break; + case 'tms': res = this.time_ms(value); break; + default: break; + } } else { switch (func) { case 'limit': res = this.limit(value, num); break; - - default: - break; + default: res = value; break; } - res = value; } return res as string; } - // 将数字按分号显示 + /** 将数字按分号显示 */ private sep(value: number) { let num = Math.round(value).toString(); return num.replace(new RegExp('(\\d)(?=(\\d{3})+$)', 'ig'), "$1,"); } - // 将数字按分显示 00:00 显示 (ms制) + /** 将数字按分显示 00:00 显示 (时:分) */ private time_m(value: number) { - //todo + return new Date(value).format('hh:ss'); } - // 将数字按秒显示 00:00:00 显示 (ms制) + /** 将数字按秒显示 00:00:00 显示 (时:分:秒) */ private time_s(value: number) { - //todo + return new Date(value).format('hh:mm:ss'); } - // 将数字按 0:00:00:000 显示 (ms制) + /** 将数字按 0:00:00:000 显示 (时:分:秒:毫秒) */ private time_ms(value: number) { - //todo + return new Date(value).format('hh:mm:ss:ms'); } - // 将时间戳显示为详细的内容 - private timeStamp(value: number) { - //todo - return new Date(value).toString() + /** 将时间戳显示为详细的内容 */ + private time_stamp(value: number) { + return new Date(value).format('yy-mm-dd hh:mm:ss'); } /** [value:int] 将取值0~1 变成 1~100,可以指定修饰的小数位数 */ private per(value: number, fd: number) { - return Math.round(value * 100).toFixed(fd); + let r = value * 100; + return r.toFixed(fd); } /** [value:int] 将取值变成整数 */ @@ -80,7 +78,7 @@ class StringFormat { return Math.round(value); } - /** [value:fix2]数值转换为小数*/ + /** [value:fix2]数值转换为小数 */ private fix(value: number, fd: number) { return value.toFixed(fd) } @@ -91,18 +89,21 @@ class StringFormat { } /** 将数字缩短显示为KMBT单位 大写,目前只支持英文 */ - private KMBT(value: number, lang: string = 'en') { + private kmbt(value: number) { //10^4=万, 10^8=亿,10^12=兆,10^16=京, - let counts = [1000, 1000000, 1000000000, 1000000000000]; - let units = ['', 'K', 'M', 'B', 'T']; + let counts: number[] = null!; + let units: string[] = null!; - switch (lang) { + switch (oops.language.current) { case 'zh': //10^4=万, 10^8=亿,10^12=兆,10^16=京, - let counts = [10000, 100000000, 1000000000000, 10000000000000000]; - let units = ['', '万', '亿', '兆', '京']; + counts = [10000, 100000000, 1000000000000, 10000000000000000]; + units = ['', '万', '亿', '兆', '京']; + break; + case 'en': + counts = [1000, 1000000, 1000000000, 1000000000000]; + units = ['', 'K', 'M', 'B', 'T']; break; - default: break; } @@ -110,12 +111,12 @@ class StringFormat { return this.compressUnit(value, counts, units, 2); } - //压缩任意单位的数字,后缀加上单位文字 + /** 压缩任意单位的数字,后缀加上单位文字 */ private compressUnit(value: any, valueArr: number[], unitArr: string[], fixNum: number = 2): string { let counts = valueArr; let units = unitArr; let res: string = ""; - let index; + let index: number; for (index = 0; index < counts.length; index++) { const e = counts[index]; if (value < e) { @@ -127,11 +128,10 @@ class StringFormat { } break; } - } return res + units[index]; } } -/**格式化处理函数 */ +/** 格式化处理函数 */ export let StringFormatFunction = new StringFormat(); \ No newline at end of file diff --git a/assets/libs/model-view/VMCompsEdit.ts b/assets/libs/model-view/VMCompsEdit.ts index fa7e786..d8c6228 100644 --- a/assets/libs/model-view/VMCompsEdit.ts +++ b/assets/libs/model-view/VMCompsEdit.ts @@ -1,4 +1,4 @@ -import { CCString, Component, Enum, log, Node, _decorator } from "cc"; +import { _decorator, CCString, Component, Enum, log, Node } from "cc"; import { VMEnv } from "./VMEnv"; const { ccclass, property, executeInEditMode, menu, help } = _decorator; @@ -36,10 +36,10 @@ export default class MVCompsEdit extends Component { return this.actionType === ACTION_MODE.SEARCH_COMPONENT; } }) - public get findTrigger() { + get findTrigger() { return false; } - public set findTrigger(v: boolean) { + set findTrigger(v: boolean) { this.setComponents(0); } @@ -50,10 +50,10 @@ export default class MVCompsEdit extends Component { return this.actionType === ACTION_MODE.ENABLE_COMPONENT; } }) - public get enableTrigger() { + get enableTrigger() { return false; } - public set enableTrigger(v: boolean) { + set enableTrigger(v: boolean) { this.setComponents(1); } @@ -64,10 +64,10 @@ export default class MVCompsEdit extends Component { return this.actionType === ACTION_MODE.ENABLE_COMPONENT; } }) - public get disableTrigger() { + get disableTrigger() { return false; } - public set disableTrigger(v: boolean) { + set disableTrigger(v: boolean) { this.setComponents(2); } @@ -88,10 +88,10 @@ export default class MVCompsEdit extends Component { return this.allowDelete && this.actionType === ACTION_MODE.DELETE_COMPONENT; } }) - public get deleteTrigger() { + get deleteTrigger() { return false; } - public set deleteTrigger(v: boolean) { + set deleteTrigger(v: boolean) { this.setComponents(3); } @@ -102,10 +102,10 @@ export default class MVCompsEdit extends Component { return this.actionType === ACTION_MODE.REPLACE_WATCH_PATH; } }) - public get replaceTrigger() { + get replaceTrigger() { return false; } - public set replaceTrigger(v: boolean) { + set replaceTrigger(v: boolean) { this.setComponents(4); } @@ -269,7 +269,7 @@ export default class MVCompsEdit extends Component { getNodePath(node: Node) { let parent = node; - let array = []; + let array: string[] = []; while (parent) { let p = parent.getParent(); if (p) { @@ -282,4 +282,4 @@ export default class MVCompsEdit extends Component { } return array.reverse().join('/'); } -} +} \ No newline at end of file diff --git a/assets/libs/model-view/VMCustom.ts b/assets/libs/model-view/VMCustom.ts index 47ba4bf..5db4230 100644 --- a/assets/libs/model-view/VMCustom.ts +++ b/assets/libs/model-view/VMCustom.ts @@ -18,7 +18,6 @@ const COMP_ARRAY_CHECK = [ ['cc.Toggle', 'isChecked', true] ]; - /** * [VM-Custom] * 自定义数值监听, 可以快速对该节点上任意一个组件上的属性进行双向绑定 @@ -170,4 +169,4 @@ export class VMCustom extends VMBase { this._oldValue = this.getComponentValue(); this.onValueController(newValue, oldValue); } -} +} \ No newline at end of file diff --git a/assets/libs/model-view/VMEnv.ts b/assets/libs/model-view/VMEnv.ts index addb3e8..0992efb 100644 --- a/assets/libs/model-view/VMEnv.ts +++ b/assets/libs/model-view/VMEnv.ts @@ -4,7 +4,6 @@ import { EDITOR } from "cc/env"; export class VMEnv { /** 编辑状态 */ static get editor() { - // @ts-ignore - return EDITOR && !cc.GAME_VIEW; + return EDITOR; } } \ No newline at end of file diff --git a/assets/libs/model-view/VMEvent.ts b/assets/libs/model-view/VMEvent.ts index dbdd1dd..4086d80 100644 --- a/assets/libs/model-view/VMEvent.ts +++ b/assets/libs/model-view/VMEvent.ts @@ -35,7 +35,7 @@ export default class VMEvent extends VMBase { @property({ tooltip: '使用模板模式,可以使用多路径监听' }) - public templateMode: boolean = false; + templateMode: boolean = false; @property({ tooltip: '监听获取值的路径', @@ -65,7 +65,7 @@ export default class VMEvent extends VMBase { tooltip: '过滤模式,会根据条件过滤掉时间的触发', type: Enum(FILTER_MODE) }) - public filterMode: FILTER_MODE = FILTER_MODE.none; + filterMode: FILTER_MODE = FILTER_MODE.none; @property({ visible: function () { @@ -73,7 +73,7 @@ export default class VMEvent extends VMBase { return this.filterMode !== FILTER_MODE.none } }) - public compareValue: string = ''; + compareValue: string = ''; @property([EventHandler]) changeEvents: EventHandler[] = []; diff --git a/assets/libs/model-view/VMLabel.ts b/assets/libs/model-view/VMLabel.ts index b5c89f8..6b4da4e 100644 --- a/assets/libs/model-view/VMLabel.ts +++ b/assets/libs/model-view/VMLabel.ts @@ -186,4 +186,4 @@ export default class VMLabel extends VMBase { return false; } -} +} \ No newline at end of file diff --git a/assets/libs/model-view/VMModify.ts b/assets/libs/model-view/VMModify.ts index 44305ac..cd07d42 100644 --- a/assets/libs/model-view/VMModify.ts +++ b/assets/libs/model-view/VMModify.ts @@ -146,4 +146,4 @@ export default class VMModify extends VMBase { if (int) { a = Math.round(a) } this.VM.setValue(this.watchPath, this.clampValue(a)); } -} +} \ No newline at end of file diff --git a/assets/libs/model-view/VMParent.ts b/assets/libs/model-view/VMParent.ts index a120605..f176b49 100644 --- a/assets/libs/model-view/VMParent.ts +++ b/assets/libs/model-view/VMParent.ts @@ -36,6 +36,8 @@ export default class VMParent extends GameComponent { */ onLoad() { if (this.data == null) return; + this.onBind(); + this.tag = '_temp' + '<' + this.node.uuid.replace('.', '') + '>'; VM.add(this.data, this.tag); // log(VM['_mvs'],this.tag) @@ -47,8 +49,6 @@ export default class VMParent extends GameComponent { this.replaceVMPath(comp, this.tag) } // console.groupEnd() - - this.onBind(); } /**在 onLoad 完成 和 start() 之前调用,你可以在这里进行初始化数据等操作 */ @@ -119,4 +119,4 @@ export default class VMParent extends GameComponent { super.onDestroy(); } -} +} \ No newline at end of file diff --git a/assets/libs/model-view/VMProgress.ts b/assets/libs/model-view/VMProgress.ts index abfe514..d41a043 100644 --- a/assets/libs/model-view/VMProgress.ts +++ b/assets/libs/model-view/VMProgress.ts @@ -95,4 +95,4 @@ export default class VMProgress extends VMCustom { this.setComponentValue(value); } -} +} \ No newline at end of file diff --git a/assets/libs/model-view/VMState.ts b/assets/libs/model-view/VMState.ts index 76bcf04..057a329 100644 --- a/assets/libs/model-view/VMState.ts +++ b/assets/libs/model-view/VMState.ts @@ -295,4 +295,4 @@ export default class VMState extends VMBase { return false; } -} +} \ No newline at end of file diff --git a/assets/libs/model-view/ViewModel.ts b/assets/libs/model-view/ViewModel.ts index c92759f..1d1af9c 100644 --- a/assets/libs/model-view/ViewModel.ts +++ b/assets/libs/model-view/ViewModel.ts @@ -34,7 +34,7 @@ function getValueFromPath(obj: any, path: string, def?: any, tag: string | null /** * ModelViewer 类 */ -class ViewModel{ +class ViewModel { constructor(data: T, tag: string) { new JsonOb(data, this._callback.bind(this)); this.$data = data; @@ -149,6 +149,9 @@ class VMManager { */ getValue(path: string, def?: any): any { path = path.trim(); // 防止空格,自动剔除 + + if (path === '') return ''; + let rs = path.split('.'); if (rs.length < 2) { console.error('Get Value Cant find path:' + path); return; }; let vm = this.get(rs[0]); @@ -215,10 +218,8 @@ class VMManager { } } -// 整数、小数、时间、缩写 - /** * VM管理对象,使用文档: - * https://github.com/wsssheep/cocos_creator_mvvm_tools/blob/master/docs/ViewModelScript.md + * https://gitee.com/dgflash/oops-framework/wikis/pages?sort_id=12037849&doc_id=2873565 */ export let VM = new VMManager(); \ No newline at end of file diff --git a/assets/libs/model-view/ui/BhvRollNumber.ts b/assets/libs/model-view/ui/BhvRollNumber.ts index 9b33aeb..e39da04 100644 --- a/assets/libs/model-view/ui/BhvRollNumber.ts +++ b/assets/libs/model-view/ui/BhvRollNumber.ts @@ -45,10 +45,10 @@ export class BhvRollNumber extends Component { @property({ tooltip: '滚动的目标值' }) - public get targetValue(): number { + get targetValue(): number { return this._targetValue; } - public set targetValue(v: number) { + set targetValue(v: number) { this._targetValue = v; this.scroll();//数据变动了就开始滚动 } diff --git a/assets/libs/model-view/ui/BhvSwitchPage.ts b/assets/libs/model-view/ui/BhvSwitchPage.ts index ae58d21..244b31d 100644 --- a/assets/libs/model-view/ui/BhvSwitchPage.ts +++ b/assets/libs/model-view/ui/BhvSwitchPage.ts @@ -13,13 +13,13 @@ export class BhvSwitchPage extends Component { @property private _index: number = 0; - public get index(): number { + get index(): number { return this._index; } @property({ type: CCInteger }) - public set index(v: number) { + set index(v: number) { if (this.isChanging) return; v = Math.round(v); let count = this.node.children.length - 1; @@ -49,7 +49,7 @@ export class BhvSwitchPage extends Component { private _isChanging: boolean = false; /**只读,是否在changing 的状态 */ - public get isChanging(): boolean { + get isChanging(): boolean { return this._isChanging; } @@ -85,7 +85,7 @@ export class BhvSwitchPage extends Component { showNode.active = true; } - public next(): boolean { + next(): boolean { if (this.isChanging) { return false; } @@ -95,7 +95,7 @@ export class BhvSwitchPage extends Component { } } - public previous(): boolean { + previous(): boolean { if (this.isChanging) { return false; } @@ -105,7 +105,7 @@ export class BhvSwitchPage extends Component { } } - public setEventIndex(e: any, index: any): boolean { + setEventIndex(e: any, index: any): boolean { if (this.index >= 0 && this.index != null && this.isChanging === false) { this.index = index; return true; @@ -114,4 +114,4 @@ export class BhvSwitchPage extends Component { return false; } } -} +} \ No newline at end of file diff --git a/assets/libs/network.meta b/assets/libs/network.meta new file mode 100644 index 0000000..bafd121 --- /dev/null +++ b/assets/libs/network.meta @@ -0,0 +1,9 @@ +{ + "ver": "1.2.0", + "importer": "directory", + "imported": true, + "uuid": "c378c808-8d92-4f96-9eb6-a122b5f1716f", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/libs/network/.network.md b/assets/libs/network/.network.md new file mode 100644 index 0000000..8ff44c7 --- /dev/null +++ b/assets/libs/network/.network.md @@ -0,0 +1,3 @@ +游戏网络库 +1. Http +2. WebSocket \ No newline at end of file diff --git a/assets/libs/network/HttpRequest.ts b/assets/libs/network/HttpRequest.ts new file mode 100644 index 0000000..3a62b60 --- /dev/null +++ b/assets/libs/network/HttpRequest.ts @@ -0,0 +1,317 @@ +/* + * @Author: dgflash + * @Date: 2022-09-01 18:00:28 + * @LastEditors: dgflash + * @LastEditTime: 2022-09-09 18:10:50 + */ +import { error, warn } from "cc"; + +/** + * 使用流程文档可参考、简化与服务器对接、使用新版API体验,可进入下面地址获取新版本,替换network目录中的内容 + * https://store.cocos.com/app/detail/5877 + */ + +/** 当前请求地址集合 */ +var urls: any = {}; +/** 请求参数 */ +var reqparams: any = {}; + +type HttpCallback = (ret: HttpReturn) => void; + +/** 请求事件 */ +export enum HttpEvent { + /** 断网 */ + NO_NETWORK = "http_request_no_network", + /** 未知错误 */ + UNKNOWN_ERROR = "http_request_unknown_error", + /** 请求超时 */ + TIMEOUT = "http_request_timout" +} + +/** + * HTTP请求返回值 + */ +export class HttpReturn { + /** 是否请求成功 */ + isSucc: boolean = false; + /** 请求返回数据 */ + res?: any; + /** 请求错误数据 */ + err?: any; +} + +/** HTTP请求 */ +export class HttpRequest { + /** 服务器地址 */ + server: string = "http://127.0.0.1/"; + /** 请求超时时间 */ + timeout: number = 10000; + /** 自定义请求头信息 */ + private header: Map = new Map(); + + /** + * 添加自定义请求头信息 + * @param name 信息名 + * @param value 信息值 + */ + addHeader(name: string, value: string) { + this.header.set(name, value); + } + + /** + * HTTP GET请求 + * @param name 协议名 + * @param onComplete 请求完整回调方法 + * @param params 查询参数 + * @example + var param = '{"uid":12345}' + var complete = (ret: HttpReturn) => { + console.log(ret.res); + } + oops.http.getWithParams(name, complete, param); + */ + get(name: string, onComplete: HttpCallback, params: any = null) { + this.sendRequest(name, params, false, onComplete) + } + + /** + * HTTP GET请求 + * @param name 协议名 + * @param params 查询参数 + * @example + var txt = await oops.http.getAsync(name); + if (txt.isSucc) { + console.log(txt.res); + } + */ + getAsync(name: string, params: any = null): Promise { + return new Promise((resolve, reject) => { + this.sendRequest(name, params, false, (ret: HttpReturn) => { + resolve(ret); + }) + }); + } + + /** + * HTTP GET请求非文本格式数据 + * @param name 协议名 + * @param onComplete 请求完整回调方法 + * @param params 查询参数 + */ + getByArraybuffer(name: string, onComplete: HttpCallback, params: any = null) { + this.sendRequest(name, params, false, onComplete, 'arraybuffer', false); + } + + /** + * HTTP GET请求非文本格式数据 + * @param name 协议名 + * @param params 查询参数 + * @returns Promise + */ + getAsyncByArraybuffer(name: string, params: any = null): Promise { + return new Promise((resolve, reject) => { + this.sendRequest(name, params, false, (ret: HttpReturn) => { + resolve(ret); + }, 'arraybuffer', false); + }); + } + + /** + * HTTP POST请求 + * @param name 协议名 + * @param params 查询参数 + * @param onComplete 请求完整回调方法 + * @example + var param = '{"LoginCode":"donggang_dev","Password":"e10adc3949ba59abbe56e057f20f883e"}' + var complete = (ret: HttpReturn) => { + console.log(ret.res); + } + oops.http.post(name, complete, param); + */ + post(name: string, onComplete: HttpCallback, params: any = null) { + this.sendRequest(name, params, true, onComplete); + } + + /** + * HTTP POST请求 + * @param name 协议名 + * @param params 查询参数 + */ + postAsync(name: string, params: any = null): Promise { + return new Promise((resolve, reject) => { + this.sendRequest(name, params, true, (ret: HttpReturn) => { + resolve(ret); + }); + }); + } + + /** + * 取消请求中的请求 + * @param name 协议名 + */ + abort(name: string) { + var xhr = urls[this.server + name]; + if (xhr) { + xhr.abort(); + } + } + + /** + * 获得字符串形式的参数 + * @param params 参数对象 + * @returns 参数字符串 + */ + private getParamString(params: any) { + var result = ""; + for (var name in params) { + let data = params[name]; + if (data instanceof Object) { + for (var key in data) + result += `${key}=${data[key]}&`; + } + else { + result += `${name}=${data}&`; + } + } + return result.substring(0, result.length - 1); + } + + /** + * Http请求 + * @param name(string) 请求地址 + * @param params(JSON) 请求参数 + * @param isPost(boolen) 是否为POST方式 + * @param callback(function) 请求成功回调 + * @param responseType(string) 响应类型 + * @param isOpenTimeout(boolean) 是否触发请求超时错误 + */ + private sendRequest(name: string, + params: any, + isPost: boolean, + onComplete: HttpCallback, + responseType?: string, + isOpenTimeout: boolean = true) { + if (name == null || name == '') { + error("请求地址不能为空"); + return; + } + + var url: string, newUrl: string, paramsStr: string = ""; + if (name.toLocaleLowerCase().indexOf("http") == 0) { + url = name; + } + else { + url = this.server + name; + } + + if (params) { + paramsStr = this.getParamString(params); + if (url.indexOf("?") > -1) + newUrl = url + "&" + paramsStr; + else + newUrl = url + "?" + paramsStr; + } + else { + newUrl = url; + } + + if (urls[newUrl] != null && reqparams[newUrl] == paramsStr) { + warn(`地址【${url}】已正在请求中,不能重复请求`); + return; + } + + var xhr = new XMLHttpRequest(); + + // 防重复请求功能 + urls[newUrl] = xhr; + reqparams[newUrl] = paramsStr; + + if (isPost) { + xhr.open("POST", url); + } + else { + xhr.open("GET", newUrl); + } + + // 添加自定义请求头信息 + for (const [key, value] of this.header) { + xhr.setRequestHeader(key, value); + } + // xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8"); + // xhr.setRequestHeader("Content-Type", "application/json; charset=utf-8"); + + var data: any = {}; + data.url = url; + data.params = params; + + // 请求超时 + if (isOpenTimeout) { + xhr.timeout = this.timeout; + xhr.ontimeout = () => { + this.deleteCache(newUrl); + + ret.isSucc = false; + ret.err = HttpEvent.TIMEOUT; // 超时 + onComplete(data); + } + } + + // 响应结果 + var ret: HttpReturn = new HttpReturn(); + + xhr.onloadend = () => { + if (xhr.status == 500) { + this.deleteCache(newUrl); + + ret.isSucc = false; + ret.err = HttpEvent.NO_NETWORK; // 断网 + onComplete(ret); + } + } + + xhr.onerror = () => { + this.deleteCache(newUrl); + + ret.isSucc = false; + if (xhr.readyState == 0 || xhr.readyState == 1 || xhr.status == 0) { + ret.err = HttpEvent.NO_NETWORK; // 断网 + } + else { + ret.err = HttpEvent.UNKNOWN_ERROR; // 未知错误 + } + + onComplete(ret); + }; + + xhr.onreadystatechange = () => { + if (xhr.readyState != 4) return; + + this.deleteCache(newUrl); + + if (xhr.status == 200 && onComplete) { + ret.isSucc = true; + if (responseType == 'arraybuffer') { + xhr.responseType = responseType; // 加载非文本格式 + ret.res = xhr.response; + } + else { + ret.res = JSON.parse(xhr.response); + } + onComplete(ret); + } + }; + + // 发送请求 + if (params == null || params == "") { + xhr.send(); + } + else { + xhr.send(paramsStr); + } + } + + private deleteCache(url: string) { + delete urls[url]; + delete reqparams[url]; + } +} \ No newline at end of file diff --git a/assets/libs/network/HttpRequest.ts.meta b/assets/libs/network/HttpRequest.ts.meta new file mode 100644 index 0000000..dc4c2e3 --- /dev/null +++ b/assets/libs/network/HttpRequest.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "806e5b7c-51eb-45cb-8b29-9fcf5d9ee6a7", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/libs/network/NetInterface.ts b/assets/libs/network/NetInterface.ts new file mode 100644 index 0000000..4bf7608 --- /dev/null +++ b/assets/libs/network/NetInterface.ts @@ -0,0 +1,92 @@ +/* + * @Author: dgflash + * @Date: 2022-09-01 18:00:28 + * @LastEditors: dgflash + * @LastEditTime: 2022-09-09 18:31:18 + */ + +/* + * 网络相关接口定义 + */ +export type NetData = (string | ArrayBufferLike | Blob | ArrayBufferView); +export type NetCallFunc = (data: any) => void; + +/** 请求协议 */ +export interface IRequestProtocol { + /** 协议命令编号 */ + cmd: string, + /** 回调方法名 */ + callback?: string, + /** 是否压缩 */ + isCompress: boolean, + /** 渠道编号 */ + channelid: number, + /** 消息内容 */ + data?: any; +} + +/** 响应协议 */ +export interface IResponseProtocol { + /** 响应协议状态码 */ + code: number, + /** 数据是否压缩 */ + isCompress: boolean, + /** 协议数据 */ + data?: any, + /** 协议回调方法名 */ + callback?: string +} + +/** 回调对象 */ +export interface CallbackObject { + target: any, // 回调对象,不为null时调用target.callback(xxx) + callback: NetCallFunc, // 回调函数 +} + +/** 请求对象 */ +export interface RequestObject { + buffer: NetData, // 请求的Buffer + rspCmd: string, // 等待响应指令 + rspObject: CallbackObject | null, // 等待响应的回调对象 +} + +/** 协议辅助接口 */ +export interface IProtocolHelper { + /** 返回包头长度 */ + getHeadlen(): number; + /** 返回一个心跳包 */ + getHearbeat(): NetData; + /** 返回整个包的长度 */ + getPackageLen(msg: NetData): number; + /** 检查包数据是否合法(避免客户端报错崩溃) */ + checkResponsePackage(msg: IResponseProtocol): boolean; + /** 处理请求包数据 */ + handlerRequestPackage(reqProtocol: IRequestProtocol): string; + /** 处理响应包数据 */ + handlerResponsePackage(respProtocol: IResponseProtocol): boolean; + /** 返回包的id或协议类型 */ + getPackageId(msg: IResponseProtocol): string; +} + +export type SocketFunc = (event: any) => void; +export type MessageFunc = (msg: NetData) => void; + +/** Socket接口 */ +export interface ISocket { + onConnected: SocketFunc | null; // 连接回调 + onMessage: MessageFunc | null; // 消息回调 + onError: SocketFunc | null; // 错误回调 + onClosed: SocketFunc | null; // 关闭回调 + + connect(options: any): any; // 连接接口 + send(buffer: NetData): number; // 数据发送接口 + close(code?: number, reason?: string): void; // 关闭接口 +} + +/** 网络提示接口 */ +export interface INetworkTips { + connectTips(isShow: boolean): void; + reconnectTips(isShow: boolean): void; + requestTips(isShow: boolean): void; + responseErrorCode(code: number): void; +} \ No newline at end of file diff --git a/assets/libs/network/NetInterface.ts.meta b/assets/libs/network/NetInterface.ts.meta new file mode 100644 index 0000000..42f5745 --- /dev/null +++ b/assets/libs/network/NetInterface.ts.meta @@ -0,0 +1,11 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "d9f8bf82-57af-45c8-ac27-51d0a33ad69d", + "files": [], + "subMetas": {}, + "userData": { + "simulateGlobals": [] + } +} diff --git a/assets/libs/network/NetManager.ts b/assets/libs/network/NetManager.ts new file mode 100644 index 0000000..b88ca88 --- /dev/null +++ b/assets/libs/network/NetManager.ts @@ -0,0 +1,148 @@ +/* + * @Author: dgflash + * @Date: 2022-09-01 18:00:28 + * @LastEditors: dgflash + * @LastEditTime: 2022-09-09 18:10:50 + */ +import { CallbackObject, IRequestProtocol, NetData } from "./NetInterface"; +import { NetConnectOptions, NetNode } from "./NetNode"; + +/** + * 使用流程文档可参考、简化与服务器对接、使用新版API体验,可进入下面地址获取新版本,替换network目录中的内容 + * https://store.cocos.com/app/detail/5877 + */ + +/* + * 网络节点管理类 + */ +export class NetManager { + private static _instance: NetManager; + protected _channels: { [key: number]: NetNode } = {}; + + /** 网络管理单例对象 */ + static getInstance(): NetManager { + if (!this._instance) { + this._instance = new NetManager(); + } + return this._instance; + } + + /** + * 添加网络节点 + * @param node 网络节点 + * @param channelId 通道编号 + * @example + // 游戏服务器心跳协议 + class GameProtocol extends NetProtocolPako { + // 自定义心跳协议 + getHearbeat(): NetData { + return '{"action":"LoginAction","method":"heart","data":"null","callback":"LoginAction_heart"}'; + } + } + + var net = new NetNodeGame(); + var ws = new WebSock(); // WebSocket 网络连接对象 + var gp = new GameProtocol(); // 网络通讯协议对象 + var gt = new NetGameTips() // 网络提示对象 + net.init(ws, gp, gt); + NetManager.getInstance().setNetNode(net, NetChannelType.Game); + */ + setNetNode(node: NetNode, channelId: number = 0) { + this._channels[channelId] = node; + } + + /** 移除Node */ + removeNetNode(channelId: number) { + delete this._channels[channelId]; + } + + /** + * 网络节点连接服务器 + * @param options 连接参数 + * @param channelId 通道编号 + * @example + var options = { + url: 'ws://127.0.0.1:3000', + autoReconnect: 0 // -1 永久重连,0不自动重连,其他正整数为自动重试次数 + } + NetManager.getInstance().connect(options, NetChannelType.Game); + */ + connect(options: NetConnectOptions, channelId: number = 0): boolean { + if (this._channels[channelId]) { + return this._channels[channelId].connect(options); + } + return false; + } + + /** 节点连接发送数据*/ + send(buf: NetData, force: boolean = false, channelId: number = 0): number { + let node = this._channels[channelId]; + if (node) { + return node!.send(buf, force); + } + return -1; + } + + /** + * 发起请求,并在在结果返回时调用指定好的回调函数 + * @param reqProtocol 请求协议 + * @param rspObject 回调对象 + * @param showTips 是否触发请求提示 + * @param force 是否强制发送 + * @param channelId 通道编号 + * @example + let protocol: IRequestProtocol = { + action: action, + method: method, + data: JSON.stringify(data), + isCompress: this.isCompress, + channelid: netConfig.channelid + } + return this.request(protocol, rspObject, showTips, force); + */ + request(reqProtocol: IRequestProtocol, rspObject: CallbackObject, showTips: boolean = true, force: boolean = false, channelId: number = 0) { + let node = this._channels[channelId]; + if (node) { + node.request(reqProtocol, rspObject, showTips, force); + } + } + + /** + * 同request功能一致,但在request之前会先判断队列中是否已有rspCmd,如有重复的则直接返回 + * @param reqProtocol 请求协议 + * @param rspObject 回调对象 + * @param showTips 是否触发请求提示 + * @param force 是否强制发送 + * @param channelId 通道编号 + * @example + let protocol: IRequestProtocol = { + action: action, + method: method, + data: JSON.stringify(data), + isCompress: this.isCompress, + channelid: netConfig.channelid + } + return this.request(protocol, rspObject, showTips, force); + */ + requestUnique(reqProtocol: IRequestProtocol, rspObject: CallbackObject, showTips: boolean = true, force: boolean = false, channelId: number = 0): boolean { + let node = this._channels[channelId]; + if (node) { + return node.requestUnique(reqProtocol, rspObject, showTips, force); + } + return false; + } + + /** + * 节点网络断开 + * @param code 关闭码 + * @param reason 关闭原因 + * @param channelId 通道编号 + * @example + * NetManager.getInstance().close(undefined, undefined, NetChannelType.Game); + */ + close(code?: number, reason?: string, channelId: number = 0) { + if (this._channels[channelId]) { + return this._channels[channelId].closeSocket(code, reason); + } + } +} \ No newline at end of file diff --git a/assets/libs/network/NetManager.ts.meta b/assets/libs/network/NetManager.ts.meta new file mode 100644 index 0000000..aa09a64 --- /dev/null +++ b/assets/libs/network/NetManager.ts.meta @@ -0,0 +1,11 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "d8cd57a5-e860-464d-84d6-f8df1bf04b89", + "files": [], + "subMetas": {}, + "userData": { + "simulateGlobals": [] + } +} diff --git a/assets/libs/network/NetNode.ts b/assets/libs/network/NetNode.ts new file mode 100644 index 0000000..76862cf --- /dev/null +++ b/assets/libs/network/NetNode.ts @@ -0,0 +1,491 @@ +import { error, warn } from "cc"; +import { Logger } from "../../core/common/log/Logger"; +import { CallbackObject, INetworkTips, IProtocolHelper, IRequestProtocol, ISocket, NetCallFunc, NetData, RequestObject } from "./NetInterface"; + +/* +* CocosCreator网络节点基类,以及网络相关接口定义 +* 1. 网络连接、断开、请求发送、数据接收等基础功能 +* 2. 心跳机制 +* 3. 断线重连 + 请求重发 +* 4. 调用网络屏蔽层 +*/ + +type ExecuterFunc = (callback: CallbackObject, buffer: NetData) => void; +type CheckFunc = (checkedFunc: VoidFunc) => void; +type VoidFunc = () => void; +type BoolFunc = () => boolean; + +var NetNodeStateStrs = ["已关闭", "连接中", "验证中", "可传输数据"]; + +/** 网络提示类型枚举 */ +export enum NetTipsType { + Connecting, + ReConnecting, + Requesting, +} + +/** 网络状态枚举 */ +export enum NetNodeState { + Closed, // 已关闭 + Connecting, // 连接中 + Checking, // 验证中 + Working, // 可传输数据 +} + +/** 网络连接参数 */ +export interface NetConnectOptions { + host?: string, // 地址 + port?: number, // 端口 + url?: string, // url,与地址+端口二选一 + autoReconnect?: number, // -1 永久重连,0不自动重连,其他正整数为自动重试次数 +} + +/** 网络节点 */ +export class NetNode { + protected _connectOptions: NetConnectOptions | null = null; + protected _autoReconnect: number = 0; + protected _isSocketInit: boolean = false; // Socket是否初始化过 + protected _isSocketOpen: boolean = false; // Socket是否连接成功过 + protected _state: NetNodeState = NetNodeState.Closed; // 节点当前状态 + protected _socket: ISocket | null = null; // Socket对象(可能是原生socket、websocket、wx.socket...) + + protected _networkTips: INetworkTips | null = null; // 网络提示ui对象(请求提示、断线重连提示等) + protected _protocolHelper: IProtocolHelper | null = null; // 包解析对象 + protected _connectedCallback: CheckFunc | null = null; // 连接完成回调 + protected _disconnectCallback: BoolFunc | null = null; // 断线回调 + protected _callbackExecuter: ExecuterFunc | null = null; // 回调执行 + + protected _keepAliveTimer: any = null; // 心跳定时器 + protected _receiveMsgTimer: any = null; // 接收数据定时器 + protected _reconnectTimer: any = null; // 重连定时器 + protected _heartTime: number = 10000; // 心跳间隔 + protected _receiveTime: number = 6000000; // 多久没收到数据断开 + protected _reconnetTimeOut: number = 8000000; // 重连间隔 + protected _requests: RequestObject[] = Array(); // 请求列表 + protected _listener: { [key: string]: CallbackObject[] | null } = {} // 监听者列表 + + /********************** 网络相关处理 *********************/ + init(socket: ISocket, protocol: IProtocolHelper, networkTips: INetworkTips | null = null, execFunc: ExecuterFunc | null = null) { + Logger.instance.logNet(`网络初始化`); + this._socket = socket; + this._protocolHelper = protocol; + this._networkTips = networkTips; + this._callbackExecuter = execFunc ? execFunc : (callback: CallbackObject, buffer: NetData) => { + callback.callback.call(callback.target, buffer); + } + } + + /** + * 请求连接服务器 + * @param options 连接参数 + */ + connect(options: NetConnectOptions): boolean { + if (this._socket && this._state == NetNodeState.Closed) { + if (!this._isSocketInit) { + this.initSocket(); + } + this._state = NetNodeState.Connecting; + if (!this._socket.connect(options)) { + this.updateNetTips(NetTipsType.Connecting, false); + return false; + } + if (this._connectOptions == null && typeof options.autoReconnect == "number") { + this._autoReconnect = options.autoReconnect; + } + this._connectOptions = options; + this.updateNetTips(NetTipsType.Connecting, true); + return true; + } + return false; + } + + protected initSocket() { + if (this._socket) { + this._socket.onConnected = (event) => { this.onConnected(event) }; + this._socket.onMessage = (msg) => { this.onMessage(msg) }; + this._socket.onError = (event) => { this.onError(event) }; + this._socket.onClosed = (event) => { this.onClosed(event) }; + this._isSocketInit = true; + } + } + + protected updateNetTips(tipsType: NetTipsType, isShow: boolean) { + if (this._networkTips) { + if (tipsType == NetTipsType.Requesting) { + this._networkTips.requestTips(isShow); + } + else if (tipsType == NetTipsType.Connecting) { + this._networkTips.connectTips(isShow); + } + else if (tipsType == NetTipsType.ReConnecting) { + this._networkTips.reconnectTips(isShow); + } + } + } + + /** 网络连接成功 */ + protected onConnected(event: any) { + Logger.instance.logNet("网络已连接") + this._isSocketOpen = true; + // 如果设置了鉴权回调,在连接完成后进入鉴权阶段,等待鉴权结束 + if (this._connectedCallback !== null) { + this._state = NetNodeState.Checking; + this._connectedCallback(() => { this.onChecked() }); + } + else { + this.onChecked(); + } + Logger.instance.logNet(`网络已连接当前状态为【${NetNodeStateStrs[this._state]}】`); + } + + /** 连接验证成功,进入工作状态 */ + protected onChecked() { + Logger.instance.logNet("连接验证成功,进入工作状态"); + this._state = NetNodeState.Working; + // 关闭连接或重连中的状态显示 + this.updateNetTips(NetTipsType.Connecting, false); + this.updateNetTips(NetTipsType.ReConnecting, false); + + // 重发待发送信息 + var requests = this._requests.concat(); + if (requests.length > 0) { + Logger.instance.logNet(`请求【${this._requests.length}】个待发送的信息`); + + for (var i = 0; i < requests.length;) { + let req = requests[i]; + this._socket!.send(req.buffer); + if (req.rspObject == null || req.rspCmd != "") { + requests.splice(i, 1); + } + else { + ++i; + } + } + // 如果还有等待返回的请求,启动网络请求层 + this.updateNetTips(NetTipsType.Requesting, this._requests.length > 0); + } + } + + /** 接收到一个完整的消息包 */ + protected onMessage(msg: any): void { + // Logger.logNet(`接受消息状态为【${NetNodeStateStrs[this._state]}】`); + + var json = JSON.parse(msg); + + // 进行头部的校验(实际包长与头部长度是否匹配) + if (!this._protocolHelper!.checkResponsePackage(json)) { + error(`校验接受消息数据异常`); + return; + } + + // 处理相应包数据 + if (!this._protocolHelper!.handlerResponsePackage(json)) { + if (this._networkTips) + this._networkTips.responseErrorCode(json.code); + } + + // 接受到数据,重新定时收数据计时器 + this.resetReceiveMsgTimer(); + // 重置心跳包发送器 + this.resetHearbeatTimer(); + // 触发消息执行 + let rspCmd = this._protocolHelper!.getPackageId(json); + + Logger.instance.logNet(`接受到命令【${rspCmd}】的消息`); + // 优先触发request队列 + if (this._requests.length > 0) { + for (let reqIdx in this._requests) { + let req = this._requests[reqIdx]; + if (req.rspCmd == rspCmd && req.rspObject) { + Logger.instance.logNet(`触发请求命令【${rspCmd}】的回调`); + this._callbackExecuter!(req.rspObject, json.data); + this._requests.splice(parseInt(reqIdx), 1); + break; + } + } + + if (this._requests.length == 0) { + this.updateNetTips(NetTipsType.Requesting, false); + } + else { + Logger.instance.logNet(`请求队列中还有【${this._requests.length}】个请求在等待`); + } + } + + let listeners = this._listener[rspCmd]; + if (null != listeners) { + for (const rsp of listeners) { + Logger.instance.logNet(`触发监听命令【${rspCmd}】的回调`); + this._callbackExecuter!(rsp, json.data); + } + } + } + + protected onError(event: any) { + error(event); + } + + protected onClosed(event: any) { + this.clearTimer(); + + // 执行断线回调,返回false表示不进行重连 + if (this._disconnectCallback && !this._disconnectCallback()) { + Logger.instance.logNet(`断开连接`); + return; + } + + // 自动重连 + if (this.isAutoReconnect()) { + this.updateNetTips(NetTipsType.ReConnecting, true); + this._reconnectTimer = setTimeout(() => { + this._socket!.close(); + this._state = NetNodeState.Closed; + this.connect(this._connectOptions!); + if (this._autoReconnect > 0) { + this._autoReconnect -= 1; + } + }, this._reconnetTimeOut); + } + else { + this._state = NetNodeState.Closed; + } + } + + /** + * 断开网络 + * @param code 关闭码 + * @param reason 关闭原因 + */ + close(code?: number, reason?: string) { + this.clearTimer(); + this._listener = {}; + this._requests.length = 0; + if (this._networkTips) { + this._networkTips.connectTips(false); + this._networkTips.reconnectTips(false); + this._networkTips.requestTips(false); + } + if (this._socket) { + this._socket.close(code, reason); + } + else { + this._state = NetNodeState.Closed; + } + } + + /** + * 只是关闭Socket套接字(仍然重用缓存与当前状态) + * @param code 关闭码 + * @param reason 关闭原因 + */ + closeSocket(code?: number, reason?: string) { + if (this._socket) { + this._socket.close(code, reason); + } + } + + /** + * 发起请求,如果当前处于重连中,进入缓存列表等待重连完成后发送 + * @param buf 网络数据 + * @param force 是否强制发送 + */ + send(buf: NetData, force: boolean = false): number { + if (this._state == NetNodeState.Working || force) { + return this._socket!.send(buf); + } + else if (this._state == NetNodeState.Checking || + this._state == NetNodeState.Connecting) { + this._requests.push({ + buffer: buf, + rspCmd: "", + rspObject: null + }); + Logger.instance.logNet(`当前状态为【${NetNodeStateStrs[this._state]}】,繁忙并缓冲发送数据`); + return 0; + } + else { + error(`当前状态为【${NetNodeStateStrs[this._state]}】,请求错误`); + return -1; + } + } + + /** + * 发起请求,并进入缓存列表 + * @param reqProtocol 请求协议 + * @param rspObject 回调对象 + * @param showTips 是否触发请求提示 + * @param force 是否强制发送 + */ + request(reqProtocol: IRequestProtocol, rspObject: CallbackObject, showTips: boolean = true, force: boolean = false) { + var rspCmd = this._protocolHelper!.handlerRequestPackage(reqProtocol); + this.base_request(reqProtocol, rspCmd, rspObject, showTips, force); + } + + /** + * 唯一request,确保没有同一响应的请求(避免一个请求重复发送,netTips界面的屏蔽也是一个好的方法) + * @param reqProtocol 请求协议 + * @param rspObject 回调对象 + * @param showTips 是否触发请求提示 + * @param force 是否强制发送 + */ + requestUnique(reqProtocol: IRequestProtocol, rspObject: CallbackObject, showTips: boolean = true, force: boolean = false): boolean { + var rspCmd = this._protocolHelper!.handlerRequestPackage(reqProtocol); + + for (let i = 0; i < this._requests.length; ++i) { + if (this._requests[i].rspCmd == rspCmd) { + Logger.instance.logNet(`命令【${rspCmd}】重复请求`); + return false; + } + } + + this.base_request(reqProtocol, rspCmd, rspObject, showTips, force); + return true; + } + + private base_request(reqProtocol: IRequestProtocol, rspCmd: string, rspObject: CallbackObject, showTips: boolean = true, force: boolean = false) { + var buf: NetData = JSON.stringify(reqProtocol); // 转为二进制流发送 + + if (this._state == NetNodeState.Working || force) { + this._socket!.send(buf); + } + + Logger.instance.logNet(`队列命令为【${rspCmd}】的请求,等待请求数据的回调`); + + // 进入发送缓存列表 + this._requests.push({ + buffer: buf, rspCmd, rspObject + }); + // 启动网络请求层 + if (showTips) { + this.updateNetTips(NetTipsType.Requesting, true); + } + } + + /********************** 回调相关处理 *********************/ + /** + * 设置一个唯一的服务器推送监听 + * @param cmd 命令字串 + * @param callback 回调方法 + * @param target 目标对象 + */ + setResponeHandler(cmd: string, callback: NetCallFunc, target?: any): boolean { + if (callback == null) { + error(`命令为【${cmd}】设置响应处理程序错误`); + return false; + } + this._listener[cmd] = [{ target, callback }]; + return true; + } + + /** + * 可添加多个同类返回消息的监听 + * @param cmd 命令字串 + * @param callback 回调方法 + * @param target 目标对象 + * @returns + */ + addResponeHandler(cmd: string, callback: NetCallFunc, target?: any): boolean { + if (callback == null) { + error(`命令为【${cmd}】添加响应处理程序错误`); + return false; + } + let rspObject = { target, callback }; + if (null == this._listener[cmd]) { + this._listener[cmd] = [rspObject]; + } + else { + let index = this.getNetListenersIndex(cmd, rspObject); + if (-1 == index) { + this._listener[cmd]!.push(rspObject); + } + } + return true; + } + + /** + * 删除一个监听中指定子回调 + * @param cmd 命令字串 + * @param callback 回调方法 + * @param target 目标对象 + */ + removeResponeHandler(cmd: string, callback: NetCallFunc, target?: any) { + if (null != this._listener[cmd] && callback != null) { + let index = this.getNetListenersIndex(cmd, { target, callback }); + if (-1 != index) { + this._listener[cmd]!.splice(index, 1); + } + } + } + + /** + * 清除所有监听或指定命令的监听 + * @param cmd 命令字串(默认不填为清除所有) + */ + cleanListeners(cmd: string = "") { + if (cmd == "") { + this._listener = {} + } + else { + delete this._listener[cmd]; + } + } + + protected getNetListenersIndex(cmd: string, rspObject: CallbackObject): number { + let index = -1; + for (let i = 0; i < this._listener[cmd]!.length; i++) { + let iterator = this._listener[cmd]![i]; + if (iterator.callback == rspObject.callback + && iterator.target == rspObject.target) { + index = i; + break; + } + } + return index; + } + + /********************** 心跳、超时相关处理 *********************/ + protected resetReceiveMsgTimer() { + if (this._receiveMsgTimer !== null) { + clearTimeout(this._receiveMsgTimer); + } + + this._receiveMsgTimer = setTimeout(() => { + warn("接收消息定时器关闭网络连接"); + this._socket!.close(); + }, this._receiveTime); + } + + protected resetHearbeatTimer() { + if (this._keepAliveTimer !== null) { + clearTimeout(this._keepAliveTimer); + } + + this._keepAliveTimer = setTimeout(() => { + Logger.instance.logNet("网络节点保持活跃发送心跳信息"); + this.send(this._protocolHelper!.getHearbeat()); + }, this._heartTime); + } + + protected clearTimer() { + if (this._receiveMsgTimer !== null) { + clearTimeout(this._receiveMsgTimer); + } + if (this._keepAliveTimer !== null) { + clearTimeout(this._keepAliveTimer); + } + if (this._reconnectTimer !== null) { + clearTimeout(this._reconnectTimer); + } + } + + /** 是否自动重连接 */ + isAutoReconnect() { + return this._autoReconnect != 0; + } + + /** 拒绝重新连接 */ + rejectReconnect() { + this._autoReconnect = 0; + this.clearTimer(); + } +} \ No newline at end of file diff --git a/assets/libs/network/NetNode.ts.meta b/assets/libs/network/NetNode.ts.meta new file mode 100644 index 0000000..5127f31 --- /dev/null +++ b/assets/libs/network/NetNode.ts.meta @@ -0,0 +1,11 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "57f0f07d-d243-4150-9f7c-cb2bbe8f18f1", + "files": [], + "subMetas": {}, + "userData": { + "simulateGlobals": [] + } +} diff --git a/assets/libs/network/NetProtocolPako.ts b/assets/libs/network/NetProtocolPako.ts new file mode 100644 index 0000000..3637b8a --- /dev/null +++ b/assets/libs/network/NetProtocolPako.ts @@ -0,0 +1,69 @@ +/* + * @Author: dgflash + * @Date: 2022-04-21 13:45:51 + * @LastEditors: dgflash + * @LastEditTime: 2022-04-21 13:51:33 + */ +import { IProtocolHelper, IRequestProtocol, IResponseProtocol, NetData } from "./NetInterface"; + +var unzip = function (str: string) { + let charData = str.split('').map(function (x) { + return x.charCodeAt(0); + }); + let binData = new Uint8Array(charData); + //@ts-ignore + let data = pako.inflate(binData, { to: 'string' }); + return data; +} + +var zip = function (str: string) { + //@ts-ignore + let binaryString = pako.gzip(str, { to: 'string' }); + return binaryString; +} + +/** Pako.js 数据压缩协议 */ +export class NetProtocolPako implements IProtocolHelper { + getHeadlen(): number { + return 0; + } + + getHearbeat(): NetData { + return ""; + } + + getPackageLen(msg: NetData): number { + return msg.toString().length; + } + + checkResponsePackage(respProtocol: IResponseProtocol): boolean { + return true; + } + + handlerResponsePackage(respProtocol: IResponseProtocol): boolean { + if (respProtocol.code == 1) { + if (respProtocol.isCompress) { + respProtocol.data = unzip(respProtocol.data); + } + respProtocol.data = JSON.parse(respProtocol.data); + + return true; + } + else { + return false; + } + } + + handlerRequestPackage(reqProtocol: IRequestProtocol): string { + var rspCmd = reqProtocol.cmd; + reqProtocol.callback = rspCmd; + if (reqProtocol.isCompress) { + reqProtocol.data = zip(reqProtocol.data); + } + return rspCmd; + } + + getPackageId(respProtocol: IResponseProtocol): string { + return respProtocol.callback!; + } +} \ No newline at end of file diff --git a/assets/libs/network/NetProtocolPako.ts.meta b/assets/libs/network/NetProtocolPako.ts.meta new file mode 100644 index 0000000..f35e285 --- /dev/null +++ b/assets/libs/network/NetProtocolPako.ts.meta @@ -0,0 +1,9 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "88ae0948-8390-4559-bd4e-d44f3f12dc22", + "files": [], + "subMetas": {}, + "userData": {} +} diff --git a/assets/libs/network/WebSock.ts b/assets/libs/network/WebSock.ts new file mode 100644 index 0000000..1ceaca9 --- /dev/null +++ b/assets/libs/network/WebSock.ts @@ -0,0 +1,84 @@ +/* + * @Author: dgflash + * @Date: 2021-07-03 16:13:17 + * @LastEditors: dgflash + * @LastEditTime: 2022-09-09 17:42:19 + */ +import { Logger } from "../../core/common/log/Logger"; +import { ISocket, MessageFunc, NetData } from "./NetInterface"; + +type Connected = (event: any) => void; + +/** + * WebSocket 封装 + * 1. 连接/断开相关接口 + * 2. 网络异常回调 + * 3. 数据发送与接收 + */ +export class WebSock implements ISocket { + private _ws: WebSocket | null = null; // websocket对象 + + /** 网络连接成功事件 */ + onConnected: ((this: WebSocket, ev: Event) => any) | null = null; + /** 接受到网络数据事件 */ + onMessage: MessageFunc | null = null; + /** 网络错误事件 */ + onError: ((this: WebSocket, ev: Event) => any) | null = null; + /** 网络断开事件 */ + onClosed: ((this: WebSocket, ev: CloseEvent) => any) | null = null; + + /** 请求连接 */ + connect(options: any) { + if (this._ws) { + if (this._ws.readyState === WebSocket.CONNECTING) { + Logger.logNet("websocket connecting, wait for a moment...") + return false; + } + } + + let url = null; + if (options.url) { + url = options.url; + } + else { + let ip = options.ip; + let port = options.port; + let protocol = options.protocol; + url = `${protocol}://${ip}:${port}`; + } + + this._ws = new WebSocket(url); + this._ws.binaryType = options.binaryType ? options.binaryType : "arraybuffer"; + this._ws.onmessage = (event) => { + let onMessage: MessageFunc = this.onMessage!; + onMessage(event.data); + }; + this._ws.onopen = this.onConnected; + this._ws.onerror = this.onError; + this._ws.onclose = this.onClosed; + return true; + } + + /** + * 发送数据 + * @param buffer 网络数据 + */ + send(buffer: NetData): number { + if (this._ws && this._ws.readyState == WebSocket.OPEN) { + this._ws.send(buffer); + return 1; + } + return -1; + } + + /** + * 网络断开 + * @param code 关闭码 + * @param reason 关闭原因 + */ + close(code?: number, reason?: string) { + if (this._ws) { + this._ws.close(code, reason); + } + } +} \ No newline at end of file diff --git a/assets/libs/network/WebSock.ts.meta b/assets/libs/network/WebSock.ts.meta new file mode 100644 index 0000000..711d773 --- /dev/null +++ b/assets/libs/network/WebSock.ts.meta @@ -0,0 +1,11 @@ +{ + "ver": "4.0.24", + "importer": "typescript", + "imported": true, + "uuid": "70df255b-214f-41eb-a16b-fa8a7c14a269", + "files": [], + "subMetas": {}, + "userData": { + "simulateGlobals": [] + } +} diff --git a/assets/libs/network/protocol.meta b/assets/libs/network/protocol.meta new file mode 100644 index 0000000..0d5da65 --- /dev/null +++ b/assets/libs/network/protocol.meta @@ -0,0 +1,12 @@ +{ + "ver": "1.2.0", + "importer": "directory", + "imported": true, + "uuid": "922e2501-4a6b-4f54-852c-28e24c3fc5b8", + "files": [], + "subMetas": {}, + "userData": { + "compressionType": {}, + "isRemoteBundle": {} + } +} diff --git a/assets/libs/network/protocol/pako.min.js b/assets/libs/network/protocol/pako.min.js new file mode 100644 index 0000000..6b4a335 --- /dev/null +++ b/assets/libs/network/protocol/pako.min.js @@ -0,0 +1,3424 @@ +!(function(t) { + if ('object' == typeof exports && 'undefined' != typeof module) + module.exports = t(); + else if ('function' == typeof define && define.amd) define([], t); + else { + ('undefined' != typeof window + ? window + : 'undefined' != typeof global + ? global + : 'undefined' != typeof self + ? self + : this + ).pako = t(); + } +})(function() { + return (function r(s, o, l) { + function h(e, t) { + if (!o[e]) { + if (!s[e]) { + var a = 'function' == typeof require && require; + if (!t && a) return a(e, !0); + if (d) return d(e, !0); + var i = new Error("Cannot find module '" + e + "'"); + throw ((i.code = 'MODULE_NOT_FOUND'), i); + } + var n = (o[e] = { exports: {} }); + s[e][0].call( + n.exports, + function(t) { + return h(s[e][1][t] || t); + }, + n, + n.exports, + r, + s, + o, + l + ); + } + return o[e].exports; + } + for ( + var d = 'function' == typeof require && require, t = 0; + t < l.length; + t++ + ) + h(l[t]); + return h; + })( + { + 1: [ + function(t, e, a) { + 'use strict'; + var s = t('./zlib/deflate'), + o = t('./utils/common'), + l = t('./utils/strings'), + n = t('./zlib/messages'), + r = t('./zlib/zstream'), + h = Object.prototype.toString, + d = 0, + f = -1, + _ = 0, + u = 8; + function c(t) { + if (!(this instanceof c)) return new c(t); + this.options = o.assign( + { + level: f, + method: u, + chunkSize: 16384, + windowBits: 15, + memLevel: 8, + strategy: _, + to: '' + }, + t || {} + ); + var e = this.options; + e.raw && 0 < e.windowBits + ? (e.windowBits = -e.windowBits) + : e.gzip && + 0 < e.windowBits && + e.windowBits < 16 && + (e.windowBits += 16), + (this.err = 0), + (this.msg = ''), + (this.ended = !1), + (this.chunks = []), + (this.strm = new r()), + (this.strm.avail_out = 0); + var a = s.deflateInit2( + this.strm, + e.level, + e.method, + e.windowBits, + e.memLevel, + e.strategy + ); + if (a !== d) throw new Error(n[a]); + if ( + (e.header && s.deflateSetHeader(this.strm, e.header), + e.dictionary) + ) { + var i; + if ( + ((i = + 'string' == typeof e.dictionary + ? l.string2buf(e.dictionary) + : '[object ArrayBuffer]' === h.call(e.dictionary) + ? new Uint8Array(e.dictionary) + : e.dictionary), + (a = s.deflateSetDictionary(this.strm, i)) !== d) + ) + throw new Error(n[a]); + this._dict_set = !0; + } + } + function i(t, e) { + var a = new c(e); + if ((a.push(t, !0), a.err)) throw a.msg || n[a.err]; + return a.result; + } + (c.prototype.push = function(t, e) { + var a, + i, + n = this.strm, + r = this.options.chunkSize; + if (this.ended) return !1; + (i = e === ~~e ? e : !0 === e ? 4 : 0), + 'string' == typeof t + ? (n.input = l.string2buf(t)) + : '[object ArrayBuffer]' === h.call(t) + ? (n.input = new Uint8Array(t)) + : (n.input = t), + (n.next_in = 0), + (n.avail_in = n.input.length); + do { + if ( + (0 === n.avail_out && + ((n.output = new o.Buf8(r)), + (n.next_out = 0), + (n.avail_out = r)), + 1 !== (a = s.deflate(n, i)) && a !== d) + ) + return this.onEnd(a), !(this.ended = !0); + (0 !== n.avail_out && + (0 !== n.avail_in || (4 !== i && 2 !== i))) || + ('string' === this.options.to + ? this.onData( + l.buf2binstring(o.shrinkBuf(n.output, n.next_out)) + ) + : this.onData(o.shrinkBuf(n.output, n.next_out))); + } while ((0 < n.avail_in || 0 === n.avail_out) && 1 !== a); + return 4 === i + ? ((a = s.deflateEnd(this.strm)), + this.onEnd(a), + (this.ended = !0), + a === d) + : 2 !== i || (this.onEnd(d), !(n.avail_out = 0)); + }), + (c.prototype.onData = function(t) { + this.chunks.push(t); + }), + (c.prototype.onEnd = function(t) { + t === d && + ('string' === this.options.to + ? (this.result = this.chunks.join('')) + : (this.result = o.flattenChunks(this.chunks))), + (this.chunks = []), + (this.err = t), + (this.msg = this.strm.msg); + }), + (a.Deflate = c), + (a.deflate = i), + (a.deflateRaw = function(t, e) { + return ((e = e || {}).raw = !0), i(t, e); + }), + (a.gzip = function(t, e) { + return ((e = e || {}).gzip = !0), i(t, e); + }); + }, + { + './utils/common': 3, + './utils/strings': 4, + './zlib/deflate': 8, + './zlib/messages': 13, + './zlib/zstream': 15 + } + ], + 2: [ + function(t, e, a) { + 'use strict'; + var f = t('./zlib/inflate'), + _ = t('./utils/common'), + u = t('./utils/strings'), + c = t('./zlib/constants'), + i = t('./zlib/messages'), + n = t('./zlib/zstream'), + r = t('./zlib/gzheader'), + b = Object.prototype.toString; + function s(t) { + if (!(this instanceof s)) return new s(t); + this.options = _.assign( + { chunkSize: 16384, windowBits: 0, to: '' }, + t || {} + ); + var e = this.options; + e.raw && + 0 <= e.windowBits && + e.windowBits < 16 && + ((e.windowBits = -e.windowBits), + 0 === e.windowBits && (e.windowBits = -15)), + !(0 <= e.windowBits && e.windowBits < 16) || + (t && t.windowBits) || + (e.windowBits += 32), + 15 < e.windowBits && + e.windowBits < 48 && + 0 == (15 & e.windowBits) && + (e.windowBits |= 15), + (this.err = 0), + (this.msg = ''), + (this.ended = !1), + (this.chunks = []), + (this.strm = new n()), + (this.strm.avail_out = 0); + var a = f.inflateInit2(this.strm, e.windowBits); + if (a !== c.Z_OK) throw new Error(i[a]); + if ( + ((this.header = new r()), + f.inflateGetHeader(this.strm, this.header), + e.dictionary && + ('string' == typeof e.dictionary + ? (e.dictionary = u.string2buf(e.dictionary)) + : '[object ArrayBuffer]' === b.call(e.dictionary) && + (e.dictionary = new Uint8Array(e.dictionary)), + e.raw && + (a = f.inflateSetDictionary(this.strm, e.dictionary)) !== + c.Z_OK)) + ) + throw new Error(i[a]); + } + function o(t, e) { + var a = new s(e); + if ((a.push(t, !0), a.err)) throw a.msg || i[a.err]; + return a.result; + } + (s.prototype.push = function(t, e) { + var a, + i, + n, + r, + s, + o = this.strm, + l = this.options.chunkSize, + h = this.options.dictionary, + d = !1; + if (this.ended) return !1; + (i = e === ~~e ? e : !0 === e ? c.Z_FINISH : c.Z_NO_FLUSH), + 'string' == typeof t + ? (o.input = u.binstring2buf(t)) + : '[object ArrayBuffer]' === b.call(t) + ? (o.input = new Uint8Array(t)) + : (o.input = t), + (o.next_in = 0), + (o.avail_in = o.input.length); + do { + if ( + (0 === o.avail_out && + ((o.output = new _.Buf8(l)), + (o.next_out = 0), + (o.avail_out = l)), + (a = f.inflate(o, c.Z_NO_FLUSH)) === c.Z_NEED_DICT && + h && + (a = f.inflateSetDictionary(this.strm, h)), + a === c.Z_BUF_ERROR && !0 === d && ((a = c.Z_OK), (d = !1)), + a !== c.Z_STREAM_END && a !== c.Z_OK) + ) + return this.onEnd(a), !(this.ended = !0); + o.next_out && + ((0 !== o.avail_out && + a !== c.Z_STREAM_END && + (0 !== o.avail_in || + (i !== c.Z_FINISH && i !== c.Z_SYNC_FLUSH))) || + ('string' === this.options.to + ? ((n = u.utf8border(o.output, o.next_out)), + (r = o.next_out - n), + (s = u.buf2string(o.output, n)), + (o.next_out = r), + (o.avail_out = l - r), + r && _.arraySet(o.output, o.output, n, r, 0), + this.onData(s)) + : this.onData(_.shrinkBuf(o.output, o.next_out)))), + 0 === o.avail_in && 0 === o.avail_out && (d = !0); + } while ( + (0 < o.avail_in || 0 === o.avail_out) && + a !== c.Z_STREAM_END + ); + return ( + a === c.Z_STREAM_END && (i = c.Z_FINISH), + i === c.Z_FINISH + ? ((a = f.inflateEnd(this.strm)), + this.onEnd(a), + (this.ended = !0), + a === c.Z_OK) + : i !== c.Z_SYNC_FLUSH || + (this.onEnd(c.Z_OK), !(o.avail_out = 0)) + ); + }), + (s.prototype.onData = function(t) { + this.chunks.push(t); + }), + (s.prototype.onEnd = function(t) { + t === c.Z_OK && + ('string' === this.options.to + ? (this.result = this.chunks.join('')) + : (this.result = _.flattenChunks(this.chunks))), + (this.chunks = []), + (this.err = t), + (this.msg = this.strm.msg); + }), + (a.Inflate = s), + (a.inflate = o), + (a.inflateRaw = function(t, e) { + return ((e = e || {}).raw = !0), o(t, e); + }), + (a.ungzip = o); + }, + { + './utils/common': 3, + './utils/strings': 4, + './zlib/constants': 6, + './zlib/gzheader': 9, + './zlib/inflate': 11, + './zlib/messages': 13, + './zlib/zstream': 15 + } + ], + 3: [ + function(t, e, a) { + 'use strict'; + var i = + 'undefined' != typeof Uint8Array && + 'undefined' != typeof Uint16Array && + 'undefined' != typeof Int32Array; + (a.assign = function(t) { + for ( + var e, a, i = Array.prototype.slice.call(arguments, 1); + i.length; + + ) { + var n = i.shift(); + if (n) { + if ('object' != typeof n) + throw new TypeError(n + 'must be non-object'); + for (var r in n) + (e = n), + (a = r), + Object.prototype.hasOwnProperty.call(e, a) && (t[r] = n[r]); + } + } + return t; + }), + (a.shrinkBuf = function(t, e) { + return t.length === e + ? t + : t.subarray + ? t.subarray(0, e) + : ((t.length = e), t); + }); + var n = { + arraySet: function(t, e, a, i, n) { + if (e.subarray && t.subarray) t.set(e.subarray(a, a + i), n); + else for (var r = 0; r < i; r++) t[n + r] = e[a + r]; + }, + flattenChunks: function(t) { + var e, a, i, n, r, s; + for (e = i = 0, a = t.length; e < a; e++) i += t[e].length; + for (s = new Uint8Array(i), e = n = 0, a = t.length; e < a; e++) + (r = t[e]), s.set(r, n), (n += r.length); + return s; + } + }, + r = { + arraySet: function(t, e, a, i, n) { + for (var r = 0; r < i; r++) t[n + r] = e[a + r]; + }, + flattenChunks: function(t) { + return [].concat.apply([], t); + } + }; + (a.setTyped = function(t) { + t + ? ((a.Buf8 = Uint8Array), + (a.Buf16 = Uint16Array), + (a.Buf32 = Int32Array), + a.assign(a, n)) + : ((a.Buf8 = Array), + (a.Buf16 = Array), + (a.Buf32 = Array), + a.assign(a, r)); + }), + a.setTyped(i); + }, + {} + ], + 4: [ + function(t, e, a) { + 'use strict'; + var l = t('./common'), + n = !0, + r = !0; + try { + String.fromCharCode.apply(null, [0]); + } catch (t) { + n = !1; + } + try { + String.fromCharCode.apply(null, new Uint8Array(1)); + } catch (t) { + r = !1; + } + for (var h = new l.Buf8(256), i = 0; i < 256; i++) + h[i] = + 252 <= i + ? 6 + : 248 <= i + ? 5 + : 240 <= i + ? 4 + : 224 <= i + ? 3 + : 192 <= i + ? 2 + : 1; + function d(t, e) { + if (e < 65534 && ((t.subarray && r) || (!t.subarray && n))) + return String.fromCharCode.apply(null, l.shrinkBuf(t, e)); + for (var a = '', i = 0; i < e; i++) a += String.fromCharCode(t[i]); + return a; + } + (h[254] = h[254] = 1), + (a.string2buf = function(t) { + var e, + a, + i, + n, + r, + s = t.length, + o = 0; + for (n = 0; n < s; n++) + 55296 == (64512 & (a = t.charCodeAt(n))) && + n + 1 < s && + 56320 == (64512 & (i = t.charCodeAt(n + 1))) && + ((a = 65536 + ((a - 55296) << 10) + (i - 56320)), n++), + (o += a < 128 ? 1 : a < 2048 ? 2 : a < 65536 ? 3 : 4); + for (e = new l.Buf8(o), n = r = 0; r < o; n++) + 55296 == (64512 & (a = t.charCodeAt(n))) && + n + 1 < s && + 56320 == (64512 & (i = t.charCodeAt(n + 1))) && + ((a = 65536 + ((a - 55296) << 10) + (i - 56320)), n++), + a < 128 + ? (e[r++] = a) + : (a < 2048 + ? (e[r++] = 192 | (a >>> 6)) + : (a < 65536 + ? (e[r++] = 224 | (a >>> 12)) + : ((e[r++] = 240 | (a >>> 18)), + (e[r++] = 128 | ((a >>> 12) & 63))), + (e[r++] = 128 | ((a >>> 6) & 63))), + (e[r++] = 128 | (63 & a))); + return e; + }), + (a.buf2binstring = function(t) { + return d(t, t.length); + }), + (a.binstring2buf = function(t) { + for ( + var e = new l.Buf8(t.length), a = 0, i = e.length; + a < i; + a++ + ) + e[a] = t.charCodeAt(a); + return e; + }), + (a.buf2string = function(t, e) { + var a, + i, + n, + r, + s = e || t.length, + o = new Array(2 * s); + for (a = i = 0; a < s; ) + if ((n = t[a++]) < 128) o[i++] = n; + else if (4 < (r = h[n])) (o[i++] = 65533), (a += r - 1); + else { + for (n &= 2 === r ? 31 : 3 === r ? 15 : 7; 1 < r && a < s; ) + (n = (n << 6) | (63 & t[a++])), r--; + 1 < r + ? (o[i++] = 65533) + : n < 65536 + ? (o[i++] = n) + : ((n -= 65536), + (o[i++] = 55296 | ((n >> 10) & 1023)), + (o[i++] = 56320 | (1023 & n))); + } + return d(o, i); + }), + (a.utf8border = function(t, e) { + var a; + for ( + (e = e || t.length) > t.length && (e = t.length), a = e - 1; + 0 <= a && 128 == (192 & t[a]); + + ) + a--; + return a < 0 ? e : 0 === a ? e : a + h[t[a]] > e ? a : e; + }); + }, + { './common': 3 } + ], + 5: [ + function(t, e, a) { + 'use strict'; + e.exports = function(t, e, a, i) { + for ( + var n = (65535 & t) | 0, r = ((t >>> 16) & 65535) | 0, s = 0; + 0 !== a; + + ) { + for ( + a -= s = 2e3 < a ? 2e3 : a; + (r = (r + (n = (n + e[i++]) | 0)) | 0), --s; + + ); + (n %= 65521), (r %= 65521); + } + return n | (r << 16) | 0; + }; + }, + {} + ], + 6: [ + function(t, e, a) { + 'use strict'; + e.exports = { + Z_NO_FLUSH: 0, + Z_PARTIAL_FLUSH: 1, + Z_SYNC_FLUSH: 2, + Z_FULL_FLUSH: 3, + Z_FINISH: 4, + Z_BLOCK: 5, + Z_TREES: 6, + Z_OK: 0, + Z_STREAM_END: 1, + Z_NEED_DICT: 2, + Z_ERRNO: -1, + Z_STREAM_ERROR: -2, + Z_DATA_ERROR: -3, + Z_BUF_ERROR: -5, + Z_NO_COMPRESSION: 0, + Z_BEST_SPEED: 1, + Z_BEST_COMPRESSION: 9, + Z_DEFAULT_COMPRESSION: -1, + Z_FILTERED: 1, + Z_HUFFMAN_ONLY: 2, + Z_RLE: 3, + Z_FIXED: 4, + Z_DEFAULT_STRATEGY: 0, + Z_BINARY: 0, + Z_TEXT: 1, + Z_UNKNOWN: 2, + Z_DEFLATED: 8 + }; + }, + {} + ], + 7: [ + function(t, e, a) { + 'use strict'; + var o = (function() { + for (var t, e = [], a = 0; a < 256; a++) { + t = a; + for (var i = 0; i < 8; i++) + t = 1 & t ? 3988292384 ^ (t >>> 1) : t >>> 1; + e[a] = t; + } + return e; + })(); + e.exports = function(t, e, a, i) { + var n = o, + r = i + a; + t ^= -1; + for (var s = i; s < r; s++) t = (t >>> 8) ^ n[255 & (t ^ e[s])]; + return -1 ^ t; + }; + }, + {} + ], + 8: [ + function(t, e, a) { + 'use strict'; + var l, + _ = t('../utils/common'), + h = t('./trees'), + u = t('./adler32'), + c = t('./crc32'), + i = t('./messages'), + d = 0, + f = 4, + b = 0, + g = -2, + m = -1, + w = 4, + n = 2, + p = 8, + v = 9, + r = 286, + s = 30, + o = 19, + k = 2 * r + 1, + y = 15, + x = 3, + z = 258, + B = z + x + 1, + S = 42, + E = 113, + A = 1, + Z = 2, + R = 3, + C = 4; + function N(t, e) { + return (t.msg = i[e]), e; + } + function O(t) { + return (t << 1) - (4 < t ? 9 : 0); + } + function D(t) { + for (var e = t.length; 0 <= --e; ) t[e] = 0; + } + function I(t) { + var e = t.state, + a = e.pending; + a > t.avail_out && (a = t.avail_out), + 0 !== a && + (_.arraySet( + t.output, + e.pending_buf, + e.pending_out, + a, + t.next_out + ), + (t.next_out += a), + (e.pending_out += a), + (t.total_out += a), + (t.avail_out -= a), + (e.pending -= a), + 0 === e.pending && (e.pending_out = 0)); + } + function U(t, e) { + h._tr_flush_block( + t, + 0 <= t.block_start ? t.block_start : -1, + t.strstart - t.block_start, + e + ), + (t.block_start = t.strstart), + I(t.strm); + } + function T(t, e) { + t.pending_buf[t.pending++] = e; + } + function F(t, e) { + (t.pending_buf[t.pending++] = (e >>> 8) & 255), + (t.pending_buf[t.pending++] = 255 & e); + } + function L(t, e) { + var a, + i, + n = t.max_chain_length, + r = t.strstart, + s = t.prev_length, + o = t.nice_match, + l = t.strstart > t.w_size - B ? t.strstart - (t.w_size - B) : 0, + h = t.window, + d = t.w_mask, + f = t.prev, + _ = t.strstart + z, + u = h[r + s - 1], + c = h[r + s]; + t.prev_length >= t.good_match && (n >>= 2), + o > t.lookahead && (o = t.lookahead); + do { + if ( + h[(a = e) + s] === c && + h[a + s - 1] === u && + h[a] === h[r] && + h[++a] === h[r + 1] + ) { + (r += 2), a++; + do {} while ( + h[++r] === h[++a] && + h[++r] === h[++a] && + h[++r] === h[++a] && + h[++r] === h[++a] && + h[++r] === h[++a] && + h[++r] === h[++a] && + h[++r] === h[++a] && + h[++r] === h[++a] && + r < _ + ); + if (((i = z - (_ - r)), (r = _ - z), s < i)) { + if (((t.match_start = e), o <= (s = i))) break; + (u = h[r + s - 1]), (c = h[r + s]); + } + } + } while ((e = f[e & d]) > l && 0 != --n); + return s <= t.lookahead ? s : t.lookahead; + } + function H(t) { + var e, + a, + i, + n, + r, + s, + o, + l, + h, + d, + f = t.w_size; + do { + if ( + ((n = t.window_size - t.lookahead - t.strstart), + t.strstart >= f + (f - B)) + ) { + for ( + _.arraySet(t.window, t.window, f, f, 0), + t.match_start -= f, + t.strstart -= f, + t.block_start -= f, + e = a = t.hash_size; + (i = t.head[--e]), (t.head[e] = f <= i ? i - f : 0), --a; + + ); + for ( + e = a = f; + (i = t.prev[--e]), (t.prev[e] = f <= i ? i - f : 0), --a; + + ); + n += f; + } + if (0 === t.strm.avail_in) break; + if ( + ((s = t.strm), + (o = t.window), + (l = t.strstart + t.lookahead), + (h = n), + (d = void 0), + (d = s.avail_in), + h < d && (d = h), + (a = + 0 === d + ? 0 + : ((s.avail_in -= d), + _.arraySet(o, s.input, s.next_in, d, l), + 1 === s.state.wrap + ? (s.adler = u(s.adler, o, d, l)) + : 2 === s.state.wrap && (s.adler = c(s.adler, o, d, l)), + (s.next_in += d), + (s.total_in += d), + d)), + (t.lookahead += a), + t.lookahead + t.insert >= x) + ) + for ( + r = t.strstart - t.insert, + t.ins_h = t.window[r], + t.ins_h = + ((t.ins_h << t.hash_shift) ^ t.window[r + 1]) & + t.hash_mask; + t.insert && + ((t.ins_h = + ((t.ins_h << t.hash_shift) ^ t.window[r + x - 1]) & + t.hash_mask), + (t.prev[r & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = r), + r++, + t.insert--, + !(t.lookahead + t.insert < x)); + + ); + } while (t.lookahead < B && 0 !== t.strm.avail_in); + } + function j(t, e) { + for (var a, i; ; ) { + if (t.lookahead < B) { + if ((H(t), t.lookahead < B && e === d)) return A; + if (0 === t.lookahead) break; + } + if ( + ((a = 0), + t.lookahead >= x && + ((t.ins_h = + ((t.ins_h << t.hash_shift) ^ t.window[t.strstart + x - 1]) & + t.hash_mask), + (a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = t.strstart)), + 0 !== a && + t.strstart - a <= t.w_size - B && + (t.match_length = L(t, a)), + t.match_length >= x) + ) + if ( + ((i = h._tr_tally( + t, + t.strstart - t.match_start, + t.match_length - x + )), + (t.lookahead -= t.match_length), + t.match_length <= t.max_lazy_match && t.lookahead >= x) + ) { + for ( + t.match_length--; + t.strstart++, + (t.ins_h = + ((t.ins_h << t.hash_shift) ^ + t.window[t.strstart + x - 1]) & + t.hash_mask), + (a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = t.strstart), + 0 != --t.match_length; + + ); + t.strstart++; + } else + (t.strstart += t.match_length), + (t.match_length = 0), + (t.ins_h = t.window[t.strstart]), + (t.ins_h = + ((t.ins_h << t.hash_shift) ^ t.window[t.strstart + 1]) & + t.hash_mask); + else + (i = h._tr_tally(t, 0, t.window[t.strstart])), + t.lookahead--, + t.strstart++; + if (i && (U(t, !1), 0 === t.strm.avail_out)) return A; + } + return ( + (t.insert = t.strstart < x - 1 ? t.strstart : x - 1), + e === f + ? (U(t, !0), 0 === t.strm.avail_out ? R : C) + : t.last_lit && (U(t, !1), 0 === t.strm.avail_out) + ? A + : Z + ); + } + function K(t, e) { + for (var a, i, n; ; ) { + if (t.lookahead < B) { + if ((H(t), t.lookahead < B && e === d)) return A; + if (0 === t.lookahead) break; + } + if ( + ((a = 0), + t.lookahead >= x && + ((t.ins_h = + ((t.ins_h << t.hash_shift) ^ t.window[t.strstart + x - 1]) & + t.hash_mask), + (a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = t.strstart)), + (t.prev_length = t.match_length), + (t.prev_match = t.match_start), + (t.match_length = x - 1), + 0 !== a && + t.prev_length < t.max_lazy_match && + t.strstart - a <= t.w_size - B && + ((t.match_length = L(t, a)), + t.match_length <= 5 && + (1 === t.strategy || + (t.match_length === x && + 4096 < t.strstart - t.match_start)) && + (t.match_length = x - 1)), + t.prev_length >= x && t.match_length <= t.prev_length) + ) { + for ( + n = t.strstart + t.lookahead - x, + i = h._tr_tally( + t, + t.strstart - 1 - t.prev_match, + t.prev_length - x + ), + t.lookahead -= t.prev_length - 1, + t.prev_length -= 2; + ++t.strstart <= n && + ((t.ins_h = + ((t.ins_h << t.hash_shift) ^ + t.window[t.strstart + x - 1]) & + t.hash_mask), + (a = t.prev[t.strstart & t.w_mask] = t.head[t.ins_h]), + (t.head[t.ins_h] = t.strstart)), + 0 != --t.prev_length; + + ); + if ( + ((t.match_available = 0), + (t.match_length = x - 1), + t.strstart++, + i && (U(t, !1), 0 === t.strm.avail_out)) + ) + return A; + } else if (t.match_available) { + if ( + ((i = h._tr_tally(t, 0, t.window[t.strstart - 1])) && + U(t, !1), + t.strstart++, + t.lookahead--, + 0 === t.strm.avail_out) + ) + return A; + } else (t.match_available = 1), t.strstart++, t.lookahead--; + } + return ( + t.match_available && + ((i = h._tr_tally(t, 0, t.window[t.strstart - 1])), + (t.match_available = 0)), + (t.insert = t.strstart < x - 1 ? t.strstart : x - 1), + e === f + ? (U(t, !0), 0 === t.strm.avail_out ? R : C) + : t.last_lit && (U(t, !1), 0 === t.strm.avail_out) + ? A + : Z + ); + } + function M(t, e, a, i, n) { + (this.good_length = t), + (this.max_lazy = e), + (this.nice_length = a), + (this.max_chain = i), + (this.func = n); + } + function P() { + (this.strm = null), + (this.status = 0), + (this.pending_buf = null), + (this.pending_buf_size = 0), + (this.pending_out = 0), + (this.pending = 0), + (this.wrap = 0), + (this.gzhead = null), + (this.gzindex = 0), + (this.method = p), + (this.last_flush = -1), + (this.w_size = 0), + (this.w_bits = 0), + (this.w_mask = 0), + (this.window = null), + (this.window_size = 0), + (this.prev = null), + (this.head = null), + (this.ins_h = 0), + (this.hash_size = 0), + (this.hash_bits = 0), + (this.hash_mask = 0), + (this.hash_shift = 0), + (this.block_start = 0), + (this.match_length = 0), + (this.prev_match = 0), + (this.match_available = 0), + (this.strstart = 0), + (this.match_start = 0), + (this.lookahead = 0), + (this.prev_length = 0), + (this.max_chain_length = 0), + (this.max_lazy_match = 0), + (this.level = 0), + (this.strategy = 0), + (this.good_match = 0), + (this.nice_match = 0), + (this.dyn_ltree = new _.Buf16(2 * k)), + (this.dyn_dtree = new _.Buf16(2 * (2 * s + 1))), + (this.bl_tree = new _.Buf16(2 * (2 * o + 1))), + D(this.dyn_ltree), + D(this.dyn_dtree), + D(this.bl_tree), + (this.l_desc = null), + (this.d_desc = null), + (this.bl_desc = null), + (this.bl_count = new _.Buf16(y + 1)), + (this.heap = new _.Buf16(2 * r + 1)), + D(this.heap), + (this.heap_len = 0), + (this.heap_max = 0), + (this.depth = new _.Buf16(2 * r + 1)), + D(this.depth), + (this.l_buf = 0), + (this.lit_bufsize = 0), + (this.last_lit = 0), + (this.d_buf = 0), + (this.opt_len = 0), + (this.static_len = 0), + (this.matches = 0), + (this.insert = 0), + (this.bi_buf = 0), + (this.bi_valid = 0); + } + function Y(t) { + var e; + return t && t.state + ? ((t.total_in = t.total_out = 0), + (t.data_type = n), + ((e = t.state).pending = 0), + (e.pending_out = 0), + e.wrap < 0 && (e.wrap = -e.wrap), + (e.status = e.wrap ? S : E), + (t.adler = 2 === e.wrap ? 0 : 1), + (e.last_flush = d), + h._tr_init(e), + b) + : N(t, g); + } + function q(t) { + var e, + a = Y(t); + return ( + a === b && + (((e = t.state).window_size = 2 * e.w_size), + D(e.head), + (e.max_lazy_match = l[e.level].max_lazy), + (e.good_match = l[e.level].good_length), + (e.nice_match = l[e.level].nice_length), + (e.max_chain_length = l[e.level].max_chain), + (e.strstart = 0), + (e.block_start = 0), + (e.lookahead = 0), + (e.insert = 0), + (e.match_length = e.prev_length = x - 1), + (e.match_available = 0), + (e.ins_h = 0)), + a + ); + } + function G(t, e, a, i, n, r) { + if (!t) return g; + var s = 1; + if ( + (e === m && (e = 6), + i < 0 ? ((s = 0), (i = -i)) : 15 < i && ((s = 2), (i -= 16)), + n < 1 || + v < n || + a !== p || + i < 8 || + 15 < i || + e < 0 || + 9 < e || + r < 0 || + w < r) + ) + return N(t, g); + 8 === i && (i = 9); + var o = new P(); + return ( + ((t.state = o).strm = t), + (o.wrap = s), + (o.gzhead = null), + (o.w_bits = i), + (o.w_size = 1 << o.w_bits), + (o.w_mask = o.w_size - 1), + (o.hash_bits = n + 7), + (o.hash_size = 1 << o.hash_bits), + (o.hash_mask = o.hash_size - 1), + (o.hash_shift = ~~((o.hash_bits + x - 1) / x)), + (o.window = new _.Buf8(2 * o.w_size)), + (o.head = new _.Buf16(o.hash_size)), + (o.prev = new _.Buf16(o.w_size)), + (o.lit_bufsize = 1 << (n + 6)), + (o.pending_buf_size = 4 * o.lit_bufsize), + (o.pending_buf = new _.Buf8(o.pending_buf_size)), + (o.d_buf = 1 * o.lit_bufsize), + (o.l_buf = 3 * o.lit_bufsize), + (o.level = e), + (o.strategy = r), + (o.method = a), + q(t) + ); + } + (l = [ + new M(0, 0, 0, 0, function(t, e) { + var a = 65535; + for ( + a > t.pending_buf_size - 5 && (a = t.pending_buf_size - 5); + ; + + ) { + if (t.lookahead <= 1) { + if ((H(t), 0 === t.lookahead && e === d)) return A; + if (0 === t.lookahead) break; + } + (t.strstart += t.lookahead), (t.lookahead = 0); + var i = t.block_start + a; + if ( + (0 === t.strstart || t.strstart >= i) && + ((t.lookahead = t.strstart - i), + (t.strstart = i), + U(t, !1), + 0 === t.strm.avail_out) + ) + return A; + if ( + t.strstart - t.block_start >= t.w_size - B && + (U(t, !1), 0 === t.strm.avail_out) + ) + return A; + } + return ( + (t.insert = 0), + e === f + ? (U(t, !0), 0 === t.strm.avail_out ? R : C) + : (t.strstart > t.block_start && (U(t, !1), t.strm.avail_out), + A) + ); + }), + new M(4, 4, 8, 4, j), + new M(4, 5, 16, 8, j), + new M(4, 6, 32, 32, j), + new M(4, 4, 16, 16, K), + new M(8, 16, 32, 32, K), + new M(8, 16, 128, 128, K), + new M(8, 32, 128, 256, K), + new M(32, 128, 258, 1024, K), + new M(32, 258, 258, 4096, K) + ]), + (a.deflateInit = function(t, e) { + return G(t, e, p, 15, 8, 0); + }), + (a.deflateInit2 = G), + (a.deflateReset = q), + (a.deflateResetKeep = Y), + (a.deflateSetHeader = function(t, e) { + return t && t.state + ? 2 !== t.state.wrap + ? g + : ((t.state.gzhead = e), b) + : g; + }), + (a.deflate = function(t, e) { + var a, i, n, r; + if (!t || !t.state || 5 < e || e < 0) return t ? N(t, g) : g; + if ( + ((i = t.state), + !t.output || + (!t.input && 0 !== t.avail_in) || + (666 === i.status && e !== f)) + ) + return N(t, 0 === t.avail_out ? -5 : g); + if ( + ((i.strm = t), + (a = i.last_flush), + (i.last_flush = e), + i.status === S) + ) + if (2 === i.wrap) + (t.adler = 0), + T(i, 31), + T(i, 139), + T(i, 8), + i.gzhead + ? (T( + i, + (i.gzhead.text ? 1 : 0) + + (i.gzhead.hcrc ? 2 : 0) + + (i.gzhead.extra ? 4 : 0) + + (i.gzhead.name ? 8 : 0) + + (i.gzhead.comment ? 16 : 0) + ), + T(i, 255 & i.gzhead.time), + T(i, (i.gzhead.time >> 8) & 255), + T(i, (i.gzhead.time >> 16) & 255), + T(i, (i.gzhead.time >> 24) & 255), + T( + i, + 9 === i.level + ? 2 + : 2 <= i.strategy || i.level < 2 + ? 4 + : 0 + ), + T(i, 255 & i.gzhead.os), + i.gzhead.extra && + i.gzhead.extra.length && + (T(i, 255 & i.gzhead.extra.length), + T(i, (i.gzhead.extra.length >> 8) & 255)), + i.gzhead.hcrc && + (t.adler = c(t.adler, i.pending_buf, i.pending, 0)), + (i.gzindex = 0), + (i.status = 69)) + : (T(i, 0), + T(i, 0), + T(i, 0), + T(i, 0), + T(i, 0), + T( + i, + 9 === i.level + ? 2 + : 2 <= i.strategy || i.level < 2 + ? 4 + : 0 + ), + T(i, 3), + (i.status = E)); + else { + var s = (p + ((i.w_bits - 8) << 4)) << 8; + (s |= + (2 <= i.strategy || i.level < 2 + ? 0 + : i.level < 6 + ? 1 + : 6 === i.level + ? 2 + : 3) << 6), + 0 !== i.strstart && (s |= 32), + (s += 31 - (s % 31)), + (i.status = E), + F(i, s), + 0 !== i.strstart && + (F(i, t.adler >>> 16), F(i, 65535 & t.adler)), + (t.adler = 1); + } + if (69 === i.status) + if (i.gzhead.extra) { + for ( + n = i.pending; + i.gzindex < (65535 & i.gzhead.extra.length) && + (i.pending !== i.pending_buf_size || + (i.gzhead.hcrc && + i.pending > n && + (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), + I(t), + (n = i.pending), + i.pending !== i.pending_buf_size)); + + ) + T(i, 255 & i.gzhead.extra[i.gzindex]), i.gzindex++; + i.gzhead.hcrc && + i.pending > n && + (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), + i.gzindex === i.gzhead.extra.length && + ((i.gzindex = 0), (i.status = 73)); + } else i.status = 73; + if (73 === i.status) + if (i.gzhead.name) { + n = i.pending; + do { + if ( + i.pending === i.pending_buf_size && + (i.gzhead.hcrc && + i.pending > n && + (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), + I(t), + (n = i.pending), + i.pending === i.pending_buf_size) + ) { + r = 1; + break; + } + T( + i, + (r = + i.gzindex < i.gzhead.name.length + ? 255 & i.gzhead.name.charCodeAt(i.gzindex++) + : 0) + ); + } while (0 !== r); + i.gzhead.hcrc && + i.pending > n && + (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), + 0 === r && ((i.gzindex = 0), (i.status = 91)); + } else i.status = 91; + if (91 === i.status) + if (i.gzhead.comment) { + n = i.pending; + do { + if ( + i.pending === i.pending_buf_size && + (i.gzhead.hcrc && + i.pending > n && + (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), + I(t), + (n = i.pending), + i.pending === i.pending_buf_size) + ) { + r = 1; + break; + } + T( + i, + (r = + i.gzindex < i.gzhead.comment.length + ? 255 & i.gzhead.comment.charCodeAt(i.gzindex++) + : 0) + ); + } while (0 !== r); + i.gzhead.hcrc && + i.pending > n && + (t.adler = c(t.adler, i.pending_buf, i.pending - n, n)), + 0 === r && (i.status = 103); + } else i.status = 103; + if ( + (103 === i.status && + (i.gzhead.hcrc + ? (i.pending + 2 > i.pending_buf_size && I(t), + i.pending + 2 <= i.pending_buf_size && + (T(i, 255 & t.adler), + T(i, (t.adler >> 8) & 255), + (t.adler = 0), + (i.status = E))) + : (i.status = E)), + 0 !== i.pending) + ) { + if ((I(t), 0 === t.avail_out)) return (i.last_flush = -1), b; + } else if (0 === t.avail_in && O(e) <= O(a) && e !== f) + return N(t, -5); + if (666 === i.status && 0 !== t.avail_in) return N(t, -5); + if ( + 0 !== t.avail_in || + 0 !== i.lookahead || + (e !== d && 666 !== i.status) + ) { + var o = + 2 === i.strategy + ? (function(t, e) { + for (var a; ; ) { + if (0 === t.lookahead && (H(t), 0 === t.lookahead)) { + if (e === d) return A; + break; + } + if ( + ((t.match_length = 0), + (a = h._tr_tally(t, 0, t.window[t.strstart])), + t.lookahead--, + t.strstart++, + a && (U(t, !1), 0 === t.strm.avail_out)) + ) + return A; + } + return ( + (t.insert = 0), + e === f + ? (U(t, !0), 0 === t.strm.avail_out ? R : C) + : t.last_lit && (U(t, !1), 0 === t.strm.avail_out) + ? A + : Z + ); + })(i, e) + : 3 === i.strategy + ? (function(t, e) { + for (var a, i, n, r, s = t.window; ; ) { + if (t.lookahead <= z) { + if ((H(t), t.lookahead <= z && e === d)) return A; + if (0 === t.lookahead) break; + } + if ( + ((t.match_length = 0), + t.lookahead >= x && + 0 < t.strstart && + (i = s[(n = t.strstart - 1)]) === s[++n] && + i === s[++n] && + i === s[++n]) + ) { + r = t.strstart + z; + do {} while ( + i === s[++n] && + i === s[++n] && + i === s[++n] && + i === s[++n] && + i === s[++n] && + i === s[++n] && + i === s[++n] && + i === s[++n] && + n < r + ); + (t.match_length = z - (r - n)), + t.match_length > t.lookahead && + (t.match_length = t.lookahead); + } + if ( + (t.match_length >= x + ? ((a = h._tr_tally(t, 1, t.match_length - x)), + (t.lookahead -= t.match_length), + (t.strstart += t.match_length), + (t.match_length = 0)) + : ((a = h._tr_tally(t, 0, t.window[t.strstart])), + t.lookahead--, + t.strstart++), + a && (U(t, !1), 0 === t.strm.avail_out)) + ) + return A; + } + return ( + (t.insert = 0), + e === f + ? (U(t, !0), 0 === t.strm.avail_out ? R : C) + : t.last_lit && (U(t, !1), 0 === t.strm.avail_out) + ? A + : Z + ); + })(i, e) + : l[i.level].func(i, e); + if ( + ((o !== R && o !== C) || (i.status = 666), o === A || o === R) + ) + return 0 === t.avail_out && (i.last_flush = -1), b; + if ( + o === Z && + (1 === e + ? h._tr_align(i) + : 5 !== e && + (h._tr_stored_block(i, 0, 0, !1), + 3 === e && + (D(i.head), + 0 === i.lookahead && + ((i.strstart = 0), + (i.block_start = 0), + (i.insert = 0)))), + I(t), + 0 === t.avail_out) + ) + return (i.last_flush = -1), b; + } + return e !== f + ? b + : i.wrap <= 0 + ? 1 + : (2 === i.wrap + ? (T(i, 255 & t.adler), + T(i, (t.adler >> 8) & 255), + T(i, (t.adler >> 16) & 255), + T(i, (t.adler >> 24) & 255), + T(i, 255 & t.total_in), + T(i, (t.total_in >> 8) & 255), + T(i, (t.total_in >> 16) & 255), + T(i, (t.total_in >> 24) & 255)) + : (F(i, t.adler >>> 16), F(i, 65535 & t.adler)), + I(t), + 0 < i.wrap && (i.wrap = -i.wrap), + 0 !== i.pending ? b : 1); + }), + (a.deflateEnd = function(t) { + var e; + return t && t.state + ? (e = t.state.status) !== S && + 69 !== e && + 73 !== e && + 91 !== e && + 103 !== e && + e !== E && + 666 !== e + ? N(t, g) + : ((t.state = null), e === E ? N(t, -3) : b) + : g; + }), + (a.deflateSetDictionary = function(t, e) { + var a, + i, + n, + r, + s, + o, + l, + h, + d = e.length; + if (!t || !t.state) return g; + if ( + 2 === (r = (a = t.state).wrap) || + (1 === r && a.status !== S) || + a.lookahead + ) + return g; + for ( + 1 === r && (t.adler = u(t.adler, e, d, 0)), + a.wrap = 0, + d >= a.w_size && + (0 === r && + (D(a.head), + (a.strstart = 0), + (a.block_start = 0), + (a.insert = 0)), + (h = new _.Buf8(a.w_size)), + _.arraySet(h, e, d - a.w_size, a.w_size, 0), + (e = h), + (d = a.w_size)), + s = t.avail_in, + o = t.next_in, + l = t.input, + t.avail_in = d, + t.next_in = 0, + t.input = e, + H(a); + a.lookahead >= x; + + ) { + for ( + i = a.strstart, n = a.lookahead - (x - 1); + (a.ins_h = + ((a.ins_h << a.hash_shift) ^ a.window[i + x - 1]) & + a.hash_mask), + (a.prev[i & a.w_mask] = a.head[a.ins_h]), + (a.head[a.ins_h] = i), + i++, + --n; + + ); + (a.strstart = i), (a.lookahead = x - 1), H(a); + } + return ( + (a.strstart += a.lookahead), + (a.block_start = a.strstart), + (a.insert = a.lookahead), + (a.lookahead = 0), + (a.match_length = a.prev_length = x - 1), + (a.match_available = 0), + (t.next_in = o), + (t.input = l), + (t.avail_in = s), + (a.wrap = r), + b + ); + }), + (a.deflateInfo = 'pako deflate (from Nodeca project)'); + }, + { + '../utils/common': 3, + './adler32': 5, + './crc32': 7, + './messages': 13, + './trees': 14 + } + ], + 9: [ + function(t, e, a) { + 'use strict'; + e.exports = function() { + (this.text = 0), + (this.time = 0), + (this.xflags = 0), + (this.os = 0), + (this.extra = null), + (this.extra_len = 0), + (this.name = ''), + (this.comment = ''), + (this.hcrc = 0), + (this.done = !1); + }; + }, + {} + ], + 10: [ + function(t, e, a) { + 'use strict'; + e.exports = function(t, e) { + var a, + i, + n, + r, + s, + o, + l, + h, + d, + f, + _, + u, + c, + b, + g, + m, + w, + p, + v, + k, + y, + x, + z, + B, + S; + (a = t.state), + (i = t.next_in), + (B = t.input), + (n = i + (t.avail_in - 5)), + (r = t.next_out), + (S = t.output), + (s = r - (e - t.avail_out)), + (o = r + (t.avail_out - 257)), + (l = a.dmax), + (h = a.wsize), + (d = a.whave), + (f = a.wnext), + (_ = a.window), + (u = a.hold), + (c = a.bits), + (b = a.lencode), + (g = a.distcode), + (m = (1 << a.lenbits) - 1), + (w = (1 << a.distbits) - 1); + t: do { + c < 15 && + ((u += B[i++] << c), (c += 8), (u += B[i++] << c), (c += 8)), + (p = b[u & m]); + e: for (;;) { + if ( + ((u >>>= v = p >>> 24), + (c -= v), + 0 === (v = (p >>> 16) & 255)) + ) + S[r++] = 65535 & p; + else { + if (!(16 & v)) { + if (0 == (64 & v)) { + p = b[(65535 & p) + (u & ((1 << v) - 1))]; + continue e; + } + if (32 & v) { + a.mode = 12; + break t; + } + (t.msg = 'invalid literal/length code'), (a.mode = 30); + break t; + } + (k = 65535 & p), + (v &= 15) && + (c < v && ((u += B[i++] << c), (c += 8)), + (k += u & ((1 << v) - 1)), + (u >>>= v), + (c -= v)), + c < 15 && + ((u += B[i++] << c), + (c += 8), + (u += B[i++] << c), + (c += 8)), + (p = g[u & w]); + a: for (;;) { + if ( + ((u >>>= v = p >>> 24), + (c -= v), + !(16 & (v = (p >>> 16) & 255))) + ) { + if (0 == (64 & v)) { + p = g[(65535 & p) + (u & ((1 << v) - 1))]; + continue a; + } + (t.msg = 'invalid distance code'), (a.mode = 30); + break t; + } + if ( + ((y = 65535 & p), + c < (v &= 15) && + ((u += B[i++] << c), + (c += 8) < v && ((u += B[i++] << c), (c += 8))), + l < (y += u & ((1 << v) - 1))) + ) { + (t.msg = 'invalid distance too far back'), (a.mode = 30); + break t; + } + if (((u >>>= v), (c -= v), (v = r - s) < y)) { + if (d < (v = y - v) && a.sane) { + (t.msg = 'invalid distance too far back'), + (a.mode = 30); + break t; + } + if (((z = _), (x = 0) === f)) { + if (((x += h - v), v < k)) { + for (k -= v; (S[r++] = _[x++]), --v; ); + (x = r - y), (z = S); + } + } else if (f < v) { + if (((x += h + f - v), (v -= f) < k)) { + for (k -= v; (S[r++] = _[x++]), --v; ); + if (((x = 0), f < k)) { + for (k -= v = f; (S[r++] = _[x++]), --v; ); + (x = r - y), (z = S); + } + } + } else if (((x += f - v), v < k)) { + for (k -= v; (S[r++] = _[x++]), --v; ); + (x = r - y), (z = S); + } + for (; 2 < k; ) + (S[r++] = z[x++]), + (S[r++] = z[x++]), + (S[r++] = z[x++]), + (k -= 3); + k && ((S[r++] = z[x++]), 1 < k && (S[r++] = z[x++])); + } else { + for ( + x = r - y; + (S[r++] = S[x++]), + (S[r++] = S[x++]), + (S[r++] = S[x++]), + 2 < (k -= 3); + + ); + k && ((S[r++] = S[x++]), 1 < k && (S[r++] = S[x++])); + } + break; + } + } + break; + } + } while (i < n && r < o); + (i -= k = c >> 3), + (u &= (1 << (c -= k << 3)) - 1), + (t.next_in = i), + (t.next_out = r), + (t.avail_in = i < n ? n - i + 5 : 5 - (i - n)), + (t.avail_out = r < o ? o - r + 257 : 257 - (r - o)), + (a.hold = u), + (a.bits = c); + }; + }, + {} + ], + 11: [ + function(t, e, a) { + 'use strict'; + var Z = t('../utils/common'), + R = t('./adler32'), + C = t('./crc32'), + N = t('./inffast'), + O = t('./inftrees'), + D = 1, + I = 2, + U = 0, + T = -2, + F = 1, + i = 852, + n = 592; + function L(t) { + return ( + ((t >>> 24) & 255) + + ((t >>> 8) & 65280) + + ((65280 & t) << 8) + + ((255 & t) << 24) + ); + } + function r() { + (this.mode = 0), + (this.last = !1), + (this.wrap = 0), + (this.havedict = !1), + (this.flags = 0), + (this.dmax = 0), + (this.check = 0), + (this.total = 0), + (this.head = null), + (this.wbits = 0), + (this.wsize = 0), + (this.whave = 0), + (this.wnext = 0), + (this.window = null), + (this.hold = 0), + (this.bits = 0), + (this.length = 0), + (this.offset = 0), + (this.extra = 0), + (this.lencode = null), + (this.distcode = null), + (this.lenbits = 0), + (this.distbits = 0), + (this.ncode = 0), + (this.nlen = 0), + (this.ndist = 0), + (this.have = 0), + (this.next = null), + (this.lens = new Z.Buf16(320)), + (this.work = new Z.Buf16(288)), + (this.lendyn = null), + (this.distdyn = null), + (this.sane = 0), + (this.back = 0), + (this.was = 0); + } + function s(t) { + var e; + return t && t.state + ? ((e = t.state), + (t.total_in = t.total_out = e.total = 0), + (t.msg = ''), + e.wrap && (t.adler = 1 & e.wrap), + (e.mode = F), + (e.last = 0), + (e.havedict = 0), + (e.dmax = 32768), + (e.head = null), + (e.hold = 0), + (e.bits = 0), + (e.lencode = e.lendyn = new Z.Buf32(i)), + (e.distcode = e.distdyn = new Z.Buf32(n)), + (e.sane = 1), + (e.back = -1), + U) + : T; + } + function o(t) { + var e; + return t && t.state + ? (((e = t.state).wsize = 0), (e.whave = 0), (e.wnext = 0), s(t)) + : T; + } + function l(t, e) { + var a, i; + return t && t.state + ? ((i = t.state), + e < 0 + ? ((a = 0), (e = -e)) + : ((a = 1 + (e >> 4)), e < 48 && (e &= 15)), + e && (e < 8 || 15 < e) + ? T + : (null !== i.window && i.wbits !== e && (i.window = null), + (i.wrap = a), + (i.wbits = e), + o(t))) + : T; + } + function h(t, e) { + var a, i; + return t + ? ((i = new r()), + ((t.state = i).window = null), + (a = l(t, e)) !== U && (t.state = null), + a) + : T; + } + var d, + f, + _ = !0; + function H(t) { + if (_) { + var e; + for (d = new Z.Buf32(512), f = new Z.Buf32(32), e = 0; e < 144; ) + t.lens[e++] = 8; + for (; e < 256; ) t.lens[e++] = 9; + for (; e < 280; ) t.lens[e++] = 7; + for (; e < 288; ) t.lens[e++] = 8; + for ( + O(D, t.lens, 0, 288, d, 0, t.work, { bits: 9 }), e = 0; + e < 32; + + ) + t.lens[e++] = 5; + O(I, t.lens, 0, 32, f, 0, t.work, { bits: 5 }), (_ = !1); + } + (t.lencode = d), + (t.lenbits = 9), + (t.distcode = f), + (t.distbits = 5); + } + function j(t, e, a, i) { + var n, + r = t.state; + return ( + null === r.window && + ((r.wsize = 1 << r.wbits), + (r.wnext = 0), + (r.whave = 0), + (r.window = new Z.Buf8(r.wsize))), + i >= r.wsize + ? (Z.arraySet(r.window, e, a - r.wsize, r.wsize, 0), + (r.wnext = 0), + (r.whave = r.wsize)) + : (i < (n = r.wsize - r.wnext) && (n = i), + Z.arraySet(r.window, e, a - i, n, r.wnext), + (i -= n) + ? (Z.arraySet(r.window, e, a - i, i, 0), + (r.wnext = i), + (r.whave = r.wsize)) + : ((r.wnext += n), + r.wnext === r.wsize && (r.wnext = 0), + r.whave < r.wsize && (r.whave += n))), + 0 + ); + } + (a.inflateReset = o), + (a.inflateReset2 = l), + (a.inflateResetKeep = s), + (a.inflateInit = function(t) { + return h(t, 15); + }), + (a.inflateInit2 = h), + (a.inflate = function(t, e) { + var a, + i, + n, + r, + s, + o, + l, + h, + d, + f, + _, + u, + c, + b, + g, + m, + w, + p, + v, + k, + y, + x, + z, + B, + S = 0, + E = new Z.Buf8(4), + A = [ + 16, + 17, + 18, + 0, + 8, + 7, + 9, + 6, + 10, + 5, + 11, + 4, + 12, + 3, + 13, + 2, + 14, + 1, + 15 + ]; + if (!t || !t.state || !t.output || (!t.input && 0 !== t.avail_in)) + return T; + 12 === (a = t.state).mode && (a.mode = 13), + (s = t.next_out), + (n = t.output), + (l = t.avail_out), + (r = t.next_in), + (i = t.input), + (o = t.avail_in), + (h = a.hold), + (d = a.bits), + (f = o), + (_ = l), + (x = U); + t: for (;;) + switch (a.mode) { + case F: + if (0 === a.wrap) { + a.mode = 13; + break; + } + for (; d < 16; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if (2 & a.wrap && 35615 === h) { + (E[(a.check = 0)] = 255 & h), + (E[1] = (h >>> 8) & 255), + (a.check = C(a.check, E, 2, 0)), + (d = h = 0), + (a.mode = 2); + break; + } + if ( + ((a.flags = 0), + a.head && (a.head.done = !1), + !(1 & a.wrap) || (((255 & h) << 8) + (h >> 8)) % 31) + ) { + (t.msg = 'incorrect header check'), (a.mode = 30); + break; + } + if (8 != (15 & h)) { + (t.msg = 'unknown compression method'), (a.mode = 30); + break; + } + if (((d -= 4), (y = 8 + (15 & (h >>>= 4))), 0 === a.wbits)) + a.wbits = y; + else if (y > a.wbits) { + (t.msg = 'invalid window size'), (a.mode = 30); + break; + } + (a.dmax = 1 << y), + (t.adler = a.check = 1), + (a.mode = 512 & h ? 10 : 12), + (d = h = 0); + break; + case 2: + for (; d < 16; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if (((a.flags = h), 8 != (255 & a.flags))) { + (t.msg = 'unknown compression method'), (a.mode = 30); + break; + } + if (57344 & a.flags) { + (t.msg = 'unknown header flags set'), (a.mode = 30); + break; + } + a.head && (a.head.text = (h >> 8) & 1), + 512 & a.flags && + ((E[0] = 255 & h), + (E[1] = (h >>> 8) & 255), + (a.check = C(a.check, E, 2, 0))), + (d = h = 0), + (a.mode = 3); + case 3: + for (; d < 32; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + a.head && (a.head.time = h), + 512 & a.flags && + ((E[0] = 255 & h), + (E[1] = (h >>> 8) & 255), + (E[2] = (h >>> 16) & 255), + (E[3] = (h >>> 24) & 255), + (a.check = C(a.check, E, 4, 0))), + (d = h = 0), + (a.mode = 4); + case 4: + for (; d < 16; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + a.head && ((a.head.xflags = 255 & h), (a.head.os = h >> 8)), + 512 & a.flags && + ((E[0] = 255 & h), + (E[1] = (h >>> 8) & 255), + (a.check = C(a.check, E, 2, 0))), + (d = h = 0), + (a.mode = 5); + case 5: + if (1024 & a.flags) { + for (; d < 16; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + (a.length = h), + a.head && (a.head.extra_len = h), + 512 & a.flags && + ((E[0] = 255 & h), + (E[1] = (h >>> 8) & 255), + (a.check = C(a.check, E, 2, 0))), + (d = h = 0); + } else a.head && (a.head.extra = null); + a.mode = 6; + case 6: + if ( + 1024 & a.flags && + (o < (u = a.length) && (u = o), + u && + (a.head && + ((y = a.head.extra_len - a.length), + a.head.extra || + (a.head.extra = new Array(a.head.extra_len)), + Z.arraySet(a.head.extra, i, r, u, y)), + 512 & a.flags && (a.check = C(a.check, i, u, r)), + (o -= u), + (r += u), + (a.length -= u)), + a.length) + ) + break t; + (a.length = 0), (a.mode = 7); + case 7: + if (2048 & a.flags) { + if (0 === o) break t; + for ( + u = 0; + (y = i[r + u++]), + a.head && + y && + a.length < 65536 && + (a.head.name += String.fromCharCode(y)), + y && u < o; + + ); + if ( + (512 & a.flags && (a.check = C(a.check, i, u, r)), + (o -= u), + (r += u), + y) + ) + break t; + } else a.head && (a.head.name = null); + (a.length = 0), (a.mode = 8); + case 8: + if (4096 & a.flags) { + if (0 === o) break t; + for ( + u = 0; + (y = i[r + u++]), + a.head && + y && + a.length < 65536 && + (a.head.comment += String.fromCharCode(y)), + y && u < o; + + ); + if ( + (512 & a.flags && (a.check = C(a.check, i, u, r)), + (o -= u), + (r += u), + y) + ) + break t; + } else a.head && (a.head.comment = null); + a.mode = 9; + case 9: + if (512 & a.flags) { + for (; d < 16; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if (h !== (65535 & a.check)) { + (t.msg = 'header crc mismatch'), (a.mode = 30); + break; + } + d = h = 0; + } + a.head && + ((a.head.hcrc = (a.flags >> 9) & 1), (a.head.done = !0)), + (t.adler = a.check = 0), + (a.mode = 12); + break; + case 10: + for (; d < 32; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + (t.adler = a.check = L(h)), (d = h = 0), (a.mode = 11); + case 11: + if (0 === a.havedict) + return ( + (t.next_out = s), + (t.avail_out = l), + (t.next_in = r), + (t.avail_in = o), + (a.hold = h), + (a.bits = d), + 2 + ); + (t.adler = a.check = 1), (a.mode = 12); + case 12: + if (5 === e || 6 === e) break t; + case 13: + if (a.last) { + (h >>>= 7 & d), (d -= 7 & d), (a.mode = 27); + break; + } + for (; d < 3; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + switch (((a.last = 1 & h), (d -= 1), 3 & (h >>>= 1))) { + case 0: + a.mode = 14; + break; + case 1: + if ((H(a), (a.mode = 20), 6 !== e)) break; + (h >>>= 2), (d -= 2); + break t; + case 2: + a.mode = 17; + break; + case 3: + (t.msg = 'invalid block type'), (a.mode = 30); + } + (h >>>= 2), (d -= 2); + break; + case 14: + for (h >>>= 7 & d, d -= 7 & d; d < 32; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if ((65535 & h) != ((h >>> 16) ^ 65535)) { + (t.msg = 'invalid stored block lengths'), (a.mode = 30); + break; + } + if ( + ((a.length = 65535 & h), + (d = h = 0), + (a.mode = 15), + 6 === e) + ) + break t; + case 15: + a.mode = 16; + case 16: + if ((u = a.length)) { + if ((o < u && (u = o), l < u && (u = l), 0 === u)) + break t; + Z.arraySet(n, i, r, u, s), + (o -= u), + (r += u), + (l -= u), + (s += u), + (a.length -= u); + break; + } + a.mode = 12; + break; + case 17: + for (; d < 14; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if ( + ((a.nlen = 257 + (31 & h)), + (h >>>= 5), + (d -= 5), + (a.ndist = 1 + (31 & h)), + (h >>>= 5), + (d -= 5), + (a.ncode = 4 + (15 & h)), + (h >>>= 4), + (d -= 4), + 286 < a.nlen || 30 < a.ndist) + ) { + (t.msg = 'too many length or distance symbols'), + (a.mode = 30); + break; + } + (a.have = 0), (a.mode = 18); + case 18: + for (; a.have < a.ncode; ) { + for (; d < 3; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + (a.lens[A[a.have++]] = 7 & h), (h >>>= 3), (d -= 3); + } + for (; a.have < 19; ) a.lens[A[a.have++]] = 0; + if ( + ((a.lencode = a.lendyn), + (a.lenbits = 7), + (z = { bits: a.lenbits }), + (x = O(0, a.lens, 0, 19, a.lencode, 0, a.work, z)), + (a.lenbits = z.bits), + x) + ) { + (t.msg = 'invalid code lengths set'), (a.mode = 30); + break; + } + (a.have = 0), (a.mode = 19); + case 19: + for (; a.have < a.nlen + a.ndist; ) { + for ( + ; + (m = + ((S = a.lencode[h & ((1 << a.lenbits) - 1)]) >>> 16) & + 255), + (w = 65535 & S), + !((g = S >>> 24) <= d); + + ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if (w < 16) (h >>>= g), (d -= g), (a.lens[a.have++] = w); + else { + if (16 === w) { + for (B = g + 2; d < B; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if (((h >>>= g), (d -= g), 0 === a.have)) { + (t.msg = 'invalid bit length repeat'), + (a.mode = 30); + break; + } + (y = a.lens[a.have - 1]), + (u = 3 + (3 & h)), + (h >>>= 2), + (d -= 2); + } else if (17 === w) { + for (B = g + 3; d < B; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + (d -= g), + (y = 0), + (u = 3 + (7 & (h >>>= g))), + (h >>>= 3), + (d -= 3); + } else { + for (B = g + 7; d < B; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + (d -= g), + (y = 0), + (u = 11 + (127 & (h >>>= g))), + (h >>>= 7), + (d -= 7); + } + if (a.have + u > a.nlen + a.ndist) { + (t.msg = 'invalid bit length repeat'), (a.mode = 30); + break; + } + for (; u--; ) a.lens[a.have++] = y; + } + } + if (30 === a.mode) break; + if (0 === a.lens[256]) { + (t.msg = 'invalid code -- missing end-of-block'), + (a.mode = 30); + break; + } + if ( + ((a.lenbits = 9), + (z = { bits: a.lenbits }), + (x = O(D, a.lens, 0, a.nlen, a.lencode, 0, a.work, z)), + (a.lenbits = z.bits), + x) + ) { + (t.msg = 'invalid literal/lengths set'), (a.mode = 30); + break; + } + if ( + ((a.distbits = 6), + (a.distcode = a.distdyn), + (z = { bits: a.distbits }), + (x = O( + I, + a.lens, + a.nlen, + a.ndist, + a.distcode, + 0, + a.work, + z + )), + (a.distbits = z.bits), + x) + ) { + (t.msg = 'invalid distances set'), (a.mode = 30); + break; + } + if (((a.mode = 20), 6 === e)) break t; + case 20: + a.mode = 21; + case 21: + if (6 <= o && 258 <= l) { + (t.next_out = s), + (t.avail_out = l), + (t.next_in = r), + (t.avail_in = o), + (a.hold = h), + (a.bits = d), + N(t, _), + (s = t.next_out), + (n = t.output), + (l = t.avail_out), + (r = t.next_in), + (i = t.input), + (o = t.avail_in), + (h = a.hold), + (d = a.bits), + 12 === a.mode && (a.back = -1); + break; + } + for ( + a.back = 0; + (m = + ((S = a.lencode[h & ((1 << a.lenbits) - 1)]) >>> 16) & + 255), + (w = 65535 & S), + !((g = S >>> 24) <= d); + + ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if (m && 0 == (240 & m)) { + for ( + p = g, v = m, k = w; + (m = + ((S = + a.lencode[ + k + ((h & ((1 << (p + v)) - 1)) >> p) + ]) >>> + 16) & + 255), + (w = 65535 & S), + !(p + (g = S >>> 24) <= d); + + ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + (h >>>= p), (d -= p), (a.back += p); + } + if ( + ((h >>>= g), + (d -= g), + (a.back += g), + (a.length = w), + 0 === m) + ) { + a.mode = 26; + break; + } + if (32 & m) { + (a.back = -1), (a.mode = 12); + break; + } + if (64 & m) { + (t.msg = 'invalid literal/length code'), (a.mode = 30); + break; + } + (a.extra = 15 & m), (a.mode = 22); + case 22: + if (a.extra) { + for (B = a.extra; d < B; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + (a.length += h & ((1 << a.extra) - 1)), + (h >>>= a.extra), + (d -= a.extra), + (a.back += a.extra); + } + (a.was = a.length), (a.mode = 23); + case 23: + for ( + ; + (m = + ((S = a.distcode[h & ((1 << a.distbits) - 1)]) >>> 16) & + 255), + (w = 65535 & S), + !((g = S >>> 24) <= d); + + ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if (0 == (240 & m)) { + for ( + p = g, v = m, k = w; + (m = + ((S = + a.distcode[ + k + ((h & ((1 << (p + v)) - 1)) >> p) + ]) >>> + 16) & + 255), + (w = 65535 & S), + !(p + (g = S >>> 24) <= d); + + ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + (h >>>= p), (d -= p), (a.back += p); + } + if (((h >>>= g), (d -= g), (a.back += g), 64 & m)) { + (t.msg = 'invalid distance code'), (a.mode = 30); + break; + } + (a.offset = w), (a.extra = 15 & m), (a.mode = 24); + case 24: + if (a.extra) { + for (B = a.extra; d < B; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + (a.offset += h & ((1 << a.extra) - 1)), + (h >>>= a.extra), + (d -= a.extra), + (a.back += a.extra); + } + if (a.offset > a.dmax) { + (t.msg = 'invalid distance too far back'), (a.mode = 30); + break; + } + a.mode = 25; + case 25: + if (0 === l) break t; + if (((u = _ - l), a.offset > u)) { + if ((u = a.offset - u) > a.whave && a.sane) { + (t.msg = 'invalid distance too far back'), + (a.mode = 30); + break; + } + u > a.wnext + ? ((u -= a.wnext), (c = a.wsize - u)) + : (c = a.wnext - u), + u > a.length && (u = a.length), + (b = a.window); + } else (b = n), (c = s - a.offset), (u = a.length); + for ( + l < u && (u = l), l -= u, a.length -= u; + (n[s++] = b[c++]), --u; + + ); + 0 === a.length && (a.mode = 21); + break; + case 26: + if (0 === l) break t; + (n[s++] = a.length), l--, (a.mode = 21); + break; + case 27: + if (a.wrap) { + for (; d < 32; ) { + if (0 === o) break t; + o--, (h |= i[r++] << d), (d += 8); + } + if ( + ((_ -= l), + (t.total_out += _), + (a.total += _), + _ && + (t.adler = a.check = a.flags + ? C(a.check, n, _, s - _) + : R(a.check, n, _, s - _)), + (_ = l), + (a.flags ? h : L(h)) !== a.check) + ) { + (t.msg = 'incorrect data check'), (a.mode = 30); + break; + } + d = h = 0; + } + a.mode = 28; + case 28: + if (a.wrap && a.flags) { + for (; d < 32; ) { + if (0 === o) break t; + o--, (h += i[r++] << d), (d += 8); + } + if (h !== (4294967295 & a.total)) { + (t.msg = 'incorrect length check'), (a.mode = 30); + break; + } + d = h = 0; + } + a.mode = 29; + case 29: + x = 1; + break t; + case 30: + x = -3; + break t; + case 31: + return -4; + case 32: + default: + return T; + } + return ( + (t.next_out = s), + (t.avail_out = l), + (t.next_in = r), + (t.avail_in = o), + (a.hold = h), + (a.bits = d), + (a.wsize || + (_ !== t.avail_out && + a.mode < 30 && + (a.mode < 27 || 4 !== e))) && + j(t, t.output, t.next_out, _ - t.avail_out) + ? ((a.mode = 31), -4) + : ((f -= t.avail_in), + (_ -= t.avail_out), + (t.total_in += f), + (t.total_out += _), + (a.total += _), + a.wrap && + _ && + (t.adler = a.check = a.flags + ? C(a.check, n, _, t.next_out - _) + : R(a.check, n, _, t.next_out - _)), + (t.data_type = + a.bits + + (a.last ? 64 : 0) + + (12 === a.mode ? 128 : 0) + + (20 === a.mode || 15 === a.mode ? 256 : 0)), + ((0 === f && 0 === _) || 4 === e) && x === U && (x = -5), + x) + ); + }), + (a.inflateEnd = function(t) { + if (!t || !t.state) return T; + var e = t.state; + return e.window && (e.window = null), (t.state = null), U; + }), + (a.inflateGetHeader = function(t, e) { + var a; + return t && t.state + ? 0 == (2 & (a = t.state).wrap) + ? T + : (((a.head = e).done = !1), U) + : T; + }), + (a.inflateSetDictionary = function(t, e) { + var a, + i = e.length; + return t && t.state + ? 0 !== (a = t.state).wrap && 11 !== a.mode + ? T + : 11 === a.mode && R(1, e, i, 0) !== a.check + ? -3 + : j(t, e, i, i) + ? ((a.mode = 31), -4) + : ((a.havedict = 1), U) + : T; + }), + (a.inflateInfo = 'pako inflate (from Nodeca project)'); + }, + { + '../utils/common': 3, + './adler32': 5, + './crc32': 7, + './inffast': 10, + './inftrees': 12 + } + ], + 12: [ + function(t, e, a) { + 'use strict'; + var D = t('../utils/common'), + I = [ + 3, + 4, + 5, + 6, + 7, + 8, + 9, + 10, + 11, + 13, + 15, + 17, + 19, + 23, + 27, + 31, + 35, + 43, + 51, + 59, + 67, + 83, + 99, + 115, + 131, + 163, + 195, + 227, + 258, + 0, + 0 + ], + U = [ + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 16, + 17, + 17, + 17, + 17, + 18, + 18, + 18, + 18, + 19, + 19, + 19, + 19, + 20, + 20, + 20, + 20, + 21, + 21, + 21, + 21, + 16, + 72, + 78 + ], + T = [ + 1, + 2, + 3, + 4, + 5, + 7, + 9, + 13, + 17, + 25, + 33, + 49, + 65, + 97, + 129, + 193, + 257, + 385, + 513, + 769, + 1025, + 1537, + 2049, + 3073, + 4097, + 6145, + 8193, + 12289, + 16385, + 24577, + 0, + 0 + ], + F = [ + 16, + 16, + 16, + 16, + 17, + 17, + 18, + 18, + 19, + 19, + 20, + 20, + 21, + 21, + 22, + 22, + 23, + 23, + 24, + 24, + 25, + 25, + 26, + 26, + 27, + 27, + 28, + 28, + 29, + 29, + 64, + 64 + ]; + e.exports = function(t, e, a, i, n, r, s, o) { + var l, + h, + d, + f, + _, + u, + c, + b, + g, + m = o.bits, + w = 0, + p = 0, + v = 0, + k = 0, + y = 0, + x = 0, + z = 0, + B = 0, + S = 0, + E = 0, + A = null, + Z = 0, + R = new D.Buf16(16), + C = new D.Buf16(16), + N = null, + O = 0; + for (w = 0; w <= 15; w++) R[w] = 0; + for (p = 0; p < i; p++) R[e[a + p]]++; + for (y = m, k = 15; 1 <= k && 0 === R[k]; k--); + if ((k < y && (y = k), 0 === k)) + return (n[r++] = 20971520), (n[r++] = 20971520), (o.bits = 1), 0; + for (v = 1; v < k && 0 === R[v]; v++); + for (y < v && (y = v), w = B = 1; w <= 15; w++) + if (((B <<= 1), (B -= R[w]) < 0)) return -1; + if (0 < B && (0 === t || 1 !== k)) return -1; + for (C[1] = 0, w = 1; w < 15; w++) C[w + 1] = C[w] + R[w]; + for (p = 0; p < i; p++) 0 !== e[a + p] && (s[C[e[a + p]]++] = p); + if ( + (0 === t + ? ((A = N = s), (u = 19)) + : 1 === t + ? ((A = I), (Z -= 257), (N = U), (O -= 257), (u = 256)) + : ((A = T), (N = F), (u = -1)), + (w = v), + (_ = r), + (z = p = E = 0), + (d = -1), + (f = (S = 1 << (x = y)) - 1), + (1 === t && 852 < S) || (2 === t && 592 < S)) + ) + return 1; + for (;;) { + for ( + c = w - z, + s[p] < u + ? ((b = 0), (g = s[p])) + : s[p] > u + ? ((b = N[O + s[p]]), (g = A[Z + s[p]])) + : ((b = 96), (g = 0)), + l = 1 << (w - z), + v = h = 1 << x; + (n[_ + (E >> z) + (h -= l)] = (c << 24) | (b << 16) | g | 0), + 0 !== h; + + ); + for (l = 1 << (w - 1); E & l; ) l >>= 1; + if ( + (0 !== l ? ((E &= l - 1), (E += l)) : (E = 0), p++, 0 == --R[w]) + ) { + if (w === k) break; + w = e[a + s[p]]; + } + if (y < w && (E & f) !== d) { + for ( + 0 === z && (z = y), _ += v, B = 1 << (x = w - z); + x + z < k && !((B -= R[x + z]) <= 0); + + ) + x++, (B <<= 1); + if ( + ((S += 1 << x), (1 === t && 852 < S) || (2 === t && 592 < S)) + ) + return 1; + n[(d = E & f)] = (y << 24) | (x << 16) | (_ - r) | 0; + } + } + return ( + 0 !== E && (n[_ + E] = ((w - z) << 24) | (64 << 16) | 0), + (o.bits = y), + 0 + ); + }; + }, + { '../utils/common': 3 } + ], + 13: [ + function(t, e, a) { + 'use strict'; + e.exports = { + 2: 'need dictionary', + 1: 'stream end', + 0: '', + '-1': 'file error', + '-2': 'stream error', + '-3': 'data error', + '-4': 'insufficient memory', + '-5': 'buffer error', + '-6': 'incompatible version' + }; + }, + {} + ], + 14: [ + function(t, e, a) { + 'use strict'; + var l = t('../utils/common'), + o = 0, + h = 1; + function i(t) { + for (var e = t.length; 0 <= --e; ) t[e] = 0; + } + var d = 0, + s = 29, + f = 256, + _ = f + 1 + s, + u = 30, + c = 19, + g = 2 * _ + 1, + m = 15, + n = 16, + b = 7, + w = 256, + p = 16, + v = 17, + k = 18, + y = [ + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 0, + 1, + 1, + 1, + 1, + 2, + 2, + 2, + 2, + 3, + 3, + 3, + 3, + 4, + 4, + 4, + 4, + 5, + 5, + 5, + 5, + 0 + ], + x = [ + 0, + 0, + 0, + 0, + 1, + 1, + 2, + 2, + 3, + 3, + 4, + 4, + 5, + 5, + 6, + 6, + 7, + 7, + 8, + 8, + 9, + 9, + 10, + 10, + 11, + 11, + 12, + 12, + 13, + 13 + ], + z = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 2, 3, 7], + B = [ + 16, + 17, + 18, + 0, + 8, + 7, + 9, + 6, + 10, + 5, + 11, + 4, + 12, + 3, + 13, + 2, + 14, + 1, + 15 + ], + S = new Array(2 * (_ + 2)); + i(S); + var E = new Array(2 * u); + i(E); + var A = new Array(512); + i(A); + var Z = new Array(256); + i(Z); + var R = new Array(s); + i(R); + var C, + N, + O, + D = new Array(u); + function I(t, e, a, i, n) { + (this.static_tree = t), + (this.extra_bits = e), + (this.extra_base = a), + (this.elems = i), + (this.max_length = n), + (this.has_stree = t && t.length); + } + function r(t, e) { + (this.dyn_tree = t), (this.max_code = 0), (this.stat_desc = e); + } + function U(t) { + return t < 256 ? A[t] : A[256 + (t >>> 7)]; + } + function T(t, e) { + (t.pending_buf[t.pending++] = 255 & e), + (t.pending_buf[t.pending++] = (e >>> 8) & 255); + } + function F(t, e, a) { + t.bi_valid > n - a + ? ((t.bi_buf |= (e << t.bi_valid) & 65535), + T(t, t.bi_buf), + (t.bi_buf = e >> (n - t.bi_valid)), + (t.bi_valid += a - n)) + : ((t.bi_buf |= (e << t.bi_valid) & 65535), (t.bi_valid += a)); + } + function L(t, e, a) { + F(t, a[2 * e], a[2 * e + 1]); + } + function H(t, e) { + for (var a = 0; (a |= 1 & t), (t >>>= 1), (a <<= 1), 0 < --e; ); + return a >>> 1; + } + function j(t, e, a) { + var i, + n, + r = new Array(m + 1), + s = 0; + for (i = 1; i <= m; i++) r[i] = s = (s + a[i - 1]) << 1; + for (n = 0; n <= e; n++) { + var o = t[2 * n + 1]; + 0 !== o && (t[2 * n] = H(r[o]++, o)); + } + } + function K(t) { + var e; + for (e = 0; e < _; e++) t.dyn_ltree[2 * e] = 0; + for (e = 0; e < u; e++) t.dyn_dtree[2 * e] = 0; + for (e = 0; e < c; e++) t.bl_tree[2 * e] = 0; + (t.dyn_ltree[2 * w] = 1), + (t.opt_len = t.static_len = 0), + (t.last_lit = t.matches = 0); + } + function M(t) { + 8 < t.bi_valid + ? T(t, t.bi_buf) + : 0 < t.bi_valid && (t.pending_buf[t.pending++] = t.bi_buf), + (t.bi_buf = 0), + (t.bi_valid = 0); + } + function P(t, e, a, i) { + var n = 2 * e, + r = 2 * a; + return t[n] < t[r] || (t[n] === t[r] && i[e] <= i[a]); + } + function Y(t, e, a) { + for ( + var i = t.heap[a], n = a << 1; + n <= t.heap_len && + (n < t.heap_len && P(e, t.heap[n + 1], t.heap[n], t.depth) && n++, + !P(e, i, t.heap[n], t.depth)); + + ) + (t.heap[a] = t.heap[n]), (a = n), (n <<= 1); + t.heap[a] = i; + } + function q(t, e, a) { + var i, + n, + r, + s, + o = 0; + if (0 !== t.last_lit) + for ( + ; + (i = + (t.pending_buf[t.d_buf + 2 * o] << 8) | + t.pending_buf[t.d_buf + 2 * o + 1]), + (n = t.pending_buf[t.l_buf + o]), + o++, + 0 === i + ? L(t, n, e) + : (L(t, (r = Z[n]) + f + 1, e), + 0 !== (s = y[r]) && F(t, (n -= R[r]), s), + L(t, (r = U(--i)), a), + 0 !== (s = x[r]) && F(t, (i -= D[r]), s)), + o < t.last_lit; + + ); + L(t, w, e); + } + function G(t, e) { + var a, + i, + n, + r = e.dyn_tree, + s = e.stat_desc.static_tree, + o = e.stat_desc.has_stree, + l = e.stat_desc.elems, + h = -1; + for (t.heap_len = 0, t.heap_max = g, a = 0; a < l; a++) + 0 !== r[2 * a] + ? ((t.heap[++t.heap_len] = h = a), (t.depth[a] = 0)) + : (r[2 * a + 1] = 0); + for (; t.heap_len < 2; ) + (r[2 * (n = t.heap[++t.heap_len] = h < 2 ? ++h : 0)] = 1), + (t.depth[n] = 0), + t.opt_len--, + o && (t.static_len -= s[2 * n + 1]); + for (e.max_code = h, a = t.heap_len >> 1; 1 <= a; a--) Y(t, r, a); + for ( + n = l; + (a = t.heap[1]), + (t.heap[1] = t.heap[t.heap_len--]), + Y(t, r, 1), + (i = t.heap[1]), + (t.heap[--t.heap_max] = a), + (t.heap[--t.heap_max] = i), + (r[2 * n] = r[2 * a] + r[2 * i]), + (t.depth[n] = + (t.depth[a] >= t.depth[i] ? t.depth[a] : t.depth[i]) + 1), + (r[2 * a + 1] = r[2 * i + 1] = n), + (t.heap[1] = n++), + Y(t, r, 1), + 2 <= t.heap_len; + + ); + (t.heap[--t.heap_max] = t.heap[1]), + (function(t, e) { + var a, + i, + n, + r, + s, + o, + l = e.dyn_tree, + h = e.max_code, + d = e.stat_desc.static_tree, + f = e.stat_desc.has_stree, + _ = e.stat_desc.extra_bits, + u = e.stat_desc.extra_base, + c = e.stat_desc.max_length, + b = 0; + for (r = 0; r <= m; r++) t.bl_count[r] = 0; + for ( + l[2 * t.heap[t.heap_max] + 1] = 0, a = t.heap_max + 1; + a < g; + a++ + ) + c < (r = l[2 * l[2 * (i = t.heap[a]) + 1] + 1] + 1) && + ((r = c), b++), + (l[2 * i + 1] = r), + h < i || + (t.bl_count[r]++, + (s = 0), + u <= i && (s = _[i - u]), + (o = l[2 * i]), + (t.opt_len += o * (r + s)), + f && (t.static_len += o * (d[2 * i + 1] + s))); + if (0 !== b) { + do { + for (r = c - 1; 0 === t.bl_count[r]; ) r--; + t.bl_count[r]--, + (t.bl_count[r + 1] += 2), + t.bl_count[c]--, + (b -= 2); + } while (0 < b); + for (r = c; 0 !== r; r--) + for (i = t.bl_count[r]; 0 !== i; ) + h < (n = t.heap[--a]) || + (l[2 * n + 1] !== r && + ((t.opt_len += (r - l[2 * n + 1]) * l[2 * n]), + (l[2 * n + 1] = r)), + i--); + } + })(t, e), + j(r, h, t.bl_count); + } + function X(t, e, a) { + var i, + n, + r = -1, + s = e[1], + o = 0, + l = 7, + h = 4; + for ( + 0 === s && ((l = 138), (h = 3)), + e[2 * (a + 1) + 1] = 65535, + i = 0; + i <= a; + i++ + ) + (n = s), + (s = e[2 * (i + 1) + 1]), + (++o < l && n === s) || + (o < h + ? (t.bl_tree[2 * n] += o) + : 0 !== n + ? (n !== r && t.bl_tree[2 * n]++, t.bl_tree[2 * p]++) + : o <= 10 + ? t.bl_tree[2 * v]++ + : t.bl_tree[2 * k]++, + (r = n), + (o = 0) === s + ? ((l = 138), (h = 3)) + : n === s + ? ((l = 6), (h = 3)) + : ((l = 7), (h = 4))); + } + function W(t, e, a) { + var i, + n, + r = -1, + s = e[1], + o = 0, + l = 7, + h = 4; + for (0 === s && ((l = 138), (h = 3)), i = 0; i <= a; i++) + if (((n = s), (s = e[2 * (i + 1) + 1]), !(++o < l && n === s))) { + if (o < h) for (; L(t, n, t.bl_tree), 0 != --o; ); + else + 0 !== n + ? (n !== r && (L(t, n, t.bl_tree), o--), + L(t, p, t.bl_tree), + F(t, o - 3, 2)) + : o <= 10 + ? (L(t, v, t.bl_tree), F(t, o - 3, 3)) + : (L(t, k, t.bl_tree), F(t, o - 11, 7)); + (r = n), + (o = 0) === s + ? ((l = 138), (h = 3)) + : n === s + ? ((l = 6), (h = 3)) + : ((l = 7), (h = 4)); + } + } + i(D); + var J = !1; + function Q(t, e, a, i) { + var n, r, s, o; + F(t, (d << 1) + (i ? 1 : 0), 3), + (r = e), + (s = a), + (o = !0), + M((n = t)), + o && (T(n, s), T(n, ~s)), + l.arraySet(n.pending_buf, n.window, r, s, n.pending), + (n.pending += s); + } + (a._tr_init = function(t) { + J || + ((function() { + var t, + e, + a, + i, + n, + r = new Array(m + 1); + for (i = a = 0; i < s - 1; i++) + for (R[i] = a, t = 0; t < 1 << y[i]; t++) Z[a++] = i; + for (Z[a - 1] = i, i = n = 0; i < 16; i++) + for (D[i] = n, t = 0; t < 1 << x[i]; t++) A[n++] = i; + for (n >>= 7; i < u; i++) + for (D[i] = n << 7, t = 0; t < 1 << (x[i] - 7); t++) + A[256 + n++] = i; + for (e = 0; e <= m; e++) r[e] = 0; + for (t = 0; t <= 143; ) (S[2 * t + 1] = 8), t++, r[8]++; + for (; t <= 255; ) (S[2 * t + 1] = 9), t++, r[9]++; + for (; t <= 279; ) (S[2 * t + 1] = 7), t++, r[7]++; + for (; t <= 287; ) (S[2 * t + 1] = 8), t++, r[8]++; + for (j(S, _ + 1, r), t = 0; t < u; t++) + (E[2 * t + 1] = 5), (E[2 * t] = H(t, 5)); + (C = new I(S, y, f + 1, _, m)), + (N = new I(E, x, 0, u, m)), + (O = new I(new Array(0), z, 0, c, b)); + })(), + (J = !0)), + (t.l_desc = new r(t.dyn_ltree, C)), + (t.d_desc = new r(t.dyn_dtree, N)), + (t.bl_desc = new r(t.bl_tree, O)), + (t.bi_buf = 0), + (t.bi_valid = 0), + K(t); + }), + (a._tr_stored_block = Q), + (a._tr_flush_block = function(t, e, a, i) { + var n, + r, + s = 0; + 0 < t.level + ? (2 === t.strm.data_type && + (t.strm.data_type = (function(t) { + var e, + a = 4093624447; + for (e = 0; e <= 31; e++, a >>>= 1) + if (1 & a && 0 !== t.dyn_ltree[2 * e]) return o; + if ( + 0 !== t.dyn_ltree[18] || + 0 !== t.dyn_ltree[20] || + 0 !== t.dyn_ltree[26] + ) + return h; + for (e = 32; e < f; e++) + if (0 !== t.dyn_ltree[2 * e]) return h; + return o; + })(t)), + G(t, t.l_desc), + G(t, t.d_desc), + (s = (function(t) { + var e; + for ( + X(t, t.dyn_ltree, t.l_desc.max_code), + X(t, t.dyn_dtree, t.d_desc.max_code), + G(t, t.bl_desc), + e = c - 1; + 3 <= e && 0 === t.bl_tree[2 * B[e] + 1]; + e-- + ); + return (t.opt_len += 3 * (e + 1) + 5 + 5 + 4), e; + })(t)), + (n = (t.opt_len + 3 + 7) >>> 3), + (r = (t.static_len + 3 + 7) >>> 3) <= n && (n = r)) + : (n = r = a + 5), + a + 4 <= n && -1 !== e + ? Q(t, e, a, i) + : 4 === t.strategy || r === n + ? (F(t, 2 + (i ? 1 : 0), 3), q(t, S, E)) + : (F(t, 4 + (i ? 1 : 0), 3), + (function(t, e, a, i) { + var n; + for ( + F(t, e - 257, 5), F(t, a - 1, 5), F(t, i - 4, 4), n = 0; + n < i; + n++ + ) + F(t, t.bl_tree[2 * B[n] + 1], 3); + W(t, t.dyn_ltree, e - 1), W(t, t.dyn_dtree, a - 1); + })(t, t.l_desc.max_code + 1, t.d_desc.max_code + 1, s + 1), + q(t, t.dyn_ltree, t.dyn_dtree)), + K(t), + i && M(t); + }), + (a._tr_tally = function(t, e, a) { + return ( + (t.pending_buf[t.d_buf + 2 * t.last_lit] = (e >>> 8) & 255), + (t.pending_buf[t.d_buf + 2 * t.last_lit + 1] = 255 & e), + (t.pending_buf[t.l_buf + t.last_lit] = 255 & a), + t.last_lit++, + 0 === e + ? t.dyn_ltree[2 * a]++ + : (t.matches++, + e--, + t.dyn_ltree[2 * (Z[a] + f + 1)]++, + t.dyn_dtree[2 * U(e)]++), + t.last_lit === t.lit_bufsize - 1 + ); + }), + (a._tr_align = function(t) { + var e; + F(t, 2, 3), + L(t, w, S), + 16 === (e = t).bi_valid + ? (T(e, e.bi_buf), (e.bi_buf = 0), (e.bi_valid = 0)) + : 8 <= e.bi_valid && + ((e.pending_buf[e.pending++] = 255 & e.bi_buf), + (e.bi_buf >>= 8), + (e.bi_valid -= 8)); + }); + }, + { '../utils/common': 3 } + ], + 15: [ + function(t, e, a) { + 'use strict'; + e.exports = function() { + (this.input = null), + (this.next_in = 0), + (this.avail_in = 0), + (this.total_in = 0), + (this.output = null), + (this.next_out = 0), + (this.avail_out = 0), + (this.total_out = 0), + (this.msg = ''), + (this.state = null), + (this.data_type = 2), + (this.adler = 0); + }; + }, + {} + ], + '/': [ + function(t, e, a) { + 'use strict'; + var i = {}; + (0, t('./lib/utils/common').assign)( + i, + t('./lib/deflate'), + t('./lib/inflate'), + t('./lib/zlib/constants') + ), + (e.exports = i); + }, + { + './lib/deflate': 1, + './lib/inflate': 2, + './lib/utils/common': 3, + './lib/zlib/constants': 6 + } + ] + }, + {}, + [] + )('/'); +}); diff --git a/assets/libs/network/protocol/pako.min.js.meta b/assets/libs/network/protocol/pako.min.js.meta new file mode 100644 index 0000000..19c0b67 --- /dev/null +++ b/assets/libs/network/protocol/pako.min.js.meta @@ -0,0 +1,17 @@ +{ + "ver": "4.0.24", + "importer": "javascript", + "imported": true, + "uuid": "60e799a8-4bb9-4e3d-8b8c-ab86909f9eb8", + "files": [ + ".js" + ], + "subMetas": {}, + "userData": { + "isPlugin": true, + "loadPluginInWeb": true, + "loadPluginInNative": false, + "loadPluginInEditor": false, + "loadPluginInMiniGame": true + } +}