// Copyright (c) 2015 Vadim Macagon
// MIT License, see LICENSE file for full terms.

import * as path from 'path';
import * as electron from 'electron';
import { IAppWindowConfig } from '../common/app-window-config';
import * as AppWindowConfig from '../common/app-window-config';

export interface IApplicationWindowOpenParams {
  windowUrl: string;
  config: IAppWindowConfig;
}

export class ApplicationWindow {
  private _browserWindow: GitHubElectron.BrowserWindow;

  open({ windowUrl, config }: IApplicationWindowOpenParams): void {
    const options = <GitHubElectron.BrowserWindowOptions> {
      // the window will be shown later after everything is fully initialized
      show: false,
      title: 'Debug Workbench',
      'web-preferences': {
        'direct-write': true
      }
    };
    this._browserWindow = new electron.BrowserWindow(options);
    this._browserWindow.loadURL(windowUrl + '#' + AppWindowConfig.encodeToUriComponent(config));
    this._bindEventHandlers();
  }

  private _bindEventHandlers(): void {
    this._browserWindow.on('closed', () => {
      this._browserWindow = null;
    });
  }
}

// Copyright (c) 2015 Vadim Macagon
// MIT License, see LICENSE file for full terms.

import * as path from 'path';
import * as electron from 'electron';
import { IAppWindowConfig } from '../common/app-window-config';
import * as AppWindowConfig from '../common/app-window-config';

export interface IApplicationWindowOpenParams {
  windowUrl: string;
  config: IAppWindowConfig;
}

export class ApplicationWindow {
  private _browserWindow: GitHubElectron.BrowserWindow;

  open({ windowUrl, config }: IApplicationWindowOpenParams): void {
    const options: GitHubElectron.BrowserWindowOptions = {
      // the window will be shown later after everything is fully initialized
      show: false,
      title: 'Debug Workbench',
      webPreferences: {
        directWrite: true
      }
    };
    this._browserWindow = new electron.BrowserWindow(options);
    this._browserWindow.loadURL(windowUrl + '#' + AppWindowConfig.encodeToUriComponent(config));
    this._bindEventHandlers();
  }

  private _bindEventHandlers(): void {
    this._browserWindow.on('closed', () => {
      this._browserWindow = null;
    });
  }
}

Fix misnamed options being used to create BrowserWindow(s)
Fix misnamed options being used to create BrowserWindow(s)

BrowserWindow option names were normalized in v0.35. I forgot to update
this bit after the recent update to the Electron typings, and TypeScript
didn't pick up the errors because strict checking of object literals
only occurs when the variable the object literal is assigned to
(`options` in this case) is declared with an explicit type
(and it wasn't in this case).
