brs-js 2.1.3 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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 +7389 -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 +41 -17
  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
package/README.md CHANGED
@@ -1,10 +1,10 @@
1
1
  # brs.js
2
2
 
3
- Read and write Brickadia save files (.brs)
3
+ Read and write Brickadia save files (.brs, .brz)
4
4
 
5
- Currently supports save versions <= 10
5
+ Currently supports all BRS save versions. BRS Files are no longer supported as of Brickadia EA3.
6
6
 
7
- **Warning:** __Unreal Engine uses numbers potentially larger than Javascript can handle.__
7
+ **Warning:** **Unreal Engine uses numbers potentially larger than Javascript can handle.**
8
8
 
9
9
  ## Install
10
10
 
@@ -134,47 +134,47 @@ Unsigned ints, while unlikely, may overflow.
134
134
 
135
135
  **Fields:** (optional fields during `brs.write(save)` will be set to default)
136
136
 
137
- | field | type | default | optional | description |
138
- |-----------------------------|--------|--------------------------------------|----------|----------------------------------|
139
- | version | short | Latest Save Version | auto | Save file version |
140
- | game_version | int | Game Version | &#9745; | Saving version of the game |
141
- | map | string | 'Unknown' | &#9745; | Map where the save was generated |
142
- | author.id | uuid | 00000000-0000-0000-0000-000000000000 | &#9745; | Save author UUID |
143
- | author.name | string | 'Unknown' | &#9745; | Save author name |
144
- | description | string | '' (Empty String) | &#9745; | Save author name |
145
- | save_time | array | [0, 0, 0, 0, 0, 0, 0, 0] | &#9745; | UTC in bytes of creation time |
146
- | brick_count | int | Number of bricks in `bricks` | auto | Number of bricks in save |
147
- | mods | array | [] | &#9745; | In game mods required for load |
148
- | brick_assets | array | ['PB_DefaultBrick'] | &#9745; | List of brick assets |
149
- | colors | array | [] | &#9745; | List of colorset colors |
150
- | materials | array | ['BMC_Plastic'] | &#9745; | List of used materials |
151
- | physical_materials | array | [] | &#9745; | List of physical materials |
152
- | brick_owners | array | [{}] | &#9745; | Brick owner list |
153
- | brick_owners[].id | uuid | 00000000-0000-0000-0000-000000000000 | &#9745; | Brick owner list user uuid |
154
- | brick_owners[].name | string | 'Unknown' | &#9745; | Brick owner list user name |
155
- | brick_owners[].display_name | string | 'Unknown' | &#9745; | Brick owner list display name |
156
- | preview | array | undefined | &#9745; | 1280x720 png screenshot data |
157
- | bricks | array | | | List of bricks in the save |
158
- | bricks[].asset_name_index | int | 0 (0 indexed) | &#9745; | Index of asset in `brick_assets` |
159
- | bricks[].size | array | | | Brick size |
160
- | bricks[].position | array | | | Brick position |
161
- | bricks[].direction | int | 4 (Positive Z, Upward) | &#9745; | Brick axis / facing direction |
162
- | bricks[].rotation | int | 0 (0 degrees) | &#9745; | Brick rotation on axis |
163
- | bricks[].collision | bool | true | &#9745; | Brick has collision with players |
164
- | bricks[].collision | object | | &#9745; | Brick collision in general |
165
- | bricks[].visibility | bool | true | &#9745; | Brick renders to players |
166
- | bricks[].material_index | int | 0 (0 indexed) | &#9745; | Index of material in `materials` |
167
- | bricks[].material_intensity | int | 0 (0 indexed) | &#9745; | Material intensity (0-10) |
168
- | bricks[].physical_index | int | 0 (0 indexed) | &#9745; | Index of physical material |
169
- | bricks[].color *(colorset)* | int | 0 | &#9745; | Index of color in `colors` |
170
- | bricks[].color *(rgba)* | array | [255, 255, 255, 255] | &#9745; | Color in RGBA Bytes |
171
- | bricks[].color *(rgb)* | array | [255, 255, 255] *(v9+)* | &#9745; | Color in RGBA Bytes |
172
- | bricks[].owner_index | int | 1 (1 indexed) | &#9745; | Index of owner in `brick_owners` |
173
- | bricks[].components | object | {} | &#9745; | Components on this brick |
174
- | components | object | {} | &#9745; | List of components in the save |
175
- | components[].version | int | | | Game version for this component |
176
- | components[].brick_indices | array | | | Indices of assigned bricks |
177
- | components[].properties | object | | | Map of properties names and types|
137
+ | field | type | default | optional | description |
138
+ | --------------------------- | ------ | ------------------------------------ | -------- | --------------------------------- |
139
+ | version | short | Latest Save Version | auto | Save file version |
140
+ | game_version | int | Game Version | &#9745; | Saving version of the game |
141
+ | map | string | 'Unknown' | &#9745; | Map where the save was generated |
142
+ | author.id | uuid | 00000000-0000-0000-0000-000000000000 | &#9745; | Save author UUID |
143
+ | author.name | string | 'Unknown' | &#9745; | Save author name |
144
+ | description | string | '' (Empty String) | &#9745; | Save author name |
145
+ | save_time | array | [0, 0, 0, 0, 0, 0, 0, 0] | &#9745; | UTC in bytes of creation time |
146
+ | brick_count | int | Number of bricks in `bricks` | auto | Number of bricks in save |
147
+ | mods | array | [] | &#9745; | In game mods required for load |
148
+ | brick_assets | array | ['PB_DefaultBrick'] | &#9745; | List of brick assets |
149
+ | colors | array | [] | &#9745; | List of colorset colors |
150
+ | materials | array | ['BMC_Plastic'] | &#9745; | List of used materials |
151
+ | physical_materials | array | [] | &#9745; | List of physical materials |
152
+ | brick_owners | array | [{}] | &#9745; | Brick owner list |
153
+ | brick_owners[].id | uuid | 00000000-0000-0000-0000-000000000000 | &#9745; | Brick owner list user uuid |
154
+ | brick_owners[].name | string | 'Unknown' | &#9745; | Brick owner list user name |
155
+ | brick_owners[].display_name | string | 'Unknown' | &#9745; | Brick owner list display name |
156
+ | preview | array | undefined | &#9745; | 1280x720 png screenshot data |
157
+ | bricks | array | | | List of bricks in the save |
158
+ | bricks[].asset_name_index | int | 0 (0 indexed) | &#9745; | Index of asset in `brick_assets` |
159
+ | bricks[].size | array | | | Brick size |
160
+ | bricks[].position | array | | | Brick position |
161
+ | bricks[].direction | int | 4 (Positive Z, Upward) | &#9745; | Brick axis / facing direction |
162
+ | bricks[].rotation | int | 0 (0 degrees) | &#9745; | Brick rotation on axis |
163
+ | bricks[].collision | bool | true | &#9745; | Brick has collision with players |
164
+ | bricks[].collision | object | | &#9745; | Brick collision in general |
165
+ | bricks[].visibility | bool | true | &#9745; | Brick renders to players |
166
+ | bricks[].material_index | int | 0 (0 indexed) | &#9745; | Index of material in `materials` |
167
+ | bricks[].material_intensity | int | 0 (0 indexed) | &#9745; | Material intensity (0-10) |
168
+ | bricks[].physical_index | int | 0 (0 indexed) | &#9745; | Index of physical material |
169
+ | bricks[].color _(colorset)_ | int | 0 | &#9745; | Index of color in `colors` |
170
+ | bricks[].color _(rgba)_ | array | [255, 255, 255, 255] | &#9745; | Color in RGBA Bytes |
171
+ | bricks[].color _(rgb)_ | array | [255, 255, 255] _(v9+)_ | &#9745; | Color in RGBA Bytes |
172
+ | bricks[].owner_index | int | 1 (1 indexed) | &#9745; | Index of owner in `brick_owners` |
173
+ | bricks[].components | object | {} | &#9745; | Components on this brick |
174
+ | components | object | {} | &#9745; | List of components in the save |
175
+ | components[].version | int | | | Game version for this component |
176
+ | components[].brick_indices | array | | | Indices of assigned bricks |
177
+ | components[].properties | object | | | Map of properties names and types |
178
178
 
