@dcl/ecs 7.0.6-4177592674.commit-39cdc99 → 7.0.6-4180146485.commit-9a7dde9

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.
Files changed (44) hide show
  1. package/dist/components/extended/Animator.d.ts +3 -2
  2. package/dist/components/extended/Material.d.ts +2 -2
  3. package/dist/components/extended/MeshCollider.d.ts +2 -2
  4. package/dist/components/extended/MeshRenderer.d.ts +2 -2
  5. package/dist/components/generated/global.gen.d.ts +26 -26
  6. package/dist/components/generated/index.gen.d.ts +32 -31
  7. package/dist/components/generated/index.gen.js +4 -1
  8. package/dist/components/generated/pb/decentraland/sdk/components/pointer_events_result.gen.d.ts +1 -9
  9. package/dist/components/generated/pb/decentraland/sdk/components/pointer_events_result.gen.js +2 -36
  10. package/dist/components/index.d.ts +9 -9
  11. package/dist/components/index.js +1 -1
  12. package/dist/components/{legacy → manual}/Transform.d.ts +2 -2
  13. package/dist/components/{legacy → manual}/Transform.js +0 -0
  14. package/dist/components/types.d.ts +1 -1
  15. package/dist/engine/component.d.ts +74 -27
  16. package/dist/engine/component.js +7 -240
  17. package/dist/engine/grow-only-value-set-component-definition.d.ts +8 -0
  18. package/dist/engine/grow-only-value-set-component-definition.js +132 -0
  19. package/dist/engine/index.d.ts +1 -2
  20. package/dist/engine/index.js +18 -1
  21. package/dist/engine/input.d.ts +3 -3
  22. package/dist/engine/input.js +75 -68
  23. package/dist/engine/lww-element-set-component-definition.d.ts +6 -0
  24. package/dist/engine/lww-element-set-component-definition.js +229 -0
  25. package/dist/engine/readonly.d.ts +2 -2
  26. package/dist/engine/types.d.ts +20 -9
  27. package/dist/engine/types.js +1 -1
  28. package/dist/runtime/invariant.d.ts +1 -0
  29. package/dist/runtime/invariant.js +6 -1
  30. package/dist/runtime/types.d.ts +1 -2
  31. package/dist/runtime/types.js +0 -1
  32. package/dist/schemas/ISchema.d.ts +3 -2
  33. package/dist/schemas/Map.d.ts +0 -1
  34. package/dist/serialization/crdt/appendValue.d.ts +1 -0
  35. package/dist/serialization/crdt/appendValue.js +49 -0
  36. package/dist/serialization/crdt/index.d.ts +1 -0
  37. package/dist/serialization/crdt/index.js +1 -0
  38. package/dist/serialization/crdt/message.js +4 -0
  39. package/dist/serialization/crdt/types.d.ts +24 -3
  40. package/dist/serialization/crdt/types.js +2 -1
  41. package/dist/systems/crdt/index.d.ts +1 -1
  42. package/dist/systems/crdt/index.js +21 -8
  43. package/dist/systems/events.d.ts +2 -2
  44. package/package.json +3 -3
@@ -1,9 +1,10 @@
1
- import { ComponentDefinition, Entity, IEngine } from '../../engine';
1
+ import { Entity, IEngine } from '../../engine';
2
+ import { LastWriteWinElementSetComponentDefinition } from '../../engine/component';
2
3
  import { PBAnimationState, PBAnimator } from '../generated/pb/decentraland/sdk/components/animator.gen';
3
4
  /**
4
5
  * @public
5
6
  */
