Skip to content

Commit fc8cfc6

Browse files
authored
feat: add ExplorerUiEventsResult component and share the ExplorerUi enum (#1511)
Round 2 of scene-triggered explorer UI. Round 1 (#1503) gave scenes `openExplorerUi`; this adds the result channel, so a scene can observe when the panel it opened is actually shown or dismissed. Depends on decentraland/protocol#455 — **do not merge before it**. ## What changes - `ExplorerUiEventsResult` is registered in `GROWN_ONLY_COMPONENTS`, so it generates as a grow-only value set (`APPEND`) rather than LWW, matching `PointerEventsResult` and friends. The generated `maxElements: 100` lines up with the explorer's `MAX_APPEND_COMPONENTS_COUNT`. - `~system/RestrictedActions` no longer re-declares `ExplorerUi`. The enum moved to `sdk/components/common/explorer_ui.proto` upstream, so `apis.d.ts` now reads `ui: import('../ecs').ExplorerUi` and scene code sees a single nominal type: ```ts for (const e of ExplorerUiEventsResult.get(engine.RootEntity)) { if (e.ui === ExplorerUi.EU_MAP) { /* no cast needed */ } } ``` - Regenerated: `playground-assets.api.md`, 12 CRDT snapshots, three lockfiles. - New: `test/ecs/components/ExplorerUiEventsResult.spec.ts` (3 tests). The accumulation test is a deliberate guard — the serialization tests alone would still pass if the `GROWN_ONLY_COMPONENTS` entry were dropped. ## Before merging - [ ] decentraland/protocol#455 merged - [ ] `@dcl/protocol` repinned from the PR tarball to the published version, lockfiles refreshed, snapshots and `api.md` regenerated The pin is currently a tarball URL in both `package.json` and `packages/@dcl/sdk-commands/package.json`, because PR builds are not published to npm. It carries one unrelated delta into `api.md` — `AvatarEmoteMask`, from `avatar_shape.proto` — which disappears on repin. ## Verification Locally: `make build` exit 0 (38/38, including the `check no conflict in types` and `ae-forgotten-export` gates); snapshot comparison 17/17. `make test` on this Windows checkout reports 12 failures in `test/ecs/composite.spec.ts` plus 3 jest timeouts in sdk-commands. The composite failures are a CRLF artifact: the fixtures are `i/lf w/crlf` under `core.autocrlf=true`, and `composite.spec.ts` compares without the `\r\n` normalization that `snapshots.spec.ts` applies. No `ExplorerUi` line appears in any of those diffs and this branch touches no fixture. CI on Linux is the real signal. ## Follow-up `openExplorerUiAndWaitClose` — a promise-based helper wrapping the call and its matching result event — is a separate PR.
1 parent f858f90 commit fc8cfc6

20 files changed

Lines changed: 216 additions & 98 deletions

package-lock.json

Lines changed: 4 additions & 34 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
@@ -9,7 +9,7 @@
99
"@babel/plugin-transform-modules-commonjs": "^7.28.5",
1010
"@babel/plugin-transform-react-jsx": "^7.28.5",
1111
"@babel/preset-typescript": "^7.28.5",
12-
"@dcl/protocol": "1.0.0-31211128817.commit-215d09c",
12+
"@dcl/protocol": "1.0.0-31617402096.commit-86c4613",
1313
"@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1",
1414
"@dcl/ts-proto": "1.153.0",
1515
"@types/fs-extra": "^9.0.12",

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

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -726,6 +726,7 @@ export const componentDefinitionByName: {
726726
"core::CameraMode": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBCameraMode>>;
727727
"core::CameraModeArea": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBCameraModeArea>>;
728728
"core::EngineInfo": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBEngineInfo>>;
729+
"core::ExplorerUiEventsResult": GSetComponentGetter<GrowOnlyValueSetComponentDefinition<PBExplorerUiEventsResult>>;
729730
"core::GltfContainer": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfContainer>>;
730731
"core::GltfContainerLoadingState": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfContainerLoadingState>>;
731732
"core::GltfNodeModifiers": LwwComponentGetter<LastWriteWinElementSetComponentDefinition<PBGltfNodeModifiers>>;
@@ -1278,6 +1279,27 @@ export type ExcludeUndefined<T> = {
12781279
// @public
12791280
export const executeTask: (task: Task<unknown>) => void;
12801281

1282+
// @public (undocumented)
1283+
export const enum ExplorerUi {
1284+
// (undocumented)
1285+
EU_BACKPACK = 2,
1286+
// (undocumented)
1287+
EU_CAMERA_REEL = 3,
1288+
// (undocumented)
1289+
EU_COMMUNITIES = 4,
1290+
// (undocumented)
1291+
EU_EVENTS = 6,
1292+
// (undocumented)
1293+
EU_MAP = 1,
1294+
// (undocumented)
1295+
EU_PLACES = 5,
1296+
// (undocumented)
1297+
EU_SETTINGS = 0
1298+
}
1299+
1300+
// @public (undocumented)
1301+
export const ExplorerUiEventsResult: GrowOnlyValueSetComponentDefinition<PBExplorerUiEventsResult>;
1302+
12811303
// @public
12821304
export interface FlatMaterial {
12831305
albedoColor: PBColor4 | undefined;
@@ -2747,6 +2769,52 @@ export namespace PBEngineInfo {
27472769
export function encode(message: PBEngineInfo, writer?: _m0.Writer): _m0.Writer;
27482770
}
27492771

2772+
// @public (undocumented)
2773+
export interface PBExplorerUiEventsResult {
2774+
// (undocumented)
2775+
event?: {
2776+
$case: "opened";
2777+
opened: PBExplorerUiEventsResult_UiOpened;
2778+
} | {
2779+
$case: "closed";
2780+
closed: PBExplorerUiEventsResult_UiClosed;
2781+
} | undefined;
2782+
timestamp: number;
2783+
ui: ExplorerUi;
2784+
}
2785+
2786+
// @public (undocumented)
2787+
export namespace PBExplorerUiEventsResult {
2788+
// (undocumented)
2789+
export function decode(input: _m0.Reader | Uint8Array, length?: number): PBExplorerUiEventsResult;
2790+
// (undocumented)
2791+
export function encode(message: PBExplorerUiEventsResult, writer?: _m0.Writer): _m0.Writer;
2792+
}
2793+
2794+
// @public (undocumented)
2795+
export interface PBExplorerUiEventsResult_UiClosed {
2796+
}
2797+
2798+
// @public (undocumented)
2799+
export namespace PBExplorerUiEventsResult_UiClosed {
2800+
// (undocumented)
2801+
export function decode(input: _m0.Reader | Uint8Array, length?: number): PBExplorerUiEventsResult_UiClosed;
2802+
// (undocumented)
2803+
export function encode(_: PBExplorerUiEventsResult_UiClosed, writer?: _m0.Writer): _m0.Writer;
2804+
}
2805+
2806+
// @public (undocumented)
2807+
export interface PBExplorerUiEventsResult_UiOpened {
2808+
}
2809+
2810+
// @public (undocumented)
2811+
export namespace PBExplorerUiEventsResult_UiOpened {
2812+
// (undocumented)
2813+
export function decode(input: _m0.Reader | Uint8Array, length?: number): PBExplorerUiEventsResult_UiOpened;
2814+
// (undocumented)
2815+
export function encode(_: PBExplorerUiEventsResult_UiOpened, writer?: _m0.Writer): _m0.Writer;
2816+
}
2817+
27502818
// @public (undocumented)
27512819
export interface PBGltfContainer {
27522820
invisibleMeshesCollisionMask?: number | undefined;

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

Lines changed: 4 additions & 4 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
@@ -14,7 +14,7 @@
1414
"@dcl/inspector": "7.36.3",
1515
"@dcl/linker-dapp": "0.15.2",
1616
"@dcl/mini-comms": "1.0.1-20230216163137.commit-a4c75be",
17-
"@dcl/protocol": "1.0.0-31211128817.commit-215d09c",
17+
"@dcl/protocol": "1.0.0-31617402096.commit-86c4613",
1818
"@dcl/quests-client": "^1.0.3",
1919
"@dcl/quests-manager": "^0.1.4",
2020
"@dcl/rpc": "^1.1.1",

scripts/protocol-buffer-generation/generateIndex.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ function exportComponent(component: Component) {
1515
return `export * from './pb/decentraland/sdk/components/${component.componentFile}.gen'`
1616
}
1717

18-
const GROWN_ONLY_COMPONENTS = ['PointerEventsResult', 'VideoEvent', 'AvatarEmoteCommand', 'AudioEvent', 'TriggerAreaResult', 'AssetLoadLoadingState']
18+
const GROWN_ONLY_COMPONENTS = ['PointerEventsResult', 'VideoEvent', 'AvatarEmoteCommand', 'AudioEvent', 'TriggerAreaResult', 'AssetLoadLoadingState', 'ExplorerUiEventsResult']
1919
function isGrowOnlyValueSet(component: Component): boolean {
2020
return GROWN_ONLY_COMPONENTS.includes(component.componentPascalName)
2121
}
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
import { components, Engine, ExplorerUi } from '../../../packages/@dcl/ecs/src'
2+
import { testSchemaSerializationIdentity } from './assertion'
3+
4+
describe('Generated ExplorerUiEventsResult ProtoBuf', () => {
5+
it('should serialize', () => {
6+
const newEngine = Engine()
7+
const ExplorerUiEventsResult = components.ExplorerUiEventsResult(newEngine)
8+
9+
testSchemaSerializationIdentity(ExplorerUiEventsResult.schema, {
10+
ui: ExplorerUi.EU_MAP,
11+
timestamp: 10,
12+
event: { $case: 'opened', opened: {} }
13+
})
14+
15+
testSchemaSerializationIdentity(ExplorerUiEventsResult.schema, {
16+
ui: ExplorerUi.EU_MAP,
17+
timestamp: 20,
18+
event: { $case: 'closed', closed: {} }
19+
})
20+
21+
testSchemaSerializationIdentity(ExplorerUiEventsResult.schema, {
22+
ui: ExplorerUi.EU_SETTINGS,
23+
timestamp: 30,
24+
event: { $case: 'opened', opened: {} }
25+
})
26+
27+
testSchemaSerializationIdentity(ExplorerUiEventsResult.schema, {
28+
ui: ExplorerUi.EU_EVENTS,
29+
timestamp: 40,
30+
event: undefined
31+
})
32+
33+
testSchemaSerializationIdentity(ExplorerUiEventsResult.schema, ExplorerUiEventsResult.schema.create())
34+
})
35+
36+
it('should serialize every ExplorerUi panel', () => {
37+
const newEngine = Engine()
38+
const ExplorerUiEventsResult = components.ExplorerUiEventsResult(newEngine)
39+
40+
const panels = [
41+
ExplorerUi.EU_SETTINGS,
42+
ExplorerUi.EU_MAP,
43+
ExplorerUi.EU_BACKPACK,
44+
ExplorerUi.EU_CAMERA_REEL,
45+
ExplorerUi.EU_COMMUNITIES,
46+
ExplorerUi.EU_PLACES,
47+
ExplorerUi.EU_EVENTS
48+
]
49+
50+
for (const ui of panels) {
51+
testSchemaSerializationIdentity(ExplorerUiEventsResult.schema, {
52+
ui,
53+
timestamp: ui + 1,
54+
event: { $case: 'opened', opened: {} }
55+
})
56+
}
57+
})
58+
59+
it('should accumulate appended values on the grow only value set', () => {
60+
const newEngine = Engine()
61+
const ExplorerUiEventsResult = components.ExplorerUiEventsResult(newEngine)
62+
const entity = newEngine.addEntity()
63+
64+
ExplorerUiEventsResult.addValue(entity, {
65+
ui: ExplorerUi.EU_BACKPACK,
66+
timestamp: 1,
67+
event: { $case: 'opened', opened: {} }
68+
})
69+
ExplorerUiEventsResult.addValue(entity, {
70+
ui: ExplorerUi.EU_BACKPACK,
71+
timestamp: 2,
72+
event: { $case: 'closed', closed: {} }
73+
})
74+
75+
expect(Array.from(ExplorerUiEventsResult.get(entity))).toEqual([
76+
{ ui: ExplorerUi.EU_BACKPACK, timestamp: 1, event: { $case: 'opened', opened: {} } },
77+
{ ui: ExplorerUi.EU_BACKPACK, timestamp: 2, event: { $case: 'closed', closed: {} } }
78+
])
79+
})
80+
})

test/snapshots/development-bundles/static-scene.test.ts.crdt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=613.9k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=619.9k bytes
22
THE BUNDLE HAS SOURCEMAPS
33
(start empty vm 0.21.0-3680274614.commit-1808aa1)
44
OPCODES ~= 0k
@@ -10,8 +10,8 @@ EVAL test/snapshots/development-bundles/static-scene.test.js
1010
REQUIRE: ~system/EngineApi
1111
REQUIRE: ~system/Runtime
1212
OPCODES ~= 74k
13-
MALLOC_COUNT = 16723
14-
ALIVE_OBJS_DELTA ~= 3.28k
13+
MALLOC_COUNT = 16866
14+
ALIVE_OBJS_DELTA ~= 3.31k
1515
CALL onStart()
1616
main.crdt: PUT_COMPONENT e=0x200 c=1 t=0 data={"position":{"x":5.880000114440918,"y":2.7916901111602783,"z":7.380000114440918},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":1,"y":1,"z":1},"parent":0}
1717
main.crdt: PUT_COMPONENT e=0x202 c=1 t=0 data={"position":{"x":4,"y":0.800000011920929,"z":8},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":1,"y":1,"z":1},"parent":0}
@@ -55,4 +55,4 @@ CALL onUpdate(0.1)
5555
OPCODES ~= 5k
5656
MALLOC_COUNT = -5
5757
ALIVE_OBJS_DELTA ~= 0.00k
58-
MEMORY_USAGE_COUNT ~= 1536.00k bytes
58+
MEMORY_USAGE_COUNT ~= 1546.52k bytes

test/snapshots/development-bundles/testing-fw.test.ts.crdt

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
SCENE_COMPILED_JS_SIZE_PROD=614.4k bytes
1+
SCENE_COMPILED_JS_SIZE_PROD=620.4k bytes
22
THE BUNDLE HAS SOURCEMAPS
33
(start empty vm 0.21.0-3680274614.commit-1808aa1)
44
OPCODES ~= 0k
@@ -9,9 +9,9 @@ EVAL test/snapshots/development-bundles/testing-fw.test.js
99
REQUIRE: ~system/EngineApi
1010
REQUIRE: ~system/EngineApi
1111
REQUIRE: ~system/Runtime
12-
OPCODES ~= 83k
13-
MALLOC_COUNT = 17275
14-
ALIVE_OBJS_DELTA ~= 3.43k
12+
OPCODES ~= 84k
13+
MALLOC_COUNT = 17418
14+
ALIVE_OBJS_DELTA ~= 3.46k
1515
CALL onStart()
1616
LOG: ["Adding one to position.y=0"]
1717
Renderer: PUT_COMPONENT e=0x0 c=1 t=1 data={"position":{"x":1,"y":0,"z":0},"rotation":{"x":0,"y":0,"z":0,"w":1},"scale":{"x":9,"y":9,"z":9},"parent":0}
@@ -61,4 +61,4 @@ CALL onUpdate(0.1)
6161
OPCODES ~= 6k
6262
MALLOC_COUNT = -53
6363
ALIVE_OBJS_DELTA ~= -0.01k
64-
MEMORY_USAGE_COUNT ~= 1541.70k bytes
64+
MEMORY_USAGE_COUNT ~= 1552.21k bytes

0 commit comments

Comments
 (0)