@dcl/playground-assets 7.0.6-4106539347.commit-b417eb5 → 7.0.6-4107031259.commit-ac4f9ce
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 +7 -4
- package/dist/beta.d.ts +7 -4
- package/dist/index.bundled.d.ts +7 -4
- package/dist/index.js +106 -112
- package/dist/index.js.map +1 -1
- package/dist/index.min.js +1 -1
- package/dist/index.min.js.map +1 -1
- package/dist/playground/sdk/dcl-sdk.package.json +3 -3
- package/dist/playground-assets.d.ts +7 -4
- package/etc/playground-assets.api.json +2 -2
- package/package.json +3 -3
package/dist/alpha.d.ts
CHANGED
|
@@ -1134,6 +1134,9 @@ export declare type DeepReadonlySet<T> = ReadonlySet<DeepReadonly<T>>;
|
|
|
1134
1134
|
export declare const DEG2RAD: number;
|
|
1135
1135
|
|
|
1136
1136
|
/**
|
|
1137
|
+
* @param entity - Uint32 number of the entity
|
|
1138
|
+
* @param componentId - Uint32 number of id
|
|
1139
|
+
* @param timestamp - Uint32 Lamport timestamp
|
|
1137
1140
|
* @public
|
|
1138
1141
|
*/
|
|
1139
1142
|
export declare type DeleteComponentMessageBody = {
|
|
@@ -3719,11 +3722,11 @@ export declare type PositionType = 'absolute' | 'relative';
|
|
|
3719
3722
|
export declare type PositionUnit = `${number}px` | `${number}%` | number;
|
|
3720
3723
|
|
|
3721
3724
|
/**
|
|
3722
|
-
* Min. length = header (8 bytes) +
|
|
3725
|
+
* Min. length = header (8 bytes) + 16 bytes = 24 bytes
|
|
3723
3726
|
*
|
|
3724
|
-
* @param entity -
|
|
3725
|
-
* @param componentId -
|
|
3726
|
-
* @param timestamp -
|
|
3727
|
+
* @param entity - Uint32 number of the entity
|
|
3728
|
+
* @param componentId - Uint32 number of id
|
|
3729
|
+
* @param timestamp - Uint32 Lamport timestamp
|
|
3727
3730
|
* @param data - Uint8[] data of component => length(4 bytes) + block of bytes[0..length-1]
|
|
3728
3731
|
* @public
|
|
3729
3732
|
*/
|
package/dist/beta.d.ts
CHANGED
|
@@ -1134,6 +1134,9 @@ export declare type DeepReadonlySet<T> = ReadonlySet<DeepReadonly<T>>;
|
|
|
1134
1134
|
export declare const DEG2RAD: number;
|
|
1135
1135
|
|
|
1136
1136
|
/**
|
|
1137
|
+
* @param entity - Uint32 number of the entity
|
|
1138
|
+
* @param componentId - Uint32 number of id
|
|
1139
|
+
* @param timestamp - Uint32 Lamport timestamp
|
|
1137
1140
|
* @public
|
|
1138
1141
|
*/
|
|
1139
1142
|
export declare type DeleteComponentMessageBody = {
|
|
@@ -3715,11 +3718,11 @@ export declare type PositionType = 'absolute' | 'relative';
|
|
|
3715
3718
|
export declare type PositionUnit = `${number}px` | `${number}%` | number;
|
|
3716
3719
|
|
|
3717
3720
|
/**
|
|
3718
|
-
* Min. length = header (8 bytes) +
|
|
3721
|
+
* Min. length = header (8 bytes) + 16 bytes = 24 bytes
|
|
3719
3722
|
*
|
|
3720
|
-
* @param entity -
|
|
3721
|
-
* @param componentId -
|
|
3722
|
-
* @param timestamp -
|
|
3723
|
+
* @param entity - Uint32 number of the entity
|
|
3724
|
+
* @param componentId - Uint32 number of id
|
|
3725
|
+
* @param timestamp - Uint32 Lamport timestamp
|
|
3723
3726
|
* @param data - Uint8[] data of component => length(4 bytes) + block of bytes[0..length-1]
|
|
3724
3727
|
* @public
|
|
3725
3728
|
*/
|
package/dist/index.bundled.d.ts
CHANGED
|
@@ -1134,6 +1134,9 @@ export declare type DeepReadonlySet<T> = ReadonlySet<DeepReadonly<T>>;
|
|
|
1134
1134
|
export declare const DEG2RAD: number;
|
|
1135
1135
|
|
|
1136
1136
|
/**
|
|
1137
|
+
* @param entity - Uint32 number of the entity
|
|
1138
|
+
* @param componentId - Uint32 number of id
|
|
1139
|
+
* @param timestamp - Uint32 Lamport timestamp
|
|
1137
1140
|
* @public
|
|
1138
1141
|
*/
|
|
1139
1142
|
export declare type DeleteComponentMessageBody = {
|
|
@@ -3715,11 +3718,11 @@ export declare type PositionType = 'absolute' | 'relative';
|
|
|
3715
3718
|
export declare type PositionUnit = `${number}px` | `${number}%` | number;
|
|
3716
3719
|
|
|
3717
3720
|
/**
|
|
3718
|
-
* Min. length = header (8 bytes) +
|
|
3721
|
+
* Min. length = header (8 bytes) + 16 bytes = 24 bytes
|
|
3719
3722
|
*
|
|
3720
|
-
* @param entity -
|
|
3721
|
-
* @param componentId -
|
|
3722
|
-
* @param timestamp -
|
|
3723
|
+
* @param entity - Uint32 number of the entity
|
|
3724
|
+
* @param componentId - Uint32 number of id
|
|
3725
|
+
* @param timestamp - Uint32 Lamport timestamp
|
|
3723
3726
|
* @param data - Uint8[] data of component => length(4 bytes) + block of bytes[0..length-1]
|
|
3724
3727
|
* @public
|
|
3725
3728
|
*/
|
package/dist/index.js
CHANGED
|
@@ -13936,7 +13936,7 @@
|
|
|
13936
13936
|
}
|
|
13937
13937
|
// Outdated Message. Resend our state message through the wire.
|
|
13938
13938
|
if (current.timestamp > timestamp) {
|
|
13939
|
-
return types_1.ProcessMessageResultType.
|
|
13939
|
+
return types_1.ProcessMessageResultType.StateOutdatedTimestamp;
|
|
13940
13940
|
}
|
|
13941
13941
|
const currentDataGreater = dataCompare(current.data, data);
|
|
13942
13942
|
// Same data, same timestamp. Weirdo echo message.
|
|
@@ -14440,13 +14440,80 @@
|
|
|
14440
14440
|
*/
|
|
14441
14441
|
const CRDT_MESSAGE_HEADER_LENGTH = 8;
|
|
14442
14442
|
|
|
14443
|
+
/**
|
|
14444
|
+
* @internal
|
|
14445
|
+
*/
|
|
14446
|
+
exports.CrdtMessageProtocol = void 0;
|
|
14447
|
+
(function (CrdtMessageProtocol) {
|
|
14448
|
+
/**
|
|
14449
|
+
* Validate if the message incoming is completed
|
|
14450
|
+
* @param buf - ByteBuffer
|
|
14451
|
+
*/
|
|
14452
|
+
function validate(buf) {
|
|
14453
|
+
const rem = buf.remainingBytes();
|
|
14454
|
+
if (rem < CRDT_MESSAGE_HEADER_LENGTH) {
|
|
14455
|
+
return false;
|
|
14456
|
+
}
|
|
14457
|
+
const messageLength = buf.getUint32(buf.currentReadOffset());
|
|
14458
|
+
if (rem < messageLength) {
|
|
14459
|
+
return false;
|
|
14460
|
+
}
|
|
14461
|
+
return true;
|
|
14462
|
+
}
|
|
14463
|
+
CrdtMessageProtocol.validate = validate;
|
|
14464
|
+
/**
|
|
14465
|
+
* Get the current header, consuming the bytes involved.
|
|
14466
|
+
* @param buf - ByteBuffer
|
|
14467
|
+
* @returns header or null if there is no validated message
|
|
14468
|
+
*/
|
|
14469
|
+
function readHeader(buf) {
|
|
14470
|
+
if (!validate(buf)) {
|
|
14471
|
+
return null;
|
|
14472
|
+
}
|
|
14473
|
+
return {
|
|
14474
|
+
length: buf.readUint32(),
|
|
14475
|
+
type: buf.readUint32()
|
|
14476
|
+
};
|
|
14477
|
+
}
|
|
14478
|
+
CrdtMessageProtocol.readHeader = readHeader;
|
|
14479
|
+
/**
|
|
14480
|
+
* Get the current header, without consuming the bytes involved.
|
|
14481
|
+
* @param buf - ByteBuffer
|
|
14482
|
+
* @returns header or null if there is no validated message
|
|
14483
|
+
*/
|
|
14484
|
+
function getHeader(buf) {
|
|
14485
|
+
if (!validate(buf)) {
|
|
14486
|
+
return null;
|
|
14487
|
+
}
|
|
14488
|
+
const currentOffset = buf.currentReadOffset();
|
|
14489
|
+
return {
|
|
14490
|
+
length: buf.getUint32(currentOffset),
|
|
14491
|
+
type: buf.getUint32(currentOffset + 4)
|
|
14492
|
+
};
|
|
14493
|
+
}
|
|
14494
|
+
CrdtMessageProtocol.getHeader = getHeader;
|
|
14495
|
+
/**
|
|
14496
|
+
* Consume the incoming message without processing it.
|
|
14497
|
+
* @param buf - ByteBuffer
|
|
14498
|
+
* @returns true in case of success or false if there is no valid message.
|
|
14499
|
+
*/
|
|
14500
|
+
function consumeMessage(buf) {
|
|
14501
|
+
const header = getHeader(buf);
|
|
14502
|
+
if (!header) {
|
|
14503
|
+
return false;
|
|
14504
|
+
}
|
|
14505
|
+
buf.incrementReadOffset(header.length);
|
|
14506
|
+
return true;
|
|
14507
|
+
}
|
|
14508
|
+
CrdtMessageProtocol.consumeMessage = consumeMessage;
|
|
14509
|
+
})(exports.CrdtMessageProtocol || (exports.CrdtMessageProtocol = {}));
|
|
14510
|
+
|
|
14443
14511
|
/**
|
|
14444
14512
|
* @internal
|
|
14445
14513
|
*/
|
|
14446
14514
|
exports.DeleteComponent = void 0;
|
|
14447
14515
|
(function (DeleteComponent) {
|
|
14448
|
-
|
|
14449
|
-
DeleteComponent.MESSAGE_HEADER_LENGTH = 20;
|
|
14516
|
+
DeleteComponent.MESSAGE_HEADER_LENGTH = 12;
|
|
14450
14517
|
/**
|
|
14451
14518
|
* Write DeleteComponent message
|
|
14452
14519
|
*/
|
|
@@ -14460,10 +14527,7 @@
|
|
|
14460
14527
|
// Write ComponentOperation header
|
|
14461
14528
|
buf.setUint32(startMessageOffset + 8, entity);
|
|
14462
14529
|
buf.setUint32(startMessageOffset + 12, componentId);
|
|
14463
|
-
|
|
14464
|
-
buf.setUint64(startMessageOffset + 16, BigInt(timestamp));
|
|
14465
|
-
// TODO: remove buffer length (-4 bytes)
|
|
14466
|
-
buf.setUint32(startMessageOffset + 24, 0);
|
|
14530
|
+
buf.setUint32(startMessageOffset + 16, timestamp);
|
|
14467
14531
|
}
|
|
14468
14532
|
DeleteComponent.write = write;
|
|
14469
14533
|
function read(buf) {
|
|
@@ -14478,61 +14542,13 @@
|
|
|
14478
14542
|
...header,
|
|
14479
14543
|
entityId: buf.readUint32(),
|
|
14480
14544
|
componentId: buf.readUint32(),
|
|
14481
|
-
timestamp:
|
|
14545
|
+
timestamp: buf.readUint32()
|
|
14482
14546
|
};
|
|
14483
|
-
// TODO: remove buffer length
|
|
14484
|
-
buf.incrementReadOffset(4);
|
|
14485
14547
|
return msg;
|
|
14486
14548
|
}
|
|
14487
14549
|
DeleteComponent.read = read;
|
|
14488
14550
|
})(exports.DeleteComponent || (exports.DeleteComponent = {}));
|
|
14489
14551
|
|
|
14490
|
-
/**
|
|
14491
|
-
* @internal
|
|
14492
|
-
*/
|
|
14493
|
-
exports.PutComponentOperation = void 0;
|
|
14494
|
-
(function (PutComponentOperation) {
|
|
14495
|
-
PutComponentOperation.MESSAGE_HEADER_LENGTH = 20;
|
|
14496
|
-
/**
|
|
14497
|
-
* Call this function for an optimal writing data passing the ByteBuffer
|
|
14498
|
-
* already allocated
|
|
14499
|
-
*/
|
|
14500
|
-
function write(entity, timestamp, componentDefinition, buf) {
|
|
14501
|
-
// reserve the beginning
|
|
14502
|
-
const startMessageOffset = buf.incrementWriteOffset(CRDT_MESSAGE_HEADER_LENGTH + PutComponentOperation.MESSAGE_HEADER_LENGTH);
|
|
14503
|
-
// write body
|
|
14504
|
-
componentDefinition.writeToByteBuffer(entity, buf);
|
|
14505
|
-
const messageLength = buf.currentWriteOffset() - startMessageOffset;
|
|
14506
|
-
// Write CrdtMessage header
|
|
14507
|
-
buf.setUint32(startMessageOffset, messageLength);
|
|
14508
|
-
buf.setUint32(startMessageOffset + 4, exports.CrdtMessageType.PUT_COMPONENT);
|
|
14509
|
-
// Write ComponentOperation header
|
|
14510
|
-
buf.setUint32(startMessageOffset + 8, entity);
|
|
14511
|
-
buf.setUint32(startMessageOffset + 12, componentDefinition.componentId);
|
|
14512
|
-
buf.setUint64(startMessageOffset + 16, BigInt(timestamp));
|
|
14513
|
-
const newLocal = messageLength - PutComponentOperation.MESSAGE_HEADER_LENGTH - CRDT_MESSAGE_HEADER_LENGTH;
|
|
14514
|
-
buf.setUint32(startMessageOffset + 24, newLocal);
|
|
14515
|
-
}
|
|
14516
|
-
PutComponentOperation.write = write;
|
|
14517
|
-
function read(buf) {
|
|
14518
|
-
const header = exports.CrdtMessageProtocol.readHeader(buf);
|
|
14519
|
-
if (!header) {
|
|
14520
|
-
return null;
|
|
14521
|
-
}
|
|
14522
|
-
if (header.type !== exports.CrdtMessageType.PUT_COMPONENT) {
|
|
14523
|
-
throw new Error('PutComponentOperation tried to read another message type.');
|
|
14524
|
-
}
|
|
14525
|
-
return {
|
|
14526
|
-
...header,
|
|
14527
|
-
entityId: buf.readUint32(),
|
|
14528
|
-
componentId: buf.readUint32(),
|
|
14529
|
-
timestamp: Number(buf.readUint64()),
|
|
14530
|
-
data: buf.readBuffer()
|
|
14531
|
-
};
|
|
14532
|
-
}
|
|
14533
|
-
PutComponentOperation.read = read;
|
|
14534
|
-
})(exports.PutComponentOperation || (exports.PutComponentOperation = {}));
|
|
14535
|
-
|
|
14536
14552
|
/**
|
|
14537
14553
|
* @internal
|
|
14538
14554
|
*/
|
|
@@ -14553,7 +14569,7 @@
|
|
|
14553
14569
|
return null;
|
|
14554
14570
|
}
|
|
14555
14571
|
if (header.type !== exports.CrdtMessageType.DELETE_ENTITY) {
|
|
14556
|
-
throw new Error('
|
|
14572
|
+
throw new Error('DeleteEntity tried to read another message type.');
|
|
14557
14573
|
}
|
|
14558
14574
|
return {
|
|
14559
14575
|
...header,
|
|
@@ -14566,70 +14582,48 @@
|
|
|
14566
14582
|
/**
|
|
14567
14583
|
* @internal
|
|
14568
14584
|
*/
|
|
14569
|
-
exports.
|
|
14570
|
-
(function (
|
|
14585
|
+
exports.PutComponentOperation = void 0;
|
|
14586
|
+
(function (PutComponentOperation) {
|
|
14587
|
+
PutComponentOperation.MESSAGE_HEADER_LENGTH = 16;
|
|
14571
14588
|
/**
|
|
14572
|
-
*
|
|
14573
|
-
*
|
|
14589
|
+
* Call this function for an optimal writing data passing the ByteBuffer
|
|
14590
|
+
* already allocated
|
|
14574
14591
|
*/
|
|
14575
|
-
function
|
|
14576
|
-
|
|
14577
|
-
|
|
14578
|
-
|
|
14579
|
-
|
|
14580
|
-
const messageLength = buf.
|
|
14581
|
-
|
|
14582
|
-
|
|
14583
|
-
|
|
14584
|
-
|
|
14592
|
+
function write(entity, timestamp, componentDefinition, buf) {
|
|
14593
|
+
// reserve the beginning
|
|
14594
|
+
const startMessageOffset = buf.incrementWriteOffset(CRDT_MESSAGE_HEADER_LENGTH + PutComponentOperation.MESSAGE_HEADER_LENGTH);
|
|
14595
|
+
// write body
|
|
14596
|
+
componentDefinition.writeToByteBuffer(entity, buf);
|
|
14597
|
+
const messageLength = buf.currentWriteOffset() - startMessageOffset;
|
|
14598
|
+
// Write CrdtMessage header
|
|
14599
|
+
buf.setUint32(startMessageOffset, messageLength);
|
|
14600
|
+
buf.setUint32(startMessageOffset + 4, exports.CrdtMessageType.PUT_COMPONENT);
|
|
14601
|
+
// Write ComponentOperation header
|
|
14602
|
+
buf.setUint32(startMessageOffset + 8, entity);
|
|
14603
|
+
buf.setUint32(startMessageOffset + 12, componentDefinition.componentId);
|
|
14604
|
+
buf.setUint32(startMessageOffset + 16, timestamp);
|
|
14605
|
+
const newLocal = messageLength - PutComponentOperation.MESSAGE_HEADER_LENGTH - CRDT_MESSAGE_HEADER_LENGTH;
|
|
14606
|
+
buf.setUint32(startMessageOffset + 20, newLocal);
|
|
14585
14607
|
}
|
|
14586
|
-
|
|
14587
|
-
|
|
14588
|
-
|
|
14589
|
-
|
|
14590
|
-
* @returns header or null if there is no validated message
|
|
14591
|
-
*/
|
|
14592
|
-
function readHeader(buf) {
|
|
14593
|
-
if (!validate(buf)) {
|
|
14608
|
+
PutComponentOperation.write = write;
|
|
14609
|
+
function read(buf) {
|
|
14610
|
+
const header = exports.CrdtMessageProtocol.readHeader(buf);
|
|
14611
|
+
if (!header) {
|
|
14594
14612
|
return null;
|
|
14595
14613
|
}
|
|
14596
|
-
|
|
14597
|
-
|
|
14598
|
-
type: buf.readUint32()
|
|
14599
|
-
};
|
|
14600
|
-
}
|
|
14601
|
-
CrdtMessageProtocol.readHeader = readHeader;
|
|
14602
|
-
/**
|
|
14603
|
-
* Get the current header, without consuming the bytes involved.
|
|
14604
|
-
* @param buf - ByteBuffer
|
|
14605
|
-
* @returns header or null if there is no validated message
|
|
14606
|
-
*/
|
|
14607
|
-
function getHeader(buf) {
|
|
14608
|
-
if (!validate(buf)) {
|
|
14609
|
-
return null;
|
|
14614
|
+
if (header.type !== exports.CrdtMessageType.PUT_COMPONENT) {
|
|
14615
|
+
throw new Error('PutComponentOperation tried to read another message type.');
|
|
14610
14616
|
}
|
|
14611
|
-
const currentOffset = buf.currentReadOffset();
|
|
14612
14617
|
return {
|
|
14613
|
-
|
|
14614
|
-
|
|
14618
|
+
...header,
|
|
14619
|
+
entityId: buf.readUint32(),
|
|
14620
|
+
componentId: buf.readUint32(),
|
|
14621
|
+
timestamp: buf.readUint32(),
|
|
14622
|
+
data: buf.readBuffer()
|
|
14615
14623
|
};
|
|
14616
14624
|
}
|
|
14617
|
-
|
|
14618
|
-
|
|
14619
|
-
* Consume the incoming message without processing it.
|
|
14620
|
-
* @param buf - ByteBuffer
|
|
14621
|
-
* @returns true in case of success or false if there is no valid message.
|
|
14622
|
-
*/
|
|
14623
|
-
function consumeMessage(buf) {
|
|
14624
|
-
const header = getHeader(buf);
|
|
14625
|
-
if (!header) {
|
|
14626
|
-
return false;
|
|
14627
|
-
}
|
|
14628
|
-
buf.incrementReadOffset(header.length);
|
|
14629
|
-
return true;
|
|
14630
|
-
}
|
|
14631
|
-
CrdtMessageProtocol.consumeMessage = consumeMessage;
|
|
14632
|
-
})(exports.CrdtMessageProtocol || (exports.CrdtMessageProtocol = {}));
|
|
14625
|
+
PutComponentOperation.read = read;
|
|
14626
|
+
})(exports.PutComponentOperation || (exports.PutComponentOperation = {}));
|
|
14633
14627
|
|
|
14634
14628
|
/**
|
|
14635
14629
|
* @internal
|