Skip to content

Commit

Permalink
fix onChange for custom componetns
Browse files Browse the repository at this point in the history
forward params to explorer alpha
  • Loading branch information
gonpombo8 committed Dec 6, 2024
1 parent 085da37 commit e7441ed
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
15 changes: 7 additions & 8 deletions packages/@dcl/ecs/src/systems/crdt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
}
Expand Down
27 changes: 22 additions & 5 deletions packages/@dcl/sdk-commands/src/commands/start/explorer-alpha.ts
Original file line number Diff line number Diff line change
@@ -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<typeof startArgs>
}
) {
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
}

Expand All @@ -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<typeof startArgs>
}
) {
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`)
Expand Down
3 changes: 1 addition & 2 deletions packages/@dcl/sdk-commands/src/commands/start/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/@dcl/sdk-commands/src/logic/args.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export type Args = {

export function parseArgs<T extends Args>(argv: string[], args: T): Result<T> {
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 */
Expand Down

0 comments on commit e7441ed

Please sign in to comment.