forked from olcxjas-softworks/LarpixClient
Update gitignore (sorry)
This commit is contained in:
parent
a8f8c4d7ad
commit
cca8b02fea
6604 changed files with 1219661 additions and 4 deletions
67
electron/node_modules/electron-serve/index.d.ts
generated
vendored
Normal file
67
electron/node_modules/electron-serve/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
/// <reference lib="dom"/>
|
||||
import {BrowserWindow} from 'electron';
|
||||
|
||||
declare namespace electronServe {
|
||||
interface Options {
|
||||
/**
|
||||
The directory to serve, relative to the app root directory.
|
||||
*/
|
||||
directory: string;
|
||||
|
||||
/**
|
||||
Custom scheme. For example, `foo` results in your `directory` being available at `foo://-`.
|
||||
|
||||
@default 'app'
|
||||
*/
|
||||
scheme?: string;
|
||||
|
||||
/**
|
||||
Whether [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) should be enabled.
|
||||
Useful for testing purposes.
|
||||
|
||||
@default true
|
||||
*/
|
||||
isCorsEnabled?: boolean;
|
||||
|
||||
/**
|
||||
The partition the protocol should be installed to, if you're not using Electron's default partition.
|
||||
|
||||
@default electron.session.defaultSession
|
||||
*/
|
||||
partition?: string;
|
||||
}
|
||||
|
||||
/**
|
||||
Load the index file in the window.
|
||||
*/
|
||||
type loadURL = (window: BrowserWindow) => Promise<void>;
|
||||
}
|
||||
|
||||
/**
|
||||
Static file serving for Electron apps.
|
||||
|
||||
@example
|
||||
```
|
||||
import {app, BrowserWindow} from 'electron';
|
||||
import serve = require('electron-serve');
|
||||
|
||||
const loadURL = serve({directory: 'renderer'});
|
||||
|
||||
let mainWindow;
|
||||
|
||||
(async () => {
|
||||
await app.whenReady();
|
||||
|
||||
mainWindow = new BrowserWindow();
|
||||
|
||||
await loadURL(mainWindow);
|
||||
|
||||
// The above is equivalent to this:
|
||||
await mainWindow.loadURL('app://-');
|
||||
// The `-` is just the required hostname.
|
||||
})();
|
||||
```
|
||||
*/
|
||||
declare function electronServe(options: electronServe.Options): electronServe.loadURL;
|
||||
|
||||
export = electronServe;
|
||||
77
electron/node_modules/electron-serve/index.js
generated
vendored
Normal file
77
electron/node_modules/electron-serve/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
'use strict';
|
||||
const fs = require('fs');
|
||||
const path = require('path');
|
||||
const {promisify} = require('util');
|
||||
const electron = require('electron');
|
||||
|
||||
const stat = promisify(fs.stat);
|
||||
|
||||
// See https://cs.chromium.org/chromium/src/net/base/net_error_list.h
|
||||
const FILE_NOT_FOUND = -6;
|
||||
|
||||
const getPath = async path_ => {
|
||||
try {
|
||||
const result = await stat(path_);
|
||||
|
||||
if (result.isFile()) {
|
||||
return path_;
|
||||
}
|
||||
|
||||
if (result.isDirectory()) {
|
||||
return getPath(path.join(path_, 'index.html'));
|
||||
}
|
||||
} catch (_) {}
|
||||
};
|
||||
|
||||
module.exports = options => {
|
||||
options = Object.assign({
|
||||
isCorsEnabled: true,
|
||||
scheme: 'app'
|
||||
}, options);
|
||||
|
||||
if (!options.directory) {
|
||||
throw new Error('The `directory` option is required');
|
||||
}
|
||||
|
||||
options.directory = path.resolve(electron.app.getAppPath(), options.directory);
|
||||
|
||||
const handler = async (request, callback) => {
|
||||
const indexPath = path.join(options.directory, 'index.html');
|
||||
const filePath = path.join(options.directory, decodeURIComponent(new URL(request.url).pathname));
|
||||
const resolvedPath = await getPath(filePath);
|
||||
const fileExtension = path.extname(filePath);
|
||||
|
||||
if (resolvedPath || !fileExtension || fileExtension === '.html' || fileExtension === '.asar') {
|
||||
callback({
|
||||
path: resolvedPath || indexPath
|
||||
});
|
||||
} else {
|
||||
callback({error: FILE_NOT_FOUND});
|
||||
}
|
||||
};
|
||||
|
||||
electron.protocol.registerSchemesAsPrivileged([
|
||||
{
|
||||
scheme: options.scheme,
|
||||
privileges: {
|
||||
standard: true,
|
||||
secure: true,
|
||||
allowServiceWorkers: true,
|
||||
supportFetchAPI: true,
|
||||
corsEnabled: options.isCorsEnabled
|
||||
}
|
||||
}
|
||||
]);
|
||||
|
||||
electron.app.on('ready', () => {
|
||||
const session = options.partition ?
|
||||
electron.session.fromPartition(options.partition) :
|
||||
electron.session.defaultSession;
|
||||
|
||||
session.protocol.registerFileProtocol(options.scheme, handler);
|
||||
});
|
||||
|
||||
return async window_ => {
|
||||
await window_.loadURL(`${options.scheme}://-`);
|
||||
};
|
||||
};
|
||||
9
electron/node_modules/electron-serve/license
generated
vendored
Normal file
9
electron/node_modules/electron-serve/license
generated
vendored
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
|
||||
|
||||
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.
|
||||
55
electron/node_modules/electron-serve/package.json
generated
vendored
Normal file
55
electron/node_modules/electron-serve/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
{
|
||||
"name": "electron-serve",
|
||||
"version": "1.1.0",
|
||||
"description": "Static file serving for Electron apps",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/electron-serve",
|
||||
"author": {
|
||||
"name": "Sindre Sorhus",
|
||||
"email": "sindresorhus@gmail.com",
|
||||
"url": "sindresorhus.com"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo",
|
||||
"//test": "xo && (cd test && ava) && tsd"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"electron",
|
||||
"serve",
|
||||
"serving",
|
||||
"server",
|
||||
"static",
|
||||
"file",
|
||||
"dev",
|
||||
"development",
|
||||
"react",
|
||||
"router",
|
||||
"web",
|
||||
"app",
|
||||
"history",
|
||||
"pushstate",
|
||||
"replacestate",
|
||||
"href",
|
||||
"url"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^2.1.0",
|
||||
"electron": "^8.2.0",
|
||||
"spectron": "^10.0.1",
|
||||
"tsd": "^0.11.0",
|
||||
"xo": "^0.28.2"
|
||||
},
|
||||
"xo": {
|
||||
"envs": [
|
||||
"node",
|
||||
"browser"
|
||||
],
|
||||
"rules": {
|
||||
"no-redeclare": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
82
electron/node_modules/electron-serve/readme.md
generated
vendored
Normal file
82
electron/node_modules/electron-serve/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
# electron-serve
|
||||
|
||||
> Static file serving for Electron apps
|
||||
|
||||
Normally you would just use `win.loadURL('file://…')`, but that doesn't work when you're making a single-page web app, which most Electron apps are today, as [`history.pushState()`](https://developer.mozilla.org/en-US/docs/Web/API/History_API)'ed URLs don't exist on disk. It serves files if they exist, and falls back to `index.html` if not, which means you can use router modules like [`react-router`](https://github.com/ReactTraining/react-router), [`vue-router`](https://github.com/vuejs/vue-router), etc.
|
||||
|
||||
## Install
|
||||
|
||||
```
|
||||
$ npm install electron-serve
|
||||
```
|
||||
|
||||
*Requires Electron 8 or later.*
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
const {app, BrowserWindow} = require('electron');
|
||||
const serve = require('electron-serve');
|
||||
|
||||
const loadURL = serve({directory: 'renderer'});
|
||||
|
||||
let mainWindow;
|
||||
|
||||
(async () => {
|
||||
await app.whenReady();
|
||||
|
||||
mainWindow = new BrowserWindow();
|
||||
|
||||
await loadURL(mainWindow);
|
||||
|
||||
// The above is equivalent to this:
|
||||
await mainWindow.loadURL('app://-');
|
||||
// The `-` is just the required hostname
|
||||
})();
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### serve(options)
|
||||
|
||||
#### options
|
||||
|
||||
Type: `object`
|
||||
|
||||
##### directory
|
||||
|
||||
*Required*\
|
||||
Type: `string`
|
||||
|
||||
The directory to serve, relative to the app root directory.
|
||||
|
||||
##### scheme
|
||||
|
||||
Type: `string`\
|
||||
Default: `'app'`
|
||||
|
||||
Custom scheme. For example, `foo` results in your `directory` being available at `foo://-`.
|
||||
|
||||
##### isCorsEnabled
|
||||
|
||||
Type: `boolean`\
|
||||
Default: `true`
|
||||
|
||||
Whether [CORS](https://developer.mozilla.org/en-US/docs/Web/HTTP/CORS) should be enabled.
|
||||
Useful for testing purposes.
|
||||
|
||||
##### partition
|
||||
|
||||
Type: `string`\
|
||||
Default: [`electron.session.defaultSession`](https://electronjs.org/docs/api/session#sessiondefaultsession)
|
||||
|
||||
The [partition](https://electronjs.org/docs/api/session#sessionfrompartitionpartition-options) the protocol should be installed to, if you're not using Electron's default partition.
|
||||
|
||||
## Related
|
||||
|
||||
- [electron-util](https://github.com/sindresorhus/electron-util) - Useful utilities for developing Electron apps and modules
|
||||
- [electron-reloader](https://github.com/sindresorhus/electron-reloader) - Simple auto-reloading for Electron apps during development
|
||||
- [electron-debug](https://github.com/sindresorhus/electron-debug) - Adds useful debug features to your Electron app
|
||||
- [electron-context-menu](https://github.com/sindresorhus/electron-context-menu) - Context menu for your Electron app
|
||||
- [electron-dl](https://github.com/sindresorhus/electron-dl) - Simplified file downloads for your Electron app
|
||||
- [electron-unhandled](https://github.com/sindresorhus/electron-unhandled) - Catch unhandled errors and promise rejections in your Electron app
|
||||
Loading…
Add table
Add a link
Reference in a new issue