From e7441ed7486cc61d2c79491d20241ea53600058d Mon Sep 17 00:00:00 2001 From: Gonzalo DCL Date: Fri, 6 Dec 2024 14:49:39 -0300 Subject: [PATCH] fix onChange for custom componetns forward params to explorer alpha --- packages/@dcl/ecs/src/systems/crdt/index.ts | 15 +++++------ .../src/commands/start/explorer-alpha.ts | 27 +++++++++++++++---- .../sdk-commands/src/commands/start/index.ts | 3 +-- packages/@dcl/sdk-commands/src/logic/args.ts | 2 +- 4 files changed, 31 insertions(+), 16 deletions(-) diff --git a/packages/@dcl/ecs/src/systems/crdt/index.ts b/packages/@dcl/ecs/src/systems/crdt/index.ts index cb8afb32e..9640b573f 100644 --- a/packages/@dcl/ecs/src/systems/crdt/index.ts +++ b/packages/@dcl/ecs/src/systems/crdt/index.ts @@ -216,15 +216,14 @@ export function crdtSceneSystem(engine: PreEngine, onProcessEntityComponentChang ...message, messageBuffer: buffer.buffer().subarray(offset, buffer.currentWriteOffset()) }) + } + if (onProcessEntityComponentChange) { + const rawValue = + message.type === CrdtMessageType.PUT_COMPONENT || message.type === CrdtMessageType.APPEND_VALUE + ? component.get(message.entityId) + : undefined - if (onProcessEntityComponentChange) { - const rawValue = - message.type === CrdtMessageType.PUT_COMPONENT || message.type === CrdtMessageType.APPEND_VALUE - ? component.get(message.entityId) - : undefined - - onProcessEntityComponentChange(message.entityId, message.type, component, rawValue) - } + onProcessEntityComponentChange(message.entityId, message.type, component, rawValue) } } } diff --git a/packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts b/packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts index 10e19a39c..fd9a49752 100644 --- a/packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts +++ b/packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts @@ -1,14 +1,22 @@ +import { Result } from 'arg' +import { args as startArgs } from '.' import { CliComponents } from '../../components' const isWindows = /^win/.test(process.platform) export async function runExplorerAlpha( components: CliComponents, - opts: { cwd: string; realm: string; baseCoords: { x: number; y: number }; isHub: boolean } + opts: { + cwd: string + realm: string + baseCoords: { x: number; y: number } + isHub: boolean + args: Result + } ) { const { cwd, realm, baseCoords, isHub } = opts - if (await runApp(components, { cwd, realm, baseCoords, isHub })) { + if (await runApp(components, { cwd, realm, baseCoords, isHub, args: opts.args })) { return } @@ -21,12 +29,21 @@ async function runApp( cwd, realm, baseCoords, - isHub - }: { cwd: string; realm: string; baseCoords: { x: number; y: number }; isHub: boolean } + isHub, + args + }: { + cwd: string + realm: string + baseCoords: { x: number; y: number } + isHub: boolean + args: Result + } ) { const cmd = isWindows ? 'start' : 'open' + // Remove (--) from the command + const extraArgs = args._.map(($) => $.replace(/^-+/, '')).join('&') try { - const params = `realm=${realm}&position=${baseCoords.x},${baseCoords.y}&local-scene=true&debug=true&hub=${isHub}` + const params = `realm=${realm}&position=${baseCoords.x},${baseCoords.y}&local-scene=true&debug=true&hub=${isHub}&${extraArgs}` const app = `decentraland://"${params}"` await components.spawner.exec(cwd, cmd, [app], { silent: true }) components.logger.info(`Desktop client: decentraland://${params}\n`) diff --git a/packages/@dcl/sdk-commands/src/commands/start/index.ts b/packages/@dcl/sdk-commands/src/commands/start/index.ts index ab5b3dbd8..ee15d9fad 100644 --- a/packages/@dcl/sdk-commands/src/commands/start/index.ts +++ b/packages/@dcl/sdk-commands/src/commands/start/index.ts @@ -97,7 +97,6 @@ export async function main(options: Options) { const isHub = !!options.args['--hub'] let hasSmartWearable = false - const workspace = await getValidWorkspace(options.components, workingDirectory) /* istanbul ignore if */ @@ -232,7 +231,7 @@ export async function main(options: Options) { if (explorerAlpha) { const realm = new URL(sortedURLs[0]).origin - await runExplorerAlpha(components, { cwd: workingDirectory, realm, baseCoords, isHub }) + await runExplorerAlpha(components, { cwd: workingDirectory, realm, baseCoords, isHub, args: options.args }) } // Open preferably localhost/127.0.0.1 diff --git a/packages/@dcl/sdk-commands/src/logic/args.ts b/packages/@dcl/sdk-commands/src/logic/args.ts index 1875f0a89..a7d89cc63 100644 --- a/packages/@dcl/sdk-commands/src/logic/args.ts +++ b/packages/@dcl/sdk-commands/src/logic/args.ts @@ -7,7 +7,7 @@ export type Args = { export function parseArgs(argv: string[], args: T): Result { try { - return arg({ '--json': Boolean, '-h': '--help', '--help': Boolean, ...args }, { permissive: false, argv }) + return arg({ '--json': Boolean, '-h': '--help', '--help': Boolean, ...args }, { permissive: true, argv }) } catch (err: any) { if (err.name === 'ArgError') throw new CliError(`Argument error: ` + err.message) /* istanbul ignore next */