circular deps
This commit is contained in:
		@ -34,8 +34,8 @@ import type {
 | 
				
			|||||||
  ModelingMachineEvent,
 | 
					  ModelingMachineEvent,
 | 
				
			||||||
  modelingMachine,
 | 
					  modelingMachine,
 | 
				
			||||||
} from '@src/machines/modelingMachine'
 | 
					} from '@src/machines/modelingMachine'
 | 
				
			||||||
 | 
					import type CodeManager from '@src/lang/codeManager'
 | 
				
			||||||
import { codeManagerHistoryCompartment } from '@src/lang/codeManager'
 | 
					import { codeManagerHistoryCompartment } from '@src/lang/codeManager'
 | 
				
			||||||
import { codeManager, kclManager } from '@src/lib/singletons'
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
declare global {
 | 
					declare global {
 | 
				
			||||||
  interface Window {
 | 
					  interface Window {
 | 
				
			||||||
@ -82,6 +82,7 @@ export default class EditorManager {
 | 
				
			|||||||
  private _editorState: EditorState
 | 
					  private _editorState: EditorState
 | 
				
			||||||
  private _editorView: EditorView | null = null
 | 
					  private _editorView: EditorView | null = null
 | 
				
			||||||
  public kclManager?: KclManager
 | 
					  public kclManager?: KclManager
 | 
				
			||||||
 | 
					  public codeManager?: CodeManager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  constructor(engineCommandManager: EngineCommandManager) {
 | 
					  constructor(engineCommandManager: EngineCommandManager) {
 | 
				
			||||||
    this.engineCommandManager = engineCommandManager
 | 
					    this.engineCommandManager = engineCommandManager
 | 
				
			||||||
@ -325,8 +326,8 @@ export default class EditorManager {
 | 
				
			|||||||
      console.log('before', state.doc.length, state.doc.toString())
 | 
					      console.log('before', state.doc.length, state.doc.toString())
 | 
				
			||||||
      const undoPerformed = undo(this)
 | 
					      const undoPerformed = undo(this)
 | 
				
			||||||
      if (undoPerformed) {
 | 
					      if (undoPerformed) {
 | 
				
			||||||
        codeManager.code = state.doc.toString()
 | 
					        this.codeManager!.code = state.doc.toString()
 | 
				
			||||||
        void kclManager.executeCode()
 | 
					        void this.kclManager!.executeCode()
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
      console.log(state.doc.length, state.doc.toString())
 | 
					      console.log(state.doc.length, state.doc.toString())
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
@ -341,8 +342,8 @@ export default class EditorManager {
 | 
				
			|||||||
        console.log('before', state.doc.length, state.doc.toString())
 | 
					        console.log('before', state.doc.length, state.doc.toString())
 | 
				
			||||||
        const redoPerformed = redo(this)
 | 
					        const redoPerformed = redo(this)
 | 
				
			||||||
        if (redoPerformed) {
 | 
					        if (redoPerformed) {
 | 
				
			||||||
          codeManager.code = state.doc.toString()
 | 
					          this.codeManager!.code = state.doc.toString()
 | 
				
			||||||
          void kclManager.executeCode()
 | 
					          void this.kclManager!.executeCode()
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
        console.log(state.doc.length, state.doc.toString())
 | 
					        console.log(state.doc.length, state.doc.toString())
 | 
				
			||||||
      }
 | 
					      }
 | 
				
			||||||
 | 
				
			|||||||
@ -69,6 +69,7 @@ export const kclManager = new KclManager(engineCommandManager, {
 | 
				
			|||||||
// method requires it for the current ast.
 | 
					// method requires it for the current ast.
 | 
				
			||||||
// CYCLIC REF
 | 
					// CYCLIC REF
 | 
				
			||||||
editorManager.kclManager = kclManager
 | 
					editorManager.kclManager = kclManager
 | 
				
			||||||
 | 
					editorManager.codeManager = codeManager
 | 
				
			||||||
 | 
					
 | 
				
			||||||
// These are all late binding because of their circular dependency.
 | 
					// These are all late binding because of their circular dependency.
 | 
				
			||||||
// TODO: proper dependency injection.
 | 
					// TODO: proper dependency injection.
 | 
				
			||||||
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user