@dcl/playground-assets 7.0.6-3830539086.commit-6152fbd → 7.0.6-3832097301.commit-4e46b20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/alpha.d.ts CHANGED
@@ -202,10 +202,6 @@ export declare type ByteBuffer = {
202
202
  * @returns The offset when this reserving starts.
203
203
  */
204
204
  incrementWriteOffset(amount: number): number;
205
- /**
206
- * @returns The total number of bytes writen in the buffer.
207
- */
208
- size(): number;
209
205
  /**
210
206
  * Take care using this function, if you modify the data after, the
211
207
  * returned subarray will change too. If you'll modify the content of the
package/dist/beta.d.ts CHANGED
@@ -202,10 +202,6 @@ export declare type ByteBuffer = {
202
202
  * @returns The offset when this reserving starts.
203
203
  */
204
204
  incrementWriteOffset(amount: number): number;
205
- /**
206
- * @returns The total number of bytes writen in the buffer.
207
- */
208
- size(): number;
209
205
  /**
210
206
  * Take care using this function, if you modify the data after, the
211
207
  * returned subarray will change too. If you'll modify the content of the
@@ -202,10 +202,6 @@ export declare type ByteBuffer = {
202
202
  * @returns The offset when this reserving starts.
203
203
  */
204
204
  incrementWriteOffset(amount: number): number;
205
- /**
206
- * @returns The total number of bytes writen in the buffer.
207
- */
208
- size(): number;
209
205
  /**
210
206
  * Take care using this function, if you modify the data after, the
211
207
  * returned subarray will change too. If you'll modify the content of the
package/dist/index.js CHANGED
@@ -13687,6 +13687,12 @@
13687
13687
 
13688
13688
  var utf8Exports = requireUtf8();
13689
13689
 
13690
+ var __classPrivateFieldGet = (globalThis && globalThis.__classPrivateFieldGet) || function (receiver, state, kind, f) {
13691
+ if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
13692
+ if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
13693
+ return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
13694
+ };
13695
+ var _ReadWriteByteBuffer_instances, _ReadWriteByteBuffer_woAdd, _ReadWriteByteBuffer_roAdd;
13690
13696
  /**
13691
13697
  * Take the max between currentSize and intendedSize and then plus 1024. Then,
13692
13698
  * find the next nearer multiple of 1024.
@@ -13706,243 +13712,223 @@
13706
13712
  * - Use read and write function to generate or consume data.
13707
13713
  * - Use set and get only if you are sure that you're doing.
13708
13714
  */
13709
- function createByteBuffer(options = {}) {
13710
- const initialROffset = options.reading?.currentOffset || 0;
13711
- let initialBuffer = null;
13712
- let initialWOffset = 0;
13713
- if (options.writing) {
13714
- initialBuffer = options.writing.buffer;
13715
- if (options.writing.currentOffset) {
13716
- initialWOffset = options.writing.currentOffset;
13717
- }
13718
- }
13719
- else if (options.reading) {
13720
- initialBuffer = options.reading.buffer;
13721
- initialWOffset = options.reading.length || options.reading.buffer.length;
13722
- }
13723
- else {
13724
- initialBuffer = new Uint8Array(options.initialCapacity || defaultInitialCapacity);
13725
- }
13726
- let buffer = initialBuffer;
13727
- let view = new DataView(buffer.buffer, buffer.byteOffset);
13728
- let woffset = initialWOffset;
13729
- let roffset = initialROffset;
13730
- /**
13731
- * Increement the write offset and resize the buffer if it needs.
13732
- */
13733
- const woAdd = (amount) => {
13734
- if (woffset + amount > buffer.byteLength) {
13735
- const newsize = getNextSize(buffer.byteLength, woffset + amount);
13736
- const newBuffer = new Uint8Array(newsize);
13737
- newBuffer.set(buffer);
13738
- buffer = newBuffer;
13739
- view = new DataView(buffer.buffer);
13740
- }
13741
- woffset += amount;
13742
- return woffset - amount;
13743
- };
13715
+ class ReadWriteByteBuffer {
13744
13716
  /**
13745
- * Increment the read offset and throw an error if it's trying to read
13746
- * outside the bounds.
13717
+ * @param buffer - The initial buffer, provide a buffer if you need to set "initial capacity"
13718
+ * @param readingOffset - Set the cursor where begins to read. Default 0
13719
+ * @param writingOffset - Set the cursor to not start writing from the begin of it. Defaults to the buffer size
13747
13720
  */
13748
- const roAdd = (amount) => {
13749
- if (roffset + amount > woffset) {
13750
- throw new Error('Outside of the bounds of writen data.');
13721
+ constructor(buffer, readingOffset, writingOffset) {
13722
+ _ReadWriteByteBuffer_instances.add(this);
13723
+ this._buffer = buffer || new Uint8Array(defaultInitialCapacity);
13724
+ this.view = new DataView(this._buffer.buffer, this._buffer.byteOffset);
13725
+ this.woffset = writingOffset ?? (buffer ? this._buffer.length : null) ?? 0;
13726
+ this.roffset = readingOffset ?? 0;
13727
+ }
13728
+ buffer() {
13729
+ return this._buffer;
13730
+ }
13731
+ bufferLength() {
13732
+ return this._buffer.length;
13733
+ }
13734
+ resetBuffer() {
13735
+ this.roffset = 0;
13736
+ this.woffset = 0;
13737
+ }
13738
+ currentReadOffset() {
13739
+ return this.roffset;
13740
+ }
13741
+ currentWriteOffset() {
13742
+ return this.woffset;
13743
+ }
13744
+ incrementReadOffset(amount) {
13745
+ return __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, amount);
13746
+ }
13747
+ remainingBytes() {
13748
+ return this.woffset - this.roffset;
13749
+ }
13750
+ readFloat32() {
13751
+ return this.view.getFloat32(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 4));
13752
+ }
13753
+ readFloat64() {
13754
+ return this.view.getFloat64(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 8));
13755
+ }
13756
+ readInt8() {
13757
+ return this.view.getInt8(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 1));
13758
+ }
13759
+ readInt16() {
13760
+ return this.view.getInt16(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 2));
13761
+ }
13762
+ readInt32() {
13763
+ return this.view.getInt32(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 4));
13764
+ }
13765
+ readInt64() {
13766
+ return this.view.getBigInt64(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 8));
13767
+ }
13768
+ readUint8() {
13769
+ return this.view.getUint8(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 1));
13770
+ }
13771
+ readUint16() {
13772
+ return this.view.getUint16(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 2));
13773
+ }
13774
+ readUint32() {
13775
+ return this.view.getUint32(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 4));
13776
+ }
13777
+ readUint64() {
13778
+ return this.view.getBigUint64(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 8));
13779
+ }
13780
+ readBuffer() {
13781
+ const length = this.view.getUint32(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 4));
13782
+ return this._buffer.subarray(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, length), __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 0));
13783
+ }
13784
+ readUtf8String() {
13785
+ const length = this.view.getUint32(__classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 4));
13786
+ return utf8Exports.read(this._buffer, __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, length), __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_roAdd).call(this, 0));
13787
+ }
13788
+ incrementWriteOffset(amount) {
13789
+ return __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, amount);
13790
+ }
13791
+ toBinary() {
13792
+ return this._buffer.subarray(0, this.woffset);
13793
+ }
13794
+ toCopiedBinary() {
13795
+ return new Uint8Array(this.toBinary());
13796
+ }
13797
+ writeBuffer(value, writeLength = true) {
13798
+ if (writeLength) {
13799
+ this.writeUint32(value.byteLength);
13751
13800
  }
13752
- roffset += amount;
13753
- return roffset - amount;
13754
- };
13755
- return {
13756
- buffer() {
13757
- return buffer;
13758
- },
13759
- bufferLength() {
13760
- return buffer.length;
13761
- },
13762
- resetBuffer() {
13763
- roffset = 0;
13764
- woffset = 0;
13765
- },
13766
- currentReadOffset() {
13767
- return roffset;
13768
- },
13769
- currentWriteOffset() {
13770
- return woffset;
13771
- },
13772
- incrementReadOffset(amount) {
13773
- return roAdd(amount);
13774
- },
13775
- remainingBytes() {
13776
- return woffset - roffset;
13777
- },
13778
- readFloat32() {
13779
- return view.getFloat32(roAdd(4));
13780
- },
13781
- readFloat64() {
13782
- return view.getFloat64(roAdd(8));
13783
- },
13784
- readInt8() {
13785
- return view.getInt8(roAdd(1));
13786
- },
13787
- readInt16() {
13788
- return view.getInt16(roAdd(2));
13789
- },
13790
- readInt32() {
13791
- return view.getInt32(roAdd(4));
13792
- },
13793
- readInt64() {
13794
- return view.getBigInt64(roAdd(8));
13795
- },
13796
- readUint8() {
13797
- return view.getUint8(roAdd(1));
13798
- },
13799
- readUint16() {
13800
- return view.getUint16(roAdd(2));
13801
- },
13802
- readUint32() {
13803
- return view.getUint32(roAdd(4));
13804
- },
13805
- readUint64() {
13806
- return view.getBigUint64(roAdd(8));
13807
- },
13808
- readBuffer() {
13809
- const length = view.getUint32(roAdd(4));
13810
- return buffer.subarray(roAdd(length), roAdd(0));
13811
- },
13812
- readUtf8String() {
13813
- const length = view.getUint32(roAdd(4));
13814
- return utf8Exports.read(buffer, roAdd(length), roAdd(0));
13815
- },
13816
- incrementWriteOffset(amount) {
13817
- return woAdd(amount);
13818
- },
13819
- size() {
13820
- return woffset;
13821
- },
13822
- toBinary() {
13823
- return buffer.subarray(0, woffset);
13824
- },
13825
- toCopiedBinary() {
13826
- return new Uint8Array(this.toBinary());
13827
- },
13828
- writeBuffer(value, writeLength = true) {
13829
- if (writeLength) {
13830
- this.writeUint32(value.byteLength);
13831
- }
13832
- const o = woAdd(value.byteLength);
13833
- buffer.set(value, o);
13834
- },
13835
- writeUtf8String(value, writeLength = true) {
13836
- const byteLength = utf8Exports.length(value);
13837
- if (writeLength) {
13838
- this.writeUint32(byteLength);
13839
- }
13840
- const o = woAdd(byteLength);
13841
- utf8Exports.write(value, buffer, o);
13842
- },
13843
- writeFloat32(value) {
13844
- const o = woAdd(4);
13845
- view.setFloat32(o, value);
13846
- },
13847
- writeFloat64(value) {
13848
- const o = woAdd(8);
13849
- view.setFloat64(o, value);
13850
- },
13851
- writeInt8(value) {
13852
- const o = woAdd(1);
13853
- view.setInt8(o, value);
13854
- },
13855
- writeInt16(value) {
13856
- const o = woAdd(2);
13857
- view.setInt16(o, value);
13858
- },
13859
- writeInt32(value) {
13860
- const o = woAdd(4);
13861
- view.setInt32(o, value);
13862
- },
13863
- writeInt64(value) {
13864
- const o = woAdd(8);
13865
- view.setBigInt64(o, value);
13866
- },
13867
- writeUint8(value) {
13868
- const o = woAdd(1);
13869
- view.setUint8(o, value);
13870
- },
13871
- writeUint16(value) {
13872
- const o = woAdd(2);
13873
- view.setUint16(o, value);
13874
- },
13875
- writeUint32(value) {
13876
- const o = woAdd(4);
13877
- view.setUint32(o, value);
13878
- },
13879
- writeUint64(value) {
13880
- const o = woAdd(8);
13881
- view.setBigUint64(o, value);
13882
- },
13883
- // Dataview Proxy
13884
- getFloat32(offset) {
13885
- return view.getFloat32(offset);
13886
- },
13887
- getFloat64(offset) {
13888
- return view.getFloat64(offset);
13889
- },
13890
- getInt8(offset) {
13891
- return view.getInt8(offset);
13892
- },
13893
- getInt16(offset) {
13894
- return view.getInt16(offset);
13895
- },
13896
- getInt32(offset) {
13897
- return view.getInt32(offset);
13898
- },
13899
- getInt64(offset) {
13900
- return view.getBigInt64(offset);
13901
- },
13902
- getUint8(offset) {
13903
- return view.getUint8(offset);
13904
- },
13905
- getUint16(offset) {
13906
- return view.getUint16(offset);
13907
- },
13908
- getUint32(offset) {
13909
- return view.getUint32(offset);
13910
- },
13911
- getUint64(offset) {
13912
- return view.getBigUint64(offset);
13913
- },
13914
- setFloat32(offset, value) {
13915
- view.setFloat32(offset, value);
13916
- },
13917
- setFloat64(offset, value) {
13918
- view.setFloat64(offset, value);
13919
- },
13920
- setInt8(offset, value) {
13921
- view.setInt8(offset, value);
13922
- },
13923
- setInt16(offset, value) {
13924
- view.setInt16(offset, value);
13925
- },
13926
- setInt32(offset, value) {
13927
- view.setInt32(offset, value);
13928
- },
13929
- setInt64(offset, value) {
13930
- view.setBigInt64(offset, value);
13931
- },
13932
- setUint8(offset, value) {
13933
- view.setUint8(offset, value);
13934
- },
13935
- setUint16(offset, value) {
13936
- view.setUint16(offset, value);
13937
- },
13938
- setUint32(offset, value) {
13939
- view.setUint32(offset, value);
13940
- },
13941
- setUint64(offset, value) {
13942
- view.setBigUint64(offset, value);
13801
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, value.byteLength);
13802
+ this._buffer.set(value, o);
13803
+ }
13804
+ writeUtf8String(value, writeLength = true) {
13805
+ const byteLength = utf8Exports.length(value);
13806
+ if (writeLength) {
13807
+ this.writeUint32(byteLength);
13943
13808
  }
13944
- };
13809
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, byteLength);
13810
+ utf8Exports.write(value, this._buffer, o);
13811
+ }
13812
+ writeFloat32(value) {
13813
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 4);
13814
+ this.view.setFloat32(o, value);
13815
+ }
13816
+ writeFloat64(value) {
13817
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 8);
13818
+ this.view.setFloat64(o, value);
13819
+ }
13820
+ writeInt8(value) {
13821
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 1);
13822
+ this.view.setInt8(o, value);
13823
+ }
13824
+ writeInt16(value) {
13825
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 2);
13826
+ this.view.setInt16(o, value);
13827
+ }
13828
+ writeInt32(value) {
13829
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 4);
13830
+ this.view.setInt32(o, value);
13831
+ }
13832
+ writeInt64(value) {
13833
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 8);
13834
+ this.view.setBigInt64(o, value);
13835
+ }
13836
+ writeUint8(value) {
13837
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 1);
13838
+ this.view.setUint8(o, value);
13839
+ }
13840
+ writeUint16(value) {
13841
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 2);
13842
+ this.view.setUint16(o, value);
13843
+ }
13844
+ writeUint32(value) {
13845
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 4);
13846
+ this.view.setUint32(o, value);
13847
+ }
13848
+ writeUint64(value) {
13849
+ const o = __classPrivateFieldGet(this, _ReadWriteByteBuffer_instances, "m", _ReadWriteByteBuffer_woAdd).call(this, 8);
13850
+ this.view.setBigUint64(o, value);
13851
+ }
13852
+ // DataView Proxy
13853
+ getFloat32(offset) {
13854
+ return this.view.getFloat32(offset);
13855
+ }
13856
+ getFloat64(offset) {
13857
+ return this.view.getFloat64(offset);
13858
+ }
13859
+ getInt8(offset) {
13860
+ return this.view.getInt8(offset);
13861
+ }
13862
+ getInt16(offset) {
13863
+ return this.view.getInt16(offset);
13864
+ }
13865
+ getInt32(offset) {
13866
+ return this.view.getInt32(offset);
13867
+ }
13868
+ getInt64(offset) {
13869
+ return this.view.getBigInt64(offset);
13870
+ }
13871
+ getUint8(offset) {
13872
+ return this.view.getUint8(offset);
13873
+ }
13874
+ getUint16(offset) {
13875
+ return this.view.getUint16(offset);
13876
+ }
13877
+ getUint32(offset) {
13878
+ return this.view.getUint32(offset);
13879
+ }
13880
+ getUint64(offset) {
13881
+ return this.view.getBigUint64(offset);
13882
+ }
13883
+ setFloat32(offset, value) {
13884
+ this.view.setFloat32(offset, value);
13885
+ }
13886
+ setFloat64(offset, value) {
13887
+ this.view.setFloat64(offset, value);
13888
+ }
13889
+ setInt8(offset, value) {
13890
+ this.view.setInt8(offset, value);
13891
+ }
13892
+ setInt16(offset, value) {
13893
+ this.view.setInt16(offset, value);
13894
+ }
13895
+ setInt32(offset, value) {
13896
+ this.view.setInt32(offset, value);
13897
+ }
13898
+ setInt64(offset, value) {
13899
+ this.view.setBigInt64(offset, value);
13900
+ }
13901
+ setUint8(offset, value) {
13902
+ this.view.setUint8(offset, value);
13903
+ }
13904
+ setUint16(offset, value) {
13905
+ this.view.setUint16(offset, value);
13906
+ }
13907
+ setUint32(offset, value) {
13908
+ this.view.setUint32(offset, value);
13909
+ }
13910
+ setUint64(offset, value) {
13911
+ this.view.setBigUint64(offset, value);
13912
+ }
13945
13913
  }
