mirror of
https://github.com/SillyTavern/SillyTavern.git
synced 2025-06-05 21:59:27 +02:00
debugger basics rough
This commit is contained in:
41
public/scripts/slash-commands/SlashCommandDebugController.js
Normal file
41
public/scripts/slash-commands/SlashCommandDebugController.js
Normal file
@ -0,0 +1,41 @@
|
||||
import { SlashCommandClosure } from './SlashCommandClosure.js';
|
||||
import { SlashCommandExecutor } from './SlashCommandExecutor.js';
|
||||
|
||||
export class SlashCommandDebugController {
|
||||
/**@type {boolean} */ isStepping = false;
|
||||
/**@type {boolean} */ isSteppingInto = false;
|
||||
|
||||
/**@type {Promise<boolean>} */ continuePromise;
|
||||
/**@type {(boolean)=>void} */ continueResolver;
|
||||
|
||||
/**@type {(closure:SlashCommandClosure, executor:SlashCommandExecutor)=>Promise<boolean>} */ onBreakPoint;
|
||||
|
||||
|
||||
|
||||
resume() {
|
||||
this.continueResolver?.(false);
|
||||
this.continuePromise = null;
|
||||
}
|
||||
step() {
|
||||
this.continueResolver?.(true);
|
||||
this.continuePromise = null;
|
||||
}
|
||||
stepInto() {
|
||||
this.isSteppingInto = true;
|
||||
this.continueResolver?.(true);
|
||||
this.continuePromise = null;
|
||||
}
|
||||
|
||||
async awaitContinue() {
|
||||
this.continuePromise ??= new Promise(resolve=>{
|
||||
this.continueResolver = resolve;
|
||||
});
|
||||
this.isStepping = await this.continuePromise;
|
||||
return this.isStepping;
|
||||
}
|
||||
|
||||
async awaitBreakPoint(closure, executor) {
|
||||
this.isStepping = await this.onBreakPoint(closure, executor);
|
||||
return this.isStepping;
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user