6
- export interface AnimatorComponentDefinitionExtended extends ComponentDefinition<PBAnimator> {
7
+ export interface AnimatorComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBAnimator> {
7
8
  /**
8
9
  * @public
9
10
  *
@@ -1,4 +1,4 @@
1
- import { ComponentDefinition, Entity, IEngine } from '../../engine';
1
+ import { LastWriteWinElementSetComponentDefinition, Entity, IEngine } from '../../engine';
2
2
  import { PBMaterial, PBMaterial_PbrMaterial, PBMaterial_UnlitMaterial } from '../generated/index.gen';
3
3
  import { AvatarTexture, Texture, TextureUnion, VideoTexture } from '../generated/types.gen';
4
4
  /**
@@ -21,7 +21,7 @@ export interface TextureHelper {
21
21
  /**
22
22
  * @public
23
23
  */
24
- export interface MaterialComponentDefinitionExtended extends ComponentDefinition<PBMaterial> {
24
+ export interface MaterialComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBMaterial> {
25
25
  /**
26
26
  * Texture helpers with constructor
27
27
  */
@@ -1,9 +1,9 @@
1
- import { ComponentDefinition, Entity, IEngine } from '../../engine';
1
+ import { LastWriteWinElementSetComponentDefinition, Entity, IEngine } from '../../engine';
2
2
  import { ColliderLayer, PBMeshCollider } from '../generated/index.gen';
3
3
  /**
4
4
  * @public
5
5
  */
6
- export interface MeshColliderComponentDefinitionExtended extends ComponentDefinition<PBMeshCollider> {
6
+ export interface MeshColliderComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBMeshCollider> {
7
7
  /**
8
8
  * @public
9
9
  * Set a box in the MeshCollider component
@@ -1,9 +1,9 @@
1
- import { ComponentDefinition, Entity, IEngine } from '../../engine';
1
+ import { LastWriteWinElementSetComponentDefinition, Entity, IEngine } from '../../engine';
2
2
  import { PBMeshRenderer } from '../generated/index.gen';
3
3
  /**
4
4
  * @public
5
5
  */
6
- export interface MeshRendererComponentDefinitionExtended extends ComponentDefinition<PBMeshRenderer> {
6
+ export interface MeshRendererComponentDefinitionExtended extends LastWriteWinElementSetComponentDefinition<PBMeshRenderer> {
7
7
  /**
8
8
  * @public
9
9
  * Set a box in the MeshRenderer component
@@ -1,4 +1,4 @@
1
- import { ComponentDefinition } from '../../engine/component';
1
+ import { LastWriteWinElementSetComponentDefinition, GrowOnlyValueSetComponentDefinition } from '../../engine/component';
2
2
  export * from './index.gen';
3
3
  import { PBAudioSource } from './pb/decentraland/sdk/components/audio_source.gen';
4
4
  import { PBAudioStream } from './pb/decentraland/sdk/components/audio_stream.gen';
@@ -25,28 +25,28 @@ import { PBUiText } from './pb/decentraland/sdk/components/ui_text.gen';
25
25
  import { PBUiTransform } from './pb/decentraland/sdk/components/ui_transform.gen';
26
26
  import { PBVideoPlayer } from './pb/decentraland/sdk/components/video_player.gen';
27
27
  import { PBVisibilityComponent } from './pb/decentraland/sdk/components/visibility_component.gen';
28
- /** @public */ export declare const AudioSource: ComponentDefinition<PBAudioSource>;
29
- /** @public */ export declare const AudioStream: ComponentDefinition<PBAudioStream>;
30
- /** @public */ export declare const AvatarAttach: ComponentDefinition<PBAvatarAttach>;
31
- /** @public */ export declare const AvatarModifierArea: ComponentDefinition<PBAvatarModifierArea>;
32
- /** @public */ export declare const AvatarShape: ComponentDefinition<PBAvatarShape>;
33
- /** @public */ export declare const Billboard: ComponentDefinition<PBBillboard>;
34
- /** @public */ export declare const CameraMode: ComponentDefinition<PBCameraMode>;
35
- /** @public */ export declare const CameraModeArea: ComponentDefinition<PBCameraModeArea>;
36
- /** @public */ export declare const GltfContainer: ComponentDefinition<PBGltfContainer>;
37
- /** @public */ export declare const NftShape: ComponentDefinition<PBNftShape>;
38
- /** @public */ export declare const PointerEvents: ComponentDefinition<PBPointerEvents>;
39
- /** @public */ export declare const PointerEventsResult: ComponentDefinition<PBPointerEventsResult>;
40
- /** @public */ export declare const PointerLock: ComponentDefinition<PBPointerLock>;
41
- /** @public */ export declare const Raycast: ComponentDefinition<PBRaycast>;
42
- /** @public */ export declare const RaycastResult: ComponentDefinition<PBRaycastResult>;
43
- /** @public */ export declare const TextShape: ComponentDefinition<PBTextShape>;
44
- /** @public */ export declare const UiBackground: ComponentDefinition<PBUiBackground>;
45
- /** @public */ export declare const UiDropdown: ComponentDefinition<PBUiDropdown>;
46
- /** @public */ export declare const UiDropdownResult: ComponentDefinition<PBUiDropdownResult>;
47
- /** @public */ export declare const UiInput: ComponentDefinition<PBUiInput>;
48
- /** @public */ export declare const UiInputResult: ComponentDefinition<PBUiInputResult>;
49
- /** @public */ export declare const UiText: ComponentDefinition<PBUiText>;
50
- /** @public */ export declare const UiTransform: ComponentDefinition<PBUiTransform>;
51
- /** @public */ export declare const VideoPlayer: ComponentDefinition<PBVideoPlayer>;
52
- /** @public */ export declare const VisibilityComponent: ComponentDefinition<PBVisibilityComponent>;
28
+ /** @public */ export declare const AudioSource: LastWriteWinElementSetComponentDefinition<PBAudioSource>;
29
+ /** @public */ export declare const AudioStream: LastWriteWinElementSetComponentDefinition<PBAudioStream>;
30
+ /** @public */ export declare const AvatarAttach: LastWriteWinElementSetComponentDefinition<PBAvatarAttach>;
31
+ /** @public */ export declare const AvatarModifierArea: LastWriteWinElementSetComponentDefinition<PBAvatarModifierArea>;
32
+ /** @public */ export declare const AvatarShape: LastWriteWinElementSetComponentDefinition<PBAvatarShape>;
33
+ /** @public */ export declare const Billboard: LastWriteWinElementSetComponentDefinition<PBBillboard>;
34
+ /** @public */ export declare const CameraMode: LastWriteWinElementSetComponentDefinition<PBCameraMode>;
35
+ /** @public */ export declare const CameraModeArea: LastWriteWinElementSetComponentDefinition<PBCameraModeArea>;
36
+ /** @public */ export declare const GltfContainer: LastWriteWinElementSetComponentDefinition<PBGltfContainer>;
37
+ /** @public */ export declare const NftShape: LastWriteWinElementSetComponentDefinition<PBNftShape>;
38
+ /** @public */ export declare const PointerEvents: LastWriteWinElementSetComponentDefinition<PBPointerEvents>;
39
+ /** @public */ export declare const PointerEventsResult: GrowOnlyValueSetComponentDefinition<PBPointerEventsResult>;
40
+ /** @public */ export declare const PointerLock: LastWriteWinElementSetComponentDefinition<PBPointerLock>;
41
+ /** @public */ export declare const Raycast: LastWriteWinElementSetComponentDefinition<PBRaycast>;
42
+ /** @public */ export declare const RaycastResult: LastWriteWinElementSetComponentDefinition<PBRaycastResult>;
43
+ /** @public */ export declare const TextShape: LastWriteWinElementSetComponentDefinition<PBTextShape>;
44
+ /** @public */ export declare const UiBackground: LastWriteWinElementSetComponentDefinition<PBUiBackground>;
45
+ /** @public */ export declare const UiDropdown: LastWriteWinElementSetComponentDefinition<PBUiDropdown>;
46
+ /** @public */ export declare const UiDropdownResult: LastWriteWinElementSetComponentDefinition<PBUiDropdownResult>;
47
+ /** @public */ export declare const UiInput: LastWriteWinElementSetComponentDefinition<PBUiInput>;
48
+ /** @public */ export declare const UiInputResult: LastWriteWinElementSetComponentDefinition<PBUiInputResult>;
49
+ /** @public */ export declare const UiText: LastWriteWinElementSetComponentDefinition<PBUiText>;
50
+ /** @public */ export declare const UiTransform: LastWriteWinElementSetComponentDefinition<PBUiTransform>;
51
+ /** @public */ export declare const VideoPlayer: LastWriteWinElementSetComponentDefinition<PBVideoPlayer>;
52
+ /** @public */ export declare const VisibilityComponent: LastWriteWinElementSetComponentDefinition<PBVisibilityComponent>;
@@ -1,5 +1,5 @@
1
1
  import type { IEngine } from '../../engine/types';
2
- import { ComponentDefinition } from '../../engine/component';
2
+ import { LastWriteWinElementSetComponentDefinition, GrowOnlyValueSetComponentDefinition } from '../../engine/component';
3
3
  import { PBAnimator } from './pb/decentraland/sdk/components/animator.gen';
4
4
  import { PBAudioSource } from './pb/decentraland/sdk/components/audio_source.gen';
5
5
  import { PBAudioStream } from './pb/decentraland/sdk/components/audio_stream.gen';
@@ -58,33 +58,34 @@ export * from './pb/decentraland/sdk/components/ui_text.gen';
58
58
  export * from './pb/decentraland/sdk/components/ui_transform.gen';
59
59
  export * from './pb/decentraland/sdk/components/video_player.gen';
60
60
  export * from './pb/decentraland/sdk/components/visibility_component.gen';
61
- export type ComponentGetter<T extends ComponentDefinition<any>> = (engine: Pick<IEngine, 'defineComponentFromSchema'>) => T;
62
- /** @public */ export declare const Animator: ComponentGetter<ComponentDefinition<PBAnimator>>;
63
- /** @public */ export declare const AudioSource: ComponentGetter<ComponentDefinition<PBAudioSource>>;
64
- /** @public */ export declare const AudioStream: ComponentGetter<ComponentDefinition<PBAudioStream>>;
65
- /** @public */ export declare const AvatarAttach: ComponentGetter<ComponentDefinition<PBAvatarAttach>>;
66
- /** @public */ export declare const AvatarModifierArea: ComponentGetter<ComponentDefinition<PBAvatarModifierArea>>;
67
- /** @public */ export declare const AvatarShape: ComponentGetter<ComponentDefinition<PBAvatarShape>>;
68
- /** @public */ export declare const Billboard: ComponentGetter<ComponentDefinition<PBBillboard>>;
69
- /** @public */ export declare const CameraMode: ComponentGetter<ComponentDefinition<PBCameraMode>>;
70
- /** @public */ export declare const CameraModeArea: ComponentGetter<ComponentDefinition<PBCameraModeArea>>;
71
- /** @public */ export declare const GltfContainer: ComponentGetter<ComponentDefinition<PBGltfContainer>>;
72
- /** @public */ export declare const Material: ComponentGetter<ComponentDefinition<PBMaterial>>;
73
- /** @public */ export declare const MeshCollider: ComponentGetter<ComponentDefinition<PBMeshCollider>>;
74
- /** @public */ export declare const MeshRenderer: ComponentGetter<ComponentDefinition<PBMeshRenderer>>;
75
- /** @public */ export declare const NftShape: ComponentGetter<ComponentDefinition<PBNftShape>>;
76
- /** @public */ export declare const PointerEvents: ComponentGetter<ComponentDefinition<PBPointerEvents>>;
77
- /** @public */ export declare const PointerEventsResult: ComponentGetter<ComponentDefinition<PBPointerEventsResult>>;
78
- /** @public */ export declare const PointerLock: ComponentGetter<ComponentDefinition<PBPointerLock>>;
79
- /** @public */ export declare const Raycast: ComponentGetter<ComponentDefinition<PBRaycast>>;
80
- /** @public */ export declare const RaycastResult: ComponentGetter<ComponentDefinition<PBRaycastResult>>;
81
- /** @public */ export declare const TextShape: ComponentGetter<ComponentDefinition<PBTextShape>>;
82
- /** @public */ export declare const UiBackground: ComponentGetter<ComponentDefinition<PBUiBackground>>;
83
- /** @public */ export declare const UiDropdown: ComponentGetter<ComponentDefinition<PBUiDropdown>>;
84
- /** @public */ export declare const UiDropdownResult: ComponentGetter<ComponentDefinition<PBUiDropdownResult>>;
85
- /** @public */ export declare const UiInput: ComponentGetter<ComponentDefinition<PBUiInput>>;
86
- /** @public */ export declare const UiInputResult: ComponentGetter<ComponentDefinition<PBUiInputResult>>;
87
- /** @public */ export declare const UiText: ComponentGetter<ComponentDefinition<PBUiText>>;
88
- /** @public */ export declare const UiTransform: ComponentGetter<ComponentDefinition<PBUiTransform>>;
89
- /** @public */ export declare const VideoPlayer: ComponentGetter<ComponentDefinition<PBVideoPlayer>>;
90
- /** @public */ export declare const VisibilityComponent: ComponentGetter<ComponentDefinition<PBVisibilityComponent>>;
61
+ export type LwwComponentGetter<T extends LastWriteWinElementSetComponentDefinition<any>> = (engine: Pick<IEngine, 'defineComponentFromSchema'>) => T;
62
+ export type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<any>> = (engine: Pick<IEngine, 'defineValueSetComponentFromSchema'>) => T;
63
+ /** @public */ export declare const Animator: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAnimator>>;
64
+ /** @public */ export declare const AudioSource: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAudioSource>>;
65
+ /** @public */ export declare const AudioStream: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAudioStream>>;
66
+ /** @public */ export declare const AvatarAttach: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarAttach>>;
67
+ /** @public */ export declare const AvatarModifierArea: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarModifierArea>>;
68
+ /** @public */ export declare const AvatarShape: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBAvatarShape>>;
69
+ /** @public */ export declare const Billboard: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBBillboard>>;
70
+ /** @public */ export declare const CameraMode: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBCameraMode>>;
71
+ /** @public */ export declare const CameraModeArea: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBCameraModeArea>>;
72
+ /** @public */ export declare const GltfContainer: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfContainer>>;
73
+ /** @public */ export declare const Material: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMaterial>>;
74
+ /** @public */ export declare const MeshCollider: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMeshCollider>>;
75
+ /** @public */ export declare const MeshRenderer: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBMeshRenderer>>;
76
+ /** @public */ export declare const NftShape: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBNftShape>>;
77
+ /** @public */ export declare const PointerEvents: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBPointerEvents>>;
78
+ /** @public */ export declare const PointerEventsResult: GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBPointerEventsResult>>;
79
+ /** @public */ export declare const PointerLock: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBPointerLock>>;
80
+ /** @public */ export declare const Raycast: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBRaycast>>;
81
+ /** @public */ export declare const RaycastResult: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBRaycastResult>>;
82
+ /** @public */ export declare const TextShape: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextShape>>;
83
+ /** @public */ export declare const UiBackground: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBUiBackground>>;
84
+ /** @public */ export declare const UiDropdown: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBUiDropdown>>;
85
+ /** @public */ export declare const UiDropdownResult: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBUiDropdownResult>>;
86
+ /** @public */ export declare const UiInput: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBUiInput>>;
87
+ /** @public */ export declare const UiInputResult: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBUiInputResult>>;
88
+ /** @public */ export declare const UiText: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBUiText>>;
89
+ /** @public */ export declare const UiTransform: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBUiTransform>>;
90
+ /** @public */ export declare const VideoPlayer: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBVideoPlayer>>;
91
+ /** @public */ export declare const VisibilityComponent: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBVisibilityComponent>>;
@@ -71,7 +71,10 @@ export * from './pb/decentraland/sdk/components/visibility_component.gen';
71
71
  /** @public */ /*#__PURE__*/ export const MeshRenderer = engine => engine.defineComponentFromSchema("core::MeshRenderer", MeshRendererSchema);
72
72
  /** @public */ /*#__PURE__*/ export const NftShape = engine => engine.defineComponentFromSchema("core::NftShape", NftShapeSchema);
73
73
  /** @public */ /*#__PURE__*/ export const PointerEvents = engine => engine.defineComponentFromSchema("core::PointerEvents", PointerEventsSchema);
74
- /** @public */ /*#__PURE__*/ export const PointerEventsResult = engine => engine.defineComponentFromSchema("core::PointerEventsResult", PointerEventsResultSchema);
74
+ /** @public */ /*#__PURE__*/ export const PointerEventsResult = (engine) => engine.defineValueSetComponentFromSchema("core::PointerEventsResult", PointerEventsResultSchema, {
75
+ timestampFunction: (t) => t.timestamp,
76
+ maxElements: 100
77
+ });
75
78
  /** @public */ /*#__PURE__*/ export const PointerLock = engine => engine.defineComponentFromSchema("core::PointerLock", PointerLockSchema);
76
79
  /** @public */ /*#__PURE__*/ export const Raycast = engine => engine.defineComponentFromSchema("core::Raycast", RaycastSchema);
77
80
  /** @public */ /*#__PURE__*/ export const RaycastResult = engine => engine.defineComponentFromSchema("core::RaycastResult", RaycastResultSchema);
@@ -1,19 +1,11 @@
1
1
  import { InputAction } from "./common/input_action.gen";
2
2
  import { PointerEventType } from "./pointer_events.gen";
3
3
  import { RaycastHit } from "./raycast_result.gen";
4
- /** the renderer will set this component to the root entity once per frame with all the events */
4
+ /** renderer append a new object of this in each command, there can be many commands per frames */
5
5
  /**
6
6
  * @public
7
7
  */
8
8
  export interface PBPointerEventsResult {
9
- /** a list of the last N pointer commands (from the engine) */
10
- commands: PBPointerEventsResult_PointerCommand[];
11
- }
12
- /** this message represents a pointer event, used both for UP and DOWN actions */
13
- /**
14
- * @public
15
- */
16
- export interface PBPointerEventsResult_PointerCommand {
17
9
  /** identifier of the input */
18
10
  button: InputAction;
19
11
  hit: RaycastHit | undefined;
@@ -3,40 +3,6 @@ import _m0 from "protobufjs/minimal";
3
3
  import { RaycastHit } from "./raycast_result.gen";
4
4
  const protobufPackageSarasa = "decentraland.sdk.components";
5
5
  function createBasePBPointerEventsResult() {
6
- return { commands: [] };
7
- }
8
- /**
9
- * @public
10
- */
11
- /**
12
- * @internal
13
- */
14
- export const PBPointerEventsResult = {
15
- encode(message, writer = _m0.Writer.create()) {
16
- for (const v of message.commands) {
17
- PBPointerEventsResult_PointerCommand.encode(v, writer.uint32(10).fork()).ldelim();
18
- }
19
- return writer;
20
- },
21
- decode(input, length) {
22
- const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
23
- let end = length === undefined ? reader.len : reader.pos + length;
24
- const message = createBasePBPointerEventsResult();
25
- while (reader.pos < end) {
26
- const tag = reader.uint32();
27
- switch (tag >>> 3) {
28
- case 1:
29
- message.commands.push(PBPointerEventsResult_PointerCommand.decode(reader, reader.uint32()));
30
- break;
31
- default:
32
- reader.skipType(tag & 7);
33
- break;
34
- }
35
- }
36
- return message;
37
- },
38
- };
39
- function createBasePBPointerEventsResult_PointerCommand() {
40
6
  return { button: 0, hit: undefined, state: 0, timestamp: 0, analog: undefined };
41
7
  }
42
8
  /**
@@ -45,7 +11,7 @@ function createBasePBPointerEventsResult_PointerCommand() {
45
11
  /**
46
12
  * @internal
47
13
  */
48
- export const PBPointerEventsResult_PointerCommand = {
14
+ export const PBPointerEventsResult = {
49
15
  encode(message, writer = _m0.Writer.create()) {
50
16
  if (message.button !== 0) {
51
17
  writer.uint32(8).int32(message.button);
@@ -67,7 +33,7 @@ export const PBPointerEventsResult_PointerCommand = {
67
33
  decode(input, length) {
68
34
  const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
69
35
  let end = length === undefined ? reader.len : reader.pos + length;
70
- const message = createBasePBPointerEventsResult_PointerCommand();
36
+ const message = createBasePBPointerEventsResult();
71
37
  while (reader.pos < end) {
72
38
  const tag = reader.uint32();
73
39
  switch (tag >>> 3) {
@@ -1,14 +1,14 @@
1
- import { ComponentDefinition } from '../engine/component';
1
+ import { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition } from '../engine/component';
2
2
  import { AnimatorComponentDefinitionExtended } from './extended/Animator';
3
3
  import { MaterialComponentDefinitionExtended } from './extended/Material';
4
4
  import { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
5
5
  import { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
6
- import { ComponentGetter } from './generated/index.gen';
7
- import { TransformComponentExtended } from './legacy/Transform';
6
+ import { LwwComponentGetter, GSetComponentGetter } from './generated/index.gen';
7
+ import { TransformComponentExtended } from './manual/Transform';
8
8
  export * from './generated/index.gen';
9
- export type { ComponentDefinition, ComponentGetter };
10
- export declare const Transform: ComponentGetter<TransformComponentExtended>;
11
- export declare const Material: ComponentGetter<MaterialComponentDefinitionExtended>;
12
- export declare const Animator: ComponentGetter<AnimatorComponentDefinitionExtended>;
13
- export declare const MeshRenderer: ComponentGetter<MeshRendererComponentDefinitionExtended>;
14
- export declare const MeshCollider: ComponentGetter<MeshColliderComponentDefinitionExtended>;
9
+ export type { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition, LwwComponentGetter, GSetComponentGetter };
10
+ export declare const Transform: LwwComponentGetter<TransformComponentExtended>;
11
+ export declare const Material: LwwComponentGetter<MaterialComponentDefinitionExtended>;
12
+ export declare const Animator: LwwComponentGetter<AnimatorComponentDefinitionExtended>;
13
+ export declare const MeshRenderer: LwwComponentGetter<MeshRendererComponentDefinitionExtended>;
14
+ export declare const MeshCollider: LwwComponentGetter<MeshColliderComponentDefinitionExtended>;
@@ -2,7 +2,7 @@ import { defineAnimatorComponent } from './extended/Animator';
2
2
  import { defineMaterialComponent } from './extended/Material';
3
3
  import { defineMeshColliderComponent } from './extended/MeshCollider';
4
4
  import { defineMeshRendererComponent } from './extended/MeshRenderer';
5
- import { defineTransformComponent } from './legacy/Transform';
5
+ import { defineTransformComponent } from './manual/Transform';
6
6
  export * from './generated/index.gen';
7
7
  /*#__PURE__*/
8
8
  export const Transform = (engine) => defineTransformComponent(engine);
@@ -1,9 +1,9 @@
1
- import { ComponentDefinition, IEngine } from '../../engine';
1
+ import { LastWriteWinElementSetComponentDefinition, IEngine } from '../../engine';
2
2
  import { Entity } from '../../engine/entity';
3
3
  /**
4
4
  * @public
5
5
  */
6
- export type TransformComponent = ComponentDefinition<TransformType>;
6
+ export type TransformComponent = LastWriteWinElementSetComponentDefinition<TransformType>;
7
7
  /**
8
8
  * @public
9
9
  */
File without changes
@@ -2,4 +2,4 @@ export type { AnimatorComponentDefinitionExtended } from './extended/Animator';
2
2
  export type { MeshRendererComponentDefinitionExtended } from './extended/MeshRenderer';
3
3
  export type { MeshColliderComponentDefinitionExtended } from './extended/MeshCollider';
4
4
  export type { TextureHelper, MaterialComponentDefinitionExtended } from './extended/Material';
5
- export type { TransformComponentExtended, TransformTypeWithOptionals } from './legacy/Transform';
5
+ export type { TransformComponentExtended, TransformTypeWithOptionals } from './manual/Transform';
@@ -1,24 +1,72 @@
1
- import type { ISchema } from '../schemas/ISchema';
1
+ import { ISchema } from '../schemas';
2
2
  import { CrdtMessageBody, DeleteComponentMessageBody, PutComponentMessageBody } from '../serialization/crdt';
3
3
  import { Entity } from './entity';
4
- import { DeepReadonly } from './readonly';
4
+ import { DeepReadonly, DeepReadonlySet } from './readonly';
5
5
  /**
6
+ * Component types are used to pick the wire protocol and the conflict resolution algorithm
6
7
  * @public
7
8
  */
8
- export interface ComponentDefinition<T> {
9
+ export declare const enum ComponentType {
10
+ LastWriteWinElementSet = 0,
11
+ GrowOnlyValueSet = 1
12
+ }
13
+ /**
14
+ * A conflict resolution message is the response to an outdated or invalid state
15
+ * in the CRDT.
16
+ * @public
17
+ */
18
+ export type ConflictResolutionMessage = PutComponentMessageBody | DeleteComponentMessageBody;
19
+ /**
20
+ * @public
21
+ */
22
+ export interface BaseComponent<T> {
9
23
  readonly componentId: number;
10
24
  readonly componentName: string;
25
+ readonly componentType: ComponentType;
26
+ readonly schema: ISchema<T>;
27
+ /**
28
+ * This function receives a CRDT update and returns a touple with a "conflict
29
+ * resoluton" message, in case of the sender being updated or null in case of noop/accepted
30
+ * change. The second element of the touple is the modified/changed/deleted value.
31
+ * @public
32
+ */
33
+ updateFromCrdt(body: CrdtMessageBody): [null | ConflictResolutionMessage, T | undefined];
34
+ /**
35
+ * This function returns an iterable with all the CRDT updates that need to be
36
+ * broadcasted to other actors in the system. After returning, this function
37
+ * clears the internal dirty state. Updates are produced only once.
38
+ * @public
39
+ */
40
+ getCrdtUpdates(): Iterable<CrdtMessageBody>;
11
41
  /**
12
- * Return the default value of the current component
42
+ * @public
43
+ * Marks the entity as deleted and signals it cannot be used ever again. It must
44
+ * clear the component internal state, produces a synchronization message to remove
45
+ * the component from the entity.
46
+ * @param entity - Entity ID that was deleted.
13
47
  */
14
- default(): DeepReadonly<T>;
48
+ entityDeleted(entity: Entity, markAsDirty: boolean): void;
15
49
  /**
16
50
  * Get if the entity has this component
17
51
  * @param entity - entity to test
18
52
  */
19
53
  has(entity: Entity): boolean;
20
54
  /**
21
- * Get the readonly component of the entity (to mutate it, use getMutable instead), throw an error if the entity doesn't have the component.
55
+ * Get the readonly component of the entity (to mutate it, use getMutable instead),
56
+ * throws an error if the entity doesn't have the component.
57
+ * @param entity - Entity that will be used to get the component
58
+ * @returns
59
+ */
60
+ get(entity: Entity): any;
61
+ }
62
+ /**
63
+ * @public
64
+ */
65
+ export interface LastWriteWinElementSetComponentDefinition<T> extends BaseComponent<T> {
66
+ readonly componentType: ComponentType.LastWriteWinElementSet;
67
+ /**
68
+ * Get the readonly component of the entity (to mutate it, use getMutable instead),
69
+ * throws an error if the entity doesn't have the component.
22
70
  * @param entity - Entity that will be used to get the component
23
71
  * @returns
24
72
  */
@@ -49,14 +97,6 @@ export interface ComponentDefinition<T> {
49
97
  * @param entity - Entity to delete the component from
50
98
  */
51
99
  deleteFrom(entity: Entity): T | null;
52
- /**
53
- * @public
54
- * Marks the entity as deleted and signals it cannot be used ever again. It must
55
- * clear the component internal state, produces a synchronization message to remove
56
- * the component from the entity.
57
- * @param entity - Entity to delete the component from
58
- */
59
- entityDeleted(entity: Entity, markAsDirty: boolean): void;
60
100
  /**
61
101
  * Get the mutable component of the entity, throw an error if the entity doesn't have the component.
62
102
  * - Internal comment: This method adds the &lt;entity,component&gt; to the list to be reviewed next frame
@@ -69,21 +109,28 @@ export interface ComponentDefinition<T> {
69
109
  * @param entity - Entity to get the component from
70
110
  */
71
111
  getMutableOrNull(entity: Entity): T | null;
112
+ }
113
+ /**
114
+ * @public
115
+ */
116
+ export interface GrowOnlyValueSetComponentDefinition<T> extends BaseComponent<T> {
117
+ readonly componentType: ComponentType.GrowOnlyValueSet;
72
118
  /**
73
- * This function receives a CRDT update and returns a touple with a "conflict
74
- * resoluton" message, in case of the sender being updated or null in case of noop/accepted
75
- * change. The second element of the touple is the modified/changed/deleted value.
76
- * @public
119
+ * Appends an element to the set.
120
+ * @param entity - Entity that will host the value
121
+ * @param val - The final value. The Set will freeze the value, it won't be editable from
122
+ * the script.
77
123
  */
78
- updateFromCrdt(body: CrdtMessageBody): [null | PutComponentMessageBody | DeleteComponentMessageBody, T | null];
124
+ addValue(entity: Entity, val: DeepReadonly<T>): DeepReadonlySet<T>;
79
125
  /**
80
- * This function returns an iterable with all the CRDT updates that need to be
81
- * broadcasted to other actors in the system. After returning, this function
82
- * clears the internal dirty state. Updates are produced only once.
83
- * @public
126
+ * Get the readonly component of the entity (to mutate it, use getMutable instead),
127
+ * throws an error if the entity doesn't have the component.
128
+ * @param entity - Entity that will be used to get the component
129
+ * @returns
84
130
  */
85
- getCrdtUpdates(): Iterable<CrdtMessageBody>;
131
+ get(entity: Entity): DeepReadonlySet<T>;
86
132
  }
87
- export declare function incrementTimestamp(entity: Entity, timestamps: Map<Entity, number>): number;
88
- export declare function createUpdateFromCrdt(componentId: number, timestamps: Map<Entity, number>, schema: Pick<ISchema<any>, 'serialize' | 'deserialize'>, data: Map<Entity, unknown>): (msg: CrdtMessageBody) => [null | PutComponentMessageBody | DeleteComponentMessageBody, any];
89
- export declare function createGetCrdtMessages(componentId: number, timestamps: Map<Entity, number>, dirtyIterator: Set<Entity>, schema: Pick<ISchema<any>, 'serialize'>, data: Map<Entity, unknown>): () => Generator<PutComponentMessageBody | DeleteComponentMessageBody, void, unknown>;
133
+ /**
134
+ * @public
135
+ */
136
+ export type ComponentDefinition<T> = LastWriteWinElementSetComponentDefinition<T> | GrowOnlyValueSetComponentDefinition<T>;