@dcl/playground-assets 7.0.6-3823801200.commit-32470bd → 7.0.6-3830539086.commit-6152fbd

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.
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dcl/sdk",
3
- "version": "7.0.6-3823801200.commit-32470bd",
3
+ "version": "7.0.6-3830539086.commit-6152fbd",
4
4
  "description": "",
5
5
  "main": "./index.js",
6
6
  "typings": "./index.d.ts",
@@ -36,5 +36,5 @@
36
36
  "displayName": "SDK",
37
37
  "tsconfig": "./tsconfig.json"
38
38
  },
39
- "commit": "32470bdb44a9d3c8663f432e0d3262a09c4201cf"
39
+ "commit": "6152fbdf7dfabf5e0d61ef713e75e670ed3d69b8"
40
40
  }
@@ -1057,6 +1057,57 @@ export declare type ComponentSchema<T extends [ComponentDefinition<any>, ...Comp
1057
1057
  [K in keyof T]: T[K] extends ComponentDefinition<any> ? ReturnType<T[K]['getMutable']> : never;
1058
1058
  };
1059
1059
 
1060
+ export declare const CRDT_MESSAGE_HEADER_LENGTH = 8;
1061
+
1062
+ export declare type CrdtMessage = PutComponentMessage | DeleteComponentMessage | DeleteEntityMessage;
1063
+
1064
+ export declare type CrdtMessageBody = PutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessage;
1065
+
1066
+ /**
1067
+ * Min length = 8 bytes
1068
+ * All message length including
1069
+ * @param length - Uint32 the length of all message (including the header)
1070
+ * @param type - define the function which handles the data
1071
+ */
1072
+ export declare type CrdtMessageHeader = {
1073
+ length: Uint32;
1074
+ type: Uint32;
1075
+ };
1076
+
1077
+ export declare namespace CrdtMessageProtocol {
1078
+ /**
1079
+ * Validate if the message incoming is completed
1080
+ * @param buf - ByteBuffer
1081
+ */
1082
+ export function validate(buf: ByteBuffer): boolean;
1083
+ /**
1084
+ * Get the current header, consuming the bytes involved.
1085
+ * @param buf - ByteBuffer
1086
+ * @returns header or null if there is no validated message
1087
+ */
1088
+ export function readHeader(buf: ByteBuffer): CrdtMessageHeader | null;
1089
+ /**
1090
+ * Get the current header, without consuming the bytes involved.
1091
+ * @param buf - ByteBuffer
1092
+ * @returns header or null if there is no validated message
1093
+ */
1094
+ export function getHeader(buf: ByteBuffer): CrdtMessageHeader | null;
1095
+ /**
1096
+ * Consume the incoming message without processing it.
1097
+ * @param buf - ByteBuffer
1098
+ * @returns true in case of success or false if there is no valid message.
1099
+ */
1100
+ export function consumeMessage(buf: ByteBuffer): boolean;
1101
+ }
1102
+
1103
+ export declare enum CrdtMessageType {
1104
+ RESERVED = 0,
1105
+ PUT_COMPONENT = 1,
1106
+ DELETE_COMPONENT = 2,
1107
+ DELETE_ENTITY = 3,
1108
+ MAX_MESSAGE_TYPE = 4
1109
+ }
1110
+
1060
1111
  export declare function createEthereumProvider(): {
1061
1112
  send(message: RPCSendableMessage, callback?: ((error: Error | null, result?: any) => void) | undefined): void;
1062
1113
  sendAsync(message: RPCSendableMessage, callback: (error: Error | null, result?: any) => void): void;
@@ -1162,6 +1213,40 @@ export declare function defineComponent<T>(componentId: number, spec: ISchema<T>
1162
1213
  */
1163
1214
  export declare const DEG2RAD: number;
1164
1215
 
1216
+ export declare namespace DeleteComponent {
1217
+ const MESSAGE_HEADER_LENGTH = 20;
1218
+ /**
1219
+ * Write DeleteComponent message
1220
+ */
1221
+ export function write(entity: Entity, componentId: number, timestamp: number, buf: ByteBuffer): void;
1222
+ export function read(buf: ByteBuffer): DeleteComponentMessage | null;
1223
+ }
1224
+
1225
+ export declare type DeleteComponentMessage = CrdtMessageHeader & DeleteComponentMessageBody;
1226
+
1227
+ export declare type DeleteComponentMessageBody = {
1228
+ type: CrdtMessageType.DELETE_COMPONENT;
1229
+ entityId: Entity;
1230
+ componentId: number;
1231
+ timestamp: number;
1232
+ };
1233
+
1234
+ export declare namespace DeleteEntity {
1235
+ const MESSAGE_HEADER_LENGTH = 4;
1236
+ export function write(entity: Entity, buf: ByteBuffer): void;
1237
+ export function read(buf: ByteBuffer): DeleteEntityMessage | null;
1238
+ }
1239
+
1240
+ export declare type DeleteEntityMessage = CrdtMessageHeader & DeleteEntityMessageBody;
1241
+
1242
+ /**
1243
+ * @param entity - Uint32 number of the entity
1244
+ */
1245
+ export declare type DeleteEntityMessageBody = {
1246
+ type: CrdtMessageType.DELETE_ENTITY;
1247
+ entityId: Entity;
1248
+ };
1249
+
1165
1250
  /**
1166
1251
  * @public
1167
1252
  */
@@ -1195,7 +1280,7 @@ export declare type EngineEvent<T extends IEventNames = IEventNames, V = IEvents
1195
1280
  * Convertion from its compound numbers to entity:
1196
1281
  * entity = (entityNumber & MAX_U16) | ((entityVersion & MAX_U16) << 16)
1197
1282
  */
1198
- export declare type Entity = uint32 & {
1283
+ export declare type Entity = number & {
1199
1284
  __entity_type: '';
1200
1285
  };
1201
1286
 
@@ -1209,14 +1294,16 @@ export declare type EntityComponents = {
1209
1294
  onMouseUp: Callback;
1210
1295
  };
1211
1296
 
1212
- export declare function EntityContainer(): {
1297
+ export declare function EntityContainer(): EntityContainer;
1298
+
1299
+ export declare type EntityContainer = {
1213
1300
  generateEntity(): Entity;
1214
1301
  removeEntity(entity: Entity): boolean;
1215
- entityExists(entity: Entity): boolean;
1302
+ getEntityState(entity: Entity): EntityState;
1216
1303
  getExistingEntities(): Set<Entity>;
1217
- entityVersion: (entity: Entity) => number;
1218
- entityNumber: (entity: Entity) => number;
1219
- entityId: (entityNumber: number, entityVersion: number) => Entity;
1304
+ releaseRemovedEntities(): Entity[];
1305
+ updateRemovedEntity(entity: Entity): boolean;
1306
+ updateUsedEntity(entity: Entity): boolean;
1220
1307
  };
1221
1308
 
1222
1309
  /**
@@ -1227,6 +1314,36 @@ export declare type EntityPropTypes = {
1227
1314
  uiBackground?: UiBackgroundProps;
1228
1315
  } & Listeners & Pick<CommonProps, 'key'>;
1229
1316
 
1317
+ /**
1318
+ * @public
1319
+ */
1320
+ export declare enum EntityState {
1321
+ Unknown = 0,
1322
+ /**
1323
+ * The entity was generated and added to the usedEntities set
1324
+ */
1325
+ UsedEntity = 1,
1326
+ /**
1327
+ * The entity was removed from current engine or remotely
1328
+ */
1329
+ Removed = 2,
1330
+ /**
1331
+ * The entity is reserved number.
1332
+ */
1333
+ Reserved = 3
1334
+ }
1335
+
1336
+ export declare namespace EntityUtils {
1337
+ /**
1338
+ * @returns [entityNumber, entityVersion]
1339
+ */
1340
+ export function fromEntityId(entityId: Entity): [number, number];
1341
+ /**
1342
+ * @returns compound number from entityNumber and entityVerison
1343
+ */
1344
+ export function toEntityId(entityNumber: number, entityVersion: number): Entity;
1345
+ }
1346
+
1230
1347
  /**
1231
1348
  * Constant used to define the minimal number value in Babylon.js
1232
1349
  * @public
@@ -1310,11 +1427,11 @@ export declare type IEngine = {
1310
1427
  */
1311
1428
  removeEntityWithChildren(firstEntity: Entity): void;
1312
1429
  /**
1313
- * Check if an entity exists in the engine
1430
+ * Check the state of an entityin the engine
1314
1431
  * @param entity - the entity to validate
1315
- * @returns true if the entity exists in the engine
1432
+ * @returns known enum value
1316
1433
  */
1317
- entityExists(entity: Entity): boolean;
1434
+ getEntityState(entity: Entity): EntityState;
1318
1435
  /**
1319
1436
  * Add the system to the engine. It will be called every tick updated.
1320
1437
  * @param system - function that receives the delta time between last tick and current one.
@@ -1430,6 +1547,10 @@ export declare type IEngine = {
1430
1547
  * @param transport - transport which changes its onmessage to process CRDT messages
1431
1548
  */
1432
1549
  addTransport(transport: Transport): void;
1550
+ /**
1551
+ * Entity continaer
1552
+ */
1553
+ entityContainer: EntityContainer;
1433
1554
  /**
1434
1555
  * Iterator of registered components
1435
1556
  */
@@ -2663,7 +2784,7 @@ export declare class ObserverEventState {
2663
2784
  /**
2664
2785
  * @public
2665
2786
  */
2666
- export declare type OnChangeFunction = (entity: Entity, component: ComponentDefinition<any>, operation: WireMessage.Enum) => void;
2787
+ export declare type OnChangeFunction = (entity: Entity, operation: CrdtMessageType, component?: ComponentDefinition<any>) => void;
2667
2788
 
2668
2789
  export declare const onCommsMessage: Observable<{
2669
2790
  sender: string;
@@ -3770,6 +3891,34 @@ export declare type Position = {
3770
3891
 
3771
3892
  export declare type PositionUnit = `${number}px` | `${number}%` | number;
3772
3893
 
3894
+ export declare type PutComponentMessage = CrdtMessageHeader & PutComponentMessageBody;
3895
+
3896
+ /**
3897
+ * Min. length = header (8 bytes) + 20 bytes = 28 bytes
3898
+ *
3899
+ * @param entity - Uint32 number of the entity
3900
+ * @param componentId - Uint32 number of id
3901
+ * @param timestamp - Uint64 Lamport timestamp
3902
+ * @param data - Uint8[] data of component => length(4 bytes) + block of bytes[0..length-1]
3903
+ */
3904
+ export declare type PutComponentMessageBody = {
3905
+ type: CrdtMessageType.PUT_COMPONENT;
3906
+ entityId: Entity;
3907
+ componentId: number;
3908
+ timestamp: number;
3909
+ data: Uint8Array;
3910
+ };
3911
+
3912
+ export declare namespace PutComponentOperation {
3913
+ const MESSAGE_HEADER_LENGTH = 20;
3914
+ /**
3915
+ * Call this function for an optimal writing data passing the ByteBuffer
3916
+ * already allocated
3917
+ */
3918
+ export function write(entity: Entity, timestamp: number, componentDefinition: ComponentDefinition<unknown>, buf: ByteBuffer): void;
3919
+ export function read(buf: ByteBuffer): PutComponentMessage | null;
3920
+ }
3921
+
3773
3922
  /**
3774
3923
  * @public
3775
3924
  * Quaternion is a type and a namespace.
@@ -4098,13 +4247,8 @@ export declare type ReadonlyComponentSchema<T extends [ComponentDefinition<unkno
4098
4247
  */
4099
4248
  export declare type ReadonlyPrimitive = number | string | number[] | string[] | boolean | boolean[];
4100
4249
 
4101
- export declare type ReceiveMessage = {
4102
- type: WireMessage.Enum;
4103
- entity: Entity;
4104
- componentId: number;
4105
- timestamp: number;
4250
+ export declare type ReceiveMessage = CrdtMessageBody & {
4106
4251
  transportId?: number;
4107
- data?: Uint8Array;
4108
4252
  messageBuffer: Uint8Array;
4109
4253
  };
4110
4254
 
@@ -4553,6 +4697,8 @@ export declare type UiInputProps = PBUiInput & {
4553
4697
  /** @public */
4554
4698
  export declare const UiInputResult: ComponentDefinition<PBUiInputResult>;
4555
4699
 
4700
+ export declare type Uint32 = number;
4701
+
4556
4702
  /**
4557
4703
  * @public It only defines the type explicitly, no effects.
4558
4704
  */
@@ -5220,32 +5366,6 @@ export declare type Vector3Type = {
5220
5366
  /** @public */
5221
5367
  export declare const VisibilityComponent: ComponentDefinition<PBVisibilityComponent>;
5222
5368
 
5223
- export declare namespace WireMessage {
5224
- export type Uint32 = number;
5225
- export enum Enum {
5226
- RESERVED = 0,
5227
- PUT_COMPONENT = 1,
5228
- DELETE_COMPONENT = 2,
5229
- MAX_MESSAGE_TYPE = 3
5230
- }
5231
- /**
5232
- * @param length - Uint32 the length of all message (including the header)
5233
- * @param type - define the function which handles the data
5234
- */
5235
- export type Header = {
5236
- length: Uint32;
5237
- type: Uint32;
5238
- };
5239
- const HEADER_LENGTH = 8;
5240
- /**
5241
- * Validate if the message incoming is completed
5242
- * @param buf - ByteBuffer
5243
- */
5244
- export function validate(buf: ByteBuffer): boolean;
5245
- export function readHeader(buf: ByteBuffer): Header | null;
5246
- export function getType(component: ComponentDefinition<unknown>, entity: Entity): Enum;
5247
- }
5248
-
5249
5369
  export declare const enum YGAlign {
5250
5370
  YGA_AUTO = 0,
5251
5371
  YGA_FLEX_START = 1,