@dcl/ecs 7.29.1-35917671376.commit-046b268 → 7.29.1-36041177279.commit-502e633
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/components/generated/component-names.gen.js +0 -1
- package/dist/components/generated/global.gen.d.ts +0 -2
- package/dist/components/generated/global.gen.js +0 -1
- package/dist/components/generated/index.gen.d.ts +0 -4
- package/dist/components/generated/index.gen.js +0 -7
- package/dist/components/generated/pb/decentraland/sdk/components/common/explorer_ui.gen.d.ts +2 -4
- package/dist/components/generated/pb/decentraland/sdk/components/common/explorer_ui.gen.js +1 -3
- package/dist/components/generated/pb/decentraland/sdk/components/explorer_ui_events_result.gen.d.ts +3 -8
- package/dist/components/generated/pb/decentraland/sdk/components/explorer_ui_events_result.gen.js +1 -10
- package/dist/components/index.d.ts +5 -0
- package/dist/components/index.js +5 -2
- package/dist/components/manual/CreatedBy.d.ts +9 -0
- package/dist/components/manual/CreatedBy.js +8 -0
- package/dist/components/manual/Transform.d.ts +9 -0
- package/dist/components/manual/Transform.js +3 -3
- package/dist/components/types.d.ts +1 -0
- package/dist/engine/component.d.ts +52 -1
- package/dist/engine/grow-only-value-set-component-definition.js +45 -2
- package/dist/engine/lww-element-set-component-definition.d.ts +3 -1
- package/dist/engine/lww-element-set-component-definition.js +68 -13
- package/dist/index.d.ts +2 -1
- package/dist/index.js +1 -0
- package/dist/serialization/crdt/authoritativePutComponent.d.ts +15 -0
- package/dist/serialization/crdt/authoritativePutComponent.js +47 -0
- package/dist/serialization/crdt/index.d.ts +1 -0
- package/dist/serialization/crdt/index.js +1 -0
- package/dist/serialization/crdt/types.d.ts +25 -3
- package/dist/serialization/crdt/types.js +3 -1
- package/dist/systems/crdt/index.d.ts +0 -1
- package/dist/systems/crdt/index.js +76 -143
- package/dist/systems/crdt/types.d.ts +10 -0
- package/dist-cjs/components/generated/component-names.gen.js +0 -1
- package/dist-cjs/components/generated/global.gen.d.ts +0 -2
- package/dist-cjs/components/generated/global.gen.js +2 -3
- package/dist-cjs/components/generated/index.gen.d.ts +0 -4
- package/dist-cjs/components/generated/index.gen.js +2 -10
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/common/explorer_ui.gen.d.ts +2 -4
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/common/explorer_ui.gen.js +1 -3
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/explorer_ui_events_result.gen.d.ts +3 -8
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/explorer_ui_events_result.gen.js +1 -10
- package/dist-cjs/components/index.d.ts +5 -0
- package/dist-cjs/components/index.js +7 -3
- package/dist-cjs/components/manual/CreatedBy.d.ts +9 -0
- package/dist-cjs/components/manual/CreatedBy.js +10 -0
- package/dist-cjs/components/manual/Transform.d.ts +9 -0
- package/dist-cjs/components/manual/Transform.js +3 -3
- package/dist-cjs/components/types.d.ts +1 -0
- package/dist-cjs/engine/component.d.ts +52 -1
- package/dist-cjs/engine/grow-only-value-set-component-definition.js +44 -1
- package/dist-cjs/engine/lww-element-set-component-definition.d.ts +3 -1
- package/dist-cjs/engine/lww-element-set-component-definition.js +71 -14
- package/dist-cjs/index.d.ts +2 -1
- package/dist-cjs/index.js +2 -1
- package/dist-cjs/serialization/crdt/authoritativePutComponent.d.ts +15 -0
- package/dist-cjs/serialization/crdt/authoritativePutComponent.js +50 -0
- package/dist-cjs/serialization/crdt/index.d.ts +1 -0
- package/dist-cjs/serialization/crdt/index.js +1 -0
- package/dist-cjs/serialization/crdt/types.d.ts +25 -3
- package/dist-cjs/serialization/crdt/types.js +3 -1
- package/dist-cjs/systems/crdt/index.d.ts +0 -1
- package/dist-cjs/systems/crdt/index.js +76 -166
- package/dist-cjs/systems/crdt/types.d.ts +10 -0
- package/package.json +2 -2
- package/dist/components/generated/ExplorerItemPurchaseResult.gen.d.ts +0 -1
- package/dist/components/generated/ExplorerItemPurchaseResult.gen.js +0 -25
- package/dist/components/generated/pb/decentraland/sdk/components/explorer_item_purchase_result.gen.d.ts +0 -68
- package/dist/components/generated/pb/decentraland/sdk/components/explorer_item_purchase_result.gen.js +0 -184
- package/dist/serialization/crdt/network/utils.d.ts +0 -9
- package/dist/serialization/crdt/network/utils.js +0 -60
- package/dist-cjs/components/generated/ExplorerItemPurchaseResult.gen.d.ts +0 -1
- package/dist-cjs/components/generated/ExplorerItemPurchaseResult.gen.js +0 -28
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/explorer_item_purchase_result.gen.d.ts +0 -68
- package/dist-cjs/components/generated/pb/decentraland/sdk/components/explorer_item_purchase_result.gen.js +0 -190
- package/dist-cjs/serialization/crdt/network/utils.d.ts +0 -9
- package/dist-cjs/serialization/crdt/network/utils.js +0 -67
|
@@ -22,7 +22,6 @@ export const coreComponentMappings = {
|
|
|
22
22
|
"core::CameraMode": 1072,
|
|
23
23
|
"core::CameraModeArea": 1071,
|
|
24
24
|
"core::EngineInfo": 1048,
|
|
25
|
-
"core::ExplorerItemPurchaseResult": 1222,
|
|
26
25
|
"core::ExplorerUiEventsResult": 1220,
|
|
27
26
|
"core::GltfContainer": 1041,
|
|
28
27
|
"core::GltfContainerLoadingState": 1049,
|
|
@@ -18,7 +18,6 @@ import { PBBillboard } from './pb/decentraland/sdk/components/billboard.gen';
|
|
|
18
18
|
import { PBCameraMode } from './pb/decentraland/sdk/components/camera_mode.gen';
|
|
19
19
|
import { PBCameraModeArea } from './pb/decentraland/sdk/components/camera_mode_area.gen';
|
|
20
20
|
import { PBEngineInfo } from './pb/decentraland/sdk/components/engine_info.gen';
|
|
21
|
-
import { PBExplorerItemPurchaseResult } from './pb/decentraland/sdk/components/explorer_item_purchase_result.gen';
|
|
22
21
|
import { PBExplorerUiEventsResult } from './pb/decentraland/sdk/components/explorer_ui_events_result.gen';
|
|
23
22
|
import { PBGltfContainer } from './pb/decentraland/sdk/components/gltf_container.gen';
|
|
24
23
|
import { PBGltfContainerLoadingState } from './pb/decentraland/sdk/components/gltf_container_loading_state.gen';
|
|
@@ -76,7 +75,6 @@ import { PBVisibilityComponent } from './pb/decentraland/sdk/components/visibili
|
|
|
76
75
|
/** @public */ export declare const CameraMode: LastWriteWinElementSetComponentDefinition<PBCameraMode>;
|
|
77
76
|
/** @public */ export declare const CameraModeArea: LastWriteWinElementSetComponentDefinition<PBCameraModeArea>;
|
|
78
77
|
/** @public */ export declare const EngineInfo: LastWriteWinElementSetComponentDefinition<PBEngineInfo>;
|
|
79
|
-
/** @public */ export declare const ExplorerItemPurchaseResult: GrowOnlyValueSetComponentDefinition<PBExplorerItemPurchaseResult>;
|
|
80
78
|
/** @public */ export declare const ExplorerUiEventsResult: GrowOnlyValueSetComponentDefinition<PBExplorerUiEventsResult>;
|
|
81
79
|
/** @public */ export declare const GltfContainer: LastWriteWinElementSetComponentDefinition<PBGltfContainer>;
|
|
82
80
|
/** @public */ export declare const GltfContainerLoadingState: LastWriteWinElementSetComponentDefinition<PBGltfContainerLoadingState>;
|
|
@@ -19,7 +19,6 @@ export * from './index.gen';
|
|
|
19
19
|
/** @public */ export const CameraMode = /* @__PURE__ */ components.CameraMode(engine);
|
|
20
20
|
/** @public */ export const CameraModeArea = /* @__PURE__ */ components.CameraModeArea(engine);
|
|
21
21
|
/** @public */ export const EngineInfo = /* @__PURE__ */ components.EngineInfo(engine);
|
|
22
|
-
/** @public */ export const ExplorerItemPurchaseResult = /* @__PURE__ */ components.ExplorerItemPurchaseResult(engine);
|
|
23
22
|
/** @public */ export const ExplorerUiEventsResult = /* @__PURE__ */ components.ExplorerUiEventsResult(engine);
|
|
24
23
|
/** @public */ export const GltfContainer = /* @__PURE__ */ components.GltfContainer(engine);
|
|
25
24
|
/** @public */ export const GltfContainerLoadingState = /* @__PURE__ */ components.GltfContainerLoadingState(engine);
|
|
@@ -19,7 +19,6 @@ import { PBBillboard } from './pb/decentraland/sdk/components/billboard.gen';
|
|
|
19
19
|
import { PBCameraMode } from './pb/decentraland/sdk/components/camera_mode.gen';
|
|
20
20
|
import { PBCameraModeArea } from './pb/decentraland/sdk/components/camera_mode_area.gen';
|
|
21
21
|
import { PBEngineInfo } from './pb/decentraland/sdk/components/engine_info.gen';
|
|
22
|
-
import { PBExplorerItemPurchaseResult } from './pb/decentraland/sdk/components/explorer_item_purchase_result.gen';
|
|
23
22
|
import { PBExplorerUiEventsResult } from './pb/decentraland/sdk/components/explorer_ui_events_result.gen';
|
|
24
23
|
import { PBGltfContainer } from './pb/decentraland/sdk/components/gltf_container.gen';
|
|
25
24
|
import { PBGltfContainerLoadingState } from './pb/decentraland/sdk/components/gltf_container_loading_state.gen';
|
|
@@ -82,7 +81,6 @@ export * from './pb/decentraland/sdk/components/billboard.gen';
|
|
|
82
81
|
export * from './pb/decentraland/sdk/components/camera_mode.gen';
|
|
83
82
|
export * from './pb/decentraland/sdk/components/camera_mode_area.gen';
|
|
84
83
|
export * from './pb/decentraland/sdk/components/engine_info.gen';
|
|
85
|
-
export * from './pb/decentraland/sdk/components/explorer_item_purchase_result.gen';
|
|
86
84
|
export * from './pb/decentraland/sdk/components/explorer_ui_events_result.gen';
|
|
87
85
|
export * from './pb/decentraland/sdk/components/gltf_container.gen';
|
|
88
86
|
export * from './pb/decentraland/sdk/components/gltf_container_loading_state.gen';
|
|
@@ -147,7 +145,6 @@ export type GSetComponentGetter<T extends GrowOnlyValueSetComponentDefinition<an
|
|
|
147
145
|
/** @public */ export declare const CameraMode: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBCameraMode>>;
|
|
148
146
|
/** @public */ export declare const CameraModeArea: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBCameraModeArea>>;
|
|
149
147
|
/** @public */ export declare const EngineInfo: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBEngineInfo>>;
|
|
150
|
-
/** @public */ export declare const ExplorerItemPurchaseResult: GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBExplorerItemPurchaseResult>>;
|
|
151
148
|
/** @public */ export declare const ExplorerUiEventsResult: GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBExplorerUiEventsResult>>;
|
|
152
149
|
/** @public */ export declare const GltfContainer: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfContainer>>;
|
|
153
150
|
/** @public */ export declare const GltfContainerLoadingState: LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfContainerLoadingState>>;
|
|
@@ -212,7 +209,6 @@ export declare const componentDefinitionByName: {
|
|
|
212
209
|
"core::CameraMode": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBCameraMode>>;
|
|
213
210
|
"core::CameraModeArea": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBCameraModeArea>>;
|
|
214
211
|
"core::EngineInfo": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBEngineInfo>>;
|
|
215
|
-
"core::ExplorerItemPurchaseResult": GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBExplorerItemPurchaseResult>>;
|
|
216
212
|
"core::ExplorerUiEventsResult": GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBExplorerUiEventsResult>>;
|
|
217
213
|
"core::GltfContainer": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfContainer>>;
|
|
218
214
|
"core::GltfContainerLoadingState": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfContainerLoadingState>>;
|
|
@@ -17,7 +17,6 @@ import { BillboardSchema } from './Billboard.gen';
|
|
|
17
17
|
import { CameraModeSchema } from './CameraMode.gen';
|
|
18
18
|
import { CameraModeAreaSchema } from './CameraModeArea.gen';
|
|
19
19
|
import { EngineInfoSchema } from './EngineInfo.gen';
|
|
20
|
-
import { ExplorerItemPurchaseResultSchema } from './ExplorerItemPurchaseResult.gen';
|
|
21
20
|
import { ExplorerUiEventsResultSchema } from './ExplorerUiEventsResult.gen';
|
|
22
21
|
import { GltfContainerSchema } from './GltfContainer.gen';
|
|
23
22
|
import { GltfContainerLoadingStateSchema } from './GltfContainerLoadingState.gen';
|
|
@@ -80,7 +79,6 @@ export * from './pb/decentraland/sdk/components/billboard.gen';
|
|
|
80
79
|
export * from './pb/decentraland/sdk/components/camera_mode.gen';
|
|
81
80
|
export * from './pb/decentraland/sdk/components/camera_mode_area.gen';
|
|
82
81
|
export * from './pb/decentraland/sdk/components/engine_info.gen';
|
|
83
|
-
export * from './pb/decentraland/sdk/components/explorer_item_purchase_result.gen';
|
|
84
82
|
export * from './pb/decentraland/sdk/components/explorer_ui_events_result.gen';
|
|
85
83
|
export * from './pb/decentraland/sdk/components/gltf_container.gen';
|
|
86
84
|
export * from './pb/decentraland/sdk/components/gltf_container_loading_state.gen';
|
|
@@ -168,10 +166,6 @@ export * from './pb/decentraland/sdk/components/visibility_component.gen';
|
|
|
168
166
|
/* @__PURE__ */ engine.defineComponentFromSchema("core::CameraModeArea", CameraModeAreaSchema);
|
|
169
167
|
/** @public */ export const EngineInfo = engine =>
|
|
170
168
|
/* @__PURE__ */ engine.defineComponentFromSchema("core::EngineInfo", EngineInfoSchema);
|
|
171
|
-
/** @public */ export const ExplorerItemPurchaseResult = (engine) => /* @__PURE__ */ engine.defineValueSetComponentFromSchema("core::ExplorerItemPurchaseResult", ExplorerItemPurchaseResultSchema, {
|
|
172
|
-
timestampFunction: (t) => t.timestamp,
|
|
173
|
-
maxElements: 100
|
|
174
|
-
});
|
|
175
169
|
/** @public */ export const ExplorerUiEventsResult = (engine) => /* @__PURE__ */ engine.defineValueSetComponentFromSchema("core::ExplorerUiEventsResult", ExplorerUiEventsResultSchema, {
|
|
176
170
|
timestampFunction: (t) => t.timestamp,
|
|
177
171
|
maxElements: 100
|
|
@@ -287,7 +281,6 @@ export const componentDefinitionByName = /* @__PURE__ */ {
|
|
|
287
281
|
"core::CameraMode": CameraMode,
|
|
288
282
|
"core::CameraModeArea": CameraModeArea,
|
|
289
283
|
"core::EngineInfo": EngineInfo,
|
|
290
|
-
"core::ExplorerItemPurchaseResult": ExplorerItemPurchaseResult,
|
|
291
284
|
"core::ExplorerUiEventsResult": ExplorerUiEventsResult,
|
|
292
285
|
"core::GltfContainer": GltfContainer,
|
|
293
286
|
"core::GltfContainerLoadingState": GltfContainerLoadingState,
|
package/dist/components/generated/pb/decentraland/sdk/components/common/explorer_ui.gen.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* Identifies which explorer panel OpenExplorerUi targets.
|
|
2
|
+
* Identifies which fullscreen explorer panel OpenExplorerUi targets.
|
|
3
3
|
* EU_SETTINGS holds 0 so an unset `ui` field defaults to the least-intrusive panel.
|
|
4
4
|
*/
|
|
5
5
|
/**
|
|
@@ -12,7 +12,5 @@ export declare const enum ExplorerUi {
|
|
|
12
12
|
EU_CAMERA_REEL = 3,
|
|
13
13
|
EU_COMMUNITIES = 4,
|
|
14
14
|
EU_PLACES = 5,
|
|
15
|
-
EU_EVENTS = 6
|
|
16
|
-
/** EU_ITEM_PURCHASE - the item-purchase confirmation modal; see OpenExplorerUi for its parameters and result component */
|
|
17
|
-
EU_ITEM_PURCHASE = 7
|
|
15
|
+
EU_EVENTS = 6
|
|
18
16
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/* eslint-disable */
|
|
2
2
|
const protobufPackageSarasa = "decentraland.sdk.components.common";
|
|
3
3
|
/**
|
|
4
|
-
* Identifies which explorer panel OpenExplorerUi targets.
|
|
4
|
+
* Identifies which fullscreen explorer panel OpenExplorerUi targets.
|
|
5
5
|
* EU_SETTINGS holds 0 so an unset `ui` field defaults to the least-intrusive panel.
|
|
6
6
|
*/
|
|
7
7
|
/**
|
|
@@ -16,6 +16,4 @@ export var ExplorerUi;
|
|
|
16
16
|
ExplorerUi[ExplorerUi["EU_COMMUNITIES"] = 4] = "EU_COMMUNITIES";
|
|
17
17
|
ExplorerUi[ExplorerUi["EU_PLACES"] = 5] = "EU_PLACES";
|
|
18
18
|
ExplorerUi[ExplorerUi["EU_EVENTS"] = 6] = "EU_EVENTS";
|
|
19
|
-
/** EU_ITEM_PURCHASE - the item-purchase confirmation modal; see OpenExplorerUi for its parameters and result component */
|
|
20
|
-
ExplorerUi[ExplorerUi["EU_ITEM_PURCHASE"] = 7] = "EU_ITEM_PURCHASE";
|
|
21
19
|
})(ExplorerUi || (ExplorerUi = {}));
|
package/dist/components/generated/pb/decentraland/sdk/components/explorer_ui_events_result.gen.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import _m0 from "protobufjs/minimal";
|
|
2
2
|
import { ExplorerUi } from "./common/explorer_ui.gen";
|
|
3
3
|
/**
|
|
4
|
-
* PBExplorerUiEventsResult transports the lifecycle events of explorer
|
|
4
|
+
* PBExplorerUiEventsResult transports the lifecycle events of fullscreen explorer panels — a panel was
|
|
5
5
|
* opened, a panel was closed. It is a grow only value set appended to the scene root entity, so every
|
|
6
6
|
* event of a tick is delivered and none overwrites another.
|
|
7
7
|
*/
|
|
@@ -13,8 +13,6 @@ export interface PBExplorerUiEventsResult {
|
|
|
13
13
|
ui: ExplorerUi;
|
|
14
14
|
/** The scene tick when the event occurred */
|
|
15
15
|
timestamp: number;
|
|
16
|
-
/** The OpenExplorerUiRequest.request_id that caused this event; 0 when the request carried none */
|
|
17
|
-
requestId: number;
|
|
18
16
|
event?: {
|
|
19
17
|
$case: "opened";
|
|
20
18
|
opened: PBExplorerUiEventsResult_UiOpened;
|
|
@@ -23,16 +21,13 @@ export interface PBExplorerUiEventsResult {
|
|
|
23
21
|
closed: PBExplorerUiEventsResult_UiClosed;
|
|
24
22
|
} | undefined;
|
|
25
23
|
}
|
|
26
|
-
/**
|
|
27
|
-
* Emitted when an explorer panel is opened. The OpenExplorerUi response carries the same fact,
|
|
28
|
-
* but it reaches only the caller; this channel is scene wide.
|
|
29
|
-
*/
|
|
24
|
+
/** Emitted when a fullscreen explorer panel is opened. */
|
|
30
25
|
/**
|
|
31
26
|
* @public
|
|
32
27
|
*/
|
|
33
28
|
export interface PBExplorerUiEventsResult_UiOpened {
|
|
34
29
|
}
|
|
35
|
-
/** Emitted when
|
|
30
|
+
/** Emitted when a fullscreen explorer panel is closed. */
|
|
36
31
|
/**
|
|
37
32
|
* @public
|
|
38
33
|
*/
|
package/dist/components/generated/pb/decentraland/sdk/components/explorer_ui_events_result.gen.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import _m0 from "protobufjs/minimal";
|
|
3
3
|
const protobufPackageSarasa = "decentraland.sdk.components";
|
|
4
4
|
function createBasePBExplorerUiEventsResult() {
|
|
5
|
-
return { ui: 0, timestamp: 0,
|
|
5
|
+
return { ui: 0, timestamp: 0, event: undefined };
|
|
6
6
|
}
|
|
7
7
|
/**
|
|
8
8
|
* @public
|
|
@@ -16,9 +16,6 @@ export var PBExplorerUiEventsResult;
|
|
|
16
16
|
if (message.timestamp !== 0) {
|
|
17
17
|
writer.uint32(16).uint32(message.timestamp);
|
|
18
18
|
}
|
|
19
|
-
if (message.requestId !== 0) {
|
|
20
|
-
writer.uint32(24).uint32(message.requestId);
|
|
21
|
-
}
|
|
22
19
|
switch (message.event?.$case) {
|
|
23
20
|
case "opened":
|
|
24
21
|
PBExplorerUiEventsResult_UiOpened.encode(message.event.opened, writer.uint32(82).fork()).ldelim();
|
|
@@ -49,12 +46,6 @@ export var PBExplorerUiEventsResult;
|
|
|
49
46
|
}
|
|
50
47
|
message.timestamp = reader.uint32();
|
|
51
48
|
continue;
|
|
52
|
-
case 3:
|
|
53
|
-
if (tag !== 24) {
|
|
54
|
-
break;
|
|
55
|
-
}
|
|
56
|
-
message.requestId = reader.uint32();
|
|
57
|
-
continue;
|
|
58
49
|
case 10:
|
|
59
50
|
if (tag !== 82) {
|
|
60
51
|
break;
|
|
@@ -23,6 +23,7 @@ import { TriggerAreaComponentDefinitionExtended } from './extended/TriggerArea';
|
|
|
23
23
|
import { ParticleSystemComponentDefinitionExtended } from './extended/ParticleSystem';
|
|
24
24
|
import { TouchScreenControlsComponentDefinitionExtended } from './extended/TouchScreenControls';
|
|
25
25
|
import { TagsComponentDefinitionExtended } from './manual/Tags';
|
|
26
|
+
import { ICreatedByType } from './manual/CreatedBy';
|
|
26
27
|
export * from './generated/index.gen';
|
|
27
28
|
export type { GrowOnlyValueSetComponentDefinition, LastWriteWinElementSetComponentDefinition, LwwComponentGetter, GSetComponentGetter };
|
|
28
29
|
export declare const Transform: LwwComponentGetter<TransformComponentExtended>;
|
|
@@ -57,5 +58,9 @@ export declare const NetworkEntity: (engine: Pick<IEngine, 'defineComponent'>) =
|
|
|
57
58
|
* @alpha
|
|
58
59
|
*/
|
|
59
60
|
export declare const NetworkParent: (engine: Pick<IEngine, 'defineComponent'>) => LastWriteWinElementSetComponentDefinition<INetowrkParentType>;
|
|
61
|
+
/**
|
|
62
|
+
* @public
|
|
63
|
+
*/
|
|
64
|
+
export declare const CreatedBy: (engine: Pick<IEngine, 'defineComponent'>) => LastWriteWinElementSetComponentDefinition<ICreatedByType>;
|
|
60
65
|
export { MediaState };
|
|
61
66
|
export type { AudioAnalysisView };
|
package/dist/components/index.js
CHANGED
|
@@ -19,6 +19,7 @@ import { defineTriggerAreaComponent } from './extended/TriggerArea';
|
|
|
19
19
|
import { defineParticleSystemComponent } from './extended/ParticleSystem';
|
|
20
20
|
import { defineTouchScreenControlsComponent } from './extended/TouchScreenControls';
|
|
21
21
|
import defineTagsComponent from './manual/Tags';
|
|
22
|
+
import defineCreatedBy from './manual/CreatedBy';
|
|
22
23
|
export * from './generated/index.gen';
|
|
23
24
|
/* @__PURE__ */
|
|
24
25
|
export const Transform = (engine) => defineTransformComponent(engine);
|
|
@@ -65,11 +66,13 @@ export const SyncComponents = (engine) => defineSyncComponent(engine);
|
|
|
65
66
|
/**
|
|
66
67
|
* @alpha
|
|
67
68
|
*/
|
|
68
|
-
/* @__PURE__ */
|
|
69
69
|
export const NetworkEntity = (engine) => defineNetworkEntity(engine);
|
|
70
70
|
/**
|
|
71
71
|
* @alpha
|
|
72
72
|
*/
|
|
73
|
-
/* @__PURE__ */
|
|
74
73
|
export const NetworkParent = (engine) => defineNetworkParent(engine);
|
|
74
|
+
/**
|
|
75
|
+
* @public
|
|
76
|
+
*/
|
|
77
|
+
export const CreatedBy = (engine) => defineCreatedBy(engine);
|
|
75
78
|
export { MediaState };
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { IEngine, LastWriteWinElementSetComponentDefinition } from '../../engine/types';
|
|
2
|
+
export interface ICreatedByType {
|
|
3
|
+
address: string;
|
|
4
|
+
}
|
|
5
|
+
export type ICreatedBy = LastWriteWinElementSetComponentDefinition<ICreatedByType>;
|
|
6
|
+
declare function defineCreatedBy(engine: Pick<IEngine, 'defineComponent'>): import("../../engine/types").MapComponentDefinition<import("../..").MapResult<{
|
|
7
|
+
address: import("../../schemas").ISchema<string>;
|
|
8
|
+
}>>;
|
|
9
|
+
export default defineCreatedBy;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { LastWriteWinElementSetComponentDefinition, IEngine } from '../../engine';
|
|
2
2
|
import { Entity } from '../../engine/entity';
|
|
3
|
+
import type { ISchema } from '../../schemas/ISchema';
|
|
3
4
|
import type { Vector3Type } from '../../schemas/custom/Vector3';
|
|
4
5
|
/**
|
|
5
6
|
* @public
|
|
@@ -24,6 +25,10 @@ export interface TransformComponentExtended extends TransformComponent {
|
|
|
24
25
|
*/
|
|
25
26
|
localToWorldDirection(entity: Entity, localDirection: Vector3Type): Vector3Type;
|
|
26
27
|
}
|
|
28
|
+
/**
|
|
29
|
+
* @public
|
|
30
|
+
*/
|
|
31
|
+
export declare const COMPONENT_ID = 1;
|
|
27
32
|
/**
|
|
28
33
|
* @public
|
|
29
34
|
*/
|
|
@@ -46,6 +51,10 @@ export type TransformType = {
|
|
|
46
51
|
};
|
|
47
52
|
parent?: Entity;
|
|
48
53
|
};
|
|
54
|
+
/** @public */
|
|
55
|
+
export declare const TRANSFORM_LENGTH = 44;
|
|
56
|
+
/** @public */
|
|
57
|
+
export declare const TransformSchema: ISchema<TransformType>;
|
|
49
58
|
/**
|
|
50
59
|
* @public
|
|
51
60
|
*/
|
|
@@ -3,12 +3,12 @@
|
|
|
3
3
|
// getters via __importStar in CJS), so by the time methods are called all exports are available.
|
|
4
4
|
import * as treeHelpers from '../../runtime/helpers/tree';
|
|
5
5
|
/**
|
|
6
|
-
* @
|
|
6
|
+
* @public
|
|
7
7
|
*/
|
|
8
8
|
export const COMPONENT_ID = 1;
|
|
9
|
-
/** @
|
|
9
|
+
/** @public */
|
|
10
10
|
export const TRANSFORM_LENGTH = 44;
|
|
11
|
-
/** @
|
|
11
|
+
/** @public */
|
|
12
12
|
export const TransformSchema = {
|
|
13
13
|
serialize(value, builder) {
|
|
14
14
|
const ptr = builder.incrementWriteOffset(TRANSFORM_LENGTH);
|
|
@@ -13,6 +13,7 @@ export type { TagsComponentDefinitionExtended, TagsType } from './manual/Tags';
|
|
|
13
13
|
export type { ISyncComponents, ISyncComponentsType } from './manual/SyncComponents';
|
|
14
14
|
export type { INetowrkEntity, INetowrkEntityType } from './manual/NetworkEntity';
|
|
15
15
|
export type { INetowrkParent, INetowrkParentType } from './manual/NetworkParent';
|
|
16
|
+
export type { ICreatedBy, ICreatedByType } from './manual/CreatedBy';
|
|
16
17
|
export type { InputModifierHelper, InputModifierComponentDefinitionExtended } from './extended/InputModifier';
|
|
17
18
|
export type { LightSourceHelper, LightSourceComponentDefinitionExtended } from './extended/LightSource';
|
|
18
19
|
export type { TriggerAreaComponentDefinitionExtended } from './extended/TriggerArea';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { ISchema } from '../schemas';
|
|
2
2
|
import { ByteBuffer } from '../serialization/ByteBuffer';
|
|
3
|
-
import { CrdtMessageBody, DeleteComponentMessageBody, PutComponentMessageBody } from '../serialization/crdt';
|
|
3
|
+
import { CrdtMessageBody, DeleteComponentMessageBody, ProcessMessageResultType, PutComponentMessageBody } from '../serialization/crdt';
|
|
4
4
|
import { Entity } from './entity';
|
|
5
5
|
import { DeepReadonly, DeepReadonlySet } from './readonly';
|
|
6
6
|
/**
|
|
@@ -70,7 +70,58 @@ export interface BaseComponent<T> {
|
|
|
70
70
|
* If the value is undefined, the component was deleted.
|
|
71
71
|
*/
|
|
72
72
|
onChange(entity: Entity, cb: (value: T | undefined) => void): void;
|
|
73
|
+
/**
|
|
74
|
+
* @public
|
|
75
|
+
*
|
|
76
|
+
*/
|
|
77
|
+
validateBeforeChange(entity: Entity, cb: ValidateCallback<T>): void;
|
|
78
|
+
validateBeforeChange(cb: ValidateCallback<T>): void;
|
|
79
|
+
/**
|
|
80
|
+
* Get the CRDT state for an entity (serialized data and timestamp)
|
|
81
|
+
* @param entity - Entity to get the CRDT state for
|
|
82
|
+
* @returns Object with serialized data and timestamp, or null if entity doesn't have the component
|
|
83
|
+
* @public
|
|
84
|
+
*/
|
|
85
|
+
getCrdtState(entity: Entity): {
|
|
86
|
+
data: Uint8Array;
|
|
87
|
+
timestamp: number;
|
|
88
|
+
} | null;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Internal component interface that exposes all internal methods for SDK use
|
|
92
|
+
* This is not exposed to users, only for internal SDK operations
|
|
93
|
+
*/
|
|
94
|
+
export interface InternalBaseComponent<T> extends BaseComponent<T> {
|
|
95
|
+
/**
|
|
96
|
+
* @public
|
|
97
|
+
* Dry run update to check if a CRDT message would be accepted without actually applying it
|
|
98
|
+
*/
|
|
99
|
+
__dry_run_updateFromCrdt(body: CrdtMessageBody): ProcessMessageResultType;
|
|
100
|
+
/**
|
|
101
|
+
* @public
|
|
102
|
+
* Get the iterator to every entity has the component
|
|
103
|
+
*/
|
|
104
|
+
iterator(): Iterable<[Entity, any]>;
|
|
105
|
+
/**
|
|
106
|
+
* @public
|
|
107
|
+
*/
|
|
108
|
+
dirtyIterator(): Iterable<Entity>;
|
|
109
|
+
/**
|
|
110
|
+
* @public
|
|
111
|
+
*/
|
|
112
|
+
__onChangeCallbacks(entity: Entity, value: T): void;
|
|
113
|
+
/**
|
|
114
|
+
* @public
|
|
115
|
+
*/
|
|
116
|
+
__run_validateBeforeChange(entity: Entity, newValue: T | undefined, senderAddress: string, createdBy: string): boolean;
|
|
73
117
|
}
|
|
118
|
+
export type ValidateCallback<T> = (value: {
|
|
119
|
+
entity: Entity;
|
|
120
|
+
currentValue: T | undefined;
|
|
121
|
+
newValue: T | undefined;
|
|
122
|
+
senderAddress: string;
|
|
123
|
+
createdBy: string;
|
|
124
|
+
}) => boolean;
|
|
74
125
|
/**
|
|
75
126
|
* @public
|
|
76
127
|
*/
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { ReadWriteByteBuffer } from '../serialization/ByteBuffer';
|
|
2
|
-
import { AppendValueOperation, CrdtMessageType } from '../serialization/crdt';
|
|
2
|
+
import { AppendValueOperation, CrdtMessageType, ProcessMessageResultType } from '../serialization/crdt';
|
|
3
3
|
import { __DEV__ } from '../runtime/invariant';
|
|
4
4
|
const emptyReadonlySet = freezeSet(new Set());
|
|
5
|
+
const __GLOBAL_ENTITY = '__GLOBAL_ENTITY';
|
|
5
6
|
function frozenError() {
|
|
6
7
|
throw new Error('The set is frozen');
|
|
7
8
|
}
|
|
@@ -22,6 +23,7 @@ export function createValueSetComponentDefinitionFromSchema(componentName, compo
|
|
|
22
23
|
const dirtyIterator = new Set();
|
|
23
24
|
const queuedCommands = [];
|
|
24
25
|
const onChangeCallbacks = new Map();
|
|
26
|
+
const validateCallbacks = new Map();
|
|
25
27
|
// only sort the array if the latest (N) element has a timestamp <= N-1
|
|
26
28
|
function shouldSort(row) {
|
|
27
29
|
const len = row.raw.length;
|
|
@@ -80,8 +82,11 @@ export function createValueSetComponentDefinitionFromSchema(componentName, compo
|
|
|
80
82
|
has(entity) {
|
|
81
83
|
return data.has(entity);
|
|
82
84
|
},
|
|
83
|
-
entityDeleted(entity) {
|
|
85
|
+
entityDeleted(entity, markAsDirty) {
|
|
84
86
|
data.delete(entity);
|
|
87
|
+
if (markAsDirty) {
|
|
88
|
+
// For grow-only sets, we don't need to mark as dirty since deletion doesn't generate CRDT messages
|
|
89
|
+
}
|
|
85
90
|
},
|
|
86
91
|
get(entity) {
|
|
87
92
|
const values = data.get(entity);
|
|
@@ -152,6 +157,44 @@ export function createValueSetComponentDefinitionFromSchema(componentName, compo
|
|
|
152
157
|
for (const cb of cbs) {
|
|
153
158
|
cb(value);
|
|
154
159
|
}
|
|
160
|
+
},
|
|
161
|
+
__dry_run_updateFromCrdt(_body) {
|
|
162
|
+
return ProcessMessageResultType.StateUpdatedData;
|
|
163
|
+
},
|
|
164
|
+
validateBeforeChange(entityOrCb, cb) {
|
|
165
|
+
if (arguments.length === 1) {
|
|
166
|
+
// Second overload: just callback (global validation)
|
|
167
|
+
validateCallbacks.set(__GLOBAL_ENTITY, entityOrCb);
|
|
168
|
+
}
|
|
169
|
+
else {
|
|
170
|
+
if (cb) {
|
|
171
|
+
validateCallbacks.set(entityOrCb, cb);
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
},
|
|
175
|
+
__run_validateBeforeChange(entity, newValue, senderAddress, createdBy) {
|
|
176
|
+
const cb = entity && validateCallbacks.get(entity);
|
|
177
|
+
const globalCb = validateCallbacks.get(__GLOBAL_ENTITY);
|
|
178
|
+
const currentValue = [...this.get(entity).values()];
|
|
179
|
+
const value = { entity, currentValue: currentValue, newValue, senderAddress, createdBy };
|
|
180
|
+
const globalResult = globalCb?.(value) ?? true;
|
|
181
|
+
const entityResult = (globalResult && cb?.(value)) ?? true;
|
|
182
|
+
return globalResult && entityResult;
|
|
183
|
+
},
|
|
184
|
+
getCrdtState(entity) {
|
|
185
|
+
const row = data.get(entity);
|
|
186
|
+
if (!row || row.raw.length === 0) {
|
|
187
|
+
return null;
|
|
188
|
+
}
|
|
189
|
+
// For GrowOnlySet, we need to return the complete CRDT messages for all values
|
|
190
|
+
// This is complex because GrowOnlySet uses APPEND messages, not a single PUT
|
|
191
|
+
// For now, return null to indicate this component type doesn't support simple corrections
|
|
192
|
+
return null;
|
|
193
|
+
},
|
|
194
|
+
__forceUpdateFromCrdt(_msg) {
|
|
195
|
+
// GrowOnlySet doesn't support authoritative corrections in the same way as LWW
|
|
196
|
+
// since it uses APPEND_VALUE messages instead of PUT_COMPONENT messages
|
|
197
|
+
return [null, undefined];
|
|
155
198
|
}
|
|
156
199
|
};
|
|
157
200
|
return ret;
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { ISchema } from '../schemas';
|
|
2
2
|
import { ByteBuffer } from '../serialization/ByteBuffer';
|
|
3
|
-
import { PutComponentMessageBody, DeleteComponentMessageBody, CrdtMessageBody } from '../serialization/crdt';
|
|
3
|
+
import { PutComponentMessageBody, DeleteComponentMessageBody, ProcessMessageResultType, CrdtMessageBody, PutNetworkComponentMessageBody, DeleteComponentNetworkMessageBody, AuthoritativePutComponentMessageBody } from '../serialization/crdt';
|
|
4
4
|
import { Entity } from './entity';
|
|
5
5
|
export declare function incrementTimestamp(entity: Entity, timestamps: Map<Entity, number>): number;
|
|
6
6
|
export declare function createDumpLwwFunctionFromCrdt(componentId: number, timestamps: Map<Entity, number>, schema: Pick<ISchema<any>, 'serialize' | 'deserialize'>, data: Map<Entity, unknown>): (buffer: ByteBuffer, filterEntity?: ((entity: Entity) => boolean) | undefined) => void;
|
|
7
|
+
export declare function createCrdtRuleValidator(timestamps: Map<Entity, number>, schema: Pick<ISchema<any>, 'serialize' | 'deserialize'>, data: Map<Entity, unknown>, lastSentData: Map<Entity, Uint8Array>): (message: PutComponentMessageBody | DeleteComponentMessageBody | PutNetworkComponentMessageBody | DeleteComponentNetworkMessageBody) => ProcessMessageResultType;
|
|
8
|
+
export declare function createForceUpdateLwwFromCrdt(componentId: number, timestamps: Map<Entity, number>, schema: Pick<ISchema<any>, 'serialize' | 'deserialize'>, data: Map<Entity, unknown>): (msg: AuthoritativePutComponentMessageBody) => [null, any];
|
|
7
9
|
export declare function createUpdateLwwFromCrdt(componentId: number, timestamps: Map<Entity, number>, schema: Pick<ISchema<any>, 'serialize' | 'deserialize'>, data: Map<Entity, unknown>, lastSentData: Map<Entity, Uint8Array>): (msg: CrdtMessageBody) => [null | PutComponentMessageBody | DeleteComponentMessageBody, any];
|
|
8
10
|
export declare function createGetCrdtMessagesForLww(componentId: number, timestamps: Map<Entity, number>, dirtyIterator: Set<Entity>, schema: Pick<ISchema<any>, 'serialize'>, data: Map<Entity, unknown>, lastSentData: Map<Entity, Uint8Array>): () => Generator<PutComponentMessageBody | DeleteComponentMessageBody, void, unknown>;
|
|
@@ -30,16 +30,12 @@ export function createDumpLwwFunctionFromCrdt(componentId, timestamps, schema, d
|
|
|
30
30
|
}
|
|
31
31
|
};
|
|
32
32
|
}
|
|
33
|
-
|
|
33
|
+
const __GLOBAL_ENTITY = '__GLOBAL_ENTITY';
|
|
34
|
+
export function createCrdtRuleValidator(timestamps, schema, data, lastSentData) {
|
|
34
35
|
/**
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
* Returns the recieved data if the lamport number was bigger than ours.
|
|
40
|
-
* If it was an outdated message, then we return void
|
|
41
|
-
* @public
|
|
42
|
-
*/
|
|
36
|
+
* Shared CRDT conflict resolution logic
|
|
37
|
+
* @public
|
|
38
|
+
*/
|
|
43
39
|
function crdtRuleForCurrentState(message) {
|
|
44
40
|
const { entityId, timestamp } = message;
|
|
45
41
|
const currentTimestamp = timestamps.get(entityId);
|
|
@@ -49,7 +45,6 @@ export function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, l
|
|
|
49
45
|
}
|
|
50
46
|
// Outdated Message. Resend our state message through the wire.
|
|
51
47
|
if (currentTimestamp > timestamp) {
|
|
52
|
-
// console.log('2', currentTimestamp, timestamp)
|
|
53
48
|
return ProcessMessageResultType.StateOutdatedTimestamp;
|
|
54
49
|
}
|
|
55
50
|
// Deletes are idempotent
|
|
@@ -66,7 +61,6 @@ export function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, l
|
|
|
66
61
|
currentDataGreater = dataCompare(null, message.data);
|
|
67
62
|
}
|
|
68
63
|
// Same data, same timestamp. Weirdo echo message.
|
|
69
|
-
// console.log('3', currentDataGreater, writeBuffer.toBinary(), (message as any).data || null)
|
|
70
64
|
if (currentDataGreater === 0) {
|
|
71
65
|
return ProcessMessageResultType.NoChanges;
|
|
72
66
|
}
|
|
@@ -75,10 +69,35 @@ export function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, l
|
|
|
75
69
|
return ProcessMessageResultType.StateOutdatedData;
|
|
76
70
|
}
|
|
77
71
|
else {
|
|
78
|
-
//
|
|
72
|
+
// Current data is lower
|
|
79
73
|
return ProcessMessageResultType.StateUpdatedData;
|
|
80
74
|
}
|
|
81
75
|
}
|
|
76
|
+
return crdtRuleForCurrentState;
|
|
77
|
+
}
|
|
78
|
+
export function createForceUpdateLwwFromCrdt(componentId, timestamps, schema, data) {
|
|
79
|
+
/**
|
|
80
|
+
* Force update component state regardless of timestamp - used for server authoritative messages
|
|
81
|
+
*/
|
|
82
|
+
return (msg) => {
|
|
83
|
+
const buffer = new ReadWriteByteBuffer(msg.data);
|
|
84
|
+
const deserializedValue = schema.deserialize(buffer);
|
|
85
|
+
data.set(msg.entityId, deserializedValue);
|
|
86
|
+
timestamps.set(msg.entityId, msg.timestamp);
|
|
87
|
+
return [null, deserializedValue];
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
export function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, lastSentData) {
|
|
91
|
+
/**
|
|
92
|
+
* Process the received message only if the lamport number recieved is higher
|
|
93
|
+
* than the stored one. If its lower, we spread it to the network to correct the peer.
|
|
94
|
+
* If they are equal, the bigger raw data wins.
|
|
95
|
+
|
|
96
|
+
* Returns the recieved data if the lamport number was bigger than ours.
|
|
97
|
+
* If it was an outdated message, then we return void
|
|
98
|
+
* @public
|
|
99
|
+
*/
|
|
100
|
+
const crdtRuleForCurrentState = createCrdtRuleValidator(timestamps, schema, data, lastSentData);
|
|
82
101
|
return (msg) => {
|
|
83
102
|
/* istanbul ignore next */
|
|
84
103
|
if (msg.type !== CrdtMessageType.PUT_COMPONENT &&
|
|
@@ -96,7 +115,10 @@ export function createUpdateLwwFromCrdt(componentId, timestamps, schema, data, l
|
|
|
96
115
|
if (msg.type === CrdtMessageType.PUT_COMPONENT || msg.type === CrdtMessageType.PUT_COMPONENT_NETWORK) {
|
|
97
116
|
const buf = new ReadWriteByteBuffer(msg.data);
|
|
98
117
|
data.set(entity, schema.deserialize(buf));
|
|
99
|
-
lastSentData
|
|
118
|
+
// do NOT seed lastSentData from an INCOMING message!!!!
|
|
119
|
+
// seeding it from received bytes makes the engine
|
|
120
|
+
// believe it already sent this state, which kills valid re-broadcasting 🧨
|
|
121
|
+
lastSentData.delete(entity);
|
|
100
122
|
}
|
|
101
123
|
else {
|
|
102
124
|
data.delete(entity);
|
|
@@ -185,6 +207,7 @@ export function createComponentDefinitionFromSchema(componentName, componentId,
|
|
|
185
207
|
const timestamps = new Map();
|
|
186
208
|
const lastSentData = new Map();
|
|
187
209
|
const onChangeCallbacks = new Map();
|
|
210
|
+
const validateCallbacks = new Map();
|
|
188
211
|
return {
|
|
189
212
|
get componentId() {
|
|
190
213
|
return componentId;
|
|
@@ -285,7 +308,39 @@ export function createComponentDefinitionFromSchema(componentName, componentId,
|
|
|
285
308
|
},
|
|
286
309
|
getCrdtUpdates: createGetCrdtMessagesForLww(componentId, timestamps, dirtyIterator, schema, data, lastSentData),
|
|
287
310
|
updateFromCrdt: createUpdateLwwFromCrdt(componentId, timestamps, schema, data, lastSentData),
|
|
311
|
+
__forceUpdateFromCrdt: createForceUpdateLwwFromCrdt(componentId, timestamps, schema, data),
|
|
312
|
+
__dry_run_updateFromCrdt: createCrdtRuleValidator(timestamps, schema, data, lastSentData),
|
|
288
313
|
dumpCrdtStateToBuffer: createDumpLwwFunctionFromCrdt(componentId, timestamps, schema, data),
|
|
314
|
+
validateBeforeChange(entityOrCb, cb) {
|
|
315
|
+
if (arguments.length === 1) {
|
|
316
|
+
// Second overload: just callback (global validation)
|
|
317
|
+
validateCallbacks.set(__GLOBAL_ENTITY, entityOrCb);
|
|
318
|
+
}
|
|
319
|
+
else {
|
|
320
|
+
if (cb) {
|
|
321
|
+
validateCallbacks.set(entityOrCb, cb);
|
|
322
|
+
}
|
|
323
|
+
}
|
|
324
|
+
},
|
|
325
|
+
__run_validateBeforeChange(entity, newValue, senderAddress, createdBy) {
|
|
326
|
+
const cb = entity && validateCallbacks.get(entity);
|
|
327
|
+
const globalCb = validateCallbacks.get(__GLOBAL_ENTITY);
|
|
328
|
+
const currentValue = data.get(entity);
|
|
329
|
+
const value = { entity, currentValue, newValue, senderAddress, createdBy };
|
|
330
|
+
const globalResult = globalCb?.(value) ?? true;
|
|
331
|
+
const entityResult = (globalResult && cb?.(value)) ?? true;
|
|
332
|
+
return globalResult && entityResult;
|
|
333
|
+
},
|
|
334
|
+
getCrdtState(entity) {
|
|
335
|
+
const componentData = data.get(entity);
|
|
336
|
+
const timestamp = timestamps.get(entity);
|
|
337
|
+
if (componentData && timestamp !== undefined) {
|
|
338
|
+
const buffer = new ReadWriteByteBuffer();
|
|
339
|
+
schema.serialize(deepReadonly(componentData), buffer);
|
|
340
|
+
return { data: buffer.toBinary(), timestamp };
|
|
341
|
+
}
|
|
342
|
+
return null;
|
|
343
|
+
},
|
|
289
344
|
onChange(entity, cb) {
|
|
290
345
|
const cbs = onChangeCallbacks.get(entity) ?? [];
|
|
291
346
|
cbs.push(cb);
|
package/dist/index.d.ts
CHANGED
|
@@ -16,7 +16,7 @@ export * from './systems/triggerArea';
|
|
|
16
16
|
export * from './systems/physics';
|
|
17
17
|
export * from './engine/entity';
|
|
18
18
|
export * from './components/types';
|
|
19
|
-
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, AudioSourceComponentDefinitionExtended, AudioAnalysisComponentDefinitionExtended, AudioStreamComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent, VirtualCameraComponentDefinitionExtended, InputModifierComponentDefinitionExtended, LightSourceComponentDefinitionExtended, TriggerAreaComponentDefinitionExtended, ParticleSystemComponentDefinitionExtended, TouchScreenControlsComponentDefinitionExtended } from './components/types';
|
|
19
|
+
import { MaterialComponentDefinitionExtended, MeshColliderComponentDefinitionExtended, MeshRendererComponentDefinitionExtended, TransformComponentExtended, AnimatorComponentDefinitionExtended, AudioSourceComponentDefinitionExtended, AudioAnalysisComponentDefinitionExtended, AudioStreamComponentDefinitionExtended, ISyncComponents, TweenComponentDefinitionExtended, INetowrkEntity, INetowrkParent, VirtualCameraComponentDefinitionExtended, InputModifierComponentDefinitionExtended, LightSourceComponentDefinitionExtended, TriggerAreaComponentDefinitionExtended, ParticleSystemComponentDefinitionExtended, ICreatedBy, TouchScreenControlsComponentDefinitionExtended } from './components/types';
|
|
20
20
|
import { NameComponent } from './components/manual/Name';
|
|
21
21
|
import { TagsComponentDefinitionExtended } from './components/manual/Tags';
|
|
22
22
|
export declare const Transform: TransformComponentExtended;
|
|
@@ -52,6 +52,7 @@ export declare const NetworkEntity: INetowrkEntity;
|
|
|
52
52
|
* Tag a entity to be syncronized through comms
|
|
53
53
|
*/
|
|
54
54
|
export declare const NetworkParent: INetowrkParent;
|
|
55
|
+
export declare const CreatedBy: ICreatedBy;
|
|
55
56
|
export * from './components/generated/global.gen';
|
|
56
57
|
export * from './components/generated/types.gen';
|
|
57
58
|
export * from './serialization/crdt';
|
package/dist/index.js
CHANGED
|
@@ -58,6 +58,7 @@ export const NetworkEntity = /* @__PURE__*/ components.NetworkEntity(engine);
|
|
|
58
58
|
* Tag a entity to be syncronized through comms
|
|
59
59
|
*/
|
|
60
60
|
export const NetworkParent = /* @__PURE__*/ components.NetworkParent(engine);
|
|
61
|
+
export const CreatedBy = /* @__PURE__*/ components.CreatedBy(engine);
|
|
61
62
|
// export components for global engine
|
|
62
63
|
export * from './components/generated/global.gen';
|
|
63
64
|
export * from './components/generated/types.gen';
|