13914
+ _ReadWriteByteBuffer_instances = new WeakSet(), _ReadWriteByteBuffer_woAdd = function _ReadWriteByteBuffer_woAdd(amount) {
13915
+ if (this.woffset + amount > this._buffer.byteLength) {
13916
+ const newsize = getNextSize(this._buffer.byteLength, this.woffset + amount);
13917
+ const newBuffer = new Uint8Array(newsize);
13918
+ newBuffer.set(this._buffer);
13919
+ const oldOffset = this._buffer.byteOffset;
13920
+ this._buffer = newBuffer;
13921
+ this.view = new DataView(this._buffer.buffer, oldOffset);
13922
+ }
13923
+ this.woffset += amount;
13924
+ return this.woffset - amount;
13925
+ }, _ReadWriteByteBuffer_roAdd = function _ReadWriteByteBuffer_roAdd(amount) {
13926
+ if (this.roffset + amount > this.woffset) {
13927
+ throw new Error('Outside of the bounds of writen data.');
13928
+ }
13929
+ this.roffset += amount;
13930
+ return this.roffset - amount;
13931
+ };
13946
13932
 
13947
13933
  exports.CrdtMessageType = void 0;
13948
13934
  (function (CrdtMessageType) {
@@ -14011,7 +13997,7 @@
14011
13997
  const startMessageOffset = buf.incrementWriteOffset(CRDT_MESSAGE_HEADER_LENGTH + PutComponentOperation.MESSAGE_HEADER_LENGTH);
14012
13998
  // write body
14013
13999
  componentDefinition.writeToByteBuffer(entity, buf);
14014
- const messageLength = buf.size() - startMessageOffset;
14000
+ const messageLength = buf.currentWriteOffset() - startMessageOffset;
14015
14001
  // Write CrdtMessage header
14016
14002
  buf.setUint32(startMessageOffset, messageLength);
14017
14003
  buf.setUint32(startMessageOffset + 4, exports.CrdtMessageType.PUT_COMPONENT);
@@ -14160,9 +14146,7 @@
14160
14146
  * @param chunkMessage A chunk of binary messages
14161
14147
  */
14162
14148
  return function parseChunkMessage(chunkMessage) {
14163
- const buffer = createByteBuffer({
14164
- reading: { buffer: chunkMessage, currentOffset: 0 }
14165
- });
14149
+ const buffer = new ReadWriteByteBuffer(chunkMessage);
14166
14150
  let header;
14167
14151
  while ((header = CrdtMessageProtocol.getHeader(buffer))) {
14168
14152
  const offset = buffer.currentReadOffset();
@@ -14222,10 +14206,9 @@
14222
14206
  */
14223
14207
  async function receiveMessages() {
14224
14208
  const messagesToProcess = getMessages(receivedMessages);
14225
- const bufferForOutdated = createByteBuffer();
14209
+ const bufferForOutdated = new ReadWriteByteBuffer();
14226
14210
  const entitiesShouldBeCleaned = [];
14227
14211
  for (const msg of messagesToProcess) {
14228
- // TODO: emit delete entity to el onCrdtMessage
14229
14212
  if (msg.type === exports.CrdtMessageType.DELETE_ENTITY) {
14230
14213
  crdtClient.processMessage({
14231
14214
  type: typesExports.CRDTMessageType.CRDTMT_DeleteEntity,
@@ -14234,7 +14217,6 @@
14234
14217
  entitiesShouldBeCleaned.push(msg.entityId);
14235
14218
  }
14236
14219
  else {
14237
- // TODO: emit pu/delete component to el onCrdtMessage
14238
14220
  const crdtMessage = {
14239
14221
  type: typesExports.CRDTMessageType.CRDTMT_PutComponentData,
14240
14222
  entityId: msg.entityId,
@@ -14270,10 +14252,7 @@
14270
14252
  component.deleteFrom(msg.entityId, false);
14271
14253
  }
14272
14254
  else {
14273
- const opts = {
14274
- reading: { buffer: msg.data, currentOffset: 0 }
14275
- };
14276
- const data = createByteBuffer(opts);
14255
+ const data = new ReadWriteByteBuffer(msg.data);
14277
14256
  component.upsertFromBinary(msg.entityId, data, false);
14278
14257
  }
14279
14258
  onProcessEntityComponentChange &&
@@ -14310,7 +14289,6 @@
14310
14289
  }
14311
14290
  }
14312
14291
  }
14313
- // TODO: emit delete entity to el onCrdtMessage
14314
14292
  for (const entity of entitiesShouldBeCleaned) {
14315
14293
  // If we tried to resend outdated message and the entity was deleted before, we avoid sending them.
14316
14294
  for (let i = outdatedMessages.length - 1; i >= 0; i--) {
@@ -14366,7 +14344,7 @@
14366
14344
  // CRDT Messages will be the merge between the recieved transport messages and the new crdt messages
14367
14345
  const crdtMessages = getMessages(broadcastMessages);
14368
14346
  const outdatedMessagesBkp = getMessages(outdatedMessages);
14369
- const buffer = createByteBuffer();
14347
+ const buffer = new ReadWriteByteBuffer();
14370
14348
  for (const [component, entities] of dirtyEntities) {
14371
14349
  for (const entity of entities) {
14372
14350
  // Component will be always defined here since dirtyMap its an iterator of engine.componentsDefinition
@@ -14415,7 +14393,7 @@
14415
14393
  });
14416
14394
  }
14417
14395
  // Send CRDT messages to transports
14418
- const transportBuffer = createByteBuffer();
14396
+ const transportBuffer = new ReadWriteByteBuffer();
14419
14397
  for (const index in transports) {
14420
14398
  const transportIndex = Number(index);
14421
14399
  const transport = transports[transportIndex];
@@ -14440,7 +14418,7 @@
14440
14418
  transportBuffer.writeBuffer(message.messageBuffer, false);
14441
14419
  }
14442
14420
  }
14443
- const message = transportBuffer.size()
14421
+ const message = transportBuffer.currentWriteOffset()
14444
14422
  ? transportBuffer.toBinary()
14445
14423
  : new Uint8Array([]);
14446
14424
  await transport.send(message);
@@ -14569,7 +14547,7 @@
14569
14547
  if (!component) {
14570
14548
  throw new Error(`[toBinary] Component ${componentId} for ${entity} not found`);
14571
14549
  }
14572
- const writeBuffer = createByteBuffer();
14550
+ const writeBuffer = new ReadWriteByteBuffer();
14573
14551
  spec.serialize(component, writeBuffer);
14574
14552
  return writeBuffer;
14575
14553
  },
@@ -14578,7 +14556,7 @@
14578
14556
  if (!component) {
14579
14557
  return null;
14580
14558
  }
14581
- const writeBuffer = createByteBuffer();
14559
+ const writeBuffer = new ReadWriteByteBuffer();
14582
14560
  spec.serialize(component, writeBuffer);
14583
14561
  return writeBuffer;
14584
14562
  },