sonolus-next-rush-plus-engine 1.3.4 → 1.3.5
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/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/lib/binaryseeker/mod.d.ts +14 -0
- package/dist/lib/binaryseeker/mod.js +9 -0
- package/dist/lib/binaryseeker/reader.d.ts +157 -0
- package/dist/lib/binaryseeker/reader.js +305 -0
- package/dist/lib/binaryseeker/writer.d.ts +171 -0
- package/dist/lib/binaryseeker/writer.js +360 -0
- package/dist/mmw/analyze.js +1 -1
- package/package.json +1 -2
package/dist/index.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { USC } from './usc/index.js';
|
|
|
6
6
|
export { susToUSC, mmwsToUSC, uscToLevelData };
|
|
7
7
|
export * from './usc/index.js';
|
|
8
8
|
export declare const convertToLevelData: (input: string | Uint8Array | USC | LevelData, offset?: number) => LevelData;
|
|
9
|
-
export declare const version = "1.3.
|
|
9
|
+
export declare const version = "1.3.5";
|
|
10
10
|
export declare const databaseEngineItem: {
|
|
11
11
|
readonly name: "next-rush-plus";
|
|
12
12
|
readonly version: 13;
|
package/dist/index.js
CHANGED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export * from './reader.js';
|
|
2
|
+
export * from './writer.js';
|
|
3
|
+
import { BinaryReader } from './reader.js';
|
|
4
|
+
/**
|
|
5
|
+
* Alias of BinaryReader, for compatibility with the old name.
|
|
6
|
+
* @deprecated Use BinaryReader instead.
|
|
7
|
+
*/
|
|
8
|
+
export declare const BinarySeeker: typeof BinaryReader;
|
|
9
|
+
/**
|
|
10
|
+
* Alias of BinaryReader, for compatibility with the old name.
|
|
11
|
+
* @deprecated Use BinaryReader instead.
|
|
12
|
+
*/
|
|
13
|
+
export type BinarySeeker = BinaryReader;
|
|
14
|
+
export default BinarySeeker;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export * from './reader.js';
|
|
2
|
+
export * from './writer.js';
|
|
3
|
+
import { BinaryReader } from './reader.js';
|
|
4
|
+
/**
|
|
5
|
+
* Alias of BinaryReader, for compatibility with the old name.
|
|
6
|
+
* @deprecated Use BinaryReader instead.
|
|
7
|
+
*/
|
|
8
|
+
export const BinarySeeker = BinaryReader;
|
|
9
|
+
export default BinarySeeker;
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple cursor-based binary reader.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Simple cursor-based binary reader.
|
|
7
|
+
*/
|
|
8
|
+
export declare class BinaryReader {
|
|
9
|
+
#private;
|
|
10
|
+
/**
|
|
11
|
+
* Create a new BinarySeeker instance.
|
|
12
|
+
* @param data - The ArrayBuffer to read from.
|
|
13
|
+
* @returns A new BinarySeeker instance.
|
|
14
|
+
*/
|
|
15
|
+
constructor(data: ArrayBufferLike);
|
|
16
|
+
/**
|
|
17
|
+
* Returns the current cursor position.
|
|
18
|
+
*/
|
|
19
|
+
get cursor(): number;
|
|
20
|
+
/**
|
|
21
|
+
* Seek to a specific offset in the buffer.
|
|
22
|
+
* @param offset - The offset to seek to.
|
|
23
|
+
*/
|
|
24
|
+
seek(offset: number): void;
|
|
25
|
+
/**
|
|
26
|
+
* Read a single byte from the buffer.
|
|
27
|
+
* @returns The byte read.
|
|
28
|
+
*/
|
|
29
|
+
readUInt8(): number;
|
|
30
|
+
/**
|
|
31
|
+
* Read a single signed byte from the buffer.
|
|
32
|
+
* @returns The byte read.
|
|
33
|
+
*/
|
|
34
|
+
readInt8(): number;
|
|
35
|
+
/**
|
|
36
|
+
* Read a number from the buffer.
|
|
37
|
+
*
|
|
38
|
+
* > [!NOTE]
|
|
39
|
+
* > In most cases, you should use the `read[Type][Endian]` method instead.
|
|
40
|
+
*
|
|
41
|
+
* @param type - The type of number to read.
|
|
42
|
+
* @param endian - The endianness to read the number in.
|
|
43
|
+
* @returns The number read.
|
|
44
|
+
*/
|
|
45
|
+
read(kind: 'u32' | 'u16' | 'i32' | 'i16' | 'f32' | 'f64' | 'u8' | 'i8', endian?: 'le' | 'be'): number;
|
|
46
|
+
/**
|
|
47
|
+
* Read unsigned 64-bit integer (u64) from the buffer.
|
|
48
|
+
* @returns The number read.
|
|
49
|
+
*/
|
|
50
|
+
readUInt64LE(): bigint;
|
|
51
|
+
/**
|
|
52
|
+
* Read unsigned 32-bit integer (u32) from the buffer.
|
|
53
|
+
* @returns The number read.
|
|
54
|
+
*/
|
|
55
|
+
readUInt32LE(): number;
|
|
56
|
+
/**
|
|
57
|
+
* Read unsigned 16-bit integer (u16) from the buffer.
|
|
58
|
+
* @returns The number read.
|
|
59
|
+
*/
|
|
60
|
+
readUInt16LE(): number;
|
|
61
|
+
/**
|
|
62
|
+
* Read signed 64-bit integer (i64) from the buffer.
|
|
63
|
+
* @returns The number read.
|
|
64
|
+
*/
|
|
65
|
+
readInt64LE(): bigint;
|
|
66
|
+
/**
|
|
67
|
+
* Read signed 32-bit integer (i32) from the buffer.
|
|
68
|
+
* @returns The number read.
|
|
69
|
+
*/
|
|
70
|
+
readInt32LE(): number;
|
|
71
|
+
/**
|
|
72
|
+
* Read signed 16-bit integer from the buffer.
|
|
73
|
+
* @returns The number read.
|
|
74
|
+
*/
|
|
75
|
+
readInt16LE(): number;
|
|
76
|
+
/**
|
|
77
|
+
* Read unsigned 64-bit integer (u64) from the buffer.
|
|
78
|
+
* @returns The number read.
|
|
79
|
+
*/
|
|
80
|
+
readUInt64BE(): bigint;
|
|
81
|
+
/**
|
|
82
|
+
* Read unsigned 32-bit integer (u32) from the buffer.
|
|
83
|
+
* @returns The number read.
|
|
84
|
+
*/
|
|
85
|
+
readUInt32BE(): number;
|
|
86
|
+
/**
|
|
87
|
+
* Read unsigned 16-bit integer (u16) from the buffer.
|
|
88
|
+
* @returns The number read.
|
|
89
|
+
*/
|
|
90
|
+
readUInt16BE(): number;
|
|
91
|
+
/**
|
|
92
|
+
* Read signed 64-bit integer (i64) from the buffer.
|
|
93
|
+
* @returns The number read.
|
|
94
|
+
*/
|
|
95
|
+
readInt64BE(): bigint;
|
|
96
|
+
/**
|
|
97
|
+
* Read signed 32-bit integer (i32) from the buffer.
|
|
98
|
+
* @returns The number read.
|
|
99
|
+
*/
|
|
100
|
+
readInt32BE(): number;
|
|
101
|
+
/**
|
|
102
|
+
* Read signed 16-bit integer from the buffer.
|
|
103
|
+
* @returns The number read.
|
|
104
|
+
*/
|
|
105
|
+
readInt16BE(): number;
|
|
106
|
+
/**
|
|
107
|
+
* Read a 32-bit floating point number (f32, float) from the buffer.
|
|
108
|
+
* @returns The number read.
|
|
109
|
+
*/
|
|
110
|
+
readFloat32BE(): number;
|
|
111
|
+
/**
|
|
112
|
+
* Read a 64-bit floating point number (f64, double) from the buffer.
|
|
113
|
+
* @returns The number read.
|
|
114
|
+
*/
|
|
115
|
+
readFloat64BE(): number;
|
|
116
|
+
/** Alias for `readFloat32BE` */
|
|
117
|
+
readFloat32(): number;
|
|
118
|
+
/** Alias for `readFloat64BE` */
|
|
119
|
+
readFloat64(): number;
|
|
120
|
+
/**
|
|
121
|
+
* Read a 32-bit floating point number (f32, float) in little-endian from the buffer.
|
|
122
|
+
* @returns The number read.
|
|
123
|
+
*/
|
|
124
|
+
readFloat32LE(): number;
|
|
125
|
+
/**
|
|
126
|
+
* Read a 64-bit floating point number (f64, double) in little-endian from the buffer.
|
|
127
|
+
* @returns The number read.
|
|
128
|
+
*/
|
|
129
|
+
readFloat64LE(): number;
|
|
130
|
+
/**
|
|
131
|
+
* Read a null-terminated string from the buffer.
|
|
132
|
+
* @returns The string read.
|
|
133
|
+
*/
|
|
134
|
+
readString(): string;
|
|
135
|
+
/**
|
|
136
|
+
* Read a fixed-length buffer from the buffer.
|
|
137
|
+
* @param length - The length of the buffer to read.
|
|
138
|
+
* @returns The buffer read.
|
|
139
|
+
*/
|
|
140
|
+
readBytes(length: number): Uint8Array;
|
|
141
|
+
/**
|
|
142
|
+
* Read buffer from the current cursor to the end of the buffer.
|
|
143
|
+
* @returns The buffer read.
|
|
144
|
+
*/
|
|
145
|
+
readToEnd(): Uint8Array;
|
|
146
|
+
/**
|
|
147
|
+
* Read a fixed-length string from the buffer.
|
|
148
|
+
* This is a shorthand for `readBytes` and `TextDecoder`.
|
|
149
|
+
* @param length - The length of the string to read.
|
|
150
|
+
* @returns The string read.
|
|
151
|
+
*/
|
|
152
|
+
readChars(length: number): string;
|
|
153
|
+
/**
|
|
154
|
+
* Returns if there are more data to read.
|
|
155
|
+
*/
|
|
156
|
+
get hasMoreData(): boolean;
|
|
157
|
+
}
|
|
@@ -0,0 +1,305 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple cursor-based binary reader.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
6
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
7
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
8
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
9
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var _BinaryReader_data, _BinaryReader_cursor;
|
|
17
|
+
/**
|
|
18
|
+
* Simple cursor-based binary reader.
|
|
19
|
+
*/
|
|
20
|
+
export class BinaryReader {
|
|
21
|
+
/**
|
|
22
|
+
* Create a new BinarySeeker instance.
|
|
23
|
+
* @param data - The ArrayBuffer to read from.
|
|
24
|
+
* @returns A new BinarySeeker instance.
|
|
25
|
+
*/
|
|
26
|
+
constructor(data) {
|
|
27
|
+
_BinaryReader_data.set(this, void 0);
|
|
28
|
+
_BinaryReader_cursor.set(this, void 0);
|
|
29
|
+
__classPrivateFieldSet(this, _BinaryReader_data, new DataView(data), "f");
|
|
30
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, 0, "f");
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Returns the current cursor position.
|
|
34
|
+
*/
|
|
35
|
+
get cursor() {
|
|
36
|
+
return __classPrivateFieldGet(this, _BinaryReader_cursor, "f");
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Seek to a specific offset in the buffer.
|
|
40
|
+
* @param offset - The offset to seek to.
|
|
41
|
+
*/
|
|
42
|
+
seek(offset) {
|
|
43
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, offset, "f");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Read a single byte from the buffer.
|
|
47
|
+
* @returns The byte read.
|
|
48
|
+
*/
|
|
49
|
+
readUInt8() {
|
|
50
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getUint8(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"));
|
|
51
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 1, "f");
|
|
52
|
+
return value;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Read a single signed byte from the buffer.
|
|
56
|
+
* @returns The byte read.
|
|
57
|
+
*/
|
|
58
|
+
readInt8() {
|
|
59
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getInt8(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"));
|
|
60
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 1, "f");
|
|
61
|
+
return value;
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Read a number from the buffer.
|
|
65
|
+
*
|
|
66
|
+
* > [!NOTE]
|
|
67
|
+
* > In most cases, you should use the `read[Type][Endian]` method instead.
|
|
68
|
+
*
|
|
69
|
+
* @param type - The type of number to read.
|
|
70
|
+
* @param endian - The endianness to read the number in.
|
|
71
|
+
* @returns The number read.
|
|
72
|
+
*/
|
|
73
|
+
read(kind, endian = 'le') {
|
|
74
|
+
switch (kind) {
|
|
75
|
+
case 'u8':
|
|
76
|
+
return this.readUInt8();
|
|
77
|
+
case 'i8':
|
|
78
|
+
return this.readInt8();
|
|
79
|
+
case 'u32':
|
|
80
|
+
return endian === 'le' ? this.readUInt32LE() : this.readUInt32BE();
|
|
81
|
+
case 'u16':
|
|
82
|
+
return endian === 'le' ? this.readUInt16LE() : this.readUInt16BE();
|
|
83
|
+
case 'i32':
|
|
84
|
+
return endian === 'le' ? this.readInt32LE() : this.readInt32BE();
|
|
85
|
+
case 'i16':
|
|
86
|
+
return endian === 'le' ? this.readInt16LE() : this.readInt16BE();
|
|
87
|
+
case 'f32':
|
|
88
|
+
return endian === 'le' ? this.readFloat32LE() : this.readFloat32BE();
|
|
89
|
+
case 'f64':
|
|
90
|
+
return endian === 'le' ? this.readFloat64LE() : this.readFloat64BE();
|
|
91
|
+
default:
|
|
92
|
+
kind;
|
|
93
|
+
throw new Error(`Unknown type: ${kind}`);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
/**
|
|
97
|
+
* Read unsigned 64-bit integer (u64) from the buffer.
|
|
98
|
+
* @returns The number read.
|
|
99
|
+
*/
|
|
100
|
+
readUInt64LE() {
|
|
101
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getBigUint64(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), true);
|
|
102
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 8, "f");
|
|
103
|
+
return value;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
* Read unsigned 32-bit integer (u32) from the buffer.
|
|
107
|
+
* @returns The number read.
|
|
108
|
+
*/
|
|
109
|
+
readUInt32LE() {
|
|
110
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getUint32(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), true);
|
|
111
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 4, "f");
|
|
112
|
+
return value;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Read unsigned 16-bit integer (u16) from the buffer.
|
|
116
|
+
* @returns The number read.
|
|
117
|
+
*/
|
|
118
|
+
readUInt16LE() {
|
|
119
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getUint16(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), true);
|
|
120
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 2, "f");
|
|
121
|
+
return value;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Read signed 64-bit integer (i64) from the buffer.
|
|
125
|
+
* @returns The number read.
|
|
126
|
+
*/
|
|
127
|
+
readInt64LE() {
|
|
128
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getBigInt64(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), true);
|
|
129
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 8, "f");
|
|
130
|
+
return value;
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
* Read signed 32-bit integer (i32) from the buffer.
|
|
134
|
+
* @returns The number read.
|
|
135
|
+
*/
|
|
136
|
+
readInt32LE() {
|
|
137
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getInt32(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), true);
|
|
138
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 4, "f");
|
|
139
|
+
return value;
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* Read signed 16-bit integer from the buffer.
|
|
143
|
+
* @returns The number read.
|
|
144
|
+
*/
|
|
145
|
+
readInt16LE() {
|
|
146
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getInt16(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), true);
|
|
147
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 2, "f");
|
|
148
|
+
return value;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Read unsigned 64-bit integer (u64) from the buffer.
|
|
152
|
+
* @returns The number read.
|
|
153
|
+
*/
|
|
154
|
+
readUInt64BE() {
|
|
155
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getBigUint64(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), false);
|
|
156
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 8, "f");
|
|
157
|
+
return value;
|
|
158
|
+
}
|
|
159
|
+
/**
|
|
160
|
+
* Read unsigned 32-bit integer (u32) from the buffer.
|
|
161
|
+
* @returns The number read.
|
|
162
|
+
*/
|
|
163
|
+
readUInt32BE() {
|
|
164
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getUint32(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), false);
|
|
165
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 4, "f");
|
|
166
|
+
return value;
|
|
167
|
+
}
|
|
168
|
+
/**
|
|
169
|
+
* Read unsigned 16-bit integer (u16) from the buffer.
|
|
170
|
+
* @returns The number read.
|
|
171
|
+
*/
|
|
172
|
+
readUInt16BE() {
|
|
173
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getUint16(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), false);
|
|
174
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 2, "f");
|
|
175
|
+
return value;
|
|
176
|
+
}
|
|
177
|
+
/**
|
|
178
|
+
* Read signed 64-bit integer (i64) from the buffer.
|
|
179
|
+
* @returns The number read.
|
|
180
|
+
*/
|
|
181
|
+
readInt64BE() {
|
|
182
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getBigInt64(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), false);
|
|
183
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 8, "f");
|
|
184
|
+
return value;
|
|
185
|
+
}
|
|
186
|
+
/**
|
|
187
|
+
* Read signed 32-bit integer (i32) from the buffer.
|
|
188
|
+
* @returns The number read.
|
|
189
|
+
*/
|
|
190
|
+
readInt32BE() {
|
|
191
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getInt32(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), false);
|
|
192
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 4, "f");
|
|
193
|
+
return value;
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Read signed 16-bit integer from the buffer.
|
|
197
|
+
* @returns The number read.
|
|
198
|
+
*/
|
|
199
|
+
readInt16BE() {
|
|
200
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getInt16(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), false);
|
|
201
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 2, "f");
|
|
202
|
+
return value;
|
|
203
|
+
}
|
|
204
|
+
/**
|
|
205
|
+
* Read a 32-bit floating point number (f32, float) from the buffer.
|
|
206
|
+
* @returns The number read.
|
|
207
|
+
*/
|
|
208
|
+
readFloat32BE() {
|
|
209
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getFloat32(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), false);
|
|
210
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 4, "f");
|
|
211
|
+
return value;
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
214
|
+
* Read a 64-bit floating point number (f64, double) from the buffer.
|
|
215
|
+
* @returns The number read.
|
|
216
|
+
*/
|
|
217
|
+
readFloat64BE() {
|
|
218
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getFloat64(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), false);
|
|
219
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 8, "f");
|
|
220
|
+
return value;
|
|
221
|
+
}
|
|
222
|
+
/** Alias for `readFloat32BE` */
|
|
223
|
+
readFloat32() {
|
|
224
|
+
return this.readFloat32BE();
|
|
225
|
+
}
|
|
226
|
+
/** Alias for `readFloat64BE` */
|
|
227
|
+
readFloat64() {
|
|
228
|
+
return this.readFloat64BE();
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Read a 32-bit floating point number (f32, float) in little-endian from the buffer.
|
|
232
|
+
* @returns The number read.
|
|
233
|
+
*/
|
|
234
|
+
readFloat32LE() {
|
|
235
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getFloat32(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), true);
|
|
236
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 4, "f");
|
|
237
|
+
return value;
|
|
238
|
+
}
|
|
239
|
+
/**
|
|
240
|
+
* Read a 64-bit floating point number (f64, double) in little-endian from the buffer.
|
|
241
|
+
* @returns The number read.
|
|
242
|
+
*/
|
|
243
|
+
readFloat64LE() {
|
|
244
|
+
const value = __classPrivateFieldGet(this, _BinaryReader_data, "f").getFloat64(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"), true);
|
|
245
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 8, "f");
|
|
246
|
+
return value;
|
|
247
|
+
}
|
|
248
|
+
/**
|
|
249
|
+
* Read a null-terminated string from the buffer.
|
|
250
|
+
* @returns The string read.
|
|
251
|
+
*/
|
|
252
|
+
readString() {
|
|
253
|
+
const buffer = [];
|
|
254
|
+
while (true) {
|
|
255
|
+
const charCode = __classPrivateFieldGet(this, _BinaryReader_data, "f").getUint8(__classPrivateFieldGet(this, _BinaryReader_cursor, "f"));
|
|
256
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + 1, "f");
|
|
257
|
+
if (charCode === 0) {
|
|
258
|
+
break;
|
|
259
|
+
}
|
|
260
|
+
buffer.push(charCode);
|
|
261
|
+
}
|
|
262
|
+
const decoder = new TextDecoder();
|
|
263
|
+
return decoder.decode(new Uint8Array(buffer));
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* Read a fixed-length buffer from the buffer.
|
|
267
|
+
* @param length - The length of the buffer to read.
|
|
268
|
+
* @returns The buffer read.
|
|
269
|
+
*/
|
|
270
|
+
readBytes(length) {
|
|
271
|
+
const buffer = new Uint8Array(length);
|
|
272
|
+
for (let i = 0; i < length; i++) {
|
|
273
|
+
buffer[i] = __classPrivateFieldGet(this, _BinaryReader_data, "f").getUint8(__classPrivateFieldGet(this, _BinaryReader_cursor, "f") + i);
|
|
274
|
+
}
|
|
275
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_cursor, "f") + length, "f");
|
|
276
|
+
return buffer;
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Read buffer from the current cursor to the end of the buffer.
|
|
280
|
+
* @returns The buffer read.
|
|
281
|
+
*/
|
|
282
|
+
readToEnd() {
|
|
283
|
+
const buffer = new Uint8Array(__classPrivateFieldGet(this, _BinaryReader_data, "f").buffer, __classPrivateFieldGet(this, _BinaryReader_cursor, "f"));
|
|
284
|
+
__classPrivateFieldSet(this, _BinaryReader_cursor, __classPrivateFieldGet(this, _BinaryReader_data, "f").byteLength, "f");
|
|
285
|
+
return buffer;
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Read a fixed-length string from the buffer.
|
|
289
|
+
* This is a shorthand for `readBytes` and `TextDecoder`.
|
|
290
|
+
* @param length - The length of the string to read.
|
|
291
|
+
* @returns The string read.
|
|
292
|
+
*/
|
|
293
|
+
readChars(length) {
|
|
294
|
+
const buffer = this.readBytes(length);
|
|
295
|
+
const decoder = new TextDecoder();
|
|
296
|
+
return decoder.decode(buffer);
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Returns if there are more data to read.
|
|
300
|
+
*/
|
|
301
|
+
get hasMoreData() {
|
|
302
|
+
return __classPrivateFieldGet(this, _BinaryReader_cursor, "f") < __classPrivateFieldGet(this, _BinaryReader_data, "f").byteLength;
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
_BinaryReader_data = new WeakMap(), _BinaryReader_cursor = new WeakMap();
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple cursor-based binary writer.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Simple cursor-based binary writer.
|
|
7
|
+
*
|
|
8
|
+
* On initialization, the writer creates a buffer with a default size of 256 bytes.
|
|
9
|
+
* The buffer will grow automatically as needed, but you can use {@link ensureSize} to reduce the number of resizing.
|
|
10
|
+
*/
|
|
11
|
+
export declare class BinaryWriter {
|
|
12
|
+
#private;
|
|
13
|
+
/**
|
|
14
|
+
* Create a new BinaryWriter instance.
|
|
15
|
+
* @param initialSize - The initial size of the buffer. The buffer will grow automatically as needed, but this parameter can help reduce the number of resizing.
|
|
16
|
+
* @returns A new BinaryWriter instance.
|
|
17
|
+
*/
|
|
18
|
+
constructor(initialSize?: number);
|
|
19
|
+
/**
|
|
20
|
+
* Returns the current cursor position.
|
|
21
|
+
*/
|
|
22
|
+
get cursor(): number;
|
|
23
|
+
/**
|
|
24
|
+
* Seek to a specific offset in the buffer.
|
|
25
|
+
*/
|
|
26
|
+
seek(offset: number): void;
|
|
27
|
+
/**
|
|
28
|
+
* Write a single byte to the buffer.
|
|
29
|
+
* @param value - The byte to write.
|
|
30
|
+
*/
|
|
31
|
+
writeUInt8(value: number): void;
|
|
32
|
+
/**
|
|
33
|
+
* Write a single signed byte to the buffer.
|
|
34
|
+
* @param value - The byte to write.
|
|
35
|
+
*/
|
|
36
|
+
writeInt8(value: number): void;
|
|
37
|
+
/**
|
|
38
|
+
* Write a number to the buffer.
|
|
39
|
+
*
|
|
40
|
+
* > [!NOTE]
|
|
41
|
+
* > In most cases, you should use the `write[Type][Endian]` method instead.
|
|
42
|
+
*
|
|
43
|
+
* @param value - The number to write.
|
|
44
|
+
* @param kind - The type of number to write.
|
|
45
|
+
* @param endian - The endianness to write the number in.
|
|
46
|
+
*/
|
|
47
|
+
write(value: number, kind: 'u32' | 'u16' | 'i32' | 'i16' | 'f32' | 'f64' | 'u8' | 'i8', endian?: 'le' | 'be'): void;
|
|
48
|
+
/**
|
|
49
|
+
* Write a 32-bit unsigned integer to the buffer in little-endian format.
|
|
50
|
+
* @param value - The number to write.
|
|
51
|
+
*/
|
|
52
|
+
writeUInt32LE(value: number): void;
|
|
53
|
+
/**
|
|
54
|
+
* Write a 32-bit unsigned integer to the buffer in big-endian format.
|
|
55
|
+
* @param value - The number to write.
|
|
56
|
+
*/
|
|
57
|
+
writeUInt32BE(value: number): void;
|
|
58
|
+
/**
|
|
59
|
+
* Write a 16-bit unsigned integer to the buffer in little-endian format.
|
|
60
|
+
* @param value - The number to write.
|
|
61
|
+
*/
|
|
62
|
+
writeUInt16LE(value: number): void;
|
|
63
|
+
/**
|
|
64
|
+
* Write a 16-bit unsigned integer to the buffer in big-endian format.
|
|
65
|
+
* @param value - The number to write.
|
|
66
|
+
*/
|
|
67
|
+
writeUInt16BE(value: number): void;
|
|
68
|
+
/**
|
|
69
|
+
* Write a signed 32-bit integer to the buffer in little-endian format.
|
|
70
|
+
* @param value - The number to write.
|
|
71
|
+
*/
|
|
72
|
+
writeInt32LE(value: number): void;
|
|
73
|
+
/**
|
|
74
|
+
* Write a signed 32-bit integer to the buffer in big-endian format.
|
|
75
|
+
* @param value - The number to write.
|
|
76
|
+
*/
|
|
77
|
+
writeInt32BE(value: number): void;
|
|
78
|
+
/**
|
|
79
|
+
* Write a signed 16-bit integer to the buffer in little-endian format.
|
|
80
|
+
* @param value - The number to write.
|
|
81
|
+
*/
|
|
82
|
+
writeInt16LE(value: number): void;
|
|
83
|
+
/**
|
|
84
|
+
* Write a signed 16-bit integer to the buffer in big-endian format.
|
|
85
|
+
* @param value - The number to write.
|
|
86
|
+
*/
|
|
87
|
+
writeInt16BE(value: number): void;
|
|
88
|
+
/**
|
|
89
|
+
* Write a 64-bit unsigned integer to the buffer in little-endian format.
|
|
90
|
+
* @param value - The number to write.
|
|
91
|
+
*/
|
|
92
|
+
writeUInt64LE(value: bigint): void;
|
|
93
|
+
/**
|
|
94
|
+
* Write a 64-bit unsigned integer to the buffer in big-endian format.
|
|
95
|
+
* @param value - The number to write.
|
|
96
|
+
*/
|
|
97
|
+
writeUInt64BE(value: bigint): void;
|
|
98
|
+
/**
|
|
99
|
+
* Write a 64-bit signed integer to the buffer in little-endian format.
|
|
100
|
+
* @param value - The number to write.
|
|
101
|
+
*/
|
|
102
|
+
writeInt64LE(value: bigint): void;
|
|
103
|
+
/**
|
|
104
|
+
* Write a 64-bit signed integer to the buffer in big-endian format.
|
|
105
|
+
* @param value - The number to write.
|
|
106
|
+
*/
|
|
107
|
+
writeInt64BE(value: bigint): void;
|
|
108
|
+
/**
|
|
109
|
+
* Write a 32-bit floating point number (f32, float) to the buffer in little-endian format.
|
|
110
|
+
* @param value - The number to write.
|
|
111
|
+
*/
|
|
112
|
+
writeFloat32LE(value: number): void;
|
|
113
|
+
/**
|
|
114
|
+
* Write a 64-bit floating point number (f64, double) to the buffer in little-endian format.
|
|
115
|
+
* @param value - The number to write.
|
|
116
|
+
*/
|
|
117
|
+
writeFloat64LE(value: number): void;
|
|
118
|
+
/**
|
|
119
|
+
* Write a 32-bit floating point number (f32, float) to the buffer in big-endian format.
|
|
120
|
+
* @param value - The number to write.
|
|
121
|
+
*/
|
|
122
|
+
writeFloat32BE(value: number): void;
|
|
123
|
+
/**
|
|
124
|
+
* Write a 64-bit floating point number (f64, double) to the buffer in big-endian format.
|
|
125
|
+
* @param value - The number to write.
|
|
126
|
+
*/
|
|
127
|
+
writeFloat64BE(value: number): void;
|
|
128
|
+
/** Alias for `writeFloat32LE` */
|
|
129
|
+
writeFloat32(value: number): void;
|
|
130
|
+
/** Alias for `writeFloat64LE` */
|
|
131
|
+
writeFloat64(value: number): void;
|
|
132
|
+
/**
|
|
133
|
+
* Write a null-terminated string to the buffer.
|
|
134
|
+
*
|
|
135
|
+
* @param value - The string to write.
|
|
136
|
+
*/
|
|
137
|
+
writeString(value: string): void;
|
|
138
|
+
/**
|
|
139
|
+
* Write a buffer to the buffer.
|
|
140
|
+
*
|
|
141
|
+
* @param value - The buffer to write.
|
|
142
|
+
*/
|
|
143
|
+
writeBytes(value: Uint8Array): void;
|
|
144
|
+
/**
|
|
145
|
+
* Write a string to the buffer, without null-terminating it.
|
|
146
|
+
*
|
|
147
|
+
* @param value - The string to write.
|
|
148
|
+
*/
|
|
149
|
+
writeChars(value: string): void;
|
|
150
|
+
/**
|
|
151
|
+
* Save the buffer as a Uint8Array.
|
|
152
|
+
* @returns The buffer as a Uint8Array.
|
|
153
|
+
*/
|
|
154
|
+
toUint8Array(): Uint8Array;
|
|
155
|
+
/**
|
|
156
|
+
* Increase the buffer size to the specified size if the buffer is too small.
|
|
157
|
+
* @param size - The size to increase the buffer to.
|
|
158
|
+
* @returns The new buffer size.
|
|
159
|
+
*/
|
|
160
|
+
ensureSize(size: number): number;
|
|
161
|
+
/** Get the current length of the buffer. */
|
|
162
|
+
get length(): number;
|
|
163
|
+
/** Get the current capacity of the buffer. */
|
|
164
|
+
get capacity(): number;
|
|
165
|
+
/** Allocate more space in the buffer, if needed. */
|
|
166
|
+
private preWrite;
|
|
167
|
+
/** Allocate more space in the buffer. */
|
|
168
|
+
private extendBuffer;
|
|
169
|
+
/** Update the cursor after writing to the buffer. */
|
|
170
|
+
private postWrite;
|
|
171
|
+
}
|
|
@@ -0,0 +1,360 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Simple cursor-based binary writer.
|
|
3
|
+
* @module
|
|
4
|
+
*/
|
|
5
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
6
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
7
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
8
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
9
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
10
|
+
};
|
|
11
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
12
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
13
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
14
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
15
|
+
};
|
|
16
|
+
var _BinaryWriter_data, _BinaryWriter_view, _BinaryWriter_maxCursor, _BinaryWriter_cursor;
|
|
17
|
+
/**
|
|
18
|
+
* Simple cursor-based binary writer.
|
|
19
|
+
*
|
|
20
|
+
* On initialization, the writer creates a buffer with a default size of 256 bytes.
|
|
21
|
+
* The buffer will grow automatically as needed, but you can use {@link ensureSize} to reduce the number of resizing.
|
|
22
|
+
*/
|
|
23
|
+
export class BinaryWriter {
|
|
24
|
+
/**
|
|
25
|
+
* Create a new BinaryWriter instance.
|
|
26
|
+
* @param initialSize - The initial size of the buffer. The buffer will grow automatically as needed, but this parameter can help reduce the number of resizing.
|
|
27
|
+
* @returns A new BinaryWriter instance.
|
|
28
|
+
*/
|
|
29
|
+
constructor(initialSize = 256) {
|
|
30
|
+
_BinaryWriter_data.set(this, void 0);
|
|
31
|
+
_BinaryWriter_view.set(this, void 0);
|
|
32
|
+
_BinaryWriter_maxCursor.set(this, void 0);
|
|
33
|
+
_BinaryWriter_cursor.set(this, void 0);
|
|
34
|
+
__classPrivateFieldSet(this, _BinaryWriter_data, new Uint8Array(initialSize), "f");
|
|
35
|
+
__classPrivateFieldSet(this, _BinaryWriter_view, new DataView(__classPrivateFieldGet(this, _BinaryWriter_data, "f").buffer), "f");
|
|
36
|
+
__classPrivateFieldSet(this, _BinaryWriter_cursor, 0, "f");
|
|
37
|
+
__classPrivateFieldSet(this, _BinaryWriter_maxCursor, 0, "f");
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Returns the current cursor position.
|
|
41
|
+
*/
|
|
42
|
+
get cursor() {
|
|
43
|
+
return __classPrivateFieldGet(this, _BinaryWriter_cursor, "f");
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Seek to a specific offset in the buffer.
|
|
47
|
+
*/
|
|
48
|
+
seek(offset) {
|
|
49
|
+
this.preWrite(offset - __classPrivateFieldGet(this, _BinaryWriter_cursor, "f"));
|
|
50
|
+
__classPrivateFieldSet(this, _BinaryWriter_cursor, offset, "f");
|
|
51
|
+
this.postWrite(0);
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Write a single byte to the buffer.
|
|
55
|
+
* @param value - The byte to write.
|
|
56
|
+
*/
|
|
57
|
+
writeUInt8(value) {
|
|
58
|
+
this.preWrite(1);
|
|
59
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setUint8(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value);
|
|
60
|
+
this.postWrite(1);
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Write a single signed byte to the buffer.
|
|
64
|
+
* @param value - The byte to write.
|
|
65
|
+
*/
|
|
66
|
+
writeInt8(value) {
|
|
67
|
+
this.preWrite(1);
|
|
68
|
+
__classPrivateFieldGet(this, _BinaryWriter_data, "f")[__classPrivateFieldGet(this, _BinaryWriter_cursor, "f")] = value;
|
|
69
|
+
this.postWrite(1);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Write a number to the buffer.
|
|
73
|
+
*
|
|
74
|
+
* > [!NOTE]
|
|
75
|
+
* > In most cases, you should use the `write[Type][Endian]` method instead.
|
|
76
|
+
*
|
|
77
|
+
* @param value - The number to write.
|
|
78
|
+
* @param kind - The type of number to write.
|
|
79
|
+
* @param endian - The endianness to write the number in.
|
|
80
|
+
*/
|
|
81
|
+
write(value, kind, endian = 'le') {
|
|
82
|
+
switch (kind) {
|
|
83
|
+
case 'u8':
|
|
84
|
+
this.writeUInt8(value);
|
|
85
|
+
break;
|
|
86
|
+
case 'i8':
|
|
87
|
+
this.writeInt8(value);
|
|
88
|
+
break;
|
|
89
|
+
case 'u32':
|
|
90
|
+
endian === 'le' ? this.writeUInt32LE(value) : this.writeUInt32BE(value);
|
|
91
|
+
break;
|
|
92
|
+
case 'u16':
|
|
93
|
+
endian === 'le' ? this.writeUInt16LE(value) : this.writeUInt16BE(value);
|
|
94
|
+
break;
|
|
95
|
+
case 'i32':
|
|
96
|
+
endian === 'le' ? this.writeInt32LE(value) : this.writeInt32BE(value);
|
|
97
|
+
break;
|
|
98
|
+
case 'i16':
|
|
99
|
+
endian === 'le' ? this.writeInt16LE(value) : this.writeInt16BE(value);
|
|
100
|
+
break;
|
|
101
|
+
case 'f32':
|
|
102
|
+
endian === 'le' ? this.writeFloat32LE(value) : this.writeFloat32BE(value);
|
|
103
|
+
break;
|
|
104
|
+
case 'f64':
|
|
105
|
+
endian === 'le' ? this.writeFloat64LE(value) : this.writeFloat64BE(value);
|
|
106
|
+
break;
|
|
107
|
+
default:
|
|
108
|
+
kind;
|
|
109
|
+
throw new Error(`Unknown kind: ${kind}`);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Write a 32-bit unsigned integer to the buffer in little-endian format.
|
|
114
|
+
* @param value - The number to write.
|
|
115
|
+
*/
|
|
116
|
+
writeUInt32LE(value) {
|
|
117
|
+
this.preWrite(4);
|
|
118
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setUint32(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, true);
|
|
119
|
+
this.postWrite(4);
|
|
120
|
+
}
|
|
121
|
+
/**
|
|
122
|
+
* Write a 32-bit unsigned integer to the buffer in big-endian format.
|
|
123
|
+
* @param value - The number to write.
|
|
124
|
+
*/
|
|
125
|
+
writeUInt32BE(value) {
|
|
126
|
+
this.preWrite(4);
|
|
127
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setUint32(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, false);
|
|
128
|
+
this.postWrite(4);
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Write a 16-bit unsigned integer to the buffer in little-endian format.
|
|
132
|
+
* @param value - The number to write.
|
|
133
|
+
*/
|
|
134
|
+
writeUInt16LE(value) {
|
|
135
|
+
this.preWrite(2);
|
|
136
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setUint16(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, true);
|
|
137
|
+
this.postWrite(2);
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* Write a 16-bit unsigned integer to the buffer in big-endian format.
|
|
141
|
+
* @param value - The number to write.
|
|
142
|
+
*/
|
|
143
|
+
writeUInt16BE(value) {
|
|
144
|
+
this.preWrite(2);
|
|
145
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setUint16(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, false);
|
|
146
|
+
this.postWrite(2);
|
|
147
|
+
}
|
|
148
|
+
/**
|
|
149
|
+
* Write a signed 32-bit integer to the buffer in little-endian format.
|
|
150
|
+
* @param value - The number to write.
|
|
151
|
+
*/
|
|
152
|
+
writeInt32LE(value) {
|
|
153
|
+
this.preWrite(4);
|
|
154
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setInt32(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, true);
|
|
155
|
+
this.postWrite(4);
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Write a signed 32-bit integer to the buffer in big-endian format.
|
|
159
|
+
* @param value - The number to write.
|
|
160
|
+
*/
|
|
161
|
+
writeInt32BE(value) {
|
|
162
|
+
this.preWrite(4);
|
|
163
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setInt32(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, false);
|
|
164
|
+
this.postWrite(4);
|
|
165
|
+
}
|
|
166
|
+
/**
|
|
167
|
+
* Write a signed 16-bit integer to the buffer in little-endian format.
|
|
168
|
+
* @param value - The number to write.
|
|
169
|
+
*/
|
|
170
|
+
writeInt16LE(value) {
|
|
171
|
+
this.preWrite(2);
|
|
172
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setInt16(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, true);
|
|
173
|
+
this.postWrite(2);
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Write a signed 16-bit integer to the buffer in big-endian format.
|
|
177
|
+
* @param value - The number to write.
|
|
178
|
+
*/
|
|
179
|
+
writeInt16BE(value) {
|
|
180
|
+
this.preWrite(2);
|
|
181
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setInt16(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, false);
|
|
182
|
+
this.postWrite(2);
|
|
183
|
+
}
|
|
184
|
+
/**
|
|
185
|
+
* Write a 64-bit unsigned integer to the buffer in little-endian format.
|
|
186
|
+
* @param value - The number to write.
|
|
187
|
+
*/
|
|
188
|
+
writeUInt64LE(value) {
|
|
189
|
+
this.preWrite(8);
|
|
190
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setBigUint64(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, true);
|
|
191
|
+
this.postWrite(8);
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Write a 64-bit unsigned integer to the buffer in big-endian format.
|
|
195
|
+
* @param value - The number to write.
|
|
196
|
+
*/
|
|
197
|
+
writeUInt64BE(value) {
|
|
198
|
+
this.preWrite(8);
|
|
199
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setBigUint64(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, false);
|
|
200
|
+
this.postWrite(8);
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* Write a 64-bit signed integer to the buffer in little-endian format.
|
|
204
|
+
* @param value - The number to write.
|
|
205
|
+
*/
|
|
206
|
+
writeInt64LE(value) {
|
|
207
|
+
this.preWrite(8);
|
|
208
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setBigInt64(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, true);
|
|
209
|
+
this.postWrite(8);
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* Write a 64-bit signed integer to the buffer in big-endian format.
|
|
213
|
+
* @param value - The number to write.
|
|
214
|
+
*/
|
|
215
|
+
writeInt64BE(value) {
|
|
216
|
+
this.preWrite(8);
|
|
217
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setBigInt64(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, false);
|
|
218
|
+
this.postWrite(8);
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Write a 32-bit floating point number (f32, float) to the buffer in little-endian format.
|
|
222
|
+
* @param value - The number to write.
|
|
223
|
+
*/
|
|
224
|
+
writeFloat32LE(value) {
|
|
225
|
+
this.preWrite(4);
|
|
226
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setFloat32(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, true);
|
|
227
|
+
this.postWrite(4);
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Write a 64-bit floating point number (f64, double) to the buffer in little-endian format.
|
|
231
|
+
* @param value - The number to write.
|
|
232
|
+
*/
|
|
233
|
+
writeFloat64LE(value) {
|
|
234
|
+
this.preWrite(8);
|
|
235
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setFloat64(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, true);
|
|
236
|
+
this.postWrite(8);
|
|
237
|
+
}
|
|
238
|
+
/**
|
|
239
|
+
* Write a 32-bit floating point number (f32, float) to the buffer in big-endian format.
|
|
240
|
+
* @param value - The number to write.
|
|
241
|
+
*/
|
|
242
|
+
writeFloat32BE(value) {
|
|
243
|
+
this.preWrite(4);
|
|
244
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setFloat32(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, false);
|
|
245
|
+
this.postWrite(4);
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Write a 64-bit floating point number (f64, double) to the buffer in big-endian format.
|
|
249
|
+
* @param value - The number to write.
|
|
250
|
+
*/
|
|
251
|
+
writeFloat64BE(value) {
|
|
252
|
+
this.preWrite(8);
|
|
253
|
+
__classPrivateFieldGet(this, _BinaryWriter_view, "f").setFloat64(__classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), value, false);
|
|
254
|
+
this.postWrite(8);
|
|
255
|
+
}
|
|
256
|
+
/** Alias for `writeFloat32LE` */
|
|
257
|
+
writeFloat32(value) {
|
|
258
|
+
this.writeFloat32LE(value);
|
|
259
|
+
}
|
|
260
|
+
/** Alias for `writeFloat64LE` */
|
|
261
|
+
writeFloat64(value) {
|
|
262
|
+
this.writeFloat64LE(value);
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
265
|
+
* Write a null-terminated string to the buffer.
|
|
266
|
+
*
|
|
267
|
+
* @param value - The string to write.
|
|
268
|
+
*/
|
|
269
|
+
writeString(value) {
|
|
270
|
+
const encoder = new TextEncoder();
|
|
271
|
+
const bytes = encoder.encode(value);
|
|
272
|
+
this.preWrite(bytes.length + 1);
|
|
273
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
274
|
+
__classPrivateFieldGet(this, _BinaryWriter_data, "f")[__classPrivateFieldGet(this, _BinaryWriter_cursor, "f") + i] = bytes[i];
|
|
275
|
+
}
|
|
276
|
+
__classPrivateFieldGet(this, _BinaryWriter_data, "f")[__classPrivateFieldGet(this, _BinaryWriter_cursor, "f") + bytes.length] = 0;
|
|
277
|
+
this.postWrite(bytes.length + 1);
|
|
278
|
+
}
|
|
279
|
+
/**
|
|
280
|
+
* Write a buffer to the buffer.
|
|
281
|
+
*
|
|
282
|
+
* @param value - The buffer to write.
|
|
283
|
+
*/
|
|
284
|
+
writeBytes(value) {
|
|
285
|
+
this.preWrite(value.length);
|
|
286
|
+
__classPrivateFieldGet(this, _BinaryWriter_data, "f").set(value, __classPrivateFieldGet(this, _BinaryWriter_cursor, "f"));
|
|
287
|
+
this.postWrite(value.length);
|
|
288
|
+
}
|
|
289
|
+
/**
|
|
290
|
+
* Write a string to the buffer, without null-terminating it.
|
|
291
|
+
*
|
|
292
|
+
* @param value - The string to write.
|
|
293
|
+
*/
|
|
294
|
+
writeChars(value) {
|
|
295
|
+
const encoder = new TextEncoder();
|
|
296
|
+
const bytes = encoder.encode(value);
|
|
297
|
+
this.preWrite(bytes.length);
|
|
298
|
+
for (let i = 0; i < bytes.length; i++) {
|
|
299
|
+
__classPrivateFieldGet(this, _BinaryWriter_data, "f")[__classPrivateFieldGet(this, _BinaryWriter_cursor, "f") + i] = bytes[i];
|
|
300
|
+
}
|
|
301
|
+
this.postWrite(bytes.length);
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Save the buffer as a Uint8Array.
|
|
305
|
+
* @returns The buffer as a Uint8Array.
|
|
306
|
+
*/
|
|
307
|
+
toUint8Array() {
|
|
308
|
+
return Uint8Array.from(__classPrivateFieldGet(this, _BinaryWriter_data, "f").slice(0, __classPrivateFieldGet(this, _BinaryWriter_maxCursor, "f")));
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Increase the buffer size to the specified size if the buffer is too small.
|
|
312
|
+
* @param size - The size to increase the buffer to.
|
|
313
|
+
* @returns The new buffer size.
|
|
314
|
+
*/
|
|
315
|
+
ensureSize(size) {
|
|
316
|
+
if (__classPrivateFieldGet(this, _BinaryWriter_data, "f").byteLength < size) {
|
|
317
|
+
this.extendBuffer(size);
|
|
318
|
+
}
|
|
319
|
+
return __classPrivateFieldGet(this, _BinaryWriter_data, "f").byteLength;
|
|
320
|
+
}
|
|
321
|
+
/** Get the current length of the buffer. */
|
|
322
|
+
get length() {
|
|
323
|
+
return __classPrivateFieldGet(this, _BinaryWriter_maxCursor, "f");
|
|
324
|
+
}
|
|
325
|
+
/** Get the current capacity of the buffer. */
|
|
326
|
+
get capacity() {
|
|
327
|
+
return __classPrivateFieldGet(this, _BinaryWriter_data, "f").byteLength;
|
|
328
|
+
}
|
|
329
|
+
/** Allocate more space in the buffer, if needed. */
|
|
330
|
+
preWrite(size) {
|
|
331
|
+
if (__classPrivateFieldGet(this, _BinaryWriter_cursor, "f") + size > __classPrivateFieldGet(this, _BinaryWriter_data, "f").byteLength) {
|
|
332
|
+
let newSize;
|
|
333
|
+
if (__classPrivateFieldGet(this, _BinaryWriter_data, "f").byteLength >= 2048) {
|
|
334
|
+
newSize = __classPrivateFieldGet(this, _BinaryWriter_data, "f").byteLength + 2048;
|
|
335
|
+
}
|
|
336
|
+
else {
|
|
337
|
+
newSize = __classPrivateFieldGet(this, _BinaryWriter_data, "f").byteLength * 2;
|
|
338
|
+
}
|
|
339
|
+
if (__classPrivateFieldGet(this, _BinaryWriter_cursor, "f") + size > newSize) {
|
|
340
|
+
newSize = __classPrivateFieldGet(this, _BinaryWriter_cursor, "f") + size;
|
|
341
|
+
}
|
|
342
|
+
this.extendBuffer(newSize);
|
|
343
|
+
}
|
|
344
|
+
}
|
|
345
|
+
/** Allocate more space in the buffer. */
|
|
346
|
+
extendBuffer(length) {
|
|
347
|
+
const newData = new Uint8Array(length);
|
|
348
|
+
newData.set(__classPrivateFieldGet(this, _BinaryWriter_data, "f"));
|
|
349
|
+
__classPrivateFieldSet(this, _BinaryWriter_data, newData, "f");
|
|
350
|
+
__classPrivateFieldSet(this, _BinaryWriter_view, new DataView(newData.buffer), "f");
|
|
351
|
+
}
|
|
352
|
+
/** Update the cursor after writing to the buffer. */
|
|
353
|
+
postWrite(size) {
|
|
354
|
+
__classPrivateFieldSet(this, _BinaryWriter_cursor, __classPrivateFieldGet(this, _BinaryWriter_cursor, "f") + size, "f");
|
|
355
|
+
if (__classPrivateFieldGet(this, _BinaryWriter_cursor, "f") > __classPrivateFieldGet(this, _BinaryWriter_maxCursor, "f")) {
|
|
356
|
+
__classPrivateFieldSet(this, _BinaryWriter_maxCursor, __classPrivateFieldGet(this, _BinaryWriter_cursor, "f"), "f");
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
}
|
|
360
|
+
_BinaryWriter_data = new WeakMap(), _BinaryWriter_view = new WeakMap(), _BinaryWriter_maxCursor = new WeakMap(), _BinaryWriter_cursor = new WeakMap();
|
package/dist/mmw/analyze.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import BinarySeeker from
|
|
1
|
+
import { BinarySeeker } from "../lib/binaryseeker/mod.js";
|
|
2
2
|
const FlickType = ['none', 'up', 'left', 'right'];
|
|
3
3
|
const StepType = ['visible', 'hidden', 'ignored'];
|
|
4
4
|
const EaseType = ['linear', 'easeIn', 'easeOut', 'easeInOut', 'easeOutIn'];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "sonolus-next-rush-plus-engine",
|
|
3
|
-
"version": "1.3.
|
|
3
|
+
"version": "1.3.5",
|
|
4
4
|
"description": "A new Project Sekai inspired engine for Sonolus",
|
|
5
5
|
"author": "Hyeon2",
|
|
6
6
|
"repository": {
|
|
@@ -33,7 +33,6 @@
|
|
|
33
33
|
"build": "tsc -p . && node ./build.js"
|
|
34
34
|
},
|
|
35
35
|
"dependencies": {
|
|
36
|
-
"@sevenc-nanashi/binaryseeker": "npm:@jsr/sevenc-nanashi__binaryseeker@^1.2.1",
|
|
37
36
|
"@sonolus/core": "~7.14.2"
|
|
38
37
|
},
|
|
39
38
|
"devDependencies": {
|