@dcl/playground-assets 7.1.1-4387338275.commit-167a7e2 → 7.1.1-4388004980.commit-d41e42b

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
@@ -70,6 +70,19 @@ export declare type AppendValueMessageBody = {
70
70
  data: Uint8Array;
71
71
  };
72
72
 
73
+ /**
74
+ * @public
75
+ */
76
+ export declare namespace AppendValueOperation {
77
+ const MESSAGE_HEADER_LENGTH = 16;
78
+ /**
79
+ * Call this function for an optimal writing data passing the ByteBuffer
80
+ * already allocated
81
+ */
82
+ export function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
83
+ export function read(buf: ByteBuffer): AppendValueMessage | null;
84
+ }
85
+
73
86
  /** @public */
74
87
  export declare const AudioSource: LastWriteWinElementSetComponentDefinition<PBAudioSource>;
75
88
 
@@ -160,6 +173,11 @@ export declare interface BaseComponent<T> {
160
173
  * @public
161
174
  */
162
175
  getCrdtUpdates(): Iterable<CrdtMessageBody>;
176
+ /**
177
+ * This function writes the whole state of the component into a ByteBuffer
178
+ * @public
179
+ */
180
+ dumpCrdtState(buffer: ByteBuffer): void;
163
181
  /**
164
182
  * @public
165
183
  * Marks the entity as deleted and signals it cannot be used ever again. It must
@@ -1110,6 +1128,35 @@ export declare type CrdtMessageHeader = {
1110
1128
  type: uint32;
1111
1129
  };
1112
1130
 
1131
+ /**
1132
+ * @public
1133
+ */
1134
+ export declare namespace CrdtMessageProtocol {
1135
+ /**
1136
+ * Validate if the message incoming is completed
1137
+ * @param buf - ByteBuffer
1138
+ */
1139
+ export function validate(buf: ByteBuffer): boolean;
1140
+ /**
1141
+ * Get the current header, consuming the bytes involved.
1142
+ * @param buf - ByteBuffer
1143
+ * @returns header or null if there is no validated message
1144
+ */
1145
+ export function readHeader(buf: ByteBuffer): CrdtMessageHeader | null;
1146
+ /**
1147
+ * Get the current header, without consuming the bytes involved.
1148
+ * @param buf - ByteBuffer
1149
+ * @returns header or null if there is no validated message
1150
+ */
1151
+ export function getHeader(buf: ByteBuffer): CrdtMessageHeader | null;
1152
+ /**
1153
+ * Consume the incoming message without processing it.
1154
+ * @param buf - ByteBuffer
1155
+ * @returns true in case of success or false if there is no valid message.
1156
+ */
1157
+ export function consumeMessage(buf: ByteBuffer): boolean;
1158
+ }
1159
+
1113
1160
  /**
1114
1161
  * @public
1115
1162
  */
@@ -1172,6 +1219,18 @@ export declare type DeepReadonlySet<T> = ReadonlySet<DeepReadonly<T>>;
1172
1219
  */
1173
1220
  export declare const DEG2RAD: number;
1174
1221
 
1222
+ /**
1223
+ * @public
1224
+ */
1225
+ export declare namespace DeleteComponent {
1226
+ const MESSAGE_HEADER_LENGTH = 12;
1227
+ /**
1228
+ * Write DeleteComponent message
1229
+ */
1230
+ export function write(entity: Entity, componentId: number, timestamp: number, buf: ByteBuffer): void;
1231
+ export function read(buf: ByteBuffer): DeleteComponentMessage | null;
1232
+ }
1233
+
1175
1234
  /**
1176
1235
  * @public
1177
1236
  */
@@ -1190,6 +1249,15 @@ export declare type DeleteComponentMessageBody = {
1190
1249
  timestamp: number;
1191
1250
  };
1192
1251
 
1252
+ /**
1253
+ * @public
1254
+ */
1255
+ export declare namespace DeleteEntity {
1256
+ const MESSAGE_HEADER_LENGTH = 4;
1257
+ export function write(entity: Entity, buf: ByteBuffer): void;
1258
+ export function read(buf: ByteBuffer): DeleteEntityMessage | null;
1259
+ }
1260
+
1193
1261
  /**
1194
1262
  * @public
1195
1263
  */
@@ -1239,6 +1307,13 @@ export declare interface EcsElements {
1239
1307
  };
1240
1308
  }
