@dcl/playground-assets 7.21.0 → 7.21.1-22918726402.commit-ee210ee

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
@@ -163,6 +163,42 @@ export declare interface AudioStreamComponentDefinitionExtended extends LastWrit
163
163
  getAudioState(entity: Entity): PBAudioEvent | undefined;
164
164
  }
165
165
 
166
+ /**
167
+ * @public
168
+ */
169
+ export declare type AuthoritativePutComponentMessage = CrdtMessageHeader & AuthoritativePutComponentMessageBody;
170
+
171
+ /**
172
+ * Server authoritative message - identical to PutComponentMessageBody but with forced processing
173
+ * Min. length = header (8 bytes) + 16 bytes = 24 bytes
174
+ *
175
+ * @param entity - Uint32 number of the entity
176
+ * @param componentId - Uint32 number of id
177
+ * @param timestamp - Uint32 Lamport timestamp (server's authoritative timestamp)
178
+ * @param data - Uint8[] data of component => length(4 bytes) + block of bytes[0..length-1]
179
+ * @public
180
+ */
181
+ export declare type AuthoritativePutComponentMessageBody = {
182
+ type: CrdtMessageType.AUTHORITATIVE_PUT_COMPONENT;
183
+ entityId: Entity;
184
+ componentId: number;
185
+ timestamp: number;
186
+ data: Uint8Array;
187
+ };
188
+
189
+ /**
190
+ * @public
191
+ */
192
+ export declare namespace AuthoritativePutComponentOperation {
193
+ const MESSAGE_HEADER_LENGTH = 16;
194
+ /**
195
+ * Call this function for an optimal writing data passing the ByteBuffer
196
+ * already allocated
197
+ */
198
+ export function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
199
+ export function read(buf: ByteBuffer): AuthoritativePutComponentMessage | null;
200
+ }
201
+
166
202
  /** AvatarAnchorPointType determines the part of the avatar's body that anchors the Entity. */
167
203
  /**
168
204
  * @public
@@ -322,6 +358,22 @@ export declare interface BaseComponent<T> {
322
358
  * If the value is undefined, the component was deleted.
323
359
  */
324
360
  onChange(entity: Entity, cb: (value: T | undefined) => void): void;
361
+ /**
362
+ * @public
363
+ *
364
+ */
365
+ validateBeforeChange(entity: Entity, cb: ValidateCallback<T>): void;
366
+ validateBeforeChange(cb: ValidateCallback<T>): void;
367
+ /**
368
+ * Get the CRDT state for an entity (serialized data and timestamp)
369
+ * @param entity - Entity to get the CRDT state for
370
+ * @returns Object with serialized data and timestamp, or null if entity doesn't have the component
371
+ * @public
372
+ */
373
+ getCrdtState(entity: Entity): {
374
+ data: Uint8Array;
375
+ timestamp: number;
376
+ } | null;
325
377
  }
326
378
 
327
379
  /** @public */
@@ -1532,12 +1584,12 @@ export declare const CRDT_MESSAGE_HEADER_LENGTH = 8;
1532
1584
  /**
1533
1585
  * @public
1534
1586
  */
1535
- export declare type CrdtMessage = PutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1587
+ export declare type CrdtMessage = PutComponentMessage | AuthoritativePutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1536
1588
 
1537
1589
  /**
1538
1590
  * @public
1539
1591
  */
1540
- export declare type CrdtMessageBody = PutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1592
+ export declare type CrdtMessageBody = PutComponentMessageBody | AuthoritativePutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1541
1593
 
1542
1594
  /**
1543
1595
  * Min length = 8 bytes
@@ -1592,7 +1644,8 @@ export declare enum CrdtMessageType {
1592
1644
  PUT_COMPONENT_NETWORK = 5,
1593
1645
  DELETE_COMPONENT_NETWORK = 6,
1594
1646
  DELETE_ENTITY_NETWORK = 7,
1595
- MAX_MESSAGE_TYPE = 8
1647
+ AUTHORITATIVE_PUT_COMPONENT = 8,
1648
+ MAX_MESSAGE_TYPE = 9
1596
1649
  }
1597
1650
 
1598
1651
  /**
@@ -1600,6 +1653,8 @@ export declare enum CrdtMessageType {
1600
1653
  */
