brs-js 1.4.1 → 2.0.2

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 (87) hide show
  1. package/.prettierrc +7 -0
  2. package/LICENSE +1 -1
  3. package/README.md +2 -2
  4. package/debug/Conf Spacestation.brs +0 -0
  5. package/debug/Electrks_Feminine_Challenge.brs +0 -0
  6. package/debug/a5bricks.brs +0 -0
  7. package/debug/a5p2.2.brs +0 -0
  8. package/debug/a5p2.brs +0 -0
  9. package/debug/audio.brs +0 -0
  10. package/debug/brick a5.brs +0 -0
  11. package/debug/brick qa.brs +0 -0
  12. package/debug/brsv10.brs +0 -0
  13. package/debug/brsv10brick.brs +0 -0
  14. package/debug/bruteforce.js +254 -0
  15. package/debug/clone.html +36 -0
  16. package/debug/ctf_tileset.brs +0 -0
  17. package/debug/ctf_tileset_5.brs +0 -0
  18. package/debug/evil.brs +0 -0
  19. package/{src/write.js → debug/evilwrite.js} +218 -31
  20. package/debug/foo.txt +3080 -0
  21. package/debug/kenko_big.brs +0 -0
  22. package/debug/light.brs +0 -0
  23. package/debug/out.json +105 -0
  24. package/debug/read.js +30 -0
  25. package/debug/readSpeed.js +32 -0
  26. package/debug/readTest.js +45 -0
  27. package/debug/temp.brs +0 -0
  28. package/debug/western.brs +0 -0
  29. package/dist/dist.js +1 -1
  30. package/dist/dist.node.js +1 -1
  31. package/dist/dist.web.js +1 -1
  32. package/dist/src/constants.d.ts +6 -0
  33. package/dist/src/constants.d.ts.map +1 -0
  34. package/dist/src/index.d.ts +23 -0
  35. package/dist/src/index.d.ts.map +1 -0
  36. package/dist/src/read.d.ts +3 -0
  37. package/dist/src/read.d.ts.map +1 -0
  38. package/dist/src/read.v1.d.ts +3 -0
  39. package/dist/src/read.v1.d.ts.map +1 -0
  40. package/dist/src/read.v10.d.ts +3 -0
  41. package/dist/src/read.v10.d.ts.map +1 -0
  42. package/dist/src/read.v2.d.ts +3 -0
  43. package/dist/src/read.v2.d.ts.map +1 -0
  44. package/dist/src/read.v3.d.ts +3 -0
  45. package/dist/src/read.v3.d.ts.map +1 -0
  46. package/dist/src/read.v4.d.ts +3 -0
  47. package/dist/src/read.v4.d.ts.map +1 -0
  48. package/dist/src/read.v8.d.ts +3 -0
  49. package/dist/src/read.v8.d.ts.map +1 -0
  50. package/dist/src/read.v9.d.ts +3 -0
  51. package/dist/src/read.v9.d.ts.map +1 -0
  52. package/dist/src/types.d.ts +170 -0
  53. package/dist/src/types.d.ts.map +1 -0
  54. package/dist/src/utils.d.ts +87 -0
  55. package/dist/src/utils.d.ts.map +1 -0
  56. package/dist/src/uuid.d.ts +4 -0
  57. package/dist/src/uuid.d.ts.map +1 -0
  58. package/dist/src/write.d.ts +3 -0
  59. package/dist/src/write.d.ts.map +1 -0
  60. package/examples/ATCFort.brs +0 -0
  61. package/examples/read_example.html +34 -0
  62. package/examples/read_example.js +21 -0
  63. package/examples/write_example.js +25 -0
  64. package/examples/write_planet.html +144 -0
  65. package/examples/write_simplex.html +82 -0
  66. package/examples/write_wedge_sphere.html +173 -0
  67. package/package.json +17 -14
  68. package/src/constants.ts +6 -0
  69. package/src/{index.js → index.ts} +13 -1
  70. package/src/read.ts +57 -0
  71. package/src/read.v1.ts +99 -0
  72. package/src/read.v10.ts +185 -0
  73. package/src/read.v2.ts +102 -0
  74. package/src/read.v3.ts +111 -0
  75. package/src/read.v4.ts +112 -0
  76. package/src/read.v8.ts +172 -0
  77. package/src/read.v9.ts +181 -0
  78. package/src/types.ts +240 -0
  79. package/src/{utils.js → utils.ts} +241 -181
  80. package/src/{uuid.js → uuid.ts} +9 -5
  81. package/src/write.ts +209 -0
  82. package/test/lib.test.js +31 -23
  83. package/test/utils.test.js +50 -15
  84. package/tsconfig.json +22 -0
  85. package/webpack.config.js +51 -30
  86. package/src/constants.js +0 -4
  87. package/src/read.js +0 -206