179
179
  ### Function `brs.read(buffer, options)`
180
180
 
@@ -182,15 +182,15 @@ Unsigned ints, while unlikely, may overflow.
182
182
 
183
183
  In node, the buffer can be obtained from `fs.readFile` without an encoding specified. In web, the buffer can be obtained via `File.arrayBuffer()`. Be sure to resolve promises where necessary.
184
184
 
185
- | parameter | type | description |
186
- |-------------|---------------------|-----------------------------------------|
187
- | `buffer` | Uint8Array / Buffer | Input bytes to be parsed |
188
- | `options` | Object | Options for the parser, see table below |
185
+ | parameter | type | description |
186
+ | --------- | ------------------- | --------------------------------------- |
187
+ | `buffer` | Uint8Array / Buffer | Input bytes to be parsed |
188
+ | `options` | Object | Options for the parser, see table below |
189
189
 
190
190
  #### Options
191
191
 
192
192
  | name | type | description | default |
193
- |-----------|---------|--------------------------|---------|
193
+ | --------- | ------- | ------------------------ | ------- |
194
194
  | `bricks` | boolean | Whether to read bricks | `true` |
195
195
  | `preview` | boolean | Whether to copy previews | `false` |
196
196
 
@@ -200,154 +200,235 @@ In node, the buffer can be obtained from `fs.readFile` without an encoding speci
200
200
 
