@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.
@@ -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;
@@ -1150,6 +1201,40 @@ export declare function defineComponent<T>(componentId: number, spec: ISchema<T>
1150
1201
  */
1151
1202
  export declare const DEG2RAD: number;
1152
1203
 
1204
+ export declare namespace DeleteComponent {
1205
+ const MESSAGE_HEADER_LENGTH = 20;
1206
+ /**
1207
+ * Write DeleteComponent message
1208
+ */
1209
+ export function write(entity: Entity, componentId: number, timestamp: number, buf: ByteBuffer): void;
1210
+ export function read(buf: ByteBuffer): DeleteComponentMessage | null;
1211
+ }
1212
+
1213
+ export declare type DeleteComponentMessage = CrdtMessageHeader & DeleteComponentMessageBody;
1214
+
1215
+ export declare type DeleteComponentMessageBody = {
1216
+ type: CrdtMessageType.DELETE_COMPONENT;
1217
+ entityId: Entity;
1218
+ componentId: number;
1219
+ timestamp: number;
1220
+ };
1221
+
1222
+ export declare namespace DeleteEntity {
1223
+ const MESSAGE_HEADER_LENGTH = 4;
1224
+ export function write(entity: Entity, buf: ByteBuffer): void;
1225
+ export function read(buf: ByteBuffer): DeleteEntityMessage | null;
1226
+ }
1227
+
1228
+ export declare type DeleteEntityMessage = CrdtMessageHeader & DeleteEntityMessageBody;
1229
+
1230
+ /**
1231
+ * @param entity - Uint32 number of the entity
1232
+ */
1233
+ export declare type DeleteEntityMessageBody = {
1234
+ type: CrdtMessageType.DELETE_ENTITY;
1235
+ entityId: Entity;
1236
+ };
1237
+
1153
1238
  /**
1154
1239
  * @public
1155
1240
  */
@@ -1183,7 +1268,7 @@ export declare type EngineEvent<T extends IEventNames = IEventNames, V = IEvents
1183
1268
  * Convertion from its compound numbers to entity:
1184
1269
  * entity = (entityNumber & MAX_U16) | ((entityVersion & MAX_U16) << 16)
1185
1270
  */
1186
- export declare type Entity = uint32 & {
1271
+ export declare type Entity = number & {
1187
1272
  __entity_type: '';
1188
1273
  };
1189
1274
 
@@ -1197,14 +1282,16 @@ export declare type EntityComponents = {
1197
1282
  onMouseUp: Callback;
1198
1283
  };
1199
1284
 
1200
- export declare function EntityContainer(): {
1285
+ export declare function EntityContainer(): EntityContainer;
1286
+
1287
+ export declare type EntityContainer = {
1201
1288
  generateEntity(): Entity;
1202
1289
  removeEntity(entity: Entity): boolean;
1203
- entityExists(entity: Entity): boolean;
1290
+ getEntityState(entity: Entity): EntityState;
1204
1291
  getExistingEntities(): Set<Entity>;
1205
- entityVersion: (entity: Entity) => number;
1206
- entityNumber: (entity: Entity) => number;
1207
- entityId: (entityNumber: number, entityVersion: number) => Entity;
1292
+ releaseRemovedEntities(): Entity[];
1293
+ updateRemovedEntity(entity: Entity): boolean;
1294
+ updateUsedEntity(entity: Entity): boolean;
1208
1295
  };
1209
1296
 
1210
1297
  /**
@@ -1215,6 +1302,36 @@ export declare type EntityPropTypes = {
1215
1302
  uiBackground?: UiBackgroundProps;
1216
1303
  } & Listeners & Pick<CommonProps, 'key'>;
1217
1304
 
1305
+ /**
1306
+ * @public
1307
+ */
1308
+ export declare enum EntityState {
1309
+ Unknown = 0,
1310
+ /**
1311
+ * The entity was generated and added to the usedEntities set
1312
+ */
1313
+ UsedEntity = 1,
1314
+ /**
1315
+ * The entity was removed from current engine or remotely
1316
+ */
1317
+ Removed = 2,
1318
+ /**
1319
+ * The entity is reserved number.
1320
+ */
1321
+ Reserved = 3
1322
+ }
1323
+
1324
+ export declare namespace EntityUtils {
1325
+ /**
1326
+ * @returns [entityNumber, entityVersion]
1327
+ */
1328
+ export function fromEntityId(entityId: Entity): [number, number];
1329
+ /**
1330
+ * @returns compound number from entityNumber and entityVerison
1331
+ */
1332
+ export function toEntityId(entityNumber: number, entityVersion: number): Entity;
1333
+ }
1334
+
1218
1335
  /**
1219
1336
  * Constant used to define the minimal number value in Babylon.js
1220
1337
  * @public
@@ -1298,11 +1415,11 @@ export declare type IEngine = {
1298
1415
  */
1299
1416
  removeEntityWithChildren(firstEntity: Entity): void;
1300
1417
  /**
1301
- * Check if an entity exists in the engine
1418
+ * Check the state of an entityin the engine
1302
1419
  * @param entity - the entity to validate
1303
- * @returns true if the entity exists in the engine
1420
+ * @returns known enum value
1304
1421
  */
1305
- entityExists(entity: Entity): boolean;
1422
+ getEntityState(entity: Entity): EntityState;
1306
1423
  /**
1307
1424
  * Add the system to the engine. It will be called every tick updated.
1308
1425
  * @param system - function that receives the delta time between last tick and current one.
@@ -1418,6 +1535,10 @@ export declare type IEngine = {
1418
1535
  * @param transport - transport which changes its onmessage to process CRDT messages
1419
1536
  */
1420
1537
  addTransport(transport: Transport): void;
1538
+ /**
1539
+ * Entity continaer
1540
+ */
1541
+ entityContainer: EntityContainer;
1421
1542
  /**
1422
1543
  * Iterator of registered components
1423
1544
  */
@@ -2651,7 +2772,7 @@ export declare class ObserverEventState {
2651
2772
  /**
2652
2773
  * @public
2653
2774
  */
2654
- export declare type OnChangeFunction = (entity: Entity, component: ComponentDefinition<any>, operation: WireMessage.Enum) => void;
2775
+ export declare type OnChangeFunction = (entity: Entity, operation: CrdtMessageType, component?: ComponentDefinition<any>) => void;
2655
2776
 
2656
2777
  export declare const onCommsMessage: Observable<{
2657
2778
  sender: string;
@@ -3758,6 +3879,34 @@ export declare type Position = {
3758
3879
 
3759
3880
  export declare type PositionUnit = `${number}px` | `${number}%` | number;
3760
3881
 
3882
+ export declare type PutComponentMessage = CrdtMessageHeader & PutComponentMessageBody;
3883
+
3884
+ /**
3885
+ * Min. length = header (8 bytes) + 20 bytes = 28 bytes
3886
+ *
3887
+ * @param entity - Uint32 number of the entity
3888
+ * @param componentId - Uint32 number of id
3889
+ * @param timestamp - Uint64 Lamport timestamp
3890
+ * @param data - Uint8[] data of component => length(4 bytes) + block of bytes[0..length-1]
3891
+ */
3892
+ export declare type PutComponentMessageBody = {
3893
+ type: CrdtMessageType.PUT_COMPONENT;
3894
+ entityId: Entity;
3895
+ componentId: number;
3896
+ timestamp: number;
3897
+ data: Uint8Array;
3898
+ };
3899
+
3900
+ export declare namespace PutComponentOperation {
3901
+ const MESSAGE_HEADER_LENGTH = 20;
3902
+ /**
3903
+ * Call this function for an optimal writing data passing the ByteBuffer
3904
+ * already allocated
3905
+ */
3906
+ export function write(entity: Entity, timestamp: number, componentDefinition: ComponentDefinition<unknown>, buf: ByteBuffer): void;
3907
+ export function read(buf: ByteBuffer): PutComponentMessage | null;
3908
+ }
3909
+
3761
3910
  /**
3762
3911
  * @public
3763
3912
  * Quaternion is a type and a namespace.
@@ -4086,13 +4235,8 @@ export declare type ReadonlyComponentSchema<T extends [ComponentDefinition<unkno
4086
4235
  */
4087
4236
  export declare type ReadonlyPrimitive = number | string | number[] | string[] | boolean | boolean[];
4088
4237
 
4089
- export declare type ReceiveMessage = {
4090
- type: WireMessage.Enum;
4091
- entity: Entity;
4092
- componentId: number;
4093
- timestamp: number;
4238
+ export declare type ReceiveMessage = CrdtMessageBody & {
4094
4239
  transportId?: number;
4095
- data?: Uint8Array;
4096
4240
  messageBuffer: Uint8Array;
4097
4241
  };
4098
4242
 
@@ -4541,6 +4685,8 @@ export declare type UiInputProps = PBUiInput & {
4541
4685
  /** @public */
4542
4686
  export declare const UiInputResult: ComponentDefinition<PBUiInputResult>;
4543
4687
 
4688
+ export declare type Uint32 = number;
4689
+
4544
4690
  /**
4545
4691
  * @public It only defines the type explicitly, no effects.
4546
4692
  */
@@ -5208,32 +5354,6 @@ export declare type Vector3Type = {
5208
5354
  /** @public */
5209
5355
  export declare const VisibilityComponent: ComponentDefinition<PBVisibilityComponent>;
5210
5356
 
5211
- export declare namespace WireMessage {
5212
- export type Uint32 = number;
5213
- export enum Enum {
5214
- RESERVED = 0,
5215
- PUT_COMPONENT = 1,
5216
- DELETE_COMPONENT = 2,
5217
- MAX_MESSAGE_TYPE = 3
5218
- }
5219
- /**
5220
- * @param length - Uint32 the length of all message (including the header)
5221
- * @param type - define the function which handles the data
5222
- */
5223
- export type Header = {
5224
- length: Uint32;
5225
- type: Uint32;
5226
- };
5227
- const HEADER_LENGTH = 8;
5228
- /**
5229
- * Validate if the message incoming is completed
5230
- * @param buf - ByteBuffer
5231
- */
5232
- export function validate(buf: ByteBuffer): boolean;
5233
- export function readHeader(buf: ByteBuffer): Header | null;
5234
- export function getType(component: ComponentDefinition<unknown>, entity: Entity): Enum;
5235
- }
5236
-
5237
5357
  export declare const enum YGAlign {
5238
5358
  YGA_AUTO = 0,
5239
5359
  YGA_FLEX_START = 1,