{
  "name": "electron-window-state-manager",
  "version": "0.3.2",
  "description": "Window-state manager for electron",
  "main": "main.js",
  "scripts": {
    "test": "jasmine"
  },
  "keywords": [
    "electron"
  ],
  "repository": {
    "type": "git",
    "url": "https://github.com/Sethorax/electron-window-state-manager.git"
  },
  "author": {
    "name": "sethorax"
  },
  "license": "MIT",
  "dependencies": {
    "app-root-path": "^1.3.0",
    "fs-jetpack": "^0.9.2"
  },
  "devDependencies": {
    "jasmine": "^2.4.1",
    "proxyquire": "^1.7.10"
  },
  "readme": "# electron-window-state-manager [![Build Status](https://travis-ci.org/Sethorax/electron-window-state-manager.svg?branch=master)](https://travis-ci.org/Sethorax/electron-window-state-manager) [![Build status](https://ci.appveyor.com/api/projects/status/eude9rmxi0oi1pe8/branch/master?svg=true)](https://ci.appveyor.com/project/Sethorax/electron-window-state-manager/branch/master)\n\nThe Electron Window State Manager is a small package that gives you the ability to save the state of a `BrowserWindow` and retreive the saved data of the state later.\n\n# Installation\n```\nnpm install electron-window-state-manager\n```\n\n# What does it do?\n\nThe Window State Manager can store the dimensions (width and height), the position (x and y coordinates) and the current state (maximized or not) of a `BrowserWindow` and save it to a json file.  \nThe saved state can than later be retreived when using the same window name at the instance creation.\nThe saved state's data will be automatically retreived when creating a `WindowStateManager`instance with an already saved window name.\n\n## Usage\n\nTo be able to use this package in your project you need to require it:\n```javascript\nconst WindowStateManager = require('electron-window-state-manager');\n```\n\n#### Class: WindowStateManager\n\nIt creates a new `WindowStateManager` with a `name` and default properties as set by the `options`.\n\n### `new WindowStateManager(name, [options])`\n\n* `name` String - Name of the window.\n* `options` Object\n  * `defaultWidth` Integer - Default window width in pixels.\n  * `defaultHeight` Integer - Default window height in pixels.\n\nThe value of `name` is used to reference a saved state in the json file. If you create a new instance of `WindowStateManager` with a name which was already saved previously, the data of this state will be loaded.\n\nIf a state with the value of `name` cannot be found in the json file or a saved state has wrong data, the default values assigned in the `options` Object will be used.\n\n### Methods\n\nThe `WindowStateManager` class has the following methods:\n\n#### `WindowStateManager.saveState(window)`\n\n* `window` [BrowserWindow](https://github.com/atom/electron/blob/master/docs/api/browser-window.md)\n\nSaves the state of the passed `BrowserWindow` and returns `true`or `false` depending on whether the state was successfully saved to the json file.\n\nIn case the state of a window in fullscreen is saved, the saving process will not succeed because we don't want to save the dimensions of a fullscreen window.\n\nThe method returns `false` and will not save anything if a window in fullscreen is saved, because we don't want to save the dimensions of a fullscreen window.\n\nIf a maximized window is saved, the dimensions and position of the window will not be stored, only the previously saved values or the default values will be saved.\nHowever the maximized state of the window will be saved, so that you can open the window in a maximized state again later if the window was closed in a maximized state.\n\n\n## Example\n```javascript\nconst app = require('electron').app;\nconst BrowserWindow = require('electron').BrowserWindow;\nconst WindowStateManager = require('electron-window-state-manager');\n\nconst mainWindow;\n\n// Create a new instance of the WindowStateManager\n// and pass it the name and the default properties\nconst mainWindowState = new WindowStateManager('mainWindow', {\n    defaultWidth: 1024,\n    defaultHeight: 768\n});\n\napp.on('ready', () => {\n    // When creating a new BrowserWindow\n    // you can assign the properties of the mainWindowState.\n    // If a window with the name 'main' was saved before,\n    // the saved values will now be assigned to the BrowserWindow again\n    mainWindow = new BrowserWindow({\n        width: mainWindowState.width,\n        height: mainWindowState.height,\n        x: mainWindowState.x,\n        y: mainWindowState.y,\n    });\n\n    // You can check if the window was closed in a maximized saveState\n    // If so you can maximize the BrowserWindow again\n    if (mainWindowState.maximized) {\n        mainWindow.maximize();\n    }\n\n    // Don't forget to save the current state\n    // of the Browser window when it's about to be closed\n    mainWindow.on('close', () => {\n        mainWindowState.saveState(mainWindow);\n    });\n});\n```\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/Sethorax/electron-window-state-manager/issues"
  },
  "homepage": "https://github.com/Sethorax/electron-window-state-manager",
  "_id": "electron-window-state-manager@0.3.2",
  "_shasum": "a552ea35470297c999c744d81abb2a8c8a51770e",
  "_from": "electron-window-state-manager@^0.3.0",
  "_resolved": "https://registry.npmjs.org/electron-window-state-manager/-/electron-window-state-manager-0.3.2.tgz"
}
