Skip to content
This repository was archived by the owner on Feb 27, 2023. It is now read-only.

Commit 53d04b9

Browse files
authored
refactor: @dcl/protocol implement buf (#594)
* refactor: @dcl/protocol implement buf * fix engine and permissions * remove mkdir * update protocol * update @dcl/protocol * update API to Api * update @dcl/protocol
1 parent 9183d0d commit 53d04b9

47 files changed

Lines changed: 211 additions & 181 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Makefile

Lines changed: 23 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,26 +2,27 @@
22
NODE = node
33
COMPILER = $(NODE) --max-old-space-size=4096 node_modules/.bin/decentraland-compiler
44
CONCURRENTLY = node_modules/.bin/concurrently
5-
RENDERER_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/renderer-protocol/*.proto)
6-
BFF_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/bff/*.proto)
7-
SCENE_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/kernel/apis/*.proto)
8-
COMMSRFC4_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/kernel/comms/*.proto)
9-
COMMS_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/kernel/comms/v3/*.proto)
5+
RENDERER_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/proto/decentraland/renderer/*.proto)
6+
BFF_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/proto/decentraland/bff/*.proto)
7+
SCENE_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/proto/decentraland/kernel/apis/*.proto)
8+
COMMSRFC4_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/proto/decentraland/kernel/comms/*.proto)
9+
COMMS_PROTO_FILES := $(wildcard node_modules/@dcl/protocol/proto/decentraland/kernel/comms/v3/*.proto)
1010
COMMS_PROTO_FILES2 := $(wildcard packages/shared/comms/v3/proto/*.proto)
1111

1212
BFF_TS = packages/shared/protocol/bff-services.gen.ts
1313
PBS_TS = packages/shared/protocol/kernel/sdk-apis.gen.ts
14-
PBRENDERER_TS = $(RENDERER_PROTO_FILES:node_modules/@dcl/protocol/renderer-protocol/%.proto=packages/shared/protocol/renderer-protocol/%.gen.ts)
15-
COMMSRFC4_TS = $(COMMSRFC4_PROTO_FILES:node_modules/@dcl/protocol/kernel/comms/%.proto=packages/shared/protocol/kernel/comms/%.gen.ts)
16-
COMMS_TS = $(COMMS_PROTO_FILES:node_modules/@dcl/protocol/kernel/comms/v3/%.proto=packages/shared/protocol/kernel/comms/v3/%.gen.ts)
14+
PBRENDERER_TS = $(RENDERER_PROTO_FILES:node_modules/@dcl/protocol/proto/decentraland/renderer/%.proto=packages/shared/protocol/renderer-protocol/%.gen.ts)
15+
COMMSRFC4_TS = $(COMMSRFC4_PROTO_FILES:node_modules/@dcl/protocol/proto/decentraland/kernel/comms/%.proto=packages/shared/protocol/kernel/comms/%.gen.ts)
16+
COMMS_TS = $(COMMS_PROTO_FILES:node_modules/@dcl/protocol/proto/decentraland/kernel/comms/v3/%.proto=packages/shared/protocol/kernel/comms/v3/%.gen.ts)
1717
COMMS_TS2 = $(COMMS_PROTO_FILES2:packages/shared/comms/v3/proto/%.proto=packages/shared/comms/v3/proto/%.gen.ts)
1818

1919
CWD = $(shell pwd)
2020
PROTOC = node_modules/.bin/protoc
2121
PROTOC_ARGS = --plugin=./node_modules/.bin/protoc-gen-ts_proto \
2222
--ts_proto_opt=esModuleInterop=true,returnObservable=false,outputServices=generic-definitions,fileSuffix=.gen \
2323
--ts_proto_out="$(PWD)/packages/shared/protocol" \
24-
-I="$(PWD)/node_modules/@dcl/protocol"
24+
-I="$(PWD)/node_modules/@dcl/protocol/proto" \
25+
-I="$(PWD)/node_modules/@dcl/protocol/public"
2526
# Remove default Makefile rules
2627

2728
.SUFFIXES:
@@ -182,41 +183,39 @@ help:
182183
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
183184
@echo "\nYou probably want to run 'make watch' to build all the test scenes and run the local comms server."
184185

185-
packages/shared/protocol/kernel/sdk-apis.gen.ts: node_modules/@dcl/protocol/sdk-apis.proto
186+
packages/shared/protocol/kernel/sdk-apis.gen.ts: node_modules/@dcl/protocol/public/sdk-apis.proto
186187
${PROTOC} ${PROTOC_ARGS} \
187-
"$(PWD)/node_modules/@dcl/protocol/sdk-apis.proto";
188+
"$(PWD)/node_modules/@dcl/protocol/public/sdk-apis.proto";
188189

189-
packages/shared/protocol/renderer-protocol/%.gen.ts: node_modules/@dcl/protocol/renderer-protocol/%.proto
190-
mkdir -p "$(PWD)/packages/shared/protocol/renderer-protocol"
190+
packages/shared/protocol/renderer-protocol/%.gen.ts: node_modules/@dcl/protocol/proto/decentraland/renderer/%.proto
191191
${PROTOC} ${PROTOC_ARGS} \
192-
"$(PWD)/node_modules/@dcl/protocol/renderer-protocol/$*.proto";
192+
"$(PWD)/node_modules/@dcl/protocol/proto/decentraland/renderer/$*.proto";
193193

194-
packages/shared/protocol/bff-services.gen.ts: node_modules/@dcl/protocol/bff-services.proto
195-
mkdir -p "$(PWD)/packages/shared/protocol/bff"
194+
packages/shared/protocol/bff-services.gen.ts: node_modules/@dcl/protocol/public/bff-services.proto
196195
${PROTOC} ${PROTOC_ARGS} \
197196
-I="$(PWD)/node_modules/protobufjs" \
198-
"$(PWD)/node_modules/@dcl/protocol/bff-services.proto"
197+
"$(PWD)/node_modules/@dcl/protocol/public/bff-services.proto"
199198

200-
packages/shared/protocol/kernel/comms/%.gen.ts: node_modules/@dcl/protocol/kernel/comms/%.proto
199+
packages/shared/protocol/kernel/comms/%.gen.ts: node_modules/@dcl/protocol/proto/decentraland/kernel/comms/%.proto
201200
mkdir -p "$(PWD)/packages/shared/protocol/kernel/comms"
202201
${PROTOC} \
203202
--plugin=./node_modules/.bin/protoc-gen-ts_proto \
204203
--ts_proto_opt=esModuleInterop=true,returnObservable=false,outputServices=generic-definitions,oneof=unions \
205204
--ts_proto_opt=fileSuffix=.gen \
206205
--ts_proto_out="$(PWD)/packages/shared/protocol/kernel/comms" \
207-
-I="$(PWD)/node_modules/@dcl/protocol/bff" \
206+
-I="$(PWD)/node_modules/@dcl/protocol/proto/decentraland/bff" \
208207
-I="$(PWD)/node_modules/protobufjs" \
209-
-I="$(PWD)/node_modules/@dcl/protocol/kernel/comms" \
210-
"$(PWD)/node_modules/@dcl/protocol/kernel/comms/$*.proto"
208+
-I="$(PWD)/node_modules/@dcl/protocol/proto/decentraland/kernel/comms" \
209+
"$(PWD)/node_modules/@dcl/protocol/proto/decentraland/kernel/comms/$*.proto"
211210

212-
packages/shared/protocol/kernel/comms/v3/%.gen.ts: node_modules/@dcl/protocol/kernel/comms/v3/%.proto
211+
packages/shared/protocol/kernel/comms/v3/%.gen.ts: node_modules/@dcl/protocol/proto/decentraland/kernel/comms/v3/%.proto
213212
mkdir -p "$(PWD)/packages/shared/protocol/kernel/comms/v3"
214213
${PROTOC} \
215214
--plugin=./node_modules/.bin/protoc-gen-ts_proto \
216215
--ts_proto_opt=esModuleInterop=true,oneof=unions,fileSuffix=.gen \
217216
--ts_proto_out="$(PWD)/packages/shared/protocol/kernel/comms/v3" \
218-
-I="$(PWD)/node_modules/@dcl/protocol/kernel/comms/v3" \
219-
"$(PWD)/node_modules/@dcl/protocol/kernel/comms/v3/$*.proto"
217+
-I="$(PWD)/node_modules/@dcl/protocol/proto/decentraland/kernel/comms/v3" \
218+
"$(PWD)/node_modules/@dcl/protocol/proto/decentraland/kernel/comms/v3/$*.proto"
220219

221220
packages/shared/comms/v3/proto/%.gen.ts: packages/shared/comms/v3/proto/%.proto
222221
${PROTOC} \

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
@@ -75,7 +75,7 @@
7575
"@dcl/hashing": "^1.1.0",
7676
"@dcl/kernel-interface": "^2.0.0-20210922153939.commit-017905d",
7777
"@dcl/legacy-ecs": "^6.11.8",
78-
"@dcl/protocol": "^1.0.0-3199325469.commit-c9bc23f",
78+
"@dcl/protocol": "^1.0.0-3243753014.commit-161bbc8",
7979
"@dcl/rpc": "^1.0.3",
8080
"@dcl/schemas": "^5.21.0",
8181
"@dcl/urn-resolver": "^2.0.2",

packages/renderer-protocol/services/crdtService.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { RpcClientPort } from '@dcl/rpc'
22
import * as codegen from '@dcl/rpc/dist/codegen'
3-
import { CRDTServiceDefinition } from 'shared/protocol/renderer-protocol/RendererProtocol.gen'
3+
import { CRDTServiceDefinition } from 'shared/protocol/decentraland/renderer/protocol.gen'
44

55
export function registerCRDTService<Context>(
66
clientPort: RpcClientPort

packages/renderer-protocol/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { CRDTServiceDefinition } from 'shared/protocol/renderer-protocol/RendererProtocol.gen'
1+
import { CRDTServiceDefinition } from 'shared/protocol/decentraland/renderer/protocol.gen'
22
import * as codegen from '@dcl/rpc/dist/codegen'
33

44
export type RendererProtocol = {

packages/scene-system/sdk/SceneRuntime.ts

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { LoadableAPIs } from '../../shared/apis/client'
22
import { componentSerializeOpt, initMessagesFinished, numberToIdStore, resolveMapping } from './Utils'
33
import { customEval, prepareSandboxContext } from './sandbox'
44
import { RpcClient } from '@dcl/rpc/dist/types'
5-
import { PermissionItem } from 'shared/protocol/kernel/apis/Permissions.gen'
5+
import { PermissionItem } from 'shared/protocol/decentraland/kernel/apis/permissions.gen'
66

77
import { createDecentralandInterface, DecentralandInterfaceOptions } from './runtime/DecentralandInterface'
88
import { setupFpsThrottling } from './runtime/SetupFpsThrottling'
@@ -16,16 +16,16 @@ export async function startSceneRuntime(client: RpcClient) {
1616
const workerName = self.name
1717
const clientPort = await client.createPort(`scene-${workerName}`)
1818

19-
const [EngineAPI, EnvironmentAPI, Permissions, DevTools] = await Promise.all([
20-
LoadableAPIs.EngineAPI(clientPort),
21-
LoadableAPIs.EnvironmentAPI(clientPort),
19+
const [EngineApi, EnvironmentApi, Permissions, DevTools] = await Promise.all([
20+
LoadableAPIs.EngineApi(clientPort),
21+
LoadableAPIs.EnvironmentApi(clientPort),
2222
LoadableAPIs.Permissions(clientPort),
2323
LoadableAPIs.DevTools(clientPort)
2424
])
2525

2626
const [canUseWebsocket, canUseFetch] = (
2727
await Permissions.hasManyPermissions({
28-
permissions: [PermissionItem.USE_WEBSOCKET, PermissionItem.USE_FETCH]
28+
permissions: [PermissionItem.PI_USE_WEBSOCKET, PermissionItem.PI_USE_FETCH]
2929
})
3030
).hasManyPermission
3131

@@ -38,12 +38,12 @@ export async function startSceneRuntime(client: RpcClient) {
3838
events: []
3939
}
4040

41-
const bootstrapData = await EnvironmentAPI.getBootstrapData({})
41+
const bootstrapData = await EnvironmentApi.getBootstrapData({})
4242
const fullData: Scene = JSON.parse(bootstrapData.entity?.metadataJson || '{}')
43-
const isPreview = await EnvironmentAPI.isPreviewMode({})
44-
const unsafeAllowed = await EnvironmentAPI.areUnsafeRequestAllowed({})
43+
const isPreview = await EnvironmentApi.isPreviewMode({})
44+
const unsafeAllowed = await EnvironmentApi.areUnsafeRequestAllowed({})
4545

46-
const explorerConfiguration = await EnvironmentAPI.getExplorerConfiguration({})
46+
const explorerConfiguration = await EnvironmentApi.getExplorerConfiguration({})
4747

4848
if (!fullData || !fullData.main) {
4949
throw new Error(`No boostrap data`)
@@ -53,15 +53,15 @@ export async function startSceneRuntime(client: RpcClient) {
5353
const mapping = bootstrapData.entity?.content.find(($) => $.file === mappingName)
5454

5555
if (!mapping) {
56-
await EngineAPI.sendBatch({ actions: [initMessagesFinished()] })
56+
await EngineApi.sendBatch({ actions: [initMessagesFinished()] })
5757
throw new Error(`SDK: Error while loading scene. Main file missing.`)
5858
}
5959

6060
const url = resolveMapping(mapping.hash, mappingName, bootstrapData.baseUrl)
6161
const codeRequest = await fetch(url)
6262

6363
if (!codeRequest.ok) {
64-
await EngineAPI.sendBatch({ actions: [initMessagesFinished()] })
64+
await EngineApi.sendBatch({ actions: [initMessagesFinished()] })
6565
throw new Error(
6666
`SDK: Error while loading ${url} (${mappingName} -> ${mapping?.file}:${mapping?.hash}) the mapping was not found`
6767
)
@@ -79,7 +79,7 @@ export async function startSceneRuntime(client: RpcClient) {
7979
batchEvents.events = []
8080
}
8181

82-
const res = await EngineAPI.sendBatch({ actions })
82+
const res = await EngineApi.sendBatch({ actions })
8383
for (const e of res.events) {
8484
eventReceiver(EventDataToRuntimeEvent(e))
8585
}
@@ -153,7 +153,7 @@ export async function startSceneRuntime(client: RpcClient) {
153153
sceneId: bootstrapData.id,
154154
eventState,
155155
batchEvents,
156-
EngineAPI,
156+
EngineApi,
157157
onEventFunctions,
158158
onStartFunctions,
159159
onUpdateFunctions
@@ -177,7 +177,7 @@ export async function startSceneRuntime(client: RpcClient) {
177177
// run the code of the scene
178178
await customEval(sourceCode, runtimeExecutionContext)
179179
} catch (err) {
180-
await EngineAPI.sendBatch({ actions: [initMessagesFinished()] })
180+
await EngineApi.sendBatch({ actions: [initMessagesFinished()] })
181181

182182
devToolsAdapter.error(new Error(`SceneRuntime: Error while evaluating the scene ${workerName}`))
183183

packages/scene-system/sdk/Utils.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { Quaternion, Vector3 } from '@dcl/ecs-math'
22
import type { CLASS_ID, Transform } from '@dcl/legacy-ecs/dist/decentraland/Components'
3-
import { EAType } from 'shared/protocol/kernel/apis/EngineAPI.gen'
4-
import { PBTransform } from 'shared/protocol/renderer-protocol/EngineInterface.gen'
3+
import { EAType } from 'shared/protocol/decentraland/kernel/apis/engine_api.gen'
4+
import { PBTransform } from 'shared/protocol/decentraland/renderer/engine_interface.gen'
55

66
const VECTOR3_MEMBER_CAP = 1000000 // Value measured when genesis plaza glitch triggered a physics engine breakdown
77
const pbTransform = {
@@ -144,7 +144,7 @@ export function getIdAsNumber(id: string): number {
144144

145145
export function initMessagesFinished() {
146146
return {
147-
type: EAType.InitMessagesFinished,
147+
type: EAType.EAT_INIT_MESSAGES_FINISHED,
148148
tag: 'scene',
149149
payload: { initMessagesFinished: {} }
150150
}

0 commit comments

Comments
 (0)