11import { v4 as uuidv4 } from "uuid" ;
22import { publish } from "../utils" ;
3- import { Events , events , ManagerMsg , PromiseHandlers , UniverseConfig } from "../types" ;
4-
3+ import {
4+ Events ,
5+ events ,
6+ ManagerMsg ,
7+ PromiseHandlers ,
8+ UniverseConfig ,
9+ } from "../types" ;
510
611export default class CommsManager {
712 private static instance : CommsManager | undefined ;
@@ -53,7 +58,7 @@ export default class CommsManager {
5358 this . ws . onclose = ( e ) => {
5459 if ( e . wasClean ) {
5560 console . log (
56- `Connection with ${ address } closed, all suscribers cleared`
61+ `Connection with ${ address } closed, all suscribers cleared` ,
5762 ) ;
5863 } else {
5964 console . log ( `Connection with ${ address } interrupted` ) ;
@@ -100,7 +105,7 @@ export default class CommsManager {
100105 for ( let i = 0 , length = events . length ; i < length ; i ++ ) {
101106 this . observers [ events [ i ] ] = this . observers [ events [ i ] ] || [ ] ;
102107 this . observers [ events [ i ] ] . splice (
103- this . observers [ events [ i ] ] . indexOf ( callback )
108+ this . observers [ events [ i ] ] . indexOf ( callback ) ,
104109 ) ;
105110 }
106111 } ;
@@ -136,10 +141,10 @@ export default class CommsManager {
136141 }
137142
138143 private setManagerState ( msg : ManagerMsg ) {
139- publish ( "CommsManagerStateChange" , { state : msg . data . state } )
144+ publish ( "CommsManagerStateChange" , { state : msg . data . state } ) ;
140145 CommsManager . state = msg . data . state ;
141146 if ( msg . data . state === "connected" ) {
142- CommsManager . universe = undefined
147+ CommsManager . universe = undefined ;
143148 }
144149 }
145150
@@ -165,25 +170,22 @@ export default class CommsManager {
165170 }
166171
167172 public launchWorld ( cfg : UniverseConfig ) {
168- CommsManager . universe = cfg . name
173+ CommsManager . universe = cfg . name ;
169174 return this . send ( "launch_world" , cfg ) ;
170175 }
171176
172- public prepareVisualization (
173- visualization_type : string ,
174- visualization_config : string | null
175- ) {
176- if ( visualization_config === null || visualization_config === undefined ) {
177- visualization_config = "None" ;
177+ public prepareTools ( tools : string [ ] , tools_config : Object ) {
178+ if ( tools_config === null || tools_config === undefined ) {
179+ tools_config = "None" ;
178180 }
179- return this . send ( "prepare_visualization " , {
180- type : visualization_type ,
181- file : visualization_config ,
181+ return this . send ( "prepare_tools " , {
182+ tools : tools ,
183+ config : tools_config ,
182184 } ) ;
183185 }
184186
185- public run ( cfg : Object ) {
186- return this . send ( "run_application" , cfg ) ;
187+ public run ( entrypoint : string , code : string ) {
188+ return this . send ( "run_application" , { entrypoint : entrypoint , code : code } ) ;
187189 }
188190
189191 public stop ( ) {
@@ -236,4 +238,4 @@ export default class CommsManager {
236238 public code_autocomplete ( code : string , line : number , col : number ) {
237239 return this . send ( "code_autocomplete" , { code : code , line : line , col : col } ) ;
238240 }
239- }
241+ }
0 commit comments