diff --git a/package-lock.json b/package-lock.json index 666953c76..a375e3028 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,7 +11,7 @@ "license": "Apache-2.0", "dependencies": { "@actions/core": "^1.10.0", - "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12687285199.commit-5a8c3ae.tgz", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12754011500.commit-762ebe6.tgz", "@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1", "@dcl/ts-proto": "1.153.0", "@types/fs-extra": "^9.0.12", @@ -577,9 +577,9 @@ } }, "node_modules/@dcl/protocol": { - "version": "1.0.0-12687285199.commit-5a8c3ae", - "resolved": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12687285199.commit-5a8c3ae.tgz", - "integrity": "sha512-JbO0JJpUr1aolAd/UxFZ9aFNijyPnZQtoJuSS9z0r18nZGLK6gbBiLYakCYMi/3izJGbgr17p7ZN1RZCb7DvVQ==", + "version": "1.0.0-12754011500.commit-762ebe6", + "resolved": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12754011500.commit-762ebe6.tgz", + "integrity": "sha512-0b3A6Nzezi8ebTf3fYQvZH2z3VdXQ9RQw/1M3nOKTYuy85QSkUS0PxqXgdiYgNzrSzGsV0AQdEwHRgO8ys0krA==", "license": "Apache-2.0", "dependencies": { "@dcl/ts-proto": "1.154.0" @@ -8394,8 +8394,8 @@ } }, "@dcl/protocol": { - "version": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12687285199.commit-5a8c3ae.tgz", - "integrity": "sha512-JbO0JJpUr1aolAd/UxFZ9aFNijyPnZQtoJuSS9z0r18nZGLK6gbBiLYakCYMi/3izJGbgr17p7ZN1RZCb7DvVQ==", + "version": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12754011500.commit-762ebe6.tgz", + "integrity": "sha512-0b3A6Nzezi8ebTf3fYQvZH2z3VdXQ9RQw/1M3nOKTYuy85QSkUS0PxqXgdiYgNzrSzGsV0AQdEwHRgO8ys0krA==", "requires": { "@dcl/ts-proto": "1.154.0" }, diff --git a/package.json b/package.json index b9e5bf7db..aa84d1c9e 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "bugs": "https://github.com/decentraland/js-sdk-toolchain/issues", "dependencies": { "@actions/core": "^1.10.0", - "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12687285199.commit-5a8c3ae.tgz", + "@dcl/protocol": "https://sdk-team-cdn.decentraland.org/@dcl/protocol/branch//dcl-protocol-1.0.0-12754011500.commit-762ebe6.tgz", "@dcl/quickjs-emscripten": "^0.21.0-3680274614.commit-1808aa1", "@dcl/ts-proto": "1.153.0", "@types/fs-extra": "^9.0.12", diff --git a/packages/@dcl/sdk/src/network/binary-message-bus.ts b/packages/@dcl/sdk/src/network/binary-message-bus.ts index 18bc6565c..69d67d6c4 100644 --- a/packages/@dcl/sdk/src/network/binary-message-bus.ts +++ b/packages/@dcl/sdk/src/network/binary-message-bus.ts @@ -6,13 +6,15 @@ export enum CommsMessage { RES_CRDT_STATE = 3 } -export function BinaryMessageBus(send: (message: Uint8Array, toPeerAddress?: string) => void) { +export function BinaryMessageBus( + send: (message: Uint8Array, toPeerAddress?: string[]) => void +) { const mapping: Map void> = new Map() return { on: (message: K, callback: (value: Uint8Array, sender: string) => void) => { mapping.set(message, callback) }, - emit: (message: K, value: Uint8Array, toPeerAddress?: string) => { + emit: (message: K, value: Uint8Array, toPeerAddress?: string[]) => { send(craftCommsMessage(message, value), toPeerAddress) }, __processMessages: (messages: Uint8Array[]) => { diff --git a/packages/@dcl/sdk/src/network/message-bus-sync.ts b/packages/@dcl/sdk/src/network/message-bus-sync.ts index 658e493ed..682deb44b 100644 --- a/packages/@dcl/sdk/src/network/message-bus-sync.ts +++ b/packages/@dcl/sdk/src/network/message-bus-sync.ts @@ -26,15 +26,10 @@ export function addSyncTransport( const entityDefinitions = entityUtils(engine, myProfile) // List of MessageBuss messsages to be sent on every frame to comms - const pendingMessageBusMessagesToSend: { data: Uint8Array[]; address: string }[] = [] + const pendingMessageBusMessagesToSend: { data: Uint8Array[]; address: string[] }[] = [] const binaryMessageBus = BinaryMessageBus((data, address) => { - const pendingAddressMessage = address && pendingMessageBusMessagesToSend.find(($) => $.address === address) - if (pendingAddressMessage) { - pendingAddressMessage.data.push(data) - } else { - pendingMessageBusMessagesToSend.push({ data: [data], address: address ?? '' }) - } + pendingMessageBusMessagesToSend.push({ data: [data], address: address ?? [] }) }) function getMessagesToSend(): [Uint8Array[], typeof pendingMessageBusMessagesToSend] { @@ -44,7 +39,7 @@ export function addSyncTransport( const peerMessages: typeof pendingMessageBusMessagesToSend = [] for (const message of messages) { - if (!message.address) { + if (!message.address.length) { broadcastMessages.push(...message.data) } else { peerMessages.push(message) @@ -90,7 +85,7 @@ export function addSyncTransport( binaryMessageBus.on(CommsMessage.REQ_CRDT_STATE, async (message, userId) => { console.log(`Sending CRDT State to: ${userId}`) transport.onmessage!(message) - binaryMessageBus.emit(CommsMessage.RES_CRDT_STATE, encodeCRDTState(userId, engineToCrdt(engine)), userId) + binaryMessageBus.emit(CommsMessage.RES_CRDT_STATE, encodeCRDTState(userId, engineToCrdt(engine)), [userId]) }) // Process CRDT messages here diff --git a/test/snapshots/development-bundles/static-scene.test.ts.crdt b/test/snapshots/development-bundles/static-scene.test.ts.crdt index 79917bd70..c600435a5 100644 --- a/test/snapshots/development-bundles/static-scene.test.ts.crdt +++ b/test/snapshots/development-bundles/static-scene.test.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=455.7k bytes +SCENE_COMPILED_JS_SIZE_PROD=456k bytes THE BUNDLE HAS SOURCEMAPS (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k @@ -11,7 +11,7 @@ EVAL test/snapshots/development-bundles/static-scene.test.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 54k - MALLOC_COUNT = 13700 + MALLOC_COUNT = 13705 ALIVE_OBJS_DELTA ~= 2.70k CALL onStart() 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} @@ -56,4 +56,4 @@ CALL onUpdate(0.1) OPCODES ~= 3k MALLOC_COUNT = -5 ALIVE_OBJS_DELTA ~= 0.00k - MEMORY_USAGE_COUNT ~= 1198.40k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 1199.30k bytes \ No newline at end of file diff --git a/test/snapshots/development-bundles/testing-fw.test.ts.crdt b/test/snapshots/development-bundles/testing-fw.test.ts.crdt index c6187c91a..ac876d61f 100644 --- a/test/snapshots/development-bundles/testing-fw.test.ts.crdt +++ b/test/snapshots/development-bundles/testing-fw.test.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=456.2k bytes +SCENE_COMPILED_JS_SIZE_PROD=456.5k bytes THE BUNDLE HAS SOURCEMAPS (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k @@ -11,7 +11,7 @@ EVAL test/snapshots/development-bundles/testing-fw.test.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 63k - MALLOC_COUNT = 14221 + MALLOC_COUNT = 14226 ALIVE_OBJS_DELTA ~= 2.85k CALL onStart() LOG: ["Adding one to position.y=0"] @@ -64,4 +64,4 @@ CALL onUpdate(0.1) OPCODES ~= 5k MALLOC_COUNT = -40 ALIVE_OBJS_DELTA ~= -0.01k - MEMORY_USAGE_COUNT ~= 1207.01k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 1207.91k bytes \ No newline at end of file diff --git a/test/snapshots/development-bundles/two-way-crdt.test.ts.crdt b/test/snapshots/development-bundles/two-way-crdt.test.ts.crdt index fa1011c9e..f0e77ee43 100644 --- a/test/snapshots/development-bundles/two-way-crdt.test.ts.crdt +++ b/test/snapshots/development-bundles/two-way-crdt.test.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=456.2k bytes +SCENE_COMPILED_JS_SIZE_PROD=456.5k bytes THE BUNDLE HAS SOURCEMAPS (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k @@ -11,7 +11,7 @@ EVAL test/snapshots/development-bundles/two-way-crdt.test.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 63k - MALLOC_COUNT = 14221 + MALLOC_COUNT = 14226 ALIVE_OBJS_DELTA ~= 2.85k CALL onStart() LOG: ["Adding one to position.y=0"] @@ -64,4 +64,4 @@ CALL onUpdate(0.1) OPCODES ~= 5k MALLOC_COUNT = -40 ALIVE_OBJS_DELTA ~= -0.01k - MEMORY_USAGE_COUNT ~= 1207.02k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 1207.92k bytes \ No newline at end of file diff --git a/test/snapshots/production-bundles/append-value-crdt.ts.crdt b/test/snapshots/production-bundles/append-value-crdt.ts.crdt index 7765ebb5f..e2044fafe 100644 --- a/test/snapshots/production-bundles/append-value-crdt.ts.crdt +++ b/test/snapshots/production-bundles/append-value-crdt.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=199.2k bytes +SCENE_COMPILED_JS_SIZE_PROD=199.4k bytes (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k MALLOC_COUNT = 1005 @@ -9,7 +9,7 @@ EVAL test/snapshots/production-bundles/append-value-crdt.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 65k - MALLOC_COUNT = 12748 + MALLOC_COUNT = 12753 ALIVE_OBJS_DELTA ~= 2.85k CALL onStart() Renderer: APPEND_VALUE e=0x200 c=1063 t=0 data={"button":0,"hit":{"position":{"x":1,"y":2,"z":3},"globalOrigin":{"x":1,"y":2,"z":3},"direction":{"x":1,"y":2,"z":3},"normalHit":{"x":1,"y":2,"z":3},"length":10,"meshName":"mesh","entityId":512},"state":1,"timestamp":1,"analog":5,"tickNumber":0} @@ -55,4 +55,4 @@ CALL onUpdate(0.1) OPCODES ~= 14k MALLOC_COUNT = 31 ALIVE_OBJS_DELTA ~= 0.01k - MEMORY_USAGE_COUNT ~= 902.35k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 903.06k bytes \ No newline at end of file diff --git a/test/snapshots/production-bundles/billboard.ts.crdt b/test/snapshots/production-bundles/billboard.ts.crdt index 9678880b9..bde499166 100644 --- a/test/snapshots/production-bundles/billboard.ts.crdt +++ b/test/snapshots/production-bundles/billboard.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=232.2k bytes +SCENE_COMPILED_JS_SIZE_PROD=232.4k bytes (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k MALLOC_COUNT = 1005 @@ -9,8 +9,8 @@ EVAL test/snapshots/production-bundles/billboard.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 66k - MALLOC_COUNT = 14860 - ALIVE_OBJS_DELTA ~= 3.24k + MALLOC_COUNT = 14865 + ALIVE_OBJS_DELTA ~= 3.25k CALL onStart() OPCODES ~= 0k MALLOC_COUNT = 4 @@ -77,4 +77,4 @@ CALL onUpdate(0.1) OPCODES ~= 10k MALLOC_COUNT = 0 ALIVE_OBJS_DELTA ~= 0.00k - MEMORY_USAGE_COUNT ~= 1044.69k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 1045.40k bytes \ No newline at end of file diff --git a/test/snapshots/production-bundles/cube-deleted.ts.crdt b/test/snapshots/production-bundles/cube-deleted.ts.crdt index 716793a9a..a71e707bd 100644 --- a/test/snapshots/production-bundles/cube-deleted.ts.crdt +++ b/test/snapshots/production-bundles/cube-deleted.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=195.4k bytes +SCENE_COMPILED_JS_SIZE_PROD=195.6k bytes (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k MALLOC_COUNT = 1005 @@ -9,7 +9,7 @@ EVAL test/snapshots/production-bundles/cube-deleted.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 55k - MALLOC_COUNT = 11902 + MALLOC_COUNT = 11907 ALIVE_OBJS_DELTA ~= 2.63k CALL onStart() OPCODES ~= 0k @@ -42,4 +42,4 @@ CALL onUpdate(0.1) OPCODES ~= 5k MALLOC_COUNT = 1 ALIVE_OBJS_DELTA ~= 0.00k - MEMORY_USAGE_COUNT ~= 865.07k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 865.78k bytes \ No newline at end of file diff --git a/test/snapshots/production-bundles/cube.ts.crdt b/test/snapshots/production-bundles/cube.ts.crdt index f05c74ba2..39ddc97a2 100644 --- a/test/snapshots/production-bundles/cube.ts.crdt +++ b/test/snapshots/production-bundles/cube.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=195.3k bytes +SCENE_COMPILED_JS_SIZE_PROD=195.5k bytes (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k MALLOC_COUNT = 1005 @@ -9,7 +9,7 @@ EVAL test/snapshots/production-bundles/cube.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 55k - MALLOC_COUNT = 11875 + MALLOC_COUNT = 11880 ALIVE_OBJS_DELTA ~= 2.62k CALL onStart() OPCODES ~= 0k @@ -32,4 +32,4 @@ CALL onUpdate(0.1) OPCODES ~= 1k MALLOC_COUNT = 0 ALIVE_OBJS_DELTA ~= 0.00k - MEMORY_USAGE_COUNT ~= 854.99k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 855.70k bytes \ No newline at end of file diff --git a/test/snapshots/production-bundles/cubes.ts.crdt b/test/snapshots/production-bundles/cubes.ts.crdt index 07866b425..a0cd818d9 100644 --- a/test/snapshots/production-bundles/cubes.ts.crdt +++ b/test/snapshots/production-bundles/cubes.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=232.6k bytes +SCENE_COMPILED_JS_SIZE_PROD=232.8k bytes (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k MALLOC_COUNT = 1005 @@ -9,7 +9,7 @@ EVAL test/snapshots/production-bundles/cubes.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 105k - MALLOC_COUNT = 18202 + MALLOC_COUNT = 18207 ALIVE_OBJS_DELTA ~= 4.53k CALL onStart() OPCODES ~= 0k @@ -1652,4 +1652,4 @@ CALL onUpdate(0.1) OPCODES ~= 692k MALLOC_COUNT = 0 ALIVE_OBJS_DELTA ~= 0.00k - MEMORY_USAGE_COUNT ~= 1180.62k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 1181.33k bytes \ No newline at end of file diff --git a/test/snapshots/production-bundles/pointer-events.ts.crdt b/test/snapshots/production-bundles/pointer-events.ts.crdt index 99ae0a42d..b3297944d 100644 --- a/test/snapshots/production-bundles/pointer-events.ts.crdt +++ b/test/snapshots/production-bundles/pointer-events.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=196.2k bytes +SCENE_COMPILED_JS_SIZE_PROD=196.4k bytes (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k MALLOC_COUNT = 1005 @@ -9,7 +9,7 @@ EVAL test/snapshots/production-bundles/pointer-events.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 56k - MALLOC_COUNT = 12161 + MALLOC_COUNT = 12166 ALIVE_OBJS_DELTA ~= 2.70k CALL onStart() OPCODES ~= 0k @@ -43,4 +43,4 @@ CALL onUpdate(0.1) OPCODES ~= 1k MALLOC_COUNT = 0 ALIVE_OBJS_DELTA ~= 0.00k - MEMORY_USAGE_COUNT ~= 872.71k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 873.43k bytes \ No newline at end of file diff --git a/test/snapshots/production-bundles/schema-components.ts.crdt b/test/snapshots/production-bundles/schema-components.ts.crdt index 7920c6e38..bd5ae24de 100644 --- a/test/snapshots/production-bundles/schema-components.ts.crdt +++ b/test/snapshots/production-bundles/schema-components.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=195.3k bytes +SCENE_COMPILED_JS_SIZE_PROD=195.5k bytes (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k MALLOC_COUNT = 1005 @@ -9,7 +9,7 @@ EVAL test/snapshots/production-bundles/schema-components.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 59k - MALLOC_COUNT = 12002 + MALLOC_COUNT = 12007 ALIVE_OBJS_DELTA ~= 2.65k CALL onStart() OPCODES ~= 0k @@ -31,4 +31,4 @@ CALL onUpdate(0.1) OPCODES ~= 1k MALLOC_COUNT = 0 ALIVE_OBJS_DELTA ~= 0.00k - MEMORY_USAGE_COUNT ~= 857.41k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 858.12k bytes \ No newline at end of file diff --git a/test/snapshots/production-bundles/ui.ts.crdt b/test/snapshots/production-bundles/ui.ts.crdt index 8df46a88d..a7bdcade7 100644 --- a/test/snapshots/production-bundles/ui.ts.crdt +++ b/test/snapshots/production-bundles/ui.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=353.5k bytes +SCENE_COMPILED_JS_SIZE_PROD=353.7k bytes (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k MALLOC_COUNT = 1005 @@ -9,7 +9,7 @@ EVAL test/snapshots/production-bundles/ui.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 65k - MALLOC_COUNT = 19502 + MALLOC_COUNT = 19507 ALIVE_OBJS_DELTA ~= 3.88k CALL onStart() OPCODES ~= 0k @@ -65,4 +65,4 @@ CALL onUpdate(0.1) OPCODES ~= 64k MALLOC_COUNT = 0 ALIVE_OBJS_DELTA ~= 0.00k - MEMORY_USAGE_COUNT ~= 1694.71k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 1695.42k bytes \ No newline at end of file diff --git a/test/snapshots/production-bundles/with-main-function.ts.crdt b/test/snapshots/production-bundles/with-main-function.ts.crdt index 2aa48892b..19affa192 100644 --- a/test/snapshots/production-bundles/with-main-function.ts.crdt +++ b/test/snapshots/production-bundles/with-main-function.ts.crdt @@ -1,4 +1,4 @@ -SCENE_COMPILED_JS_SIZE_PROD=196k bytes +SCENE_COMPILED_JS_SIZE_PROD=196.2k bytes (start empty vm 0.21.0-3680274614.commit-1808aa1) OPCODES ~= 0k MALLOC_COUNT = 1005 @@ -9,7 +9,7 @@ EVAL test/snapshots/production-bundles/with-main-function.js REQUIRE: ~system/EngineApi REQUIRE: ~system/EngineApi OPCODES ~= 55k - MALLOC_COUNT = 12031 + MALLOC_COUNT = 12036 ALIVE_OBJS_DELTA ~= 2.65k CALL onStart() OPCODES ~= 0k @@ -37,4 +37,4 @@ CALL onUpdate(0.1) OPCODES ~= 3k MALLOC_COUNT = 5 ALIVE_OBJS_DELTA ~= 0.00k - MEMORY_USAGE_COUNT ~= 870.53k bytes \ No newline at end of file + MEMORY_USAGE_COUNT ~= 871.24k bytes \ No newline at end of file