(host: string, options: HttpgdViewerOptions)
| 333 | // constructor called by the session watcher if a corresponding function was called in R |
| 334 | // creates a new api instance itself |
| 335 | constructor(host: string, options: HttpgdViewerOptions) { |
| 336 | this.host = host; |
| 337 | this.token = options.token; |
| 338 | this.parent = options.parent; |
| 339 | |
| 340 | this.api = new Httpgd(this.host, this.token, true); |
| 341 | this.api.onPlotsChanged((newState) => { |
| 342 | void this.refreshPlotsDelayed(newState.plots); |
| 343 | }); |
| 344 | this.api.onConnectionChanged(() => { |
| 345 | // todo |
| 346 | }); |
| 347 | this.api.onDeviceActiveChanged(() => { |
| 348 | // todo |
| 349 | }); |
| 350 | const conf = config(); |
| 351 | this.customOverwriteCssPath = conf.get('plot.customStyleOverwrites', ''); |
| 352 | const localResourceRoots = ( |
| 353 | this.customOverwriteCssPath ? |
| 354 | [extensionContext.extensionUri, vscode.Uri.file(path.dirname(this.customOverwriteCssPath))] : |
| 355 | undefined |
| 356 | ); |
| 357 | this.htmlRoot = options.htmlRoot; |
| 358 | this.htmlTemplate = fs.readFileSync(path.join(this.htmlRoot, 'index.ejs'), 'utf-8'); |
| 359 | this.smallPlotTemplate = fs.readFileSync(path.join(this.htmlRoot, 'smallPlot.ejs'), 'utf-8'); |
| 360 | this.showOptions = { |
| 361 | viewColumn: options.viewColumn ?? asViewColumn(conf.get<string>('session.viewers.viewColumn.plot'), vscode.ViewColumn.Two), |
| 362 | preserveFocus: !!options.preserveFocus |
| 363 | }; |
| 364 | this.webviewOptions = { |
| 365 | enableCommandUris: true, |
| 366 | enableScripts: true, |
| 367 | retainContextWhenHidden: true, |
| 368 | localResourceRoots: localResourceRoots |
| 369 | }; |
| 370 | this.defaultStripStyles = options.stripStyles ?? this.defaultStripStyles; |
| 371 | this.stripStyles = this.defaultStripStyles; |
| 372 | this.defaultPreviewPlotLayout = options.previewPlotLayout ?? this.defaultPreviewPlotLayout; |
| 373 | this.previewPlotLayout = this.defaultPreviewPlotLayout; |
| 374 | this.defaultFullWindow = options.fullWindow ?? this.defaultFullWindow; |
| 375 | this.fullWindow = this.defaultFullWindow; |
| 376 | this.resizeTimeoutLength = options.refreshTimeoutLength ?? this.resizeTimeoutLength; |
| 377 | this.refreshTimeoutLength = options.refreshTimeoutLength ?? this.refreshTimeoutLength; |
| 378 | void this.api.connect(); |
| 379 | //void this.checkState(); |
| 380 | } |
| 381 | |
| 382 | |
| 383 | // Methods to interact with the webview |
nothing calls this directly
no test coverage detected