@dcl/playground-assets 7.20.1 → 7.20.2-22102228700.commit-61000fc

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 */
@@ -1530,12 +1582,12 @@ export declare const CRDT_MESSAGE_HEADER_LENGTH = 8;
1530
1582
  /**
1531
1583
  * @public
1532
1584
  */
1533
- export declare type CrdtMessage = PutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1585
+ export declare type CrdtMessage = PutComponentMessage | AuthoritativePutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1534
1586
 
1535
1587
  /**
1536
1588
  * @public
1537
1589
  */
1538
- export declare type CrdtMessageBody = PutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1590
+ export declare type CrdtMessageBody = PutComponentMessageBody | AuthoritativePutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1539
1591
 
1540
1592
  /**
1541
1593
  * Min length = 8 bytes
@@ -1590,7 +1642,8 @@ export declare enum CrdtMessageType {
1590
1642
  PUT_COMPONENT_NETWORK = 5,
1591
1643
  DELETE_COMPONENT_NETWORK = 6,
1592
1644
  DELETE_ENTITY_NETWORK = 7,
1593
- MAX_MESSAGE_TYPE = 8
1645
+ AUTHORITATIVE_PUT_COMPONENT = 8,
1646
+ MAX_MESSAGE_TYPE = 9
1594
1647
  }
1595
1648
 
1596
1649
  /**
@@ -1598,6 +1651,8 @@ export declare enum CrdtMessageType {
1598
1651
  */
1599
1652
  export declare type CrdtNetworkMessageBody = PutNetworkComponentMessageBody | DeleteComponentNetworkMessageBody | DeleteEntityNetworkMessageBody;
1600
1653
 
1654
+ export declare const CreatedBy: ICreatedBy;
1655
+
1601
1656
  /**
1602
1657
  * @public
1603
1658
  */
@@ -2290,6 +2345,12 @@ export declare interface GrowOnlyValueSetComponentDefinition<T> extends BaseComp
2290
2345
 
2291
2346
  export declare type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<any>> = (engine: Pick<IEngine, 'defineValueSetComponentFromSchema'>) => T;
2292
2347
 
2348
+ export declare type ICreatedBy = LastWriteWinElementSetComponentDefinition<ICreatedByType>;
2349
+
2350
+ export declare interface ICreatedByType {
2351
+ address: string;
2352
+ }
2353
+
2293
2354
  /**
2294
2355
  * @public
2295
2356
  */
@@ -2733,6 +2794,35 @@ export declare type InstanceCompositeOptions = {
2733
2794
  alreadyRequestedSrc?: Set<string>;
2734
2795
  };
2735
2796
 
2797
+ /**
2798
+ * Internal component interface that exposes all internal methods for SDK use
2799
+ * This is not exposed to users, only for internal SDK operations
2800
+ */
2801
+ export declare interface InternalBaseComponent<T> extends BaseComponent<T> {
2802
+ /**
2803
+ * @public
2804
+ * Dry run update to check if a CRDT message would be accepted without actually applying it
2805
+ */
2806
+ __dry_run_updateFromCrdt(body: CrdtMessageBody): ProcessMessageResultType;
2807
+ /**
2808
+ * @public
2809
+ * Get the iterator to every entity has the component
2810
+ */
2811
+ iterator(): Iterable<[Entity, any]>;
2812
+ /**
2813
+ * @public
2814
+ */
2815
+ dirtyIterator(): Iterable<Entity>;
2816
+ /**
2817
+ * @public
2818
+ */
2819
+ __onChangeCallbacks(entity: Entity, value: T): void;
2820
+ /**
2821
+ * @public
2822
+ */
2823
+ __run_validateBeforeChange(entity: Entity, newValue: T | undefined, senderAddress: string, createdBy: string): boolean;
2824
+ }
2825
+
2736
2826
  /**
2737
2827
  * @public
2738
2828
  */
