import { Actor } from './actor.js'; import { Action } from './action.js'; // import mermaid from 'https://unpkg.com/mermaid@9.2.2/dist/mermaid.esm.mjs'; export class Scene { constructor(name, rootBox) { this.name = name; this.box = rootBox.addBox(name); this.titleBox = this.box.addBox().setInnerHTML(name); this.box.addBox('Spacer').setInnerHTML(' '); this.displayValuesBox = this.box.addBox(`${this.name}-values`); this.box.addBox('Spacer').setInnerHTML(' '); this.logBox = this.box.addBox(`${this.name}-log`); this.actors = new Set(); // this.seqDiagramContainer = this.box.addBox(`${this.name}-seq-diagram-container`); // this.seqDiagramBox = this.box.addBox(`${this.name}-seq-diagram`); // mermaid.mermaidAPI.initialize({ startOnLoad: false }); } addActor(name) { const actor = new Actor(name, this); return actor; } registerActor(actor) { this.actors.add(actor); } addAction(name) { const action = new Action(name, this); return action; } addDisplayValue(name) { const dv = this.displayValuesBox.addDisplayValue(name); return dv; } log(msg) { this.logBox.addBox().setInnerHTML(msg).monospace(); return this; } deactivateAll() { for (const actor of this.actors.values()) { console.log(actor); while (actor.active) { actor.deactivate(); } } } // async renderSequenceDiagram() { // await mermaid.mermaidAPI.render( // `${this.name}-seq-diagram-element`, // this.logBox.getInnerText(), // this.insertSvg, // this.seqDiagramContainer.el // ); // } // insertSvg (svgCode) { // this.seqDiagramBox.setInnerHTML(svgCode); // }; }