201
201
  In node, the buffer can be saved with from `fs.writeFile(fileName, buffer)`. In web, the buffer can be made into a `new Blob([buffer])`, and can be downloaded with an `<a download>` with `href` as `URL.createObjectURL(blob)`.
202
202
 
203
- | parameter | type | description |
204
- |-------------|-------------|----------------------------------------|
205
- | `saveObj` | Save Object | Save Object to be turned into a buffer |
203
+ | parameter | type | description |
204
+ | --------- | ----------- | -------------------------------------- |
205
+ | `saveObj` | Save Object | Save Object to be turned into a buffer |
206
206
 
207
207
  ### Brick Assets
208
208
 
209
209
  Notes:
210
210
 
211
- - Size must be [0, 0, 0] for bricks using non-procedural brick assets
212
- - Size must NOT be [0, 0, 0] for bricks using procedural brick assets
213
- - 1x1 brick has size [5, 5, 6] and 'PB_DefaultBrick' brick asset
214
- - 1x1F plate has size [5, 5, 2] and 'PB_DefaultBrick' brick asset
215
-
216
-
217
- | name | procedural |
218
- |------|------------|
219
- | PB_DefaultBrick | &#9745; |
220
- | PB_DefaultRamp | &#9745; |
221
- | PB_DefaultRampCrest | &#9745; |
222
- | PB_DefaultRampCrestCorner | &#9745; |
223
- | PB_DefaultRampCrestEnd | &#9745; |
224
- | PB_DefaultRampInnerCornerInverted | &#9745; |
225
- | PB_DefaultRampInverted | &#9745; |
226
- | PB_DefaultSideWedge | &#9745; |
227
- | PB_DefaultSideWedgeTile | &#9745; |
228
- | PB_DefaultTile | &#9745; |
229
- | PB_DefaultWedge | &#9745; |
230
- | PB_DefaultMicroBrick | &#9745; |
231
- | PB_DefaultMicroWedge | &#9745; |
232
- | B_1x1_Brick_Side | |
233
- | B_1x1_Brick_Side_Lip | |
234
- | B_1x1_Cone | |
235
- | B_1x1_Round | |
236
- | B_1x1F_Octo | |
237
- | B_1x1F_Round | |
238
- | B_1x2_Overhang | |
239
- | B_1x2f_Plate_Center | |
240
- | B_1x2f_Plate_Center_Inv | |
241
- | B_1x4_Brick_Side | |
242
- | B_1x_Octo | |
243
- | B_1x_Octo_90Deg | |
244
- | B_1x_Octo_90Deg_Inv | |
245
- | B_1x_Octo_T | |
246
- | B_1x_Octo_T_Inv | |
247
- | B_2x1_Slipper | |
248
- | B_2x2_Cone | |
249
- | B_2x2_Corner | |
250
- | B_2x2_Overhang | |
251
- | B_2x2_Round | |
252
- | B_2x2_Slipper | |
253
- | B_2x2F_Octo | |
254
- | B_2x2F_Octo_Converter | |
255
- | B_2x2F_Octo_Converter_Inv | |
256
- | B_2x2f_Plate_Center | |
257
- | B_2x2f_Plate_Center_Inv | |
258
- | B_2x2F_Round | |
259
- | B_2x4_Door_Frame | |
260
- | B_2x_Cube_Side | |
261
- | B_2x_Octo | |
262
- | B_2x_Octo_90Deg | |
263
- | B_2x_Octo_90Deg_Inv | |
264
- | B_2x_Octo_Cone | |
265
- | B_2x_Octo_T | |
266
- | B_2x_Octo_T_Inv | |
267
- | B_4x4_Round | |
268
- | B_8x8_Lattice_Plate | |
269
- | B_Bishop | |
270
- | B_Bone | |
271
- | B_BoneStraight | |
272
- | B_Branch | |
273
- | B_Bush | |
274
- | B_Cauldron | |
275
- | B_Chalice | |
276
- | B_CheckPoint | |
277
- | B_Coffin | |
278
- | B_Coffin_Lid | |
279
- | B_Fern | |
280
- | B_Flame | |
281
- | B_Flower | |
282
- | B_Gravestone | |
283
- | B_GoalPoint | |
284
- | B_Handle | |
285
- | B_Hedge_1x1 | |
286
- | B_Hedge_1x1_Corner | |
287
- | B_Hedge_1x2 | |
288
- | B_Hedge_1x4 | |
289
- | B_Inverted_Cone | |
290
- | B_Jar | |
291
- | B_King | |
292
- | B_Knight | |
293
- | B_Ladder | |
294
- | B_Pawn | |
295
- | B_Picket_Fence | |
296
- | B_Pine_Tree | |
297
- | B_Pumpkin | |
298
- | B_Pumpkin_Carved | |
299
- | B_Queen | |
300
- | B_Rook | |
301
- | B_Sausage | |
302
- | B_Small_Flower | |
303
- | B_SpawnPoint | |
304
- | B_Swirl_Plate | |
305
- | B_Turkey_Body | |
306
- | B_Turkey_Leg | |
307
- | B_1x1_Gate_Constant | |
308
- | B_1x1_Gate_Subtract | |
309
- | B_1x1_Gate_Multiply | |
310
- | B_1x1_Gate_ModFloored | |
311
- | B_1x1_Gate_Mod | |
312
- | B_1x1_Gate_Divide | |
313
- | B_1x1_Gate_Blend | |
314
- | B_1x1_Gate_Add | |
315
- | B_1x1_Gate_XOR | |
316
- | B_1x1_Gate_OR | |
317
- | B_1x1_Gate_NOR | |
318
- | B_1x1_Gate_NAND | |
319
- | B_1x1_Gate_EdgeDetector | |
320
- | B_1x1_Gate_Floor | |
321
- | B_1x1_Gate_Ceiling | |
322
- | B_1x1_EntityGate_ReadBrickGrid | |
323
- | B_1x1_Gate_NotEqual | |
324
- | B_1x1_Gate_LessThanEqual | |
325
- | B_1x1_Gate_LessThan | |
326
- | B_1x1_Gate_GreaterThanEqual | |
327
- | B_1x1_Gate_GreaterThan | |
328
- | B_1x1_Gate_XOR_Bitwise | |
329
- | B_1x1_Gate_ShiftRight_Bitwise | |
330
- | B_1x1_Gate_ShiftLeft_Bitwise | |
331
- | B_1x1_Gate_OR_Bitwise | |
332
- | B_1x1_Gate_NOR_Bitwise | |
333
- | B_1x1_Gate_NAND_Bitwise | |
334
- | B_1x1_Gate_AND_Bitwise | |
335
- | B_1x1_Reroute_Node | |
336
- | B_1x1_Gate_Timer_Tick | |
337
- | B_1x1_Gate_Timer | |
338
- | B_1x1_NOT_Gate | |
339
- | B_1x1_Gate_AND | |
340
- | B_1x1_Gate_Equal | |
341
- | B_1x1_Gate_NOT_Bitwise | |
211
+ - Size must be [0, 0, 0] for bricks using non-procedural brick assets
212
+ - Size must NOT be [0, 0, 0] for bricks using procedural brick assets
213
+ - 1x1 brick has size [5, 5, 6] and 'PB_DefaultBrick' brick asset
214
+ - 1x1F plate has size [5, 5, 2] and 'PB_DefaultBrick' brick asset
215
+
216
+ | name | procedural |
217
+ | --------------------------------- | ---------- |
218
+ | PB_DefaultBrick | &#9745; |
219
+ | PB_DefaultRamp | &#9745; |
220
+ | PB_DefaultRampCrest | &#9745; |
221
+ | PB_DefaultRampCrestCorner | &#9745; |
222
+ | PB_DefaultRampCrestEnd | &#9745; |
223
+ | PB_DefaultRampInnerCornerInverted | &#9745; |
224
+ | PB_DefaultRampInverted | &#9745; |
225
+ | PB_DefaultSideWedge | &#9745; |
226
+ | PB_DefaultSideWedgeTile | &#9745; |
227
+ | PB_DefaultTile | &#9745; |
228
+ | PB_DefaultWedge | &#9745; |
229
+ | PB_DefaultMicroBrick | &#9745; |
230
+ | PB_DefaultMicroWedge | &#9745; |
231
+ | B_1x1_Brick_Side | |
232
+ | B_1x1_Brick_Side_Lip | |
233
+ | B_1x1_Cone | |
234
+ | B_1x1_Round | |
235
+ | B_1x1F_Octo | |
236
+ | B_1x1F_Round | |
237
+ | B_1x2_Overhang | |
238
+ | B_1x2f_Plate_Center | |
239
+ | B_1x2f_Plate_Center_Inv | |
240
+ | B_1x4_Brick_Side | |
241
+ | B_1x_Octo | |
242
+ | B_1x_Octo_90Deg | |
243
+ | B_1x_Octo_90Deg_Inv | |
244
+ | B_1x_Octo_T | |
245
+ | B_1x_Octo_T_Inv | |
246
+ | B_2x1_Slipper | |
247
+ | B_2x2_Cone | |
248
+ | B_2x2_Corner | |
249
+ | B_2x2_Overhang | |
250
+ | B_2x2_Round | |
251
+ | B_2x2_Slipper | |
252
+ | B_2x2F_Octo | |
253
+ | B_2x2F_Octo_Converter | |
254
+ | B_2x2F_Octo_Converter_Inv | |
255
+ | B_2x2f_Plate_Center | |
256
+ | B_2x2f_Plate_Center_Inv | |
257
+ | B_2x2F_Round | |
258
+ | B_2x4_Door_Frame | |
259
+ | B_2x_Cube_Side | |
260
+ | B_2x_Octo | |
261
+ | B_2x_Octo_90Deg | |
262
+ | B_2x_Octo_90Deg_Inv | |
263
+ | B_2x_Octo_Cone | |
264
+ | B_2x_Octo_T | |
265
+ | B_2x_Octo_T_Inv | |
266
+ | B_4x4_Round | |
267
+ | B_8x8_Lattice_Plate | |
268
+ | B_Bishop | |
269
+ | B_Bone | |
270
+ | B_BoneStraight | |
271
+ | B_Branch | |
272
+ | B_Bush | |
273
+ | B_Cauldron | |
274
+ | B_Chalice | |
275
+ | B_CheckPoint | |
276
+ | B_Coffin | |
277
+ | B_Coffin_Lid | |
278
+ | B_Fern | |
279
+ | B_Flame | |
280
+ | B_Flower | |
281
+ | B_Gravestone | |
282
+ | B_GoalPoint | |
283
+ | B_Handle | |
284
+ | B_Hedge_1x1 | |
285
+ | B_Hedge_1x1_Corner | |
286
+ | B_Hedge_1x2 | |
287
+ | B_Hedge_1x4 | |
288
+ | B_Inverted_Cone | |
289
+ | B_Jar | |
290
+ | B_King | |
291
+ | B_Knight | |
292
+ | B_Ladder | |
293
+ | B_Pawn | |
294
+ | B_Picket_Fence | |
295
+ | B_Pine_Tree | |
296
+ | B_Pumpkin | |
297
+ | B_Pumpkin_Carved | |
298
+ | B_Queen | |
299
+ | B_Rook | |
300
+ | B_Sausage | |
301
+ | B_Small_Flower | |
302
+ | B_SpawnPoint | |
303
+ | B_Swirl_Plate | |
304
+ | B_Turkey_Body | |
305
+ | B_Turkey_Leg | |
306
+ | B_1x1_Gate_Constant | |
307
+ | B_1x1_Gate_Subtract | |
308
+ | B_1x1_Gate_Multiply | |
309
+ | B_1x1_Gate_ModFloored | |
310
+ | B_1x1_Gate_Mod | |
311
+ | B_1x1_Gate_Divide | |
312
+ | B_1x1_Gate_Blend | |
313
+ | B_1x1_Gate_Add | |
314
+ | B_1x1_Gate_XOR | |
315
+ | B_1x1_Gate_OR | |
316
+ | B_1x1_Gate_NOR | |
317
+ | B_1x1_Gate_NAND | |
318
+ | B_1x1_Gate_EdgeDetector | |
319
+ | B_1x1_Gate_Floor | |
320
+ | B_1x1_Gate_Ceiling | |
321
+ | B_1x1_EntityGate_ReadBrickGrid | |
322
+ | B_1x1_Gate_NotEqual | |
323
+ | B_1x1_Gate_LessThanEqual | |
324
+ | B_1x1_Gate_LessThan | |
325
+ | B_1x1_Gate_GreaterThanEqual | |
326
+ | B_1x1_Gate_GreaterThan | |
327
+ | B_1x1_Gate_XOR_Bitwise | |
328
+ | B_1x1_Gate_ShiftRight_Bitwise | |
329
+ | B_1x1_Gate_ShiftLeft_Bitwise | |
330
+ | B_1x1_Gate_OR_Bitwise | |
331
+ | B_1x1_Gate_NOR_Bitwise | |
332
+ | B_1x1_Gate_NAND_Bitwise | |
333
+ | B_1x1_Gate_AND_Bitwise | |
334
+ | B_1x1_Reroute_Node | |
335
+ | B_1x1_Gate_Timer_Tick | |
336
+ | B_1x1_Gate_Timer | |
337
+ | B_1x1_NOT_Gate | |
338
+ | B_1x1_Gate_AND | |
339
+ | B_1x1_Gate_Equal | |
340
+ | B_1x1_Gate_NOT_Bitwise | |
341
+
342
+ ## Brickadia Worlds (.brz)
343
+
344
+ brs-js can write and read the Brickadia World archive format (`.brz`).
345
+ Writing covers bricks, components, and wires; entities can be read but not
346
+ yet written. `writeBrzLegacy` converts the same legacy `WriteSaveObject`
347
+ that `write()` takes, except that `components` on bricks is a modern typed
348
+ array (the legacy .brs component map is not converted) and `wires` on the
349
+ save uses modern component and port names. A builder-style world API for
350
+ authoring saves from scratch is planned:
351
+
352
+ ```js
353
+ import { writeBrzLegacy, WorldReader } from 'brs-js';
354
+
355
+ const brz = writeBrzLegacy({
356
+ description: 'my world',
357
+ bricks: [{ size: [5, 5, 6], position: [0, 0, 6], color: [255, 0, 0] }],
358
+ });
359
+
360
+ // WorldReader is lazy: schemas are parsed once and cached, and chunk
361
+ // payloads are only decoded when you ask for them.
362
+ const world = WorldReader.from(brz);
363
+ world.bundle(); // Meta/Bundle.json
364
+ world.brickAssets(); // basic asset names followed by procedural
365
+ world.brickOwners(); // owner rows (PUBLIC excluded)
366
+ world.gridIds(); // [1] plus any entity sub-grids
367
+ for (const brick of world.bricks()) {
368
+ // decoded chunk by chunk
369
+ }
370
+ ```
371
+
372
+ Blobs are stored uncompressed by default, which is valid and matches the
373
+ reference implementation byte for byte. To compress with zstd (Node 22.15
374
+ or newer):
375
+
376
+ ```js
377
+ import { zstdCompressSync, constants } from 'node:zlib';
378
+ const brz = writeBrzLegacy(save, {
379
+ compress: data =>
380
+ zstdCompressSync(data, {
381
+ params: { [constants.ZSTD_c_compressionLevel]: 14 },
382
+ }),
383
+ });
384
+ ```
385
+
386
+ Reading applies a few normalizations:
387
+
388
+ - Brick order round-trips per chunk rather than in global save order.
389
+ - `collision.tool` always reads `true` because the format does not store it.
390
+ - Palette color indices are resolved to `[r, g, b]` at write time.
391
+ - `save.map` is not mapped; pass `{ environment }` in the options instead.
392
+
393
+ The cross-language fixture tests skip unless fixtures have been generated.
394
+ To enable them, run `just fixtures` with a crate checkout at `../brdb` (or
395
+ set `BRDB_CRATE`).
396
+
397
+ ### .brdb (SQLite worlds)
398
+
399
+ `.brdb` is the game's live world format: the same virtual filesystem as
400
+ `.brz`, stored in SQLite with full revision history. Reading and writing
401
+ requires `better-sqlite3` (an optional peer dependency, node only):
402
+
403
+ npm install better-sqlite3
404
+
405
+ ```js
406
+ import { Brdb } from 'brs-js';
407
+
408
+ const db = await Brdb.open('MyWorld.brdb');
409
+ const reader = db.worldReader(); // same surface as WorldReader.from(brz)
410
+ for (const brick of reader.bricks()) console.log(brick.position);
411
+
412
+ const out = await Brdb.create('New.brdb');
413
+ out.save('initial save', {
414
+ bricks: [{ size: [5, 5, 6], position: [0, 0, 6] }],
415
+ });
416
+ ```
417
+
418
+ Every `save`/`writePending` call is one revision: unchanged files are shared,
419
+ changed files are soft-deleted and reinserted, and blobs are deduplicated by
420
+ BLAKE3 hash. Blobs compress with zstd level 14 when node's zlib supports it
421
+ (pass `compress: null` to store raw). Advanced: `new Brdb(db)` wraps any
422
+ SQLite handle with a compatible synchronous API, with no dependency at all.
342
423
 
343
424
  ## Development
344
425
 
345
426
  NPM Scripts (`npm run <cmd>`)
346
427
 
347
- | name | description |
348
- |-------|----------------------------------------------------------|
349
- | build | Build library in development mode |
350
- | watch | Auto-build library in development mode when files change |
351
- | dist | Build library in production mode |
352
- | test | Run tests |
353
-
428
+ | name | description |
429
+ | ---------- | ---------------------------------------------------- |
430
+ | build | Build all targets (web + node) and type declarations |
431
+ | watch | Rebuild the library when files change |
432
+ | dist | Alias for `build` |
433
+ | test | Run the test suite once |
434
+ | test:watch | Run the test suite in watch mode |