This repository has been archived by the owner on Aug 16, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* initial changes to make it debuggable * production mode minifies the final file * add checks to build real scenes and libraries * a bit more readable makefile * move terser to dev dependencies * rename ulla -> dcl * fix build * checkpoint; * import only types when possible * rename shell to runtime Co-authored-by: Nicolas Chamo <[email protected]>
- Loading branch information
Showing
10 changed files
with
743 additions
and
656 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -30,4 +30,4 @@ | |
"." | ||
] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import { WebWorkerTransport } from 'decentraland-rpc' | ||
import { SceneRuntime } from './sdk/SceneRuntime' | ||
import type { IWorker } from 'decentraland-rpc/lib/common/transports/WebWorker' | ||
|
||
/** | ||
* This file starts the scene in a Node.js context. | ||
* The runtime ends up mocking the WebWorker environment | ||
* (postMessage,addEventListener,fetch, WebSocket) for fidelity. | ||
*/ | ||
|
||
export interface VMEnvironment extends IWorker { | ||
global: VMEnvironment | ||
__env__onTick(cb: (dt: number) => void): void | ||
__env__error(error: Error): void | ||
__env__log(...args: any[]): void | ||
runCode(filename: string): Promise<void> | ||
} | ||
|
||
const globalObject: VMEnvironment = globalThis as any | ||
|
||
if (!('global' in globalObject)) { | ||
;(globalObject as any).global = globalObject | ||
} | ||
|
||
class CliScene extends SceneRuntime { | ||
onError(error: Error): void { | ||
globalObject.__env__error(error) | ||
} | ||
|
||
onLog(...messages: any[]): void { | ||
globalObject.__env__log(...messages) | ||
} | ||
|
||
async runCode(location: string, env: any): Promise<void> { | ||
Object.assign(globalObject, env) | ||
return globalObject.runCode(location) | ||
} | ||
|
||
startLoop(): void { | ||
globalObject.__env__onTick((dt) => this.update(dt)) | ||
} | ||
} | ||
|
||
// tslint:disable-next-line | ||
new CliScene(WebWorkerTransport(globalObject)) |
Oops, something went wrong.