1601
1654
  export declare type CrdtNetworkMessageBody = PutNetworkComponentMessageBody | DeleteComponentNetworkMessageBody | DeleteEntityNetworkMessageBody;
1602
1655
 
1656
+ export declare const CreatedBy: ICreatedBy;
1657
+
1603
1658
  /**
1604
1659
  * @public
1605
1660
  */
@@ -2301,6 +2356,12 @@ export declare interface GrowOnlyValueSetComponentDefinition<T> extends BaseComp
2301
2356
 
2302
2357
  export declare type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<any>> = (engine: Pick<IEngine, 'defineValueSetComponentFromSchema'>) => T;
2303
2358
 
2359
+ export declare type ICreatedBy = LastWriteWinElementSetComponentDefinition<ICreatedByType>;
2360
+
2361
+ export declare interface ICreatedByType {
2362
+ address: string;
2363
+ }
2364
+
2304
2365
  /**
2305
2366
  * @public
2306
2367
  */
@@ -2744,6 +2805,35 @@ export declare type InstanceCompositeOptions = {
2744
2805
  alreadyRequestedSrc?: Set<string>;
2745
2806
  };
2746
2807
 
2808
+ /**
2809
+ * Internal component interface that exposes all internal methods for SDK use
2810
+ * This is not exposed to users, only for internal SDK operations
2811
+ */
2812
+ export declare interface InternalBaseComponent<T> extends BaseComponent<T> {
2813
+ /**
2814
+ * @public
2815
+ * Dry run update to check if a CRDT message would be accepted without actually applying it
2816
+ */
2817
+ __dry_run_updateFromCrdt(body: CrdtMessageBody): ProcessMessageResultType;
2818
+ /**
2819
+ * @public
2820
+ * Get the iterator to every entity has the component
2821
+ */
2822
+ iterator(): Iterable<[Entity, any]>;
2823
+ /**
2824
+ * @public
2825
+ */
2826
+ dirtyIterator(): Iterable<Entity>;
2827
+ /**
2828
+ * @public
2829
+ */
2830
+ __onChangeCallbacks(entity: Entity, value: T): void;
2831
+ /**
2832
+ * @public
2833
+ */
2834
+ __run_validateBeforeChange(entity: Entity, newValue: T | undefined, senderAddress: string, createdBy: string): boolean;
2835
+ }
2836
+
2747
2837
  /**
2748
2838
  * @public
2749
2839
  */
@@ -8854,6 +8944,14 @@ export declare interface UiTransformProps {
8854
8944
  */
8855
8945
  export declare type Unpacked<T> = T extends (infer U)[] ? U : T;
8856
8946
 
8947
+ export declare type ValidateCallback<T> = (value: {
8948
+ entity: Entity;
8949
+ currentValue: T | undefined;
8950
+ newValue: T | undefined;
8951
+ senderAddress: string;
8952
+ createdBy: string;
8953
+ }) => boolean;
8954
+
8857
8955
  /**
8858
8956
  * @public
8859
8957
  */
package/dist/beta.d.ts CHANGED
@@ -163,6 +163,42 @@ export declare interface AudioStreamComponentDefinitionExtended extends LastWrit
163
163
  getAudioState(entity: Entity): PBAudioEvent | undefined;
164
164
  }
165
165
 
166
+ /**
167
+ * @public
168
+ */
169
+ export declare type AuthoritativePutComponentMessage = CrdtMessageHeader & AuthoritativePutComponentMessageBody;
170
+
171
+ /**
172
+ * Server authoritative message - identical to PutComponentMessageBody but with forced processing
173
+ * Min. length = header (8 bytes) + 16 bytes = 24 bytes
174
+ *
175
+ * @param entity - Uint32 number of the entity
176
+ * @param componentId - Uint32 number of id
177
+ * @param timestamp - Uint32 Lamport timestamp (server's authoritative timestamp)
178
+ * @param data - Uint8[] data of component => length(4 bytes) + block of bytes[0..length-1]
179
+ * @public
180
+ */
181
+ export declare type AuthoritativePutComponentMessageBody = {
182
+ type: CrdtMessageType.AUTHORITATIVE_PUT_COMPONENT;
183
+ entityId: Entity;
184
+ componentId: number;
185
+ timestamp: number;
186
+ data: Uint8Array;
187
+ };
188
+
189
+ /**
190
+ * @public
191
+ */
192
+ export declare namespace AuthoritativePutComponentOperation {
193
+ const MESSAGE_HEADER_LENGTH = 16;
194
+ /**
195
+ * Call this function for an optimal writing data passing the ByteBuffer
196
+ * already allocated
197
+ */
198
+ export function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
199
+ export function read(buf: ByteBuffer): AuthoritativePutComponentMessage | null;
200
+ }
201
+
166
202
  /** AvatarAnchorPointType determines the part of the avatar's body that anchors the Entity. */
