brs-js 2.1.3 → 3.0.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.
Files changed (85) hide show
  1. package/README.md +271 -190
  2. package/dist/dist.js +6 -1
  3. package/dist/dist.js.map +1 -1
  4. package/dist/dist.mjs +7393 -0
  5. package/dist/dist.mjs.map +1 -0
  6. package/dist/dist.node.js +6 -1
  7. package/dist/dist.node.js.map +1 -1
  8. package/dist/dist.web.js +6 -1
  9. package/dist/dist.web.js.map +1 -1
  10. package/dist/src/brdb/bits.d.ts +13 -0
  11. package/dist/src/brdb/bits.d.ts.map +1 -0
  12. package/dist/src/brdb/brdb.d.ts +131 -0
  13. package/dist/src/brdb/brdb.d.ts.map +1 -0
  14. package/dist/src/brdb/brz.d.ts +51 -0
  15. package/dist/src/brdb/brz.d.ts.map +1 -0
  16. package/dist/src/brdb/bytes.d.ts +56 -0
  17. package/dist/src/brdb/bytes.d.ts.map +1 -0
  18. package/dist/src/brdb/catalog.d.ts +5 -0
  19. package/dist/src/brdb/catalog.d.ts.map +1 -0
  20. package/dist/src/brdb/componentDb.d.ts +8 -0
  21. package/dist/src/brdb/componentDb.d.ts.map +1 -0
  22. package/dist/src/brdb/fs.d.ts +16 -0
  23. package/dist/src/brdb/fs.d.ts.map +1 -0
  24. package/dist/src/brdb/guid.d.ts +11 -0
  25. package/dist/src/brdb/guid.d.ts.map +1 -0
  26. package/dist/src/brdb/index.d.ts +21 -0
  27. package/dist/src/brdb/index.d.ts.map +1 -0
  28. package/dist/src/brdb/msgpack.d.ts +23 -0
  29. package/dist/src/brdb/msgpack.d.ts.map +1 -0
  30. package/dist/src/brdb/pending.d.ts +11 -0
  31. package/dist/src/brdb/pending.d.ts.map +1 -0
  32. package/dist/src/brdb/reader.d.ts +176 -0
  33. package/dist/src/brdb/reader.d.ts.map +1 -0
  34. package/dist/src/brdb/schema.d.ts +73 -0
  35. package/dist/src/brdb/schema.d.ts.map +1 -0
  36. package/dist/src/brdb/schemaText.d.ts +8 -0
  37. package/dist/src/brdb/schemaText.d.ts.map +1 -0
  38. package/dist/src/brdb/schemas.d.ts +4 -0
  39. package/dist/src/brdb/schemas.d.ts.map +1 -0
  40. package/dist/src/brdb/world.d.ts +80 -0
  41. package/dist/src/brdb/world.d.ts.map +1 -0
  42. package/dist/src/{constants.d.ts → brs/constants.d.ts} +1 -1
  43. package/dist/src/brs/constants.d.ts.map +1 -0
  44. package/dist/src/brs/read.d.ts.map +1 -0
  45. package/dist/src/brs/read.v1.d.ts.map +1 -0
  46. package/dist/src/brs/read.v10.d.ts.map +1 -0
  47. package/dist/src/brs/read.v14.d.ts.map +1 -0
  48. package/dist/src/brs/read.v2.d.ts.map +1 -0
  49. package/dist/src/brs/read.v3.d.ts.map +1 -0
  50. package/dist/src/brs/read.v4.d.ts.map +1 -0
  51. package/dist/src/brs/read.v8.d.ts.map +1 -0
  52. package/dist/src/brs/read.v9.d.ts.map +1 -0
  53. package/dist/src/{types.d.ts → brs/types.d.ts} +35 -35
  54. package/dist/src/brs/types.d.ts.map +1 -0
  55. package/dist/src/{utils.d.ts → brs/utils.d.ts} +4 -9
  56. package/dist/src/brs/utils.d.ts.map +1 -0
  57. package/dist/src/{write.d.ts → brs/write.d.ts} +1 -1
  58. package/dist/src/brs/write.d.ts.map +1 -0
  59. package/dist/src/index.d.ts +10 -7
  60. package/dist/src/index.d.ts.map +1 -1
  61. package/dist/src/uuid.d.ts +1 -1
  62. package/dist/src/uuid.d.ts.map +1 -1
  63. package/package.json +42 -18
  64. package/dist/src/constants.d.ts.map +0 -1
  65. package/dist/src/read.d.ts.map +0 -1
  66. package/dist/src/read.v1.d.ts.map +0 -1
  67. package/dist/src/read.v10.d.ts.map +0 -1
  68. package/dist/src/read.v14.d.ts.map +0 -1
  69. package/dist/src/read.v2.d.ts.map +0 -1
  70. package/dist/src/read.v3.d.ts.map +0 -1
  71. package/dist/src/read.v4.d.ts.map +0 -1
  72. package/dist/src/read.v8.d.ts.map +0 -1
  73. package/dist/src/read.v9.d.ts.map +0 -1
  74. package/dist/src/types.d.ts.map +0 -1
  75. package/dist/src/utils.d.ts.map +0 -1
  76. package/dist/src/write.d.ts.map +0 -1
  77. /package/dist/src/{read.d.ts → brs/read.d.ts} +0 -0
  78. /package/dist/src/{read.v1.d.ts → brs/read.v1.d.ts} +0 -0
  79. /package/dist/src/{read.v10.d.ts → brs/read.v10.d.ts} +0 -0
  80. /package/dist/src/{read.v14.d.ts → brs/read.v14.d.ts} +0 -0
  81. /package/dist/src/{read.v2.d.ts → brs/read.v2.d.ts} +0 -0
  82. /package/dist/src/{read.v3.d.ts → brs/read.v3.d.ts} +0 -0
  83. /package/dist/src/{read.v4.d.ts → brs/read.v4.d.ts} +0 -0
  84. /package/dist/src/{read.v8.d.ts → brs/read.v8.d.ts} +0 -0
  85. /package/dist/src/{read.v9.d.ts → brs/read.v9.d.ts} +0 -0
