Skip to content

Commit 6d2ec97

Browse files
authored
refactor observables. (#928)
* refactor observables: use systems & components instead of sendBatch events * add realminfo & playerclicked component * add missing observables * add fallback to sdk6 obserables pollEvents * add missing comms * replace player clicked with ponterevents * fix build * add tests * remove non used code * update protocol version * add fallback support because renderer release
1 parent 3236fa6 commit 6d2ec97

File tree

10 files changed

+235
-578
lines changed

10 files changed

+235
-578
lines changed

package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"bugs": "https://github.com/decentraland/js-sdk-toolchain/issues",
77
"dependencies": {
88
"@actions/core": "^1.10.0",
9-
"@dcl/protocol": "^1.0.0-8691799990.commit-4ba546c",
9+
"@dcl/protocol": "1.0.0-8758013256.commit-44aab53",
1010
"@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1",
1111
"@dcl/ts-proto": "1.153.0",
1212
"@types/fs-extra": "^9.0.12",

packages/@dcl/playground-assets/etc/playground-assets.api.md

Lines changed: 28 additions & 143 deletions
Original file line numberDiff line numberDiff line change
@@ -564,6 +564,7 @@ export const componentDefinitionByName: {
564564
"core::PointerLock": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBPointerLock>>;
565565
"core::Raycast": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBRaycast>>;
566566
"core::RaycastResult": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBRaycastResult>>;
567+
"core::RealmInfo": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBRealmInfo>>;
567568
"core::TextShape": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTextShape>>;
568569
"core::Tween": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTween>>;
569570
"core::TweenSequence": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBTweenSequence>>;
@@ -982,12 +983,6 @@ export function Engine(options?: IEngineOptions): IEngine;
982983
// @public
983984
export const engine: IEngine;
984985

985-
// @public (undocumented)
986-
export type EngineEvent<T extends IEventNames = IEventNames, V = IEvents[T]> = {
987-
type: T;
988-
data: Readonly<V>;
989-
};
990-
991986
// @public (undocumented)
992987
export const EngineInfo: LastWriteWinElementSetComponentDefinition<PBEngineInfo>;
993988

@@ -1097,24 +1092,6 @@ export function getComponentEntityTree<T>(engine: Pick<IEngine, 'getEntitiesWith
10971092
// @public @deprecated (undocumented)
10981093
export function getCompositeRootComponent(engine: IEngine): LastWriteWinElementSetComponentDefinition<CompositeRootType>;
10991094

1100-
// @public (undocumented)
1101-
export type GizmoDragEndEvent = {
1102-
type: 'gizmoDragEnded';
1103-
transforms: Array<{
1104-
position: Vector3Type;
1105-
rotation: QuaternionType;
1106-
scale: Vector3Type;
1107-
entityId: unknown;
1108-
}>;
1109-
};
1110-
1111-
// @public (undocumented)
1112-
export type GizmoSelectedEvent = {
1113-
type: 'gizmoSelected';
1114-
gizmoType: 'MOVE' | 'ROTATE' | 'SCALE' | 'NONE';
1115-
entities: string[];
1116-
};
1117-
11181095
// Warning: (ae-missing-release-tag) "GlobalDirectionRaycastOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
11191096
//
11201097
// @public (undocumented)
@@ -1127,11 +1104,6 @@ export type GlobalDirectionRaycastSystemOptions = {
11271104
direction?: PBVector3;
11281105
};
11291106

1130-
// @public (undocumented)
1131-
export type GlobalInputEventResult = InputEventResult & {
1132-
type: 0 | 1;
1133-
};
1134-
11351107
// Warning: (ae-missing-release-tag) "GlobalTargetRaycastOptions" is part of the package's API, but it is missing a release tag (@alpha, @beta, @public, or @internal)
11361108
//
11371109
// @public (undocumented)
@@ -1219,88 +1191,22 @@ export type IEventNames = keyof IEvents;
12191191

12201192
// @public
12211193
export interface IEvents {
1222-
actionButtonEvent: GlobalInputEventResult;
1223-
builderSceneStart: unknown;
1224-
builderSceneUnloaded: unknown;
1225-
cameraModeChanged: {
1226-
cameraMode: 0 | 1 | 2;
1227-
};
1228-
chatMessage: {
1229-
id: string;
1230-
sender: string;
1231-
message: string;
1232-
isCommand: boolean;
1233-
};
12341194
comms: {
12351195
sender: string;
12361196
message: string;
12371197
};
1238-
entitiesOutOfBoundaries: {
1239-
entities: string[];
1240-
};
1241-
entityBackInScene: {
1242-
entityId: unknown;
1243-
};
1244-
entityOutOfScene: {
1245-
entityId: unknown;
1246-
};
1247-
// (undocumented)
1248-
externalAction: {
1249-
type: string;
1250-
[key: string]: any;
1251-
};
1252-
gizmoEvent: GizmoDragEndEvent | GizmoSelectedEvent;
1253-
idleStateChanged: {
1254-
isIdle: boolean;
1255-
};
1256-
// (undocumented)
1257-
limitsExceeded: {
1258-
given: Record<string, number>;
1259-
limit: Record<string, number>;
1260-
};
1261-
// (undocumented)
1262-
metricsUpdate: {
1263-
given: Record<string, number>;
1264-
limit: Record<string, number>;
1265-
};
1266-
onAnimationEnd: {
1267-
clipName: string;
1268-
};
1269-
onBlur: {
1270-
entityId: unknown;
1271-
pointerId: number;
1272-
};
1273-
onChange: {
1274-
value?: any;
1275-
pointerId?: number;
1276-
};
1277-
onClick: {
1278-
entityId: unknown;
1279-
};
1280-
onEnter: unknown;
12811198
onEnterScene: {
12821199
userId: string;
12831200
};
1284-
onFocus: {
1285-
entityId: unknown;
1286-
pointerId: number;
1287-
};
12881201
onLeaveScene: {
12891202
userId: string;
12901203
};
1291-
onPointerLock: {
1292-
locked?: boolean;
1293-
};
12941204
onRealmChanged: {
12951205
domain: string;
12961206
room: string;
12971207
serverName: string;
12981208
displayName: string;
12991209
};
1300-
// (undocumented)
1301-
onTextSubmit: {
1302-
text: string;
1303-
};
13041210
playerClicked: {
13051211
userId: string;
13061212
ray: {
@@ -1319,37 +1225,11 @@ export interface IEvents {
13191225
playerExpression: {
13201226
expressionId: string;
13211227
};
1322-
pointerDown: InputEventResult;
1323-
// @deprecated
1324-
pointerEvent: GlobalInputEventResult;
1325-
pointerHoverEnter: unknown;
1326-
pointerHoverExit: unknown;
1327-
pointerUp: InputEventResult;
1328-
positionChanged: {
1329-
position: Vector3Type;
1330-
cameraPosition: Vector3Type;
1331-
playerHeight: number;
1332-
};
13331228
profileChanged: {
13341229
ethAddress: string;
13351230
version: number;
13361231
};
1337-
raycastResponse: RaycastResponsePayload<any>;
1338-
rotationChanged: {
1339-
rotation: Vector3Type;
1340-
quaternion: QuaternionType;
1341-
};
13421232
sceneStart: unknown;
1343-
// (undocumented)
1344-
stateEvent: {
1345-
type: string;
1346-
payload: any;
1347-
};
1348-
// (undocumented)
1349-
uuidEvent: {
1350-
uuid: string;
1351-
payload: any;
1352-
};
13531233
videoEvent: {
13541234
componentId: string;
13551235
videoClipId: string;
@@ -1460,21 +1340,6 @@ export const enum InputAction {
14601340
IA_WALK = 9
14611341
}
14621342

1463-
// @public (undocumented)
1464-
export type InputEventResult = {
1465-
origin: Vector3Type;
1466-
direction: Vector3Type;
1467-
buttonId: number;
1468-
hit?: {
1469-
length: number;
1470-
hitPoint: Vector3Type;
1471-
meshName: string;
1472-
normal: Vector3Type;
1473-
worldNormal: Vector3Type;
1474-
entityId: unknown;
1475-
};
1476-
};
1477-
14781343
// @public
14791344
export const inputSystem: IInputSystem;
14801345

@@ -2800,6 +2665,30 @@ export namespace PBRaycastResult {
28002665
export function encode(message: PBRaycastResult, writer?: _m0.Writer): _m0.Writer;
28012666
}
28022667

2668+
// @public (undocumented)
2669+
export interface PBRealmInfo {
2670+
// (undocumented)
2671+
baseUrl: string;
2672+
// (undocumented)
2673+
commsAdapter: string;
2674+
// (undocumented)
2675+
isPreview: boolean;
2676+
// (undocumented)
2677+
networkId: number;
2678+
// (undocumented)
2679+
realmName: string;
2680+
// (undocumented)
2681+
room?: string | undefined;
2682+
}
2683+
2684+
// @public (undocumented)
2685+
export namespace PBRealmInfo {
2686+
// (undocumented)
2687+
export function decode(input: _m0.Reader | Uint8Array, length?: number): PBRealmInfo;
2688+
// (undocumented)
2689+
export function encode(message: PBRealmInfo, writer?: _m0.Writer): _m0.Writer;
2690+
}
2691+
28032692
// @public (undocumented)
28042693
export interface PBTextShape {
28052694
font?: Font | undefined;
@@ -3464,13 +3353,6 @@ export const enum RaycastQueryType {
34643353
RQT_QUERY_ALL = 1
34653354
}
34663355

3467-
// @public (undocumented)
3468-
export type RaycastResponsePayload<T> = {
3469-
queryId: string;
3470-
queryType: string;
3471-
payload: T;
3472-
};
3473-
34743356
// @public (undocumented)
34753357
export const RaycastResult: LastWriteWinElementSetComponentDefinition<PBRaycastResult>;
34763358

@@ -3566,6 +3448,9 @@ export type ReadOnlyLastWriteWinElementSetComponentDefinition<T> = Omit<LastWrit
35663448
// @public (undocumented)
35673449
export type ReadonlyPrimitive = number | string | number[] | string[] | boolean | boolean[];
35683450

3451+
// @public (undocumented)
3452+
export const RealmInfo: LastWriteWinElementSetComponentDefinition<PBRealmInfo>;
3453+
35693454
// @public (undocumented)
35703455
export type ReceiveMessage = CrdtMessageBody & {
35713456
transportId?: number;

packages/@dcl/sdk-commands/package-lock.json

Lines changed: 7 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/@dcl/sdk-commands/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@dcl/inspector": "file:../inspector",
1414
"@dcl/linker-dapp": "^0.12.0",
1515
"@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be",
16-
"@dcl/protocol": "^1.0.0-8691799990.commit-4ba546c",
16+
"@dcl/protocol": "1.0.0-8758013256.commit-44aab53",
1717
"@dcl/quests-client": "^1.0.3",
1818
"@dcl/quests-manager": "^0.1.4",
1919
"@dcl/rpc": "^1.1.1",

packages/@dcl/sdk/src/internal/transports/rendererTransport.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export function createRendererTransport(engineApi: EngineApiForTransport): Trans
1111
const response = await engineApi.crdtSendToRenderer({
1212
data: new Uint8Array(message)
1313
})
14-
1514
if (response && response.data && response.data.length) {
1615
if (rendererTransport.onmessage) {
1716
for (const byteArray of response.data) {

0 commit comments

Comments
 (0)