TheDesk Mio (ver.1 beta)

This commit is contained in:
cutls
2018-05-02 13:14:03 +09:00
parent 7caed2d119
commit e4414f6051
45 changed files with 599 additions and 1320 deletions

View File

@@ -1,5 +0,0 @@
/typings
/.git
/example
npm-debug.log
node_modules

View File

@@ -1,3 +0,0 @@
{
"extends": "stylelint-config-standard"
}

View File

@@ -1,19 +0,0 @@
Copyright (c) 2015 rhysd
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.

View File

@@ -1,100 +0,0 @@
'About This App' Window for [Electron](https://github.com/atom/electron) Apps
=============================================================================
[![npm version](https://badge.fury.io/js/about-window.svg)](https://www.npmjs.com/package/about-window)
[This package](https://www.npmjs.com/package/about-window) provides 'About This App' window for [Electron](https://github.com/atom/electron) applications.
- [x] Create 'About This App' window from given parameters
- [x] Icon path
- [x] Copy right
- [x] App name and Versions
- [x] Description
- [x] Gather package information from package.json
- [x] Automatically detect package.json
- [x] Adjust window size to its contents automatically
- [x] CSS customizability
You can install this module via [npm](https://www.npmjs.com/).
```sh
$ npm install about-window
```
Only one function is exported as default. Please see [TypeScript type definition](index.d.ts).
The function can be called from both main process and renderer process.
```typescript
export default function openAboutWindow(info: {
icon_path: string;
package_json_dir?: string;
bug_report_url?: string;
copyright?: string;
homepage?: string;
description?: string;
license?: string;
css_path?: string;
adjust_window_size?: boolean;
win_options?: BrowserWindowOptions;
}): BrowserWindow
```
Only `icon_path` property is required, others are optional.
I recommend to specify as below to extract information from package.json as much as possible.
Path to package.json is also automatically detected if possible.
```typescript
openAboutWindow({
icon_path: 'path/to/icon.png'
});
```
You can check [an example app](example) to know how to use this package.
```sh
$ git clone https://github.com/rhysd/about-window.git
$ cd about-window/example
$ npm install
$ npm start
# Or for debug
$ npm run debug
```
### Parameter's properties of `openAboutWindow()`
| Name | Description | Type |
|------|-------------|------|
| `icon_path` | Path to icon file of the application. The path is passed to `src` property of `<img>` element. **Required** | string |
| `package_json_dir` | Path to directory which contains package.json. If not specified, it will try to detect a path to package.json. If also failed, it gives up and show less information in 'About This App' window. **Optional** | string |
| `bug_report_url` | URL to bug report page. If not specified, 'bugs' entry in package.json is used. **Optional** | string |
| `copyright` | Copyright notice shown in window. If not specified, it is replaced with license description generated by 'license' entry of package.json. **Optional** | string |
| `homepage` | URL of application's web page. If not specified, 'homepage' entry of package.json is used instead. **Optional** | string |
| `description` | Description of the application. If not specified, 'description' entry of package.json is used instead. **Optional** | string |
| `license` | License of the application. If not specified, 'license' entry of package.json is used instead. This property is used when `copyright` is not specified. **Optional** | string |
| `win_options` | Options of 'About This App' window. It is merged into default options. **Optional** | [BrowserWindow options object](https://github.com/atom/electron/blob/master/docs/api/browser-window.md#new-browserwindowoptions) |
| `css_path` | Path to user-defined CSS file. It will be inserted to DOM of the window. **Optional** | string |
| `adjust_window_size` | Adjust the window size to its content not to show scroll bar. **Optional** | boolean |
| `open_devtools` | For debug purpose, Chrome DevTools will start when the window is opened **Optional** | boolean |
| `use_inner_html` | If `true`, set the value with `.innerHTML` on copyright, license and description Default is `false` **Optional** | boolean |
**Note:** If you set `use_inner_html` to `true`, please ensure that contents don't contain any untrusted external input
in order to avoid XSS. Be careful.
## Screen Shots
### Linux
![Linux screenshot](https://raw.githubusercontent.com/rhysd/ss/master/about-window/about-window-linux.png)
### OS X
![OS X screenshot](https://raw.githubusercontent.com/rhysd/ss/master/about-window/about-window-os-x.png)
### Windows
![Windows screenshot](https://raw.githubusercontent.com/rhysd/ss/master/about-window/about-window-windows.jpg)
## License
[MIT License](/LICENSE.txt).

View File

@@ -1,27 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, minimum-scale=1.0, initial-scale=1, user-scalable=yes">
<title>About This App</title>
<link rel="stylesheet" href="./styles/ui.css">
<link href="https://fonts.googleapis.com/icon?family=Material+Icons|Open+Sans:300" rel="stylesheet">
</head>
<body>
<div class="logo">
<img id="app-icon" alt="App icon" height="200">
</div>
<h2 class="title"></h2>
<span class="description"></span>
<div class="copyright"></div>
<table class="versions"></table>
<footer class="footer">
<div class="link bug-report-link"></div>
</footer>
<!-- https://github.com/electron/electron/issues/2863 -->
<script>var exports = exports || {};</script>
<script src="./src/renderer.js"></script>
</body>
</html>

View File

@@ -1,18 +0,0 @@
/// <reference types="electron" />
export interface AboutWindowInfo {
icon_path: string;
package_json_dir?: string;
bug_report_url?: string;
copyright?: string;
homepage?: string;
description?: string;
license?: string;
win_options?: Electron.BrowserWindowConstructorOptions;
css_path?: string;
adjust_window_size?: boolean;
open_devtools?: boolean;
use_inner_html?: boolean;
}
export default function openAboutWindow(into: AboutWindowInfo): Electron.BrowserWindow;

View File

@@ -1,105 +0,0 @@
{
"_args": [
[
{
"raw": "about-window",
"scope": null,
"escapedName": "about-window",
"name": "about-window",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"C:\\Users\\ryuki\\TheDesk"
]
],
"_from": "about-window@latest",
"_id": "about-window@1.8.0",
"_inCache": true,
"_location": "/about-window",
"_nodeVersion": "6.10.3",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/about-window-1.8.0.tgz_1506494385445_0.4268775100354105"
},
"_npmUser": {
"name": "rhysd",
"email": "lin90162@yahoo.co.jp"
},
"_npmVersion": "3.10.10",
"_phantomChildren": {},
"_requested": {
"raw": "about-window",
"scope": null,
"escapedName": "about-window",
"name": "about-window",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"_requiredBy": [
"#USER"
],
"_resolved": "https://registry.npmjs.org/about-window/-/about-window-1.8.0.tgz",
"_shasum": "3e183cfaef4342e1fea6c442f4e43f682e9da580",
"_shrinkwrap": null,
"_spec": "about-window",
"_where": "C:\\Users\\ryuki\\TheDesk",
"author": {
"name": "rhysd",
"email": "lin90162@yahoo.co.jp"
},
"bugs": {
"url": "https://github.com/rhysd/electron-about-window/issues"
},
"dependencies": {},
"description": "'About App' window for Electron application",
"devDependencies": {
"@types/node": "^8.0.24",
"electron": "^1.7.5",
"stylelint": "^8.0.0",
"stylelint-config-standard": "^17.0.0",
"tslint": "^5.6.0",
"typescript": "^2.4.2"
},
"directories": {},
"dist": {
"shasum": "3e183cfaef4342e1fea6c442f4e43f682e9da580",
"tarball": "https://registry.npmjs.org/about-window/-/about-window-1.8.0.tgz"
},
"gitHead": "c2dac96372fcde38f2f842c00a34f024d0bdf4c1",
"homepage": "https://github.com/rhysd/electron-about-window#readme",
"keywords": [
"Electron",
"electron-component",
"about",
"window"
],
"license": "MIT",
"main": "src/index.js",
"maintainers": [
{
"name": "rhysd",
"email": "lin90162@yahoo.co.jp"
}
],
"name": "about-window",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/rhysd/electron-about-window.git"
},
"scripts": {
"build": "tsc -p src/",
"debug": "electron ./example",
"dep": "npm install",
"example": "NODE_ENV=production electron ./example",
"lint": "npm run tslint && npm run stylelint",
"preversion": "npm run lint && npm run build",
"start": "npm run dep && npm run build && npm run example",
"stylelint": "stylelint styles/*.css",
"tslint": "tslint -p ./src --type-check"
},
"version": "1.8.0"
}

View File

@@ -1,115 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
const fs_1 = require("fs");
const path = require("path");
let window = null;
function loadPackageJson(pkg_path) {
try {
return require(pkg_path);
}
catch (e) {
return null;
}
}
function detectPackageJson(specified_dir) {
if (specified_dir) {
const pkg = loadPackageJson(path.join(specified_dir, 'package.json'));
if (pkg !== null) {
return pkg;
}
else {
console.warn('about-window: package.json is not found in specified directory path: ' + specified_dir);
}
}
const app_name = electron_1.app.getName();
for (const mod_path of module.paths) {
if (!path.isAbsolute(mod_path)) {
continue;
}
const p = path.join(mod_path, '..', 'package.json');
try {
const stats = fs_1.statSync(p);
if (stats.isFile()) {
const pkg = loadPackageJson(p);
if (pkg !== null && pkg.productName === app_name) {
return pkg;
}
}
}
catch (e) {
}
}
return null;
}
function injectInfoFromPackageJson(info) {
const pkg = detectPackageJson(info.package_json_dir);
if (pkg === null) {
return info;
}
if (!info.description) {
info.description = pkg.description;
}
if (!info.license && pkg.license) {
const l = pkg.license;
info.license = typeof l === 'string' ? l : l.type;
}
if (!info.homepage) {
info.homepage = pkg.homepage;
}
if (!info.bug_report_url && typeof (pkg.bugs) === 'object') {
info.bug_report_url = pkg.bugs.url;
}
if (info.use_inner_html === undefined) {
info.use_inner_html = false;
}
return info;
}
function openAboutWindow(info) {
if (window !== null) {
window.focus();
return window;
}
const index_html = 'file://' + path.join(__dirname, '..', 'about.html');
const options = Object.assign({
width: 400,
height: 400,
useContentSize: true,
titleBarStyle: 'hidden-inset',
show: !info.adjust_window_size,
icon: info.icon_path,
}, info.win_options || {});
window = new (electron_1.BrowserWindow || electron_1.remote.BrowserWindow)(options);
window.once('closed', () => {
window = null;
});
window.loadURL(index_html);
window.webContents.on('will-navigate', (e, url) => {
e.preventDefault();
electron_1.shell.openExternal(url);
});
window.webContents.on('new-window', (e, url) => {
e.preventDefault();
electron_1.shell.openExternal(url);
});
window.webContents.once('dom-ready', () => {
delete info.win_options;
window.webContents.send('about-window:info', info);
if (info.open_devtools) {
if (process.versions.electron >= '1.4') {
window.webContents.openDevTools({ mode: 'detach' });
}
else {
window.webContents.openDevTools();
}
}
});
window.once('ready-to-show', () => {
window.show();
});
window.setMenu(null);
info = injectInfoFromPackageJson(info);
return window;
}
exports.default = openAboutWindow;
//# sourceMappingURL=index.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;AAAA,uCAA2D;AAC3D,2BAA4B;AAC5B,6BAA6B;AAE7B,IAAI,MAAM,GAA2B,IAAI,CAAC;AAE1C,yBAAyB,QAAgB;IACrC,IAAI,CAAC;QACD,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC;IAC7B,CAAC;IAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACT,MAAM,CAAC,IAAI,CAAC;IAChB,CAAC;AACL,CAAC;AAED,2BAA2B,aAAqB;IAC5C,EAAE,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC;QAChB,MAAM,GAAG,GAAG,eAAe,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,EAAE,cAAc,CAAC,CAAC,CAAC;QACtE,EAAE,CAAC,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC;YACf,MAAM,CAAC,GAAG,CAAC;QACf,CAAC;QAAC,IAAI,CAAC,CAAC;YACJ,OAAO,CAAC,IAAI,CAAC,uEAAuE,GAAG,aAAa,CAAC,CAAC;QAC1G,CAAC;IACL,CAAC;IAED,MAAM,QAAQ,GAAG,cAAG,CAAC,OAAO,EAAE,CAAC;IAE/B,GAAG,CAAC,CAAC,MAAM,QAAQ,IAAK,MAAc,CAAC,KAAK,CAAC,CAAC,CAAC;QAC3C,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC,CAAC,CAAC;YAC7B,QAAQ,CAAC;QACb,CAAC;QAED,MAAM,CAAC,GAAG,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE,IAAI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E,EAAE;QAC9C,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,gBAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IACH,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC,YAAY,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,EAAE;QAC3C,CAAC,CAAC,cAAc,EAAE,CAAC;QACnB,gBAAK,CAAC,YAAY,CAAC,GAAG,CAAC,CAAC;IAC5B,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE;QACtC,OAAO,IAAI,CAAC,WAAW,CAAC;QACxB,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,mBAAmB,EAAE,IAAI,CAAC,CAAC;QACnD,EAAE,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YACrB,EAAE,CAAC,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,IAAI,KAAK,CAAC,CAAC,CAAC;gBACrC,MAAM,CAAC,WAAW,CAAC,YAAY,CAAC,EAAC,IAAI,EAAE,QAAQ,EAAC,CAAC,CAAC;YACtD,CAAC;YAAC,IAAI,CAAC,CAAC;gBACJ,MAAM,CAAC,WAAW,CAAC,YAAY,EAAE,CAAC;YACtC,CAAC;QACL,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,IAAI,CAAC,eAAe,EAAE,GAAG,EAAE;QAC9B,MAAM,CAAC,IAAI,EAAE,CAAC;IAClB,CAAC,CAAC,CAAC;IAEH,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;IAErB,IAAI,GAAG,yBAAyB,CAAC,IAAI,CAAC,CAAC;IAEvC,MAAM,CAAC,MAAM,CAAC;AAClB,CAAC;AAzDD,kCAyDC"}

View File

@@ -1,134 +0,0 @@
import {app, BrowserWindow, remote, shell} from 'electron';
import {statSync} from 'fs';
import * as path from 'path';
let window: Electron.BrowserWindow = null;
function loadPackageJson(pkg_path: string): PackageJson {
try {
return require(pkg_path);
} catch (e) {
return null;
}
}
function detectPackageJson(specified_dir: string) {
if (specified_dir) {
const pkg = loadPackageJson(path.join(specified_dir, 'package.json'));
if (pkg !== null) {
return pkg;
} else {
console.warn('about-window: package.json is not found in specified directory path: ' + specified_dir);
}
}
const app_name = app.getName();
for (const mod_path of (module as any).paths) {
if (!path.isAbsolute(mod_path)) {
continue;
}
const p = path.join(mod_path, '..', 'package.json');
try {
const stats = statSync(p);
if (stats.isFile()) {
const pkg = loadPackageJson(p);
if (pkg !== null && pkg.productName === app_name) {
return pkg;
}
}
} catch (e) {
// File not found. Ignored.
}
}
// Note: Not found.
return null;
}
function injectInfoFromPackageJson(info: AboutWindowInfo) {
const pkg = detectPackageJson(info.package_json_dir);
if (pkg === null) {
// Note: Give up.
return info;
}
if (!info.description) {
info.description = pkg.description;
}
if (!info.license && pkg.license) {
const l = pkg.license;
info.license = typeof l === 'string' ? l : l.type;
}
if (!info.homepage) {
info.homepage = pkg.homepage;
}
if (!info.bug_report_url && typeof (pkg.bugs) === 'object') {
info.bug_report_url = pkg.bugs.url;
}
if (info.use_inner_html === undefined) {
info.use_inner_html = false;
}
return info;
}
export default function openAboutWindow(info: AboutWindowInfo) {
if (window !== null) {
window.focus();
return window;
}
const index_html = 'file://' + path.join(__dirname, '..', 'about.html');
const options = Object.assign(
{
width: 400,
height: 400,
useContentSize: true,
titleBarStyle: 'hidden-inset',
show: !info.adjust_window_size,
icon: info.icon_path,
},
info.win_options || {},
);
window = new (BrowserWindow || remote.BrowserWindow)(options);
window.once('closed', () => {
window = null;
});
window.loadURL(index_html);
window.webContents.on('will-navigate', (e, url) => {
e.preventDefault();
shell.openExternal(url);
});
window.webContents.on('new-window', (e, url) => {
e.preventDefault();
shell.openExternal(url);
});
window.webContents.once('dom-ready', () => {
delete info.win_options;
window.webContents.send('about-window:info', info);
if (info.open_devtools) {
if (process.versions.electron >= '1.4') {
window.webContents.openDevTools({mode: 'detach'});
} else {
window.webContents.openDevTools();
}
}
});
window.once('ready-to-show', () => {
window.show();
});
window.setMenu(null);
info = injectInfoFromPackageJson(info);
return window;
}

View File

@@ -1,37 +0,0 @@
/// <reference types="electron" />
interface LicenseEntry {
type: string;
url: string;
}
interface PackageJson {
productName?: string;
description?: string;
homepage?: string;
license?: string | LicenseEntry;
bugs?: {
url: string;
};
}
interface AboutWindowInfo {
icon_path: string;
copyright?: string;
homepage?: string;
description?: string;
package_json_dir?: string;
license?: string;
bug_report_url?: string;
css_path?: string;
adjust_window_size?: boolean;
win_options?: Electron.BrowserWindowConstructorOptions;
open_devtools?: boolean;
use_inner_html?: boolean;
}
declare namespace NodeJS {
interface ProcessVersions {
[name: string]: string;
}
}

View File

@@ -1,65 +0,0 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const electron_1 = require("electron");
electron_1.ipcRenderer.on('about-window:info', (_, info) => {
const app_name = electron_1.remote.app.getName();
const open_home = () => electron_1.shell.openExternal(info.homepage);
const content = info.use_inner_html ? 'innerHTML' : 'innerText';
document.title = `About ${app_name}`;
const title_elem = document.querySelector('.title');
title_elem.innerText = `${app_name} ${electron_1.remote.app.getVersion()}`;
title_elem.addEventListener('click', open_home);
if (info.homepage) {
document
.querySelector('.logo')
.addEventListener('click', open_home);
}
const copyright_elem = document.querySelector('.copyright');
if (info.copyright) {
copyright_elem[content] = info.copyright;
}
else if (info.license) {
copyright_elem[content] = `Distributed under ${info.license} license.`;
}
const icon_elem = document.getElementById('app-icon');
icon_elem.src = info.icon_path;
if (info.description) {
const desc_elem = document.querySelector('.description');
desc_elem[content] = info.description;
}
if (info.bug_report_url) {
const bug_report = document.querySelector('.bug-report-link');
bug_report.innerText = 'found bug?';
bug_report.addEventListener('click', e => {
e.preventDefault();
electron_1.shell.openExternal(info.bug_report_url);
});
}
if (info.css_path) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = info.css_path;
document.head.appendChild(link);
}
if (info.adjust_window_size) {
const height = document.body.scrollHeight;
const width = document.body.scrollWidth;
const win = electron_1.remote.getCurrentWindow();
if (height > 0 && width > 0) {
win.setContentSize(width, height + 40);
}
}
});
const versions = document.querySelector('.versions');
const vs = process.versions;
for (const name of ['electron', 'chrome', 'node', 'v8']) {
const tr = document.createElement('tr');
const name_td = document.createElement('td');
name_td.innerText = name;
tr.appendChild(name_td);
const version_td = document.createElement('td');
version_td.innerText = ' : ' + vs[name];
tr.appendChild(version_td);
versions.appendChild(tr);
}
//# sourceMappingURL=renderer.js.map

View File

@@ -1 +0,0 @@
{"version":3,"file":"renderer.js","sourceRoot":"","sources":["renderer.ts"],"names":[],"mappings":";;AAAA,uCAAoD;AAEpD,sBAAW,CAAC,EAAE,CAAC,mBAAmB,EAAE,CAAC,CAAM,EAAE,IAAqB,EAAE,EAAE;IAClE,MAAM,QAAQ,GAAG,iBAAM,CAAC,GAAG,CAAC,OAAO,EAAE,CAAC;IACtC,MAAM,SAAS,GAAG,GAAG,EAAE,CAAC,gBAAK,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAC1D,MAAM,OAAO,GAAG,IAAI,CAAC,cAAc,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,WAAW,CAAC;IAChE,QAAQ,CAAC,KAAK,GAAG,SAAS,QAAQ,EAAE,CAAC;IAErC,MAAM,UAAU,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAuB,CAAC;IAC1E,UAAU,CAAC,SAAS,GAAG,GAAG,QAAQ,IAAI,iBAAM,CAAC,GAAG,CAAC,UAAU,EAAE,EAAE,CAAC;IAChE,UAAU,CAAC,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAEhD,EAAE,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,CAAC;QAChB,QAAQ;aACH,aAAa,CAAC,OAAO,CAAC;aACtB,gBAAgB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IAC9C,CAAC;IAED,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AAC,WAAW,CAAC,EAAE,CAAC,CAAC;AAC7B,CAAC"}

View File

@@ -1,73 +0,0 @@
import {ipcRenderer, remote, shell} from 'electron';
ipcRenderer.on('about-window:info', (_: any, info: AboutWindowInfo) => {
const app_name = remote.app.getName();
const open_home = () => shell.openExternal(info.homepage);
const content = info.use_inner_html ? 'innerHTML' : 'innerText';
document.title = `About ${app_name}`;
const title_elem = document.querySelector('.title') as HTMLHeadingElement;
title_elem.innerText = `${app_name} ${remote.app.getVersion()}`;
title_elem.addEventListener('click', open_home);
if (info.homepage) {
document
.querySelector('.logo')
.addEventListener('click', open_home);
}
const copyright_elem = document.querySelector('.copyright') as any;
if (info.copyright) {
copyright_elem[content] = info.copyright;
} else if (info.license) {
copyright_elem[content] = `Distributed under ${info.license} license.`;
}
const icon_elem = document.getElementById('app-icon') as HTMLImageElement;
icon_elem.src = info.icon_path;
if (info.description) {
const desc_elem = document.querySelector('.description') as any;
desc_elem[content] = info.description;
}
if (info.bug_report_url) {
const bug_report = document.querySelector('.bug-report-link') as HTMLDivElement;
bug_report.innerText = 'found bug?';
bug_report.addEventListener('click', e => {
e.preventDefault();
shell.openExternal(info.bug_report_url);
});
}
if (info.css_path) {
const link = document.createElement('link');
link.rel = 'stylesheet';
link.href = info.css_path;
document.head.appendChild(link);
}
if (info.adjust_window_size) {
const height = document.body.scrollHeight;
const width = document.body.scrollWidth;
const win = remote.getCurrentWindow();
if (height > 0 && width > 0) {
// Note:
// Add 30px(= about 2em) to add padding in window
win.setContentSize(width, height + 40);
}
}
});
const versions = document.querySelector('.versions');
const vs = process.versions;
for (const name of ['electron', 'chrome', 'node', 'v8']) {
const tr = document.createElement('tr');
const name_td = document.createElement('td');
name_td.innerText = name;
tr.appendChild(name_td);
const version_td = document.createElement('td');
version_td.innerText = ' : ' + vs[name];
tr.appendChild(version_td);
versions.appendChild(tr);
}

View File

@@ -1,20 +0,0 @@
{
"compilerOptions": {
"module": "commonjs",
"moduleResolution": "node",
"removeComments": true,
"preserveConstEnums": true,
"noImplicitAny": true,
"noImplicitReturns": true,
"noImplicitThis": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noEmitOnError": true,
"strictNullChecks": false,
"target": "es2015",
"sourceMap": true
},
"include": [
"**/*.ts"
]
}

View File

@@ -1,64 +0,0 @@
body,
html {
width: 100%;
height: 100%;
-webkit-user-select: none;
user-select: none;
-webkit-app-region: drag;
}
body {
margin: 0;
display: flex;
flex-direction: column;
justify-content: center;
align-items: center;
color: #333;
background-color: #eee;
font-size: 12px;
font-family: 'Helvetica', 'Arial', 'ヒラギノ角ゴ Pro W3', 'Hiragino Kaku Gothic Pro', 'メイリオ', Meiryo, ' Pゴシック', 'MS PGothic', sans-serif;
}
.logo {
width: 200px;
cursor: pointer;
-webkit-user-select: none;
user-select: none;
}
.title,
.copyright,
.description {
margin: 0.2em;
}
.title {
cursor: pointer;
}
.description {
margin-bottom: 1em;
text-align: center;
}
.versions {
border-collapse: collapse;
margin-top: 1em;
}
.copyright,
.versions {
color: #999;
}
.link {
cursor: pointer;
color: #80a0c2;
}
.bug-report-link {
-webkit-app-region: no-drag;
position: absolute;
right: 0.5em;
bottom: 0.5em;
}

View File

@@ -1,127 +0,0 @@
{
"extends": ["tslint:recommended"],
"rules": {
"align": [
true,
"parameters",
"statements"
],
"ban": false,
"class-name": true,
"comment-format": [
true,
"check-space"
],
"curly": true,
"eofline": true,
"forin": false,
"indent": [
true,
"spaces"
],
"interface-name": false,
"jsdoc-format": true,
"label-position": true,
"max-line-length": false,
"member-access": false,
"member-ordering": [
true,
"public-before-private",
"static-before-instance",
"variables-before-functions"
],
"no-any": false,
"no-arg": true,
"no-bitwise": false,
"no-conditional-assignment": true,
"no-consecutive-blank-lines": false,
"no-console": [
true,
"debug",
"info",
"time",
"timeEnd",
"trace"
],
"no-construct": true,
"no-constructor-vars": false,
"no-debugger": true,
"no-duplicate-variable": true,
"no-empty": true,
"no-eval": true,
"no-inferrable-types": false,
"no-internal-module": true,
"no-require-imports": false,
"no-shadowed-variable": true,
"no-string-literal": true,
"no-switch-case-fall-through": false,
"no-trailing-whitespace": true,
"no-unused-expression": true,
"no-unsafe-finally": true,
"no-use-before-declare": true,
"no-var-keyword": true,
"no-var-requires": true,
"object-literal-sort-keys": false,
"object-literal-key-quotes": [
true,
"as-needed"
],
"one-line": [
true,
"check-open-brace",
"check-catch",
"check-else",
"check-whitespace"
],
"quotemark": [
true,
"single",
"avoid-escape",
"jsx-double"
],
"radix": true,
"semicolon": true,
"switch-default": true,
"trailing-comma": [
true,
{
"multiline": "always",
"singleline": "never"
}
],
"triple-equals": [
true,
"allow-null-check"
],
"typedef": [
false
],
"typedef-whitespace": [
true,
{
"call-signature": "nospace",
"index-signature": "nospace",
"parameter": "nospace",
"property-declaration": "nospace",
"variable-declaration": "nospace"
}
],
"use-strict": false,
"variable-name": [
false,
"check-format",
"allow-leading-underscore",
"ban-keywords"
],
"whitespace": [
true,
"check-branch",
"check-decl",
"check-operator",
"check-separator",
"check-type"
],
"no-namespace": false,
"arrow-parens": false
}
}

View File

@@ -18,7 +18,7 @@ function getFilenameFromMime(name, mime) {
return `${name}.${exts[0].ext}`;
}
function registerListener(session, opts = {}, cb = () => {}) {
function registerListener(session, options, cb = () => {}) {
const downloadItems = new Set();
let receivedBytes = 0;
let completedBytes = 0;
@@ -26,6 +26,10 @@ function registerListener(session, opts = {}, cb = () => {}) {
const activeDownloadItems = () => downloadItems.size;
const progressDownloadItems = () => receivedBytes / totalBytes;
options = Object.assign({
showBadge: true
}, options);
const listener = (e, item, webContents) => {
downloadItems.add(item);
totalBytes += item.getTotalBytes();
@@ -36,10 +40,10 @@ function registerListener(session, opts = {}, cb = () => {}) {
}
const win = electron.BrowserWindow.fromWebContents(hostWebContents);
const dir = opts.directory || app.getPath('downloads');
const dir = options.directory || app.getPath('downloads');
let filePath;
if (opts.filename) {
filePath = path.join(dir, opts.filename);
if (options.filename) {
filePath = path.join(dir, options.filename);
} else {
const filename = item.getFilename();
const name = path.extname(filename) ? filename : getFilenameFromMime(filename, item.getMimeType());
@@ -47,10 +51,10 @@ function registerListener(session, opts = {}, cb = () => {}) {
filePath = unusedFilename.sync(path.join(dir, name));
}
const errorMessage = opts.errorMessage || 'The download of {filename} was interrupted';
const errorTitle = opts.errorTitle || 'Download Error';
const errorMessage = options.errorMessage || 'The download of {filename} was interrupted';
const errorTitle = options.errorTitle || 'Download Error';
if (!opts.saveAs) {
if (!options.saveAs) {
item.setSavePath(filePath);
}
@@ -60,7 +64,7 @@ function registerListener(session, opts = {}, cb = () => {}) {
return receivedBytes;
}, completedBytes);
if (['darwin', 'linux'].includes(process.platform)) {
if (options.showBadge && ['darwin', 'linux'].includes(process.platform)) {
app.setBadgeCount(activeDownloadItems());
}
@@ -68,8 +72,8 @@ function registerListener(session, opts = {}, cb = () => {}) {
win.setProgressBar(progressDownloadItems());
}
if (typeof opts.onProgress === 'function') {
opts.onProgress(progressDownloadItems());
if (typeof options.onProgress === 'function') {
options.onProgress(progressDownloadItems());
}
});
@@ -77,7 +81,7 @@ function registerListener(session, opts = {}, cb = () => {}) {
completedBytes += item.getTotalBytes();
downloadItems.delete(item);
if (['darwin', 'linux'].includes(process.platform)) {
if (options.showBadge && ['darwin', 'linux'].includes(process.platform)) {
app.setBadgeCount(activeDownloadItems());
}
@@ -97,11 +101,11 @@ function registerListener(session, opts = {}, cb = () => {}) {
app.dock.downloadFinished(filePath);
}
if (opts.openFolderWhenDone) {
shell.showItemInFolder(filePath);
if (options.openFolderWhenDone) {
shell.showItemInFolder(path.join(dir, item.getFilename()));
}
if (opts.unregisterWhenDone) {
if (options.unregisterWhenDone) {
session.removeListener('will-download', listener);
}
@@ -113,16 +117,16 @@ function registerListener(session, opts = {}, cb = () => {}) {
session.on('will-download', listener);
}
module.exports = (opts = {}) => {
module.exports = (options = {}) => {
app.on('session-created', session => {
registerListener(session, opts);
registerListener(session, options);
});
};
module.exports.download = (win, url, opts) => new Promise((resolve, reject) => {
opts = Object.assign({}, opts, {unregisterWhenDone: true});
module.exports.download = (win, url, options) => new Promise((resolve, reject) => {
options = Object.assign({}, options, {unregisterWhenDone: true});
registerListener(win.webContents.session, opts, (err, item) => {
registerListener(win.webContents.session, options, (err, item) => {
if (err) {
reject(err);
} else {

View File

@@ -1,50 +1,28 @@
{
"_args": [
[
{
"raw": "electron-dl",
"scope": null,
"escapedName": "electron-dl",
"name": "electron-dl",
"rawSpec": "",
"spec": "latest",
"type": "tag"
},
"C:\\Users\\ryuki\\TheDesk"
]
],
"_from": "electron-dl@latest",
"_id": "electron-dl@1.10.0",
"_inCache": true,
"_from": "electron-dl@1.11.0",
"_id": "electron-dl@1.11.0",
"_inBundle": false,
"_integrity": "sha512-iL9qHzzWOuL9bus+UT+P72SwrDQcFTV6QHqcbhwgqjCC9/K5jhdRzG0dIMB3TzYlk6rmApanPqh9DvWykwIH1Q==",
"_location": "/electron-dl",
"_nodeVersion": "4.8.3",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/electron-dl-1.10.0.tgz_1502139802256_0.5021310658194125"
},
"_npmUser": {
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
},
"_npmVersion": "2.15.11",
"_phantomChildren": {},
"_requested": {
"raw": "electron-dl",
"scope": null,
"escapedName": "electron-dl",
"type": "version",
"registry": true,
"raw": "electron-dl@1.11.0",
"name": "electron-dl",
"rawSpec": "",
"spec": "latest",
"type": "tag"
"escapedName": "electron-dl",
"rawSpec": "1.11.0",
"saveSpec": null,
"fetchSpec": "1.11.0"
},
"_requiredBy": [
"#USER"
"#USER",
"/"
],
"_resolved": "https://registry.npmjs.org/electron-dl/-/electron-dl-1.10.0.tgz",
"_shasum": "f94416064056fc6f2a86ae498614c93526890af9",
"_shrinkwrap": null,
"_spec": "electron-dl",
"_where": "C:\\Users\\ryuki\\TheDesk",
"_resolved": "https://registry.npmjs.org/electron-dl/-/electron-dl-1.11.0.tgz",
"_shasum": "112851f3857bb1a556b5c736af06040bd40df850",
"_spec": "electron-dl@1.11.0",
"_where": "C:\\Users\\ryuki\\TheDesk\\app",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
@@ -53,15 +31,17 @@
"bugs": {
"url": "https://github.com/sindresorhus/electron-dl/issues"
},
"bundleDependencies": false,
"dependencies": {
"ext-name": "^5.0.0",
"pupa": "^1.0.0",
"unused-filename": "^1.0.0"
},
"deprecated": false,
"description": "Simplified file downloads for your Electron app",
"devDependencies": {
"ava": "^0.21.0",
"cp-file": "^4.2.0",
"ava": "^0.25.0",
"cp-file": "^5.0.0",
"electron": "^1.3.3",
"minimist": "^1.2.0",
"node-static": "^0.7.9",
@@ -70,15 +50,9 @@
"uuid": "^3.1.0",
"xo": "*"
},
"directories": {},
"dist": {
"shasum": "f94416064056fc6f2a86ae498614c93526890af9",
"tarball": "https://registry.npmjs.org/electron-dl/-/electron-dl-1.10.0.tgz"
},
"files": [
"index.js"
],
"gitHead": "b47d7e9ee5e8c89b08ed86e9e395aa052e39f4bf",
"homepage": "https://github.com/sindresorhus/electron-dl#readme",
"keywords": [
"electron",
@@ -89,15 +63,7 @@
"progress"
],
"license": "MIT",
"maintainers": [
{
"name": "sindresorhus",
"email": "sindresorhus@gmail.com"
}
],
"name": "electron-dl",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/sindresorhus/electron-dl.git"
@@ -106,7 +72,7 @@
"start": "electron run.js",
"test": "xo && ava"
},
"version": "1.10.0",
"version": "1.11.0",
"xo": {
"envs": [
"node",

View File

@@ -1,6 +1,6 @@
# electron-dl [![Build Status](https://travis-ci.org/sindresorhus/electron-dl.svg?branch=master)](https://travis-ci.org/sindresorhus/electron-dl)
> Simplified file downloads for your [Electron](http://electron.atom.io) app
> Simplified file downloads for your [Electron](https://electronjs.org) app
## Why?
@@ -56,9 +56,11 @@ ipcMain.on('download-btn', (e, args) => {
## API
It can only be used in the [main](https://electronjs.org/docs/glossary/#main-process) process.
### electronDl([options])
### electronDl.download(window, url, [options]): Promise<[DownloadItem](https://github.com/electron/electron/blob/master/docs/api/download-item.md)>
### electronDl.download(window, url, [options]): Promise<[DownloadItem](https://electronjs.org/docs/api/download-item)>
### window
@@ -86,14 +88,14 @@ Note: Only use this option when strictly necessary. Downloading directly without
#### directory
Type: `string`<br>
Default: [User's downloads directory](http://electron.atom.io/docs/api/app/#appgetpathname)
Default: [User's downloads directory](https://electronjs.org/docs/api/app/#appgetpathname)
Directory to save the file in.
#### filename
Type: `string`<br>
Default: [`downloadItem.getFilename()`](https://electron.atom.io/docs/api/download-item/#downloaditemgetfilename)
Default: [`downloadItem.getFilename()`](https://electronjs.org/docs/api/download-item/#downloaditemgetfilename)
Name of the saved file.
@@ -126,6 +128,12 @@ Default: `false`
Reveal the downloaded file in the system file manager, and if possible, select the file.
#### showBadge
Type: `boolean`<br>
Default: `true`
Shows the file count badge on macOS/Linux dock icons when download is in progress.
## Development

View File

@@ -1,3 +1,11 @@
1.33.0 / 2018-02-15
===================
* Add extensions from IANA for `message/*` types
* Add new upstream MIME types
* Fix some incorrect OOXML types
* Remove `application/font-woff2`
1.32.0 / 2017-11-29
===================

85
app/node_modules/mime-db/db.json generated vendored
View File

@@ -369,6 +369,9 @@
"application/fdt+xml": {
"source": "iana"
},
"application/fhir+xml": {
"source": "iana"
},
"application/fido.trusted-apps+json": {
"compressible": true
},
@@ -387,10 +390,6 @@
"compressible": false,
"extensions": ["woff"]
},
"application/font-woff2": {
"compressible": false,
"extensions": ["woff2"]
},
"application/framework-attributes+xml": {
"source": "iana"
},
@@ -779,6 +778,9 @@
"application/nlsml+xml": {
"source": "iana"
},
"application/node": {
"source": "iana"
},
"application/nss": {
"source": "iana"
},
@@ -883,6 +885,9 @@
"source": "iana",
"extensions": ["p8"]
},
"application/pkcs8-encrypted": {
"source": "iana"
},
"application/pkix-attr-cert": {
"source": "iana",
"extensions": ["ac"]
@@ -1247,6 +1252,9 @@
"source": "iana",
"extensions": ["tsd"]
},
"application/tnauthlist": {
"source": "iana"
},
"application/trig": {
"source": "iana"
},
@@ -1433,6 +1441,10 @@
"source": "iana",
"extensions": ["azs"]
},
"application/vnd.amadeus+json": {
"source": "iana",
"compressible": true
},
"application/vnd.amazon.ebook": {
"source": "apache",
"extensions": ["azw"]
@@ -1537,6 +1549,10 @@
"application/vnd.bbf.usp.msg": {
"source": "iana"
},
"application/vnd.bbf.usp.msg+json": {
"source": "iana",
"compressible": true
},
"application/vnd.bekitzur-stech+json": {
"source": "iana",
"compressible": true
@@ -1640,9 +1656,15 @@
"application/vnd.collabio.xodocuments.presentation": {
"source": "iana"
},
"application/vnd.collabio.xodocuments.presentation-template": {
"source": "iana"
},
"application/vnd.collabio.xodocuments.spreadsheet": {
"source": "iana"
},
"application/vnd.collabio.xodocuments.spreadsheet-template": {
"source": "iana"
},
"application/vnd.collection+json": {
"source": "iana",
"compressible": true
@@ -1658,6 +1680,9 @@
"application/vnd.comicbook+zip": {
"source": "iana"
},
"application/vnd.comicbook-rar": {
"source": "iana"
},
"application/vnd.commerce-battelle": {
"source": "iana"
},
@@ -3452,9 +3477,6 @@
"application/vnd.openxmlformats-officedocument.extended-properties+xml": {
"source": "iana"
},
"application/vnd.openxmlformats-officedocument.presentationml-template": {
"source": "iana"
},
"application/vnd.openxmlformats-officedocument.presentationml.commentauthors+xml": {
"source": "iana"
},
@@ -3511,7 +3533,7 @@
"source": "iana"
},
"application/vnd.openxmlformats-officedocument.presentationml.template": {
"source": "apache",
"source": "iana",
"extensions": ["potx"]
},
"application/vnd.openxmlformats-officedocument.presentationml.template.main+xml": {
@@ -3520,9 +3542,6 @@
"application/vnd.openxmlformats-officedocument.presentationml.viewprops+xml": {
"source": "iana"
},
"application/vnd.openxmlformats-officedocument.spreadsheetml-template": {
"source": "iana"
},
"application/vnd.openxmlformats-officedocument.spreadsheetml.calcchain+xml": {
"source": "iana"
},
@@ -3583,7 +3602,7 @@
"source": "iana"
},
"application/vnd.openxmlformats-officedocument.spreadsheetml.template": {
"source": "apache",
"source": "iana",
"extensions": ["xltx"]
},
"application/vnd.openxmlformats-officedocument.spreadsheetml.template.main+xml": {
@@ -3607,9 +3626,6 @@
"application/vnd.openxmlformats-officedocument.vmldrawing": {
"source": "iana"
},
"application/vnd.openxmlformats-officedocument.wordprocessingml-template": {
"source": "iana"
},
"application/vnd.openxmlformats-officedocument.wordprocessingml.comments+xml": {
"source": "iana"
},
@@ -3646,7 +3662,7 @@
"source": "iana"
},
"application/vnd.openxmlformats-officedocument.wordprocessingml.template": {
"source": "apache",
"source": "iana",
"extensions": ["dotx"]
},
"application/vnd.openxmlformats-officedocument.wordprocessingml.template.main+xml": {
@@ -3874,6 +3890,10 @@
"application/vnd.renlearn.rlprint": {
"source": "iana"
},
"application/vnd.restful+json": {
"source": "iana",
"compressible": true
},
"application/vnd.rig.cryptonote": {
"source": "iana",
"extensions": ["cryptonote"]
@@ -4021,6 +4041,9 @@
"source": "iana",
"extensions": ["sfs"]
},
"application/vnd.sqlite3": {
"source": "iana"
},
"application/vnd.sss-cod": {
"source": "iana"
},
@@ -4446,6 +4469,9 @@
"source": "iana",
"extensions": ["cmp"]
},
"application/vnd.youtube.yt": {
"source": "iana"
},
"application/vnd.zul": {
"source": "iana",
"extensions": ["zir","zirz"]
@@ -4458,6 +4484,10 @@
"source": "iana",
"extensions": ["vxml"]
},
"application/voucher-cms+json": {
"source": "iana",
"compressible": true
},
"application/vq-rtcpxr": {
"source": "iana"
},
@@ -5784,6 +5814,9 @@
"source": "iana",
"extensions": ["woff2"]
},
"image/aces": {
"source": "iana"
},
"image/apng": {
"compressible": false,
"extensions": ["apng"]
@@ -6089,7 +6122,10 @@
"source": "iana"
},
"message/disposition-notification": {
"source": "iana"
"source": "iana",
"extensions": [
"disposition-notification"
]
},
"message/external-body": {
"source": "iana"
@@ -6098,16 +6134,20 @@
"source": "iana"
},
"message/global": {
"source": "iana"
"source": "iana",
"extensions": ["u8msg"]
},
"message/global-delivery-status": {
"source": "iana"
"source": "iana",
"extensions": ["u8dsn"]
},
"message/global-disposition-notification": {
"source": "iana"
"source": "iana",
"extensions": ["u8mdn"]
},
"message/global-headers": {
"source": "iana"
"source": "iana",
"extensions": ["u8hdr"]
},
"message/http": {
"source": "iana",
@@ -6145,7 +6185,8 @@
"source": "iana"
},
"message/vnd.wfa.wsc": {
"source": "iana"
"source": "iana",
"extensions": ["wsc"]
},
"model/3mf": {
"source": "iana"

View File

@@ -1,53 +1,31 @@
{
"_args": [
[
{
"raw": "mime-db@^1.28.0",
"scope": null,
"escapedName": "mime-db",
"name": "mime-db",
"rawSpec": "^1.28.0",
"spec": ">=1.28.0 <2.0.0",
"type": "range"
},
"C:\\Users\\ryuki\\TheDesk\\node_modules\\ext-list"
]
],
"_from": "mime-db@>=1.28.0 <2.0.0",
"_id": "mime-db@1.32.0",
"_inCache": true,
"_from": "mime-db@^1.28.0",
"_id": "mime-db@1.33.0",
"_inBundle": false,
"_integrity": "sha512-BHJ/EKruNIqJf/QahvxwQZXKygOQ256myeN/Ew+THcAa5q+PjyTTMMeNQC4DZw5AwfvelsUrA6B67NKMqXDbzQ==",
"_location": "/mime-db",
"_nodeVersion": "6.12.0",
"_npmOperationalInternal": {
"host": "s3://npm-registry-packages",
"tmp": "tmp/mime-db-1.32.0.tgz_1511989647467_0.298956407699734"
},
"_npmUser": {
"name": "dougwilson",
"email": "doug@somethingdoug.com"
},
"_npmVersion": "5.5.1",
"_phantomChildren": {},
"_requested": {
"type": "range",
"registry": true,
"raw": "mime-db@^1.28.0",
"scope": null,
"escapedName": "mime-db",
"name": "mime-db",
"escapedName": "mime-db",
"rawSpec": "^1.28.0",
"spec": ">=1.28.0 <2.0.0",
"type": "range"
"saveSpec": null,
"fetchSpec": "^1.28.0"
},
"_requiredBy": [
"/ext-list"
],
"_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.32.0.tgz",
"_shasum": "485b3848b01a3cda5f968b4882c0771e58e09414",
"_shrinkwrap": null,
"_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.33.0.tgz",
"_shasum": "a3492050a5cb9b63450541e39d9788d2272783db",
"_spec": "mime-db@^1.28.0",
"_where": "C:\\Users\\ryuki\\TheDesk\\node_modules\\ext-list",
"_where": "C:\\Users\\ryuki\\TheDesk\\app\\node_modules\\ext-list",
"bugs": {
"url": "https://github.com/jshttp/mime-db/issues"
},
"bundleDependencies": false,
"contributors": [
{
"name": "Douglas Christopher Wilson",
@@ -64,7 +42,7 @@
"url": "http://github.com/broofa"
}
],
"dependencies": {},
"deprecated": false,
"description": "Media Type Database",
"devDependencies": {
"bluebird": "3.5.1",
@@ -79,16 +57,10 @@
"eslint-plugin-standard": "3.0.1",
"gnode": "0.1.2",
"mocha": "1.21.5",
"nyc": "11.3.0",
"nyc": "11.4.1",
"raw-body": "2.3.2",
"stream-to-array": "2.3.0"
},
"directories": {},
"dist": {
"integrity": "sha512-+ZWo/xZN40Tt6S+HyakUxnSOgff+JEdaneLWIm0Z6LmpCn5DMcZntLyUY5c/rTDog28LhXLKOUZKoTxTCAdBVw==",
"shasum": "485b3848b01a3cda5f968b4882c0771e58e09414",
"tarball": "https://registry.npmjs.org/mime-db/-/mime-db-1.32.0.tgz"
},
"engines": {
"node": ">= 0.6"
},
@@ -99,7 +71,6 @@
"db.json",
"index.js"
],
"gitHead": "555f55537d688a6ba935253d8d36bf270a4a0ffa",
"homepage": "https://github.com/jshttp/mime-db#readme",
"keywords": [
"mime",
@@ -111,19 +82,7 @@
"charsets"
],
"license": "MIT",
"maintainers": [
{
"name": "dougwilson",
"email": "doug@somethingdoug.com"
},
{
"name": "jongleberry",
"email": "jonathanrichardong@gmail.com"
}
],
"name": "mime-db",
"optionalDependencies": {},
"readme": "ERROR: No README data found!",
"repository": {
"type": "git",
"url": "git+https://github.com/jshttp/mime-db.git"
@@ -137,5 +96,5 @@
"test-travis": "nyc --reporter=text npm test",
"update": "npm run fetch && npm run build"
},
"version": "1.32.0"
"version": "1.33.0"
}