@@ -0,0 +1,13 @@
1
+ import type { BrdbValue } from './schema';
2
+ /** Read bit i of a packed { Flags } column. Bytes past the end read as 0. */
3
+ export declare const bit: (flags: {
4
+ Flags: number[];
5
+ }, i: number) => boolean;
6
+ /** Accumulate booleans into a packed { Flags } column. */
7
+ export declare class BitFlags {
8
+ bytes: number[];
9
+ private bits;
10
+ push(v: boolean): void;
11
+ toValue(): BrdbValue;
12
+ }
13
+ //# sourceMappingURL=bits.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bits.d.ts","sourceRoot":"","sources":["../../../src/brdb/bits.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAE1C,6EAA6E;AAC7E,eAAO,MAAM,GAAG,GAAI,OAAO;IAAE,KAAK,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,GAAG,MAAM,KAAG,OACP,CAAC;AAEtD,0DAA0D;AAC1D,qBAAa,QAAQ;IACnB,KAAK,EAAE,MAAM,EAAE,CAAM;IACrB,OAAO,CAAC,IAAI,CAAK;IACjB,IAAI,CAAC,CAAC,EAAE,OAAO;IAKf,OAAO,IAAI,SAAS;CAGrB"}
@@ -0,0 +1,131 @@
1
+ import type { Compressor } from './brz';
2
+ import type { FoundFile, WorldFs } from './fs';
3
+ import type { PendingEntry } from './pending';
4
+ import { WorldReader } from './reader';
5
+ import { WriteBrzInput, WriteBrzOptions } from './world';
6
+ export interface BrdbStatement {
7
+ run(...params: unknown[]): {
8
+ lastInsertRowid: number | bigint;
9
+ };
10
+ get(...params: unknown[]): unknown;
11
+ all(...params: unknown[]): unknown[];
12
+ }
13
+ export interface BrdbSqlite {
14
+ exec(sql: string): unknown;
15
+ prepare(sql: string): BrdbStatement;
16
+ close(): void;
17
+ }
18
+ export interface BrdbBlob {
19
+ blobId: number;
20
+ compression: number;
21
+ sizeUncompressed: number;
22
+ sizeCompressed: number;
23
+ deltaBaseId: number | null;
24
+ hash: Uint8Array;
25
+ content: Uint8Array;
26
+ }
27
+ export interface BrdbRevision {
28
+ revisionId: number;
29
+ description: string;
30
+ createdAt: number;
31
+ }
32
+ export interface WritePendingOptions {
33
+ /** Revision timestamp in unix seconds. Defaults to the wall clock. */
34
+ createdAt?: number;
35
+ /** Blob compressor. undefined uses the instance default (zstd level 14
36
+ * when opened through the lazy openers); null stores raw. */
37
+ compress?: Compressor | null;
38
+ }
39
+ export declare const BRDB_SQLITE_SCHEMA: string;
40
+ export declare class Brdb implements WorldFs {
41
+ readonly db: BrdbSqlite;
42
+ /** Override how the better-sqlite3 module is resolved. Useful when a
43
+ * bundler or test runner cannot execute a native dynamic import. */
44
+ static engineLoader: (() => Promise<unknown>) | null;
45
+ /** zstd compressor applied to new blobs when no per-write compressor is
46
+ * given. The lazy openers set this; a directly-wrapped handle has none. */
47
+ defaultCompress: Compressor | null;
48
+ constructor(db: BrdbSqlite);
49
+ /** Create-container semantics on any handle: run the DDL and stamp the
50
+ * initial revision. */
51
+ static init(db: BrdbSqlite, createdAt?: number): Brdb;
52
+ /** Construct create/open semantics on a handle, closing it if construction
53
+ * (the DDL or the required-table guard) throws so a failed opener never
54
+ * leaks the underlying handle (and, on Windows, never leaves it locked). */
55
+ private static wrap;
56
+ /** Open an existing database file. Rejects (without creating a file) when
57
+ * the path does not already exist. */
58
+ static open(path: string): Promise<Brdb>;
59
+ /** Open an existing database file read-only. Rejects (without creating a
60
+ * file) when the path does not already exist. */
61
+ static openReadonly(path: string): Promise<Brdb>;
62
+ /** Create a new database file (container schema + initial revision). */
63
+ static create(path: string): Promise<Brdb>;
64
+ /** Open the file if it exists, otherwise create it. */
65
+ static openOrCreate(path: string): Promise<Brdb>;
66
+ /** New in-memory database. */
67
+ static memory(): Promise<Brdb>;
68
+ /** Open a database from serialized bytes. */
69
+ static fromBytes(bytes: Uint8Array): Promise<Brdb>;
70
+ /** Serialize the database to bytes (requires a better-sqlite3 handle). */
71
+ toBytes(): Uint8Array;
72
+ /** Write a world save as one revision. */
73
+ save(description: string, save: WriteBrzInput, options?: Omit<WriteBrzOptions, 'compress'> & WritePendingOptions): void;
74
+ /** Lazy world reader over this database (same surface as .brz reading).
75
+ * The reader caches decoded metadata (GlobalData, Owners, Bundle/World
76
+ * JSON) for its lifetime; if this Brdb is written to (save/writePending)
77
+ * after the reader is created, construct a fresh worldReader() rather
78
+ * than reusing the old one, or later reads may mix stale cached metadata
79
+ * with newly written chunk data. */
80
+ worldReader(): WorldReader;
81
+ sqliteSchema(): string;
82
+ createRevision(description: string, createdAt?: number): number;
83
+ revisions(): BrdbRevision[];
84
+ insertFolder(name: string, parentId: number | null, createdAt: number): number;
85
+ insertFile(name: string, parentId: number | null, contentId: number, createdAt: number): number;
86
+ /** Insert a blob (dedup by hash + uncompressed size), compressing when the
87
+ * compressor yields something strictly smaller. */
88
+ insertBlob(content: Uint8Array, hash: Uint8Array, compress: Compressor | null): number;
89
+ findBlobByHash(size: number, hash: Uint8Array): BrdbBlob | null;
90
+ findBlob(contentId: number): BrdbBlob;
91
+ deleteFile(fileId: number, deletedAt: number): void;
92
+ deleteFolder(folderId: number, deletedAt: number): void;
93
+ findFolder(parentId: number | null, name: string): number | null;
94
+ /** Like findFolder, but resolves against the tree as of a revision date
95
+ * instead of the current tree. Used by findFileByPathAtRevision so an
96
+ * ancestor folder that was soft-deleted after `date` does not hide a file
97
+ * that was still live at `date`. */
98
+ findFolderAtRevision(parentId: number | null, name: string, date: number): number | null;
99
+ findFile(parentId: number | null, name: string): FoundFile | null;
100
+ findFileAtRevision(parentId: number | null, name: string, date: number): FoundFile | null;
101
+ close(): void;
102
+ /** Merge a COMPLETE pending tree against the current tree in one
103
+ * transaction: identical files are noops, changed files are soft-deleted
104
+ * and reinserted, and existing entries absent from the pending tree are
105
+ * soft-deleted recursively. */
106
+ writePending(description: string, pending: PendingEntry[], options?: WritePendingOptions): void;
107
+ private currentFolders;
108
+ private currentFiles;
109
+ private mergeFolder;
110
+ private insertPending;
111
+ private deleteFolderRecursive;
112
+ /** Resolve a folder path. '' is the root. With no date, resolves against
113
+ * the current tree; with a date, resolves each segment against the tree
114
+ * as of that revision (see findFolderAtRevision). */
115
+ private folderIdOf;
116
+ findFileByPath(path: string): FoundFile | null;
117
+ /** Both folders and the leaf file resolve against the tree as of `date`,
118
+ * so a file is still reachable at a date before an ancestor folder was
119
+ * later soft-deleted. */
120
+ findFileByPathAtRevision(path: string, date: number): FoundFile | null;
121
+ childFolders(path: string): string[];
122
+ childFiles(path: string): string[];
123
+ /** Decompressed blob content. Empty files (contentId -1) yield empty
124
+ * bytes, matching the .brz reader's documented deviation. */
125
+ readBlob(contentId: number): Uint8Array;
126
+ readFile(path: string): Uint8Array;
127
+ /** The full current tree as a pending tree (folders first, then files,
128
+ * each in name order). */
129
+ toPending(): PendingEntry[];
130
+ }
131
+ //# sourceMappingURL=brdb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brdb.d.ts","sourceRoot":"","sources":["../../../src/brdb/brdb.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,OAA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EACvB,OAAO,GAAE,mBAAwB,GAChC,IAAI;IAuBP,OAAO,CAAC,cAAc;IAetB,OAAO,CAAC,YAAY;IAgBpB,OAAO,CAAC,WAAW;IAgDnB,OAAO,CAAC,aAAa;IAgCrB,OAAO,CAAC,qBAAqB;IAQ7B;;yDAEqD;IACrD,OAAO,CAAC,UAAU;IAsBlB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAU9C;;6BAEyB;IACzB,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI;IAUtE,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAMpC,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE;IAMlC;iEAC6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU;IAevC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU;IAMlC;8BAC0B;IAC1B,SAAS,IAAI,YAAY,EAAE;CAc5B"}
@@ -0,0 +1,51 @@
1
+ import type { FoundFile, WorldFs } from './fs';
2
+ import { PendingEntry } from './pending';
3
+ export type Compressor = (data: Uint8Array) => Uint8Array | null;
4
+ export interface BrzContainerOptions {
5
+ /** zstd compressor (e.g. node:zlib zstdCompressSync); return null to skip.
6
+ * Omitted -> every blob stored raw (still a valid archive, and what the
7
+ * byte-parity gates compare against). */
8
+ compress?: Compressor;
9
+ }
10
+ export declare function writeBrzContainer(root: PendingEntry[], options?: BrzContainerOptions): Uint8Array;
11
+ export declare class BrzReader implements WorldFs {
12
+ readonly folderParentIds: number[];
13
+ readonly folderNames: string[];
14
+ readonly fileParentIds: number[];
15
+ readonly fileContentIds: number[];
16
+ readonly fileNames: string[];
17
+ private blobs;
18
+ private blobData;
19
+ private folderLut;
20
+ private fileLut;
21
+ private pathCache;
22
+ private constructor();
23
+ static from(data: Uint8Array): BrzReader;
24
+ /** parentId -1 = root */
25
+ findFolder(parentId: number, name: string): number | null;
26
+ findFile(parentId: number, name: string): {
27
+ contentId: number;
28
+ } | null;
29
+ private folderIdOf;
30
+ /** Names of the subfolders of a folder path ('' = root), in id order.
31
+ * A missing path yields []. */
32
+ childFolders(path: string): string[];
33
+ /** Names of the files directly inside a folder path ('' = root), in id
34
+ * order. A missing path yields []. */
35
+ childFiles(path: string): string[];
36
+ blobMethod(contentId: number): number;
37
+ private blob;
38
+ /** Decompress (if needed) and verify size + BLAKE3. */
39
+ readBlob(contentId: number): Uint8Array;
40
+ /** '/'-separated path from the root. An empty file (contentId -1) returns
41
+ * an empty buffer (the reference reader treats empty files as unfindable
42
+ * — deliberate, documented deviation for usability). */
43
+ readFile(path: string): Uint8Array;
44
+ /** Path lookup returning the WorldFs FoundFile shape. createdAt is always
45
+ * 0: a .brz archive holds exactly one revision. */
46
+ findFileByPath(path: string): FoundFile | null;
47
+ findFileByPathAtRevision(path: string, _date: number): FoundFile | null;
48
+ /** All file paths in file-id (BFS) order. */
49
+ listPaths(): string[];
50
+ }
51
+ //# sourceMappingURL=brz.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"brz.d.ts","sourceRoot":"","sources":["../../../src/brdb/brz.ts"],"names":[],"mappings":"AAMA,OAAO,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC/C,OAAO,EAAE,YAAY,EAAe,MAAM,WAAW,CAAC;AAEtD,MAAM,MAAM,UAAU,GAAG,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,GAAG,IAAI,CAAC;AAEjE,MAAM,WAAW,mBAAmB;IAClC;;6CAEyC;IACzC,QAAQ,CAAC,EAAE,UAAU,CAAC;CACvB;AAED,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,YAAY,EAAE,EACpB,OAAO,GAAE,mBAAwB,GAChC,UAAU,CAsGZ;AAWD,qBAAa,SAAU,YAAW,OAAO;IAMrC,QAAQ,CAAC,eAAe,EAAE,MAAM,EA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 export declare class ByteWriter {
2
+ private buf;
3
+ private view;
4
+ private len;
5
+ private ensure;
6
+ get length(): number;
7
+ u8(v: number): void;
8
+ i8(v: number): void;
9
+ bytes(v: Uint8Array | number[]): void;
10
+ u16be(v: number): void;
11
+ u32be(v: number): void;
12
+ u64be(v: bigint): void;
13
+ i16be(v: number): void;
14
+ i32be(v: number): void;
15
+ i64be(v: bigint): void;
16
+ f32be(v: number): void;
17
+ f64be(v: number): void;
18
+ u16le(v: number): void;
19
+ u32le(v: number): void;
20
+ u64le(v: bigint): void;
21
+ i16le(v: number): void;
22
+ i32le(v: number): void;
23
+ i64le(v: bigint): void;
24
+ f32le(v: number): void;
25
+ f64le(v: number): void;
26
+ toBytes(): Uint8Array;
27
+ }
28
+ export declare class ByteReader {
29
+ data: Uint8Array;
30
+ private view;
31
+ offset: number;
32
+ constructor(data: Uint8Array, offset?: number);
33
+ get remaining(): number;
34
+ private need;
35
+ peek(): number;
36
+ u8(): number;
37
+ i8(): number;
38
+ bytes(n: number): Uint8Array;
39
+ u16be(): number;
40
+ u32be(): number;
41
+ u64be(): bigint;
42
+ i16be(): number;
43
+ i32be(): number;
44
+ i64be(): bigint;
45
+ f32be(): number;
46
+ f64be(): number;
47
+ u16le(): number;
48
+ u32le(): number;
49
+ u64le(): bigint;
50
+ i16le(): number;
51
+ i32le(): number;
52
+ i64le(): bigint;
53
+ f32le(): number;
54
+ f64le(): number;
55
+ }
56
+ //# sourceMappingURL=bytes.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"bytes.d.ts","sourceRoot":"","sources":["../../../src/brdb/bytes.ts"],"names":[],"mappings":"AAGA,qBAAa,UAAU;IACrB,OAAO,CAAC,GAAG,CAAuB;IAClC,OAAO,CAAC,IAAI,CAAiC;IAC7C,OAAO,CAAC,GAAG,CAAK;IAEhB,OAAO,CAAC,MAAM;IAUd,IAAI,MAAM,IAAI,MAAM,CAEnB;IAED,EAAE,CAAC,CAAC,EAAE,MAAM;IAKZ,EAAE,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,MAAM;IAMf,KAAK,IAAI,MAAM;IAMf,KAAK,IAAI,MAAM;IAMf,KAAK,IAAI,MAAM;IAMf,KAAK,IAAI,MAAM;IAMf,KAAK,IAAI,MAAM;IAMf,KAAK,IAAI,MAAM;IAMf,KAAK,IAAI,MAAM;CAMhB"}
@@ -0,0 +1,5 @@
1
+ export declare const BASIC_BRICK_ASSETS: readonly string[];
2
+ export declare const PROCEDURAL_BRICK_ASSETS: readonly string[];
3
+ /** Classify a brick asset as procedural (parametric, carries a size) or basic. */
4
+ export declare function isProceduralAsset(name: string): boolean;
5
+ //# sourceMappingURL=catalog.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"catalog.d.ts","sourceRoot":"","sources":["../../../src/brdb/catalog.ts"],"names":[],"mappings":"AAGA,eAAO,MAAM,kBAAkB,EAAE,SAAS,MAAM,EAwJ/C,CAAC;AAEF,eAAO,MAAM,uBAAuB,EAAE,SAAS,MAAM,EAuCpD,CAAC;AAKF,kFAAkF;AAClF,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAKvD"}
@@ -0,0 +1,8 @@
1
+ /** Component type name -> data struct name ("None" = no data struct). */
2
+ export declare const COMPONENT_TYPE_STRUCTS: ReadonlyMap<string, string>;
3
+ /** Known wire port names (a save's port registry is built from the ports
4
+ * its wires actually use, but names must come from this vocabulary). */
5
+ export declare const WIRE_PORT_NAMES: readonly string[];
6
+ /** Entity type name -> data class name. */
7
+ export declare const ENTITY_TYPE_STRUCTS: ReadonlyMap<string, string>;
8
+ //# sourceMappingURL=componentDb.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"componentDb.d.ts","sourceRoot":"","sources":["../../../src/brdb/componentDb.ts"],"names":[],"mappings":"AAGA,yEAAyE;AACzE,eAAO,MAAM,sBAAsB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAkiC7D,CAAC;AAEH;wEACwE;AACxE,eAAO,MAAM,eAAe,EAAE,SAAS,MAAM,EAsiB5C,CAAC;AAEF,2CAA2C;AAC3C,eAAO,MAAM,mBAAmB,EAAE,WAAW,CAAC,MAAM,EAAE,MAAM,CAG1D,CAAC"}
@@ -0,0 +1,16 @@
1
+ export interface FoundFile {
2
+ contentId: number;
3
+ createdAt: number;
4
+ }
5
+ export interface WorldFs {
6
+ findFileByPath(path: string): FoundFile | null;
7
+ /** The file revision whose [created_at, deleted_at) interval contains
8
+ * date. For single-revision containers this is findFileByPath. */
9
+ findFileByPathAtRevision(path: string, date: number): FoundFile | null;
10
+ /** Decompressed blob content. */
11
+ readBlob(contentId: number): Uint8Array;
12
+ readFile(path: string): Uint8Array;
13
+ /** Names of the subfolders of a folder path ('' = root). */
14
+ childFolders(path: string): string[];
15
+ }
16
+ //# sourceMappingURL=fs.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"fs.d.ts","sourceRoot":"","sources":["../../../src/brdb/fs.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,SAAS;IACxB,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,OAAO;IACtB,cAAc,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IAC/C;sEACkE;IAClE,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,IAAI,CAAC;IACvE,iCAAiC;IACjC,QAAQ,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAC;IACxC,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,UAAU,CAAC;IACnC,4DAA4D;IAC5D,YAAY,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC;CACtC"}
@@ -0,0 +1,11 @@
1
+ export interface BrGuid {
2
+ A: number;
3
+ B: number;
4
+ C: number;
5
+ D: number;
6
+ }
7
+ /** Owner-table row 0 sentinel (the PUBLIC owner). */
8
+ export declare const PUBLIC_GUID: BrGuid;
9
+ export declare function uuidToGuid(uuid: string): BrGuid;
10
+ export declare function guidToUuid(guid: BrGuid): string;
11
+ //# sourceMappingURL=guid.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"guid.d.ts","sourceRoot":"","sources":["../../../src/brdb/guid.ts"],"names":[],"mappings":"AAMA,MAAM,WAAW,MAAM;IACrB,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;IACV,CAAC,EAAE,MAAM,CAAC;CACX;AAED,qDAAqD;AACrD,eAAO,MAAM,WAAW,EAAE,MAKzB,CAAC;AAEF,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAS/C;AAED,wBAAgB,UAAU,CAAC,IAAI,EAAE,MAAM,GAAG,MAAM,CAQ/C"}
@@ -0,0 +1,21 @@
1
+ export { CHUNK_HALF, CHUNK_SIZE, saveToPendingFs, toRelative, writeBrzLegacy, } from './world';
2
+ export type { BrdbBrickExtras, BrdbComponentInput, BrdbSaveExtras, BrdbWireEndpointInput, BrdbWireInput, BundleJson, WriteBrzInput, WriteBrzOptions, WriteBrzSave, } from './world';
3
+ export { MAIN_GRID, WorldReader } from './reader';
4
+ export type { BrickChunkRef, BrzWorldBrick, ChunkCoord, ComponentInstance, EntityChunkIndex, EntityChunkRef, EntityRecord, FoundFile, RemoteWireEndpoint, WireChunk, WireEndpoint, WorldFs, } from './reader';
5
+ export { BrzReader, writeBrzContainer } from './brz';
6
+ export type { BrzContainerOptions, Compressor } from './brz';
7
+ export { BrdbSchema, embeddedSchema } from './schema';
8
+ export type { BrdbValue, BrdbVariant, PropDesc, SchemaSource, SchemaSourceProp, } from './schema';
9
+ export type { SchemaData } from './schemaText';
10
+ export type { EmbeddedSchemaName } from './schemas';
11
+ export { guidToUuid, PUBLIC_GUID, uuidToGuid } from './guid';
12
+ export type { BrGuid } from './guid';
13
+ export { file, folder } from './pending';
14
+ export type { PendingEntry, PendingNode } from './pending';
15
+ export { isProceduralAsset } from './catalog';
16
+ export { Brdb, BRDB_SQLITE_SCHEMA } from './brdb';
17
+ export type { BrdbBlob, BrdbRevision, BrdbSqlite, BrdbStatement, WritePendingOptions, } from './brdb';
18
+ export { bit, BitFlags } from './bits';
19
+ export { ByteReader, ByteWriter } from './bytes';
20
+ export * as msgpack from './msgpack';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/brdb/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,UAAU,EACV,eAAe,EACf,UAAU,EACV,cAAc,GACf,MAAM,SAAS,CAAC;AACjB,YAAY,EACV,eAAe,EACf,kBAAkB,EAClB,cAAc,EACd,qBAAqB,EACrB,aAAa,EACb,UAAU,EACV,aAAa,EACb,eAAe,EACf,YAAY,GACb,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAClD,YAAY,EACV,aAAa,EACb,aAAa,EACb,UAAU,EACV,iBAAiB,EACjB,gBAAgB,EAChB,cAAc,EACd,YAAY,EACZ,SAAS,EACT,kBAAkB,EAClB,SAAS,EACT,YAAY,EACZ,OAAO,GACR,MAAM,UAAU,CAAC;AAClB,OAAO,EAAE,SAAS,EAAE,iBAAiB,EAAE,MAAM,OAAO,CAAC;AACrD,YAAY,EAAE,mBAAmB,EAAE,UAAU,EAAE,MAAM,OAAO,CAAC;AAC7D,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AACtD,YAAY,EACV,SAAS,EACT,WAAW,EACX,QAAQ,EACR,YAAY,EACZ,gBAAgB,GACjB,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC/C,YAAY,EAAE,kBAAkB,EAAE,MAAM,WAAW,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AAC7D,YAAY,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AACrC,OAAO,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC;AAC3D,OAAO,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,kBAAkB,EAAE,MAAM,QAAQ,CAAC;AAClD,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,UAAU,EACV,aAAa,EACb,mBAAmB,GACpB,MAAM,QAAQ,CAAC;AAIhB,OAAO,EAAE,GAAG,EAAE,QAAQ,EAAE,MAAM,QAAQ,CAAC;AACvC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC"}
@@ -0,0 +1,23 @@
1
+ import { ByteReader, ByteWriter } from './bytes';
2
+ export declare const mpNil: (w: ByteWriter) => void;
3
+ export declare const mpBool: (w: ByteWriter, v: boolean) => void;
4
+ export declare function mpU8(w: ByteWriter, v: number): void;
5
+ export declare function mpUint(w: ByteWriter, v: number): void;
6
+ export declare function mpInt(w: ByteWriter, v: number): void;
7
+ export declare function mpF32(w: ByteWriter, v: number): void;
8
+ export declare function mpF64(w: ByteWriter, v: number): void;
9
+ export declare function mpStr(w: ByteWriter, s: string): void;
10
+ export declare function mpBinHeader(w: ByteWriter, len: number): void;
11
+ export declare function mpArrayHeader(w: ByteWriter, len: number): void;
12
+ export declare function mpMapHeader(w: ByteWriter, len: number): void;
13
+ export declare function rdInt(r: ByteReader): number;
14
+ export declare function rdUint(r: ByteReader): number;
15
+ export declare function rdF32(r: ByteReader): number;
16
+ export declare function rdF64(r: ByteReader): number;
17
+ export declare function rdBool(r: ByteReader): boolean;
18
+ export declare function rdStr(r: ByteReader): string;
19
+ export declare function rdBinLen(r: ByteReader): number;
20
+ export declare function rdArrayLen(r: ByteReader): number;
21
+ export declare function rdMapLen(r: ByteReader): number;
22
+ export declare function rdNil(r: ByteReader): void;
23
+ //# sourceMappingURL=msgpack.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"msgpack.d.ts","sourceRoot":"","sources":["../../../src/brdb/msgpack.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAUjD,eAAO,MAAM,KAAK,GAAI,GAAG,UAAU,SAAe,CAAC;AACnD,eAAO,MAAM,MAAM,GAAI,GAAG,UAAU,EAAE,GAAG,OAAO,SAA0B,CAAC;AAI3E,wBAAgB,IAAI,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,QAU5C;AAGD,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,QAiB9C;AAID,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,QA+B7C;AAID,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,QAM7C;AAGD,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,QAO7C;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,EAAE,CAAC,EAAE,MAAM,QAe7C;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,QAWrD;AAED,wBAAgB,aAAa,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,QASvD;AAED,wBAAgB,WAAW,CAAC,CAAC,EAAE,UAAU,EAAE,GAAG,EAAE,MAAM,QASrD;AAyBD,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAwB3C;AAMD,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAsB5C;AAGD,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAkB3C;AAGD,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAwB3C;AAED,wBAAgB,MAAM,CAAC,CAAC,EAAE,UAAU,GAAG,OAAO,CAK7C;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAS3C;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAM9C;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAMhD;AAED,wBAAgB,QAAQ,CAAC,CAAC,EAAE,UAAU,GAAG,MAAM,CAM9C;AAED,wBAAgB,KAAK,CAAC,CAAC,EAAE,UAAU,GAAG,IAAI,CAGzC"}
@@ -0,0 +1,11 @@
1
+ export type PendingEntry = [name: string, node: PendingNode];
2
+ export type PendingNode = {
3
+ type: 'folder';
4
+ children: PendingEntry[];
5
+ } | {
6
+ type: 'file';
7
+ content: Uint8Array;
8
+ };
9
+ export declare const folder: (children: PendingEntry[]) => PendingNode;
10
+ export declare const file: (content: Uint8Array) => PendingNode;
11
+ //# sourceMappingURL=pending.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"pending.d.ts","sourceRoot":"","sources":["../../../src/brdb/pending.ts"],"names":[],"mappings":"AAGA,MAAM,MAAM,YAAY,GAAG,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,CAAC,CAAC;AAC7D,MAAM,MAAM,WAAW,GACnB;IAAE,IAAI,EAAE,QAAQ,CAAC;IAAC,QAAQ,EAAE,YAAY,EAAE,CAAA;CAAE,GAC5C;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,UAAU,CAAA;CAAE,CAAC;AAE1C,eAAO,MAAM,MAAM,GAAI,UAAU,YAAY,EAAE,KAAG,WAGhD,CAAC;AAEH,eAAO,MAAM,IAAI,GAAI,SAAS,UAAU,KAAG,WAGzC,CAAC"}
@@ -0,0 +1,176 @@
1
+ import type { Collision, Owner, Vector } from '../brs/types';
2
+ import type { WorldFs } from './fs';
3
+ import { BrdbSchema, BrdbValue } from './schema';
4
+ import { BundleJson } from './world';
5
+ export type { FoundFile, WorldFs } from './fs';
6
+ export declare const MAIN_GRID = 1;
7
+ export interface ChunkCoord {
8
+ x: number;
9
+ y: number;
10
+ z: number;
11
+ }
12
+ export interface BrickChunkRef {
13
+ index: ChunkCoord;
14
+ offset: ChunkCoord;
15
+ size: number;
16
+ numBricks: number;
17
+ numComponents: number;
18
+ numWires: number;
19
+ }
20
+ export interface EntityChunkRef {
21
+ index: ChunkCoord;
22
+ numEntities: number;
23
+ }
24
+ export interface EntityChunkIndex {
25
+ nextPersistentIndex: number;
26
+ chunks: EntityChunkRef[];
27
+ }
28
+ export interface ComponentInstance {
29
+ typeName: string;
30
+ structName: string | null;
31
+ /** the owning brick's local index within its chunk */
32
+ brickIndex: number;
33
+ data: Record<string, BrdbValue> | null;
34
+ }
35
+ export interface WireEndpoint {
36
+ /** the endpoint brick's local index within its chunk */
37
+ brickIndex: number;
38
+ componentType: string;
39
+ port: string;
40
+ }
41
+ export interface RemoteWireEndpoint extends WireEndpoint {
42
+ gridId: number;
43
+ chunk: ChunkCoord;
44
+ }
45
+ export interface WireChunk {
46
+ /** wires whose source is in the same grid+chunk as the target */
47
+ local: Array<{
48
+ source: WireEndpoint;
49
+ target: WireEndpoint;
50
+ }>;
51
+ /** wires whose source lives in another grid or chunk */
52
+ remote: Array<{
53
+ source: RemoteWireEndpoint;
54
+ target: WireEndpoint;
55
+ }>;
56
+ }
57
+ export interface EntityRecord {
58
+ typeName: string;
59
+ className: string | null;
60
+ persistentIndex: number;
61
+ ownerIndex: number;
62
+ originalOwnerIndex: number;
63
+ location: {
64
+ X: number;
65
+ Y: number;
66
+ Z: number;
67
+ };
68
+ rotation: {
69
+ X: number;
70
+ Y: number;
71
+ Z: number;
72
+ W: number;
73
+ };
74
+ frozen: boolean;
75
+ sleeping: boolean;
76
+ linearVelocity: {
77
+ X: number;
78
+ Y: number;
79
+ Z: number;
80
+ };
81
+ angularVelocity: {
82
+ X: number;
83
+ Y: number;
84
+ Z: number;
85
+ };
86
+ colors: Record<string, BrdbValue>;
87
+ remainingLifeSpan: number;
88
+ data: Record<string, BrdbValue> | null;
89
+ }
90
+ export interface BrzWorldBrick {
91
+ asset_name_index: number;
92
+ size: Vector;
93
+ position: Vector;
94
+ direction: number;
95
+ rotation: number;
96
+ collision: Collision;
97
+ visibility: boolean;
98
+ material_index: number;
99
+ material_intensity: number;
100
+ color: [number, number, number];
101
+ owner_index: number;
102
+ }
103
+ /** Convert one linear-light color channel (0-255) to sRGB. Saves whose
104
+ * colors are stored linear (bColorsAreLinear true, or the field missing
105
+ * entirely on older saves) need this on read; new saves store sRGB already
106
+ * and skip the conversion. Values at or below 0x0F scale into a 15-wide
107
+ * range instead of 255, matching the low-value storage convention used
108
+ * throughout the color format. */
109
+ export declare function linearToSrgb(v: number): number;
110
+ /** Reads a .brz or .brdb world lazily through a WorldFs. Schema blobs and
111
+ * decoded metadata (GlobalData, Owners, Bundle/World JSON) are cached for
112
+ * the lifetime of the reader; chunk payloads are always decoded fresh. For
113
+ * a .brz this is safe by construction (the archive never changes), but a
114
+ * reader built over a live Brdb (Brdb.worldReader()) must not be reused
115
+ * across a write to that database: construct a new reader afterward so
116
+ * cached metadata cannot mix with newly written chunk data. */
117
+ export declare class WorldReader {
118
+ readonly fs: WorldFs;
119
+ readonly worldId: number;
120
+ private schemas;
121
+ private values;
122
+ constructor(fs: WorldFs, worldId?: number);
123
+ static from(data: Uint8Array): WorldReader;
124
+ private path;
125
+ /** Parse a .schema blob once per revision; later calls return the cached
126
+ * schema. The public form resolves the schema file's own (latest)
127
+ * revision. */
128
+ schema(path: string): BrdbSchema;
129
+ /** Schema as it existed at `revision` (a created_at timestamp). Schemas
130
+ * evolve over a world's history; data files must decode with the schema
131
+ * revision that was live when they were written. */
132
+ private schemaAt;
133
+ private decode;
134
+ private cached;
135
+ bundle(): BundleJson;
136
+ environment(): {
137
+ environment: string;
138
+ };
139
+ globalData(): any;
140
+ owners(): any;
141
+ /** Basic asset names followed by procedural — decoded brick
142
+ * asset_name_index values point into this combined list. */
143
+ brickAssets(): string[];
144
+ materials(): string[];
145
+ /** Owner rows 1.. (the PUBLIC row 0 is excluded). */
146
+ brickOwners(): Owner[];
147
+ /** Grid ids under Bricks/Grids: 1 = the main grid, ≥2 = entity sub-grids. */
148
+ gridIds(): number[];
149
+ brickChunkIndex(gridId?: number): BrickChunkRef[];
150
+ /** Decode one brick chunk's SoA. Not cached: chunk payloads are the bulk
151
+ * of an archive and are meant to be streamed, not retained. */
152
+ brickChunkSoa(gridId: number, chunk: ChunkCoord): any;
153
+ /** Lazily decode a grid's bricks, one chunk at a time. Positions are
154
+ * relative to the grid's origin: world origin for the main grid (1),
155
+ * entity-relative for sub-grids (≥2). */
156
+ bricks(gridId?: number): Generator<BrzWorldBrick, void, void>;
157
+ /** Entity chunk registry. */
158
+ entityChunkIndex(): EntityChunkIndex;
159
+ /** Decode a component chunk: the SoA plus each instance's trailing data
160
+ * struct. Instances stream in counter order; a type whose data-struct
161
+ * slot is missing or "None" contributes no trailing bytes. */
162
+ componentChunk(gridId: number, chunk: ChunkCoord): {
163
+ soa: any;
164
+ components: ComponentInstance[];
165
+ };
166
+ /** Decode a wire chunk. Wires live in the TARGET's grid+chunk; local
167
+ * rows are same-grid-same-chunk sources, remote rows carry the source
168
+ * grid + chunk. Component/port names resolve through GlobalData. */
169
+ wireChunk(gridId: number, chunk: ChunkCoord): WireChunk;
170
+ /** Decode one entity chunk: the SoA plus each entity's trailing data
171
+ * struct (gated on EntityDataClassNames: absent or "None" = no struct). */
172
+ entityChunk(chunk: ChunkCoord): EntityRecord[];
173
+ /** Lazily decode every entity, one chunk at a time. */
174
+ entities(): Generator<EntityRecord, void, void>;
175
+ }
176
+ //# sourceMappingURL=reader.d.ts.map
@@ -0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