167
203
  /**
168
204
  * @public
@@ -322,6 +358,22 @@ export declare interface BaseComponent<T> {
322
358
  * If the value is undefined, the component was deleted.
323
359
  */
324
360
  onChange(entity: Entity, cb: (value: T | undefined) => void): void;
361
+ /**
362
+ * @public
363
+ *
364
+ */
365
+ validateBeforeChange(entity: Entity, cb: ValidateCallback<T>): void;
366
+ validateBeforeChange(cb: ValidateCallback<T>): void;
367
+ /**
368
+ * Get the CRDT state for an entity (serialized data and timestamp)
369
+ * @param entity - Entity to get the CRDT state for
370
+ * @returns Object with serialized data and timestamp, or null if entity doesn't have the component
371
+ * @public
372
+ */
373
+ getCrdtState(entity: Entity): {
374
+ data: Uint8Array;
375
+ timestamp: number;
376
+ } | null;
325
377
  }
326
378
 
327
379
  /** @public */
@@ -1532,12 +1584,12 @@ export declare const CRDT_MESSAGE_HEADER_LENGTH = 8;
1532
1584
  /**
1533
1585
  * @public
1534
1586
  */
1535
- export declare type CrdtMessage = PutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1587
+ export declare type CrdtMessage = PutComponentMessage | AuthoritativePutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1536
1588
 
1537
1589
  /**
1538
1590
  * @public
1539
1591
  */
1540
- export declare type CrdtMessageBody = PutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1592
+ export declare type CrdtMessageBody = PutComponentMessageBody | AuthoritativePutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1541
1593
 
1542
1594
  /**
1543
1595
  * Min length = 8 bytes
@@ -1592,7 +1644,8 @@ export declare enum CrdtMessageType {
1592
1644
  PUT_COMPONENT_NETWORK = 5,
1593
1645
  DELETE_COMPONENT_NETWORK = 6,
1594
1646
  DELETE_ENTITY_NETWORK = 7,
1595
- MAX_MESSAGE_TYPE = 8
1647
+ AUTHORITATIVE_PUT_COMPONENT = 8,
1648
+ MAX_MESSAGE_TYPE = 9
1596
1649
  }
1597
1650
 
1598
1651
  /**
@@ -1600,6 +1653,8 @@ export declare enum CrdtMessageType {
1600
1653
  */
1601
1654
  export declare type CrdtNetworkMessageBody = PutNetworkComponentMessageBody | DeleteComponentNetworkMessageBody | DeleteEntityNetworkMessageBody;
1602
1655
 
1656
+ export declare const CreatedBy: ICreatedBy;
1657
+
1603
1658
  /**
1604
1659
  * @public
1605
1660
  */
@@ -2301,6 +2356,12 @@ export declare interface GrowOnlyValueSetComponentDefinition<T> extends BaseComp
2301
2356
 
2302
2357
  export declare type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<any>> = (engine: Pick<IEngine, 'defineValueSetComponentFromSchema'>) => T;
2303
2358
 
2359
+ export declare type ICreatedBy = LastWriteWinElementSetComponentDefinition<ICreatedByType>;
2360
+
2361
+ export declare interface ICreatedByType {
2362
+ address: string;
2363
+ }
2364
+
2304
2365
  /**
2305
2366
  * @public
2306
2367
  */
@@ -2735,6 +2796,35 @@ export declare type InstanceCompositeOptions = {
2735
2796
  alreadyRequestedSrc?: Set<string>;
2736
2797
  };
2737
2798
 
