Gather KCL Manager info for CoreDump
This commit is contained in:
@ -157,9 +157,18 @@ export class CoreDumpManager {
|
||||
|
||||
// Currently just a placeholder to begin loading singleton and xstate data into
|
||||
getClientState(): Promise<string> {
|
||||
|
||||
/**
|
||||
* Deep clone a JavaScript Object
|
||||
* - NOTE: this function thows on parse errors from things like circular references
|
||||
* - It is also syncronous and could be more performant
|
||||
* - There is a whole rabbit hole to explore here if you like.
|
||||
* - This work for our use case.
|
||||
* @param {object} obj - The object to clone.
|
||||
*/
|
||||
const deepClone = (obj: any) => JSON.parse(JSON.stringify(obj))
|
||||
|
||||
console.warn('Gathering client state for coredump')
|
||||
console.warn('CoreDump: Gathering client state')
|
||||
|
||||
// Initialize the clientState object
|
||||
let clientState: ClientState = {
|
||||
@ -184,16 +193,18 @@ export class CoreDumpManager {
|
||||
modeling_machine: { meta: [] },
|
||||
settings_machine: { meta: [] },
|
||||
}
|
||||
console.log('initialized clientState', clientState)
|
||||
console.log('CoreDump: initialized clientState', clientState)
|
||||
|
||||
try {
|
||||
|
||||
// Singletons
|
||||
|
||||
// engine_command_manager
|
||||
console.log('engineCommandManager', this.engineCommandManager)
|
||||
console.log('CoreDump: the engineCommandManager singlton', this.engineCommandManager)
|
||||
|
||||
// artifact map - this.engineCommandManager.artifactMap
|
||||
if (this.engineCommandManager?.artifactMap) {
|
||||
console.log('artifact map', this.engineCommandManager.artifactMap)
|
||||
console.log('CoreDump: artifact map', this.engineCommandManager.artifactMap)
|
||||
clientState.engine_command_manager.artifact_map = deepClone(
|
||||
this.engineCommandManager.artifactMap
|
||||
)
|
||||
@ -201,7 +212,7 @@ export class CoreDumpManager {
|
||||
|
||||
// command logs - this.engineCommandManager.commandLogs
|
||||
if (this.engineCommandManager?.commandLogs) {
|
||||
console.log('command logs', this.engineCommandManager.commandLogs)
|
||||
console.log('CoreDump: command logs', this.engineCommandManager.commandLogs)
|
||||
clientState.engine_command_manager.command_logs = deepClone(
|
||||
this.engineCommandManager.commandLogs
|
||||
)
|
||||
@ -209,7 +220,7 @@ export class CoreDumpManager {
|
||||
|
||||
// default planes - this.engineCommandManager.defaultPlanes
|
||||
if (this.engineCommandManager?.defaultPlanes) {
|
||||
console.log('default planes', this.engineCommandManager.defaultPlanes)
|
||||
console.log('CoreDump: default planes', this.engineCommandManager.defaultPlanes)
|
||||
clientState.engine_command_manager.default_planes = deepClone(
|
||||
this.engineCommandManager.defaultPlanes
|
||||
)
|
||||
@ -220,21 +231,21 @@ export class CoreDumpManager {
|
||||
clientState.engine_command_manager.engine_connection.state =
|
||||
this.engineCommandManager.engineConnection.state
|
||||
console.log(
|
||||
'engine connection state',
|
||||
'CoreDump: engine connection state',
|
||||
this.engineCommandManager.engineConnection.state
|
||||
)
|
||||
}
|
||||
|
||||
// in sequence - this.engineCommandManager.inSequence
|
||||
if (this.engineCommandManager?.inSequence) {
|
||||
console.log('in sequence', this.engineCommandManager.inSequence)
|
||||
console.log('CoreDump: in sequence', this.engineCommandManager.inSequence)
|
||||
clientState.engine_command_manager.in_sequence =
|
||||
this.engineCommandManager.inSequence
|
||||
}
|
||||
|
||||
// out sequence - this.engineCommandManager.outSequence
|
||||
if (this.engineCommandManager?.inSequence) {
|
||||
console.log('out sequence', this.engineCommandManager.outSequence)
|
||||
console.log('CoreDump: out sequence', this.engineCommandManager.outSequence)
|
||||
clientState.engine_command_manager.out_sequence =
|
||||
this.engineCommandManager.inSequence
|
||||
}
|
||||
@ -242,7 +253,7 @@ export class CoreDumpManager {
|
||||
// scene command artifacts - this.engineCommandManager.sceneCommandArtifacts
|
||||
if (this.engineCommandManager?.sceneCommandArtifacts) {
|
||||
console.log(
|
||||
'scene command artifacts',
|
||||
'CoreDump: scene command artifacts',
|
||||
this.engineCommandManager.sceneCommandArtifacts
|
||||
)
|
||||
clientState.engine_command_manager.scene_command_artifacts = deepClone(
|
||||
@ -250,36 +261,52 @@ export class CoreDumpManager {
|
||||
)
|
||||
}
|
||||
|
||||
// KCL Manager
|
||||
console.log('kclManager', this.kclManager)
|
||||
// KCL Manager - this.kclManager
|
||||
console.log('CoreDump: kclManager', this.kclManager)
|
||||
|
||||
// this.kclManager.ast
|
||||
console.log('KCL Manager AST', this?.kclManager?.ast)
|
||||
if (this?.kclManager) {
|
||||
// this.kclManager.ast Object - this?.kclManager?.ast
|
||||
console.log('CoreDump: KCL Manager AST', this?.kclManager?.ast)
|
||||
clientState.kcl_manager.ast = deepClone(this.kclManager.ast)
|
||||
|
||||
// this.kclManager.kclErrors
|
||||
console.log('KCL Errors', this?.kclManager?.kclErrors)
|
||||
// this.kclManager.kclErrors Array - this?.kclManager?.kclErrors
|
||||
console.log('CoreDump: KCL Errors', this?.kclManager?.kclErrors)
|
||||
clientState.kcl_manager.kcl_errors = deepClone(this.kclManager.kclErrors)
|
||||
}
|
||||
|
||||
// Scene Infra - this.sceneInfra
|
||||
console.log('CoreDump: Scene Infra', this.sceneInfra)
|
||||
//scene_infra
|
||||
|
||||
// TODO: /src/lib/singletons.ts also defines the following singletons
|
||||
// sceneEntitiesManager
|
||||
// editorManager
|
||||
// enableMousePositionLogs
|
||||
|
||||
// XState Machines
|
||||
|
||||
console.log('xstateServices', this?.__xstate__?.services)
|
||||
console.log('CoreDump: xstateServices', this?.__xstate__?.services)
|
||||
let xstateServices = this?.__xstate__?.services || new Set()
|
||||
|
||||
xstateServices?.forEach((interpreter: any) => {
|
||||
console.log('interpreter', interpreter)
|
||||
console.log('CoreDump: XState interpreter', interpreter)
|
||||
// Command Bar Machine XState
|
||||
if (interpreter.id('Command Bar')) {
|
||||
// clientState.command_bar_machine.meta.push(1)
|
||||
}
|
||||
})
|
||||
|
||||
console.log('final clientState', clientState)
|
||||
console.log('JSON', JSON.stringify(clientState))
|
||||
console.log('CoreDump: final clientState', clientState)
|
||||
|
||||
const clientStateJson = JSON.stringify(clientState);
|
||||
console.log('CoreDump: final clientState JSON', clientStateJson)
|
||||
|
||||
return Promise.resolve(clientStateJson)
|
||||
|
||||
try {
|
||||
return Promise.resolve(JSON.stringify(clientState))
|
||||
} catch (error) {
|
||||
console.error('unable to return coredump data due to ', error)
|
||||
|
||||
console.error('CoreDump: unable to return data due to ', error)
|
||||
return Promise.reject(JSON.stringify(error))
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user