@@ -1,4 +1,7 @@
1
1
  // this code is modified from https://github.com/uuidjs/uuid
2
+
3
+ import { Uuid } from './types';
4
+
2
5
  /*
3
6
  The MIT License (MIT)
4
7
 
@@ -10,11 +13,12 @@ The above copyright notice and this permission notice shall be included in all c
10
13
 
11
14
  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
12
15
  */
13
- const hexTable = Array.from({length: 256}).map((_, i) =>
14
- (i + 0x100).toString(16).substr(1));
16
+ const hexTable: string[] = Array.from({ length: 256 }).map((_, i) =>
17
+ (i + 0x100).toString(16).substr(1)
18
+ );
15
19
 
16
20
  // stringify uuid
17
- export function uuidStringify(arr) {
21
+ export function uuidStringify(arr: number[]): Uuid {
18
22
  return (
19
23
  hexTable[arr[0]] +
20
24
  hexTable[arr[1]] +
@@ -39,7 +43,7 @@ export function uuidStringify(arr) {
39
43
  ).toLowerCase();
40
44
  }
41
45
 
42
- export function uuidParse(uuid) {
46
+ export function uuidParse(uuid: Uuid): Uint8Array {
43
47
  let v;
44
48
  const arr = new Uint8Array(16);
45
49
 
@@ -71,4 +75,4 @@ export function uuidParse(uuid) {
71
75
  arr[15] = v & 0xff;
72
76
 
73
77
  return arr;
74
- }
78
+ }
package/src/write.ts ADDED
@@ -0,0 +1,209 @@
1
+ import { MAGIC, LATEST_VERSION, MAX_INT, DEFAULT_UUID } from './constants';
2
+ import { Brick, Owner, WriteOptions, WriteSaveObject } from './types';
3
+ import { write, isEqual, concat } from './utils';
4
+
5
+ const EMPTY_ARR = new Uint8Array([]);
6
+
7
+ export default function writeBrs(
8
+ save: WriteSaveObject,
9
+ options: WriteOptions = {}
10
+ ) {
11
+ if (typeof save !== 'object') {
12
+ throw new Error('Expected save to be an object');
13
+ }
14
+
15
+ if (!Array.isArray(save.bricks) || save.bricks.length === 0) {
16
+ throw new Error('Expected save to have bricks field');
17
+ }
18
+
19
+ if (save.bricks.length > MAX_INT) {
20
+ throw new Error('Brick count out of range');
21
+ }
22
+
23
+ // compression is disabled by default
24
+ const compress = options.compress ? write.compressed : write.uncompressed;
25
+
26
+ // Convert from BGRA to RGBA
27
+ const rgba = ([r, g, b, a]: number[]) => new Uint8Array([b, g, r, a]);
28
+
29
+ // stored brick indices from components on the bricks
30
+ const componentBrickOwnership: { [component_name: string]: number[] } = {};
31
+
32
+ const numColors = Math.max(save.colors?.length ?? 0, 2);
33
+ const numAssets = Math.max(save.brick_assets?.length ?? 0, 2);
34
+ const numMats = Math.max(save.materials?.length ?? 0, 2);
35
+ const numPhysMats = Math.max(save.physical_materials?.length ?? 0, 2);
36
+
37
+ if (save.preview && !Array.isArray(save.preview))
38
+ throw new Error('Expected preview to be an array');
39
+
40
+ const buff = concat(
41
+ // Write magic bytes
42
+ MAGIC,
43
+ write.u16(LATEST_VERSION),
44
+ write.i32(save.game_version ?? 0),
45
+
46
+ // Header 1
47
+ compress(
48
+ write.string(save.map ?? 'Unknown'),
49
+ write.string(save.author?.name ?? 'Unknown'),
50
+ write.string(save.description ?? ''),
51
+ write.uuid(save.author?.id ?? DEFAULT_UUID),
52
+ concat(
53
+ write.string(save.host?.name ?? 'Unknown'),
54
+ write.uuid(save.host?.id ?? DEFAULT_UUID)
55
+ ),
56
+ new Uint8Array(
57
+ save.save_time &&
58
+ (Array.isArray(save.save_time) ||
59
+ save.save_time instanceof Uint8Array) &&
60
+ save.save_time.length === 8
61
+ ? save.save_time
62
+ : [0, 0, 0, 0, 0, 0, 0, 0]
63
+ ),
64
+ write.i32(save.bricks.length)
65
+ ),
66
+
67
+ // Header 2
68
+ compress(
69
+ write.array(save.mods ?? [], write.string),
70
+ write.array(save.brick_assets ?? ['PB_DefaultBrick'], write.string),
71
+ write.array(save.colors ?? [], rgba),
72
+ write.array(save.materials ?? ['BMC_Plastic'], write.string),
73
+ write.array(
74
+ save.brick_owners ?? [],
75
+ ({ id = DEFAULT_UUID, name = 'Unknown', bricks = 0 }: Partial<Owner>) =>
76
+ concat(write.uuid(id), write.string(name), write.i32(bricks))
77
+ ),
78
+ write.array(save.physical_materials ?? ['BPMC_Default'], write.string)
79
+ ),
80
+
81
+ // write the save preview if it exists
82
+ concat(
83
+ new Uint8Array([save.preview ? 1 : 0]),
84
+ save.preview ? write.i32(save.preview.length) : EMPTY_ARR, // <- Sorry @Uxie https://i.imgur.com/hSRxdbf.png
85
+ save.preview ?? EMPTY_ARR
86
+ ),
87
+
88
+ // Bricks
89
+ compress(
90
+ write
91
+ .bits()
92
+ .each(save.bricks, function (brick: Brick, i) {
93
+ if (typeof brick !== 'object')
94
+ throw new Error(`Expected save.bricks[${i}] to be an object`);
95
+
96
+ if (!Array.isArray(brick.size) || brick.size.length !== 3)
97
+ throw new Error(
98
+ `Expected save.bricks[${i}].size to be an array of length 3`
99
+ );
100
+
101
+ if (!Array.isArray(brick.position) || brick.position.length !== 3)
102
+ throw new Error(
103
+ `Expected save.bricks[${i}].position to be an array of length 3`
104
+ );
105
+
106
+ this.align();
107
+ this.int(brick.asset_name_index ?? 0, numAssets);
108
+
109
+ const isNonProcedural = isEqual(brick.size, [0, 0, 0]);
110
+ this.bit(!isNonProcedural);
111
+ if (!isNonProcedural) {
112
+ brick.size.map(s => this.uint_packed(s));
113
+ }
114
+ brick.position.map(s => this.int_packed(s));
115
+ this.int(((brick.direction ?? 4) << 2) | (brick.rotation ?? 0), 24);
116
+
117
+ if (typeof brick.collision === 'boolean') {
118
+ this.bit(brick.collision);
119
+ this.bit(brick.collision);
120
+ this.bit(brick.collision);
121
+ this.bit(true);
122
+ } else {
123
+ this.bit(brick.collision?.player ?? true);
124
+ this.bit(brick.collision?.weapon ?? true);
125
+ this.bit(brick.collision?.interaction ?? true);
126
+ this.bit(brick.collision?.tool ?? true);
127
+ }
128
+
129
+ this.bit(brick?.visibility ?? true);
130
+ this.int(brick?.material_index ?? 0, numMats);
131
+ this.int(brick.physical_index ?? 0, numPhysMats);
132
+ this.int(brick.material_intensity ?? 5, 11);
133
+
134
+ if (typeof brick.color === 'number') {
135
+ this.bit(false);
136
+ this.int(brick.color, numColors);
137
+ } else {
138
+ this.bit(true);
139
+ if (
140
+ brick.color &&
141
+ (!Array.isArray(brick.color) || brick.color.length !== 3)
142
+ )
143
+ throw new Error(
144
+ `Expected save.bricks[${i}].color to be an array of length 3`
145
+ );
146
+ this.bytes(new Uint8Array(brick.color ?? [255, 255, 255]));
147
+ }
148
+
149
+ this.uint_packed(brick.owner_index ?? 1);
150
+
151
+ // add all the brick indices to the components list
152
+ for (const key in brick.components ?? {}) {
153
+ componentBrickOwnership[key] ??= [];
154
+ componentBrickOwnership[key].push(i);
155
+ }
156
+ })
157
+ .finish()
158
+ ),
159
+
160
+ // write components section
161
+ compress(
162
+ write.array(
163
+ Object.keys(save.components ?? {}).filter(
164
+ name => componentBrickOwnership[name]
165
+ ),
166
+ name =>
167
+ concat(
168
+ write.string(name),
169
+ write
170
+ .bits()
171
+ .self(function () {
172
+ const component = save.components[name];
173
+ const brick_indices = componentBrickOwnership[name];
174
+ const properties = Object.entries(component.properties);
175
+
176
+ // write version
177
+ this.bytes(write.i32(component.version));
178
+
179
+ // write bricks;
180
+ this.array(brick_indices, i => {
181
+ this.int(i, Math.max(save.bricks.length, 2));
182
+ });
183
+
184
+ // write properties
185
+ this.array(properties, ([name, type]) => {
186
+ this.string(name);
187
+ this.string(type);
188
+ });
189
+
190
+ // read brick indices
191
+ for (const i of brick_indices) {
192
+ for (const [prop, type] of properties) {
193
+ if (!(prop in save.bricks[i].components[name])) {
194
+ throw new Error(
195
+ `Expected save.bricks[${i}].components[${name}] to have property '${prop}' of type '${type}'`
196
+ );
197
+ }
198
+ this.unreal(type, save.bricks[i].components[name][prop]);
199
+ }
200
+ }
201
+ this.align();
202
+ })
203
+ .finishSection()
204
+ )
205
+ )
206
+ )
207
+ );
208
+ return buff;
209
+ }
package/test/lib.test.js CHANGED
@@ -1,43 +1,51 @@
1
- const { read, write } = require('../dist/dist.node.js');
2
- const _ = require('lodash');
1
+ const { read, write } = require('..');
3
2
 
4
3
  // const uuid0 = '00000000-0000-0000-0000-000000000000';
5
4
  const uuid0 = '12345678-4321-1234-4321-123456789012';
6
-
7
5
  const save = {
8
- version: 8,
6
+ version: 10,
9
7
  map: 'Unknown',
10
8
  description: '',
11
- author: {id: uuid0, name: 'Test'},
9
+ author: { id: uuid0, name: 'Test' },
12
10
  save_time: new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8]),
13
11
  brick_count: 1,
14
12
  mods: [],
15
- preview: undefined,
13
+ preview: null,
16
14
  brick_assets: [],
17
15
  colors: [],
18
16
  components: {},
19
- gameVersion: 0,
20
- host: {id: uuid0, name: 'Test'},
17
+ game_version: 0,
18
+ host: { id: uuid0, name: 'Test' },
21
19
  materials: ['BMC_Hologram', 'BMC_Plastic', 'BMC_Glow', 'BMC_Metallic'],
22
- brick_owners: [{id: uuid0, name: 'Test', bricks: 0}],
23
- bricks: [{
24
- asset_name_index: 1,
25
- size: [10, 10, 10],
26
- position: [0, 0, 0],
27
- components: {},
28
- direction: 4,
29
- owner_index: 1,
30
- rotation: 0,
31
- collision: true,
32
- visibility: true,
33
- material_index: 1,
34
- color: [0, 0, 0, 255],
35
- }],
20
+ physical_materials: ['BPMC_Default'],
21
+ brick_owners: [{ id: uuid0, name: 'Test', bricks: 0 }],
22
+ bricks: [
23
+ {
24
+ asset_name_index: 1,
25
+ size: [10, 10, 10],
26
+ position: [0, 0, 0],
27
+ components: {},
28
+ direction: 4,
29
+ owner_index: 1,
30
+ rotation: 0,
31
+ collision: {
32
+ player: true,
33
+ interaction: true,
34
+ tool: true,
35
+ weapon: true,
36
+ },
37
+ visibility: true,
38
+ material_index: 1,
39
+ material_intensity: 5,
40
+ physical_index: 0,
41
+ color: [0, 0, 0],
42
+ },
43
+ ],
36
44
  };
37
45
  test('creating a brs from thin air', () => {
38
46
  expect(read(write(save))).toEqual(save);
39
47
  });
40
48
 
41
49
  test('reads no bricks when the option is passed in', () => {
42
- expect(read(write(save), {bricks: false})).toEqual({...save, bricks: []});
50
+ expect(read(write(save), { bricks: false })).toEqual({ ...save, bricks: [] });
43
51
  });
@@ -1,12 +1,15 @@
1
- const { utils: { read, write } } = require('../dist/dist.node.js');
2
- const clone = require('lodash/clone');
1
+ const {
2
+ utils: { read, write, subarray, chunk },
3
+ } = require('..');
3
4
 
4
5
  describe('buffer read/writing', () => {
5
6
  // Generic testing of read and write
6
- const rwTest = fn => (bytes, val, ...args) => {
7
- expect(read[fn](new Uint8Array(bytes), ...args)).toEqual(val);
8
- expect(write[fn](val, ...args)).toMatchObject(new Uint8Array(bytes));
9
- };
7
+ const rwTest =
8
+ fn =>
9
+ (bytes, val, ...args) => {
10
+ expect(read[fn](new Uint8Array(bytes), ...args)).toEqual(val);
11
+ expect(write[fn](val, ...args)).toMatchObject(new Uint8Array(bytes));
12
+ };
10
13
 
11
14
  // Testing both endiannesses for read and write
12
15
  const endianTest = fn => (bytes, val) => {
@@ -17,6 +20,28 @@ describe('buffer read/writing', () => {
17
20
  rwTest(fn)(new Uint8Array(bytes).reverse(), val, false);
18
21
  };
19
22
 
23
+ describe('byte manipulating util', () => {
24
+ test('subarray', () => {
25
+ const arr = new Uint8Array([1, 2, 3, 4, 5, 6, 7, 8, 9, 10]);
26
+ expect(subarray(arr, 2)).toMatchObject({ 0: 1, 1: 2 });
27
+ expect(arr.brsOffset).toEqual(2);
28
+ expect(subarray(arr, 4)).toMatchObject({ 0: 3, 1: 4, 2: 5, 3: 6 });
29
+ expect(arr.brsOffset).toEqual(6);
30
+ });
31
+
32
+ test('chunk', () => {
33
+ const arr = new Uint8Array([
34
+ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16,
35
+ ]);
36
+ expect(chunk(arr, 4)).toMatchObject([
37
+ { 0: 1, 1: 2, 2: 3, 3: 4 },
38
+ { 0: 5, 1: 6, 2: 7, 3: 8 },
39
+ { 0: 9, 1: 10, 2: 11, 3: 12 },
40
+ { 0: 13, 1: 14, 2: 15, 3: 16 },
41
+ ]);
42
+ });
43
+ });
44
+
20
45
  describe('unsigned short', () => {
21
46
  const shortTest = endianTest('u16');
22
47
 
@@ -77,12 +102,10 @@ describe('buffer read/writing', () => {
77
102
  });
78
103
 
79
104
  describe('uuid', () => {
80
- test('can parse uuid', () => {
105
+ test('can parse uuid', () => {
81
106
  const bytes = [
82
- 205,107, 157, 27,
83
- 45, 75, 253, 187,
84
- 141,171, 93, 155,
85
- 237, 75, 189, 251,
107
+ 205, 107, 157, 27, 45, 75, 253, 187, 141, 171, 93, 155, 237, 75, 189,
108
+ 251,
86
109
  ];
87
110
  const uuid = '1b9d6bcd-bbfd-4b2d-9b5d-ab8dfbbd4bed';
88
111
 
@@ -119,8 +142,18 @@ describe('buffer read/writing', () => {
119
142
  test('string array', () => {
120
143
  const str_bytes = [0x04, 0x00, 0x00, 0x00, 0x66, 0x6f, 0x6f, 0x00];
121
144
  const str = 'foo';
122
- const bytes = [0x05, 0, 0, 0, ...str_bytes, ...str_bytes, ...str_bytes, ...str_bytes, ...str_bytes];
123
- const arr = [str, str, str, str, str, ];
145
+ const bytes = [
146
+ 0x05,
147
+ 0,
148
+ 0,
149
+ 0,
150
+ ...str_bytes,
151
+ ...str_bytes,
152
+ ...str_bytes,
153
+ ...str_bytes,
154
+ ...str_bytes,
155
+ ];
156
+ const arr = [str, str, str, str, str];
124
157
  arrTest(bytes, arr, read.string, write.string);
125
158
  });
126
159
  });
@@ -166,9 +199,11 @@ describe('buffer read/writing', () => {
166
199
  it('writes floats', () => {
167
200
  const bits = write.bits();
168
201
  bits.float(123.45);
169
- expect(bits.finish()).toStrictEqual([0x42, 0xf6, 0xe6, 0x66].reverse());
202
+ expect(bits.finish()).toStrictEqual(
203
+ new Uint8Array([0x42, 0xf6, 0xe6, 0x66]).reverse()
204
+ );
170
205
  });
171
206
 
172
207
  // TODO: tests for int_packed, uint_packed, bytes
173
208
  });
174
- });
209
+ });
package/tsconfig.json ADDED
@@ -0,0 +1,22 @@
1
+ {
2
+ "compilerOptions": {
3
+ "allowJs": true,
4
+ "baseUrl": ".",
5
+ "declaration": true,
6
+ "module": "es6",
7
+ "moduleResolution": "node",
8
+ "noImplicitAny": true,
9
+ "outDir": "./dist/",
10
+ "sourceMap": true,
11
+ "declarationMap": true,
12
+ "target": "es2020",
13
+ "typeRoots": [
14
+ "dist/*"
15
+ ]
16
+ },
17
+ "exclude": [
18
+ "node_modules",
19
+ "dist",
20
+ "dist/*"
21
+ ]
22
+ }
package/webpack.config.js CHANGED
@@ -4,40 +4,61 @@ const mode = process.env.NODE_ENV || 'development';
4
4
 
5
5
  const config = {
6
6
  mode,
7
- entry: path.resolve(__dirname, 'src/index.js'),
7
+ cache: { type: 'filesystem' },
8
+ resolve: {
9
+ cacheWithContext: true,
10
+ extensions: ['', '.js', '.ts'],
11
+ },
12
+ entry: path.resolve(__dirname, 'src/index.ts'),
8
13
  devtool: 'source-map',
9
14
  module: {
10
- rules: [{
11
- test: /\.js$/,
12
- use: 'babel-loader',
13
- exclude: /node_modules/,
14
- }],
15
- }
15
+ rules: [
16
+ {
17
+ test: /\.ts$/,
18
+ use: {
19
+ loader: 'ts-loader',
20
+ options: {
21
+ experimentalFileCaching: true,
22
+ },
23
+ },
24
+ exclude: /node_modules/,
25
+ },
26
+ ],
27
+ },
28
+ resolve: {
29
+ extensions: ['.ts', '.js'],
30
+ },
16
31
  };
17
32
 
18
- module.exports = [{
19
- ...config,
20
- target: 'node',
21
- output: {
22
- path: path.resolve(__dirname, 'dist'),
23
- filename: 'dist.node.js',
24
- library: 'brs-js',
25
- libraryTarget: 'commonjs2',
33
+ module.exports = [
34
+ {
35
+ ...config,
36
+ target: 'node',
37
+ output: {
38
+ path: path.resolve(__dirname, 'dist'),
39
+ filename: 'dist.node.js',
40
+ library: {
41
+ type: 'commonjs2',
42
+ },
43
+ },
26
44
  },
27
- }, {
28
- ...config,
29
- target: 'web',
30
- output: {
31
- path: path.resolve(__dirname, 'dist'),
32
- filename: 'dist.js',
45
+ {
46
+ ...config,
47
+ target: 'web',
48
+ output: {
49
+ path: path.resolve(__dirname, 'dist'),
50
+ filename: 'dist.js',
51
+ },
33
52
  },
34
- }, {
35
- ...config,
36
- target: 'web',
37
- output: {
38
- path: path.resolve(__dirname, 'dist'),
39
- filename: 'dist.web.js',
40
- library: 'brs-js',
41
- libraryTarget: 'commonjs2',
53
+ {
54
+ ...config,
55
+ target: 'web',
56
+ output: {
57
+ path: path.resolve(__dirname, 'dist'),
58
+ filename: 'dist.web.js',
59
+ library: {
60
+ type: 'commonjs2',
61
+ },
62
+ },
42
63
  },
43
- }];
64
+ ];
package/src/constants.js DELETED
@@ -1,4 +0,0 @@
1
- export const MAGIC = new Uint8Array([66, 82, 83]); // BRS
2
- export const MAX_VERSION = 10;
3
- export const LATEST_VERSION = 8;
4
- export const MAX_INT = ~(1 << 31);