2799
+ /**
2800
+ * Internal component interface that exposes all internal methods for SDK use
2801
+ * This is not exposed to users, only for internal SDK operations
2802
+ */
2803
+ export declare interface InternalBaseComponent<T> extends BaseComponent<T> {
2804
+ /**
2805
+ * @public
2806
+ * Dry run update to check if a CRDT message would be accepted without actually applying it
2807
+ */
2808
+ __dry_run_updateFromCrdt(body: CrdtMessageBody): ProcessMessageResultType;
2809
+ /**
2810
+ * @public
2811
+ * Get the iterator to every entity has the component
2812
+ */
2813
+ iterator(): Iterable<[Entity, any]>;
2814
+ /**
2815
+ * @public
2816
+ */
2817
+ dirtyIterator(): Iterable<Entity>;
2818
+ /**
2819
+ * @public
2820
+ */
2821
+ __onChangeCallbacks(entity: Entity, value: T): void;
2822
+ /**
2823
+ * @public
2824
+ */
2825
+ __run_validateBeforeChange(entity: Entity, newValue: T | undefined, senderAddress: string, createdBy: string): boolean;
2826
+ }
2827
+
2738
2828
  /**
2739
2829
  * @public
2740
2830
  */
@@ -8821,6 +8911,14 @@ export declare interface UiTransformProps {
8821
8911
  */
8822
8912
  export declare type Unpacked<T> = T extends (infer U)[] ? U : T;
8823
8913
 
8914
+ export declare type ValidateCallback<T> = (value: {
8915
+ entity: Entity;
8916
+ currentValue: T | undefined;
8917
+ newValue: T | undefined;
8918
+ senderAddress: string;
8919
+ createdBy: string;
8920
+ }) => boolean;
8921
+
8824
8922
  /**
8825
8923
  * @public
8826
8924
  */
@@ -163,6 +163,42 @@ export declare interface AudioStreamComponentDefinitionExtended extends LastWrit
163
163
  getAudioState(entity: Entity): PBAudioEvent | undefined;
164
164
  }
165
165
 
166
+ /**
167
+ * @public
168
+ */
169
+ export declare type AuthoritativePutComponentMessage = CrdtMessageHeader & AuthoritativePutComponentMessageBody;
170
+
171
+ /**
172
+ * Server authoritative message - identical to PutComponentMessageBody but with forced processing
173
+ * Min. length = header (8 bytes) + 16 bytes = 24 bytes
174
+ *
175
+ * @param entity - Uint32 number of the entity
176
+ * @param componentId - Uint32 number of id
177
+ * @param timestamp - Uint32 Lamport timestamp (server's authoritative timestamp)
178
+ * @param data - Uint8[] data of component => length(4 bytes) + block of bytes[0..length-1]
179
+ * @public
180
+ */
181
+ export declare type AuthoritativePutComponentMessageBody = {
182
+ type: CrdtMessageType.AUTHORITATIVE_PUT_COMPONENT;
183
+ entityId: Entity;
184
+ componentId: number;
185
+ timestamp: number;
186
+ data: Uint8Array;
187
+ };
188
+
189
+ /**
190
+ * @public
191
+ */
192
+ export declare namespace AuthoritativePutComponentOperation {
193
+ const MESSAGE_HEADER_LENGTH = 16;
194
+ /**
195
+ * Call this function for an optimal writing data passing the ByteBuffer
196
+ * already allocated
197
+ */
198
+ export function write(entity: Entity, timestamp: number, componentId: number, data: Uint8Array, buf: ByteBuffer): void;
199
+ export function read(buf: ByteBuffer): AuthoritativePutComponentMessage | null;
200
+ }
201
+
166
202
  /** AvatarAnchorPointType determines the part of the avatar's body that anchors the Entity. */
167
203
  /**
168
204
  * @public
@@ -322,6 +358,22 @@ export declare interface BaseComponent<T> {
322
358
  * If the value is undefined, the component was deleted.
323
359
  */
324
360
  onChange(entity: Entity, cb: (value: T | undefined) => void): void;
361
+ /**
362
+ * @public
363
+ *
364
+ */
365
+ validateBeforeChange(entity: Entity, cb: ValidateCallback<T>): void;
366
+ validateBeforeChange(cb: ValidateCallback<T>): void;
367
+ /**
368
+ * Get the CRDT state for an entity (serialized data and timestamp)
369
+ * @param entity - Entity to get the CRDT state for
370
+ * @returns Object with serialized data and timestamp, or null if entity doesn't have the component
371
+ * @public
372
+ */
373
+ getCrdtState(entity: Entity): {
374
+ data: Uint8Array;
375
+ timestamp: number;
376
+ } | null;
325
377
  }
326
378
 
327
379
  /** @public */