1241
1309
 
1310
+ /**
1311
+ * Internal constructor of new engines, this is an internal API
1312
+ * @public
1313
+ * @deprecated Prevent manual usage prefer "engine" for scene development
1314
+ */
1315
+ export declare function Engine(options?: IEngineOptions): IEngine;
1316
+
1242
1317
  /**
1243
1318
  * @public
1244
1319
  * The engine is the part of the scene that sits in the middle and manages all of the other parts.
@@ -1615,6 +1690,13 @@ export declare interface IEngine {
1615
1690
  seal(): void;
1616
1691
  }
1617
1692
 
1693
+ /**
1694
+ * @public
1695
+ */
1696
+ export declare interface IEngineOptions {
1697
+ onChangeFunction: OnChangeFunction;
1698
+ }
1699
+
1618
1700
  export declare type IEventNames = keyof IEvents;
1619
1701
 
1620
1702
  export declare interface IEvents {
@@ -3960,6 +4042,19 @@ export declare type PutComponentMessageBody = {
3960
4042
  data: Uint8Array;
3961
4043
  };
3962
4044
 
4045
+ /**
4046
+ * @public
4047
+ */
4048
+ export declare namespace PutComponentOperation {
4049
+ const MESSAGE_HEADER_LENGTH = 16;
4050
+ /**
4051
+ * Call this function for an optimal writing data passing the ByteBuffer
4052
+ * already allocated
4053
+ */
4054
+ export function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
4055
+ export function read(buf: ByteBuffer): PutComponentMessage | null;
4056
+ }
4057
+
3963
4058
  /**
3964
4059
  * @public
3965
4060
  * Quaternion is a type and a namespace.
package/dist/beta.d.ts CHANGED
@@ -70,6 +70,19 @@ export declare type AppendValueMessageBody = {
70
70
  data: Uint8Array;
71
71
  };
72
72
 
73
+ /**
74
+ * @public
75
+ */
76
+ export declare namespace AppendValueOperation {
77
+ const MESSAGE_HEADER_LENGTH = 16;
78
+ /**
79
+ * Call this function for an optimal writing data passing the ByteBuffer
80
+ * already allocated
81
+ */
82
+ export function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
83
+ export function read(buf: ByteBuffer): AppendValueMessage | null;
84
+ }
85
+
73
86
  /** @public */
74
87
  export declare const AudioSource: LastWriteWinElementSetComponentDefinition<PBAudioSource>;
75
88
 
@@ -160,6 +173,11 @@ export declare interface BaseComponent<T> {
160
173
  * @public
161
174
  */
162
175
  getCrdtUpdates(): Iterable<CrdtMessageBody>;
176
+ /**
177
+ * This function writes the whole state of the component into a ByteBuffer
178
+ * @public
179
+ */
180
+ dumpCrdtState(buffer: ByteBuffer): void;
163
181
  /**
164
182
  * @public
165
183
  * Marks the entity as deleted and signals it cannot be used ever again. It must
@@ -1110,6 +1128,35 @@ export declare type CrdtMessageHeader = {
1110
1128
  type: uint32;
1111
1129
  };
1112
1130
 
1131
+ /**
1132
+ * @public
1133
+ */
1134
+ export declare namespace CrdtMessageProtocol {
1135
+ /**
1136
+ * Validate if the message incoming is completed
1137
+ * @param buf - ByteBuffer
1138
+ */
1139
+ export function validate(buf: ByteBuffer): boolean;
1140
+ /**
1141
+ * Get the current header, consuming the bytes involved.
1142
+ * @param buf - ByteBuffer
1143
+ * @returns header or null if there is no validated message
1144
+ */
1145
+ export function readHeader(buf: ByteBuffer): CrdtMessageHeader | null;
1146
+ /**
1147
+ * Get the current header, without consuming the bytes involved.
1148
+ * @param buf - ByteBuffer
1149
+ * @returns header or null if there is no validated message
1150
+ */
1151
+ export function getHeader(buf: ByteBuffer): CrdtMessageHeader | null;
1152
+ /**
1153
+ * Consume the incoming message without processing it.
1154
+ * @param buf - ByteBuffer
1155
+ * @returns true in case of success or false if there is no valid message.
1156
+ */
1157
+ export function consumeMessage(buf: ByteBuffer): boolean;
1158
+ }
1159
+
1113
1160
  /**
1114
1161
  * @public
1115
1162
  */
@@ -1172,6 +1219,18 @@ export declare type DeepReadonlySet<T> = ReadonlySet<DeepReadonly<T>>;
1172
1219
  */
1173
1220
  export declare const DEG2RAD: number;
1174
1221
 
1222
+ /**
1223
+ * @public
1224
+ */
1225
+ export declare namespace DeleteComponent {
1226
+ const MESSAGE_HEADER_LENGTH = 12;
1227
+ /**
1228
+ * Write DeleteComponent message
1229
+ */
1230
+ export function write(entity: Entity, componentId: number, timestamp: number, buf: ByteBuffer): void;
1231
+ export function read(buf: ByteBuffer): DeleteComponentMessage | null;
1232
+ }
1233
+
1175
1234
  /**
1176
1235
  * @public
1177
1236
  */
@@ -1190,6 +1249,15 @@ export declare type DeleteComponentMessageBody = {
1190
1249
  timestamp: number;
1191
1250
  };
1192
1251
 
1252
+ /**
1253
+ * @public
1254
+ */
1255
+ export declare namespace DeleteEntity {
1256
+ const MESSAGE_HEADER_LENGTH = 4;
1257
+ export function write(entity: Entity, buf: ByteBuffer): void;
1258
+ export function read(buf: ByteBuffer): DeleteEntityMessage | null;
1259
+ }
1260
+
1193
1261
  /**
1194
1262
  * @public
1195
1263
  */
@@ -1239,6 +1307,13 @@ export declare interface EcsElements {
1239
1307
  };
1240
1308
  }
1241
1309
 
1310
+ /**
1311
+ * Internal constructor of new engines, this is an internal API
1312
+ * @public
1313
+ * @deprecated Prevent manual usage prefer "engine" for scene development
1314
+ */
1315
+ export declare function Engine(options?: IEngineOptions): IEngine;
1316
+
1242
1317
  /**
1243
1318
  * @public
1244
1319
  * The engine is the part of the scene that sits in the middle and manages all of the other parts.
@@ -1611,6 +1686,13 @@ export declare interface IEngine {
1611
1686
  seal(): void;
1612
1687
  }
1613
1688
 
1689
+ /**
1690
+ * @public
1691
+ */
1692
+ export declare interface IEngineOptions {
1693
+ onChangeFunction: OnChangeFunction;
1694
+ }
1695
+
1614
1696
  export declare type IEventNames = keyof IEvents;
1615
1697
 
1616
1698
  export declare interface IEvents {
@@ -3956,6 +4038,19 @@ export declare type PutComponentMessageBody = {
3956
4038
  data: Uint8Array;
3957
4039
  };
3958
4040
 
4041
+ /**
4042
+ * @public
4043
+ */
4044
+ export declare namespace PutComponentOperation {
4045
+ const MESSAGE_HEADER_LENGTH = 16;
4046
+ /**
4047
+ * Call this function for an optimal writing data passing the ByteBuffer
4048
+ * already allocated
4049
+ */
4050
+ export function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
4051
+ export function read(buf: ByteBuffer): PutComponentMessage | null;
4052
+ }
4053
+
3959
4054
  /**
3960
4055
  * @public
3961
4056
  * Quaternion is a type and a namespace.
@@ -70,6 +70,19 @@ export declare type AppendValueMessageBody = {
70
70
  data: Uint8Array;
71
71
  };
72
72
 
73
+ /**
74
+ * @public
75
+ */
76
+ export declare namespace AppendValueOperation {
77
+ const MESSAGE_HEADER_LENGTH = 16;
78
+ /**
79
+ * Call this function for an optimal writing data passing the ByteBuffer
80
+ * already allocated
81
+ */
82
+ export function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
83
+ export function read(buf: ByteBuffer): AppendValueMessage | null;
84
+ }
85
+
73
86
  /** @public */
74
87
  export declare const AudioSource: LastWriteWinElementSetComponentDefinition<PBAudioSource>;
75
88
 
@@ -160,6 +173,11 @@ export declare interface BaseComponent<T> {
160
173
  * @public
161
174
  */
162
175
  getCrdtUpdates(): Iterable<CrdtMessageBody>;
176
+ /**
177
+ * This function writes the whole state of the component into a ByteBuffer
178
+ * @public
179
+ */
180
+ dumpCrdtState(buffer: ByteBuffer): void;
163
181
  /**
164
182
  * @public
165
183
  * Marks the entity as deleted and signals it cannot be used ever again. It must
@@ -1110,6 +1128,35 @@ export declare type CrdtMessageHeader = {
1110
1128
  type: uint32;
1111
1129
  };
1112
1130
 
1131
+ /**
1132
+ * @public
1133
+ */
1134
+ export declare namespace CrdtMessageProtocol {
1135
+ /**
1136
+ * Validate if the message incoming is completed
1137
+ * @param buf - ByteBuffer
1138
+ */
1139
+ export function validate(buf: ByteBuffer): boolean;
1140
+ /**
1141
+ * Get the current header, consuming the bytes involved.
1142
+ * @param buf - ByteBuffer
1143
+ * @returns header or null if there is no validated message
1144
+ */
1145
+ export function readHeader(buf: ByteBuffer): CrdtMessageHeader | null;
1146
+ /**
1147
+ * Get the current header, without consuming the bytes involved.
1148
+ * @param buf - ByteBuffer
1149
+ * @returns header or null if there is no validated message
1150
+ */
1151
+ export function getHeader(buf: ByteBuffer): CrdtMessageHeader | null;
1152
+ /**
1153
+ * Consume the incoming message without processing it.
1154
+ * @param buf - ByteBuffer
1155
+ * @returns true in case of success or false if there is no valid message.
1156
+ */
1157
+ export function consumeMessage(buf: ByteBuffer): boolean;
1158
+ }
1159
+
1113
1160
  /**
1114
1161
  * @public
1115
1162
  */
@@ -1172,6 +1219,18 @@ export declare type DeepReadonlySet<T> = ReadonlySet<DeepReadonly<T>>;
1172
1219
  */
1173
1220
  export declare const DEG2RAD: number;
1174
1221
 
1222
+ /**
1223
+ * @public
1224
+ */
1225
+ export declare namespace DeleteComponent {
1226
+ const MESSAGE_HEADER_LENGTH = 12;
1227
+ /**
1228
+ * Write DeleteComponent message
1229
+ */
1230
+ export function write(entity: Entity, componentId: number, timestamp: number, buf: ByteBuffer): void;
1231
+ export function read(buf: ByteBuffer): DeleteComponentMessage | null;
1232
+ }
1233
+
1175
1234
  /**
1176
1235
  * @public
1177
1236
  */
@@ -1190,6 +1249,15 @@ export declare type DeleteComponentMessageBody = {
1190
1249
  timestamp: number;
1191
1250
  };
1192
1251
 
1252
+ /**
1253
+ * @public
1254
+ */
1255
+ export declare namespace DeleteEntity {
1256
+ const MESSAGE_HEADER_LENGTH = 4;
1257
+ export function write(entity: Entity, buf: ByteBuffer): void;
1258
+ export function read(buf: ByteBuffer): DeleteEntityMessage | null;
1259
+ }
1260
+
1193
1261
  /**
1194
1262
  * @public
1195
1263
  */
@@ -1239,6 +1307,13 @@ export declare interface EcsElements {
1239
1307
  };
1240
1308
  }
1241
1309
 
1310
+ /**
1311
+ * Internal constructor of new engines, this is an internal API
1312
+ * @public
1313
+ * @deprecated Prevent manual usage prefer "engine" for scene development
1314
+ */
1315
+ export declare function Engine(options?: IEngineOptions): IEngine;
1316
+
1242
1317
  /**
1243
1318
  * @public
1244
1319
  * The engine is the part of the scene that sits in the middle and manages all of the other parts.
@@ -1611,6 +1686,13 @@ export declare interface IEngine {
1611
1686
  seal(): void;
1612
1687
  }
1613
1688
 
1689
+ /**
1690
+ * @public
1691
+ */
1692
+ export declare interface IEngineOptions {
1693
+ onChangeFunction: OnChangeFunction;
1694
+ }
1695
+
1614
1696
  export declare type IEventNames = keyof IEvents;
1615
1697
 
1616
1698
  export declare interface IEvents {
@@ -3956,6 +4038,19 @@ export declare type PutComponentMessageBody = {
3956
4038
  data: Uint8Array;
3957
4039
  };
3958
4040
 
4041
+ /**
4042
+ * @public
4043
+ */
4044
+ export declare namespace PutComponentOperation {
4045
+ const MESSAGE_HEADER_LENGTH = 16;
4046
+ /**
4047
+ * Call this function for an optimal writing data passing the ByteBuffer
4048
+ * already allocated
4049
+ */
4050
+ export function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
4051
+ export function read(buf: ByteBuffer): PutComponentMessage | null;
4052
+ }
4053
+
3959
4054
  /**
3960
4055
  * @public
3961
4056
  * Quaternion is a type and a namespace.
package/dist/index.js CHANGED
@@ -14512,7 +14512,7 @@
14512
14512
  //
14513
14513
 
14514
14514
  /**
14515
- * @internal
14515
+ * @public
14516
14516
  */
14517
14517
  exports.CrdtMessageProtocol = void 0;
14518
14518
  (function (CrdtMessageProtocol) {
@@ -14580,7 +14580,7 @@
14580
14580
  })(exports.CrdtMessageProtocol || (exports.CrdtMessageProtocol = {}));
14581
14581
 
14582
14582
  /**
14583
- * @internal
14583
+ * @public
14584
14584
  */
14585
14585
  exports.DeleteComponent = void 0;
14586
14586
  (function (DeleteComponent) {
@@ -14621,7 +14621,7 @@
14621
14621
  })(exports.DeleteComponent || (exports.DeleteComponent = {}));
14622
14622
 
14623
14623
  /**
14624
- * @internal
14624
+ * @public
14625
14625
  */
14626
14626
  exports.AppendValueOperation = void 0;
14627
14627
  (function (AppendValueOperation) {
@@ -14669,7 +14669,7 @@
14669
14669
  })(exports.AppendValueOperation || (exports.AppendValueOperation = {}));
14670
14670
 
14671
14671
  /**
14672
- * @internal
14672
+ * @public
14673
14673
  */
14674
14674
  exports.DeleteEntity = void 0;
14675
14675
  (function (DeleteEntity) {
@@ -14699,7 +14699,7 @@
14699
14699
  })(exports.DeleteEntity || (exports.DeleteEntity = {}));
14700
14700
 
14701
14701
  /**
14702
- * @internal
14702
+ * @public
14703
14703
  */
14704
14704
  exports.PutComponentOperation = void 0;
14705
14705
  (function (PutComponentOperation) {
@@ -14842,6 +14842,7 @@
14842
14842
  engine.entityContainer.updateUsedEntity(msg.entityId);
14843
14843
  }
14844
14844
  const component = engine.getComponentOrNull(msg.componentId);
14845
+ /* istanbul ignore else */
14845
14846
  if (component) {
14846
14847
  const [conflictMessage, value] = component.updateFromCrdt(msg);
14847
14848
  if (conflictMessage) {
@@ -14863,6 +14864,10 @@
14863
14864
  onProcessEntityComponentChange && onProcessEntityComponentChange(msg.entityId, msg.type, component, value);
14864
14865
  }
14865
14866
  }
14867
+ else {
14868
+ // TODO: test this line, it is fundammental to make the editor work
14869
+ broadcastMessages.push(msg);
14870
+ }
14866
14871
  }
14867
14872
  }
14868
14873
  // the last stage of the syncrhonization is to delete the entities
@@ -15022,6 +15027,22 @@
15022
15027
  timestamps.set(entity, newTimestamp);
15023
15028
  return newTimestamp;
15024
15029
  }
15030
+ function createDumpLwwFunctionFromCrdt(componentId, timestamps, schema, data) {
15031
+ return function dumpCrdtState(buffer) {
15032
+ for (const [entity, timestamp] of timestamps) {
15033
+ /* istanbul ignore else */
15034
+ if (data.has(entity)) {
15035
+ const it = data.get(entity);
15036
+ const buf = new ReadWriteByteBuffer();
15037
+ schema.serialize(it, buf);
15038
+ exports.PutComponentOperation.write(entity, timestamp, componentId, buf.toBinary(), buffer);
15039
+ }
15040
+ else {
15041
+ exports.DeleteComponent.write(entity, componentId, timestamp, buffer);
15042
+ }
15043
+ }
15044
+ };
15045
+ }
15025
15046
  function createUpdateLwwFromCrdt(componentId, timestamps, schema, data) {
15026
15047
  /**
15027
15048
  * Process the received message only if the lamport number recieved is higher
@@ -15239,7 +15260,8 @@
15239
15260
  }
15240
15261
  },
15241
15262
  getCrdtUpdates: createGetCrdtMessagesForLww(componentId, timestamps, dirtyIterator, schema, data),
15242
- updateFromCrdt: createUpdateLwwFromCrdt(componentId, timestamps, schema, data)
15263
+ updateFromCrdt: createUpdateLwwFromCrdt(componentId, timestamps, schema, data),
15264
+ dumpCrdtState: createDumpLwwFunctionFromCrdt(componentId, timestamps, schema, data)
15243
15265
  };
15244
15266
  }
15245
15267
 
@@ -15412,6 +15434,15 @@
15412
15434
  append(_body.entityId, schema.deserialize(buf));
15413
15435
  }
15414
15436
  return [null, undefined];
15437
+ },
15438
+ dumpCrdtState: function (buffer) {
15439
+ for (const [entity, { raw }] of data) {
15440
+ for (const it of raw) {
15441
+ const buf = new ReadWriteByteBuffer();
15442
+ schema.serialize(it.value, buf);
15443
+ exports.AppendValueOperation.write(entity, 0, componentId, buf.toBinary(), buffer);
15444
+ }
15445
+ }
15415
15446
  }
15416
15447
  };
15417
15448
  return ret;
@@ -15796,7 +15827,9 @@
15796
15827
  };
15797
15828
  }
15798
15829
  /**
15799
- * @internal
15830
+ * Internal constructor of new engines, this is an internal API
15831
+ * @public
15832
+ * @deprecated Prevent manual usage prefer "engine" for scene development
15800
15833
  */
15801
15834
  function Engine(options) {
15802
15835
  const partialEngine = preEngine();