import'./root/root-legacy.js';import*as RootModule from'./root/root.js';self.Runtime=self.Runtime||{};Runtime=Runtime||{};self.Root=self.Root||{};Root=Root||{};Root.allDescriptors=Root.allDescriptors||[];Root.applicationDescriptor=Root.applicationDescriptor||undefined;let appStartedPromiseCallback;Runtime.appStarted=new Promise(fulfil=>{appStartedPromiseCallback=fulfil;});export async function startApplication(appName){console.timeStamp('Root.Runtime.startApplication');const allDescriptorsByName={};for(let i=0;i<Root.allDescriptors.length;++i){const d=Root.allDescriptors[i];allDescriptorsByName[d['name']]=d;}
const configuration=Root.applicationDescriptor.modules;const moduleDescriptors=[];const coreModuleNames=[];for(let i=0;i<configuration.length;++i){const descriptor=configuration[i];const name=descriptor['name'];moduleDescriptors.push(allDescriptorsByName[name]);if(descriptor['type']==='autostart'){coreModuleNames.push(name);}}
for(let i=0;i<moduleDescriptors.length;++i){moduleDescriptors[i].name=configuration[i]['name'];moduleDescriptors[i].condition=configuration[i]['condition'];}
const runtimeInstance=RootModule.Runtime.Runtime.instance({forceNew:true,moduleDescriptors});self.runtime=runtimeInstance;if(coreModuleNames){await runtimeInstance.loadAutoStartModules(coreModuleNames);}
appStartedPromiseCallback();}
export async function startWorker(appName){return startApplication(appName).then(sendWorkerReady);function sendWorkerReady(){self.postMessage('workerReady');}}