@@ -1532,12 +1584,12 @@ export declare const CRDT_MESSAGE_HEADER_LENGTH = 8;
1532
1584
  /**
1533
1585
  * @public
1534
1586
  */
1535
- export declare type CrdtMessage = PutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1587
+ export declare type CrdtMessage = PutComponentMessage | AuthoritativePutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1536
1588
 
1537
1589
  /**
1538
1590
  * @public
1539
1591
  */
1540
- export declare type CrdtMessageBody = PutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1592
+ export declare type CrdtMessageBody = PutComponentMessageBody | AuthoritativePutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1541
1593
 
1542
1594
  /**
1543
1595
  * Min length = 8 bytes
@@ -1592,7 +1644,8 @@ export declare enum CrdtMessageType {
1592
1644
  PUT_COMPONENT_NETWORK = 5,
1593
1645
  DELETE_COMPONENT_NETWORK = 6,
1594
1646
  DELETE_ENTITY_NETWORK = 7,
1595
- MAX_MESSAGE_TYPE = 8
1647
+ AUTHORITATIVE_PUT_COMPONENT = 8,
1648
+ MAX_MESSAGE_TYPE = 9
1596
1649
  }
1597
1650
 
1598
1651
  /**
@@ -1600,6 +1653,8 @@ export declare enum CrdtMessageType {
1600
1653
  */
1601
1654
  export declare type CrdtNetworkMessageBody = PutNetworkComponentMessageBody | DeleteComponentNetworkMessageBody | DeleteEntityNetworkMessageBody;
1602
1655
 
1656
+ export declare const CreatedBy: ICreatedBy;
1657
+
1603
1658
  /**
1604
1659
  * @public
1605
1660
  */
@@ -2301,6 +2356,12 @@ export declare interface GrowOnlyValueSetComponentDefinition<T> extends BaseComp
2301
2356
 
2302
2357
  export declare type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<any>> = (engine: Pick<IEngine, 'defineValueSetComponentFromSchema'>) => T;
2303
2358
 
2359
+ export declare type ICreatedBy = LastWriteWinElementSetComponentDefinition<ICreatedByType>;
2360
+
2361
+ export declare interface ICreatedByType {
2362
+ address: string;
2363
+ }
2364
+
2304
2365
  /**
2305
2366
  * @public
2306
2367
  */
@@ -2735,6 +2796,35 @@ export declare type InstanceCompositeOptions = {
2735
2796
  alreadyRequestedSrc?: Set<string>;
2736
2797
  };
2737
2798
 
2799
+ /**
2800
+ * Internal component interface that exposes all internal methods for SDK use
2801
+ * This is not exposed to users, only for internal SDK operations
2802
+ */
2803
+ export declare interface InternalBaseComponent<T> extends BaseComponent<T> {
2804
+ /**
2805
+ * @public
2806
+ * Dry run update to check if a CRDT message would be accepted without actually applying it
2807
+ */
2808
+ __dry_run_updateFromCrdt(body: CrdtMessageBody): ProcessMessageResultType;
2809
+ /**
2810
+ * @public
2811
+ * Get the iterator to every entity has the component
2812
+ */
2813
+ iterator(): Iterable<[Entity, any]>;
2814
+ /**
2815
+ * @public
2816
+ */
2817
+ dirtyIterator(): Iterable<Entity>;
2818
+ /**
2819
+ * @public
2820
+ */
2821
+ __onChangeCallbacks(entity: Entity, value: T): void;
2822
+ /**
2823
+ * @public
2824
+ */
2825
+ __run_validateBeforeChange(entity: Entity, newValue: T | undefined, senderAddress: string, createdBy: string): boolean;
2826
+ }
2827
+
2738
2828
  /**
2739
2829
  * @public
2740
2830
  */
@@ -8821,6 +8911,14 @@ export declare interface UiTransformProps {
8821
8911
  */
8822
8912
  export declare type Unpacked<T> = T extends (infer U)[] ? U : T;
8823
8913
 
8914
+ export declare type ValidateCallback<T> = (value: {
8915
+ entity: Entity;
8916
+ currentValue: T | undefined;
8917
+ newValue: T | undefined;
8918
+ senderAddress: string;
8919
+ createdBy: string;
8920
+ }) => boolean;
8921
+
8824
8922
  /**
8825
8923
  * @public
8826
8924
  */