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