mcbe-leveldb 1.3.4 → 1.5.0
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/Changelog.md +57 -4
- package/DBUtils.js +3 -2
- package/DBUtils.js.map +1 -1
- package/DBUtils.ts +20 -11
- package/LevelUtils.js +750 -46
- package/LevelUtils.js.map +1 -1
- package/LevelUtils.ts +890 -100
- package/nbtSchemas.js +52 -0
- package/nbtSchemas.js.map +1 -1
- package/nbtSchemas.ts +72 -0
- package/package.json +1 -1
package/Changelog.md
CHANGED
|
@@ -1,8 +1,61 @@
|
|
|
1
|
+
# v1.5.0
|
|
2
|
+
|
|
3
|
+
## Additions
|
|
4
|
+
|
|
5
|
+
- Added custom serializers and parsers for the following content types:
|
|
6
|
+
- `BlockEntity`
|
|
7
|
+
- `Entity`
|
|
8
|
+
- `PendingTicks`
|
|
9
|
+
- `RandomTicks`
|
|
10
|
+
|
|
11
|
+
## Changes
|
|
12
|
+
|
|
13
|
+
- Marked the following content types as deprecated:
|
|
14
|
+
- `FlatWorldLayers`
|
|
15
|
+
- `Entity`
|
|
16
|
+
|
|
17
|
+
# v1.4.0
|
|
18
|
+
|
|
19
|
+
## Critical fixes
|
|
20
|
+
|
|
21
|
+
- Fixed a bug where if the object passed into the `indices` parameter of the `generateChunkKeyFromIndices` function had a `subChunkIndex` property with a value of `undefined`, then the function would return the chunk key with the sub-chunk index set to `0` instead of not including the sub-chunk index in the key, which would result in incorrect chunk keys.
|
|
22
|
+
|
|
23
|
+
## Additions
|
|
24
|
+
|
|
25
|
+
- Added the format type for the following content types:
|
|
26
|
+
- `ForcedWorldCorruption`
|
|
27
|
+
- Added default values for the following content types:
|
|
28
|
+
- `Version`
|
|
29
|
+
- `FinalizedState`
|
|
30
|
+
- `LevelDat`
|
|
31
|
+
- `DynamicProperties`
|
|
32
|
+
- `ForcedWorldCorruption`
|
|
33
|
+
- Added the `rawFileExtension` property to the following content types:
|
|
34
|
+
- `StructureTemplate`
|
|
35
|
+
- `LevelDat`
|
|
36
|
+
- Added a custom serializer and parser for the `LevelDat` content types as it was actually not just pure NBT, as there was 8 bytes of important extra data before the NBT data.
|
|
37
|
+
- Added/Updated documentation for several content types.
|
|
38
|
+
- Added the `DynamicProperties` NBT schema.
|
|
39
|
+
|
|
40
|
+
## Changes
|
|
41
|
+
|
|
42
|
+
- Changed the return type of the `serialize` method for the `Data3D` and `SubChunkPrefix` content types from `Buffer<ArrayBufferLike>` to `Buffer<ArrayBuffer>`.
|
|
43
|
+
- Changed many types to use the more explicit `Buffer<ArrayBuffer>` type instead of `Buffer` (i.e. `Buffer<ArrayBufferLike>`).
|
|
44
|
+
- The properties of the `EntryContentTypeFormatData` type are now read-only.
|
|
45
|
+
|
|
46
|
+
## Fixes
|
|
47
|
+
|
|
48
|
+
- Fixed a bug where the `getChunkKeyIndices` function return an object containing a `subChunkIndex` property with a value of `undefined` when the key had no sub-chunk index, instead of not including that property at all.
|
|
49
|
+
|
|
50
|
+
## Performance Improvements
|
|
51
|
+
|
|
52
|
+
- Performance improvements to the `getKeysOfTypes` function when passing buffers to it (it now only gets the content type of each key once instead of twice).
|
|
53
|
+
|
|
1
54
|
# v1.3.4
|
|
2
55
|
|
|
3
56
|
## Critical Fixes
|
|
4
57
|
|
|
5
|
-
- Fixed a bug where the SNBT stringifier did not escape control characters (`\x00-\x1F`), characters in the `\uD800-\uDFFF` range, or characters `\u2028`or `\u2029`.
|
|
58
|
+
- Fixed a bug where the SNBT stringifier did not escape control characters (`\x00-\x1F`), characters in the `\uD800-\uDFFF` range, or characters `\u2028` or `\u2029`.
|
|
6
59
|
|
|
7
60
|
# v1.3.3
|
|
8
61
|
|
|
@@ -62,17 +115,17 @@
|
|
|
62
115
|
|
|
63
116
|
## Changes
|
|
64
117
|
|
|
65
|
-
- Replaced the `leveldb-zlib` package with the `@8crafter/leveldb-zlib` package.
|
|
118
|
+
- Replaced the [`leveldb-zlib`](https://www.npmjs.com/package/leveldb-zlib) package with the [`@8crafter/leveldb-zlib`](https://www.npmjs.com/package/@8crafter/leveldb-zlib) package.
|
|
66
119
|
|
|
67
120
|
# v1.1.0
|
|
68
121
|
|
|
69
122
|
## Additions
|
|
70
123
|
|
|
71
124
|
- Added a Changelog file.
|
|
72
|
-
- Added two new schemas:
|
|
125
|
+
- Added two new NBT schemas:
|
|
73
126
|
- `SubChunkPrefix`
|
|
74
127
|
- `SubChunkPrefixLayer`
|
|
75
|
-
- Added some more schema aliases.
|
|
128
|
+
- Added some more NBT schema aliases.
|
|
76
129
|
|
|
77
130
|
## Fixes
|
|
78
131
|
|
package/DBUtils.js
CHANGED
|
@@ -20,8 +20,9 @@ export function getKeysOfTypes(dbOrDBKeys, types) {
|
|
|
20
20
|
});
|
|
21
21
|
if (Array.isArray(dbOrDBKeys)) {
|
|
22
22
|
for (const key of dbOrDBKeys) {
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
const contentType = getContentTypeFromDBKey(key);
|
|
24
|
+
if (types.includes(contentType))
|
|
25
|
+
results[contentType].push(key);
|
|
25
26
|
}
|
|
26
27
|
return results;
|
|
27
28
|
}
|
package/DBUtils.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"DBUtils.js","sourceRoot":"","sources":["DBUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAA2B,MAAM,iBAAiB,CAAC;AACnF,OAAO,GAAG,MAAM,gBAAgB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"DBUtils.js","sourceRoot":"","sources":["DBUtils.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,uBAAuB,EAA2B,MAAM,iBAAiB,CAAC;AACnF,OAAO,GAAG,MAAM,gBAAgB,CAAC;AACjC,OAAO,EAAE,KAAK,EAAE,MAAM,kBAAkB,CAAC;AA0BzC,MAAM,UAAU,aAAa,CAA+B,UAA8B,EAAE,IAAO;IAC/F,I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
|
13
13
|
* @param type The {@link DBEntryContentType | content type} to look for.
|
|
14
14
|
* @returns The keys from the LevelDB with the specified content type, the keys are in Buffer format, this is because some keys contain binary data like chunk indices.
|
|
15
15
|
*/
|
|
16
|
-
export async function getKeysOfType<T extends DBEntryContentType>(db: LevelDB, type: T): Promise<Buffer[]>;
|
|
16
|
+
export async function getKeysOfType<T extends DBEntryContentType>(db: LevelDB, type: T): Promise<Buffer<ArrayBuffer>[]>;
|
|
17
17
|
/**
|
|
18
18
|
* Gets the keys from the list of LevelDB keys with a specific content type.
|
|
19
19
|
*
|
|
20
20
|
* @template T The content type to look for.
|
|
21
|
+
* @template TArrayBuffer The type of the buffers.
|
|
21
22
|
* @param dbKeys The LevelDB keys. Should be an array of Buffers.
|
|
22
23
|
* @param type The {@link DBEntryContentType | content type} to look for.
|
|
23
24
|
* @returns The keys from the provided LevelDB keys array with the specified content type, the keys are in Buffer format, this is because some keys contain binary data like chunk indices.
|
|
24
25
|
*/
|
|
25
|
-
export function getKeysOfType<T extends DBEntryContentType
|
|
26
|
-
|
|
26
|
+
export function getKeysOfType<T extends DBEntryContentType, TArrayBuffer extends ArrayBufferLike = ArrayBufferLike>(
|
|
27
|
+
dbKeys: Buffer<TArrayBuffer>[],
|
|
28
|
+
type: T
|
|
29
|
+
): Buffer<TArrayBuffer>[];
|
|
30
|
+
export function getKeysOfType<T extends DBEntryContentType>(dbOrDBKeys: LevelDB | Buffer[], type: T): Promise<Buffer<ArrayBuffer>[]> | Buffer[] {
|
|
27
31
|
if (Array.isArray(dbOrDBKeys)) return dbOrDBKeys.filter((key: Buffer): boolean => getContentTypeFromDBKey(key) === type);
|
|
28
|
-
return new Promise(async (resolve: (value: Buffer[]) => void): Promise<void> => {
|
|
29
|
-
const foundKeys: Buffer[] = [];
|
|
32
|
+
return new Promise(async (resolve: (value: Buffer<ArrayBuffer>[]) => void): Promise<void> => {
|
|
33
|
+
const foundKeys: Buffer<ArrayBuffer>[] = [];
|
|
30
34
|
for await (const [rawKey, _value] of dbOrDBKeys.getIterator({ keys: true, keyAsBuffer: true, values: false })) {
|
|
31
35
|
if (getContentTypeFromDBKey(rawKey) === type) foundKeys.push(rawKey);
|
|
32
36
|
}
|
|
@@ -45,31 +49,36 @@ export function getKeysOfType<T extends DBEntryContentType>(dbOrDBKeys: LevelDB
|
|
|
45
49
|
export async function getKeysOfTypes<T extends DBEntryContentType[] | readonly DBEntryContentType[]>(
|
|
46
50
|
db: LevelDB,
|
|
47
51
|
types: T
|
|
48
|
-
): Promise<{ [key in T[number]]: Buffer[] }>;
|
|
52
|
+
): Promise<{ [key in T[number]]: Buffer<ArrayBuffer>[] }>;
|
|
49
53
|
/**
|
|
50
54
|
* Gets the keys from the list of LevelDB keys with one of the specified content types.
|
|
51
55
|
*
|
|
52
56
|
* @template T The content types to look for.
|
|
57
|
+
* @template TArrayBuffer The type of the buffers.
|
|
53
58
|
* @param dbKeys The LevelDB keys. Should be an array of Buffers.
|
|
54
59
|
* @param types The {@link DBEntryContentType | content types} to look for.
|
|
55
60
|
* @returns An object mapping each of the specified content types to the keys from the provided LevelDB keys array with that content type, the keys are in Buffer format, this is because some keys contain binary data like chunk indices.
|
|
56
61
|
*/
|
|
57
|
-
export function getKeysOfTypes<T extends DBEntryContentType[] | readonly DBEntryContentType[]
|
|
62
|
+
export function getKeysOfTypes<T extends DBEntryContentType[] | readonly DBEntryContentType[], TArrayBuffer extends ArrayBufferLike>(
|
|
63
|
+
dbKeys: Buffer<TArrayBuffer>[],
|
|
64
|
+
types: T
|
|
65
|
+
): { [key in T[number]]: Buffer<TArrayBuffer>[] };
|
|
58
66
|
export function getKeysOfTypes<T extends DBEntryContentType[] | readonly DBEntryContentType[]>(
|
|
59
67
|
dbOrDBKeys: LevelDB | Buffer[],
|
|
60
68
|
types: T
|
|
61
|
-
): Promise<{ [key in T[number]]: Buffer[] }> | { [key in T[number]]: Buffer[] } {
|
|
62
|
-
const results = {} as { [key in T[number]]: Buffer[] };
|
|
69
|
+
): Promise<{ [key in T[number]]: Buffer<ArrayBuffer>[] }> | { [key in T[number]]: Buffer[] } {
|
|
70
|
+
const results = {} as { [key in T[number]]: Buffer<any>[] };
|
|
63
71
|
types.forEach((contentType: T[number]): void => {
|
|
64
72
|
results[contentType] = [];
|
|
65
73
|
});
|
|
66
74
|
if (Array.isArray(dbOrDBKeys)) {
|
|
67
75
|
for (const key of dbOrDBKeys) {
|
|
68
|
-
|
|
76
|
+
const contentType: DBEntryContentType = getContentTypeFromDBKey(key);
|
|
77
|
+
if (types.includes(contentType)) results[contentType as T[number]].push(key);
|
|
69
78
|
}
|
|
70
79
|
return results;
|
|
71
80
|
}
|
|
72
|
-
return new Promise(async (resolve: (value: { [key in T[number]]: Buffer[] }) => void): Promise<void> => {
|
|
81
|
+
return new Promise(async (resolve: (value: { [key in T[number]]: Buffer<ArrayBuffer>[] }) => void): Promise<void> => {
|
|
73
82
|
for await (const [rawKey, _value] of dbOrDBKeys.getIterator({ keys: true, keyAsBuffer: true, values: false })) {
|
|
74
83
|
const contentType: DBEntryContentType = getContentTypeFromDBKey(rawKey);
|
|
75
84
|
if (types.includes(contentType)) results[contentType as T[number]].push(rawKey);
|