Dead code clean up (smol PR) (#4653)
* general clean up * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores) * A snapshot a day keeps the bugs away! 📷🐛 (OS: ubuntu-latest-8-cores) * trigger CI * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores) * A snapshot a day keeps the bugs away! 📷🐛 (OS: windows-latest-8-cores) * trigger CI --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
@ -1,6 +1,6 @@
|
|||||||
import {
|
import {
|
||||||
Program,
|
Program,
|
||||||
_executor,
|
executor,
|
||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
kclLint,
|
kclLint,
|
||||||
emptyExecState,
|
emptyExecState,
|
||||||
@ -64,7 +64,7 @@ export async function executeAst({
|
|||||||
try {
|
try {
|
||||||
const execState = await (programMemoryOverride
|
const execState = await (programMemoryOverride
|
||||||
? enginelessExecutor(ast, programMemoryOverride)
|
? enginelessExecutor(ast, programMemoryOverride)
|
||||||
: _executor(ast, engineCommandManager))
|
: executor(ast, engineCommandManager))
|
||||||
|
|
||||||
await engineCommandManager.waitForAllCommands()
|
await engineCommandManager.waitForAllCommands()
|
||||||
|
|
||||||
|
@ -506,22 +506,6 @@ export const executor = async (
|
|||||||
return Promise.reject(programMemoryOverride)
|
return Promise.reject(programMemoryOverride)
|
||||||
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
engineCommandManager.startNewSession()
|
|
||||||
const _programMemory = await _executor(
|
|
||||||
node,
|
|
||||||
engineCommandManager,
|
|
||||||
programMemoryOverride
|
|
||||||
)
|
|
||||||
await engineCommandManager.waitForAllCommands()
|
|
||||||
|
|
||||||
return _programMemory
|
|
||||||
}
|
|
||||||
|
|
||||||
export const _executor = async (
|
|
||||||
node: Node<Program>,
|
|
||||||
engineCommandManager: EngineCommandManager,
|
|
||||||
programMemoryOverride: ProgramMemory | Error | null = null
|
|
||||||
): Promise<ExecState> => {
|
|
||||||
if (programMemoryOverride !== null && err(programMemoryOverride))
|
if (programMemoryOverride !== null && err(programMemoryOverride))
|
||||||
return Promise.reject(programMemoryOverride)
|
return Promise.reject(programMemoryOverride)
|
||||||
|
|
||||||
|
@ -1,20 +1,16 @@
|
|||||||
import {
|
import {
|
||||||
Program,
|
Program,
|
||||||
ProgramMemory,
|
ProgramMemory,
|
||||||
_executor,
|
executor,
|
||||||
SourceRange,
|
SourceRange,
|
||||||
ExecState,
|
ExecState,
|
||||||
} from '../lang/wasm'
|
} from '../lang/wasm'
|
||||||
import {
|
import { EngineCommandManager } from 'lang/std/engineConnection'
|
||||||
EngineCommandManager,
|
|
||||||
EngineCommandManagerEvents,
|
|
||||||
} from 'lang/std/engineConnection'
|
|
||||||
import { EngineCommand } from 'lang/std/artifactGraph'
|
import { EngineCommand } from 'lang/std/artifactGraph'
|
||||||
import { Models } from '@kittycad/lib'
|
import { Models } from '@kittycad/lib'
|
||||||
import { v4 as uuidv4 } from 'uuid'
|
import { v4 as uuidv4 } from 'uuid'
|
||||||
import { DefaultPlanes } from 'wasm-lib/kcl/bindings/DefaultPlanes'
|
import { DefaultPlanes } from 'wasm-lib/kcl/bindings/DefaultPlanes'
|
||||||
import { err, reportRejection } from 'lib/trap'
|
import { err } from 'lib/trap'
|
||||||
import { toSync } from './utils'
|
|
||||||
import { Node } from 'wasm-lib/kcl/bindings/Node'
|
import { Node } from 'wasm-lib/kcl/bindings/Node'
|
||||||
|
|
||||||
type WebSocketResponse = Models['WebSocketResponse_type']
|
type WebSocketResponse = Models['WebSocketResponse_type']
|
||||||
@ -94,36 +90,7 @@ export async function enginelessExecutor(
|
|||||||
}) as any as EngineCommandManager
|
}) as any as EngineCommandManager
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
||||||
mockEngineCommandManager.startNewSession()
|
mockEngineCommandManager.startNewSession()
|
||||||
const execState = await _executor(ast, mockEngineCommandManager, pmo)
|
const execState = await executor(ast, mockEngineCommandManager, pmo)
|
||||||
await mockEngineCommandManager.waitForAllCommands()
|
await mockEngineCommandManager.waitForAllCommands()
|
||||||
return execState
|
return execState
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function executor(
|
|
||||||
ast: Node<Program>,
|
|
||||||
pmo: ProgramMemory = ProgramMemory.empty()
|
|
||||||
): Promise<ExecState> {
|
|
||||||
const engineCommandManager = new EngineCommandManager()
|
|
||||||
engineCommandManager.start({
|
|
||||||
setIsStreamReady: () => {},
|
|
||||||
setMediaStream: () => {},
|
|
||||||
width: 0,
|
|
||||||
height: 0,
|
|
||||||
makeDefaultPlanes: () => {
|
|
||||||
return new Promise((resolve) => resolve(defaultPlanes))
|
|
||||||
},
|
|
||||||
})
|
|
||||||
|
|
||||||
return new Promise((resolve) => {
|
|
||||||
engineCommandManager.addEventListener(
|
|
||||||
EngineCommandManagerEvents.SceneReady,
|
|
||||||
toSync(async () => {
|
|
||||||
// eslint-disable-next-line @typescript-eslint/no-floating-promises
|
|
||||||
engineCommandManager.startNewSession()
|
|
||||||
const execState = await _executor(ast, engineCommandManager, pmo)
|
|
||||||
await engineCommandManager.waitForAllCommands()
|
|
||||||
resolve(execState)
|
|
||||||
}, reportRejection)
|
|
||||||
)
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user