2023-07-13 16:57:22 +10:00
|
|
|
import { Program } from '../lang/abstractSyntaxTreeTypes'
|
2023-06-22 16:43:33 +10:00
|
|
|
import { ProgramMemory, _executor } from '../lang/executor'
|
|
|
|
import { EngineCommandManager } from '../lang/std/engineConnection'
|
|
|
|
|
2023-07-10 15:15:07 +10:00
|
|
|
class MockEngineCommandManager {
|
|
|
|
constructor(mockParams: {
|
|
|
|
setIsStreamReady: (isReady: boolean) => void
|
|
|
|
setMediaStream: (stream: MediaStream) => void
|
|
|
|
}) {}
|
|
|
|
startNewSession() {}
|
|
|
|
waitForAllCommands() {}
|
|
|
|
waitForReady = new Promise<void>((resolve) => resolve())
|
2023-08-24 11:41:38 -07:00
|
|
|
sendModelingCommand() {}
|
2023-07-10 15:15:07 +10:00
|
|
|
sendSceneCommand() {}
|
|
|
|
}
|
|
|
|
|
|
|
|
export async function enginelessExecutor(
|
|
|
|
ast: Program,
|
|
|
|
pm: ProgramMemory = { root: {}, pendingMemory: {} }
|
|
|
|
): Promise<ProgramMemory> {
|
|
|
|
const mockEngineCommandManager = new MockEngineCommandManager({
|
|
|
|
setIsStreamReady: () => {},
|
|
|
|
setMediaStream: () => {},
|
|
|
|
}) as any as EngineCommandManager
|
|
|
|
await mockEngineCommandManager.waitForReady
|
|
|
|
mockEngineCommandManager.startNewSession()
|
|
|
|
const programMemory = await _executor(ast, pm, mockEngineCommandManager)
|
|
|
|
await mockEngineCommandManager.waitForAllCommands()
|
|
|
|
return programMemory
|
|
|
|
}
|
|
|
|
|
2023-06-22 16:43:33 +10:00
|
|
|
export async function executor(
|
|
|
|
ast: Program,
|
|
|
|
pm: ProgramMemory = { root: {}, pendingMemory: {} }
|
|
|
|
): Promise<ProgramMemory> {
|
2023-06-23 14:19:15 +10:00
|
|
|
const engineCommandManager = new EngineCommandManager({
|
|
|
|
setIsStreamReady: () => {},
|
|
|
|
setMediaStream: () => {},
|
2023-08-09 20:49:10 +10:00
|
|
|
width: 100,
|
|
|
|
height: 100,
|
2023-06-23 14:19:15 +10:00
|
|
|
})
|
2023-07-10 15:15:07 +10:00
|
|
|
await engineCommandManager.waitForReady
|
2023-06-22 16:43:33 +10:00
|
|
|
engineCommandManager.startNewSession()
|
|
|
|
const programMemory = await _executor(ast, pm, engineCommandManager)
|
|
|
|
await engineCommandManager.waitForAllCommands()
|
|
|
|
return programMemory
|
|
|
|
}
|