Skip to content

TagSpaces is an offline, open source, document manager with tagging support

adding support for saving the windows state, size and location

uggrockb35514be49d7
diff --git a/data/electron/main.js b/data/electron/main.js
index b72d85fe2..4ebb8caea 100644
--- a/data/electron/main.js
+++ b/data/electron/main.js
@@ -8,15 +8,16 @@ const Menu = electron.Menu;
const Tray = electron.Tray;
const globalShortcut = electron.globalShortcut;
const dialog = electron.dialog;
+const windowStateKeeper = require('electron-window-state');
-var debugMode;
-var portableMode;
-var startupFilePath;
-var trayIcon = null;
+let debugMode;
+let portableMode;
+let startupFilePath;
+let trayIcon = null;
//handling start parameter
//console.log(JSON.stringify(process.argv));
-process.argv.forEach(function(arg, count) {
+process.argv.forEach((arg, count) => {
if (arg.toLowerCase() === '-d' || arg.toLowerCase() === '--debug') {
debugMode = true;
} else if (arg.toLowerCase() === '-p' || arg.toLowerCase() === '--portable') {
@@ -34,18 +35,18 @@ if (portableMode) {
startupFilePath = undefined;
}
-ipcMain.on('quit-application', function(event, arg) {
+ipcMain.on('quit-application', (event, arg) => {
app.quit();
});
-var path = require('path');
+let path = require('path');
// Keep a global reference of the window object, if you don't, the window will
// be closed automatically when the JavaScript object is garbage collected.
-var mainWindow = null, newWindow = null;
-//var childWindow = null;
+let mainWindow = null;
+let newWindow = null;
// Quit when all windows are closed.
-app.on('window-all-closed', function() {
+app.on('window-all-closed', () => {
// On OS X it is common for applications and their menu bar
// to stay active until the user quits explicitly with Cmd + Q
//if (process.platform != 'darwin') {
@@ -53,19 +54,19 @@ app.on('window-all-closed', function() {
//}
});
-app.on('will-quit', function() {
+app.on('will-quit', () => {
// Unregister all shortcuts.
globalShortcut.unregisterAll();
});
-ipcMain.on("new-win", function() {
+ipcMain.on("new-win", () => {
newWindow = new BrowserWindow({width: 1280, height: 768});
- //var indexPath = 'file://' + __dirname + '/index.html';
- var startupParameter = "";
+
+ let startupParameter = "";
if (startupFilePath) {
startupParameter = "?open=" + encodeURIComponent(startupFilePath);
}
- var indexPath = 'file://' + path.dirname(__dirname) + '/index.html' + startupParameter;
+ let indexPath = 'file://' + path.dirname(__dirname) + '/index.html' + startupParameter;
newWindow.setMenu(null);
newWindow.loadURL(indexPath);
@@ -74,30 +75,47 @@ ipcMain.on("new-win", function() {
newWindow.webContents.openDevTools();
}
- newWindow.once('ready-to-show', function() {
+ newWindow.once('ready-to-show', () => {
newWindow.show();
});
- ipcMain.on('win-close', function(e, arg) {
+ ipcMain.on('win-close', (e, arg) => {
newWindow.hide();
});
- ipcMain.on('close', function(e, arg) {
+ ipcMain.on('close', (e, arg) => {
newWindow.hide();
});
});
-app.on('ready', function(event) {
+app.on('ready', (event) => {
//console.log(app.getLocale());
//console.log(app.getAppPath());
- mainWindow = new BrowserWindow({width: 1280, height: 768});
- //var indexPath = 'file://' + __dirname + '/index.html';
- var startupParameter = "";
+ // Load the previous state with fallback to defaults
+ let mainWindowState = windowStateKeeper({
+ defaultWidth: 1280,
+ defaultHeight: 768
+ });
+
+ // Create the window using the state information
+ mainWindow = new BrowserWindow({
+ 'x': mainWindowState.x,
+ 'y': mainWindowState.y,
+ 'width': mainWindowState.width,
+ 'height': mainWindowState.height
+ });
+
+ // Let us register listeners on the window, so we can update the state
+ // automatically (the listeners will be removed when the window is closed)
+ // and restore the maximized or full screen state
+ mainWindowState.manage(mainWindow);
+
+ let startupParameter = "";
if (startupFilePath) {
startupParameter = "?open=" + encodeURIComponent(startupFilePath);
}
- var indexPath = 'file://' + path.dirname(__dirname) + '/index.html' + startupParameter;
+ let indexPath = 'file://' + path.dirname(__dirname) + '/index.html' + startupParameter;
mainWindow.setMenu(null);
mainWindow.loadURL(indexPath);
@@ -107,25 +125,25 @@ app.on('ready', function(event) {
}
// Emitted when the window is closed.
- mainWindow.on('closed', function() {
+ mainWindow.on('closed', () => {
// Dereference the window object, usually you would store windows
// in an array if your app supports multi windows, this is the time
// when you should delete the corresponding element.
mainWindow = null;
});
- ipcMain.on('close', function(e, arg) {
+ ipcMain.on('close', (e, arg) => {
mainWindow.hide();
});
- mainWindow.webContents.on('crashed', function() {
+ mainWindow.webContents.on('crashed', () => {
const options = {
type: 'info',
title: 'Renderer Process Crashed',
message: 'This process has crashed.',
buttons: ['Reload', 'Close']
};
- dialog.showMessageBox(mainWindow, options, function(index) {
+ dialog.showMessageBox(mainWindow, options, (index) => {
mainWindow.hide();
if (index === 0) {
mainWindow.reload();
@@ -135,13 +153,13 @@ app.on('ready', function(event) {
});
});
- ipcMain.on('win-close', function(e, arg) {
+ ipcMain.on('win-close', (e, arg) => {
mainWindow.hide();
});
- var focusedWindow = BrowserWindow.getFocusedWindow();
+ let focusedWindow = BrowserWindow.getFocusedWindow();
- var trayIconPath;
+ let trayIconPath;
if (process.platform === 'darwin') {
trayIconPath = path.join(__dirname, '/../assets/icon16.png');
} else if (process.platform === 'win32') {
@@ -152,12 +170,12 @@ app.on('ready', function(event) {
trayIcon = new Tray(trayIconPath);
- var ctrlName = "Ctrl";
+ let ctrlName = "Ctrl";
if (process.platform == 'darwin') {
ctrlName = "Cmd";
}
- var trayMenuTemplate = [
+ let trayMenuTemplate = [
{
label: 'Show TagSpaces (' + ctrlName + '+Alt+W)',
click: showTagSpaces
@@ -204,13 +222,13 @@ app.on('ready', function(event) {
},
{
label: 'Quit TagSpaces',
- click: function() {
+ click: () => {
app.quit();
}
}
];
- trayIcon.on('click', function() {
+ trayIcon.on('click', () => {
if (mainWindow) {
mainWindow.show();
} else {
@@ -219,8 +237,8 @@ app.on('ready', function(event) {
//mainWindow.isVisible() ? mainWindow.hide() : mainWindow.show();
});
- var title = 'TagSpaces App';
- var trayMenu = Menu.buildFromTemplate(trayMenuTemplate);
+ let title = 'TagSpaces App';
+ let trayMenu = Menu.buildFromTemplate(trayMenuTemplate);
// trayIcon.setToolTip(title);
// trayIcon.setTitle(title);
trayIcon.setContextMenu(trayMenu);
@@ -315,7 +333,7 @@ app.on('ready', function(event) {
}
});
-process.on('uncaughtException', function(error) {
+process.on('uncaughtException', (error) => {
if (error.stack) {
console.error('error:', error.stack);
}
diff --git a/data/electron/package.tmpl.json b/data/electron/package.tmpl.json
index bdb9a7bc6..d9524a5e0 100644
--- a/data/electron/package.tmpl.json
+++ b/data/electron/package.tmpl.json
@@ -6,6 +6,7 @@
"version": "@@VERSION.@@BUILD",
"main": "electron/main.js",
"dependencies": {
+ "electron-window-state": "^4.0.0",
"fs-extra": "~1.0.0"
},
"devDependencies": {
diff --git a/data/node_modules/electron-window-state/index.js b/data/node_modules/electron-window-state/index.js
new file mode 100644
index 000000000..9a0632b14
--- /dev/null
+++ b/data/node_modules/electron-window-state/index.js
@@ -0,0 +1,172 @@
+'use strict';
+
+var path = require('path');
+var electron = require('electron');
+var jsonfile = require('jsonfile');
+var mkdirp = require('mkdirp');
+var deepEqual = require('deep-equal');
+
+module.exports = function (options) {
+ var app = electron.app;
+ var screen = electron.screen;
+ var state;
+ var winRef;
+ var stateChangeTimer;
+ var eventHandlingDelay = 100;
+ var config = Object.assign({
+ file: 'window-state.json',
+ path: app.getPath('userData'),
+ maximize: true,
+ fullScreen: true
+ }, options);
+ var fullStoreFileName = path.join(config.path, config.file);
+
+ function isNormal(win) {
+ return !win.isMaximized() && !win.isMinimized() && !win.isFullScreen();
+ }
+
+ function hasBounds() {
+ return state &&
+ state.x !== undefined &&
+ state.y !== undefined &&
+ state.width !== undefined &&
+ state.height !== undefined;
+ }
+
+ function validateState() {
+ var isValid = state && (hasBounds() || state.isMaximized || state.isFullScreen);
+ if (!isValid) {
+ state = null;
+ return;
+ }
+
+ if (hasBounds() && state.displayBounds) {
+ // Check if the display where the window was last open is still available
+ var displayBounds = screen.getDisplayMatching(state).bounds;
+ var sameBounds = deepEqual(state.displayBounds, displayBounds, {strict: true});
+ if (!sameBounds) {
+ if (displayBounds.width < state.displayBounds.width) {
+ if (state.x > displayBounds.width) {
+ state.x = null;
+ }
+
+ if (state.width > displayBounds.width) {
+ state.width = displayBounds.width;
+ }
+ }
+
+ if (displayBounds.height < state.displayBounds.height) {
+ if (state.y > displayBounds.height) {
+ state.y = null;
+ }
+
+ if (state.height > displayBounds.height) {
+ state.height = displayBounds.height;
+ }
+ }
+ }
+ }
+ }
+
+ function updateState(win) {
+ win = win || winRef;
+ if (!win) {
+ return;
+ }
+
+ var winBounds = win.getBounds();
+ if (isNormal(win)) {
+ state.x = winBounds.x;
+ state.y = winBounds.y;
+ state.width = winBounds.width;
+ state.height = winBounds.height;
+ }
+ state.isMaximized = win.isMaximized();
+ state.isFullScreen = win.isFullScreen();
+ state.displayBounds = screen.getDisplayMatching(winBounds).bounds;
+ }
+
+ function saveState(win) {
+ // Update window state only if it was provided
+ if (win) {
+ updateState(win);
+ }
+
+ // Save state
+ try {
+ mkdirp.sync(path.dirname(fullStoreFileName));
+ jsonfile.writeFileSync(fullStoreFileName, state);
+ } catch (err) {
+ // Don't care
+ }
+ }
+
+ function stateChangeHandler() {
+ // Handles both 'resize' and 'move'
+ clearTimeout(stateChangeTimer);
+ stateChangeTimer = setTimeout(updateState, eventHandlingDelay);
+ }
+
+ function closeHandler() {
+ updateState();
+ }
+
+ function closedHandler() {
+ // Unregister listeners and save state
+ unmanage();
+ saveState();
+ }
+
+ function manage(win) {
+ if (config.maximize && state.isMaximized) {
+ win.maximize();
+ }
+ if (config.fullScreen && state.isFullScreen) {
+ win.setFullScreen(true);
+ }
+ win.on('resize', stateChangeHandler);
+ win.on('move', stateChangeHandler);
+ win.on('close', closeHandler);
+ win.on('closed', closedHandler);
+ winRef = win;
+ }
+
+ function unmanage() {
+ if (winRef) {
+ winRef.removeListener('resize', stateChangeHandler);
+ winRef.removeListener('move', stateChangeHandler);
+ clearTimeout(stateChangeTimer);
+ winRef.removeListener('close', closeHandler);
+ winRef.removeListener('closed', closedHandler);
+ winRef = null;
+ }
+ }
+
+ // Load previous state
+ try {
+ state = jsonfile.readFileSync(fullStoreFileName);
+ } catch (err) {
+ // Don't care
+ }
+
+ // Check state validity
+ validateState();
+
+ // Set state fallback values
+ state = Object.assign({
+ width: config.defaultWidth || 800,
+ height: config.defaultHeight || 600
+ }, state);
+
+ return {
+ get x() { return state.x; },
+ get y() { return state.y; },
+ get width() { return state.width; },
+ get height() { return state.height; },
+ get isMaximized() { return state.isMaximized; },
+ get isFullScreen() { return state.isFullScreen; },
+ saveState: saveState,
+ unmanage: unmanage,
+ manage: manage
+ };
+};
diff --git a/data/node_modules/electron-window-state/license b/data/node_modules/electron-window-state/license
new file mode 100644
index 000000000..8078dfa34
--- /dev/null
+++ b/data/node_modules/electron-window-state/license
@@ -0,0 +1,22 @@
+The MIT License (MIT)
+
+Copyright (c) 2015 Jakub Szwacz
+Copyright (c) Marcel Wiehle <[email protected]> (http://marcel.wiehle.me)
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/data/node_modules/electron-window-state/package.json b/data/node_modules/electron-window-state/package.json
new file mode 100644
index 000000000..9f53932bc
--- /dev/null
+++ b/data/node_modules/electron-window-state/package.json
@@ -0,0 +1,115 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "electron-window-state",
+ "scope": null,
+ "escapedName": "electron-window-state",
+ "name": "electron-window-state",
+ "rawSpec": "",
+ "spec": "latest",
+ "type": "tag"
+ },
+ "/home/na/TagSpaces/repo/data"
+ ]
+ ],
+ "_from": "electron-window-state@latest",
+ "_id": "[email protected]",
+ "_inCache": true,
+ "_installable": true,
+ "_location": "/electron-window-state",
+ "_nodeVersion": "6.8.0",
+ "_npmOperationalInternal": {
+ "host": "packages-12-west.internal.npmjs.com",
+ "tmp": "tmp/electron-window-state-4.0.0.tgz_1479926522550_0.4300933440681547"
+ },
+ "_npmUser": {
+ "name": "mawie81",
+ "email": "[email protected]"
+ },
+ "_npmVersion": "3.10.8",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "electron-window-state",
+ "scope": null,
+ "escapedName": "electron-window-state",
+ "name": "electron-window-state",
+ "rawSpec": "",
+ "spec": "latest",
+ "type": "tag"
+ },
+ "_requiredBy": [
+ "#USER",
+ "/"
+ ],
+ "_resolved": "https://registry.npmjs.org/electron-window-state/-/electron-window-state-4.0.0.tgz",
+ "_shasum": "ac24438162d4640506b4a36dd8363a1c3abd278f",
+ "_shrinkwrap": null,
+ "_spec": "electron-window-state",
+ "_where": "/home/na/TagSpaces/repo/data",
+ "author": {
+ "name": "Marcel Wiehle"
+ },
+ "bugs": {
+ "url": "https://github.com/mawie81/electron-window-state/issues"
+ },
+ "dependencies": {
+ "deep-equal": "^1.0.1",
+ "jsonfile": "^2.2.3",
+ "mkdirp": "^0.5.1"
+ },
+ "description": "Simple module that helps to save and restore size and position of Electron windows.",
+ "devDependencies": {
+ "ava": "^0.17.0",
+ "mockery": "^1.4.0",
+ "sinon": "^1.17.2",
+ "xo": "^0.17.1"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "ac24438162d4640506b4a36dd8363a1c3abd278f",
+ "tarball": "https://registry.npmjs.org/electron-window-state/-/electron-window-state-4.0.0.tgz"
+ },
+ "engines": {
+ "node": ">=4.0.0"
+ },
+ "files": [
+ "index.js"
+ ],
+ "gitHead": "2c302e5e2da1a128d6566eaab759f32bdbf490ca",
+ "homepage": "https://github.com/mawie81/electron-window-state#readme",
+ "keywords": [
+ "electron"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "maintainers": [
+ {
+ "name": "mawie81",
+ "email": "[email protected]"
+ }
+ ],
+ "name": "electron-window-state",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/mawie81/electron-window-state.git"
+ },
+ "scripts": {
+ "test": "xo && ava"
+ },
+ "version": "4.0.0",
+ "xo": {
+ "space": true,
+ "rules": {
+ "brace-style": [
+ 2,
+ "1tbs",
+ {
+ "allowSingleLine": true
+ }
+ ]
+ }
+ }
+}
diff --git a/data/node_modules/minimist/LICENSE b/data/node_modules/minimist/LICENSE
new file mode 100644
index 000000000..ee27ba4b4
--- /dev/null
+++ b/data/node_modules/minimist/LICENSE
@@ -0,0 +1,18 @@
+This software is released under the MIT license:
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of
+this software and associated documentation files (the "Software"), to deal in
+the Software without restriction, including without limitation the rights to
+use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
+the Software, and to permit persons to whom the Software is furnished to do so,
+subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all
+copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
+FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
+COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
+IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
+CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
diff --git a/data/node_modules/minimist/index.js b/data/node_modules/minimist/index.js
new file mode 100644
index 000000000..584f551a6
--- /dev/null
+++ b/data/node_modules/minimist/index.js
@@ -0,0 +1,187 @@
+module.exports = function (args, opts) {
+ if (!opts) opts = {};
+
+ var flags = { bools : {}, strings : {} };
+
+ [].concat(opts['boolean']).filter(Boolean).forEach(function (key) {
+ flags.bools[key] = true;
+ });
+
+ [].concat(opts.string).filter(Boolean).forEach(function (key) {
+ flags.strings[key] = true;
+ });
+
+ var aliases = {};
+ Object.keys(opts.alias || {}).forEach(function (key) {
+ aliases[key] = [].concat(opts.alias[key]);
+ aliases[key].forEach(function (x) {
+ aliases[x] = [key].concat(aliases[key].filter(function (y) {
+ return x !== y;
+ }));
+ });
+ });
+
+ var defaults = opts['default'] || {};
+
+ var argv = { _ : [] };
+ Object.keys(flags.bools).forEach(function (key) {
+ setArg(key, defaults[key] === undefined ? false : defaults[key]);
+ });
+
+ var notFlags = [];
+
+ if (args.indexOf('--') !== -1) {
+ notFlags = args.slice(args.indexOf('--')+1);
+ args = args.slice(0, args.indexOf('--'));
+ }
+
+ function setArg (key, val) {
+ var value = !flags.strings[key] && isNumber(val)
+ ? Number(val) : val
+ ;
+ setKey(argv, key.split('.'), value);
+
+ (aliases[key] || []).forEach(function (x) {
+ setKey(argv, x.split('.'), value);
+ });
+ }
+
+ for (var i = 0; i < args.length; i++) {
+ var arg = args[i];
+
+ if (/^--.+=/.test(arg)) {
+ // Using [\s\S] instead of . because js doesn't support the
+ // 'dotall' regex modifier. See:
+ // http://stackoverflow.com/a/1068308/13216
+ var m = arg.match(/^--([^=]+)=([\s\S]*)$/);
+ setArg(m[1], m[2]);
+ }
+ else if (/^--no-.+/.test(arg)) {
+ var key = arg.match(/^--no-(.+)/)[1];
+ setArg(key, false);
+ }
+ else if (/^--.+/.test(arg)) {
+ var key = arg.match(/^--(.+)/)[1];
+ var next = args[i + 1];
+ if (next !== undefined && !/^-/.test(next)
+ && !flags.bools[key]
+ && (aliases[key] ? !flags.bools[aliases[key]] : true)) {
+ setArg(key, next);
+ i++;
+ }
+ else if (/^(true|false)$/.test(next)) {
+ setArg(key, next === 'true');
+ i++;
+ }
+ else {
+ setArg(key, flags.strings[key] ? '' : true);
+ }
+ }
+ else if (/^-[^-]+/.test(arg)) {
+ var letters = arg.slice(1,-1).split('');
+
+ var broken = false;
+ for (var j = 0; j < letters.length; j++) {
+ var next = arg.slice(j+2);
+
+ if (next === '-') {
+ setArg(letters[j], next)
+ continue;
+ }
+
+ if (/[A-Za-z]/.test(letters[j])
+ && /-?\d+(\.\d*)?(e-?\d+)?$/.test(next)) {
+ setArg(letters[j], next);
+ broken = true;
+ break;
+ }
+
+ if (letters[j+1] && letters[j+1].match(/\W/)) {
+ setArg(letters[j], arg.slice(j+2));
+ broken = true;
+ break;
+ }
+ else {
+ setArg(letters[j], flags.strings[letters[j]] ? '' : true);
+ }
+ }
+
+ var key = arg.slice(-1)[0];
+ if (!broken && key !== '-') {
+ if (args[i+1] && !/^(-|--)[^-]/.test(args[i+1])
+ && !flags.bools[key]
+ && (aliases[key] ? !flags.bools[aliases[key]] : true)) {
+ setArg(key, args[i+1]);
+ i++;
+ }
+ else if (args[i+1] && /true|false/.test(args[i+1])) {
+ setArg(key, args[i+1] === 'true');
+ i++;
+ }
+ else {
+ setArg(key, flags.strings[key] ? '' : true);
+ }
+ }
+ }
+ else {
+ argv._.push(
+ flags.strings['_'] || !isNumber(arg) ? arg : Number(arg)
+ );
+ }
+ }
+
+ Object.keys(defaults).forEach(function (key) {
+ if (!hasKey(argv, key.split('.'))) {
+ setKey(argv, key.split('.'), defaults[key]);
+
+ (aliases[key] || []).forEach(function (x) {
+ setKey(argv, x.split('.'), defaults[key]);
+ });
+ }
+ });
+
+ notFlags.forEach(function(key) {
+ argv._.push(key);
+ });
+
+ return argv;
+};
+
+function hasKey (obj, keys) {
+ var o = obj;
+ keys.slice(0,-1).forEach(function (key) {
+ o = (o[key] || {});
+ });
+
+ var key = keys[keys.length - 1];
+ return key in o;
+}
+
+function setKey (obj, keys, value) {
+ var o = obj;
+ keys.slice(0,-1).forEach(function (key) {
+ if (o[key] === undefined) o[key] = {};
+ o = o[key];
+ });
+
+ var key = keys[keys.length - 1];
+ if (o[key] === undefined || typeof o[key] === 'boolean') {
+ o[key] = value;
+ }
+ else if (Array.isArray(o[key])) {
+ o[key].push(value);
+ }
+ else {
+ o[key] = [ o[key], value ];
+ }
+}
+
+function isNumber (x) {
+ if (typeof x === 'number') return true;
+ if (/^0x[0-9a-f]+$/i.test(x)) return true;
+ return /^[-+]?(?:\d+(?:\.\d*)?|\.\d+)(e[-+]?\d+)?$/.test(x);
+}
+
+function longest (xs) {
+ return Math.max.apply(null, xs.map(function (x) { return x.length }));
+}
diff --git a/data/node_modules/minimist/package.json b/data/node_modules/minimist/package.json
new file mode 100644
index 000000000..f16cbeb22
--- /dev/null
+++ b/data/node_modules/minimist/package.json
@@ -0,0 +1,102 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "[email protected]",
+ "scope": null,
+ "escapedName": "minimist",
+ "name": "minimist",
+ "rawSpec": "0.0.8",
+ "spec": "0.0.8",
+ "type": "version"
+ },
+ "/home/na/TagSpaces/repo/data/node_modules/mkdirp"
+ ]
+ ],
+ "_from": "[email protected]",
+ "_id": "[email protected]",
+ "_inCache": true,
+ "_installable": true,
+ "_location": "/minimist",
+ "_npmUser": {
+ "name": "substack",
+ "email": "[email protected]"
+ },
+ "_npmVersion": "1.4.3",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "[email protected]",
+ "scope": null,
+ "escapedName": "minimist",
+ "name": "minimist",
+ "rawSpec": "0.0.8",
+ "spec": "0.0.8",
+ "type": "version"
+ },
+ "_requiredBy": [
+ "/mkdirp"
+ ],
+ "_resolved": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz",
+ "_shasum": "857fcabfc3397d2625b8228262e86aa7a011b05d",
+ "_shrinkwrap": null,
+ "_spec": "[email protected]",
+ "_where": "/home/na/TagSpaces/repo/data/node_modules/mkdirp",
+ "author": {
+ "name": "James Halliday",
+ "email": "[email protected]",
+ "url": "http://substack.net"
+ },
+ "bugs": {
+ "url": "https://github.com/substack/minimist/issues"
+ },
+ "dependencies": {},
+ "description": "parse argument options",
+ "devDependencies": {
+ "tap": "~0.4.0",
+ "tape": "~1.0.4"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "857fcabfc3397d2625b8228262e86aa7a011b05d",
+ "tarball": "https://registry.npmjs.org/minimist/-/minimist-0.0.8.tgz"
+ },
+ "homepage": "https://github.com/substack/minimist",
+ "keywords": [
+ "argv",
+ "getopt",
+ "parser",
+ "optimist"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "maintainers": [
+ {
+ "name": "substack",
+ "email": "[email protected]"
+ }
+ ],
+ "name": "minimist",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/substack/minimist.git"
+ },
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "testling": {
+ "files": "test/*.js",
+ "browsers": [
+ "ie/6..latest",
+ "ff/5",
+ "firefox/latest",
+ "chrome/10",
+ "chrome/latest",
+ "safari/5.1",
+ "safari/latest",
+ "opera/12"
+ ]
+ },
+ "version": "0.0.8"
+}
diff --git a/data/node_modules/mkdirp/LICENSE b/data/node_modules/mkdirp/LICENSE
new file mode 100644
index 000000000..432d1aeb0
--- /dev/null
+++ b/data/node_modules/mkdirp/LICENSE
@@ -0,0 +1,21 @@
+Copyright 2010 James Halliday ([email protected])
+
+This project is free software released under the MIT/X11 license:
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/data/node_modules/mkdirp/bin/cmd.js b/data/node_modules/mkdirp/bin/cmd.js
new file mode 100644
index 000000000..d95de15ae
--- /dev/null
+++ b/data/node_modules/mkdirp/bin/cmd.js
@@ -0,0 +1,33 @@
+#!/usr/bin/env node
+
+var mkdirp = require('../');
+var minimist = require('minimist');
+var fs = require('fs');
+
+var argv = minimist(process.argv.slice(2), {
+ alias: { m: 'mode', h: 'help' },
+ string: [ 'mode' ]
+});
+if (argv.help) {
+ fs.createReadStream(__dirname + '/usage.txt').pipe(process.stdout);
+ return;
+}
+
+var paths = argv._.slice();
+var mode = argv.mode ? parseInt(argv.mode, 8) : undefined;
+
+(function next () {
+ if (paths.length === 0) return;
+ var p = paths.shift();
+
+ if (mode === undefined) mkdirp(p, cb)
+ else mkdirp(p, mode, cb)
+
+ function cb (err) {
+ if (err) {
+ console.error(err.message);
+ process.exit(1);
+ }
+ else next();
+ }
+})();
diff --git a/data/node_modules/mkdirp/index.js b/data/node_modules/mkdirp/index.js
new file mode 100644
index 000000000..6ce241b58
--- /dev/null
+++ b/data/node_modules/mkdirp/index.js
@@ -0,0 +1,98 @@
+var path = require('path');
+var fs = require('fs');
+var _0777 = parseInt('0777', 8);
+
+module.exports = mkdirP.mkdirp = mkdirP.mkdirP = mkdirP;
+
+function mkdirP (p, opts, f, made) {
+ if (typeof opts === 'function') {
+ f = opts;
+ opts = {};
+ }
+ else if (!opts || typeof opts !== 'object') {
+ opts = { mode: opts };
+ }
+
+ var mode = opts.mode;
+ var xfs = opts.fs || fs;
+
+ if (mode === undefined) {
+ mode = _0777 & (~process.umask());
+ }
+ if (!made) made = null;
+
+ var cb = f || function () {};
+ p = path.resolve(p);
+
+ xfs.mkdir(p, mode, function (er) {
+ if (!er) {
+ made = made || p;
+ return cb(null, made);
+ }
+ switch (er.code) {
+ case 'ENOENT':
+ mkdirP(path.dirname(p), opts, function (er, made) {
+ if (er) cb(er, made);
+ else mkdirP(p, opts, cb, made);
+ });
+ break;
+
+ // In the case of any other error, just see if there's a dir
+ // there already. If so, then hooray! If not, then something
+ // is borked.
+ default:
+ xfs.stat(p, function (er2, stat) {
+ // if the stat fails, then that's super weird.
+ // let the original error be the failure reason.
+ if (er2 || !stat.isDirectory()) cb(er, made)
+ else cb(null, made);
+ });
+ break;
+ }
+ });
+}
+
+mkdirP.sync = function sync (p, opts, made) {
+ if (!opts || typeof opts !== 'object') {
+ opts = { mode: opts };
+ }
+
+ var mode = opts.mode;
+ var xfs = opts.fs || fs;
+
+ if (mode === undefined) {
+ mode = _0777 & (~process.umask());
+ }
+ if (!made) made = null;
+
+ p = path.resolve(p);
+
+ try {
+ xfs.mkdirSync(p, mode);
+ made = made || p;
+ }
+ catch (err0) {
+ switch (err0.code) {
+ case 'ENOENT' :
+ made = sync(path.dirname(p), opts, made);
+ sync(p, opts, made);
+ break;
+
+ // In the case of any other error, just see if there's a dir
+ // there already. If so, then hooray! If not, then something
+ // is borked.
+ default:
+ var stat;
+ try {
+ stat = xfs.statSync(p);
+ }
+ catch (err1) {
+ throw err0;
+ }
+ if (!stat.isDirectory()) throw err0;
+ break;
+ }
+ }
+
+ return made;
+};
diff --git a/data/node_modules/mkdirp/package.json b/data/node_modules/mkdirp/package.json
new file mode 100644
index 000000000..9c46e5d84
--- /dev/null
+++ b/data/node_modules/mkdirp/package.json
@@ -0,0 +1,94 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "mkdirp@^0.5.1",
+ "scope": null,
+ "escapedName": "mkdirp",
+ "name": "mkdirp",
+ "rawSpec": "^0.5.1",
+ "spec": ">=0.5.1 <0.6.0",
+ "type": "range"
+ },
+ "/home/na/TagSpaces/repo/data/node_modules/electron-window-state"
+ ]
+ ],
+ "_from": "mkdirp@>=0.5.1 <0.6.0",
+ "_id": "[email protected]",
+ "_inCache": true,
+ "_installable": true,
+ "_location": "/mkdirp",
+ "_nodeVersion": "2.0.0",
+ "_npmUser": {
+ "name": "substack",
+ "email": "[email protected]"
+ },
+ "_npmVersion": "2.9.0",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "mkdirp@^0.5.1",
+ "scope": null,
+ "escapedName": "mkdirp",
+ "name": "mkdirp",
+ "rawSpec": "^0.5.1",
+ "spec": ">=0.5.1 <0.6.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/electron-window-state"
+ ],
+ "_resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz",
+ "_shasum": "30057438eac6cf7f8c4767f38648d6697d75c903",
+ "_shrinkwrap": null,
+ "_spec": "mkdirp@^0.5.1",
+ "_where": "/home/na/TagSpaces/repo/data/node_modules/electron-window-state",
+ "author": {
+ "name": "James Halliday",
+ "email": "[email protected]",
+ "url": "http://substack.net"
+ },
+ "bin": {
+ "mkdirp": "bin/cmd.js"
+ },
+ "bugs": {
+ "url": "https://github.com/substack/node-mkdirp/issues"
+ },
+ "dependencies": {
+ "minimist": "0.0.8"
+ },
+ "description": "Recursively mkdir, like `mkdir -p`",
+ "devDependencies": {
+ "mock-fs": "2 >=2.7.0",
+ "tap": "1"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "30057438eac6cf7f8c4767f38648d6697d75c903",
+ "tarball": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.1.tgz"
+ },
+ "gitHead": "d4eff0f06093aed4f387e88e9fc301cb76beedc7",
+ "homepage": "https://github.com/substack/node-mkdirp#readme",
+ "keywords": [
+ "mkdir",
+ "directory"
+ ],
+ "license": "MIT",
+ "main": "index.js",
+ "maintainers": [
+ {
+ "name": "substack",
+ "email": "[email protected]"
+ }
+ ],
+ "name": "mkdirp",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/substack/node-mkdirp.git"
+ },
+ "scripts": {
+ "test": "tap test/*.js"
+ },
+ "version": "0.5.1"
+}
diff --git a/data/package.json b/data/package.json
index d50432ffb..f7bffffd2 100644
--- a/data/package.json
+++ b/data/package.json
@@ -6,6 +6,7 @@
"version": "2.6.2",
"main": "electron/main.js",
"dependencies": {
+ "electron-window-state": "^4.0.0",
"fs-extra": "~1.0.0"
},
"devDependencies": {
@@ -27,4 +28,4 @@
"start": "electron .",
"test": "electron . -d"
}
-}
\ No newline at end of file
+}