@@ -8704,6 +8794,14 @@ export declare interface UiTransformProps {
8704
8794
  */
8705
8795
  export declare type Unpacked<T> = T extends (infer U)[] ? U : T;
8706
8796
 
8797
+ export declare type ValidateCallback<T> = (value: {
8798
+ entity: Entity;
8799
+ currentValue: T | undefined;
8800
+ newValue: T | undefined;
8801
+ senderAddress: string;
8802
+ createdBy: string;
8803
+ }) => boolean;
8804
+
8707
8805
  /**
8708
8806
  * @public
8709
8807
  */
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 */
@@ -1530,12 +1582,12 @@ export declare const CRDT_MESSAGE_HEADER_LENGTH = 8;
1530
1582
  /**
1531
1583
  * @public
1532
1584
  */
1533
- export declare type CrdtMessage = PutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1585
+ export declare type CrdtMessage = PutComponentMessage | AuthoritativePutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1534
1586
 
1535
1587
  /**
1536
1588
  * @public
1537
1589
  */
1538
- export declare type CrdtMessageBody = PutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1590
+ export declare type CrdtMessageBody = PutComponentMessageBody | AuthoritativePutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1539
1591
 
1540
1592
  /**
1541
1593
  * Min length = 8 bytes
@@ -1590,7 +1642,8 @@ export declare enum CrdtMessageType {
1590
1642
  PUT_COMPONENT_NETWORK = 5,
1591
1643
  DELETE_COMPONENT_NETWORK = 6,
1592
1644
  DELETE_ENTITY_NETWORK = 7,
1593
- MAX_MESSAGE_TYPE = 8
1645
+ AUTHORITATIVE_PUT_COMPONENT = 8,
1646
+ MAX_MESSAGE_TYPE = 9
1594
1647
  }
1595
1648
 
1596
1649
  /**
@@ -1598,6 +1651,8 @@ export declare enum CrdtMessageType {
1598
1651
  */
1599
1652
  export declare type CrdtNetworkMessageBody = PutNetworkComponentMessageBody | DeleteComponentNetworkMessageBody | DeleteEntityNetworkMessageBody;
1600
1653
 
1654
+ export declare const CreatedBy: ICreatedBy;
1655
+
1601
1656
  /**
1602
1657
  * @public
1603
1658
  */
@@ -2290,6 +2345,12 @@ export declare interface GrowOnlyValueSetComponentDefinition<T> extends BaseComp
2290
2345
 
2291
2346
  export declare type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<any>> = (engine: Pick<IEngine, 'defineValueSetComponentFromSchema'>) => T;
2292
2347
 
2348
+ export declare type ICreatedBy = LastWriteWinElementSetComponentDefinition<ICreatedByType>;
2349
+
2350
+ export declare interface ICreatedByType {
2351
+ address: string;
2352
+ }
2353
+
2293
2354
  /**
2294
2355
  * @public
2295
2356
  */
@@ -2724,6 +2785,35 @@ export declare type InstanceCompositeOptions = {
2724
2785
  alreadyRequestedSrc?: Set<string>;
2725
2786
  };
2726
2787
 
2788
+ /**
2789
+ * Internal component interface that exposes all internal methods for SDK use
2790
+ * This is not exposed to users, only for internal SDK operations
2791
+ */
2792
+ export declare interface InternalBaseComponent<T> extends BaseComponent<T> {
2793
+ /**
2794
+ * @public
2795
+ * Dry run update to check if a CRDT message would be accepted without actually applying it
2796
+ */
2797
+ __dry_run_updateFromCrdt(body: CrdtMessageBody): ProcessMessageResultType;
2798
+ /**
2799
+ * @public
2800
+ * Get the iterator to every entity has the component
2801
+ */
2802
+ iterator(): Iterable<[Entity, any]>;
2803
+ /**
2804
+ * @public
2805
+ */
2806
+ dirtyIterator(): Iterable<Entity>;
2807
+ /**
2808
+ * @public
2809
+ */
2810
+ __onChangeCallbacks(entity: Entity, value: T): void;
2811
+ /**
2812
+ * @public
2813
+ */
2814
+ __run_validateBeforeChange(entity: Entity, newValue: T | undefined, senderAddress: string, createdBy: string): boolean;
2815
+ }
2816
+
2727
2817
  /**
2728
2818
  * @public
2729
2819
  */
@@ -8671,6 +8761,14 @@ export declare interface UiTransformProps {
8671
8761
  */
8672
8762
  export declare type Unpacked<T> = T extends (infer U)[] ? U : T;
8673
8763
 
8764
+ export declare type ValidateCallback<T> = (value: {
8765
+ entity: Entity;
8766
+ currentValue: T | undefined;
8767
+ newValue: T | undefined;
8768
+ senderAddress: string;
8769
+ createdBy: string;
8770
+ }) => boolean;
8771
+
8674
8772
  /**
8675
8773
  * @public
8676
8774
  */
@@ -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 */
@@ -1530,12 +1582,12 @@ export declare const CRDT_MESSAGE_HEADER_LENGTH = 8;
1530
1582
  /**
1531
1583
  * @public
1532
1584
  */
1533
- export declare type CrdtMessage = PutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1585
+ export declare type CrdtMessage = PutComponentMessage | AuthoritativePutComponentMessage | DeleteComponentMessage | AppendValueMessage | DeleteEntityMessage | PutNetworkComponentMessage | DeleteComponentNetworkMessage | DeleteEntityNetworkMessage;
1534
1586
 
1535
1587
  /**
1536
1588
  * @public
1537
1589
  */
1538
- export declare type CrdtMessageBody = PutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1590
+ export declare type CrdtMessageBody = PutComponentMessageBody | AuthoritativePutComponentMessageBody | DeleteComponentMessageBody | DeleteEntityMessageBody | AppendValueMessageBody | CrdtNetworkMessageBody;
1539
1591
 
1540
1592
  /**
1541
1593
  * Min length = 8 bytes
@@ -1590,7 +1642,8 @@ export declare enum CrdtMessageType {
1590
1642
  PUT_COMPONENT_NETWORK = 5,
1591
1643
  DELETE_COMPONENT_NETWORK = 6,
1592
1644
  DELETE_ENTITY_NETWORK = 7,
1593
- MAX_MESSAGE_TYPE = 8
1645
+ AUTHORITATIVE_PUT_COMPONENT = 8,
1646
+ MAX_MESSAGE_TYPE = 9
1594
1647
  }
1595
1648
 
1596
1649
  /**
@@ -1598,6 +1651,8 @@ export declare enum CrdtMessageType {
1598
1651
  */
1599
1652
  export declare type CrdtNetworkMessageBody = PutNetworkComponentMessageBody | DeleteComponentNetworkMessageBody | DeleteEntityNetworkMessageBody;
1600
1653
 
1654
+ export declare const CreatedBy: ICreatedBy;
1655
+
1601
1656
  /**
1602
1657
  * @public
1603
1658
  */
@@ -2290,6 +2345,12 @@ export declare interface GrowOnlyValueSetComponentDefinition<T> extends BaseComp
2290
2345
 
2291
2346
  export declare type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<any>> = (engine: Pick<IEngine, 'defineValueSetComponentFromSchema'>) => T;
2292
2347
 
2348
+ export declare type ICreatedBy = LastWriteWinElementSetComponentDefinition<ICreatedByType>;
2349
+
2350
+ export declare interface ICreatedByType {
2351
+ address: string;
2352
+ }
2353
+
2293
2354
  /**
2294
2355
  * @public
2295
2356
  */
@@ -2724,6 +2785,35 @@ export declare type InstanceCompositeOptions = {
2724
2785
  alreadyRequestedSrc?: Set<string>;
2725
2786
  };
2726
2787
 
2788
+ /**
2789
+ * Internal component interface that exposes all internal methods for SDK use
2790
+ * This is not exposed to users, only for internal SDK operations
2791
+ */
2792
+ export declare interface InternalBaseComponent<T> extends BaseComponent<T> {
2793
+ /**
2794
+ * @public
2795
+ * Dry run update to check if a CRDT message would be accepted without actually applying it
2796
+ */
2797
+ __dry_run_updateFromCrdt(body: CrdtMessageBody): ProcessMessageResultType;
2798
+ /**
2799
+ * @public
2800
+ * Get the iterator to every entity has the component
2801
+ */
2802
+ iterator(): Iterable<[Entity, any]>;
2803
+ /**
2804
+ * @public
2805
+ */
2806
+ dirtyIterator(): Iterable<Entity>;
2807
+ /**
2808
+ * @public
2809
+ */
2810
+ __onChangeCallbacks(entity: Entity, value: T): void;
2811
+ /**
2812
+ * @public
2813
+ */
2814
+ __run_validateBeforeChange(entity: Entity, newValue: T | undefined, senderAddress: string, createdBy: string): boolean;
2815
+ }
2816
+
2727
2817
  /**
2728
2818
  * @public
2729
2819
  */
@@ -8671,6 +8761,14 @@ export declare interface UiTransformProps {
8671
8761
  */
8672
8762
  export declare type Unpacked<T> = T extends (infer U)[] ? U : T;
8673
8763
 
8764
+ export declare type ValidateCallback<T> = (value: {
8765
+ entity: Entity;
8766
+ currentValue: T | undefined;
8767
+ newValue: T | undefined;
8768
+ senderAddress: string;
8769
+ createdBy: string;
8770
+ }) => boolean;
8771
+
8674
8772
  /**
8675
8773
  * @public
8676
8774
  */