Version 2.2.0.

* Adds support for custom injected scripts with automatic reload
* Refactors extension
This commit is contained in:
Henning Dieterichs
2021-06-18 20:26:51 +02:00
parent 6ce5d666a3
commit d22e5d4111
46 changed files with 1421 additions and 716 deletions

View File

@@ -112,11 +112,11 @@ function getDebugVisualizerWebviewHtml(
window.addEventListener('message', event => {
if (event.source === window.frames[0]) {
if (event.data.command === "setState") {
console.log("setState", event.data.state);
// console.log("setState", event.data.state);
api.setState(event.data.state);
}
if (event.data.command === "getState") {
console.log("getState, sent ", api.getState());
// console.log("getState, sent ", api.getState());
window.frames[0].postMessage({ command: "getStateResult", state: api.getState() }, "*");
}
}

View File

@@ -2,9 +2,9 @@ import { Disposable } from "@hediet/std/disposable";
import { webviewContract } from "../webviewContract";
import { ConsoleRpcLogger, RequestHandlingError } from "@hediet/typed-json-rpc";
import {
EvaluationWatcher,
EvaluationWatchService,
} from "../EvaluationWatchService";
VisualizationWatch,
VisualizationWatchModel,
} from "../VisualizationWatchModel";
import { WebSocketStream } from "@hediet/typed-json-rpc-websocket";
import { observable, autorun } from "mobx";
import { WebviewServer } from "./WebviewServer";
@@ -15,12 +15,12 @@ import { Config } from "../Config";
export class WebviewConnection {
public readonly dispose = Disposable.fn();
@observable
private watcher: EvaluationWatcher | undefined = undefined;
private watcher: VisualizationWatch | undefined = undefined;
private readonly client: typeof webviewContract["TClientInterface"];
constructor(
evaluationWatchService: EvaluationWatchService,
evaluationWatchService: VisualizationWatchModel,
stream: WebSocketStream,
server: WebviewServer,
config: Config,
@@ -55,19 +55,16 @@ export class WebviewConnection {
setExpression: async ({ newExpression }) => {
throwIfNotAuthenticated();
let oldPreferredDataExtractor: EvaluationWatcher["preferredDataExtractor"];
let oldPreferredDataExtractor: VisualizationWatch["preferredDataExtractor"];
if (this.watcher) {
oldPreferredDataExtractor = this.watcher
.preferredDataExtractor;
this.dispose.untrack(this.watcher).dispose();
}
this.watcher = this.dispose.track(
evaluationWatchService.createEvaluationWatcher(
newExpression,
{
preferredDataExtractor: oldPreferredDataExtractor,
}
)
evaluationWatchService.createWatch(newExpression, {
preferredDataExtractor: oldPreferredDataExtractor,
})
);
},
openInBrowser: async ({}) => {

View File

@@ -8,7 +8,7 @@ import * as serveStatic from "serve-static";
import { Config } from "../Config";
import cryptoRandomString = require("crypto-random-string");
import { distPath } from "debug-visualizer-webview";
import { EvaluationWatchService } from "../EvaluationWatchService/EvaluationWatchService";
import { VisualizationWatchModel } from "../VisualizationWatchModel/VisualizationWatchModel";
import { URLSearchParams } from "url";
import { autorun, reaction } from "mobx";
@@ -19,7 +19,7 @@ export class WebviewServer {
public readonly connections = new Set<WebviewConnection>();
constructor(
dataSource: EvaluationWatchService,
dataSource: VisualizationWatchModel,
private readonly config: Config
) {
const app = express();
@@ -28,11 +28,13 @@ export class WebviewServer {
this.server = app.listen();
/*
console.log(
`Serving "${distPath}" on port ${
(this.server.address() as AddressInfo).port
}`
);
*/
const wss = new WebSocket.Server({ server: this.server });
wss.on("connection", async ws => {