Add evaluateForEffect method to support expression evaluation for side effects
Some checks failed
/ build (macos-latest) (push) Has been cancelled
/ build (ubuntu-latest) (push) Has been cancelled
/ build (windows-latest) (push) Has been cancelled

This commit is contained in:
mynameisdeleted
2026-07-10 03:57:54 -04:00
parent 96c26e5388
commit 18acf1d7f4
7 changed files with 93 additions and 0 deletions

View File

@@ -161,6 +161,24 @@ export class Model {
this.pollingTimer.onTick.sub(() => {
this.refresh();
});
// Exposed globally (not passed into custom visualizer scripts'
// closures) for the same reason setVisualizationModule is below:
// setCustomVisualizerScript's `eval()` runs plugin code in this
// same window/global scope, so a plugin (see vis-plugins/node-
// table-visualizer.js) can reach these to support editing values
// in place, without threading a new parameter through the whole
// register()/getVisualization()/render() plugin contract.
(globalThis as any).debugVisualizerSetValue = (expression: string) =>
this.evaluateForEffect(expression);
(globalThis as any).debugVisualizerRefresh = () => this.refresh();
}
async evaluateForEffect(expression: string): Promise<{ success: boolean; message: string }> {
if (!this.server) {
return { success: false, message: "Not connected to the debug visualizer server." };
}
return this.server.evaluateForEffect({ expression });
}
@action