sonic-ws 2.0.0-fix → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ts/index.d.ts +0 -5
- package/dist/ts/native/wasm/node/README.md +6 -0
- package/dist/ts/native/wasm/node/package.json +13 -0
- package/dist/ts/native/wasm/node/sonic_ws_core.d.ts +53 -0
- package/dist/ts/native/wasm/node/sonic_ws_core.js +7 -0
- package/dist/ts/native/wasm/node/sonic_ws_core_bg.wasm +0 -0
- package/dist/ts/native/wasm/node/sonic_ws_core_bg.wasm.d.ts +37 -0
- package/dist/ts/native/wasm/pkg/README.md +6 -0
- package/dist/ts/native/wasm/pkg/package.json +19 -0
- package/dist/ts/native/wasm/pkg/sonic_ws_core.d.ts +53 -0
- package/dist/ts/native/wasm/pkg/sonic_ws_core.js +7 -0
- package/dist/ts/native/wasm/pkg/sonic_ws_core_bg.js +7 -0
- package/dist/ts/native/wasm/pkg/sonic_ws_core_bg.wasm +0 -0
- package/dist/ts/native/wasm/pkg/sonic_ws_core_bg.wasm.d.ts +37 -0
- package/dist/ts/native/wrapper.d.ts +0 -5
- package/dist/ts/version.d.ts +0 -5
- package/dist/ts/ws/Connection.d.ts +0 -5
- package/dist/ts/ws/PacketProcessor.d.ts +0 -5
- package/dist/ts/ws/PacketProcessor.js +1 -1
- package/dist/ts/ws/client/core/ClientCore.d.ts +0 -5
- package/dist/ts/ws/client/node/ClientNode.d.ts +0 -5
- package/dist/ts/ws/debug/DebugServer.d.ts +0 -5
- package/dist/ts/ws/packets/PacketType.d.ts +0 -5
- package/dist/ts/ws/packets/Packets.d.ts +0 -5
- package/dist/ts/ws/packets/Packets.js +1 -1
- package/dist/ts/ws/server/SonicWSConnection.d.ts +0 -5
- package/dist/ts/ws/server/SonicWSServer.d.ts +0 -5
- package/dist/ts/ws/util/BufferUtil.d.ts +0 -5
- package/dist/ts/ws/util/StringUtil.d.ts +0 -5
- package/dist/ts/ws/util/enums/EnumHandler.d.ts +0 -5
- package/dist/ts/ws/util/enums/EnumType.d.ts +0 -5
- package/dist/ts/ws/util/enums/EnumType.js +1 -1
- package/dist/ts/ws/util/packets/BatchHelper.d.ts +0 -5
- package/dist/ts/ws/util/packets/CompressionUtil.d.ts +0 -5
- package/dist/ts/ws/util/packets/CompressionUtil.js +1 -1
- package/dist/ts/ws/util/packets/HashUtil.d.ts +0 -5
- package/dist/ts/ws/util/packets/JSONUtil.d.ts +0 -5
- package/dist/ts/ws/util/packets/JSONUtil.js +1 -1
- package/dist/ts/ws/util/packets/PacketHolder.d.ts +0 -5
- package/dist/ts/ws/util/packets/PacketHolder.js +1 -1
- package/dist/ts/ws/util/packets/PacketUtils.d.ts +0 -5
- package/dist/ts/ws/util/packets/PacketUtils.js +1 -1
- package/dist/ts/ws/util/packets/RateHandler.d.ts +0 -5
- package/package.json +12 -4
package/dist/ts/index.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sonic-ws-core",
|
|
3
|
+
"description": "Language-neutral SonicWS packet codec core",
|
|
4
|
+
"version": "0.1.0",
|
|
5
|
+
"license": "SEE LICENSE IN ../../LICENSE",
|
|
6
|
+
"files": [
|
|
7
|
+
"sonic_ws_core_bg.wasm",
|
|
8
|
+
"sonic_ws_core.js",
|
|
9
|
+
"sonic_ws_core.d.ts"
|
|
10
|
+
],
|
|
11
|
+
"main": "sonic_ws_core.js",
|
|
12
|
+
"types": "sonic_ws_core.d.ts"
|
|
13
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
+
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
+
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function decodeBatch(data: Uint8Array, compressed: boolean, max: number, max_output_size?: number | null): Array<any>;
|
|
10
|
+
|
|
11
|
+
export function decodeBooleans(data: Uint8Array, count: number): Array<any>;
|
|
12
|
+
|
|
13
|
+
export function decodeFloats(value: number, data: Uint8Array): Array<any>;
|
|
14
|
+
|
|
15
|
+
export function decodeHex(data: Uint8Array): string;
|
|
16
|
+
|
|
17
|
+
export function decodeRaw(data: Uint8Array): Uint8Array;
|
|
18
|
+
|
|
19
|
+
export function decodeSigned(value: number, data: Uint8Array): Array<any>;
|
|
20
|
+
|
|
21
|
+
export function decodeStrings(value: number, data: Uint8Array): Array<any>;
|
|
22
|
+
|
|
23
|
+
export function decodeUnsigned(value: number, data: Uint8Array): Array<any>;
|
|
24
|
+
|
|
25
|
+
export function deflateRaw(data: Uint8Array): Uint8Array;
|
|
26
|
+
|
|
27
|
+
export function encodeBatch(values: Array<any>, compressed: boolean): Uint8Array;
|
|
28
|
+
|
|
29
|
+
export function encodeBooleans(values: Array<any>): Uint8Array;
|
|
30
|
+
|
|
31
|
+
export function encodeFloats(value: number, values: Array<any>): Uint8Array;
|
|
32
|
+
|
|
33
|
+
export function encodeHex(value: string): Uint8Array;
|
|
34
|
+
|
|
35
|
+
export function encodeRaw(data: Uint8Array): Uint8Array;
|
|
36
|
+
|
|
37
|
+
export function encodeSigned(value: number, values: Array<any>): Uint8Array;
|
|
38
|
+
|
|
39
|
+
export function encodeStrings(value: number, values: Array<any>): Uint8Array;
|
|
40
|
+
|
|
41
|
+
export function encodeUnsigned(value: number, values: Array<any>): Uint8Array;
|
|
42
|
+
|
|
43
|
+
export function frameObject(sectors: Array<any>): Uint8Array;
|
|
44
|
+
|
|
45
|
+
export function inflateRaw(data: Uint8Array, max_output_size?: number | null): Uint8Array;
|
|
46
|
+
|
|
47
|
+
export function unframeObject(data: Uint8Array, count: number): Array<any>;
|
|
48
|
+
|
|
49
|
+
export function validateEncoded(value: number, data: Uint8Array, min: number, max: number, compressed: boolean, batched: boolean, max_batch?: number | null): void;
|
|
50
|
+
|
|
51
|
+
export function validateEnum(data: Uint8Array, size: number, min: number, max: number): void;
|
|
52
|
+
|
|
53
|
+
export function validateObject(data: Uint8Array, kinds: Array<any>, mins: Array<any>, maxes: Array<any>, enum_sizes: Array<any>): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
+
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
+
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
function e(e,n){return e>>>=0,c().subarray(e/1,e/1+n)}exports.decodeBatch=function(e,n,t,o){const r=b.decodeBatch(e,n,t,i(o)?Number.MAX_SAFE_INTEGER:o>>>0);if(r[2])throw d(r[1]);return d(r[0])},exports.decodeBooleans=function(e,n){const t=b.decodeBooleans(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.decodeFloats=function(e,n){const t=b.decodeFloats(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.decodeHex=function(e){let n,t;try{const i=b.decodeHex(e);var r=i[0],c=i[1];if(i[3])throw r=0,c=0,d(i[2]);return n=r,t=c,o(r,c)}finally{b.__wbindgen_free(n,t,1)}},exports.decodeRaw=function(e){const n=b.decodeRaw(e);if(n[2])throw d(n[1]);return d(n[0])},exports.decodeSigned=function(e,n){const t=b.decodeSigned(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.decodeStrings=function(e,n){const t=b.decodeStrings(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.decodeUnsigned=function(e,n){const t=b.decodeUnsigned(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.deflateRaw=function(e){const n=b.deflateRaw(e);if(n[2])throw d(n[1]);return d(n[0])},exports.encodeBatch=function(e,n){const t=b.encodeBatch(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.encodeBooleans=function(e){const n=b.encodeBooleans(e);if(n[2])throw d(n[1]);return d(n[0])},exports.encodeFloats=function(e,n){const t=b.encodeFloats(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.encodeHex=function(e){const n=_(e,b.__wbindgen_malloc,b.__wbindgen_realloc),t=s,o=b.encodeHex(n,t);if(o[2])throw d(o[1]);return d(o[0])},exports.encodeRaw=function(e){const n=b.encodeRaw(e);if(n[2])throw d(n[1]);return d(n[0])},exports.encodeSigned=function(e,n){const t=b.encodeSigned(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.encodeStrings=function(e,n){const t=b.encodeStrings(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.encodeUnsigned=function(e,n){const t=b.encodeUnsigned(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.frameObject=function(e){const n=b.frameObject(e);if(n[2])throw d(n[1]);return d(n[0])},exports.inflateRaw=function(e,n){const t=b.inflateRaw(e,i(n)?Number.MAX_SAFE_INTEGER:n>>>0);if(t[2])throw d(t[1]);return d(t[0])},exports.unframeObject=function(e,n){const t=b.unframeObject(e,n);if(t[2])throw d(t[1]);return d(t[0])},exports.validateEncoded=function(e,n,t,o,r,c,_){const u=b.validateEncoded(e,n,t,o,r,c,i(_)?Number.MAX_SAFE_INTEGER:_>>>0);if(u[1])throw d(u[0])},exports.validateEnum=function(e,n,t,o){const r=b.validateEnum(e,n,t,o);if(r[1])throw d(r[0])},exports.validateObject=function(e,n,t,o,r){const c=b.validateObject(e,n,t,o,r);if(c[1])throw d(c[0])};let n=null;function t(){return(null===n||!0===n.buffer.detached||void 0===n.buffer.detached&&n.buffer!==b.memory.buffer)&&(n=new DataView(b.memory.buffer)),n}function o(e,n){return function(e,n){return u.decode(c().subarray(e,e+n))}(e>>>0,n)}let r=null;function c(){return null!==r&&0!==r.byteLength||(r=new Uint8Array(b.memory.buffer)),r}function i(e){return null==e}function _(e,n,t){if(void 0===t){const t=f.encode(e),o=n(t.length,1)>>>0;return c().subarray(o,o+t.length).set(t),s=t.length,o}let o=e.length,r=n(o,1)>>>0;const i=c();let _=0;for(;_<o;_++){const n=e.charCodeAt(_);if(n>127)break;i[r+_]=n}if(_!==o){0!==_&&(e=e.slice(_)),r=t(r,o,o=_+3*e.length,1)>>>0;const n=c().subarray(r+_,r+o);_+=f.encodeInto(e,n).written,r=t(r,o,_,1)>>>0}return s=_,r}function d(e){const n=b.__wbindgen_externrefs.get(e);return b.__externref_table_dealloc(e),n}let u=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});u.decode();const f=new TextEncoder;"encodeInto"in f||(f.encodeInto=function(e,n){const t=f.encode(e);return n.set(t),{read:e.length,written:t.length}});let s=0;const a=`${__dirname}/sonic_ws_core_bg.wasm`,l=require("fs").readFileSync(a),w=new WebAssembly.Module(l);let b=new WebAssembly.Instance(w,{__proto__:null,"./sonic_ws_core_bg.js":{__proto__:null,__wbg___wbindgen_boolean_get_fa956cfa2d1bd751:function(e){const n="boolean"==typeof e?e:void 0;return i(n)?16777215:n?1:0},__wbg___wbindgen_number_get_394265ed1e1b84ee:function(e,n){const o="number"==typeof n?n:void 0;t().setFloat64(e+8,i(o)?0:o,!0),t().setInt32(e+0,!i(o),!0)},__wbg___wbindgen_string_get_b0ca35b86a603356:function(e,n){const o="string"==typeof n?n:void 0;var r=i(o)?0:_(o,b.__wbindgen_malloc,b.__wbindgen_realloc),c=s;t().setInt32(e+4,c,!0),t().setInt32(e+0,r,!0)},__wbg___wbindgen_throw_344f42d3211c4765:function(e,n){throw new Error(o(e,n))},__wbg_get_unchecked_6e0ad6d2a41b06f6:function(e,n){return e[n>>>0]},__wbg_length_1f0964f4a5e2c6d8:function(e){return e.length},__wbg_length_370319915dc99107:function(e){return e.length},__wbg_new_32b398fb48b6d94a:function(){return new Array},__wbg_new_cd45aabdf6073e84:function(e){return new Uint8Array(e)},__wbg_new_from_slice_77cdfb7977362f3c:function(n,t){return new Uint8Array(e(n,t))},__wbg_prototypesetcall_4770620bbe4688a0:function(n,t,o){Uint8Array.prototype.set.call(e(n,t),o)},__wbg_push_d2ae3af0c1217ae6:function(e,n){return e.push(n)},__wbindgen_cast_0000000000000001:function(e){return e},__wbindgen_cast_0000000000000002:function(e,n){return o(e,n)},__wbindgen_init_externref_table:function(){const e=b.__wbindgen_externrefs,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,!0),e.set(n+3,!1)}}}).exports;b.__wbindgen_start();
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
+
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
+
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const memory: WebAssembly.Memory;
|
|
9
|
+
export const decodeBatch: (a: any, b: number, c: number, d: number) => [number, number, number];
|
|
10
|
+
export const decodeBooleans: (a: any, b: number) => [number, number, number];
|
|
11
|
+
export const decodeFloats: (a: number, b: any) => [number, number, number];
|
|
12
|
+
export const decodeHex: (a: any) => [number, number, number, number];
|
|
13
|
+
export const decodeRaw: (a: any) => [number, number, number];
|
|
14
|
+
export const decodeSigned: (a: number, b: any) => [number, number, number];
|
|
15
|
+
export const decodeStrings: (a: number, b: any) => [number, number, number];
|
|
16
|
+
export const decodeUnsigned: (a: number, b: any) => [number, number, number];
|
|
17
|
+
export const deflateRaw: (a: any) => [number, number, number];
|
|
18
|
+
export const encodeBatch: (a: any, b: number) => [number, number, number];
|
|
19
|
+
export const encodeBooleans: (a: any) => [number, number, number];
|
|
20
|
+
export const encodeFloats: (a: number, b: any) => [number, number, number];
|
|
21
|
+
export const encodeHex: (a: number, b: number) => [number, number, number];
|
|
22
|
+
export const encodeRaw: (a: any) => [number, number, number];
|
|
23
|
+
export const encodeSigned: (a: number, b: any) => [number, number, number];
|
|
24
|
+
export const encodeStrings: (a: number, b: any) => [number, number, number];
|
|
25
|
+
export const encodeUnsigned: (a: number, b: any) => [number, number, number];
|
|
26
|
+
export const frameObject: (a: any) => [number, number, number];
|
|
27
|
+
export const inflateRaw: (a: any, b: number) => [number, number, number];
|
|
28
|
+
export const unframeObject: (a: any, b: number) => [number, number, number];
|
|
29
|
+
export const validateEncoded: (a: number, b: any, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
30
|
+
export const validateEnum: (a: any, b: number, c: number, d: number) => [number, number];
|
|
31
|
+
export const validateObject: (a: any, b: any, c: any, d: any, e: any) => [number, number];
|
|
32
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
33
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
34
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
35
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
36
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
37
|
+
export const __wbindgen_start: () => void;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "sonic-ws-core",
|
|
3
|
+
"type": "module",
|
|
4
|
+
"description": "Language-neutral SonicWS packet codec core",
|
|
5
|
+
"version": "0.1.0",
|
|
6
|
+
"license": "SEE LICENSE IN ../../LICENSE",
|
|
7
|
+
"files": [
|
|
8
|
+
"sonic_ws_core_bg.wasm",
|
|
9
|
+
"sonic_ws_core.js",
|
|
10
|
+
"sonic_ws_core_bg.js",
|
|
11
|
+
"sonic_ws_core.d.ts"
|
|
12
|
+
],
|
|
13
|
+
"main": "sonic_ws_core.js",
|
|
14
|
+
"types": "sonic_ws_core.d.ts",
|
|
15
|
+
"sideEffects": [
|
|
16
|
+
"./sonic_ws_core.js",
|
|
17
|
+
"./snippets/*"
|
|
18
|
+
]
|
|
19
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
+
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
+
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
export function decodeBatch(data: Uint8Array, compressed: boolean, max: number, max_output_size?: number | null): Array<any>;
|
|
10
|
+
|
|
11
|
+
export function decodeBooleans(data: Uint8Array, count: number): Array<any>;
|
|
12
|
+
|
|
13
|
+
export function decodeFloats(value: number, data: Uint8Array): Array<any>;
|
|
14
|
+
|
|
15
|
+
export function decodeHex(data: Uint8Array): string;
|
|
16
|
+
|
|
17
|
+
export function decodeRaw(data: Uint8Array): Uint8Array;
|
|
18
|
+
|
|
19
|
+
export function decodeSigned(value: number, data: Uint8Array): Array<any>;
|
|
20
|
+
|
|
21
|
+
export function decodeStrings(value: number, data: Uint8Array): Array<any>;
|
|
22
|
+
|
|
23
|
+
export function decodeUnsigned(value: number, data: Uint8Array): Array<any>;
|
|
24
|
+
|
|
25
|
+
export function deflateRaw(data: Uint8Array): Uint8Array;
|
|
26
|
+
|
|
27
|
+
export function encodeBatch(values: Array<any>, compressed: boolean): Uint8Array;
|
|
28
|
+
|
|
29
|
+
export function encodeBooleans(values: Array<any>): Uint8Array;
|
|
30
|
+
|
|
31
|
+
export function encodeFloats(value: number, values: Array<any>): Uint8Array;
|
|
32
|
+
|
|
33
|
+
export function encodeHex(value: string): Uint8Array;
|
|
34
|
+
|
|
35
|
+
export function encodeRaw(data: Uint8Array): Uint8Array;
|
|
36
|
+
|
|
37
|
+
export function encodeSigned(value: number, values: Array<any>): Uint8Array;
|
|
38
|
+
|
|
39
|
+
export function encodeStrings(value: number, values: Array<any>): Uint8Array;
|
|
40
|
+
|
|
41
|
+
export function encodeUnsigned(value: number, values: Array<any>): Uint8Array;
|
|
42
|
+
|
|
43
|
+
export function frameObject(sectors: Array<any>): Uint8Array;
|
|
44
|
+
|
|
45
|
+
export function inflateRaw(data: Uint8Array, max_output_size?: number | null): Uint8Array;
|
|
46
|
+
|
|
47
|
+
export function unframeObject(data: Uint8Array, count: number): Array<any>;
|
|
48
|
+
|
|
49
|
+
export function validateEncoded(value: number, data: Uint8Array, min: number, max: number, compressed: boolean, batched: boolean, max_batch?: number | null): void;
|
|
50
|
+
|
|
51
|
+
export function validateEnum(data: Uint8Array, size: number, min: number, max: number): void;
|
|
52
|
+
|
|
53
|
+
export function validateObject(data: Uint8Array, kinds: Array<any>, mins: Array<any>, maxes: Array<any>, enum_sizes: Array<any>): void;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
+
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
+
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
import*as e from"./sonic_ws_core_bg.wasm";import{__wbg_set_wasm as d}from"./sonic_ws_core_bg.js";d(e),e.__wbindgen_start();export{decodeBatch,decodeBooleans,decodeFloats,decodeHex,decodeRaw,decodeSigned,decodeStrings,decodeUnsigned,deflateRaw,encodeBatch,encodeBooleans,encodeFloats,encodeHex,encodeRaw,encodeSigned,encodeStrings,encodeUnsigned,frameObject,inflateRaw,unframeObject,validateEncoded,validateEnum,validateObject}from"./sonic_ws_core_bg.js";
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
+
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
+
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
export function decodeBatch(e,n,t,o){const r=w.decodeBatch(e,n,t,i(o)?Number.MAX_SAFE_INTEGER:o>>>0);if(r[2])throw f(r[1]);return f(r[0])}export function decodeBooleans(e,n){const t=w.decodeBooleans(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function decodeFloats(e,n){const t=w.decodeFloats(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function decodeHex(e){let n,t;try{const i=w.decodeHex(e);var r=i[0],c=i[1];if(i[3])throw r=0,c=0,f(i[2]);return n=r,t=c,o(r,c)}finally{w.__wbindgen_free(n,t,1)}}export function decodeRaw(e){const n=w.decodeRaw(e);if(n[2])throw f(n[1]);return f(n[0])}export function decodeSigned(e,n){const t=w.decodeSigned(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function decodeStrings(e,n){const t=w.decodeStrings(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function decodeUnsigned(e,n){const t=w.decodeUnsigned(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function deflateRaw(e){const n=w.deflateRaw(e);if(n[2])throw f(n[1]);return f(n[0])}export function encodeBatch(e,n){const t=w.encodeBatch(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function encodeBooleans(e){const n=w.encodeBooleans(e);if(n[2])throw f(n[1]);return f(n[0])}export function encodeFloats(e,n){const t=w.encodeFloats(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function encodeHex(e){const n=d(e,w.__wbindgen_malloc,w.__wbindgen_realloc),t=l,o=w.encodeHex(n,t);if(o[2])throw f(o[1]);return f(o[0])}export function encodeRaw(e){const n=w.encodeRaw(e);if(n[2])throw f(n[1]);return f(n[0])}export function encodeSigned(e,n){const t=w.encodeSigned(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function encodeStrings(e,n){const t=w.encodeStrings(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function encodeUnsigned(e,n){const t=w.encodeUnsigned(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function frameObject(e){const n=w.frameObject(e);if(n[2])throw f(n[1]);return f(n[0])}export function inflateRaw(e,n){const t=w.inflateRaw(e,i(n)?Number.MAX_SAFE_INTEGER:n>>>0);if(t[2])throw f(t[1]);return f(t[0])}export function unframeObject(e,n){const t=w.unframeObject(e,n);if(t[2])throw f(t[1]);return f(t[0])}export function validateEncoded(e,n,t,o,r,c,d){const u=w.validateEncoded(e,n,t,o,r,c,i(d)?Number.MAX_SAFE_INTEGER:d>>>0);if(u[1])throw f(u[0])}export function validateEnum(e,n,t,o){const r=w.validateEnum(e,n,t,o);if(r[1])throw f(r[0])}export function validateObject(e,n,t,o,r){const c=w.validateObject(e,n,t,o,r);if(c[1])throw f(c[0])}export function __wbg___wbindgen_boolean_get_fa956cfa2d1bd751(e){const n="boolean"==typeof e?e:void 0;return i(n)?16777215:n?1:0}export function __wbg___wbindgen_number_get_394265ed1e1b84ee(e,n){const o="number"==typeof n?n:void 0;t().setFloat64(e+8,i(o)?0:o,!0),t().setInt32(e+0,!i(o),!0)}export function __wbg___wbindgen_string_get_b0ca35b86a603356(e,n){const o="string"==typeof n?n:void 0;var r=i(o)?0:d(o,w.__wbindgen_malloc,w.__wbindgen_realloc),c=l;t().setInt32(e+4,c,!0),t().setInt32(e+0,r,!0)}export function __wbg___wbindgen_throw_344f42d3211c4765(e,n){throw new Error(o(e,n))}export function __wbg_get_unchecked_6e0ad6d2a41b06f6(e,n){return e[n>>>0]}export function __wbg_length_1f0964f4a5e2c6d8(e){return e.length}export function __wbg_length_370319915dc99107(e){return e.length}export function __wbg_new_32b398fb48b6d94a(){return new Array}export function __wbg_new_cd45aabdf6073e84(e){return new Uint8Array(e)}export function __wbg_new_from_slice_77cdfb7977362f3c(n,t){return new Uint8Array(e(n,t))}export function __wbg_prototypesetcall_4770620bbe4688a0(n,t,o){Uint8Array.prototype.set.call(e(n,t),o)}export function __wbg_push_d2ae3af0c1217ae6(e,n){return e.push(n)}export function __wbindgen_cast_0000000000000001(e){return e}export function __wbindgen_cast_0000000000000002(e,n){return o(e,n)}export function __wbindgen_init_externref_table(){const e=w.__wbindgen_externrefs,n=e.grow(4);e.set(0,void 0),e.set(n+0,void 0),e.set(n+1,null),e.set(n+2,!0),e.set(n+3,!1)}function e(e,n){return e>>>=0,c().subarray(e/1,e/1+n)}let n=null;function t(){return(null===n||!0===n.buffer.detached||void 0===n.buffer.detached&&n.buffer!==w.memory.buffer)&&(n=new DataView(w.memory.buffer)),n}function o(e,n){return function(e,n){a+=n,a>=_&&(u=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0}),u.decode(),a=n);return u.decode(c().subarray(e,e+n))}(e>>>0,n)}let r=null;function c(){return null!==r&&0!==r.byteLength||(r=new Uint8Array(w.memory.buffer)),r}function i(e){return null==e}function d(e,n,t){if(void 0===t){const t=s.encode(e),o=n(t.length,1)>>>0;return c().subarray(o,o+t.length).set(t),l=t.length,o}let o=e.length,r=n(o,1)>>>0;const i=c();let d=0;for(;d<o;d++){const n=e.charCodeAt(d);if(n>127)break;i[r+d]=n}if(d!==o){0!==d&&(e=e.slice(d)),r=t(r,o,o=d+3*e.length,1)>>>0;const n=c().subarray(r+d,r+o);d+=s.encodeInto(e,n).written,r=t(r,o,d,1)>>>0}return l=d,r}function f(e){const n=w.__wbindgen_externrefs.get(e);return w.__externref_table_dealloc(e),n}let u=new TextDecoder("utf-8",{ignoreBOM:!0,fatal:!0});u.decode();const _=2146435072;let a=0;const s=new TextEncoder;"encodeInto"in s||(s.encodeInto=function(e,n){const t=s.encode(e);return n.set(t),{read:e.length,written:t.length}});let w,l=0;export function __wbg_set_wasm(e){w=e}
|
|
Binary file
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
+
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
+
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
+
*/
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
export const memory: WebAssembly.Memory;
|
|
9
|
+
export const decodeBatch: (a: any, b: number, c: number, d: number) => [number, number, number];
|
|
10
|
+
export const decodeBooleans: (a: any, b: number) => [number, number, number];
|
|
11
|
+
export const decodeFloats: (a: number, b: any) => [number, number, number];
|
|
12
|
+
export const decodeHex: (a: any) => [number, number, number, number];
|
|
13
|
+
export const decodeRaw: (a: any) => [number, number, number];
|
|
14
|
+
export const decodeSigned: (a: number, b: any) => [number, number, number];
|
|
15
|
+
export const decodeStrings: (a: number, b: any) => [number, number, number];
|
|
16
|
+
export const decodeUnsigned: (a: number, b: any) => [number, number, number];
|
|
17
|
+
export const deflateRaw: (a: any) => [number, number, number];
|
|
18
|
+
export const encodeBatch: (a: any, b: number) => [number, number, number];
|
|
19
|
+
export const encodeBooleans: (a: any) => [number, number, number];
|
|
20
|
+
export const encodeFloats: (a: number, b: any) => [number, number, number];
|
|
21
|
+
export const encodeHex: (a: number, b: number) => [number, number, number];
|
|
22
|
+
export const encodeRaw: (a: any) => [number, number, number];
|
|
23
|
+
export const encodeSigned: (a: number, b: any) => [number, number, number];
|
|
24
|
+
export const encodeStrings: (a: number, b: any) => [number, number, number];
|
|
25
|
+
export const encodeUnsigned: (a: number, b: any) => [number, number, number];
|
|
26
|
+
export const frameObject: (a: any) => [number, number, number];
|
|
27
|
+
export const inflateRaw: (a: any, b: number) => [number, number, number];
|
|
28
|
+
export const unframeObject: (a: any, b: number) => [number, number, number];
|
|
29
|
+
export const validateEncoded: (a: number, b: any, c: number, d: number, e: number, f: number, g: number) => [number, number];
|
|
30
|
+
export const validateEnum: (a: any, b: number, c: number, d: number) => [number, number];
|
|
31
|
+
export const validateObject: (a: any, b: any, c: any, d: any, e: any) => [number, number];
|
|
32
|
+
export const __wbindgen_malloc: (a: number, b: number) => number;
|
|
33
|
+
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
|
34
|
+
export const __wbindgen_externrefs: WebAssembly.Table;
|
|
35
|
+
export const __externref_table_dealloc: (a: number) => void;
|
|
36
|
+
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
|
37
|
+
export const __wbindgen_start: () => void;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
package/dist/ts/version.d.ts
CHANGED
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* See LICENSE for personal, non-commercial license terms.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.MiddlewareHolder=void 0
|
|
7
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.MiddlewareHolder=void 0;exports.MiddlewareHolder=class{middlewares=[];addMiddleware(e){this.middlewares.push(e);const r=e;try{"function"==typeof r.init&&r.init(this)}catch(e){console.warn("Middleware init threw an error:",e)}}async callMiddleware(e,...r){let t=!1;for(const d of this.middlewares){const i=d[e];if(i)try{await i(...r)&&(t=!0)}catch(r){console.warn(`Middleware ${String(e)} threw an error:`,r)}}return t}};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* See LICENSE for personal, non-commercial license terms.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.PacketSchema=exports.Packet=void 0;const t=require("../util/enums/EnumHandler"),e=require("../util/enums/EnumType"),a=require("../util/packets/CompressionUtil"),i=require("../util/packets/PacketUtils"),s=require("./PacketType"),r=require("../util/StringUtil"),n=require("../../native/wrapper"),c=require("../util/packets/JSONUtil");class h{defaultEnabled;tag;maxSize;minSize;type;enumData;dataMax;dataMin;dataBatching;maxBatchSize;dontSpread;autoFlatten;rateLimit;async;rereference;gzipCompression;object;client;processReceive;processSend;validate;customValidator;lastReceived={};lastSent={};constructor(t,e,a,i,r){if(this.tag=t,this.defaultEnabled=i,this.client=r,this.async=e.async,this.enumData=e.enumData,this.rateLimit=e.rateLimit,this.dontSpread=e.dontSpread,this.autoFlatten=e.autoFlatten,this.rereference=e.rereference,this.dataBatching=e.dataBatching,this.maxBatchSize=r?1/0:e.maxBatchSize,this.gzipCompression=e.gzipCompression,this.object=e.object,this.type=e.type,this.dataMax=e.dataMax,this.dataMin=e.dataMin,e.testObject(this)){this.maxSize=this.minSize=this.type.length;for(let t=0;t<this.type.length;t++)this.type[t]==s.PacketType.NONE&&(this.dataMax[t]=this.dataMin[t]=0);const t={types:this.type,dataMins:this.dataMin,dataMaxes:this.dataMax,enumData:this.enumData};this.processReceive=e=>(0,n.decodeNativeObject)(t,e).map((t,e)=>this.type[e]===s.PacketType.JSON?(0,c.decompressJSON)(t):t),this.processSend=async e=>{let a=0;const i=e.map((t,e)=>{if(this.type[e]===s.PacketType.JSON)return(0,c.compressJSON)(t);if(this.type[e]!==s.PacketType.ENUMS)return t;const i=this.enumData[a++];return(Array.isArray(t)?t:[t]).map(t=>{if(!Number.isInteger(t)||t<0||t>=i.values.length)throw new Error(`Invalid wrapped enum index: ${t}`);return i.values[t]})});return(0,n.encodeNativeObject)(t,i)},this.validate=async e=>(
|
|
7
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.PacketSchema=exports.Packet=void 0;const t=require("../util/enums/EnumHandler"),e=require("../util/enums/EnumType"),a=require("../util/packets/CompressionUtil"),i=require("../util/packets/PacketUtils"),s=require("./PacketType"),r=require("../util/StringUtil"),n=require("../../native/wrapper"),c=require("../util/packets/JSONUtil");class h{defaultEnabled;tag;maxSize;minSize;type;enumData;dataMax;dataMin;dataBatching;maxBatchSize;dontSpread;autoFlatten;rateLimit;async;rereference;gzipCompression;object;client;processReceive;processSend;validate;customValidator;lastReceived={};lastSent={};constructor(t,e,a,i,r){if(this.tag=t,this.defaultEnabled=i,this.client=r,this.async=e.async,this.enumData=e.enumData,this.rateLimit=e.rateLimit,this.dontSpread=e.dontSpread,this.autoFlatten=e.autoFlatten,this.rereference=e.rereference,this.dataBatching=e.dataBatching,this.maxBatchSize=r?1/0:e.maxBatchSize,this.gzipCompression=e.gzipCompression,this.object=e.object,this.type=e.type,this.dataMax=e.dataMax,this.dataMin=e.dataMin,e.testObject(this)){this.maxSize=this.minSize=this.type.length;for(let t=0;t<this.type.length;t++)this.type[t]==s.PacketType.NONE&&(this.dataMax[t]=this.dataMin[t]=0);const t={types:this.type,dataMins:this.dataMin,dataMaxes:this.dataMax,enumData:this.enumData};this.processReceive=e=>(0,n.decodeNativeObject)(t,e).map((t,e)=>this.type[e]===s.PacketType.JSON?(0,c.decompressJSON)(t):t),this.processSend=async e=>{let a=0;const i=e.map((t,e)=>{if(this.type[e]===s.PacketType.JSON)return(0,c.compressJSON)(t);if(this.type[e]!==s.PacketType.ENUMS)return t;const i=this.enumData[a++];return(Array.isArray(t)?t:[t]).map(t=>{if(!Number.isInteger(t)||t<0||t>=i.values.length)throw new Error(`Invalid wrapped enum index: ${t}`);return i.values[t]})});return(0,n.encodeNativeObject)(t,i)},this.validate=async e=>{(0,n.validateNativeObject)(t,e);return(0,n.decodeNativeObject)(t,e).forEach((t,e)=>{if(this.type[e]!==s.PacketType.JSON)return;const a=(0,c.decompressJSON)(t),i=Array.isArray(a)?a.length:1;if(i<this.dataMin[e]||i>this.dataMax[e])throw new Error("JSON value count is outside schema limits")}),[e,!0]}}else{{this.maxSize=this.dataMax,this.minSize=this.dataMin,this.type==s.PacketType.NONE&&(this.dataMax=this.dataMin=0);const t=this.enumData[0];this.processReceive=e=>this.type===s.PacketType.JSON?(0,c.decompressJSON)(e):(0,n.decodeNative)(this.type,e,this.dataMax,t),this.processSend=async e=>{let a;if(this.type===s.PacketType.JSON)a=(0,c.compressJSON)(e);else if(this.type===s.PacketType.ENUMS)a=Uint8Array.from(e);else{const i=this.type===s.PacketType.RAW&&1===e.length&&e[0]instanceof Uint8Array?e[0]:e;a=(0,n.encodeNative)(this.type,i,t)}return this.gzipCompression&&0===this.dataBatching?(0,n.deflateNative)(a):a},this.validate=async e=>{const a=this.gzipCompression&&0===this.dataBatching?(0,n.inflateNative)(e):e;if(this.type===s.PacketType.JSON){const t=(0,c.decompressJSON)(a),e=Array.isArray(t)?t.length:1;if(e<this.dataMin||e>this.dataMax)throw new Error("JSON value count is outside schema limits")}else(0,n.validateNative)(this.type,a,this.dataMin,this.dataMax,{enumData:t});return[a,!0]}}}this.customValidator=a}async listen(t,e){try{const[a,s]=await this.validate(t);if(!this.client&&!1===s)return"Invalid packet";const r=this.processReceive(a,s),n=this.autoFlatten?(0,i.UnFlattenData)(r):r;if(null!=this.customValidator)if(this.dontSpread){if(!this.customValidator(e,n))return"Didn't pass custom validator"}else if(!this.customValidator(e,...n))return"Didn't pass custom validator";return[n,!this.dontSpread]}catch(t){return console.error("There was an error processing the packet! This is probably my fault... report at https://github.com/liwybloc/sonic-ws",t),"Error: "+t}}serialize(){const t=[this.tag.length,...(0,r.processCharCodes)(this.tag),(0,a.compressBools)([this.dontSpread,this.async,this.object,this.autoFlatten,this.gzipCompression,this.rereference]),this.dataBatching,this.enumData.length,...this.enumData.map(t=>t.serialize()).flat()];return this.object?[...t,this.maxSize,...this.dataMax.map(a.convertVarInt).flat(),...this.dataMin.map(a.convertVarInt).flat(),...this.type]:[...t,...(0,a.convertVarInt)(this.dataMax),...(0,a.convertVarInt)(this.dataMin),this.type]}static readVarInts(t,e,i){const s=[];for(let r=0;r<i;r++){const[i,r]=(0,a.readVarInt)(t,e);e=i,s.push(r)}return[s,e]}static deserialize(i,n,c){const o=n,d=i[n++],l=(0,r.as8String)(i.slice(n,n+=d)),[u,m,y,S,f,M]=(0,a.decompressBools)(i[n++]),g=i[n++],N=i[n++],v=[];for(let a=0;a<N;a++){const a=i[n++],s=(0,r.as8String)(i.slice(n,n+=a)),c=i[n++],h=[];for(let t=0;t<c;t++){const t=i[n++],a=i[n++],s=(0,r.as8String)(i.slice(n,n+=t));h.push(e.TYPE_CONVERSION_MAP[a](s))}v.push((0,t.DefineEnum)(s,h))}if(y){const t=i[n++],[e,a]=this.readVarInts(i,n,t);n=a;const[r,d]=this.readVarInts(i,n,t);n=d;const y=Array.from(i.slice(n,n+=t));let M=0;const N=y.map(t=>t==s.PacketType.ENUMS?v[M++]:t),x=new p(!0,N,m,r,e,-1,u,S,!1,g,-1,f);return[new h(l,x,null,!1,c),n-o]}const[x,k]=(0,a.readVarInt)(i,n);n=x;const[O,z]=(0,a.readVarInt)(i,n);n=O;const P=i[n++],b=P==s.PacketType.ENUMS?v[0]:P,E=new p(!1,b,m,z,k,-1,u,!1,M,g,-1,f);return[new h(l,E,null,!1,c),n-o]}static deserializeAll(t,e){const a=[];let i=0;for(;i<t.length;){const[s,r]=this.deserialize(t,i,e);a.push(s),i+=r}return a}}exports.Packet=h;const o=(t,a)=>t instanceof e.EnumPackage?(a.push(t),s.PacketType.ENUMS):t;class p{type;enumData=[];dataMax;dataMin;dataBatching;maxBatchSize;rateLimit;dontSpread=!1;autoFlatten=!1;async=!1;rereference=!1;gzipCompression=!1;object;constructor(t,e,a,i,s,r,n,c,h,p,d,l){this.object=t,this.async=a,this.dataMin=i,this.dataMax=s,this.rateLimit=r,this.dontSpread=n,this.autoFlatten=c,this.rereference=h,this.dataBatching=p,this.maxBatchSize=d,this.gzipCompression=l,this.type=t?e.map(t=>o(t,this.enumData)):o(e,this.enumData)}testObject(t){return this.object}}exports.PacketSchema=p;
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* See LICENSE for personal, non-commercial license terms.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.EnumPackage=exports.TYPE_CONVERSION_MAP=void 0;const e=require("../StringUtil"),t=require("./EnumHandler"),r={string:0,number:1,boolean:2,undefined:3,object:4};function n(e){const t=typeof e;if(!(t in r)&&null!=e)throw new Error(`Cannot serialize type "${t}" in an enum!`);return r[t]}exports.TYPE_CONVERSION_MAP={0:e=>e,1:e=>parseFloat(e),2:e=>"true"==e,3:()=>{},4:()=>null}
|
|
7
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.EnumPackage=exports.TYPE_CONVERSION_MAP=void 0;const e=require("../StringUtil"),t=require("./EnumHandler"),r={string:0,number:1,boolean:2,undefined:3,object:4};function n(e){const t=typeof e;if(!(t in r)&&null!=e)throw new Error(`Cannot serialize type "${t}" in an enum!`);return r[t]}exports.TYPE_CONVERSION_MAP={0:e=>e,1:e=>parseFloat(e),2:e=>"true"==e,3:()=>{},4:()=>null};exports.EnumPackage=class{tag;values;constructor(e,t){this.tag=e,this.values=t,this.wrap=this.wrap.bind(this)}serialize(){const t=(0,e.processCharCodes)(this.tag);return[this.tag.length,...t,this.values.length,...this.values.map(t=>[String(t).length,n(t),...(0,e.processCharCodes)(String(t))]).flat()]}wrap(e){return(0,t.WrapEnum)(this.tag,e)}};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* See LICENSE for personal, non-commercial license terms.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.decompressBools=exports.compressBools=exports.EMPTY_UINT8=exports.MAX_UVARINT=exports.MAX_BYTE=void 0,exports.convertVarInt=function(e){if(!Number.isSafeInteger(e)||e<0||e>exports.MAX_UVARINT)throw new Error(`Variable Ints must be within range 0 and ${exports.MAX_UVARINT}: ${e}`);const r=[];do{let o=e%128;(e=Math.floor(e/128))>0&&(o|=128),r.push(o)}while(e>0);return r},exports.readVarInt=function(e,r){let o=0,t=1;for(let s=0;s<8;s++){if(r>=e.length)throw new Error("Truncated variable integer");const s=e[r++];if(o+=(127&s)*t,!(128&s))return[r,o];t*=128}throw new Error("Variable integer is too long")},exports.MAX_BYTE=255,exports.MAX_UVARINT=128**7-1,exports.EMPTY_UINT8=new Uint8Array([])
|
|
7
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.decompressBools=exports.compressBools=exports.EMPTY_UINT8=exports.MAX_UVARINT=exports.MAX_BYTE=void 0,exports.convertVarInt=function(e){if(!Number.isSafeInteger(e)||e<0||e>exports.MAX_UVARINT)throw new Error(`Variable Ints must be within range 0 and ${exports.MAX_UVARINT}: ${e}`);const r=[];do{let o=e%128;(e=Math.floor(e/128))>0&&(o|=128),r.push(o)}while(e>0);return r},exports.readVarInt=function(e,r){let o=0,t=1;for(let s=0;s<8;s++){if(r>=e.length)throw new Error("Truncated variable integer");const s=e[r++];if(o+=(127&s)*t,!(128&s))return[r,o];t*=128}throw new Error("Variable integer is too long")},exports.MAX_BYTE=255,exports.MAX_UVARINT=128**7-1,exports.EMPTY_UINT8=new Uint8Array([]);exports.compressBools=e=>e.reduce((e,r,o)=>e|Number(r)<<7-o,0);exports.decompressBools=e=>Array.from({length:8},(r,o)=>!!(e&1<<7-o));
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* See LICENSE for personal, non-commercial license terms.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.decompressJSON=exports.compressJSON=void 0;const r=require("../BufferUtil"),e=r=>Array.from({length:8},(e,t)=>!!(r&1<<7-t));function t(r){if(!Number.isInteger(r)||r<0)throw new Error(`Invalid JSON variable integer: ${r}`);const e=[];do{let t=127&r;(r>>>=7)>0&&(t|=128),e.push(t)}while(r>0);return e}function n(r,e){let t=0,n=0;for(;;){if(e>=r.length||n>28)throw new Error("Invalid JSON variable integer");const s=r[e++];if(t+=(127&s)<<n,!(128&s))return[e,t];n+=7}}var s;!function(r){r[r.NULL=0]="NULL",r[r.BOOL=1]="BOOL",r[r.INT=2]="INT",r[r.FLOAT=3]="FLOAT",r[r.STRING=4]="STRING",r[r.ARRAY=5]="ARRAY",r[r.OBJECT=6]="OBJECT"}(s||(s={}));const o=r=>{const e=(new TextEncoder).encode(r);return[...t(e.length),...e]},a=(r,e)=>{const[t,s]=n(r,e);return{value:(new TextDecoder).decode(r.subarray(t,t+s)),length:t+s-e}};exports.compressJSON=e=>{const n=[],a=[],
|
|
7
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.decompressJSON=exports.compressJSON=void 0;const r=require("../BufferUtil"),e=r=>Array.from({length:8},(e,t)=>!!(r&1<<7-t));function t(r){if(!Number.isInteger(r)||r<0)throw new Error(`Invalid JSON variable integer: ${r}`);const e=[];do{let t=127&r;(r>>>=7)>0&&(t|=128),e.push(t)}while(r>0);return e}function n(r,e){let t=0,n=0;for(;;){if(e>=r.length||n>28)throw new Error("Invalid JSON variable integer");const s=r[e++];if(t+=(127&s)<<n,!(128&s))return[e,t];n+=7}}var s;!function(r){r[r.NULL=0]="NULL",r[r.BOOL=1]="BOOL",r[r.INT=2]="INT",r[r.FLOAT=3]="FLOAT",r[r.STRING=4]="STRING",r[r.ARRAY=5]="ARRAY",r[r.OBJECT=6]="OBJECT"}(s||(s={}));const o=r=>{const e=(new TextEncoder).encode(r);return[...t(e.length),...e]},a=(r,e)=>{const[t,s]=n(r,e);return{value:(new TextDecoder).decode(r.subarray(t,t+s)),length:t+s-e}},u=r=>{let e="";for(const t of r)e+=t.toString(2).padStart(3,"0");return(r=>new Uint8Array(r.match(/.{1,8}/g)?.map(r=>parseInt(r.padEnd(8,"0"),2))??[]))(e)},c=(r,e)=>{const t=(r=>Array.from(r,r=>r.toString(2).padStart(8,"0")).join(""))(r),n=[];for(let r=0;r<e;r++)n.push(parseInt(t.slice(3*r,3*r+3),2));return n};exports.compressJSON=e=>{const n=[],a=[],c=[],l=r=>{switch(null===r?"null":Array.isArray(r)?"array":typeof r){case"null":c.push(s.NULL);break;case"boolean":c.push(s.BOOL),n.push(r);break;case"number":Number.isInteger(r)?(c.push(s.INT),a.push(...t((r=>r<<1^r>>31)(r)))):(c.push(s.FLOAT),a.push(...function(r){if(Number.isNaN(r))return[127,128,0,1];const e=r<0?1:0;if(0===(r=Math.abs(r)))return[0,0,0,0];const t=Math.floor(Math.log2(r));if(!Number.isFinite(r)||t>127||t<-126)return[e?255:127,128,0,0];const n=(e<<31|t+127<<23|8388607&Math.round((r/2**t-1)*2**23))>>>0;return[n>>>24,n>>>16&255,n>>>8&255,255&n]}(r)));break;case"string":c.push(s.STRING),a.push(...o(r));break;case"array":c.push(s.ARRAY),a.push(...t(r.length));for(const e of r)l(e);break;case"object":{c.push(s.OBJECT);const e=Object.keys(r);a.push(...t(e.length));for(const t of e)a.push(...o(t)),l(r[t]);break}default:throw new Error("Unsupported type")}};l(e);const h=n.length?(0,r.splitArray)(n,8).map(r=>r.reduce((r,e,t)=>r|Number(e)<<7-t,0)):[],p=u(c),i=[...t(h.length),...t(p.length)];return Uint8Array.from([...i,...h.flat(),...p,...a])};exports.decompressJSON=r=>{let t=0;const[o,u]=n(r,t);t=o;const[l,h]=n(r,t);t=l;const p=[];for(let n=0;n<u;n++)p.push(...e(r[t++]));let i=0;const f=r.subarray(t,t+h);t+=h;const N=c(f,8*f.length/3);let O=0;const d=e=>{if(e>500)throw new Error("JSON array too deep.");const o=N[O++];switch(o){case s.NULL:return null;case s.BOOL:return p[i++];case s.INT:{const[e,s]=n(r,t);return t=e,(u=s)>>>1^-(1&u)}case s.FLOAT:{const e=function(r){const e=(r[0]<<24|r[1]<<16|r[2]<<8|r[3])>>>0,t=e>>>23&255,n=(0===t?0:1)+(8388607&e)/2**23,s=255===t?0===n?1/0:NaN:n*2**(0===t?-126:t-127);return e>>>31?-s:s}(Array.from(r.subarray(t,t+4)));return t+=4,e}case s.STRING:{const{value:e,length:n}=a(r,t);return t+=n,e}case s.ARRAY:{const[s,o]=n(r,t);t=s;const a=[];for(let r=0;r<o;r++)a.push(d(e+1));return a}case s.OBJECT:{const[s,o]=n(r,t);t=s;const u={};for(let n=0;n<o;n++){const{value:n,length:s}=a(r,t);t+=s,u[n]=d(e+1)}return u}default:throw new Error(`Unknown type ${o}`)}var u};return d(0)};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* See LICENSE for personal, non-commercial license terms.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.PacketHolder=void 0
|
|
7
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.PacketHolder=void 0;exports.PacketHolder=class{key;keys;tags;packetMap;packets;constructor(t){this.key=1,this.keys={},this.tags={},this.packetMap={},t&&this.holdPackets(t)}createKey(t){this.keys[t]=this.key,this.tags[this.key]=t,this.key++}holdPackets(t){this.packets=t;for(const e of t)this.createKey(e.tag),this.packetMap[e.tag]=e}getKey(t){if(!(t in this.keys))throw new Error(`Not a valid tag: ${t}`);return this.keys[t]}getTag(t){if(t in this.tags)return this.tags[t]}getPacket(t){if(!(t in this.packetMap))throw new Error("Unknown packet tag: "+t);return this.packetMap[t]}hasKey(t){return t in this.tags}hasTag(t){return t in this.keys}getKeys(){return this.keys}getTagMap(){return this.tags}getTags(){return Object.values(this.tags)}getPackets(){return this.packets}serialize(){return this.packets.map(t=>t.serialize()).flat()}};
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
* See LICENSE for personal, non-commercial license terms.
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
-
Object.defineProperty(exports,"__esModule",{value:!0}),exports.processPacket=
|
|
7
|
+
Object.defineProperty(exports,"__esModule",{value:!0}),exports.processPacket=o,exports.listenPacket=async function(e,t,a){if("string"==typeof e)return a(e);const[n,r]=e;try{if(r&&Array.isArray(n))for(const e of t)await e(...n);else for(const e of t)await e(n)}catch(e){console.error(e),a(e)}},exports.CreatePacket=u,exports.CreateObjPacket=function(a){let{tag:n,types:r=[],dataMaxes:o,dataMins:u,noDataRange:f=!1,dontSpread:p=!1,autoFlatten:h=!1,validator:y=null,dataBatching:m=0,maxBatchSize:d=10,rateLimit:w=0,enabled:g=!0,async:k=!1,gzipCompression:P=r&&r.includes(t.PacketType.JSON)}=a;if(!n)throw new Error("Tag not selected!");if(!r||0==r.length)throw new Error("Types is set to 0 length");for(const e of r)if(i(e))throw new Error(`Invalid packet type in "${n}" packet: ${e}`);f?(o=Array.from({length:r.length}).map(()=>s),u=Array.from({length:r.length}).map(()=>0)):(null==o?o=Array.from({length:r.length}).map(()=>1):Array.isArray(o)||(o=Array.from({length:r.length}).map(()=>o)),null==u?u=Array.from({length:r.length}).map((e,t)=>o[t]):Array.isArray(u)||(u=Array.from({length:r.length}).map(()=>u)));const E=o.map(c),S=u.map((e,a)=>r[a]==t.PacketType.NONE?0:l(e,E[a])),x=new e.PacketSchema(!0,r,k,S,E,w,p,h,!1,m,d,P);return new e.Packet(n,x,y,g,!1)},exports.CreateEnumPacket=function(e){const{tag:t,enumData:a,dataMax:n=1,dataMin:r=0,noDataRange:o=!1,dontSpread:i=!1,validator:s=null,dataBatching:c=0,maxBatchSize:l=10,rateLimit:f=0,enabled:p=!0,async:h=!1}=e;return u({tag:t,type:a,dataMax:n,dataMin:r,noDataRange:o,dontSpread:i,validator:s,dataBatching:c,maxBatchSize:l,rateLimit:f,enabled:p,async:h})},exports.CreateKeyEffective=function(e){const{tag:t,count:a=2,validator:n=null,async:r=!1}=e;if(!t)throw new Error("Tag not selected!");if(a<2)throw new Error("Must have at least 2 key consumptions on key effective packet!");throw new Error("Currently W.I.P.")},exports.FlattenData=f,exports.UnFlattenData=function(e){return e[0]?.map((t,a)=>e.map(e=>e[a]))??[]};const e=require("../../packets/Packets"),t=require("../../packets/PacketType"),a=require("../enums/EnumType"),n=require("./CompressionUtil"),r=require("./HashUtil");async function o(e,a,i,s,c,l=!1){const u=e.getKey(a),p=e.getPacket(a);return async function(e,t,a,n,r,i,s){if(e[0]&&!i)return new Promise(t=>e[1].push([t,n,r]));e[0]=!0;const c=await s();if(e[1].length>0){const[n,r,i]=e[1].shift();queueMicrotask(async()=>{n(await o(t,r,i,e,a,!0))})}else e[0]=!1;return c}(s,e,c,a,i,l,async()=>{if(p.rereference){if(-1===c)throw new Error("Cannot send a re-referenced packet from the server-wide sender!");const e=(0,r.hashValue)(i);if(p.lastSent[c]===e)return[u,n.EMPTY_UINT8,p];p.lastSent[c]=e}if(p.autoFlatten)i=f(i[0]);else{if(i.length>p.maxSize)throw new Error(`Packet "${a}" only allows ${p.maxSize} values!`);if(i.length<p.minSize)throw new Error(`Packet "${a}" requires at least ${p.minSize} values!`)}if(p.object){if(i=i.map(e=>Array.isArray(e)?e:[e]),!p.autoFlatten){const e=p.dataMin,t=p.dataMax;for(let n=0;n<e.length;n++){if(i[n].length<e[n])throw new Error(`Section ${n+1} of packet "${a}" requires at least ${e[n]} values!`);if(i[n].length>t[n])throw new Error(`Section ${n+1} of packet "${a}" only allows ${t[n]} values!`)}}}else if(p.type!==t.PacketType.JSON){const e=i.find(e=>"object"==typeof e&&null!=e);e&&console.warn(`Passing an array will result in undefined behavior (${JSON.stringify(e)}). Spread the array with ...arr`)}const e=i.length>0?await p.processSend(i):n.EMPTY_UINT8;return[u,e,p]})}function i(e){return!(("number"==typeof e&&e in t.PacketType||e instanceof a.EnumPackage)&&e!=t.PacketType.KEY_EFFECTIVE)}const s=2048383;function c(e){return e<0?(console.warn("Having a data maximum below 0 does not do anything!"),0):e>s?(console.warn(`Only ${s} values can be sent on a type! Uhh make an issue if you want to send more.`),s):e}function l(e,t){return e<0?(console.warn("Having a data minimum below 0 does not do anything!"),0):e>t?(console.warn("Data minimum can not be higher than the data maximum!"),t):e}function u(a){let{tag:n,type:r=t.PacketType.NONE,dataMax:o=1,dataMin:u=1,noDataRange:f=!1,dontSpread:p=!1,validator:h=null,dataBatching:y=0,maxBatchSize:m=10,rateLimit:d=0,enabled:w=!0,async:g=!1,gzipCompression:k=r==t.PacketType.JSON,rereference:P=!1}=a;if(!n)throw new Error("Tag not selected!");if(f?(u=P?1:0,o=s):null==u&&(u=r==t.PacketType.NONE?0:o),P&&0==u)throw new Error("Rereference cannot be true if the dataMin is 0");if(i(r))throw new Error(`Invalid packet type: ${r}`);const E=new e.PacketSchema(!1,r,g,l(u,o),c(o),d,p,!1,P,y,m,k);return new e.Packet(n,E,h,w,!1)}function f(e){if(null==e)return[];const t=e[0];if(null==t)return[];if(!Array.isArray(t))throw new Error(`Cannot flatten array: ${e}`);return t.map((t,a)=>e.map(e=>e[a]))??[]}
|
|
@@ -1,8 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Copyright (c) 2026 Lily (liwybloc)
|
|
3
|
-
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
|
4
|
-
* See LICENSE for personal, non-commercial license terms.
|
|
5
|
-
*/
|
|
6
1
|
/**
|
|
7
2
|
* Copyright (c) 2026 Lily (liwybloc)
|
|
8
3
|
* License-Identifier: LicenseRef-Lily-Personal-NonCommercial-2026
|
package/package.json
CHANGED
|
@@ -1,20 +1,28 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sonic-ws",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.1",
|
|
4
4
|
"description": "Ultra-lightweight, high-performance, and bandwidth efficient websocket library",
|
|
5
5
|
"main": "dist/ts/index.js",
|
|
6
6
|
"types": "dist/ts/index.d.ts",
|
|
7
|
+
"files": [
|
|
8
|
+
"dist/ts/**/*",
|
|
9
|
+
"bundled/bundle.js",
|
|
10
|
+
"bundled/bundle.wasm",
|
|
11
|
+
"README.md",
|
|
12
|
+
"LICENSE"
|
|
13
|
+
],
|
|
7
14
|
"scripts": {
|
|
8
15
|
"webpack": "webpack --mode production",
|
|
9
16
|
"build_wasm_browser": "wasm-pack build --release --target bundler --out-dir ../ts/native/wasm/pkg --out-name sonic_ws_core ./src/core --features wasm --no-default-features",
|
|
10
17
|
"build_wasm_node": "wasm-pack build --release --target nodejs --out-dir ../ts/native/wasm/node --out-name sonic_ws_core ./src/core --features wasm --no-default-features",
|
|
11
18
|
"build_wasm": "npm run build_wasm_browser && npm run build_wasm_node",
|
|
12
|
-
"build_web": "npm run build_wasm_browser && tsc --moduleResolution nodenext --module nodenext --outDir ./dist/ts src/ts/ws/client/browser/ClientBrowser.ts && cpy \"src/ts/native/wasm/pkg/*\" dist/ts/native/wasm/pkg --flat && npm run webpack",
|
|
13
|
-
"build_node": "npm run build_wasm && rimraf ./dist/ts && tsc -d && cpy \"src/ts/native/wasm/node/*\" dist/ts/native/wasm/node --flat",
|
|
19
|
+
"build_web": "npm run build_wasm_browser && tsc --moduleResolution nodenext --module nodenext --outDir ./dist/ts src/ts/ws/client/browser/ClientBrowser.ts && cpy \"src/ts/native/wasm/pkg/*\" dist/ts/native/wasm/pkg --flat && rimraf ./dist/ts/native/wasm/pkg/.gitignore && npm run webpack",
|
|
20
|
+
"build_node": "npm run build_wasm && rimraf ./dist/ts && tsc -d && cpy \"src/ts/native/wasm/node/*\" dist/ts/native/wasm/node --flat && rimraf ./dist/ts/native/wasm/node/.gitignore",
|
|
14
21
|
"build": "npm run build_node && npm run build_web && rimraf ./dist/ts/ws/client/browser && rimraf ./dist/ts/ws/debug/DebugClient.d.ts && rimraf ./dist/ts/ws/debug/DebugClient.js && node minify",
|
|
15
22
|
"test_web": "npm run build && node tests/test_web.mjs",
|
|
16
23
|
"test_node": "npm --prefix src/core/tests/typescript run build:native && npm run build_node && node tests/test_node.mjs",
|
|
17
|
-
"
|
|
24
|
+
"prepack": "npm run build",
|
|
25
|
+
"publish": "rimraf ./release/SonicWS_bundle.js ./release/SonicWS_core.wasm && cp ./bundled/bundle.js ./release/bundle.js && cp ./bundled/bundle.wasm ./release/bundle.wasm"
|
|
18
26
|
},
|
|
19
27
|
"repository": {
|
|
20
28
|
"type": "git",
|