Initial commit
This commit is contained in:
6
.gitignore
vendored
Normal file
6
.gitignore
vendored
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
package-lock.json
|
||||||
|
node_modules/
|
||||||
|
.idea/
|
||||||
|
build/
|
||||||
|
chrome_data/
|
||||||
|
dist/
|
||||||
12
README.md
Normal file
12
README.md
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
# Repertory UI
|
||||||
|

|
||||||
|
|
||||||
|
### GUI for [Repertory](https://bitbucket.org/blockstorage/repertory) ###
|
||||||
|
Repertory allows you to mount Hyperspace or Sia blockchain storage solutions via FUSE on Linux/OS X or via WinFSP on Windows.
|
||||||
|
# Downloads #
|
||||||
|
* [Repertory UI v1.0.0 Windows 64-bit](https://sia.pixeldrain.com/api/file/qXM6pVZZ/download)
|
||||||
|
# Supported Platforms #
|
||||||
|
* Windows 64-bit
|
||||||
|
# Future Platforms #
|
||||||
|
* OS X
|
||||||
|
* Linux 64-bit
|
||||||
93
config/env.js
Normal file
93
config/env.js
Normal file
@@ -0,0 +1,93 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const paths = require('./paths');
|
||||||
|
|
||||||
|
// Make sure that including paths.js after env.js will read .env variables.
|
||||||
|
delete require.cache[require.resolve('./paths')];
|
||||||
|
|
||||||
|
const NODE_ENV = process.env.NODE_ENV;
|
||||||
|
if (!NODE_ENV) {
|
||||||
|
throw new Error(
|
||||||
|
'The NODE_ENV environment variable is required but was not specified.'
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
// https://github.com/bkeepers/dotenv#what-other-env-files-can-i-use
|
||||||
|
var dotenvFiles = [
|
||||||
|
`${paths.dotenv}.${NODE_ENV}.local`,
|
||||||
|
`${paths.dotenv}.${NODE_ENV}`,
|
||||||
|
// Don't include `.env.local` for `test` environment
|
||||||
|
// since normally you expect tests to produce the same
|
||||||
|
// results for everyone
|
||||||
|
NODE_ENV !== 'test' && `${paths.dotenv}.local`,
|
||||||
|
paths.dotenv,
|
||||||
|
].filter(Boolean);
|
||||||
|
|
||||||
|
// Load environment variables from .env* files. Suppress warnings using silent
|
||||||
|
// if this file is missing. dotenv will never modify any environment variables
|
||||||
|
// that have already been set. Variable expansion is supported in .env files.
|
||||||
|
// https://github.com/motdotla/dotenv
|
||||||
|
// https://github.com/motdotla/dotenv-expand
|
||||||
|
dotenvFiles.forEach(dotenvFile => {
|
||||||
|
if (fs.existsSync(dotenvFile)) {
|
||||||
|
require('dotenv-expand')(
|
||||||
|
require('dotenv').config({
|
||||||
|
path: dotenvFile,
|
||||||
|
})
|
||||||
|
);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// We support resolving modules according to `NODE_PATH`.
|
||||||
|
// This lets you use absolute paths in imports inside large monorepos:
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/253.
|
||||||
|
// It works similar to `NODE_PATH` in Node itself:
|
||||||
|
// https://nodejs.org/api/modules.html#modules_loading_from_the_global_folders
|
||||||
|
// Note that unlike in Node, only *relative* paths from `NODE_PATH` are honored.
|
||||||
|
// Otherwise, we risk importing Node.js core modules into an app instead of Webpack shims.
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/1023#issuecomment-265344421
|
||||||
|
// We also resolve them to make sure all tools using them work consistently.
|
||||||
|
const appDirectory = fs.realpathSync(process.cwd());
|
||||||
|
process.env.NODE_PATH = (process.env.NODE_PATH || '')
|
||||||
|
.split(path.delimiter)
|
||||||
|
.filter(folder => folder && !path.isAbsolute(folder))
|
||||||
|
.map(folder => path.resolve(appDirectory, folder))
|
||||||
|
.join(path.delimiter);
|
||||||
|
|
||||||
|
// Grab NODE_ENV and REACT_APP_* environment variables and prepare them to be
|
||||||
|
// injected into the application via DefinePlugin in Webpack configuration.
|
||||||
|
const REACT_APP = /^REACT_APP_/i;
|
||||||
|
|
||||||
|
function getClientEnvironment(publicUrl) {
|
||||||
|
const raw = Object.keys(process.env)
|
||||||
|
.filter(key => REACT_APP.test(key))
|
||||||
|
.reduce(
|
||||||
|
(env, key) => {
|
||||||
|
env[key] = process.env[key];
|
||||||
|
return env;
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// Useful for determining whether we’re running in production mode.
|
||||||
|
// Most importantly, it switches React into the correct mode.
|
||||||
|
NODE_ENV: process.env.NODE_ENV || 'development',
|
||||||
|
// Useful for resolving the correct path to static assets in `public`.
|
||||||
|
// For example, <img src={process.env.PUBLIC_URL + '/img/logo.png'} />.
|
||||||
|
// This should only be used as an escape hatch. Normally you would put
|
||||||
|
// images into the `src` and `import` them in code to get their paths.
|
||||||
|
PUBLIC_URL: publicUrl,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
// Stringify all values so we can feed into Webpack DefinePlugin
|
||||||
|
const stringified = {
|
||||||
|
'process.env': Object.keys(raw).reduce((env, key) => {
|
||||||
|
env[key] = JSON.stringify(raw[key]);
|
||||||
|
return env;
|
||||||
|
}, {}),
|
||||||
|
};
|
||||||
|
|
||||||
|
return { raw, stringified };
|
||||||
|
}
|
||||||
|
|
||||||
|
module.exports = getClientEnvironment;
|
||||||
14
config/jest/cssTransform.js
Normal file
14
config/jest/cssTransform.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// This is a custom Jest transformer turning style imports into empty objects.
|
||||||
|
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
process() {
|
||||||
|
return 'module.exports = {};';
|
||||||
|
},
|
||||||
|
getCacheKey() {
|
||||||
|
// The output is always the same.
|
||||||
|
return 'cssTransform';
|
||||||
|
},
|
||||||
|
};
|
||||||
12
config/jest/fileTransform.js
Normal file
12
config/jest/fileTransform.js
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
|
||||||
|
// This is a custom Jest transformer turning file imports into filenames.
|
||||||
|
// http://facebook.github.io/jest/docs/en/webpack.html
|
||||||
|
|
||||||
|
module.exports = {
|
||||||
|
process(src, filename) {
|
||||||
|
return `module.exports = ${JSON.stringify(path.basename(filename))};`;
|
||||||
|
},
|
||||||
|
};
|
||||||
55
config/paths.js
Normal file
55
config/paths.js
Normal file
@@ -0,0 +1,55 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const fs = require('fs');
|
||||||
|
const url = require('url');
|
||||||
|
|
||||||
|
// Make sure any symlinks in the project folder are resolved:
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/637
|
||||||
|
const appDirectory = fs.realpathSync(process.cwd());
|
||||||
|
const resolveApp = relativePath => path.resolve(appDirectory, relativePath);
|
||||||
|
|
||||||
|
const envPublicUrl = process.env.PUBLIC_URL;
|
||||||
|
|
||||||
|
function ensureSlash(path, needsSlash) {
|
||||||
|
const hasSlash = path.endsWith('/');
|
||||||
|
if (hasSlash && !needsSlash) {
|
||||||
|
return path.substr(path, path.length - 1);
|
||||||
|
} else if (!hasSlash && needsSlash) {
|
||||||
|
return `${path}/`;
|
||||||
|
} else {
|
||||||
|
return path;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const getPublicUrl = appPackageJson =>
|
||||||
|
envPublicUrl || require(appPackageJson).homepage;
|
||||||
|
|
||||||
|
// We use `PUBLIC_URL` environment variable or "homepage" field to infer
|
||||||
|
// "public path" at which the app is served.
|
||||||
|
// Webpack needs to know it to put the right <script> hrefs into HTML even in
|
||||||
|
// single-page apps that may serve index.html for nested URLs like /todos/42.
|
||||||
|
// We can't use a relative path in HTML because we don't want to load something
|
||||||
|
// like /todos/42/static/js/bundle.7289d.js. We have to know the root.
|
||||||
|
function getServedPath(appPackageJson) {
|
||||||
|
const publicUrl = getPublicUrl(appPackageJson);
|
||||||
|
const servedUrl =
|
||||||
|
envPublicUrl || (publicUrl ? url.parse(publicUrl).pathname : '/');
|
||||||
|
return ensureSlash(servedUrl, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// config after eject: we're in ./config/
|
||||||
|
module.exports = {
|
||||||
|
dotenv: resolveApp('.env'),
|
||||||
|
appBuild: resolveApp('build'),
|
||||||
|
appPublic: resolveApp('public'),
|
||||||
|
appHtml: resolveApp('public/index.html'),
|
||||||
|
appIndexJs: resolveApp('src/index.js'),
|
||||||
|
appPackageJson: resolveApp('package.json'),
|
||||||
|
appSrc: resolveApp('src'),
|
||||||
|
yarnLockFile: resolveApp('yarn.lock'),
|
||||||
|
testsSetup: resolveApp('src/setupTests.js'),
|
||||||
|
appNodeModules: resolveApp('node_modules'),
|
||||||
|
publicUrl: getPublicUrl(resolveApp('package.json')),
|
||||||
|
servedPath: getServedPath(resolveApp('package.json')),
|
||||||
|
};
|
||||||
22
config/polyfills.js
Normal file
22
config/polyfills.js
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
if (typeof Promise === 'undefined') {
|
||||||
|
// Rejection tracking prevents a common issue where React gets into an
|
||||||
|
// inconsistent state due to an error, but it gets swallowed by a Promise,
|
||||||
|
// and the user has no idea what causes React's erratic future behavior.
|
||||||
|
require('promise/lib/rejection-tracking').enable();
|
||||||
|
window.Promise = require('promise/lib/es6-extensions.js');
|
||||||
|
}
|
||||||
|
|
||||||
|
// fetch() polyfill for making API calls.
|
||||||
|
require('whatwg-fetch');
|
||||||
|
|
||||||
|
// Object.assign() is commonly used with React.
|
||||||
|
// It will use the native implementation if it's present and isn't buggy.
|
||||||
|
Object.assign = require('object-assign');
|
||||||
|
|
||||||
|
// In tests, polyfill requestAnimationFrame since jsdom doesn't provide it yet.
|
||||||
|
// We don't polyfill it in the browser--this is user's responsibility.
|
||||||
|
if (process.env.NODE_ENV === 'test') {
|
||||||
|
require('raf').polyfill(global);
|
||||||
|
}
|
||||||
251
config/webpack.config.dev.js
Normal file
251
config/webpack.config.dev.js
Normal file
@@ -0,0 +1,251 @@
|
|||||||
|
'use strict';
|
||||||
|
const browserPlugin = require('webpack-browser-plugin');
|
||||||
|
const chromeUserDataDir = './chrome_data';
|
||||||
|
|
||||||
|
|
||||||
|
const autoprefixer = require('autoprefixer');
|
||||||
|
const path = require('path');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
|
||||||
|
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
|
||||||
|
const WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
|
||||||
|
const eslintFormatter = require('react-dev-utils/eslintFormatter');
|
||||||
|
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
||||||
|
const getClientEnvironment = require('./env');
|
||||||
|
const paths = require('./paths');
|
||||||
|
|
||||||
|
// Webpack uses `publicPath` to determine where the app is being served from.
|
||||||
|
// In development, we always serve from the root. This makes config easier.
|
||||||
|
const publicPath = '/';
|
||||||
|
// `publicUrl` is just like `publicPath`, but we will provide it to our app
|
||||||
|
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
|
||||||
|
// Omit trailing slash as %PUBLIC_PATH%/xyz looks better than %PUBLIC_PATH%xyz.
|
||||||
|
const publicUrl = '';
|
||||||
|
// Get environment variables to inject into our app.
|
||||||
|
const env = getClientEnvironment(publicUrl);
|
||||||
|
|
||||||
|
// This is the development configuration.
|
||||||
|
// It is focused on developer experience and fast rebuilds.
|
||||||
|
// The production configuration is different and lives in a separate file.
|
||||||
|
module.exports = {
|
||||||
|
// You may want 'eval' instead if you prefer to see the compiled output in DevTools.
|
||||||
|
// See the discussion in https://github.com/facebookincubator/create-react-app/issues/343.
|
||||||
|
devtool: 'cheap-module-source-map',
|
||||||
|
// These are the "entry points" to our application.
|
||||||
|
// This means they will be the "root" imports that are included in JS bundle.
|
||||||
|
// The first two entry points enable "hot" CSS and auto-refreshes for JS.
|
||||||
|
entry: [
|
||||||
|
// We ship a few polyfills by default:
|
||||||
|
require.resolve('./polyfills'),
|
||||||
|
// Include an alternative client for WebpackDevServer. A client's job is to
|
||||||
|
// connect to WebpackDevServer by a socket and get notified about changes.
|
||||||
|
// When you save a file, the client will either apply hot updates (in case
|
||||||
|
// of CSS changes), or refresh the page (in case of JS changes). When you
|
||||||
|
// make a syntax error, this client will display a syntax error overlay.
|
||||||
|
// Note: instead of the default WebpackDevServer client, we use a custom one
|
||||||
|
// to bring better experience for Create React App users. You can replace
|
||||||
|
// the line below with these two lines if you prefer the stock client:
|
||||||
|
// require.resolve('webpack-dev-server/client') + '?/',
|
||||||
|
// require.resolve('webpack/hot/dev-server'),
|
||||||
|
require.resolve('react-dev-utils/webpackHotDevClient'),
|
||||||
|
// Finally, this is your app's code:
|
||||||
|
paths.appIndexJs,
|
||||||
|
// We include the app code last so that if there is a runtime error during
|
||||||
|
// initialization, it doesn't blow up the WebpackDevServer client, and
|
||||||
|
// changing JS code would still trigger a refresh.
|
||||||
|
],
|
||||||
|
output: {
|
||||||
|
// Add /* filename */ comments to generated require()s in the output.
|
||||||
|
pathinfo: true,
|
||||||
|
// This does not produce a real file. It's just the virtual path that is
|
||||||
|
// served by WebpackDevServer in development. This is the JS bundle
|
||||||
|
// containing code from all our entry points, and the Webpack runtime.
|
||||||
|
filename: 'static/js/bundle.js',
|
||||||
|
// There are also additional JS chunk files if you use code splitting.
|
||||||
|
chunkFilename: 'static/js/[name].chunk.js',
|
||||||
|
// This is the URL that app is served from. We use "/" in development.
|
||||||
|
publicPath: publicPath,
|
||||||
|
// Point sourcemap entries to original disk location (format as URL on Windows)
|
||||||
|
devtoolModuleFilenameTemplate: info =>
|
||||||
|
path.resolve(info.absoluteResourcePath).replace(/\\/g, '/'),
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
// This allows you to set a fallback for where Webpack should look for modules.
|
||||||
|
// We placed these paths second because we want `node_modules` to "win"
|
||||||
|
// if there are any conflicts. This matches Node resolution mechanism.
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/253
|
||||||
|
modules: ['node_modules', paths.appNodeModules].concat(
|
||||||
|
// It is guaranteed to exist because we tweak it in `env.js`
|
||||||
|
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
|
||||||
|
),
|
||||||
|
// These are the reasonable defaults supported by the Node ecosystem.
|
||||||
|
// We also include JSX as a common component filename extension to support
|
||||||
|
// some tools, although we do not recommend using it, see:
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/290
|
||||||
|
// `web` extension prefixes have been added for better support
|
||||||
|
// for React Native Web.
|
||||||
|
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
|
||||||
|
alias: {
|
||||||
|
|
||||||
|
// Support React Native Web
|
||||||
|
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
|
||||||
|
'react-native': 'react-native-web',
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// Prevents users from importing files from outside of src/ (or node_modules/).
|
||||||
|
// This often causes confusion because we only process files within src/ with babel.
|
||||||
|
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
||||||
|
// please link the files into your node_modules/ and let module-resolution kick in.
|
||||||
|
// Make sure your source files are compiled, as they will not be processed in any way.
|
||||||
|
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
strictExportPresence: true,
|
||||||
|
rules: [
|
||||||
|
// TODO: Disable require.ensure as it's not a standard language feature.
|
||||||
|
// We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176.
|
||||||
|
// { parser: { requireEnsure: false } },
|
||||||
|
|
||||||
|
// First, run the linter.
|
||||||
|
// It's important to do this before Babel processes the JS.
|
||||||
|
{
|
||||||
|
test: /\.(js|jsx|mjs)$/,
|
||||||
|
enforce: 'pre',
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
options: {
|
||||||
|
formatter: eslintFormatter,
|
||||||
|
eslintPath: require.resolve('eslint'),
|
||||||
|
|
||||||
|
},
|
||||||
|
loader: require.resolve('eslint-loader'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
include: paths.appSrc,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// "oneOf" will traverse all following loaders until one will
|
||||||
|
// match the requirements. When no loader matches it will fall
|
||||||
|
// back to the "file" loader at the end of the loader list.
|
||||||
|
oneOf: [
|
||||||
|
// "url" loader works like "file" loader except that it embeds assets
|
||||||
|
// smaller than specified limit in bytes as data URLs to avoid requests.
|
||||||
|
// A missing `test` is equivalent to a match.
|
||||||
|
{
|
||||||
|
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
||||||
|
loader: require.resolve('url-loader'),
|
||||||
|
options: {
|
||||||
|
limit: 10000,
|
||||||
|
name: 'static/media/[name].[hash:8].[ext]',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Process JS with Babel.
|
||||||
|
{
|
||||||
|
test: /\.(js|jsx|mjs)$/,
|
||||||
|
include: paths.appSrc,
|
||||||
|
loader: require.resolve('babel-loader'),
|
||||||
|
options: {
|
||||||
|
|
||||||
|
// This is a feature of `babel-loader` for webpack (not Babel itself).
|
||||||
|
// It enables caching results in ./node_modules/.cache/babel-loader/
|
||||||
|
// directory for faster rebuilds.
|
||||||
|
cacheDirectory: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// "postcss" loader applies autoprefixer to our CSS.
|
||||||
|
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
||||||
|
// "style" loader turns CSS into JS modules that inject <style> tags.
|
||||||
|
// In production, we use a plugin to extract that CSS to a file, but
|
||||||
|
// in development "style" loader enables hot editing of CSS.
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
loaders: [
|
||||||
|
'style-loader?sourceMap',
|
||||||
|
'css-loader?modules&importLoaders=1&localIdentName=[path]___[name]__[local]___[hash:base64:5]'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
// "file" loader makes sure those assets get served by WebpackDevServer.
|
||||||
|
// When you `import` an asset, you get its (virtual) filename.
|
||||||
|
// In production, they would get copied to the `build` folder.
|
||||||
|
// This loader doesn't use a "test" so it will catch all modules
|
||||||
|
// that fall through the other loaders.
|
||||||
|
{
|
||||||
|
// Exclude `js` files to keep "css" loader working as it injects
|
||||||
|
// its runtime that would otherwise processed through "file" loader.
|
||||||
|
// Also exclude `html` and `json` extensions so they get processed
|
||||||
|
// by webpacks internal loaders.
|
||||||
|
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
|
||||||
|
loader: require.resolve('file-loader'),
|
||||||
|
options: {
|
||||||
|
name: 'static/media/[name].[hash:8].[ext]',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
// ** STOP ** Are you adding a new loader?
|
||||||
|
// Make sure to add the new loader(s) before the "file" loader.
|
||||||
|
],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// Makes some environment variables available in index.html.
|
||||||
|
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
|
||||||
|
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||||
|
// In development, this will be an empty string.
|
||||||
|
new InterpolateHtmlPlugin(env.raw),
|
||||||
|
// Generates an `index.html` file with the <script> injected.
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
inject: true,
|
||||||
|
template: paths.appHtml,
|
||||||
|
}),
|
||||||
|
// Add module names to factory functions so they appear in browser profiler.
|
||||||
|
new webpack.NamedModulesPlugin(),
|
||||||
|
// Makes some environment variables available to the JS code, for example:
|
||||||
|
// if (process.env.NODE_ENV === 'development') { ... }. See `./env.js`.
|
||||||
|
new webpack.DefinePlugin(env.stringified),
|
||||||
|
// This is necessary to emit hot updates (currently CSS only):
|
||||||
|
new webpack.HotModuleReplacementPlugin(),
|
||||||
|
// Watcher doesn't work well if you mistype casing in a path so we use
|
||||||
|
// a plugin that prints an error when you attempt to do this.
|
||||||
|
// See https://github.com/facebookincubator/create-react-app/issues/240
|
||||||
|
new CaseSensitivePathsPlugin(),
|
||||||
|
// If you require a missing module and then `npm install` it, you still have
|
||||||
|
// to restart the development server for Webpack to discover it. This plugin
|
||||||
|
// makes the discovery automatic so you don't have to restart.
|
||||||
|
// See https://github.com/facebookincubator/create-react-app/issues/186
|
||||||
|
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
|
||||||
|
// Moment.js is an extremely popular library that bundles large locale files
|
||||||
|
// by default due to how Webpack interprets its code. This is a practical
|
||||||
|
// solution that requires the user to opt into importing specific locales.
|
||||||
|
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
||||||
|
// You can remove this if you don't use Moment.js:
|
||||||
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
||||||
|
new browserPlugin({
|
||||||
|
url: 'http://localhost',
|
||||||
|
port: 3000,
|
||||||
|
openOptions: {
|
||||||
|
app: [
|
||||||
|
process.platform === 'win32' ? 'chrome' : 'google-chrome-stable',
|
||||||
|
'--disable-web-security',
|
||||||
|
'--user-data-dir=' + path.resolve(chromeUserDataDir)
|
||||||
|
]
|
||||||
|
}
|
||||||
|
})
|
||||||
|
],
|
||||||
|
// Some libraries import Node modules but don't use them in the browser.
|
||||||
|
// Tell Webpack to provide empty mocks for them so importing them works.
|
||||||
|
node: {
|
||||||
|
dgram: 'empty',
|
||||||
|
fs: 'empty',
|
||||||
|
net: 'empty',
|
||||||
|
tls: 'empty',
|
||||||
|
child_process: 'empty',
|
||||||
|
},
|
||||||
|
// Turn off performance hints during development because we don't do any
|
||||||
|
// splitting or minification in interest of speed. These warnings become
|
||||||
|
// cumbersome.
|
||||||
|
performance: {
|
||||||
|
hints: false,
|
||||||
|
}
|
||||||
|
};
|
||||||
291
config/webpack.config.prod.js
Normal file
291
config/webpack.config.prod.js
Normal file
@@ -0,0 +1,291 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const autoprefixer = require('autoprefixer');
|
||||||
|
const path = require('path');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const HtmlWebpackPlugin = require('html-webpack-plugin');
|
||||||
|
const ExtractTextPlugin = require('extract-text-webpack-plugin');
|
||||||
|
const ManifestPlugin = require('webpack-manifest-plugin');
|
||||||
|
const InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
|
||||||
|
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
|
||||||
|
const eslintFormatter = require('react-dev-utils/eslintFormatter');
|
||||||
|
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
|
||||||
|
const paths = require('./paths');
|
||||||
|
const getClientEnvironment = require('./env');
|
||||||
|
|
||||||
|
// Webpack uses `publicPath` to determine where the app is being served from.
|
||||||
|
// It requires a trailing slash, or the file assets will get an incorrect path.
|
||||||
|
const publicPath = paths.servedPath;
|
||||||
|
// Some apps do not use client-side routing with pushState.
|
||||||
|
// For these, "homepage" can be set to "." to enable relative asset paths.
|
||||||
|
const shouldUseRelativeAssetPaths = publicPath === './';
|
||||||
|
// Source maps are resource heavy and can cause out of memory issue for large source files.
|
||||||
|
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
|
||||||
|
// `publicUrl` is just like `publicPath`, but we will provide it to our app
|
||||||
|
// as %PUBLIC_URL% in `index.html` and `process.env.PUBLIC_URL` in JavaScript.
|
||||||
|
// Omit trailing slash as %PUBLIC_URL%/xyz looks better than %PUBLIC_URL%xyz.
|
||||||
|
const publicUrl = publicPath.slice(0, -1);
|
||||||
|
// Get environment variables to inject into our app.
|
||||||
|
const env = getClientEnvironment(publicUrl);
|
||||||
|
|
||||||
|
// Assert this just to be safe.
|
||||||
|
// Development builds of React are slow and not intended for production.
|
||||||
|
if (env.stringified['process.env'].NODE_ENV !== '"production"') {
|
||||||
|
throw new Error('Production builds must have NODE_ENV=production.');
|
||||||
|
}
|
||||||
|
|
||||||
|
// This is the production configuration.
|
||||||
|
// It compiles slowly and is focused on producing a fast and minimal bundle.
|
||||||
|
// The development configuration is different and lives in a separate file.
|
||||||
|
module.exports = {
|
||||||
|
// Don't attempt to continue if there are any errors.
|
||||||
|
bail: true,
|
||||||
|
// We generate sourcemaps in production. This is slow but gives good results.
|
||||||
|
// You can exclude the *.map files from the build during deployment.
|
||||||
|
devtool: shouldUseSourceMap ? 'source-map' : false,
|
||||||
|
// In production, we only want to load the polyfills and the app code.
|
||||||
|
entry: [require.resolve('./polyfills'), paths.appIndexJs],
|
||||||
|
output: {
|
||||||
|
// The build folder.
|
||||||
|
path: paths.appBuild,
|
||||||
|
// Generated JS file names (with nested folders).
|
||||||
|
// There will be one main bundle, and one file per asynchronous chunk.
|
||||||
|
// We don't currently advertise code splitting but Webpack supports it.
|
||||||
|
filename: 'static/js/[name].[chunkhash:8].js',
|
||||||
|
chunkFilename: 'static/js/[name].[chunkhash:8].chunk.js',
|
||||||
|
// We inferred the "public path" (such as / or /my-project) from homepage.
|
||||||
|
publicPath: publicPath,
|
||||||
|
// Point sourcemap entries to original disk location (format as URL on Windows)
|
||||||
|
devtoolModuleFilenameTemplate: info =>
|
||||||
|
path
|
||||||
|
.relative(paths.appSrc, info.absoluteResourcePath)
|
||||||
|
.replace(/\\/g, '/'),
|
||||||
|
},
|
||||||
|
resolve: {
|
||||||
|
// This allows you to set a fallback for where Webpack should look for modules.
|
||||||
|
// We placed these paths second because we want `node_modules` to "win"
|
||||||
|
// if there are any conflicts. This matches Node resolution mechanism.
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/253
|
||||||
|
modules: ['node_modules', paths.appNodeModules].concat(
|
||||||
|
// It is guaranteed to exist because we tweak it in `env.js`
|
||||||
|
process.env.NODE_PATH.split(path.delimiter).filter(Boolean)
|
||||||
|
),
|
||||||
|
// These are the reasonable defaults supported by the Node ecosystem.
|
||||||
|
// We also include JSX as a common component filename extension to support
|
||||||
|
// some tools, although we do not recommend using it, see:
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/290
|
||||||
|
// `web` extension prefixes have been added for better support
|
||||||
|
// for React Native Web.
|
||||||
|
extensions: ['.web.js', '.mjs', '.js', '.json', '.web.jsx', '.jsx'],
|
||||||
|
alias: {
|
||||||
|
|
||||||
|
// Support React Native Web
|
||||||
|
// https://www.smashingmagazine.com/2016/08/a-glimpse-into-the-future-with-react-native-for-web/
|
||||||
|
'react-native': 'react-native-web',
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// Prevents users from importing files from outside of src/ (or node_modules/).
|
||||||
|
// This often causes confusion because we only process files within src/ with babel.
|
||||||
|
// To fix this, we prevent you from importing files out of src/ -- if you'd like to,
|
||||||
|
// please link the files into your node_modules/ and let module-resolution kick in.
|
||||||
|
// Make sure your source files are compiled, as they will not be processed in any way.
|
||||||
|
new ModuleScopePlugin(paths.appSrc, [paths.appPackageJson]),
|
||||||
|
],
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
strictExportPresence: true,
|
||||||
|
rules: [
|
||||||
|
// TODO: Disable require.ensure as it's not a standard language feature.
|
||||||
|
// We are waiting for https://github.com/facebookincubator/create-react-app/issues/2176.
|
||||||
|
// { parser: { requireEnsure: false } },
|
||||||
|
|
||||||
|
// First, run the linter.
|
||||||
|
// It's important to do this before Babel processes the JS.
|
||||||
|
{
|
||||||
|
test: /\.(js|jsx|mjs)$/,
|
||||||
|
enforce: 'pre',
|
||||||
|
use: [
|
||||||
|
{
|
||||||
|
options: {
|
||||||
|
formatter: eslintFormatter,
|
||||||
|
eslintPath: require.resolve('eslint'),
|
||||||
|
|
||||||
|
},
|
||||||
|
loader: require.resolve('eslint-loader'),
|
||||||
|
},
|
||||||
|
],
|
||||||
|
include: paths.appSrc,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
// "oneOf" will traverse all following loaders until one will
|
||||||
|
// match the requirements. When no loader matches it will fall
|
||||||
|
// back to the "file" loader at the end of the loader list.
|
||||||
|
oneOf: [
|
||||||
|
// "url" loader works just like "file" loader but it also embeds
|
||||||
|
// assets smaller than specified size as data URLs to avoid requests.
|
||||||
|
{
|
||||||
|
test: [/\.bmp$/, /\.gif$/, /\.jpe?g$/, /\.png$/],
|
||||||
|
loader: require.resolve('url-loader'),
|
||||||
|
options: {
|
||||||
|
limit: 10000,
|
||||||
|
name: 'static/media/[name].[hash:8].[ext]',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// Process JS with Babel.
|
||||||
|
{
|
||||||
|
test: /\.(js|jsx|mjs)$/,
|
||||||
|
include: paths.appSrc,
|
||||||
|
loader: require.resolve('babel-loader'),
|
||||||
|
options: {
|
||||||
|
|
||||||
|
compact: true,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// The notation here is somewhat confusing.
|
||||||
|
// "postcss" loader applies autoprefixer to our CSS.
|
||||||
|
// "css" loader resolves paths in CSS and adds assets as dependencies.
|
||||||
|
// "style" loader normally turns CSS into JS modules injecting <style>,
|
||||||
|
// but unlike in development configuration, we do something different.
|
||||||
|
// `ExtractTextPlugin` first applies the "postcss" and "css" loaders
|
||||||
|
// (second argument), then grabs the result CSS and puts it into a
|
||||||
|
// separate file in our build process. This way we actually ship
|
||||||
|
// a single CSS file in production instead of JS code injecting <style>
|
||||||
|
// tags. If you use code splitting, however, any async bundles will still
|
||||||
|
// use the "style" loader inside the async code so CSS from them won't be
|
||||||
|
// in the main CSS file.
|
||||||
|
{
|
||||||
|
test: /\.css$/,
|
||||||
|
use: ExtractTextPlugin.extract({
|
||||||
|
fallback: 'style-loader',
|
||||||
|
use: 'css-loader?modules,localIdentName="[name]-[local]-[hash:base64:6]"'
|
||||||
|
}),
|
||||||
|
},
|
||||||
|
// "file" loader makes sure assets end up in the `build` folder.
|
||||||
|
// When you `import` an asset, you get its filename.
|
||||||
|
// This loader doesn't use a "test" so it will catch all modules
|
||||||
|
// that fall through the other loaders.
|
||||||
|
{
|
||||||
|
loader: require.resolve('file-loader'),
|
||||||
|
// Exclude `js` files to keep "css" loader working as it injects
|
||||||
|
// it's runtime that would otherwise processed through "file" loader.
|
||||||
|
// Also exclude `html` and `json` extensions so they get processed
|
||||||
|
// by webpacks internal loaders.
|
||||||
|
exclude: [/\.(js|jsx|mjs)$/, /\.html$/, /\.json$/],
|
||||||
|
options: {
|
||||||
|
name: 'static/media/[name].[hash:8].[ext]',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
// ** STOP ** Are you adding a new loader?
|
||||||
|
// Make sure to add the new loader(s) before the "file" loader.
|
||||||
|
],
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
// Makes some environment variables available in index.html.
|
||||||
|
// The public URL is available as %PUBLIC_URL% in index.html, e.g.:
|
||||||
|
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||||
|
// In production, it will be an empty string unless you specify "homepage"
|
||||||
|
// in `package.json`, in which case it will be the pathname of that URL.
|
||||||
|
new InterpolateHtmlPlugin(env.raw),
|
||||||
|
// Generates an `index.html` file with the <script> injected.
|
||||||
|
new HtmlWebpackPlugin({
|
||||||
|
inject: true,
|
||||||
|
template: paths.appHtml,
|
||||||
|
minify: {
|
||||||
|
removeComments: true,
|
||||||
|
collapseWhitespace: true,
|
||||||
|
removeRedundantAttributes: true,
|
||||||
|
useShortDoctype: true,
|
||||||
|
removeEmptyAttributes: true,
|
||||||
|
removeStyleLinkTypeAttributes: true,
|
||||||
|
keepClosingSlash: true,
|
||||||
|
minifyJS: true,
|
||||||
|
minifyCSS: true,
|
||||||
|
minifyURLs: true,
|
||||||
|
},
|
||||||
|
}),
|
||||||
|
// Makes some environment variables available to the JS code, for example:
|
||||||
|
// if (process.env.NODE_ENV === 'production') { ... }. See `./env.js`.
|
||||||
|
// It is absolutely essential that NODE_ENV was set to production here.
|
||||||
|
// Otherwise React will be compiled in the very slow development mode.
|
||||||
|
new webpack.DefinePlugin(env.stringified),
|
||||||
|
// Minify the code.
|
||||||
|
new webpack.optimize.UglifyJsPlugin({
|
||||||
|
compress: {
|
||||||
|
warnings: false,
|
||||||
|
// Disabled because of an issue with Uglify breaking seemingly valid code:
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/2376
|
||||||
|
// Pending further investigation:
|
||||||
|
// https://github.com/mishoo/UglifyJS2/issues/2011
|
||||||
|
comparisons: false,
|
||||||
|
},
|
||||||
|
mangle: {
|
||||||
|
safari10: true,
|
||||||
|
},
|
||||||
|
output: {
|
||||||
|
comments: false,
|
||||||
|
// Turned on because emoji and regex is not minified properly using default
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/2488
|
||||||
|
ascii_only: true,
|
||||||
|
},
|
||||||
|
sourceMap: shouldUseSourceMap,
|
||||||
|
}),
|
||||||
|
// Note: this won't work without ExtractTextPlugin.extract(..) in `loaders`.
|
||||||
|
new ExtractTextPlugin({
|
||||||
|
filename: 'app.css',
|
||||||
|
allChunks: true
|
||||||
|
}),
|
||||||
|
// Generate a manifest file which contains a mapping of all asset filenames
|
||||||
|
// to their corresponding output file so that tools can pick it up without
|
||||||
|
// having to parse `index.html`.
|
||||||
|
new ManifestPlugin({
|
||||||
|
fileName: 'asset-manifest.json',
|
||||||
|
}),
|
||||||
|
// Generate a service worker script that will precache, and keep up to date,
|
||||||
|
// the HTML & assets that are part of the Webpack build.
|
||||||
|
new SWPrecacheWebpackPlugin({
|
||||||
|
// By default, a cache-busting query parameter is appended to requests
|
||||||
|
// used to populate the caches, to ensure the responses are fresh.
|
||||||
|
// If a URL is already hashed by Webpack, then there is no concern
|
||||||
|
// about it being stale, and the cache-busting can be skipped.
|
||||||
|
dontCacheBustUrlsMatching: /\.\w{8}\./,
|
||||||
|
filename: 'service-worker.js',
|
||||||
|
logger(message) {
|
||||||
|
if (message.indexOf('Total precache size is') === 0) {
|
||||||
|
// This message occurs for every build and is a bit too noisy.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (message.indexOf('Skipping static resource') === 0) {
|
||||||
|
// This message obscures real errors so we ignore it.
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/2612
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
console.log(message);
|
||||||
|
},
|
||||||
|
minify: true,
|
||||||
|
// For unknown URLs, fallback to the index page
|
||||||
|
navigateFallback: publicUrl + '/index.html',
|
||||||
|
// Ignores URLs starting from /__ (useful for Firebase):
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/2237#issuecomment-302693219
|
||||||
|
navigateFallbackWhitelist: [/^(?!\/__).*/],
|
||||||
|
// Don't precache sourcemaps (they're large) and build asset manifest:
|
||||||
|
staticFileGlobsIgnorePatterns: [/\.map$/, /asset-manifest\.json$/],
|
||||||
|
}),
|
||||||
|
// Moment.js is an extremely popular library that bundles large locale files
|
||||||
|
// by default due to how Webpack interprets its code. This is a practical
|
||||||
|
// solution that requires the user to opt into importing specific locales.
|
||||||
|
// https://github.com/jmblog/how-to-optimize-momentjs-with-webpack
|
||||||
|
// You can remove this if you don't use Moment.js:
|
||||||
|
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
|
||||||
|
],
|
||||||
|
// Some libraries import Node modules but don't use them in the browser.
|
||||||
|
// Tell Webpack to provide empty mocks for them so importing them works.
|
||||||
|
node: {
|
||||||
|
dgram: 'empty',
|
||||||
|
fs: 'empty',
|
||||||
|
net: 'empty',
|
||||||
|
tls: 'empty',
|
||||||
|
child_process: 'empty',
|
||||||
|
},
|
||||||
|
};
|
||||||
95
config/webpackDevServer.config.js
Normal file
95
config/webpackDevServer.config.js
Normal file
@@ -0,0 +1,95 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
const errorOverlayMiddleware = require('react-dev-utils/errorOverlayMiddleware');
|
||||||
|
const noopServiceWorkerMiddleware = require('react-dev-utils/noopServiceWorkerMiddleware');
|
||||||
|
const ignoredFiles = require('react-dev-utils/ignoredFiles');
|
||||||
|
const config = require('./webpack.config.dev');
|
||||||
|
const paths = require('./paths');
|
||||||
|
|
||||||
|
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||||
|
const host = process.env.HOST || '0.0.0.0';
|
||||||
|
|
||||||
|
module.exports = function(proxy, allowedHost) {
|
||||||
|
return {
|
||||||
|
// WebpackDevServer 2.4.3 introduced a security fix that prevents remote
|
||||||
|
// websites from potentially accessing local content through DNS rebinding:
|
||||||
|
// https://github.com/webpack/webpack-dev-server/issues/887
|
||||||
|
// https://medium.com/webpack/webpack-dev-server-middleware-security-issues-1489d950874a
|
||||||
|
// However, it made several existing use cases such as development in cloud
|
||||||
|
// environment or subdomains in development significantly more complicated:
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/2271
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/2233
|
||||||
|
// While we're investigating better solutions, for now we will take a
|
||||||
|
// compromise. Since our WDS configuration only serves files in the `public`
|
||||||
|
// folder we won't consider accessing them a vulnerability. However, if you
|
||||||
|
// use the `proxy` feature, it gets more dangerous because it can expose
|
||||||
|
// remote code execution vulnerabilities in backends like Django and Rails.
|
||||||
|
// So we will disable the host check normally, but enable it if you have
|
||||||
|
// specified the `proxy` setting. Finally, we let you override it if you
|
||||||
|
// really know what you're doing with a special environment variable.
|
||||||
|
disableHostCheck:
|
||||||
|
!proxy || process.env.DANGEROUSLY_DISABLE_HOST_CHECK === 'true',
|
||||||
|
// Enable gzip compression of generated files.
|
||||||
|
compress: true,
|
||||||
|
// Silence WebpackDevServer's own logs since they're generally not useful.
|
||||||
|
// It will still show compile warnings and errors with this setting.
|
||||||
|
clientLogLevel: 'none',
|
||||||
|
// By default WebpackDevServer serves physical files from current directory
|
||||||
|
// in addition to all the virtual build products that it serves from memory.
|
||||||
|
// This is confusing because those files won’t automatically be available in
|
||||||
|
// production build folder unless we copy them. However, copying the whole
|
||||||
|
// project directory is dangerous because we may expose sensitive files.
|
||||||
|
// Instead, we establish a convention that only files in `public` directory
|
||||||
|
// get served. Our build script will copy `public` into the `build` folder.
|
||||||
|
// In `index.html`, you can get URL of `public` folder with %PUBLIC_URL%:
|
||||||
|
// <link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||||
|
// In JavaScript code, you can access it with `process.env.PUBLIC_URL`.
|
||||||
|
// Note that we only recommend to use `public` folder as an escape hatch
|
||||||
|
// for files like `favicon.ico`, `manifest.json`, and libraries that are
|
||||||
|
// for some reason broken when imported through Webpack. If you just want to
|
||||||
|
// use an image, put it in `src` and `import` it from JavaScript instead.
|
||||||
|
contentBase: paths.appPublic,
|
||||||
|
// By default files from `contentBase` will not trigger a page reload.
|
||||||
|
watchContentBase: true,
|
||||||
|
// Enable hot reloading server. It will provide /sockjs-node/ endpoint
|
||||||
|
// for the WebpackDevServer client so it can learn when the files were
|
||||||
|
// updated. The WebpackDevServer client is included as an entry point
|
||||||
|
// in the Webpack development configuration. Note that only changes
|
||||||
|
// to CSS are currently hot reloaded. JS changes will refresh the browser.
|
||||||
|
hot: true,
|
||||||
|
// It is important to tell WebpackDevServer to use the same "root" path
|
||||||
|
// as we specified in the config. In development, we always serve from /.
|
||||||
|
publicPath: config.output.publicPath,
|
||||||
|
// WebpackDevServer is noisy by default so we emit custom message instead
|
||||||
|
// by listening to the compiler events with `compiler.plugin` calls above.
|
||||||
|
quiet: true,
|
||||||
|
// Reportedly, this avoids CPU overload on some systems.
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/293
|
||||||
|
// src/node_modules is not ignored to support absolute imports
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/1065
|
||||||
|
watchOptions: {
|
||||||
|
ignored: ignoredFiles(paths.appSrc),
|
||||||
|
},
|
||||||
|
// Enable HTTPS if the HTTPS environment variable is set to 'true'
|
||||||
|
https: protocol === 'https',
|
||||||
|
host: host,
|
||||||
|
overlay: false,
|
||||||
|
historyApiFallback: {
|
||||||
|
// Paths with dots should still use the history fallback.
|
||||||
|
// See https://github.com/facebookincubator/create-react-app/issues/387.
|
||||||
|
disableDotRule: true,
|
||||||
|
},
|
||||||
|
public: allowedHost,
|
||||||
|
proxy,
|
||||||
|
before(app) {
|
||||||
|
// This lets us open files from the runtime error overlay.
|
||||||
|
app.use(errorOverlayMiddleware());
|
||||||
|
// This service worker file is effectively a 'no-op' that will reset any
|
||||||
|
// previous service worker registered for the same host:port combination.
|
||||||
|
// We do this in development to avoid hitting the production cache if
|
||||||
|
// it used the same host and port.
|
||||||
|
// https://github.com/facebookincubator/create-react-app/issues/2272#issuecomment-302832432
|
||||||
|
app.use(noopServiceWorkerMiddleware());
|
||||||
|
},
|
||||||
|
};
|
||||||
|
};
|
||||||
416
electron.js
Normal file
416
electron.js
Normal file
@@ -0,0 +1,416 @@
|
|||||||
|
// Modules to control application life and create native browser window
|
||||||
|
|
||||||
|
const {app, BrowserWindow, Tray, nativeImage, Menu} = require('electron');
|
||||||
|
const {ipcMain} = require('electron');
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const url = require('url');
|
||||||
|
require('electron-debug')();
|
||||||
|
const os = require('os');
|
||||||
|
const helpers = require('./helpers');
|
||||||
|
const fs = require('fs');
|
||||||
|
const unzip = require('unzipper');
|
||||||
|
const AutoLaunch = require('auto-launch');
|
||||||
|
|
||||||
|
// 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.
|
||||||
|
let mainWindow;
|
||||||
|
let mainWindowTray;
|
||||||
|
let mountedPIDs = [];
|
||||||
|
|
||||||
|
function createWindow() {
|
||||||
|
// Create the browser window.
|
||||||
|
const height = process.env.ELECTRON_START_URL ? 340 : 320;
|
||||||
|
mainWindow = new BrowserWindow({
|
||||||
|
width: 425,
|
||||||
|
height: height,
|
||||||
|
resizable: false,
|
||||||
|
webPreferences: {
|
||||||
|
webSecurity: !process.env.ELECTRON_START_URL
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
// and load the index.html of the app.
|
||||||
|
const startUrl = process.env.ELECTRON_START_URL || url.format({
|
||||||
|
pathname: path.join(__dirname, '/build/index.html'),
|
||||||
|
protocol: 'file:',
|
||||||
|
slashes: true
|
||||||
|
});
|
||||||
|
mainWindow.loadURL(startUrl);
|
||||||
|
|
||||||
|
// Emitted when the window is closed.
|
||||||
|
mainWindow.on('closed', function () {
|
||||||
|
// 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
|
||||||
|
});
|
||||||
|
|
||||||
|
if (os.platform() === 'win32') {
|
||||||
|
const autoLauncher = new AutoLaunch({
|
||||||
|
name: 'Repertory UI',
|
||||||
|
path: path.resolve(path.join(app.getAppPath(), '..\\..\\repertory-ui.exe')),
|
||||||
|
});
|
||||||
|
|
||||||
|
const image = nativeImage.createFromPath(path.join(__dirname, '/build/icon.ico'));
|
||||||
|
const contextMenu = Menu.buildFromTemplate([
|
||||||
|
{
|
||||||
|
label: 'Visible', type: 'checkbox', click(item) {
|
||||||
|
if (item.checked) {
|
||||||
|
mainWindow.show();
|
||||||
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore();
|
||||||
|
}
|
||||||
|
mainWindow.focus()
|
||||||
|
} else {
|
||||||
|
mainWindow.hide();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: 'Auto-start', type: 'checkbox', click(item) {
|
||||||
|
if (item.checked) {
|
||||||
|
autoLauncher.enable();
|
||||||
|
} else {
|
||||||
|
autoLauncher.disable();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]);
|
||||||
|
|
||||||
|
contextMenu.items[0].checked = true;
|
||||||
|
autoLauncher.isEnabled()
|
||||||
|
.then((enabled) => {
|
||||||
|
contextMenu.items[1].checked = enabled;
|
||||||
|
|
||||||
|
mainWindowTray = new Tray(image);
|
||||||
|
mainWindowTray.setToolTip('Repertory UI');
|
||||||
|
mainWindowTray.setContextMenu(contextMenu)
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
app.quit();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const instanceLock = app.requestSingleInstanceLock();
|
||||||
|
if (!instanceLock) {
|
||||||
|
app.quit()
|
||||||
|
} else {
|
||||||
|
app.on('second-instance', () => {
|
||||||
|
if (mainWindow) {
|
||||||
|
if (mainWindow.isMinimized()) {
|
||||||
|
mainWindow.restore();
|
||||||
|
}
|
||||||
|
mainWindow.focus()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('ready', createWindow);
|
||||||
|
|
||||||
|
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') {
|
||||||
|
app.quit()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
app.on('activate', () => {
|
||||||
|
// On OS X it's common to re-create a window in the app when the
|
||||||
|
// dock icon is clicked and there are no other windows open.
|
||||||
|
if (mainWindow === null) {
|
||||||
|
createWindow()
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcMain.on('check_installed', (event, data) => {
|
||||||
|
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||||
|
const destination = path.join(dataDirectory, data.Version);
|
||||||
|
helpers
|
||||||
|
.getMissingDependencies(data.Dependencies)
|
||||||
|
.then((dependencies) => {
|
||||||
|
let exists = false;
|
||||||
|
try {
|
||||||
|
exists = fs.existsSync(destination) && fs.lstatSync(destination).isDirectory();
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
event.sender.send('check_installed_reply', {
|
||||||
|
data: {
|
||||||
|
Dependencies: dependencies,
|
||||||
|
Exists: exists,
|
||||||
|
Success: true,
|
||||||
|
Version: data.Version,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}).catch((e) => {
|
||||||
|
event.sender.send('check_installed_reply', {
|
||||||
|
data: {
|
||||||
|
Dependencies: [],
|
||||||
|
Error: e,
|
||||||
|
Success: false,
|
||||||
|
Version: data.Version,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('delete_file', (event, data) => {
|
||||||
|
try {
|
||||||
|
if (fs.existsSync(data.FilePath)) {
|
||||||
|
fs.unlinkSync(data.FilePath);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('detect_mounts', (event, data) => {
|
||||||
|
let driveLetters = {
|
||||||
|
Hyperspace: [],
|
||||||
|
Sia: [],
|
||||||
|
};
|
||||||
|
|
||||||
|
const grabDriveLetters = (hsLocation, siaLocation) => {
|
||||||
|
for (let i = 'c'.charCodeAt(0); i <= 'z'.charCodeAt(0); i++) {
|
||||||
|
const drive = (String.fromCharCode(i) + ':').toUpperCase();
|
||||||
|
if (!(hsLocation.startsWith(drive) || siaLocation.startsWith(drive))) {
|
||||||
|
try {
|
||||||
|
if (!fs.existsSync(drive)) {
|
||||||
|
driveLetters.Hyperspace.push(drive);
|
||||||
|
driveLetters.Sia.push(drive);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hsLocation.length > 0) {
|
||||||
|
if (!driveLetters.Hyperspace.find((driveLetter) => {
|
||||||
|
return driveLetter === hsLocation;
|
||||||
|
})) {
|
||||||
|
driveLetters.Hyperspace.push(hsLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (siaLocation.length > 0) {
|
||||||
|
if (!driveLetters.Sia.find((driveLetter) => {
|
||||||
|
return driveLetter === siaLocation;
|
||||||
|
})) {
|
||||||
|
driveLetters.Sia.push(siaLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||||
|
helpers
|
||||||
|
.detectRepertoryMounts(dataDirectory, data.Version)
|
||||||
|
.then((results) => {
|
||||||
|
let hsLocation = results.Hyperspace.Location;
|
||||||
|
let siaLocation = results.Sia.Location;
|
||||||
|
if (os.platform() === 'win32') {
|
||||||
|
hsLocation = hsLocation.toUpperCase();
|
||||||
|
siaLocation = siaLocation.toUpperCase();
|
||||||
|
grabDriveLetters(hsLocation, siaLocation);
|
||||||
|
}
|
||||||
|
event.sender.send('detect_mounts_reply', {
|
||||||
|
data: {
|
||||||
|
DriveLetters: driveLetters,
|
||||||
|
Locations: {
|
||||||
|
Hyperspace: hsLocation,
|
||||||
|
Sia: siaLocation,
|
||||||
|
},
|
||||||
|
Success: true,
|
||||||
|
PIDS: {
|
||||||
|
Hyperspace: results.Hyperspace.PID,
|
||||||
|
Sia: results.Sia.PID,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((err) => {
|
||||||
|
grabDriveLetters('', '');
|
||||||
|
|
||||||
|
event.sender.send('detect_mounts_reply', {
|
||||||
|
data: {
|
||||||
|
DriveLetters: driveLetters,
|
||||||
|
Error: err,
|
||||||
|
Success: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('download_file', (event, data) => {
|
||||||
|
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||||
|
const destination = path.join(dataDirectory, data.Filename);
|
||||||
|
helpers.downloadFile(data.URL, destination, (progress) => {
|
||||||
|
event.sender.send('download_file_progress', {
|
||||||
|
data: {
|
||||||
|
Destination: destination,
|
||||||
|
Progress: progress,
|
||||||
|
URL: data.URL,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, (success, err) => {
|
||||||
|
event.sender.send('download_file_complete', {
|
||||||
|
data: {
|
||||||
|
Destination: destination,
|
||||||
|
Error: err,
|
||||||
|
Success: success,
|
||||||
|
URL: data.URL,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('extract_release', (event, data) => {
|
||||||
|
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||||
|
const destination = path.join(dataDirectory, data.Version);
|
||||||
|
helpers.mkDirByPathSync(destination);
|
||||||
|
|
||||||
|
const stream = fs.createReadStream(data.Source);
|
||||||
|
stream.pipe(unzip.Extract({ path: destination }))
|
||||||
|
.on('error', (e) => {
|
||||||
|
try {
|
||||||
|
helpers.removeDirectoryRecursively(destination);
|
||||||
|
} catch (e) {
|
||||||
|
}
|
||||||
|
stream.close();
|
||||||
|
event.sender.send('extract_release_complete', {
|
||||||
|
data: {
|
||||||
|
Error: e,
|
||||||
|
Source: data.Source,
|
||||||
|
Success: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.on('finish', () => {
|
||||||
|
stream.close();
|
||||||
|
event.sender.send('extract_release_complete', {
|
||||||
|
data: {
|
||||||
|
Source: data.Source,
|
||||||
|
Success: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('get_platform', (event) => {
|
||||||
|
event.sender.send('get_platform_reply', {
|
||||||
|
data: os.platform()
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('get_state', (event, data) => {
|
||||||
|
const dataDirectory = helpers.resolvePath(data);
|
||||||
|
helpers.mkDirByPathSync(dataDirectory);
|
||||||
|
const configFile = path.join(dataDirectory, 'settings.json');
|
||||||
|
if (fs.existsSync(configFile)) {
|
||||||
|
event.sender.send('get_state_reply', {
|
||||||
|
data: JSON.parse(fs.readFileSync(configFile, 'utf8')),
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
event.sender.send('get_state_reply', {
|
||||||
|
data: null,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('grab_releases', (event) => {
|
||||||
|
event.sender.send('grab_releases_reply');
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('grab_ui_releases', (event) => {
|
||||||
|
event.sender.send('grab_ui_releases_reply');
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('install_dependency', (event, data) => {
|
||||||
|
helpers
|
||||||
|
.executeAndWait(data.Source)
|
||||||
|
.then(()=> {
|
||||||
|
event.sender.send('install_dependency_reply', {
|
||||||
|
data: {
|
||||||
|
Source: data.Source,
|
||||||
|
Success: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((e)=> {
|
||||||
|
event.sender.send('install_dependency_reply', {
|
||||||
|
data: {
|
||||||
|
Error: e,
|
||||||
|
Source: data.Source,
|
||||||
|
Success: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('install_upgrade', (event, data) => {
|
||||||
|
helpers
|
||||||
|
.executeAsync(data.Source)
|
||||||
|
.then(()=> {
|
||||||
|
mainWindow.close();
|
||||||
|
})
|
||||||
|
.catch((e)=> {
|
||||||
|
event.sender.send('install_upgrade_reply', {
|
||||||
|
data: {
|
||||||
|
Error: e,
|
||||||
|
Source: data.Source,
|
||||||
|
Success: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('mount_drive', (event, data) => {
|
||||||
|
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||||
|
const errorHandler = (pid) => {
|
||||||
|
mountedPIDs.splice(mountedPIDs.indexOf(pid), 1);
|
||||||
|
event.sender.send('unmount_drive_reply', {
|
||||||
|
data: {
|
||||||
|
PID: -1,
|
||||||
|
StorageType: data.StorageType,
|
||||||
|
Success: false,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
helpers.executeMount(dataDirectory, data.Version, data.StorageType, data.Location, (_, pid)=> {
|
||||||
|
errorHandler(pid);
|
||||||
|
})
|
||||||
|
.then(pid=> {
|
||||||
|
if (pid !== -1) {
|
||||||
|
mountedPIDs.push(pid);
|
||||||
|
}
|
||||||
|
event.sender.send('mount_drive_reply', {
|
||||||
|
data: {
|
||||||
|
PID: pid,
|
||||||
|
StorageType: data.StorageType,
|
||||||
|
Success: true,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((_, pid) => {
|
||||||
|
errorHandler(pid);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('save_state', (event, data) => {
|
||||||
|
const dataDirectory = helpers.resolvePath(data.Directory);
|
||||||
|
helpers.mkDirByPathSync(dataDirectory);
|
||||||
|
const configFile = path.join(dataDirectory, 'settings.json');
|
||||||
|
fs.writeFileSync(configFile, JSON.stringify(data.State), 'utf8');
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcMain.on('unmount_drive', (event, data) => {
|
||||||
|
helpers.stopProcessByPID(data.PID)
|
||||||
|
.then((pid)=> {
|
||||||
|
if (mountedPIDs.indexOf(pid) === -1) {
|
||||||
|
event.sender.send('unmount_drive_reply');
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch((e) => {
|
||||||
|
console.log(e);
|
||||||
|
});
|
||||||
|
});
|
||||||
349
helpers.js
Normal file
349
helpers.js
Normal file
@@ -0,0 +1,349 @@
|
|||||||
|
const fs = require('fs');
|
||||||
|
const path = require('path');
|
||||||
|
const os = require('os');
|
||||||
|
const axios = require('axios');
|
||||||
|
const exec = require('child_process').exec;
|
||||||
|
const spawn = require('child_process').spawn;
|
||||||
|
|
||||||
|
const tryParse = (j, def) => {
|
||||||
|
try {
|
||||||
|
return JSON.parse(j);
|
||||||
|
} catch (e) {
|
||||||
|
return def;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.detectRepertoryMounts = (directory, version) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const processOptions = {
|
||||||
|
detached: true,
|
||||||
|
shell: false,
|
||||||
|
windowsHide: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
|
const args = [];
|
||||||
|
args.push('-status');
|
||||||
|
|
||||||
|
const process = new spawn(command, args, processOptions);
|
||||||
|
let result = '';
|
||||||
|
|
||||||
|
process.on('error', (err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
|
||||||
|
process.stdout.on('data', (d)=> {
|
||||||
|
result += d;
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('exit', () => {
|
||||||
|
resolve(tryParse(result, {
|
||||||
|
Hyperspace: {
|
||||||
|
Active: false,
|
||||||
|
Location: '',
|
||||||
|
PID: -1,
|
||||||
|
},
|
||||||
|
Sia: {
|
||||||
|
Active: false,
|
||||||
|
Location: '',
|
||||||
|
PID: -1,
|
||||||
|
},
|
||||||
|
}));
|
||||||
|
});
|
||||||
|
process.unref();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.downloadFile = (url, destination, progressCallback, completeCallback) => {
|
||||||
|
try {
|
||||||
|
if (fs.existsSync(destination)) {
|
||||||
|
fs.unlinkSync(destination);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
completeCallback(false, e);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
axios
|
||||||
|
.get(url, {
|
||||||
|
responseType: 'stream',
|
||||||
|
})
|
||||||
|
.then((response) => {
|
||||||
|
const stream = fs.createWriteStream(destination);
|
||||||
|
const total = parseInt(response.headers['content-length'], 10);
|
||||||
|
let downloaded = 0;
|
||||||
|
response.data.on('data', (chunk) => {
|
||||||
|
stream.write(Buffer.from(chunk));
|
||||||
|
downloaded += chunk.length;
|
||||||
|
progressCallback((downloaded / total * 100.0).toFixed(2));
|
||||||
|
});
|
||||||
|
|
||||||
|
response.data.on('end', () => {
|
||||||
|
stream.end(() => {
|
||||||
|
completeCallback(true);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
response.data.on('error', (e) => {
|
||||||
|
stream.end(() => {
|
||||||
|
completeCallback(false, e);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch((e)=> {
|
||||||
|
completeCallback(false, e);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.executeAndWait = command => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const retryExecute = (count, lastError) => {
|
||||||
|
if (++count <= 5) {
|
||||||
|
exec(command, (error) => {
|
||||||
|
if (error) {
|
||||||
|
if (error.code === 1) {
|
||||||
|
setTimeout(() => {
|
||||||
|
retryExecute(count, error);
|
||||||
|
}, 1000);
|
||||||
|
} else {
|
||||||
|
reject(error);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
reject(lastError);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
retryExecute(0);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.executeAsync = (command) => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const launchProcess = (count, timeout) => {
|
||||||
|
const processOptions = {
|
||||||
|
detached: true,
|
||||||
|
shell: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const process = new spawn(command, [], processOptions);
|
||||||
|
const pid = process.pid;
|
||||||
|
|
||||||
|
process.on('error', (err) => {
|
||||||
|
if (++count === 5) {
|
||||||
|
reject(err, pid);
|
||||||
|
} else {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
setTimeout(()=>launchProcess(count, setTimeout(() => resolve(), 3000)), 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
process.on('exit', (code) => {
|
||||||
|
if (++count === 5) {
|
||||||
|
reject(code, pid);
|
||||||
|
} else {
|
||||||
|
setTimeout(()=>launchProcess(count, setTimeout(() => resolve(), 3000)), 1000);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
process.unref();
|
||||||
|
};
|
||||||
|
|
||||||
|
launchProcess(0, setTimeout(() => resolve(), 3000));
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.executeMount = (directory, version, storageType, location, exitCallback) => {
|
||||||
|
return new Promise((resolve) => {
|
||||||
|
const processOptions = {
|
||||||
|
detached: true,
|
||||||
|
shell: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const command = path.join(directory, version, (os.platform() === 'win32') ? 'repertory.exe' : 'repertory');
|
||||||
|
const args = [];
|
||||||
|
if (storageType.toLowerCase() === 'hyperspace') {
|
||||||
|
args.push('-hs');
|
||||||
|
}
|
||||||
|
if (os.platform() === 'linux') {
|
||||||
|
args.push("-o");
|
||||||
|
args.push("big_writes");
|
||||||
|
}
|
||||||
|
if (os.platform() === 'win32') {
|
||||||
|
args.push('-hidden');
|
||||||
|
}
|
||||||
|
args.push(location);
|
||||||
|
|
||||||
|
const process = new spawn(command, args, processOptions);
|
||||||
|
const pid = process.pid;
|
||||||
|
|
||||||
|
const timeout = setTimeout(() => {
|
||||||
|
resolve(pid);
|
||||||
|
}, 3000);
|
||||||
|
|
||||||
|
process.on('error', (err) => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
exitCallback(err, pid);
|
||||||
|
});
|
||||||
|
process.on('exit', (code) => {
|
||||||
|
clearTimeout(timeout);
|
||||||
|
exitCallback(code, pid);
|
||||||
|
});
|
||||||
|
process.unref();
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.getMissingDependencies = dependencies => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
if (!dependencies || (dependencies.length === 0)) {
|
||||||
|
reject(Error('Dependency list is empty'));
|
||||||
|
}
|
||||||
|
|
||||||
|
let missing = [];
|
||||||
|
if (os.platform() === 'win32') {
|
||||||
|
let count = 0;
|
||||||
|
const resolveIfComplete = () => {
|
||||||
|
if (++count === dependencies.length) {
|
||||||
|
resolve(missing);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
const Registry = require('winreg');
|
||||||
|
for (const dep of dependencies) {
|
||||||
|
let hive = null;
|
||||||
|
const hiveName = dep.registry[0].split('\\')[0];
|
||||||
|
switch (hiveName) {
|
||||||
|
case 'HKEY_CLASSES_ROOT':
|
||||||
|
hive = Registry.HKCR;
|
||||||
|
break;
|
||||||
|
case 'HKEY_CURRENT_CONFIG':
|
||||||
|
hive = Registry.HKCC;
|
||||||
|
break;
|
||||||
|
case 'HKEY_CURRENT_USER':
|
||||||
|
hive = Registry.HKCU;
|
||||||
|
break;
|
||||||
|
case 'HKEY_LOCAL_MACHINE':
|
||||||
|
hive = Registry.HKLM;
|
||||||
|
break;
|
||||||
|
case 'HKEY_USERS':
|
||||||
|
hive = Registry.HKU;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw Error('Invalid registry hive: ' + hiveName);
|
||||||
|
}
|
||||||
|
|
||||||
|
const key = dep.registry[0].substr(hiveName.length);
|
||||||
|
const regKey = new Registry({
|
||||||
|
hive: hive,
|
||||||
|
key: key
|
||||||
|
});
|
||||||
|
regKey.valueExists('DisplayName', (err, exists) => {
|
||||||
|
if (err || !exists) {
|
||||||
|
regKey.valueExists('ProductName', (err, exists) => {
|
||||||
|
if (err || !exists) {
|
||||||
|
missing.push(dep);
|
||||||
|
}
|
||||||
|
resolveIfComplete();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
resolveIfComplete();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
for (const dep of dependencies) {
|
||||||
|
try {
|
||||||
|
if (!fs.lstatSync(dep.file).isFile()) {
|
||||||
|
missing.push(dep);
|
||||||
|
}
|
||||||
|
} catch (e) {
|
||||||
|
missing.push(dep);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
resolve(missing);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
//https://stackoverflow.com/questions/31645738/how-to-create-full-path-with-nodes-fs-mkdirsync
|
||||||
|
module.exports.mkDirByPathSync = (targetDir, { isRelativeToScript = false } = {}) => {
|
||||||
|
const sep = path.sep;
|
||||||
|
const initDir = path.isAbsolute(targetDir) ? sep : '';
|
||||||
|
const baseDir = isRelativeToScript ? __dirname : '.';
|
||||||
|
|
||||||
|
return targetDir.split(sep).reduce((parentDir, childDir) => {
|
||||||
|
const curDir = path.resolve(baseDir, parentDir, childDir);
|
||||||
|
try {
|
||||||
|
fs.mkdirSync(curDir);
|
||||||
|
} catch (err) {
|
||||||
|
if (err.code === 'EEXIST') { // curDir already exists!
|
||||||
|
return curDir;
|
||||||
|
}
|
||||||
|
|
||||||
|
// To avoid `EISDIR` error on Mac and `EACCES`-->`ENOENT` and `EPERM` on Windows.
|
||||||
|
if (err.code === 'ENOENT') { // Throw the original parentDir error on curDir `ENOENT` failure.
|
||||||
|
throw new Error(`EACCES: permission denied, mkdir '${parentDir}'`);
|
||||||
|
}
|
||||||
|
|
||||||
|
const caughtErr = ['EACCES', 'EPERM', 'EISDIR'].indexOf(err.code) > -1;
|
||||||
|
if (!caughtErr || (caughtErr && (targetDir === curDir))) {
|
||||||
|
throw err; // Throw if it's just the last created dir.
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return curDir;
|
||||||
|
}, initDir);
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.removeDirectoryRecursively = (p) => {
|
||||||
|
if (fs.existsSync(p)) {
|
||||||
|
fs
|
||||||
|
.readdirSync(p)
|
||||||
|
.forEach(file => {
|
||||||
|
const curPath = path.join(p, file);
|
||||||
|
if (fs.lstatSync(curPath).isDirectory()) {
|
||||||
|
module.exports.removeDirectoryRecursively(curPath);
|
||||||
|
} else {
|
||||||
|
fs.unlinkSync(curPath);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
fs.rmdirSync(p);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.resolvePath = str => {
|
||||||
|
if (os.platform() === 'win32') {
|
||||||
|
return str.replace(/%([^%]+)%/g, (_, n) => {
|
||||||
|
return process.env[n];
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
return str.replace('~', os.homedir());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
module.exports.stopProcessByPID = pid => {
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
const processOptions = {
|
||||||
|
detached: true,
|
||||||
|
shell: false,
|
||||||
|
windowsHide: true,
|
||||||
|
};
|
||||||
|
|
||||||
|
const command = (os.platform() === 'win32') ? 'taskkill.exe' : '';
|
||||||
|
const args = [];
|
||||||
|
args.push('/PID');
|
||||||
|
args.push(pid);
|
||||||
|
|
||||||
|
const process = new spawn(command, args, processOptions);
|
||||||
|
|
||||||
|
process.on('error', (err) => {
|
||||||
|
reject(err);
|
||||||
|
});
|
||||||
|
process.on('exit', () => {
|
||||||
|
setTimeout(()=>resolve(pid), 3000);
|
||||||
|
});
|
||||||
|
process.unref();
|
||||||
|
});
|
||||||
|
};
|
||||||
138
package.json
Normal file
138
package.json
Normal file
@@ -0,0 +1,138 @@
|
|||||||
|
{
|
||||||
|
"name": "repertory-ui",
|
||||||
|
"version": "1.0.0",
|
||||||
|
"private": true,
|
||||||
|
"dependencies": {
|
||||||
|
"@fortawesome/fontawesome-svg-core": "^1.2.1",
|
||||||
|
"@fortawesome/free-solid-svg-icons": "^5.1.1",
|
||||||
|
"@fortawesome/react-fontawesome": "^0.1.0",
|
||||||
|
"auto-launch": "^5.0.5",
|
||||||
|
"autoprefixer": "7.1.6",
|
||||||
|
"axios": "^0.18.0",
|
||||||
|
"babel-core": "6.26.0",
|
||||||
|
"babel-eslint": "7.2.3",
|
||||||
|
"babel-jest": "20.0.3",
|
||||||
|
"babel-loader": "7.1.2",
|
||||||
|
"babel-preset-react-app": "^3.1.1",
|
||||||
|
"babel-runtime": "6.26.0",
|
||||||
|
"case-sensitive-paths-webpack-plugin": "2.1.1",
|
||||||
|
"chalk": "1.1.3",
|
||||||
|
"color": "^3.0.0",
|
||||||
|
"color-string": "^1.5.2",
|
||||||
|
"css-loader": "0.28.7",
|
||||||
|
"dotenv": "4.0.0",
|
||||||
|
"dotenv-expand": "4.2.0",
|
||||||
|
"electron-debug": "^2.0.0",
|
||||||
|
"eslint": "4.10.0",
|
||||||
|
"eslint-config-react-app": "^2.1.0",
|
||||||
|
"eslint-loader": "1.9.0",
|
||||||
|
"eslint-plugin-flowtype": "2.39.1",
|
||||||
|
"eslint-plugin-import": "2.8.0",
|
||||||
|
"eslint-plugin-jsx-a11y": "5.1.1",
|
||||||
|
"eslint-plugin-react": "7.4.0",
|
||||||
|
"file-loader": "1.1.5",
|
||||||
|
"font-awesome": "^4.7.0",
|
||||||
|
"fs-extra": "3.0.1",
|
||||||
|
"html-webpack-plugin": "2.29.0",
|
||||||
|
"jest": "20.0.4",
|
||||||
|
"node-schedule": "^1.3.0",
|
||||||
|
"npm": "^6.2.0",
|
||||||
|
"object-assign": "4.1.1",
|
||||||
|
"postcss-flexbugs-fixes": "3.2.0",
|
||||||
|
"postcss-loader": "2.0.8",
|
||||||
|
"promise": "8.0.1",
|
||||||
|
"raf": "3.4.0",
|
||||||
|
"react": "^16.4.1",
|
||||||
|
"react-css-modules": "^4.7.4",
|
||||||
|
"react-dev-utils": "^5.0.1",
|
||||||
|
"react-dom": "^16.4.1",
|
||||||
|
"react-loader-spinner": "^2.0.6",
|
||||||
|
"resolve": "1.6.0",
|
||||||
|
"style-loader": "0.19.0",
|
||||||
|
"sw-precache-webpack-plugin": "0.11.4",
|
||||||
|
"unzipper": "^0.9.3",
|
||||||
|
"url-loader": "0.6.2",
|
||||||
|
"webpack": "3.8.1",
|
||||||
|
"webpack-dev-server": "2.9.4",
|
||||||
|
"webpack-manifest-plugin": "1.3.2",
|
||||||
|
"whatwg-fetch": "2.0.3",
|
||||||
|
"winreg": "^1.2.4"
|
||||||
|
},
|
||||||
|
"scripts": {
|
||||||
|
"start": "node scripts/start.js",
|
||||||
|
"build": "node scripts/build.js",
|
||||||
|
"test": "node scripts/test.js --env=jsdom",
|
||||||
|
"electron-dev": "cross-env ELECTRON_START_URL=http://localhost:3000 electron .",
|
||||||
|
"pack": "npm run build && electron-builder --dir",
|
||||||
|
"dist": "npm run build && electron-builder"
|
||||||
|
},
|
||||||
|
"devDependencies": {
|
||||||
|
"cross-env": "^5.2.0",
|
||||||
|
"electron": "3.0.0",
|
||||||
|
"electron-builder": "^20.28.4",
|
||||||
|
"extract-text-webpack-plugin": "^3.0.2",
|
||||||
|
"webpack-browser-plugin": "^1.0.20"
|
||||||
|
},
|
||||||
|
"jest": {
|
||||||
|
"collectCoverageFrom": [
|
||||||
|
"src/**/*.{js,jsx,mjs}"
|
||||||
|
],
|
||||||
|
"setupFiles": [
|
||||||
|
"<rootDir>/config/polyfills.js"
|
||||||
|
],
|
||||||
|
"testMatch": [
|
||||||
|
"<rootDir>/src/**/__tests__/**/*.{js,jsx,mjs}",
|
||||||
|
"<rootDir>/src/**/?(*.)(spec|test).{js,jsx,mjs}"
|
||||||
|
],
|
||||||
|
"testEnvironment": "node",
|
||||||
|
"testURL": "http://localhost",
|
||||||
|
"transform": {
|
||||||
|
"^.+\\.(js|jsx|mjs)$": "<rootDir>/node_modules/babel-jest",
|
||||||
|
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
|
||||||
|
"^(?!.*\\.(js|jsx|mjs|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
|
||||||
|
},
|
||||||
|
"transformIgnorePatterns": [
|
||||||
|
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx|mjs)$"
|
||||||
|
],
|
||||||
|
"moduleNameMapper": {
|
||||||
|
"^react-native$": "react-native-web"
|
||||||
|
},
|
||||||
|
"moduleFileExtensions": [
|
||||||
|
"web.js",
|
||||||
|
"js",
|
||||||
|
"json",
|
||||||
|
"web.jsx",
|
||||||
|
"jsx",
|
||||||
|
"node",
|
||||||
|
"mjs"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"babel": {
|
||||||
|
"presets": [
|
||||||
|
"react-app"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"eslintConfig": {
|
||||||
|
"extends": "react-app"
|
||||||
|
},
|
||||||
|
"main": "electron.js",
|
||||||
|
"homepage": "./",
|
||||||
|
"build": {
|
||||||
|
"appId": "repertory-ui",
|
||||||
|
"files": [
|
||||||
|
"./electron.js",
|
||||||
|
"build/**/*",
|
||||||
|
"node_modules/**/*",
|
||||||
|
"./helpers.js"
|
||||||
|
],
|
||||||
|
"linux": {
|
||||||
|
"icon": "./build/icon.icns"
|
||||||
|
},
|
||||||
|
"win": {
|
||||||
|
"icon": "./build/icon.ico"
|
||||||
|
},
|
||||||
|
"directories": {
|
||||||
|
"buildResources": "public"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
BIN
public/favicon.ico
Normal file
BIN
public/favicon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 361 KiB |
BIN
public/icon.icns
Normal file
BIN
public/icon.icns
Normal file
Binary file not shown.
BIN
public/icon.ico
Normal file
BIN
public/icon.ico
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 361 KiB |
42
public/index.html
Normal file
42
public/index.html
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="utf-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
|
||||||
|
<meta name="theme-color" content="#000000">
|
||||||
|
<!--
|
||||||
|
manifest.json provides metadata used when your web app is added to the
|
||||||
|
homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/
|
||||||
|
-->
|
||||||
|
<link rel="manifest" href="%PUBLIC_URL%/manifest.json">
|
||||||
|
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico">
|
||||||
|
<link href="https://fonts.googleapis.com/css?family=Nunito:400,700" rel="stylesheet">
|
||||||
|
|
||||||
|
<!--
|
||||||
|
Notice the use of %PUBLIC_URL% in the tags above.
|
||||||
|
It will be replaced with the URL of the `public` folder during the build.
|
||||||
|
Only files inside the `public` folder can be referenced from the HTML.
|
||||||
|
|
||||||
|
Unlike "/favicon.ico" or "favicon.ico", "%PUBLIC_URL%/favicon.ico" will
|
||||||
|
work correctly both with client-side routing and a non-root public URL.
|
||||||
|
Learn how to configure a non-root public URL by running `npm run build`.
|
||||||
|
-->
|
||||||
|
<title>Repertory UI</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<noscript>
|
||||||
|
You need to enable JavaScript to run this app.
|
||||||
|
</noscript>
|
||||||
|
<div id="root"></div>
|
||||||
|
<!--
|
||||||
|
This HTML file is a template.
|
||||||
|
If you open it directly in the browser, you will see an empty page.
|
||||||
|
|
||||||
|
You can add webfonts, meta tags, or analytics to this file.
|
||||||
|
The build step will place the bundled scripts into the <body> tag.
|
||||||
|
|
||||||
|
To begin the development, run `npm start` or `yarn start`.
|
||||||
|
To create a production bundle, use `npm run build` or `yarn build`.
|
||||||
|
-->
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
15
public/manifest.json
Normal file
15
public/manifest.json
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
"short_name": "repertory-ui",
|
||||||
|
"name": "Repertory UI",
|
||||||
|
"icons": [
|
||||||
|
{
|
||||||
|
"src": "favicon.ico",
|
||||||
|
"sizes": "64x64 32x32 24x24 16x16",
|
||||||
|
"type": "image/x-icon"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"start_url": "./index.html",
|
||||||
|
"display": "standalone",
|
||||||
|
"theme_color": "#000000",
|
||||||
|
"background_color": "#ffffff"
|
||||||
|
}
|
||||||
17
releases.json
Normal file
17
releases.json
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
"Locations": {
|
||||||
|
"win32": {
|
||||||
|
"1.0.0": {
|
||||||
|
"hash": "",
|
||||||
|
"urls": [
|
||||||
|
"https://sia.pixeldrain.com/api/file/qXM6pVZZ/download"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"Versions": {
|
||||||
|
"win32": [
|
||||||
|
"1.0.0"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}
|
||||||
150
scripts/build.js
Normal file
150
scripts/build.js
Normal file
@@ -0,0 +1,150 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Do this as the first thing so that any code reading it knows the right env.
|
||||||
|
process.env.BABEL_ENV = 'production';
|
||||||
|
process.env.NODE_ENV = 'production';
|
||||||
|
|
||||||
|
// Makes the script crash on unhandled rejections instead of silently
|
||||||
|
// ignoring them. In the future, promise rejections that are not handled will
|
||||||
|
// terminate the Node.js process with a non-zero exit code.
|
||||||
|
process.on('unhandledRejection', err => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure environment variables are read.
|
||||||
|
require('../config/env');
|
||||||
|
|
||||||
|
const path = require('path');
|
||||||
|
const chalk = require('chalk');
|
||||||
|
const fs = require('fs-extra');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const config = require('../config/webpack.config.prod');
|
||||||
|
const paths = require('../config/paths');
|
||||||
|
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||||
|
const formatWebpackMessages = require('react-dev-utils/formatWebpackMessages');
|
||||||
|
const printHostingInstructions = require('react-dev-utils/printHostingInstructions');
|
||||||
|
const FileSizeReporter = require('react-dev-utils/FileSizeReporter');
|
||||||
|
const printBuildError = require('react-dev-utils/printBuildError');
|
||||||
|
|
||||||
|
const measureFileSizesBeforeBuild =
|
||||||
|
FileSizeReporter.measureFileSizesBeforeBuild;
|
||||||
|
const printFileSizesAfterBuild = FileSizeReporter.printFileSizesAfterBuild;
|
||||||
|
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||||
|
|
||||||
|
// These sizes are pretty large. We'll warn for bundles exceeding them.
|
||||||
|
const WARN_AFTER_BUNDLE_GZIP_SIZE = 512 * 1024;
|
||||||
|
const WARN_AFTER_CHUNK_GZIP_SIZE = 1024 * 1024;
|
||||||
|
|
||||||
|
// Warn and crash if required files are missing
|
||||||
|
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// First, read the current file sizes in build directory.
|
||||||
|
// This lets us display how much they changed later.
|
||||||
|
measureFileSizesBeforeBuild(paths.appBuild)
|
||||||
|
.then(previousFileSizes => {
|
||||||
|
// Remove all content but keep the directory so that
|
||||||
|
// if you're in it, you don't end up in Trash
|
||||||
|
fs.emptyDirSync(paths.appBuild);
|
||||||
|
// Merge with the public folder
|
||||||
|
copyPublicFolder();
|
||||||
|
// Start the webpack build
|
||||||
|
return build(previousFileSizes);
|
||||||
|
})
|
||||||
|
.then(
|
||||||
|
({ stats, previousFileSizes, warnings }) => {
|
||||||
|
if (warnings.length) {
|
||||||
|
console.log(chalk.yellow('Compiled with warnings.\n'));
|
||||||
|
console.log(warnings.join('\n\n'));
|
||||||
|
console.log(
|
||||||
|
'\nSearch for the ' +
|
||||||
|
chalk.underline(chalk.yellow('keywords')) +
|
||||||
|
' to learn more about each warning.'
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
'To ignore, add ' +
|
||||||
|
chalk.cyan('// eslint-disable-next-line') +
|
||||||
|
' to the line before.\n'
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
console.log(chalk.green('Compiled successfully.\n'));
|
||||||
|
}
|
||||||
|
|
||||||
|
console.log('File sizes after gzip:\n');
|
||||||
|
printFileSizesAfterBuild(
|
||||||
|
stats,
|
||||||
|
previousFileSizes,
|
||||||
|
paths.appBuild,
|
||||||
|
WARN_AFTER_BUNDLE_GZIP_SIZE,
|
||||||
|
WARN_AFTER_CHUNK_GZIP_SIZE
|
||||||
|
);
|
||||||
|
console.log();
|
||||||
|
|
||||||
|
const appPackage = require(paths.appPackageJson);
|
||||||
|
const publicUrl = paths.publicUrl;
|
||||||
|
const publicPath = config.output.publicPath;
|
||||||
|
const buildFolder = path.relative(process.cwd(), paths.appBuild);
|
||||||
|
printHostingInstructions(
|
||||||
|
appPackage,
|
||||||
|
publicUrl,
|
||||||
|
publicPath,
|
||||||
|
buildFolder,
|
||||||
|
useYarn
|
||||||
|
);
|
||||||
|
},
|
||||||
|
err => {
|
||||||
|
console.log(chalk.red('Failed to compile.\n'));
|
||||||
|
printBuildError(err);
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
// Create the production build and print the deployment instructions.
|
||||||
|
function build(previousFileSizes) {
|
||||||
|
console.log('Creating an optimized production build...');
|
||||||
|
|
||||||
|
let compiler = webpack(config);
|
||||||
|
return new Promise((resolve, reject) => {
|
||||||
|
compiler.run((err, stats) => {
|
||||||
|
if (err) {
|
||||||
|
return reject(err);
|
||||||
|
}
|
||||||
|
const messages = formatWebpackMessages(stats.toJson({}, true));
|
||||||
|
if (messages.errors.length) {
|
||||||
|
// Only keep the first error. Others are often indicative
|
||||||
|
// of the same problem, but confuse the reader with noise.
|
||||||
|
if (messages.errors.length > 1) {
|
||||||
|
messages.errors.length = 1;
|
||||||
|
}
|
||||||
|
return reject(new Error(messages.errors.join('\n\n')));
|
||||||
|
}
|
||||||
|
if (
|
||||||
|
process.env.CI &&
|
||||||
|
(typeof process.env.CI !== 'string' ||
|
||||||
|
process.env.CI.toLowerCase() !== 'false') &&
|
||||||
|
messages.warnings.length
|
||||||
|
) {
|
||||||
|
console.log(
|
||||||
|
chalk.yellow(
|
||||||
|
'\nTreating warnings as errors because process.env.CI = true.\n' +
|
||||||
|
'Most CI servers set it automatically.\n'
|
||||||
|
)
|
||||||
|
);
|
||||||
|
return reject(new Error(messages.warnings.join('\n\n')));
|
||||||
|
}
|
||||||
|
return resolve({
|
||||||
|
stats,
|
||||||
|
previousFileSizes,
|
||||||
|
warnings: messages.warnings,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function copyPublicFolder() {
|
||||||
|
fs.copySync(paths.appPublic, paths.appBuild, {
|
||||||
|
dereference: true,
|
||||||
|
filter: file => file !== paths.appHtml,
|
||||||
|
});
|
||||||
|
}
|
||||||
107
scripts/start.js
Normal file
107
scripts/start.js
Normal file
@@ -0,0 +1,107 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Do this as the first thing so that any code reading it knows the right env.
|
||||||
|
process.env.BABEL_ENV = 'development';
|
||||||
|
process.env.NODE_ENV = 'development';
|
||||||
|
|
||||||
|
// Makes the script crash on unhandled rejections instead of silently
|
||||||
|
// ignoring them. In the future, promise rejections that are not handled will
|
||||||
|
// terminate the Node.js process with a non-zero exit code.
|
||||||
|
process.on('unhandledRejection', err => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure environment variables are read.
|
||||||
|
require('../config/env');
|
||||||
|
|
||||||
|
const fs = require('fs');
|
||||||
|
const chalk = require('chalk');
|
||||||
|
const webpack = require('webpack');
|
||||||
|
const WebpackDevServer = require('webpack-dev-server');
|
||||||
|
const clearConsole = require('react-dev-utils/clearConsole');
|
||||||
|
const checkRequiredFiles = require('react-dev-utils/checkRequiredFiles');
|
||||||
|
const {
|
||||||
|
choosePort,
|
||||||
|
createCompiler,
|
||||||
|
prepareProxy,
|
||||||
|
prepareUrls,
|
||||||
|
} = require('react-dev-utils/WebpackDevServerUtils');
|
||||||
|
const openBrowser = require('react-dev-utils/openBrowser');
|
||||||
|
const paths = require('../config/paths');
|
||||||
|
const config = require('../config/webpack.config.dev');
|
||||||
|
const createDevServerConfig = require('../config/webpackDevServer.config');
|
||||||
|
|
||||||
|
const useYarn = fs.existsSync(paths.yarnLockFile);
|
||||||
|
const isInteractive = process.stdout.isTTY;
|
||||||
|
|
||||||
|
// Warn and crash if required files are missing
|
||||||
|
if (!checkRequiredFiles([paths.appHtml, paths.appIndexJs])) {
|
||||||
|
process.exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Tools like Cloud9 rely on this.
|
||||||
|
const DEFAULT_PORT = parseInt(process.env.PORT, 10) || 3000;
|
||||||
|
const HOST = process.env.HOST || '0.0.0.0';
|
||||||
|
|
||||||
|
if (process.env.HOST) {
|
||||||
|
console.log(
|
||||||
|
chalk.cyan(
|
||||||
|
`Attempting to bind to HOST environment variable: ${chalk.yellow(
|
||||||
|
chalk.bold(process.env.HOST)
|
||||||
|
)}`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
console.log(
|
||||||
|
`If this was unintentional, check that you haven't mistakenly set it in your shell.`
|
||||||
|
);
|
||||||
|
console.log(`Learn more here: ${chalk.yellow('http://bit.ly/2mwWSwH')}`);
|
||||||
|
console.log();
|
||||||
|
}
|
||||||
|
|
||||||
|
// We attempt to use the default port but if it is busy, we offer the user to
|
||||||
|
// run on a different port. `choosePort()` Promise resolves to the next free port.
|
||||||
|
choosePort(HOST, DEFAULT_PORT)
|
||||||
|
.then(port => {
|
||||||
|
if (port == null) {
|
||||||
|
// We have not found a port.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
const protocol = process.env.HTTPS === 'true' ? 'https' : 'http';
|
||||||
|
const appName = require(paths.appPackageJson).name;
|
||||||
|
const urls = prepareUrls(protocol, HOST, port);
|
||||||
|
// Create a webpack compiler that is configured with custom messages.
|
||||||
|
const compiler = createCompiler(webpack, config, appName, urls, useYarn);
|
||||||
|
// Load proxy config
|
||||||
|
const proxySetting = require(paths.appPackageJson).proxy;
|
||||||
|
const proxyConfig = prepareProxy(proxySetting, paths.appPublic);
|
||||||
|
// Serve webpack assets generated by the compiler over a web sever.
|
||||||
|
const serverConfig = createDevServerConfig(
|
||||||
|
proxyConfig,
|
||||||
|
urls.lanUrlForConfig
|
||||||
|
);
|
||||||
|
const devServer = new WebpackDevServer(compiler, serverConfig);
|
||||||
|
// Launch WebpackDevServer.
|
||||||
|
devServer.listen(port, HOST, err => {
|
||||||
|
if (err) {
|
||||||
|
return console.log(err);
|
||||||
|
}
|
||||||
|
if (isInteractive) {
|
||||||
|
clearConsole();
|
||||||
|
}
|
||||||
|
console.log(chalk.cyan('Starting the development server...\n'));
|
||||||
|
//openBrowser(urls.localUrlForBrowser);
|
||||||
|
});
|
||||||
|
|
||||||
|
['SIGINT', 'SIGTERM'].forEach(function(sig) {
|
||||||
|
process.on(sig, function() {
|
||||||
|
devServer.close();
|
||||||
|
process.exit();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.catch(err => {
|
||||||
|
if (err && err.message) {
|
||||||
|
console.log(err.message);
|
||||||
|
}
|
||||||
|
process.exit(1);
|
||||||
|
});
|
||||||
27
scripts/test.js
Normal file
27
scripts/test.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
// Do this as the first thing so that any code reading it knows the right env.
|
||||||
|
process.env.BABEL_ENV = 'test';
|
||||||
|
process.env.NODE_ENV = 'test';
|
||||||
|
process.env.PUBLIC_URL = '';
|
||||||
|
|
||||||
|
// Makes the script crash on unhandled rejections instead of silently
|
||||||
|
// ignoring them. In the future, promise rejections that are not handled will
|
||||||
|
// terminate the Node.js process with a non-zero exit code.
|
||||||
|
process.on('unhandledRejection', err => {
|
||||||
|
throw err;
|
||||||
|
});
|
||||||
|
|
||||||
|
// Ensure environment variables are read.
|
||||||
|
require('../config/env');
|
||||||
|
|
||||||
|
const jest = require('jest');
|
||||||
|
let argv = process.argv.slice(2);
|
||||||
|
|
||||||
|
// Watch unless on CI or in coverage mode
|
||||||
|
if (!process.env.CI && argv.indexOf('--coverage') < 0) {
|
||||||
|
argv.push('--watch');
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
jest.run(argv);
|
||||||
11
src/App.css
Normal file
11
src/App.css
Normal file
@@ -0,0 +1,11 @@
|
|||||||
|
.App {
|
||||||
|
display: flex;
|
||||||
|
flex-direction: column;
|
||||||
|
margin: 0;
|
||||||
|
padding: 10px;
|
||||||
|
box-sizing: border-box;
|
||||||
|
height: 100vh;
|
||||||
|
width: 100vw;
|
||||||
|
background-image: url('./assets/images/background.jpg');
|
||||||
|
background-size: cover;
|
||||||
|
}
|
||||||
564
src/App.js
Normal file
564
src/App.js
Normal file
@@ -0,0 +1,564 @@
|
|||||||
|
import React, {Component} from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './App.css';
|
||||||
|
import Box from './components/UI/Box/Box';
|
||||||
|
import DropDown from './components/UI/DropDown/DropDown';
|
||||||
|
import * as Constants from './constants';
|
||||||
|
import axios from 'axios';
|
||||||
|
import MountItems from './containers/MountItems/MountItems';
|
||||||
|
import DependencyList from './components/DependencyList/DependencyList';
|
||||||
|
import Button from './components/UI/Button/Button';
|
||||||
|
import Modal from './components/UI/Modal/Modal';
|
||||||
|
import DownloadProgress from './components/DownloadProgress/DownloadProgress';
|
||||||
|
import UpgradeUI from './components/UpgradeUI/UpgradeUI';
|
||||||
|
import UpgradeIcon from './components/UpgradeIcon/UpgradeIcon';
|
||||||
|
|
||||||
|
const Scheduler = require('node-schedule');
|
||||||
|
|
||||||
|
let ipcRenderer = null;
|
||||||
|
if (!process.versions.hasOwnProperty('electron')) {
|
||||||
|
ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
class App extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
|
||||||
|
if (ipcRenderer) {
|
||||||
|
ipcRenderer.on('get_platform_reply', (event, arg) => {
|
||||||
|
this.setState({
|
||||||
|
Platform: arg.data,
|
||||||
|
});
|
||||||
|
ipcRenderer.send('get_state', Constants.DATA_LOCATIONS[arg.data]);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('get_state_reply', (event, arg) => {
|
||||||
|
if (arg.data) {
|
||||||
|
if (arg.data.Hyperspace.AutoMount === undefined) {
|
||||||
|
arg.data.Hyperspace['AutoMount'] = false;
|
||||||
|
}
|
||||||
|
if (arg.data.Sia.AutoMount === undefined) {
|
||||||
|
arg.data.Sia['AutoMount'] = false;
|
||||||
|
}
|
||||||
|
this.setState({
|
||||||
|
Hyperspace: arg.data.Hyperspace,
|
||||||
|
Release: arg.data.Release,
|
||||||
|
Sia: arg.data.Sia,
|
||||||
|
Version: arg.data.Version,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
this.grabReleases();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('grab_releases_reply', ()=> {
|
||||||
|
axios.get(Constants.RELEASES_URL)
|
||||||
|
.then(response => {
|
||||||
|
const versionLookup = {
|
||||||
|
Alpha: response.data.Versions.Alpha[this.state.Platform],
|
||||||
|
Beta: response.data.Versions.Beta[this.state.Platform],
|
||||||
|
RC: response.data.Versions.RC[this.state.Platform],
|
||||||
|
Release: response.data.Versions.Release[this.state.Platform],
|
||||||
|
};
|
||||||
|
const locationsLookup = {
|
||||||
|
...response.data.Locations[this.state.Platform],
|
||||||
|
};
|
||||||
|
this.setState({
|
||||||
|
AllowOptions: true,
|
||||||
|
LocationsLookup: locationsLookup,
|
||||||
|
VersionLookup: versionLookup,
|
||||||
|
});
|
||||||
|
this.checkVersionInstalled(this.state.Release, this.state.Version, versionLookup);
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('grab_ui_releases_reply', ()=> {
|
||||||
|
axios.get(Constants.UI_RELEASES_URL)
|
||||||
|
.then(response => {
|
||||||
|
const data = response.data;
|
||||||
|
if (data.Versions &&
|
||||||
|
data.Versions[this.state.Platform] &&
|
||||||
|
(data.Versions[this.state.Platform].length > 0) &&
|
||||||
|
(data.Versions[this.state.Platform][0] !== this.props.version)) {
|
||||||
|
this.setState({
|
||||||
|
UpgradeAvailable: true,
|
||||||
|
UpgradeDismissed: false,
|
||||||
|
UpgradeData: data.Locations[this.state.Platform][data.Versions[this.state.Platform][0]],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}).catch(error => {
|
||||||
|
console.log(error);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('download_file_progress', (event, arg) => {
|
||||||
|
this.setState({
|
||||||
|
DownloadProgress: arg.data.Progress,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('download_file_complete', (event, arg) => {
|
||||||
|
if (this.state.DownloadingRelease) {
|
||||||
|
if (arg.data.Success) {
|
||||||
|
const selectedVersion = this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]][this.state.Version];
|
||||||
|
ipcRenderer.send('extract_release', {
|
||||||
|
Directory: Constants.DATA_LOCATIONS[this.state.Platform],
|
||||||
|
Source: arg.data.Destination,
|
||||||
|
Version: selectedVersion,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
DownloadActive: false,
|
||||||
|
DownloadProgress: 0.0,
|
||||||
|
DownloadingRelease: false,
|
||||||
|
ExtractActive: arg.data.Success,
|
||||||
|
DownloadName: '',
|
||||||
|
});
|
||||||
|
} else if (this.state.DownloadingDependency) {
|
||||||
|
if (arg.data.Success) {
|
||||||
|
ipcRenderer.send('install_dependency', {
|
||||||
|
Source: arg.data.Destination,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
DownloadActive: false,
|
||||||
|
DownloadProgress: 0.0,
|
||||||
|
DownloadingDependency: arg.data.Success,
|
||||||
|
DownloadName: '',
|
||||||
|
});
|
||||||
|
} else if (this.state.DownloadingUpgrade) {
|
||||||
|
if (arg.data.Success) {
|
||||||
|
ipcRenderer.send('install_upgrade', {
|
||||||
|
Source: arg.data.Destination,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
DownloadActive: false,
|
||||||
|
DownloadProgress: 0.0,
|
||||||
|
DownloadingUpgrade: false,
|
||||||
|
DownloadName: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.setState({
|
||||||
|
DownloadActive: false,
|
||||||
|
DownloadProgress: 0.0,
|
||||||
|
DownloadName: '',
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('extract_release_complete', (event, arg) => {
|
||||||
|
ipcRenderer.send('delete_file', {
|
||||||
|
FilePath: arg.data.Source,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
ExtractActive: false,
|
||||||
|
});
|
||||||
|
this.checkVersionInstalled(this.state.Release, this.state.Version);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('check_installed_reply', (event, arg) => {
|
||||||
|
this.setState({
|
||||||
|
AllowDownload: true,
|
||||||
|
DownloadingDependency: false,
|
||||||
|
MissingDependencies: arg.data.Dependencies,
|
||||||
|
RepertoryVersion: arg.data.Success && arg.data.Exists ? arg.data.Version : 'none',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('install_dependency_reply', (event, arg) => {
|
||||||
|
ipcRenderer.send('delete_file', {
|
||||||
|
FilePath: arg.data.Source,
|
||||||
|
});
|
||||||
|
this.checkVersionInstalled(this.state.Release, this.state.Version);
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('install_upgrade_reply', (event, arg) => {
|
||||||
|
ipcRenderer.sendSync('delete_file', {
|
||||||
|
FilePath: arg.data.Source,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
DownloadActive: false,
|
||||||
|
DownloadProgress: 0.0,
|
||||||
|
DownloadName: '',
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.send('get_platform');
|
||||||
|
Scheduler.scheduleJob('23 11 * * *', this.updateCheckScheduledJob);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state = {
|
||||||
|
AllowOptions: false,
|
||||||
|
AllowDownload: false,
|
||||||
|
AutoMountChecked: false,
|
||||||
|
DownloadActive: false,
|
||||||
|
DownloadProgress: 0.0,
|
||||||
|
DownloadingDependency: false,
|
||||||
|
DownloadName: '',
|
||||||
|
DownloadingRelease: false,
|
||||||
|
DownloadingUpgrade: false,
|
||||||
|
ExtractActive: false,
|
||||||
|
Hyperspace: {
|
||||||
|
AutoMount: false,
|
||||||
|
MountLocation: '',
|
||||||
|
},
|
||||||
|
LocationsLookup: {},
|
||||||
|
MissingDependencies: [],
|
||||||
|
Platform: 'unknown',
|
||||||
|
Release: 3,
|
||||||
|
ReleaseTypes: [
|
||||||
|
'Release',
|
||||||
|
'RC',
|
||||||
|
'Beta',
|
||||||
|
'Alpha',
|
||||||
|
],
|
||||||
|
RepertoryVersion: 'none',
|
||||||
|
Sia: {
|
||||||
|
AutoMount: false,
|
||||||
|
MountLocation: '',
|
||||||
|
},
|
||||||
|
UpgradeAvailable: false,
|
||||||
|
UpgradeData: {},
|
||||||
|
UpgradeDismissed: false,
|
||||||
|
Version: 0,
|
||||||
|
VersionLookup: {
|
||||||
|
Alpha: [
|
||||||
|
'unavailable'
|
||||||
|
],
|
||||||
|
Beta: [
|
||||||
|
'unavailable'
|
||||||
|
],
|
||||||
|
RC: [
|
||||||
|
'unavailable'
|
||||||
|
],
|
||||||
|
Release: [
|
||||||
|
'unavailable'
|
||||||
|
],
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
checkVersionInstalled = (release, version, versionLookup) => {
|
||||||
|
if (!versionLookup) {
|
||||||
|
versionLookup = this.state.VersionLookup;
|
||||||
|
}
|
||||||
|
|
||||||
|
const selectedVersion = versionLookup[this.state.ReleaseTypes[release]][version];
|
||||||
|
this.setState({
|
||||||
|
AllowDownload: false,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ipcRenderer) {
|
||||||
|
let dependencies = [];
|
||||||
|
if (this.state.LocationsLookup[selectedVersion] && this.state.LocationsLookup[selectedVersion].dependencies) {
|
||||||
|
dependencies = this.state.LocationsLookup[selectedVersion].dependencies;
|
||||||
|
}
|
||||||
|
|
||||||
|
ipcRenderer.send('check_installed', {
|
||||||
|
Dependencies: dependencies,
|
||||||
|
Directory: Constants.DATA_LOCATIONS[this.state.Platform],
|
||||||
|
Version: selectedVersion,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
grabReleases = () => {
|
||||||
|
if (this.state.Platform !== 'unknown') {
|
||||||
|
if (ipcRenderer) {
|
||||||
|
ipcRenderer.send('grab_releases');
|
||||||
|
ipcRenderer.send('grab_ui_releases');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleAutoMountChanged = (storageType, e) => {
|
||||||
|
let sia = {
|
||||||
|
...this.state.Sia
|
||||||
|
};
|
||||||
|
|
||||||
|
let hyperspace = {
|
||||||
|
...this.state.Hyperspace
|
||||||
|
};
|
||||||
|
|
||||||
|
if (storageType === 'Hyperspace') {
|
||||||
|
hyperspace.AutoMount = e.target.checked;
|
||||||
|
this.setState({
|
||||||
|
Hyperspace: hyperspace,
|
||||||
|
});
|
||||||
|
} else if (storageType === 'Sia') {
|
||||||
|
sia.AutoMount = e.target.checked;
|
||||||
|
this.setState({
|
||||||
|
Sia: sia,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
this.saveState(this.state.Release, this.state.Version, sia, hyperspace);
|
||||||
|
};
|
||||||
|
|
||||||
|
handleDependencyDownload = (url) => {
|
||||||
|
if (ipcRenderer) {
|
||||||
|
const items = url.split('/');
|
||||||
|
const fileName = items[items.length - 1];
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
DownloadActive: true,
|
||||||
|
DownloadingDependency: true,
|
||||||
|
DownloadName: fileName,
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.send('download_file', {
|
||||||
|
Directory: Constants.DATA_LOCATIONS[this.state.Platform],
|
||||||
|
Filename: fileName,
|
||||||
|
URL: url,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleMountLocationChanged = (storageType, location) => {
|
||||||
|
const state = {
|
||||||
|
...this.state[storageType],
|
||||||
|
MountLocation: location,
|
||||||
|
};
|
||||||
|
this.setState({
|
||||||
|
[storageType]: state,
|
||||||
|
});
|
||||||
|
const hyperspace = (storageType === 'Hyperspace') ? state : {
|
||||||
|
...this.state.Hyperspace,
|
||||||
|
};
|
||||||
|
const sia = storageType === 'Sia' ? state : {
|
||||||
|
...this.state.Sia,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.saveState(this.state.Release, this.state.Version, sia, hyperspace);
|
||||||
|
};
|
||||||
|
|
||||||
|
handleReleaseChanged = (e) => {
|
||||||
|
const val = parseInt(e.target.value, 10);
|
||||||
|
this.setState({
|
||||||
|
Release: val,
|
||||||
|
Version: 0
|
||||||
|
});
|
||||||
|
this.saveState(val, 0, this.state.Sia, this.state.Hyperspace);
|
||||||
|
this.checkVersionInstalled(val, 0);
|
||||||
|
};
|
||||||
|
|
||||||
|
handleReleaseDownload = () => {
|
||||||
|
const selectedVersion = this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]][this.state.Version];
|
||||||
|
const fileName = selectedVersion + '.zip';
|
||||||
|
if (ipcRenderer) {
|
||||||
|
this.setState({
|
||||||
|
DownloadActive: true,
|
||||||
|
DownloadingRelease: true,
|
||||||
|
DownloadName: fileName,
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.send('download_file', {
|
||||||
|
Directory: Constants.DATA_LOCATIONS[this.state.Platform],
|
||||||
|
Filename: fileName,
|
||||||
|
URL: this.state.LocationsLookup[selectedVersion].urls[0],
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleUIDownload = () => {
|
||||||
|
if (ipcRenderer) {
|
||||||
|
this.setState({
|
||||||
|
DownloadActive: true,
|
||||||
|
DownloadingUpgrade: true,
|
||||||
|
DownloadName: 'UI Upgrade',
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.send('download_file', {
|
||||||
|
Directory: Constants.DATA_LOCATIONS[this.state.Platform],
|
||||||
|
Filename: this.state.Platform === 'win32' ? 'upgrade.exe' : 'upgrade',
|
||||||
|
URL: this.state.UpgradeData.urls[0],
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
this.setState({UpgradeDismissed: true});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleVersionChanged = (e) => {
|
||||||
|
const val = parseInt(e.target.value, 10);
|
||||||
|
this.setState({
|
||||||
|
Version: val
|
||||||
|
});
|
||||||
|
this.saveState(this.state.Release, val, this.state.Sia, this.state.Hyperspace);
|
||||||
|
this.checkVersionInstalled(this.state.Release, val);
|
||||||
|
};
|
||||||
|
|
||||||
|
notifyAutoMountProcessed = () => {
|
||||||
|
this.setState({AutoMountChecked: true});
|
||||||
|
};
|
||||||
|
|
||||||
|
saveState = (release, version, sia, hyperspace)=> {
|
||||||
|
if (ipcRenderer) {
|
||||||
|
ipcRenderer.send('save_state', {
|
||||||
|
Directory: Constants.DATA_LOCATIONS[this.state.Platform],
|
||||||
|
State: {
|
||||||
|
Hyperspace: hyperspace,
|
||||||
|
Release: release,
|
||||||
|
Sia: sia,
|
||||||
|
Version: version,
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
updateCheckScheduledJob = () => {
|
||||||
|
if (this.state.Platform !== 'unknown') {
|
||||||
|
if (ipcRenderer) {
|
||||||
|
ipcRenderer.send('grab_ui_releases');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
const selectedVersion = this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]][this.state.Version];
|
||||||
|
const downloadEnabled = this.state.AllowDownload &&
|
||||||
|
!this.state.DownloadActive &&
|
||||||
|
(((selectedVersion !== 'unavailable') && (selectedVersion !== this.state.RepertoryVersion)));
|
||||||
|
const allowMount = this.state.RepertoryVersion !== 'none';
|
||||||
|
const missingDependencies = (this.state.MissingDependencies.length > 0);
|
||||||
|
|
||||||
|
let mountDisplay = null;
|
||||||
|
if (allowMount) {
|
||||||
|
mountDisplay = <MountItems platform={this.state.Platform}
|
||||||
|
sia={this.state.Sia}
|
||||||
|
hyperspace={this.state.Hyperspace}
|
||||||
|
changed={this.handleMountLocationChanged}
|
||||||
|
processAutoMount={!this.state.AutoMountChecked}
|
||||||
|
autoMountProcessed={this.notifyAutoMountProcessed}
|
||||||
|
autoMountChanged={this.handleAutoMountChanged}
|
||||||
|
version={this.state.RepertoryVersion}
|
||||||
|
directory={Constants.DATA_LOCATIONS[this.state.Platform]}
|
||||||
|
disabled={!allowMount}/>;
|
||||||
|
}
|
||||||
|
|
||||||
|
let dependencyDisplay = null;
|
||||||
|
if (missingDependencies && !this.state.DownloadActive) {
|
||||||
|
dependencyDisplay = (
|
||||||
|
<Modal>
|
||||||
|
<DependencyList allowDownload={!this.state.DownloadingDependency}
|
||||||
|
dependencies={this.state.MissingDependencies}
|
||||||
|
onDownload={this.handleDependencyDownload}/>
|
||||||
|
}
|
||||||
|
</Modal>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
let downloadDisplay = null;
|
||||||
|
if (this.state.DownloadActive) {
|
||||||
|
downloadDisplay = (
|
||||||
|
<Modal>
|
||||||
|
<DownloadProgress progress={this.state.DownloadProgress}
|
||||||
|
display={this.state.DownloadName}/>
|
||||||
|
</Modal>);
|
||||||
|
}
|
||||||
|
|
||||||
|
let releaseDisplay = null;
|
||||||
|
if (this.state.ExtractActive) {
|
||||||
|
releaseDisplay = <h3 style={{textAlign: 'center'}}>{'Activating <' + selectedVersion + '>'}</h3>
|
||||||
|
} else {
|
||||||
|
releaseDisplay = <Button disabled={!downloadEnabled}
|
||||||
|
clicked={this.handleReleaseDownload}>Install</Button>;
|
||||||
|
}
|
||||||
|
|
||||||
|
let upgradeDisplay = null;
|
||||||
|
if (!missingDependencies &&
|
||||||
|
!this.state.DownloadActive &&
|
||||||
|
this.state.UpgradeAvailable &&
|
||||||
|
!this.state.UpgradeDismissed) {
|
||||||
|
upgradeDisplay = (
|
||||||
|
<Modal>
|
||||||
|
<UpgradeUI upgrade={this.handleUIDownload}
|
||||||
|
cancel={()=>this.setState({UpgradeDismissed: true})}/>
|
||||||
|
</Modal>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
let options = null;
|
||||||
|
if (this.state.AllowOptions) {
|
||||||
|
options = (
|
||||||
|
<table width='100%' cellPadding='2'>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td width='33%'>
|
||||||
|
<h2>Release</h2>
|
||||||
|
</td>
|
||||||
|
<td width='33%'>
|
||||||
|
<h2>Version</h2>
|
||||||
|
</td>
|
||||||
|
<td width='33%'>
|
||||||
|
<h2>Installed</h2>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<DropDown disabled={this.state.DownloadActive || this.state.ExtractActive}
|
||||||
|
items={this.state.ReleaseTypes}
|
||||||
|
selected={this.state.Release}
|
||||||
|
changed={this.handleReleaseChanged}/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<DropDown disabled={this.state.DownloadActive || this.state.ExtractActive}
|
||||||
|
items={this.state.VersionLookup[this.state.ReleaseTypes[this.state.Release]]}
|
||||||
|
selected={this.state.Version}
|
||||||
|
changed={this.handleVersionChanged}/>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{this.state.RepertoryVersion}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colSpan={3}>
|
||||||
|
{releaseDisplay}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colSpan={3}>
|
||||||
|
{mountDisplay}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div styleName='App'>
|
||||||
|
{dependencyDisplay}
|
||||||
|
{upgradeDisplay}
|
||||||
|
{downloadDisplay}
|
||||||
|
<Box dxDark dxStyle={{'height': 'auto', 'padding': '2px'}}>
|
||||||
|
<table cellPadding={0} cellSpacing={0} style={{margin: 0, padding: 0}}>
|
||||||
|
<tbody style={{margin: 0, padding: 0}}>
|
||||||
|
<tr style={{margin: 0, padding: 0}}>
|
||||||
|
<td width='33%' style={{margin: 0, padding: 0}}/>
|
||||||
|
<td width='33%' style={{margin: 0, padding: 0}}>
|
||||||
|
<h1 style={{'textAlign': 'center'}}>{'Repertory UI v' + this.props.version}</h1>
|
||||||
|
</td>
|
||||||
|
<td width='33%' style={{margin: 0, padding: 0}} align='right' valign='middle'>
|
||||||
|
<UpgradeIcon
|
||||||
|
available={this.state.UpgradeAvailable}
|
||||||
|
clicked={()=>this.setState({UpgradeDismissed: false})}/>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</Box>
|
||||||
|
<Box dxStyle={{'padding': '4px', 'marginTop': '10px'}}>
|
||||||
|
{options}
|
||||||
|
</Box>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(App, styles, {allowMultiple: true});
|
||||||
BIN
src/assets/images/background.jpg
Normal file
BIN
src/assets/images/background.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 48 KiB |
BIN
src/assets/images/upgrade_available.png
Normal file
BIN
src/assets/images/upgrade_available.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 175 KiB |
9
src/components/DependencyList/Dependency/Dependency.css
Normal file
9
src/components/DependencyList/Dependency/Dependency.css
Normal file
@@ -0,0 +1,9 @@
|
|||||||
|
.Dependency {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Link {
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
25
src/components/DependencyList/Dependency/Dependency.js
Normal file
25
src/components/DependencyList/Dependency/Dependency.js
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './Dependency.css';
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
return (
|
||||||
|
<div styleName='Dependency'>
|
||||||
|
<table width="100%">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td width="35%">
|
||||||
|
<h3>{props.name}</h3>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
{props.allowDownload ?
|
||||||
|
<a styleName='Link' href={void(0)} onClick={()=>{props.onDownload(props.download); return false;}}><u>Install</u></a> :
|
||||||
|
'Installing...'}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
3
src/components/DependencyList/DependencyList.css
Normal file
3
src/components/DependencyList/DependencyList.css
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
.DependencyList {
|
||||||
|
|
||||||
|
}
|
||||||
27
src/components/DependencyList/DependencyList.js
Normal file
27
src/components/DependencyList/DependencyList.js
Normal file
@@ -0,0 +1,27 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './DependencyList.css';
|
||||||
|
import Dependency from './Dependency/Dependency';
|
||||||
|
import Box from '../UI/Box/Box';
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
const items = props.dependencies.map((k, i)=> {
|
||||||
|
return (
|
||||||
|
<Dependency allowDownload={props.allowDownload}
|
||||||
|
key={i}
|
||||||
|
name={k.display}
|
||||||
|
download={k.download}
|
||||||
|
onDownload={props.onDownload}/>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box dxDark dxStyle={{width: '300px', height: 'auto', padding: '5px'}}>
|
||||||
|
<div style={{width: '100%', height: 'auto', paddingBottom: '5px', boxSizing: 'border-box'}}>
|
||||||
|
<h1 style={{width: '100%', textAlign: 'center'}}>Missing Dependencies</h1>
|
||||||
|
</div>
|
||||||
|
{items}
|
||||||
|
</Box>
|
||||||
|
);
|
||||||
|
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
17
src/components/DownloadProgress/DownloadProgress.js
Normal file
17
src/components/DownloadProgress/DownloadProgress.js
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
import Box from '../UI/Box/Box';
|
||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './DownloadProgress.css';
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
|
||||||
|
return (
|
||||||
|
<Box dxDark dxStyle={{width: '380px', height: 'auto', padding: '5px'}}>
|
||||||
|
<div style={{width: '100%', height: 'auto'}}>
|
||||||
|
<h1 style={{width: '100%', textAlign: 'center'}}>{'Downloading ' + props.display}</h1>
|
||||||
|
</div>
|
||||||
|
<progress max={100.0} id={'download_progress'}
|
||||||
|
style={{width: '100%'}}
|
||||||
|
value={props.progress}/>
|
||||||
|
</Box>);
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
4
src/components/MountItem/MountItem.css
Normal file
4
src/components/MountItem/MountItem.css
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.MountItem {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
|
|
||||||
52
src/components/MountItem/MountItem.js
Normal file
52
src/components/MountItem/MountItem.js
Normal file
@@ -0,0 +1,52 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './MountItem.css';
|
||||||
|
import DropDown from '../UI/DropDown/DropDown';
|
||||||
|
import Button from '../UI/Button/Button';
|
||||||
|
import Loader from 'react-loader-spinner';
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
let inputControl = null;
|
||||||
|
let mountWidth = '70%';
|
||||||
|
if (props.platform === 'win32') {
|
||||||
|
inputControl = <DropDown disabled={!props.allowMount || props.mounted}
|
||||||
|
items={props.items}
|
||||||
|
selected={props.items.indexOf(props.location)}
|
||||||
|
changed={props.changed}/>;
|
||||||
|
mountWidth = '18%';
|
||||||
|
} else {
|
||||||
|
inputControl = <input disabled={!props.allowMount || props.mounted}
|
||||||
|
type={'text'}
|
||||||
|
value={props.location}
|
||||||
|
onChange={props.changed}/>;
|
||||||
|
}
|
||||||
|
|
||||||
|
let actionDisplay = null;
|
||||||
|
if (props.allowMount) {
|
||||||
|
actionDisplay = <Button buttonStyles={{width: '100%'}}
|
||||||
|
clicked={()=>props.clicked(props.title, !props.mounted, props.location, props.pid)}>{props.mounted ? 'Unmount' : 'Mount'}</Button>;
|
||||||
|
} else {
|
||||||
|
actionDisplay = <Loader color={'var(--heading_text_color)'}
|
||||||
|
height='24px'
|
||||||
|
width='24px'
|
||||||
|
type='Circles'/>;
|
||||||
|
}
|
||||||
|
return (
|
||||||
|
<div styleName='MountItem'>
|
||||||
|
<h2>{props.title}</h2>
|
||||||
|
<table width='100%' cellPadding='2'>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td width={mountWidth} height='30px'>{inputControl}</td>
|
||||||
|
<td width='25%' align='center' valign='middle'>
|
||||||
|
{actionDisplay}
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<input type='checkbox' checked={props.autoMount} onChange={props.autoMountChanged}/>Auto-mount
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
41
src/components/UI/Box/Box.css
Normal file
41
src/components/UI/Box/Box.css
Normal file
@@ -0,0 +1,41 @@
|
|||||||
|
.Box {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
background-color: var(--control_transparent_background);
|
||||||
|
box-sizing: border-box;
|
||||||
|
border: var(--control_border);
|
||||||
|
border-radius: var(--border_radius);
|
||||||
|
box-shadow: var(--control_box_shadow);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Box.Darker {
|
||||||
|
background-color: var(--control_dark_transparent_background);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Box.SlideOut {
|
||||||
|
animation: slide-out 0.5s forwards;
|
||||||
|
transform: translateX(-100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Box.SlideOutTop {
|
||||||
|
animation: slide-out-top 0.5s forwards;
|
||||||
|
transform: translateY(-100%);
|
||||||
|
}
|
||||||
|
|
||||||
|
.Box.FadeIn {
|
||||||
|
transition: 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slide-out {
|
||||||
|
100% {
|
||||||
|
transform: translateX(0%);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@keyframes slide-out-top {
|
||||||
|
100% {
|
||||||
|
transform: translateY(0%);
|
||||||
|
}
|
||||||
|
}
|
||||||
28
src/components/UI/Box/Box.js
Normal file
28
src/components/UI/Box/Box.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './Box.css';
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
const styleList = ['Box'];
|
||||||
|
if (props.dxDark) {
|
||||||
|
styleList.push('Darker');
|
||||||
|
}
|
||||||
|
|
||||||
|
if (props.dxSlideOut) {
|
||||||
|
styleList.push('SlideOut');
|
||||||
|
} else if (props.dxFadeIn) {
|
||||||
|
styleList.push('FadeIn');
|
||||||
|
} else if (props.dxSlideOutTop) {
|
||||||
|
styleList.push('SlideOutTop');
|
||||||
|
}
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
onClick={props.clicked}
|
||||||
|
styleName={styleList.join(' ')}
|
||||||
|
style={{...props.dxStyle}}>
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
30
src/components/UI/Button/Button.css
Normal file
30
src/components/UI/Button/Button.css
Normal file
@@ -0,0 +1,30 @@
|
|||||||
|
.Button {
|
||||||
|
display: block;
|
||||||
|
text-align: center;
|
||||||
|
margin: 0;
|
||||||
|
padding: 4px;
|
||||||
|
outline: 0;
|
||||||
|
color: var(--text_color);
|
||||||
|
border-radius: var(--border_radius);
|
||||||
|
background-color: var(--control_background);
|
||||||
|
border: none;
|
||||||
|
text-decoration: none;
|
||||||
|
text-outline: none;
|
||||||
|
width: 70px;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Button:hover:enabled {
|
||||||
|
background: var(--control_background_hover);
|
||||||
|
color: var(--text_color_hover);
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Button:hover:disabled {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Button:active,
|
||||||
|
.Button.active {
|
||||||
|
box-shadow: none;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
13
src/components/UI/Button/Button.js
Normal file
13
src/components/UI/Button/Button.js
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './Button.css';
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
return (
|
||||||
|
<button disabled={props.disabled}
|
||||||
|
styleName={'Button'}
|
||||||
|
style={props.buttonStyles}
|
||||||
|
onClick={props.clicked}>{props.children}</button>
|
||||||
|
);
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
|
|
||||||
24
src/components/UI/DropDown/DropDown.css
Normal file
24
src/components/UI/DropDown/DropDown.css
Normal file
@@ -0,0 +1,24 @@
|
|||||||
|
.DropDown {
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Select {
|
||||||
|
width: 100%;
|
||||||
|
height: 100%;
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
padding: 2px;
|
||||||
|
border-radius: var(--border_radius);
|
||||||
|
background: rgba(10, 10, 20, 0.3);
|
||||||
|
border-color: rgba(10, 10, 20, 0.9);
|
||||||
|
color: var(--text_color);
|
||||||
|
box-sizing: border-box;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Option {
|
||||||
|
background: rgba(10, 10, 15, 0.8);
|
||||||
|
border-color: rgba(10, 10, 20, 0.9);
|
||||||
|
color: var(--text_color);
|
||||||
|
}
|
||||||
20
src/components/UI/DropDown/DropDown.js
Normal file
20
src/components/UI/DropDown/DropDown.js
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './DropDown.css';
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
const options = props.items.map((s, i) => {
|
||||||
|
return (
|
||||||
|
<option styleName='Option' key={i} value={i}>{s}</option>
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
|
return (
|
||||||
|
<div styleName='DropDown'>
|
||||||
|
<select styleName='Select' disabled={props.disabled} onChange={props.changed} value={props.selected}>
|
||||||
|
{options}
|
||||||
|
</select>
|
||||||
|
</div>
|
||||||
|
);
|
||||||
|
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
19
src/components/UI/Modal/Modal.css
Normal file
19
src/components/UI/Modal/Modal.css
Normal file
@@ -0,0 +1,19 @@
|
|||||||
|
.Modal {
|
||||||
|
position: fixed;
|
||||||
|
left: 0;
|
||||||
|
top: 0;
|
||||||
|
width: 100vw;
|
||||||
|
height: 100vh;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
z-index: 2000;
|
||||||
|
}
|
||||||
|
|
||||||
|
.Content {
|
||||||
|
position: fixed;
|
||||||
|
width: auto;
|
||||||
|
height: auto;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
z-index: 2001;
|
||||||
|
}
|
||||||
14
src/components/UI/Modal/Modal.js
Normal file
14
src/components/UI/Modal/Modal.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './Modal.css'
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
return (
|
||||||
|
<div
|
||||||
|
styleName='Modal'
|
||||||
|
onClick={props.clicked}>
|
||||||
|
<div styleName='Content'>
|
||||||
|
{props.children}
|
||||||
|
</div>
|
||||||
|
</div>);
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
14
src/components/UpgradeIcon/UpgradeIcon.css
Normal file
14
src/components/UpgradeIcon/UpgradeIcon.css
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
.UpgradeIcon {
|
||||||
|
display: block;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
width: 20px;
|
||||||
|
height: 20px;
|
||||||
|
border: 0;
|
||||||
|
box-sizing: border-box;
|
||||||
|
cursor: pointer;
|
||||||
|
}
|
||||||
|
|
||||||
|
div.UpgradeIcon {
|
||||||
|
cursor: default;
|
||||||
|
}
|
||||||
10
src/components/UpgradeIcon/UpgradeIcon.js
Normal file
10
src/components/UpgradeIcon/UpgradeIcon.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './UpgradeIcon.css';
|
||||||
|
import availableImage from '../../assets/images/upgrade_available.png';
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
return props.available ?
|
||||||
|
<img alt='' styleName='UpgradeIcon' src={availableImage} onClick={props.clicked}/> :
|
||||||
|
<div styleName='UpgradeIcon'/> ;
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
0
src/components/UpgradeUI/UpgradeUI.css
Normal file
0
src/components/UpgradeUI/UpgradeUI.css
Normal file
28
src/components/UpgradeUI/UpgradeUI.js
Normal file
28
src/components/UpgradeUI/UpgradeUI.js
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import Button from '../UI/Button/Button';
|
||||||
|
import Box from '../UI/Box/Box';
|
||||||
|
import React from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './UpgradeUI.css';
|
||||||
|
|
||||||
|
export default CSSModules((props) => {
|
||||||
|
return (
|
||||||
|
<Box dxDark dxStyle={{width: '180px', height: 'auto', padding: '5px'}}>
|
||||||
|
<div style={{width: '100%', height: 'auto'}}>
|
||||||
|
<h1 style={{width: '100%', textAlign: 'center'}}>UI Upgrade Available</h1>
|
||||||
|
</div>
|
||||||
|
<table cellSpacing={5} width="100%">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td width="50%">
|
||||||
|
<Button buttonStyles={{width: '100%'}}
|
||||||
|
clicked={props.upgrade}>Install</Button>
|
||||||
|
</td>
|
||||||
|
<td width="50%">
|
||||||
|
<Button buttonStyles={{width: '100%'}}
|
||||||
|
clicked={props.cancel}>Cancel</Button>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</Box>);
|
||||||
|
}, styles, {allowMultiple: true});
|
||||||
7
src/constants.js
Normal file
7
src/constants.js
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
export const RELEASES_URL = 'https://bitbucket.org/blockstorage/repertory/raw/master/releases.json';
|
||||||
|
export const DATA_LOCATIONS = {
|
||||||
|
linux: '~/.local/repertory/ui',
|
||||||
|
darwin: '~/Library/Application Support/repertory/ui',
|
||||||
|
win32: '%LOCALAPPDATA%\\repertory\\ui',
|
||||||
|
};
|
||||||
|
export const UI_RELEASES_URL = 'https://bitbucket.org/blockstorage/repertory-ui/raw/master/releases.json';
|
||||||
4
src/containers/MountItems/MountItems.css
Normal file
4
src/containers/MountItems/MountItems.css
Normal file
@@ -0,0 +1,4 @@
|
|||||||
|
.MountItems {
|
||||||
|
margin-top: 10px;
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
184
src/containers/MountItems/MountItems.js
Normal file
184
src/containers/MountItems/MountItems.js
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import {Component} from 'react';
|
||||||
|
import CSSModules from 'react-css-modules';
|
||||||
|
import styles from './MountItems.css';
|
||||||
|
import MountItem from '../../components/MountItem/MountItem';
|
||||||
|
|
||||||
|
let ipcRenderer = null;
|
||||||
|
if (!process.versions.hasOwnProperty('electron')) {
|
||||||
|
ipcRenderer = ((window && window.require) ? window.require('electron').ipcRenderer : null);
|
||||||
|
}
|
||||||
|
|
||||||
|
class MountItems extends Component {
|
||||||
|
constructor(props) {
|
||||||
|
super(props);
|
||||||
|
if (ipcRenderer) {
|
||||||
|
ipcRenderer.on('detect_mounts_reply', (event, arg) => {
|
||||||
|
if (arg.data.Success) {
|
||||||
|
const sia = {
|
||||||
|
...this.state.Sia,
|
||||||
|
AllowMount: true,
|
||||||
|
DriveLetters: (arg.data.DriveLetters.Sia),
|
||||||
|
Mounted: (arg.data.Locations.Sia.length > 0),
|
||||||
|
PID: arg.data.PIDS.Sia,
|
||||||
|
};
|
||||||
|
const hs = {
|
||||||
|
...this.state.Hyperspace,
|
||||||
|
AllowMount: true,
|
||||||
|
DriveLetters: (arg.data.DriveLetters.Hyperspace),
|
||||||
|
Mounted: (arg.data.Locations.Hyperspace.length > 0),
|
||||||
|
PID: arg.data.PIDS.Hyperspace,
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setState({
|
||||||
|
Hyperspace: hs,
|
||||||
|
Sia: sia,
|
||||||
|
});
|
||||||
|
|
||||||
|
let hsLocation = arg.data.Locations.Hyperspace;
|
||||||
|
if ((hsLocation.length === 0) && (this.props.platform === 'win32')) {
|
||||||
|
hsLocation = this.props.hyperspace.MountLocation || arg.data.DriveLetters.Hyperspace[0];
|
||||||
|
}
|
||||||
|
if (hsLocation !== this.props.hyperspace.MountLocation) {
|
||||||
|
this.props.changed('Hyperspace', hsLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
let siaLocation = arg.data.Locations.Sia;
|
||||||
|
if ((siaLocation.length === 0) && (this.props.platform === 'win32')) {
|
||||||
|
siaLocation = this.props.sia.MountLocation || arg.data.DriveLetters.Sia[0];
|
||||||
|
}
|
||||||
|
if (siaLocation !== this.props.sia.MountLocation) {
|
||||||
|
this.props.changed('Sia', siaLocation);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.performAutoMount();
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('mount_drive_reply', (event, arg) => {
|
||||||
|
const state = {
|
||||||
|
...this.state[arg.data.StorageType],
|
||||||
|
PID: arg.data.PID,
|
||||||
|
Mounted: arg.data.Success,
|
||||||
|
};
|
||||||
|
this.setState({
|
||||||
|
[arg.data.StorageType]: state,
|
||||||
|
});
|
||||||
|
|
||||||
|
this.detectMounts();
|
||||||
|
});
|
||||||
|
|
||||||
|
ipcRenderer.on('unmount_drive_reply', (event, arg) => {
|
||||||
|
this.detectMounts();
|
||||||
|
});
|
||||||
|
|
||||||
|
this.detectMounts();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
state = {
|
||||||
|
Hyperspace: {
|
||||||
|
AllowMount: false,
|
||||||
|
DriveLetters: [],
|
||||||
|
Mounted: false,
|
||||||
|
PID: -1,
|
||||||
|
},
|
||||||
|
Sia: {
|
||||||
|
AllowMount: false,
|
||||||
|
DriveLetters: [],
|
||||||
|
Mounted: false,
|
||||||
|
PID: -1,
|
||||||
|
},
|
||||||
|
};
|
||||||
|
|
||||||
|
detectMounts = ()=> {
|
||||||
|
ipcRenderer.send('detect_mounts', {
|
||||||
|
Directory: this.props.directory,
|
||||||
|
Version: this.props.version,
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
|
handleMountLocationChanged = (systemType, value) => {
|
||||||
|
if (this.props.platform === 'win32') {
|
||||||
|
this.props.changed(systemType, this.state[systemType].DriveLetters[value]);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
this.props.changed(systemType, value);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
handleMountUnMount = (storageType, mount, location, pid) => {
|
||||||
|
if (ipcRenderer) {
|
||||||
|
const state = {
|
||||||
|
...this.state[storageType],
|
||||||
|
AllowMount: false,
|
||||||
|
};
|
||||||
|
this.setState({
|
||||||
|
[storageType]: state,
|
||||||
|
});
|
||||||
|
|
||||||
|
if (mount) {
|
||||||
|
ipcRenderer.send('mount_drive', {
|
||||||
|
Directory: this.props.directory,
|
||||||
|
Location: location,
|
||||||
|
StorageType: storageType,
|
||||||
|
Version: this.props.version,
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ipcRenderer.send('unmount_drive', {
|
||||||
|
Directory: this.props.directory,
|
||||||
|
Location: location,
|
||||||
|
PID: pid,
|
||||||
|
StorageType: storageType,
|
||||||
|
Version: this.props.version,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
performAutoMount = ()=> {
|
||||||
|
if (this.props.processAutoMount) {
|
||||||
|
this.props.autoMountProcessed();
|
||||||
|
if (this.props.hyperspace.AutoMount &&
|
||||||
|
!this.state.Hyperspace.Mounted &&
|
||||||
|
(this.props.hyperspace.MountLocation.length > 0)) {
|
||||||
|
this.handleMountUnMount('Hyperspace', true, this.props.hyperspace.MountLocation);
|
||||||
|
}
|
||||||
|
if (this.props.sia.AutoMount &&
|
||||||
|
!this.state.Sia.Mounted &&
|
||||||
|
(this.props.sia.MountLocation.length > 0)) {
|
||||||
|
this.handleMountUnMount('Sia', true, this.props.sia.MountLocation);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
render() {
|
||||||
|
return (
|
||||||
|
<div styleName='MountItems'>
|
||||||
|
<MountItem allowMount={this.state.Hyperspace.AllowMount}
|
||||||
|
autoMount={this.props.hyperspace.AutoMount}
|
||||||
|
autoMountChanged={(e)=>this.props.autoMountChanged('Hyperspace', e)}
|
||||||
|
mounted={this.state.Hyperspace.Mounted}
|
||||||
|
items={this.state.Hyperspace.DriveLetters}
|
||||||
|
platform={this.props.platform}
|
||||||
|
title={'Hyperspace'}
|
||||||
|
location={this.props.hyperspace.MountLocation}
|
||||||
|
changed={(e) => this.handleMountLocationChanged('Hyperspace', e.target.value)}
|
||||||
|
clicked={this.handleMountUnMount}
|
||||||
|
pid={this.state.Hyperspace.PID}/>
|
||||||
|
<MountItem allowMount={this.state.Sia.AllowMount}
|
||||||
|
autoMount={this.props.sia.AutoMount}
|
||||||
|
autoMountChanged={(e)=>this.props.autoMountChanged('Sia', e)}
|
||||||
|
mounted={this.state.Sia.Mounted}
|
||||||
|
items={this.state.Sia.DriveLetters}
|
||||||
|
platform={this.props.platform}
|
||||||
|
title={'Sia'}
|
||||||
|
location={this.props.sia.MountLocation}
|
||||||
|
changed={(e) => this.handleMountLocationChanged('Sia', e.target.value)}
|
||||||
|
clicked={this.handleMountUnMount}
|
||||||
|
pid={this.state.Sia.PID}/>
|
||||||
|
</div>);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default CSSModules(MountItems, styles, {allowMultiple: true});
|
||||||
63
src/index.css
Normal file
63
src/index.css
Normal file
@@ -0,0 +1,63 @@
|
|||||||
|
:root {
|
||||||
|
--border_radius: 4px;
|
||||||
|
|
||||||
|
--control_background: rgba(150, 150, 190, .15);
|
||||||
|
--control_background_hover: rgba(150, 150, 190, .3);
|
||||||
|
--control_border: 1px solid rgba(70, 70, 70, 0.9);
|
||||||
|
--control_box_shadow: 1px 1px 1px black;
|
||||||
|
--control_transparent_background: rgba(60, 60, 70, 0.4);
|
||||||
|
--control_dark_transparent_background: rgba(60, 60, 70, 0.4);
|
||||||
|
|
||||||
|
--text_color: rgba(200, 205, 220, 0.7);
|
||||||
|
--text_color_hover: rgba(200, 205, 220, 0.7);
|
||||||
|
--heading_text_color: rgba(194, 217, 255, 0.6);
|
||||||
|
--heading_other_text_color: rgba(200, 205, 220, 0.7);
|
||||||
|
--text_color_transition: color 0.3s;
|
||||||
|
}
|
||||||
|
|
||||||
|
* {
|
||||||
|
font-family: 'Nunito', sans-serif;
|
||||||
|
font-size: 15px;
|
||||||
|
}
|
||||||
|
|
||||||
|
*::-moz-focus-inner {
|
||||||
|
border: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
a {
|
||||||
|
outline: 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
html, body {
|
||||||
|
height: 100%;
|
||||||
|
width: 100%;
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
color: var(--text_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
p {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
color: var(--text_color);
|
||||||
|
font-size: medium;
|
||||||
|
font-weight: bold;
|
||||||
|
text-align: center;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1, h2, h3 {
|
||||||
|
padding: 0;
|
||||||
|
margin: 0;
|
||||||
|
font-weight: bold;
|
||||||
|
text-decoration: none;
|
||||||
|
white-space: pre;
|
||||||
|
text-align: left;
|
||||||
|
}
|
||||||
|
|
||||||
|
h1 {
|
||||||
|
color: var(--heading_text_color);
|
||||||
|
}
|
||||||
|
|
||||||
|
h2, h3 {
|
||||||
|
color: var(--heading_other_text_color);
|
||||||
|
}
|
||||||
10
src/index.js
Normal file
10
src/index.js
Normal file
@@ -0,0 +1,10 @@
|
|||||||
|
import React from 'react';
|
||||||
|
import ReactDOM from 'react-dom';
|
||||||
|
import './index.css';
|
||||||
|
|
||||||
|
import App from './App';
|
||||||
|
import registerServiceWorker from './registerServiceWorker';
|
||||||
|
import packageJson from '../package.json';
|
||||||
|
|
||||||
|
ReactDOM.render(<App version={packageJson.version}/>, document.getElementById('root'));
|
||||||
|
registerServiceWorker();
|
||||||
117
src/registerServiceWorker.js
Normal file
117
src/registerServiceWorker.js
Normal file
@@ -0,0 +1,117 @@
|
|||||||
|
// In production, we register a service worker to serve assets from local cache.
|
||||||
|
|
||||||
|
// This lets the app load faster on subsequent visits in production, and gives
|
||||||
|
// it offline capabilities. However, it also means that developers (and users)
|
||||||
|
// will only see deployed updates on the "N+1" visit to a page, since previously
|
||||||
|
// cached resources are updated in the background.
|
||||||
|
|
||||||
|
// To learn more about the benefits of this model, read https://goo.gl/KwvDNy.
|
||||||
|
// This link also includes instructions on opting out of this behavior.
|
||||||
|
|
||||||
|
const isLocalhost = Boolean(
|
||||||
|
window.location.hostname === 'localhost' ||
|
||||||
|
// [::1] is the IPv6 localhost address.
|
||||||
|
window.location.hostname === '[::1]' ||
|
||||||
|
// 127.0.0.1/8 is considered localhost for IPv4.
|
||||||
|
window.location.hostname.match(
|
||||||
|
/^127(?:\.(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}$/
|
||||||
|
)
|
||||||
|
);
|
||||||
|
|
||||||
|
export default function register() {
|
||||||
|
if (process.env.NODE_ENV === 'production' && 'serviceWorker' in navigator) {
|
||||||
|
// The URL constructor is available in all browsers that support SW.
|
||||||
|
const publicUrl = new URL(process.env.PUBLIC_URL, window.location);
|
||||||
|
if (publicUrl.origin !== window.location.origin) {
|
||||||
|
// Our service worker won't work if PUBLIC_URL is on a different origin
|
||||||
|
// from what our page is served on. This might happen if a CDN is used to
|
||||||
|
// serve assets; see https://github.com/facebookincubator/create-react-app/issues/2374
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
const swUrl = `${process.env.PUBLIC_URL}/service-worker.js`;
|
||||||
|
|
||||||
|
if (isLocalhost) {
|
||||||
|
// This is running on localhost. Lets check if a service worker still exists or not.
|
||||||
|
checkValidServiceWorker(swUrl);
|
||||||
|
|
||||||
|
// Add some additional logging to localhost, pointing developers to the
|
||||||
|
// service worker/PWA documentation.
|
||||||
|
navigator.serviceWorker.ready.then(() => {
|
||||||
|
console.log(
|
||||||
|
'This web app is being served cache-first by a service ' +
|
||||||
|
'worker. To learn more, visit https://goo.gl/SC7cgQ'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Is not local host. Just register service worker
|
||||||
|
registerValidSW(swUrl);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function registerValidSW(swUrl) {
|
||||||
|
navigator.serviceWorker
|
||||||
|
.register(swUrl)
|
||||||
|
.then(registration => {
|
||||||
|
registration.onupdatefound = () => {
|
||||||
|
const installingWorker = registration.installing;
|
||||||
|
installingWorker.onstatechange = () => {
|
||||||
|
if (installingWorker.state === 'installed') {
|
||||||
|
if (navigator.serviceWorker.controller) {
|
||||||
|
// At this point, the old content will have been purged and
|
||||||
|
// the fresh content will have been added to the cache.
|
||||||
|
// It's the perfect time to display a "New content is
|
||||||
|
// available; please refresh." message in your web app.
|
||||||
|
console.log('New content is available; please refresh.');
|
||||||
|
} else {
|
||||||
|
// At this point, everything has been precached.
|
||||||
|
// It's the perfect time to display a
|
||||||
|
// "Content is cached for offline use." message.
|
||||||
|
console.log('Content is cached for offline use.');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
};
|
||||||
|
})
|
||||||
|
.catch(error => {
|
||||||
|
console.error('Error during service worker registration:', error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
function checkValidServiceWorker(swUrl) {
|
||||||
|
// Check if the service worker can be found. If it can't reload the page.
|
||||||
|
fetch(swUrl)
|
||||||
|
.then(response => {
|
||||||
|
// Ensure service worker exists, and that we really are getting a JS file.
|
||||||
|
if (
|
||||||
|
response.status === 404 ||
|
||||||
|
response.headers.get('content-type').indexOf('javascript') === -1
|
||||||
|
) {
|
||||||
|
// No service worker found. Probably a different app. Reload the page.
|
||||||
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
|
registration.unregister().then(() => {
|
||||||
|
window.location.reload();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
// Service worker found. Proceed as normal.
|
||||||
|
registerValidSW(swUrl);
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.catch(() => {
|
||||||
|
console.log(
|
||||||
|
'No internet connection found. App is running in offline mode.'
|
||||||
|
);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
export function unregister() {
|
||||||
|
if ('serviceWorker' in navigator) {
|
||||||
|
navigator.serviceWorker.ready.then(registration => {
|
||||||
|
registration.unregister();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user