remove _deffer (#3114)
* remove _deffer Signed-off-by: Paul Tagliamonte <paul@zoo.dev>
This commit is contained in:
@ -177,7 +177,7 @@ const FileTreeItem = ({
|
||||
codeManager.writeToFile()
|
||||
|
||||
kclManager.isFirstRender = true
|
||||
kclManager.executeCode(true, true).then(() => {
|
||||
kclManager.executeCode(true).then(() => {
|
||||
kclManager.isFirstRender = false
|
||||
})
|
||||
} else {
|
||||
|
@ -175,7 +175,7 @@ export const ModelingMachineProvider = ({
|
||||
}
|
||||
|
||||
store.videoElement?.pause()
|
||||
kclManager.executeCode(true).then(() => {
|
||||
kclManager.executeCode().then(() => {
|
||||
if (engineCommandManager.engineConnection?.idleMode) return
|
||||
|
||||
store.videoElement?.play()
|
||||
|
@ -66,7 +66,7 @@ export const KclEditorPane = () => {
|
||||
|
||||
useEffect(() => {
|
||||
if (typeof window === 'undefined') return
|
||||
const onlineCallback = () => kclManager.executeCode(true, true)
|
||||
const onlineCallback = () => kclManager.executeCode(true)
|
||||
window.addEventListener('online', onlineCallback)
|
||||
return () => window.removeEventListener('online', onlineCallback)
|
||||
}, [])
|
||||
|
@ -177,7 +177,7 @@ export const SettingsAuthProviderBase = ({
|
||||
},
|
||||
'Execute AST': () => {
|
||||
kclManager.isFirstRender = true
|
||||
kclManager.executeCode(true, true).then(() => {
|
||||
kclManager.executeCode(true).then(() => {
|
||||
kclManager.isFirstRender = false
|
||||
})
|
||||
},
|
||||
|
@ -117,11 +117,7 @@ export class KclPlugin implements PluginValue {
|
||||
}
|
||||
|
||||
if (!this.client.ready) return
|
||||
try {
|
||||
kclManager.executeCode()
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
}
|
||||
|
||||
ensureDocUpdated() {
|
||||
|
@ -55,7 +55,7 @@ export function useSetupEngineManager(
|
||||
// We only want to execute the code here that we already have set.
|
||||
// Nothing else.
|
||||
kclManager.isFirstRender = true
|
||||
return kclManager.executeCode(true, true).then(() => {
|
||||
return kclManager.executeCode(true).then(() => {
|
||||
kclManager.isFirstRender = false
|
||||
})
|
||||
},
|
||||
|
@ -38,22 +38,6 @@ export class KclManager {
|
||||
private _wasmInitFailed = true
|
||||
|
||||
engineCommandManager: EngineCommandManager
|
||||
private _defferer = deferExecution((code: string) => {
|
||||
const ast = this.safeParse(code)
|
||||
if (!ast) {
|
||||
this.clearAst()
|
||||
return
|
||||
}
|
||||
try {
|
||||
const fmtAndStringify = (ast: Program) =>
|
||||
JSON.stringify(parse(recast(ast)))
|
||||
const isAstTheSame = fmtAndStringify(ast) === fmtAndStringify(this._ast)
|
||||
if (isAstTheSame) return
|
||||
} catch (e) {
|
||||
console.error(e)
|
||||
}
|
||||
this.executeAst(ast)
|
||||
}, 600)
|
||||
|
||||
private _isExecutingCallback: (arg: boolean) => void = () => {}
|
||||
private _astCallBack: (arg: Program) => void = () => {}
|
||||
@ -331,10 +315,8 @@ export class KclManager {
|
||||
this._cancelTokens.set(key, true)
|
||||
})
|
||||
}
|
||||
async executeCode(force?: boolean, zoomToFit?: boolean): Promise<void> {
|
||||
// If we want to force it we don't want to defer it.
|
||||
if (!force) return this._defferer(codeManager.code)
|
||||
|
||||
async executeCode(zoomToFit?: boolean): Promise<void> {
|
||||
console.log('[kcl/KclSingleton] executeCode')
|
||||
const ast = this.safeParse(codeManager.code)
|
||||
if (!ast) {
|
||||
this.clearAst()
|
||||
|
@ -105,7 +105,7 @@ export const fileLoader: LoaderFunction = async ({
|
||||
codeManager.updateCurrentFilePath(current_file_path)
|
||||
codeManager.updateCodeStateEditor(code)
|
||||
// We don't want to call await on execute code since we don't want to block the UI
|
||||
kclManager.executeCode(true, true)
|
||||
kclManager.executeCode(true)
|
||||
|
||||
// Set the file system manager to the project path
|
||||
// So that WASM gets an updated path for operations
|
||||
|
@ -56,7 +56,7 @@ function OnboardingWithNewFile() {
|
||||
next={() => {
|
||||
// We do want to update both the state and editor here.
|
||||
codeManager.updateCodeEditor(bracket)
|
||||
kclManager.executeCode(true, true)
|
||||
kclManager.executeCode(true)
|
||||
next()
|
||||
}}
|
||||
nextText="Overwrite code and continue"
|
||||
|
@ -14,7 +14,7 @@ export default function Sketching() {
|
||||
codeManager.updateCodeEditor('')
|
||||
if (kclManager.engineCommandManager.engineConnection?.isReady()) {
|
||||
// If the engine is ready, promptly execute the loaded code
|
||||
kclManager.executeCode(true, true)
|
||||
kclManager.executeCode(true)
|
||||
}
|
||||
}, [])
|
||||
|
||||
|
Reference in New Issue
Block a user