Compare commits

..

22 Commits

Author SHA1 Message Date
Timothy Warren
770fb57ab0 WIP progress commit 2020-04-10 11:30:26 -04:00
Timothy Warren
63e07cd42f Make production build work, for the most part 2019-01-14 16:25:40 -05:00
Timothy Warren
e6c3b5f9ea Update some forms 2019-01-14 14:37:26 -05:00
Timothy Warren
a1f46f9904 Update dependencies 2019-01-11 16:32:52 -05:00
Timothy Warren
fb17d1b3f9 Ugly progress commit 2018-06-06 17:01:39 -04:00
Timothy Warren
9f750721c2 Get the prod build working! 2018-06-06 09:57:40 -04:00
Timothy Warren
bc13bb6205 Icons?! 2018-06-01 16:57:36 -04:00
Timothy Warren
9a7eccb55e Parcel was convenient, but rollup is more versatile, without the esotaric webpack configuration 2018-06-01 16:01:29 -04:00
Timothy Warren
747c7ee810 minor cleanup 2018-05-31 12:40:08 -04:00
Timothy Warren
91b5ca72e3 Use context to pass down instance of WSCache 2018-05-31 12:37:57 -04:00
Timothy Warren
c5bb82f31e Remove remnants of redux 2018-05-30 10:02:55 -04:00
Timothy Warren
25230a35f7 Use a custom pub-sub system to handle receiving web socket responses 2018-05-30 09:34:33 -04:00
Timothy Warren
ab0161e0fa Add sqlite as a binary dependency 2018-05-15 16:15:18 -04:00
Timothy Warren
230ac51e90 Add reference fields from AnalogExif, update dependencies 2018-05-15 15:34:58 -04:00
Timothy Warren
74479b2050 Update dependencies 2018-05-09 09:19:48 -04:00
Timothy Warren
b1b15b1d46 Fix module resolution for eslint 2018-05-09 09:06:37 -04:00
Timothy Warren
b538bb3971 Just a few tool tweaks 2018-05-07 16:33:32 -04:00
Timothy Warren
cfc88ef5fc Use module aliases 2018-05-03 15:23:48 -04:00
Timothy Warren
224c3fac19 Use parcel over webpack 2018-05-03 14:44:48 -04:00
Timothy Warren
a1eaf1fba6 Add Error Modal 2018-05-01 16:58:24 -04:00
Timothy Warren
da94a5ac68 Remove autoprefixer 2018-05-01 16:20:49 -04:00
Timothy Warren
c2426baa1a Ugly progress commit 2018-05-01 09:53:09 -04:00
70 changed files with 4804 additions and 9180 deletions

23
.babelrc Normal file
View File

@ -0,0 +1,23 @@
{
"presets": [
"inferno-app",
["@babel/env", {
"targets": {
"browsers": [
">1%",
"not ie 11",
"not op_mini all"
]
},
"modules": false
}]
],
"plugins": [
["module-resolver", {
"root": ["./src"],
"alias": {
"//": "./"
}
}]
]
}

View File

@ -11,6 +11,10 @@ indent_size = 2
indent_style = tab indent_style = tab
insert_final_newline = true insert_final_newline = true
[package.json]
indent_size = 2
indent_style = space
# If i ever MUST use a yaml file # If i ever MUST use a yaml file
[*.yml, *.yaml] [*.yml, *.yaml]
indent_size = 2 indent_size = 2

2
.env
View File

@ -1,2 +0,0 @@
BROWSER=none
NODE_PATH=./src/

View File

@ -27,9 +27,6 @@
"properties": "never" "properties": "never"
}], }],
"comma-dangle": ["error", "always-multiline"], "comma-dangle": ["error", "always-multiline"],
"import/extensions": "off",
"import/no-extraneous-dependencies": "off",
"import/no-unresolved": [2, { "ignore": ["electron"] }],
"jsx-quotes": ["error", "prefer-double"], "jsx-quotes": ["error", "prefer-double"],
"linebreak-style": "off", "linebreak-style": "off",
"multiline-ternary": ["error", "always-multiline"], "multiline-ternary": ["error", "always-multiline"],
@ -54,9 +51,6 @@
"no-return-assign": "error", "no-return-assign": "error",
"no-return-await": "error", "no-return-await": "error",
"no-self-compare": "error", "no-self-compare": "error",
"no-shadow": ["error", {
"builtinGlobals": true
}],
"no-unneeded-ternary": "error", "no-unneeded-ternary": "error",
"no-unused-expressions": "error", "no-unused-expressions": "error",
"no-use-before-define": "error", "no-use-before-define": "error",

5
.gitignore vendored
View File

@ -1,6 +1,8 @@
.fusebox/
# Created by https://www.gitignore.io/api/osx,vim,code,node,linux,emacs,windows,jetbrains+all # Created by https://www.gitignore.io/api/osx,vim,code,node,linux,emacs,windows,jetbrains+all
.cache/
### Code ### ### Code ###
# Visual Studio Code - https://code.visualstudio.com/ # Visual Studio Code - https://code.visualstudio.com/
.settings/ .settings/
@ -268,5 +270,6 @@ $RECYCLE.BIN/
## Built files ## Built files
build/ build/
dist/ dist/
public/stats.html
# End of https://www.gitignore.io/api/osx,vim,code,node,linux,emacs,windows,jetbrains+all # End of https://www.gitignore.io/api/osx,vim,code,node,linux,emacs,windows,jetbrains+all

View File

@ -1,14 +1,29 @@
all: node_modules all: node_modules
build: node_modules
yarn dist
clean: clean:
rm -rf ./node_modules rm -rf ./.cache
rm -rf ./dist rm -rf ./dist
rm -rf ./build rm -rf ./build
node_modules: clean-all: clean
yarn --ignore-engines rm -rf ./node_modules
electron-start: node_modules
yarn electron-start
fix: node_modules fix: node_modules
yarn fix yarn fix
.PHONY: all clean fix inferno-start: node_modules
yarn inferno-start
lint: node_modules
yarn lint
node_modules:
yarn --ignore-engines
.PHONY: all clean electron-start fix lint react-start

View File

@ -1,2 +0,0 @@
react: yarn react-start
electron: yarn electron-start

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,28 @@
-----BEGIN PRIVATE KEY-----
MIIEvgIBADANBgkqhkiG9w0BAQEFAASCBKgwggSkAgEAAoIBAQC9S5RNcm4+LnZA
l0lGV5Lm8tbnbwHc5UaI2DXVKUP9AjiErY7X1tCq7fqeMsqLPwnYkaDltNq+a5tu
BfUHOCfK7tNICIkxZ8QDo1XMByaH3STx8GQ1XRXJr85ZhNxU4xnKUqpSRBFc7KO9
ZxtE+1UMZKoiZovmUc9DBQI2gY8fsric9rNOkGSW3N4xKOpeMvKlDrQwTJylJsyK
uRAaM6r2t4GuIc/BXj++Oj4r12mFAtAJPBGLs6CQWVb1qLhddgzgOxyysFhM9cQv
MbPnexYFLwfIyAXXJFrvJS0lz/HUCYKasqHXt+DD2G08p24Jy/QUX0oS/z/2cW/d
7BdMdAflAgMBAAECggEAGxHf12Nx2HqUdpAr7l8/pr87dEUvowM2nwMsT5tjGZ9j
rbWUI9GYbZkyqcThqiANrGbG95JxZaHFzGoVrD6fkimtFTQDSoloQoztDAxJukwp
qF+UNP1mzDzT6YFScOE5IvHHYZRSV1OP5toD0E2Q0ADlQ54ei4VPemoQ8vJ8ITAS
W7XuW0LvNkluS6DLrP/uJ779oPt97wv5x7jCPZVBQWQnkL3WmqX4WK251vPH4bfB
NWuZ1CPv7JEzrKK3VWe13VxVt2+RBmTMLEICXU217lLZOTmRggMTciBOvieq5zLf
9XRf2WOejU8OQY7ymhO49YD40Z4nSZmYbSqQi+7jAQKBgQD1DW1nlI/bBKeeiCaf
SDf0C6jta0/zw4WqkKb4L1OH80HaXDW+B8YOAqndGSl1iYTgp+z7CfJxdYr8o98z
178bJIofSzFDOgy/NZOatMA4fubq+YWNHWUFR3sRL6ehOBJLKTGVrFP0w0E3SFvG
72ntHFQDxR9ldPvCXImsaot6lQKBgQDFwHpFP2AS4S/FCirZL6rtyCFXUscmrnFc
4IsaCetsJYK9JdnzHlFrkakA53oV6/yZP/ZHWpc5zG9J4Uqqbsu5Uy1a1Ek0KO5p
k4HyUd4RiDojsOr81ZfZ8ByXeBzsOpCkljT3QJoCDDzc/6A3hNl5/Oh3SrvhuUSs
VlzoWxhUEQKBgQDN95c5NFklUWhBi1ZLErxU12gJBeWRkYlLr4FnoP+oiQGUs2RI
cOg65mo3d+qs7AVPflVlOxsX2iAT8Pit7mymN7QQUXb6dlQ4cqO5qKrX0XHtlgR2
c3pxUX9TFqbijupxWhJfJxT56RNrj9nz/08dCG5lLM4SzJy+5GCjFnpdcQKBgDYq
XZNgI5GoSqxe95Obweb1nWRM0S3gND7rZk6QjwKFV8U1e/hiwoyDTlZoEQG2LO9R
HMU4pBl5zLXg1tHOHVE63j51zUNTPtJ+S+ay0+/bb4ldKVBttPVGFp7KkKmH9RyP
5Bwhfs22ymkCP8FVSzhltMsQFlxiodPOqA4g/Y3xAoGBANlStShGqYVBDu+G1jkG
qmXM2eTtrh58RDRXm2ZUcJ+NbSZ1kGA94MdZaWZSSrQXzZzNWajVSE5XOV4dAbGY
LQgjCyRJQU4O+VVNfRb9E1q5P8qpECDqmqb1MHMmc7nI7hub2CLhABC+SYOI+Wn2
6q4mL0cBiCqnyUncK/mx+U47
-----END PRIVATE KEY-----

View File

@ -0,0 +1,26 @@
-----BEGIN CERTIFICATE-----
MIIEUjCCArqgAwIBAgIQfGscE02UTD1y2XRmQtXOejANBgkqhkiG9w0BAQsFADBz
MR4wHAYDVQQKExVta2NlcnQgZGV2ZWxvcG1lbnQgQ0ExJDAiBgNVBAsMG3R3YXJy
ZW5ATWFjQm9vay1Qcm8tMi5sb2NhbDErMCkGA1UEAwwibWtjZXJ0IHR3YXJyZW5A
TWFjQm9vay1Qcm8tMi5sb2NhbDAeFw0xOTAxMTYxOTMwNTFaFw0yOTAxMTYxOTMw
NTFaME8xJzAlBgNVBAoTHm1rY2VydCBkZXZlbG9wbWVudCBjZXJ0aWZpY2F0ZTEk
MCIGA1UECwwbdHdhcnJlbkBNYWNCb29rLVByby0yLmxvY2FsMIIBIjANBgkqhkiG
9w0BAQEFAAOCAQ8AMIIBCgKCAQEAvUuUTXJuPi52QJdJRleS5vLW528B3OVGiNg1
1SlD/QI4hK2O19bQqu36njLKiz8J2JGg5bTavmubbgX1Bzgnyu7TSAiJMWfEA6NV
zAcmh90k8fBkNV0Vya/OWYTcVOMZylKqUkQRXOyjvWcbRPtVDGSqImaL5lHPQwUC
NoGPH7K4nPazTpBkltzeMSjqXjLypQ60MEycpSbMirkQGjOq9reBriHPwV4/vjo+
K9dphQLQCTwRi7OgkFlW9ai4XXYM4DscsrBYTPXELzGz53sWBS8HyMgF1yRa7yUt
Jc/x1AmCmrKh17fgw9htPKduCcv0FF9KEv8/9nFv3ewXTHQH5QIDAQABo4GFMIGC
MA4GA1UdDwEB/wQEAwIFoDATBgNVHSUEDDAKBggrBgEFBQcDATAMBgNVHRMBAf8E
AjAAMB8GA1UdIwQYMBaAFFcbyc7AJktAZnOSeiE2YE03wcQHMCwGA1UdEQQlMCOC
CWxvY2FsaG9zdIcEfwAAAYcQAAAAAAAAAAAAAAAAAAAAATANBgkqhkiG9w0BAQsF
AAOCAYEAT1VQmT7WOpTJoEIFD8Mqw+JcpXKOnpc7TdvSpGu6HDKCYvKEwxsDDQEr
3JGXzzLAvexfod2W+dhBHqey/p9UqJidiLyzySHY4xIYqoBuEYW0puTO8k3kG8HD
j6zYeRkSw/9aRYa1NjjaA4UkMx/Qi74zYjGfiRNpb+RPv0aQI5009fFrD83jf1cG
dQeab8cYk5BTIH4HgRTg8azz3HECM+Hp+4i/oSx1GZ3gt4vaXM7MVVQJZtOn6eyf
ZqW6JfZOlXC4K4rTl8JX0wKWR7EPu/6CSorgLRndvc+1IfuDPn/OGU27d82a5a6S
qXEHTZ2k7Gkl8nfoFWKBmTcqESQAoINvVv3VnHiGltIjX5KfGfW/ypDStwYBhK+e
qoYB5ICKjPBUneIgKu+1MPDk1hjeIEZAXjBDxicznbqx8s7TcaWt3+fhLD1wAiXz
mJMguPnGoRREh+patpjCltXYD3YOQN5eMkGmKTzhiItex2KNqN13foZE5eHDbpMe
ly3G5TlQ
-----END CERTIFICATE-----

28
assets/certs/rootCA.pem Normal file
View File

@ -0,0 +1,28 @@
-----BEGIN CERTIFICATE-----
MIIEtTCCAx2gAwIBAgIQKfl+Gnl63rU7QNzHEtfwBTANBgkqhkiG9w0BAQsFADBz
MR4wHAYDVQQKExVta2NlcnQgZGV2ZWxvcG1lbnQgQ0ExJDAiBgNVBAsMG3R3YXJy
ZW5ATWFjQm9vay1Qcm8tMi5sb2NhbDErMCkGA1UEAwwibWtjZXJ0IHR3YXJyZW5A
TWFjQm9vay1Qcm8tMi5sb2NhbDAeFw0xOTAxMTYxOTMwMDBaFw0yOTAxMTYxOTMw
MDBaMHMxHjAcBgNVBAoTFW1rY2VydCBkZXZlbG9wbWVudCBDQTEkMCIGA1UECwwb
dHdhcnJlbkBNYWNCb29rLVByby0yLmxvY2FsMSswKQYDVQQDDCJta2NlcnQgdHdh
cnJlbkBNYWNCb29rLVByby0yLmxvY2FsMIIBojANBgkqhkiG9w0BAQEFAAOCAY8A
MIIBigKCAYEAqzewfMsejpRABJR9U1sk3O9LxoouBZMvtw4SOzNlUrJYTTNI6tJ2
ldq2Isyuxm0Jpj5zW9mlIzQWWQDPFJflPatCR3aL6HkvXwrl3QzJUVpgIdIe7ap2
rfGUUtu/GvA9zirVoCjtgg+Wixp2IpITwq5g2UhvU8gDjRpxQj/CyIgVmj4uIaMJ
uoCmjDQ88LtjW1mtsjuLwrcFwzj1VprcFQBfcFccAnawImvXtDyUpWAtI1EkqMkk
8ZupfWSl6Iz5gG7R5acssgo4k20hZ4RbPvk4JwFqxKSnKxkXQrXYdEsxX09jcc5A
lCgmZWAGKJDPUwhi0AFxqwJ6UP5TANb9AON+jM/NhE+pSIoEmuhAbMtrRTvnCM2Y
sSMT8K0ynDoj51UYJlRf6tgzChJ/Q9hQYHIzD6bRRVf+v+jSrHoC+NPozT/GbINt
R+ccMeWs9CDndM6vRinvrnUgyKtjE67Kzvy4oFtQoLTyF1ycOUFfMAagHMNlD7QO
i26r66QhfE7HAgMBAAGjRTBDMA4GA1UdDwEB/wQEAwICBDASBgNVHRMBAf8ECDAG
AQH/AgEAMB0GA1UdDgQWBBRXG8nOwCZLQGZzknohNmBNN8HEBzANBgkqhkiG9w0B
AQsFAAOCAYEAcUrZO2LhcLdVmziFaIMV0YmQumwko1H26xOxefp/Es6UCroqE64M
eMvV/xyX2fJn40Dhn/PBc0SvMYQQepC4FnkduvM92o0d+4rOLdTPIyzO7zG+XPqa
R7xwcUlDg+oNmkTdSDM+KjGN9y7lgGyRM/CS1f+70mqsNOopSuY7fUMKQmait3iU
HIPIsq7dvS5Bah5lCfz7zD86eWdoRuYgIzngA0R9ckz9rSLStB6ZsV2O9TrHlgPI
ZBrBqN4SoBe2w9p+WHJ/pSfZhZAK2JDAYIXS5VUQ16QPcNfYRJMzP9RDHZN/0FAo
zrWKswEM+UM68a3O+IVK4bSHSqyVYn3owbcsc8lDaMpix+d72MSzevHz2SQfrCZf
00xi4HuILrewsQKIlJZEpPkHL1VwPBOjytd/QsxqZ5P3NeVXxb50N9YGdfCVJPw1
9S8YNsX84Xa+vIbNYiccWQ+q6iaSVhry+qR0+L7hZRlTaO4cdLjNKtmAw+wRUGPl
lHHOrOEGYrH/
-----END CERTIFICATE-----

BIN
assets/icons/FilmExif.icns Normal file

Binary file not shown.

BIN
assets/icons/FilmExif.ico Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 295 KiB

28
assets/icons/FilmExif.svg Normal file
View File

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 16.0.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg version="1.1" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
width="512px" height="512px" viewBox="0 0 512 512" enable-background="new 0 0 512 512" xml:space="preserve">
<g>
<path d="M271.294,414H40.661c-0.117,1-0.661,1.386-0.661,2.298v13.43C40,440.854,49.497,450,60.622,450H112v5.245
c0,11.126,9.348,20.755,20.474,20.755h47.006c11.126,0,19.52-9.629,19.52-20.755V450h52.332c11.125,0,19.668-9.146,19.668-20.272
v-13.43C271,415.386,271.41,415,271.294,414z"/>
<path d="M251.332,62H199v-5.355C199,45.52,190.606,37,179.48,37h-47.006C121.348,37,112,45.52,112,56.645V62H60.622
C49.497,62,40,71.037,40,82.163v13.43C40,96.504,40.543,98,40.661,99h230.633c0.116-1-0.294-2.496-0.294-3.407v-13.43
C271,71.037,262.457,62,251.332,62z"/>
<rect x="54" y="111" width="145" height="294"/>
<g id="_x23_1e1e1cff">
<path d="M240.522,112.345c76.998-0.063,153.988-0.063,230.976,0c0.018,29.126,0,58.242,0.01,87.359
c-28.85,19.493-57.777,38.868-86.645,58.343c0.063,48.535,0.045,97.082,0.01,145.621c-48.123,0.025-96.246,0.072-144.36-0.02
C240.478,306.547,240.45,209.446,240.522,112.345 M269.424,141.506c-0.1,9.697,0.045,19.384-0.053,29.081
c9.609-0.072,19.221,0.083,28.83-0.045c0.127-9.696-0.027-19.393,0.045-29.09C288.637,141.552,279.035,141.407,269.424,141.506
M327.186,141.516c-0.127,9.697,0.025,19.393-0.047,29.089c9.611-0.1,19.211,0.045,28.822-0.055
c0.1-9.697-0.045-19.393,0.055-29.08C346.404,141.543,336.795,141.388,327.186,141.516 M384.881,141.461
c0.027,9.706,0.018,19.411,0,29.125c9.629,0.009,19.256-0.054,28.885,0.019c-0.072-9.715-0.01-19.429-0.018-29.135
C404.129,141.479,394.51,141.488,384.881,141.461 M269.434,345.461c-0.127,9.695,0.027,19.393-0.045,29.088
c9.602-0.1,19.211,0.047,28.822-0.053c0.1-9.697-0.045-19.393,0.053-29.082C288.654,345.488,279.043,345.334,269.434,345.461
M327.131,345.406c0.025,9.705,0.018,19.41,0,29.125c9.627,0.01,19.256-0.055,28.885,0.018c-0.072-9.715-0.01-19.428-0.02-29.143
C346.369,345.424,336.758,345.432,327.131,345.406z"/>
</g>
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View File

@ -1,92 +0,0 @@
'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-inferno-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-inferno-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);
// injected into the application via DefinePlugin in Webpack configuration.
const INFERNO_APP = /^INFERNO_APP_/i;
function getClientEnvironment(publicUrl) {
const raw = Object.keys(process.env)
.filter(key => INFERNO_APP.test(key))
.reduce(
(env, key) => {
env[key] = process.env[key];
return env;
},
{
// Useful for determining whether were running in production mode.
// Most importantly, it switches Inferno 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;

View File

@ -1,14 +0,0 @@
'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';
},
};

View File

@ -1,12 +0,0 @@
'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))};`;
},
};

View File

@ -1,55 +0,0 @@
'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/infernojs/create-inferno-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')),
};

View File

@ -1 +0,0 @@
'use strict';

View File

@ -1,261 +0,0 @@
'use strict';
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('inferno-dev-utils/InterpolateHtmlPlugin');
const WatchMissingNodeModulesPlugin = require('inferno-dev-utils/WatchMissingNodeModulesPlugin');
const eslintFormatter = require('inferno-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('inferno-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/infernojs/create-inferno-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 Inferno 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('inferno-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/infernojs/create-inferno-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/infernojs/create-inferno-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: {
// Use development build of inferno for better validations during development process
inferno: path.resolve(require.resolve('inferno/dist/index.dev.esm.js')),
},
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-inferno-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$/,
use: [
require.resolve('style-loader'),
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 11',
],
flexbox: 'no-2009',
}),
],
},
},
],
},
// "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/infernojs/create-inferno-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/infernojs/create-inferno-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$/),
],
// 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,
},
};

View File

@ -1,337 +0,0 @@
'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('inferno-dev-utils/InterpolateHtmlPlugin');
const SWPrecacheWebpackPlugin = require('sw-precache-webpack-plugin');
const eslintFormatter = require('inferno-dev-utils/eslintFormatter');
const ModuleScopePlugin = require('inferno-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 Inferno 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.');
}
// Note: defined here because it will be used more than once.
const cssFilename = 'static/css/[name].[contenthash:8].css';
// ExtractTextPlugin expects the build output to be flat.
// (See https://github.com/webpack-contrib/extract-text-webpack-plugin/issues/27)
// However, our output is structured with css, js and media folders.
// To have this structure working with relative paths, we have to use custom options.
const extractTextPluginOptions = shouldUseRelativeAssetPaths
? // Making sure that the publicPath goes back to to build folder.
{ publicPath: Array(cssFilename.split('/').length).join('../') }
: {};
// 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/infernojs/create-inferno-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/infernojs/create-inferno-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'],
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-inferno-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$/,
loader: ExtractTextPlugin.extract(
Object.assign(
{
fallback: {
loader: require.resolve('style-loader'),
options: {
hmr: false,
},
},
use: [
{
loader: require.resolve('css-loader'),
options: {
importLoaders: 1,
minimize: true,
sourceMap: shouldUseSourceMap,
},
},
{
loader: require.resolve('postcss-loader'),
options: {
// Necessary for external CSS imports to work
// https://github.com/facebookincubator/create-react-app/issues/2677
ident: 'postcss',
plugins: () => [
require('postcss-flexbugs-fixes'),
autoprefixer({
browsers: [
'>1%',
'last 4 versions',
'Firefox ESR',
'not ie < 11',
],
flexbox: 'no-2009',
}),
],
},
},
],
},
extractTextPluginOptions
)
),
// Note: this won't work without `new ExtractTextPlugin()` in `plugins`.
},
// "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 Inferno will be compiled in the very slow development mode.
new webpack.DefinePlugin(env.stringified),
// Minify the code.
new webpack.optimize.UglifyJsPlugin({
compress: {
screw_ie8: true, // Inferno doesn't support IE8
warnings: false,
// Disabled because of an issue with Uglify breaking seemingly valid code:
// https://github.com/facebookincubator/create-inferno-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: cssFilename,
}),
// 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-inferno-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',
},
};

View File

@ -1,95 +0,0 @@
'use strict';
const errorOverlayMiddleware = require('inferno-dev-utils/errorOverlayMiddleware');
const noopServiceWorkerMiddleware = require('inferno-dev-utils/noopServiceWorkerMiddleware');
const ignoredFiles = require('inferno-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-inferno-app/issues/2271
// https://github.com/facebookincubator/create-inferno-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 wont 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-inferno-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-inferno-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-inferno-app/issues/2272#issuecomment-302832432
app.use(noopServiceWorkerMiddleware());
},
};
};

55
fuse.js
View File

@ -1,55 +0,0 @@
// eslint-disable-no-shadow
const { FuseBox, WebIndexPlugin, SVGPlugin, QuantumPlugin } = require('fuse-box');
const { src, task, context } = require('fuse-box/sparky');
const infernoTransformer = require('ts-transform-inferno').default;
context(class {
getConfig () {
return FuseBox.init({
homeDir: 'src',
output: 'build/$name.js',
plugins: [
SVGPlugin(),
WebIndexPlugin({
template: 'public/index.html',
}),
this.isProduction && QuantumPlugin({
bakeApiIntoBundle: 'bundle',
uglify: true,
}),
],
sourceMaps: true,
target: 'electron',
transformers: {
before: [infernoTransformer()],
},
useJsNext: true,
useTypescriptCompiler: true,
});
}
createBundle (fuse) {
const app = fuse.bundle('bundle');
if (!this.isProduction) {
app.watch();
app.hmr();
}
app.instructions('> index.js');
return app;
}
});
task('clean', () => src('build').clean('build').exec());
task('default', ['clean'], async context => {
const fuse = context.getConfig();
fuse.dev();
context.createBundle(fuse);
await fuse.run();
});
task('dist', ['clean'], async context => {
context.isProduction = true;
const fuse = context.getConfig();
context.createBundle(fuse);
await fuse.run();
});

View File

@ -1,86 +1,101 @@
{ {
"name": "film-exif-electron", "name": "film-exif",
"version": "0.2.0", "author": "Timothy J. Warren",
"description": "A cross-platform app to edit exif tags",
"version": "0.5.0",
"private": true, "private": true,
"build": {
"appId": "net.timshomepage.film-exif",
"asar": true,
"copyright": "Copyright © year ${author}",
"files": [
"src/**/*",
"build/**/*",
"node_modules/**/*"
],
"directories": {
"buildResources": "assets"
},
"mac": {
"category": "public.app-category.photography",
"icon": "assets/icons/FilmExif.icns",
"identity": null
}
},
"dependencies": { "dependencies": {
"@stdlib/stdlib": "^0.0.36", "better-sqlite3": "^5.3.0",
"dotenv": "5.0.1",
"dotenv-expand": "4.2.0",
"electron-log": "^2.2.14", "electron-log": "^2.2.14",
"esm": "^3.0.20", "esm": "^3.0.40",
"exiftool-vendored": "^4.20.0", "exiftool-vendored": "^7.5.0",
"inferno": "^5.0.1", "inferno": "^7.0.5",
"inferno-bootstrap": "^5.0.0", "inferno-bootstrap": "^7.2.0",
"inferno-dev-utils": "^5.3.0", "inferno-dev-utils": "^6.0.4",
"inferno-redux": "^5.0.4", "inferno-router": "^7.0.5",
"inferno-router": "^5.0.1", "lodash-es": "^4.17.10",
"lodash": "^4.17.5", "ws": "^6.1.2"
"ramda": "^0.25.0",
"redux": "^4.0.0",
"ws": "^5.1.1"
}, },
"devDependencies": { "devDependencies": {
"autoprefixer": "^8.2.0", "@babel/core": "^7.0.0-beta.49",
"babel-core": "6.26.0", "@babel/preset-env": "^7.0.0-beta.49",
"babel-eslint": "^8.2.2", "babel-eslint": "^10.0.1",
"babel-jest": "^22.4.3", "babel-jest": "^23.0.1",
"babel-loader": "^7.1.4", "babel-plugin-external-helpers": "^6.22.0",
"babel-preset-inferno-app": "^7.1.0", "babel-plugin-module-resolver": "^3.1.1",
"babel-runtime": "6.26.0", "babel-preset-inferno-app": "^8.0.3",
"case-sensitive-paths-webpack-plugin": "^2.1.2", "babel-runtime": "^6.26.0",
"chalk": "^2.4.0", "bootstrap": "^4",
"css-loader": "^0.28.11", "electron": "^4.0.1",
"electron": "^1.8.4", "electron-builder": "^20.15.1",
"electron-builder": "^20.8.1", "electron-devtools-installer": "^2.2.4",
"eslint": "^4.19.1", "eslint": "^5.12.0",
"eslint-config-happiness": "^10.2.1", "eslint-config-happiness": "^10.2.1",
"eslint-config-inferno-app": "^6.2.0", "eslint-config-inferno-app": "^7.0.2",
"eslint-loader": "2.0.0", "eslint-plugin-import": "^2.14.0",
"eslint-plugin-flowtype": "^2.46.3",
"eslint-plugin-import": "^2.10.0",
"eslint-plugin-inferno": "^7.8.0", "eslint-plugin-inferno": "^7.8.0",
"eslint-plugin-jsx-a11y": "6.0.3", "eslint-plugin-jsx-a11y": "6.1.2",
"eslint-plugin-node": "^6.0.1", "eslint-plugin-node": "^8.0.1",
"eslint-plugin-promise": "^3.7.0", "eslint-plugin-promise": "^4.0.1",
"eslint-plugin-standard": "^3.0.1", "eslint-plugin-standard": "^4.0.0",
"extract-text-webpack-plugin": "3.0.2", "exiftool-vendored.pl": "^11.24.0",
"file-loader": "1.1.11", "husky": "^1.3.1",
"foreman": "^2.0.0", "inferno-devtools": "^7.0.5",
"fs-extra": "5.0.0", "jest": "^23.0.1",
"fuse-box": "^3.2.2", "jquery": "^3.3.1",
"html-webpack-plugin": "^3.2.0", "raf": "^3.4.0",
"husky": "^0.14.3", "rollup": "^1.1.0",
"jest": "^22.4.3", "rollup-plugin-alias": "^1.4.0",
"postcss-flexbugs-fixes": "3.3.0", "rollup-plugin-babel": "^4.3.0",
"postcss-loader": "^2.1.3", "rollup-plugin-commonjs": "^9.1.3",
"raf": "3.4.0", "rollup-plugin-copy": "^0.2.3",
"style-loader": "^0.21.0", "rollup-plugin-filesize": "^6.0.0",
"sw-precache-webpack-plugin": "^0.11.5", "rollup-plugin-livereload": "^0.6.0",
"ts-transform-inferno": "^2.1.0", "rollup-plugin-node-resolve": "^4.0.0",
"typescript": "^2.8.3", "rollup-plugin-replace": "^2.0.0",
"url-loader": "1.0.1", "rollup-plugin-serve": "^1.0.0",
"webpack": "^3", "rollup-plugin-terser": "^4.0.2",
"webpack-dev-server": "^2", "rollup-plugin-uglify": "^6.0.1",
"webpack-manifest-plugin": "1.3.2" "rollup-plugin-visualizer": "^0.9.2"
},
"homepage": "/",
"husky": {
"hooks": {
"pre-commit": "yarn lint"
}
}, },
"scripts": { "scripts": {
"build": "node scripts/build.js", "build": "set NODE_ENV=production && rollup --config rollup.prod.js",
"dist": "yarn run build && build", "predist": "yarn run build",
"electron-start": "node src/electron/wait-inferno", "dist": "build",
"electron-start": "set NODE_ENV=development && node src/electron/wait-inferno",
"electron": "electron .", "electron": "electron .",
"fix": "eslint --fix src/**/*.js", "fix": "eslint --fix src/**/*.js",
"fuse": "node fuse.js", "inferno-start": "set NODE_ENV=development && rollup --config rollup.dev.js --watch",
"lint": "eslint src/**/*.js", "lint": "eslint src/**/*.js",
"pack": "build --dir", "pack": "build --dir",
"postinstall": "electron-builder install-app-deps", "postinstall": "electron-builder install-app-deps",
"precommit": "yarn lint",
"react-start": "node scripts/start.js",
"start": "nf start -p 3000",
"test": "node scripts/test.js --env=jsdom" "test": "node scripts/test.js --env=jsdom"
}, },
"homepage": "./",
"main": "src/electron/index.js", "main": "src/electron/index.js",
"module": true,
"jest": { "jest": {
"collectCoverageFrom": [ "collectCoverageFrom": [
"src/**/*.{js,jsx,mjs}" "src/**/*.{js,jsx,mjs}"
@ -94,9 +109,7 @@
"testEnvironment": "node", "testEnvironment": "node",
"testURL": "http://localhost", "testURL": "http://localhost",
"transform": { "transform": {
"^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest", "^.+\\.(js|jsx)$": "<rootDir>/node_modules/babel-jest"
"^.+\\.css$": "<rootDir>/config/jest/cssTransform.js",
"^(?!.*\\.(js|jsx|css|json)$)": "<rootDir>/config/jest/fileTransform.js"
}, },
"transformIgnorePatterns": [ "transformIgnorePatterns": [
"[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$" "[/\\\\]node_modules[/\\\\].+\\.(js|jsx)$"
@ -109,14 +122,5 @@
"jsx", "jsx",
"node" "node"
] ]
},
"babel": {
"presets": [
"inferno-app"
]
},
"peerDependencies": {
"bootstrap": "4",
"jquery": "^3.3.1"
} }
} }

View File

@ -61,7 +61,7 @@ cssload-loader {
margin: auto; margin: auto;
} }
.cssload-inner { cssload-inner {
position: absolute; position: absolute;
width: 100%; width: 100%;
height: 100%; height: 100%;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 295 KiB

View File

@ -1,17 +0,0 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<link rel="shortcut icon" href="%PUBLIC_URL%/favicon.ico" />
<link rel="stylesheet" href="%PUBLIC_URL%/css/bootstrap.css" />
<link rel="stylesheet" href="%PUBLIC_URL%/css/app.css" />
<title>Inferno App</title>
</head>
<body>
<film-exif id="app"></film-exif>
<noscript>
You need to enable JavaScript to run this app.
</noscript>
</body>
</html>

15
public/index-prod.html Normal file
View File

@ -0,0 +1,15 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8"/>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"/>
<link rel="shortcut icon" href="./favicon.ico"/>
<link rel="stylesheet" href="./css/bootstrap.css"/>
<link rel="stylesheet" href="./css/app.css"/>
<title>Inferno App</title>
</head>
<body>
<film-exif id="app"></film-exif>
<script src="./bundle.js"></script>
</body>
</html>

View File

@ -1,8 +1,8 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no" />
<link rel="shortcut icon" href="/favicon.ico" /> <link rel="shortcut icon" href="/favicon.ico" />
<link rel="stylesheet" href="/css/bootstrap.css" /> <link rel="stylesheet" href="/css/bootstrap.css" />
<link rel="stylesheet" href="/css/app.css" /> <link rel="stylesheet" href="/css/app.css" />
@ -10,6 +10,7 @@
</head> </head>
<body> <body>
<film-exif id="app"></film-exif> <film-exif id="app"></film-exif>
<script src="/bundle.js"></script>
<noscript> <noscript>
You need to enable JavaScript to run this app. You need to enable JavaScript to run this app.
</noscript> </noscript>

30
rollup.config.js Normal file
View File

@ -0,0 +1,30 @@
import babel from 'rollup-plugin-babel';
import copy from 'rollup-plugin-copy';
import commonjs from 'rollup-plugin-commonjs';
import resolve from 'rollup-plugin-node-resolve';
export default {
input: './src/index.js',
output: {
file: './build/bundle.js',
format: 'iife',
sourcemap: true,
},
plugins: [
copy({
'public/index.html': 'build/index.html',
'public/favicon.ico': 'build/favicon.ico',
'public/css/bootstrap.css': 'build/css/bootstrap.css',
'public/css/app.css': 'build/css/app.css',
}),
resolve(),
commonjs({
include: 'node_modules/**',
exclude: 'src/**',
}),
babel({
exclude: 'node_modules/**',
runtimeHelpers: true,
}),
],
};

50
rollup.dev.js Normal file
View File

@ -0,0 +1,50 @@
import baseConfig from './rollup.config';
import alias from 'rollup-plugin-alias';
import filesize from 'rollup-plugin-filesize';
import fs from 'fs';
import livereload from 'rollup-plugin-livereload';
import replace from 'rollup-plugin-replace';
import serve from 'rollup-plugin-serve';
import visualizer from 'rollup-plugin-visualizer';
export default {
...baseConfig,
plugins: [
alias({
'inferno': `${__dirname}/node_modules/inferno/dist/index.dev.esm.js`,
}),
replace({
'process.env.NODE_ENV': "'development'",
}),
...baseConfig.plugins,
filesize(),
serve({
contentBase: ['build', 'public'],
headers: {
'Access-Control-Allow-Origin': '*',
'Content-Security-Policy': "default-src 'none'; script-src 'self' localhost:35729 localhost:65432; connect-src 'self' wss://localhost:35729 ws://localhost:65432; img-src 'self' data://*; style-src 'self';",
},
historyApiFallback: true,
host: 'localhost',
https: {
ca: fs.readFileSync('./assets/certs/rootCA.pem'),
cert: fs.readFileSync('./assets/certs/localhost+2.pem'),
key: fs.readFileSync('./assets/certs/localhost+2-key.pem'),
},
port: 3000,
}),
livereload({
https: {
ca: fs.readFileSync('./assets/certs/rootCA.pem'),
cert: fs.readFileSync('./assets/certs/localhost+2.pem'),
key: fs.readFileSync('./assets/certs/localhost+2-key.pem'),
},
watch: 'dist',
}),
visualizer({
filename: './public/stats.html',
title: 'Film EXIF modules',
}),
],
};

23
rollup.prod.js Normal file
View File

@ -0,0 +1,23 @@
import baseConfig from './rollup.config';
import filesize from 'rollup-plugin-filesize';
import replace from 'rollup-plugin-replace';
import { terser } from 'rollup-plugin-terser';
import copy from 'rollup-plugin-copy';
export default {
...baseConfig,
plugins: [
replace({
'process.env.NODE_ENV': "'production'",
}),
...baseConfig.plugins,
copy({
'public/index-prod.html': 'build/index.html',
'public/favicon.ico': 'build/favicon.ico',
'public/css/bootstrap.css': 'build/css/bootstrap.css',
'public/css/app.css': 'build/css/app.css',
}),
terser(),
filesize(),
],
};

View File

@ -1,150 +0,0 @@
'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('inferno-dev-utils/checkRequiredFiles');
const formatWebpackMessages = require('inferno-dev-utils/formatWebpackMessages');
const printHostingInstructions = require('inferno-dev-utils/printHostingInstructions');
const FileSizeReporter = require('inferno-dev-utils/FileSizeReporter');
const printBuildError = require('inferno-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,
});
}

View File

@ -1,107 +0,0 @@
'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('inferno-dev-utils/clearConsole');
const checkRequiredFiles = require('inferno-dev-utils/checkRequiredFiles');
const {
choosePort,
createCompiler,
prepareProxy,
prepareUrls,
} = require('inferno-dev-utils/WebpackDevServerUtils');
const openBrowser = require('inferno-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);
});

View File

@ -14,16 +14,7 @@ process.on('unhandledRejection', err => {
throw err; throw err;
}); });
// Ensure environment variables are read.
require('../config/env');
const jest = require('jest'); const jest = require('jest');
const argv = process.argv.slice(2); const 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); jest.run(argv);

View File

@ -1,58 +1,26 @@
import * as _ from 'lodash';
import { Component } from 'inferno'; import { Component } from 'inferno';
import { BrowserRouter, Link, NavLink } from 'inferno-router'; import { BrowserRouter, Link, NavLink } from 'inferno-router';
import { Loader } from './components';
import { import {
Container, Container,
Nav, Nav,
Navbar, Navbar,
NavbarBrand, NavbarBrand,
NavItem, NavItem,
} from './components/Bootstrap'; } from '//components/Bootstrap';
import { Routes } from './Routes'; import { Routes } from '//Routes';
import { createWsCache } from '//WSCache';
export class App extends Component { export class App extends Component {
constructor (props) { constructor (props, context) {
super(props); super(props, context);
this.state = { this.ws = createWsCache();
webSocketLoaded: false, }
getChildContext () {
return {
ws: this.ws,
}; };
_.bindAll(this, [
'onWebSocketOpen',
'onWebSocketClose',
]);
}
componentDidMount () {
window.clientWS = new WebSocket('ws://localhost:65432/');
window.clientWS.addEventListener('open', this.onWebSocketOpen);
window.clientWS.addEventListener('message', console);
window.clientWS.addEventListener('close', this.onWebSocketClose);
console.info(this.context);
}
componentWillUnmount () {
if (window.clientWS) {
window.clientWS.close();
}
}
onWebSocketOpen () {
this.setState({
webSocketLoaded: true,
});
window.clientWS.onmessage = message => {
console.info(JSON.parse(message.data));
};
}
onWebSocketClose () {
console.log('WebSocket closed');
} }
render () { render () {
@ -65,6 +33,9 @@ export class App extends Component {
<NavItem> <NavItem>
<NavLink className="nav-link" to="/camera/list">Cameras</NavLink> <NavLink className="nav-link" to="/camera/list">Cameras</NavLink>
</NavItem> </NavItem>
<NavItem>
<NavLink className="nav-link" to="/lenses/add">Lenses</NavLink>
</NavItem>
<NavItem> <NavItem>
<NavLink className="nav-link" to="/film/add">Films</NavLink> <NavLink className="nav-link" to="/film/add">Films</NavLink>
</NavItem> </NavItem>
@ -74,7 +45,6 @@ export class App extends Component {
</Nav> </Nav>
</Navbar> </Navbar>
<Routes/> <Routes/>
<Loader title="Connecting to WebSocket" hidden={this.state.webSocketLoaded} />
</Container> </Container>
</BrowserRouter> </BrowserRouter>
); );

View File

@ -1,12 +1,20 @@
import { Route, Switch } from 'inferno-router'; import { Redirect, Route, Switch } from 'inferno-router';
import * as V from './views'; import {
CameraAddView,
FilmAddView,
HomeView,
OopsView,
} from '//views';
import {LensesAddView} from './views/Lenses/LensesAddView';
export const Routes = (props) => ( export const Routes = () => (
<Switch> <Switch>
<Route exact path="/" component={V.HomeView} /> <Route exact path="/" render={() => <Redirect to="/home" />} />
<Route path="/camera" component={V.CameraAddView} /> <Route exact path="/home" component={HomeView} />
<Route path="/film" component={V.FilmAddView} /> <Route path="/camera" component={CameraAddView} />
<Route component={V.OopsView} /> <Route path="/film" component={FilmAddView} />
<Route path="/lenses" component={LensesAddView} />
<Route component={OopsView} />
</Switch> </Switch>
); );

152
src/WSCache.js Normal file
View File

@ -0,0 +1,152 @@
import bindAll from 'lodash-es/bindAll';
import { JSONMessage } from '//helpers/web-socket';
class WSCache {
constructor (ws) {
this.ws = ws;
// Websocket channels
// These hold previous messages if they are needed later
this.slots = {
'default': [],
};
// Send messages
this.sent = {
'default': [],
};
// Subscribers
this.listeners = {
'default': [console.info],
'server-log': [console.dir],
};
bindAll(this, [
'onWebSocketClose',
'onWebSocketMessage',
'publish',
'send',
'sendJSON',
'subscribe',
]);
this.ws.addEventListener('message', this.onWebSocketMessage);
this.ws.addEventListener('close', this.onWebSocketClose);
this.ws.addEventListener('error', console.error);
}
onWebSocketClose () {
this.ws = null;
console.info('WebSocket closed');
}
/**
* Callback for receiving a websocket message
*
* @param {mixed} message
*/
onWebSocketMessage (message) {
// `this` is overwritten to be the web socket object,
// so use the current instance object instead
try {
(() => {})();
const messageObject = JSON.parse(message.data);
WSCache.instance.publish(messageObject[0], messageObject[1]);
} catch (e) {
console.error('Error resolving web socket message', e);
// console.error(message);
WSCache.instance.publish('default', message.data);
}
}
/*
* Send a received websocket message to the appropriate listener(s)
*
* @param {string} slot
* @param {mixed} data
* @return {void}
*/
publish (slot, data) {
if (!this.listeners[slot] || data === undefined) {
return;
}
if (this.slots[slot] === undefined) {
this.slots[slot] = [];
}
this.slots[slot].push(data);
this.listeners[slot].forEach(listener => {
listener(data);
});
}
/**
* Send a message to the websocket server
*
* @param {mixed} message
*/
send (message) {
this.sent['default'].push(message);
return this.ws.send(message);
}
/**
* Send a JSON-encoded message to the websocket server
*
* @param {string} slot
* @param {mixed} data
*/
sendJSON (slot, data = {}) {
const sentSlots = Object.keys(this.sent);
if (!sentSlots.includes(slot)) {
this.sent[slot] = [];
}
this.sent[slot].push(data);
return this.ws.send(JSONMessage(slot, data));
}
/**
* Subscribe to a websocket message type
*
* Returns an object with a `unsubscribe` method
*
* @param {string} slot
* @param {function} cb
*/
subscribe (slot, cb) {
const slots = Object.keys(this.slots);
// Create the slots and listener arrays
if (!slots.includes(slot)) {
this.slots[slot] = [];
this.listeners[slot] = [];
}
this.listeners[slot].push(cb);
const listenerIndex = this.listeners[slot].length - 1;
return {
remove: () => {
delete this.listeners[slot][listenerIndex];
},
};
}
}
WSCache.instance = null;
export function createWsCache () {
if (WSCache.instance === null) {
const ws = new WebSocket('ws://localhost:65432/');
const instance = new WSCache(ws);
WSCache.instance = instance;
return instance;
}
return WSCache.instance;
}

View File

@ -1,5 +1,5 @@
import BSAlert from 'inferno-bootstrap/dist/Alert'; import BSAlert from 'inferno-bootstrap/dist/Alert';
import Badge from 'inferno-bootstrap/dist/Badge'; import BSBadge from 'inferno-bootstrap/dist/Badge';
import Breadcrumb from 'inferno-bootstrap/dist/Breadcrumb'; import Breadcrumb from 'inferno-bootstrap/dist/Breadcrumb';
import BreadcrumbItem from 'inferno-bootstrap/dist/BreadcrumbItem'; import BreadcrumbItem from 'inferno-bootstrap/dist/BreadcrumbItem';
import ButtonDropdown from 'inferno-bootstrap/dist/ButtonDropdown'; import ButtonDropdown from 'inferno-bootstrap/dist/ButtonDropdown';
@ -26,16 +26,18 @@ import Table from 'inferno-bootstrap/dist/Table';
import Tooltip from 'inferno-bootstrap/dist/Tooltip'; import Tooltip from 'inferno-bootstrap/dist/Tooltip';
export const BSWrapper = (Component, tagName) => { export const BSWrapper = (Component, tagName) => {
return ({children, ...props}) => ( return ({children, ...props}) => (Component.defaultProps.wrapTag !== undefined) ? (
<Component wrapTag={tagName} {...props}>{children}</Component>
) : (
<Component tag={tagName} {...props}>{children}</Component> <Component tag={tagName} {...props}>{children}</Component>
); );
}; };
export const Alert = BSWrapper(BSAlert, 'bs-alert'); export const Alert = BSWrapper(BSAlert, 'bs-alert');
export const Badge = BSWrapper(BSBadge, 'bs-badge');
export const Jumbotron = BSWrapper(BSJumbotron, 'bs-jumbotron'); export const Jumbotron = BSWrapper(BSJumbotron, 'bs-jumbotron');
export { export {
Badge,
Breadcrumb, Breadcrumb,
BreadcrumbItem, BreadcrumbItem,
ButtonDropdown, ButtonDropdown,

View File

@ -1,13 +1,11 @@
import AnimateModal from 'inferno-bootstrap/dist/Modal/AnimateModal'; import BSModal from 'inferno-bootstrap/dist/Modal/Modal';
import Modal from 'inferno-bootstrap/dist/Modal/Modal'; import BSModalBody from 'inferno-bootstrap/dist/Modal/ModalBody';
import ModalBody from 'inferno-bootstrap/dist/Modal/ModalBody'; import BSModalFooter from 'inferno-bootstrap/dist/Modal/ModalFooter';
import ModalFooter from 'inferno-bootstrap/dist/Modal/ModalFooter'; import BSModalHeader from 'inferno-bootstrap/dist/Modal/ModalHeader';
import ModalHeader from 'inferno-bootstrap/dist/Modal/ModalHeader';
export { import { BSWrapper } from './Bootstrap';
AnimateModal,
Modal, export const Modal = BSWrapper(BSModal, 'bs-modal');
ModalBody, export const ModalBody = BSWrapper(BSModalBody, 'bs-modal-body');
ModalFooter, export const ModalFooter = BSWrapper(BSModalFooter, 'bs-modal-footer');
ModalHeader, export const ModalHeader = BSWrapper(BSModalHeader, 'bs-modal-header');
};

View File

@ -1,7 +1,7 @@
export * from './Bootstrap'; export * from '//components/Bootstrap/Bootstrap';
export * from './Card'; export * from '//components/Bootstrap/Card';
export * from './Form'; export * from '//components/Bootstrap/Form';
export * from './Grid'; export * from '//components/Bootstrap/Grid';
export * from './List'; export * from '//components/Bootstrap/List';
export * from './Modal'; export * from '//components/Bootstrap/Modal';
export * from './Navigation'; export * from '//components/Bootstrap/Navigation';

89
src/components/DOMForm.js Normal file
View File

@ -0,0 +1,89 @@
import bindAll from 'lodash-es/bindAll';
import { Component, linkEvent } from 'inferno';
export class DOMForm extends Component {
constructor () {
super();
this.state = {
hasBeenValidated: false,
};
bindAll(this, [
'handleChange',
'handleSubmit',
]);
}
handleChange (props, event) {
const formElement = event.target.closest('form');
const rawFormData = new FormData(formElement);
if (props.onChange !== undefined) {
const modified = props.onChange(rawFormData);
if (modified !== undefined) {
// Update form
modified.forEach((value, key) => {
const element = formElement.elements[key];
element.value = value;
});
}
}
}
handleSubmit (props, event) {
// Don't want to actually reload the page!
event.preventDefault();
const form = event.target.closest('form');
this.setState({
hasBeenValidated: true,
});
// Parsers are formatters or maskers
const parsers = {};
const data = new FormData(form);
data.forEach((value, name) => {
const parserName = form.elements[name].dataset.parse;
if (parserName !== undefined && parsers[parserName] !== undefined) {
const parser = parsers[parserName];
const parsedValue = parser(data.get(name));
data.set(name, parsedValue);
}
});
// Don't attempt to submit an invalid form
if (!event.target.checkValidity()) {
return;
}
if (props.onSubmit) {
props.onSubmit(data);
}
}
render (props, state, context) {
const passProps = {...props};
const children = passProps.children;
delete passProps.onChange;
delete passProps.onSubmit;
const cssClass = state.hasBeenValidated ? 'was-validated' : 'needs-validation';
return (
<form
class={cssClass}
noValidate
onInput={linkEvent(props, this.handleChange)}
onSubmit={linkEvent(props, this.handleSubmit)}
{...passProps}
>
{children}
</form>
);
}
}

View File

@ -1,25 +1,51 @@
import { import {
Col, Col,
FormFeedback,
FormGroup, FormGroup,
FormText,
Input, Input,
InputGroup,
Label, Label,
} from '../Bootstrap'; } from '//components/Bootstrap';
export const FormBlock = ({ export const FormBlock = ({
children, children,
grouped = false,
helpText = null,
invalidText = null,
label, label,
type = 'text', type = 'text',
validText = null,
...props ...props
}) => { }) => {
const formElement = (children !== undefined) let formElement = (children !== undefined)
? children ? children
: <Input id={props.name} name={props.name} type={type} {...props} />; : <Input id={props.name} name={props.name} type={type} {...props} />;
if (grouped !== false) {
formElement = <InputGroup>{formElement}</InputGroup>
}
const helperText = (helpText !== null)
? <FormText>{helpText}</FormText>
: null;
let feedbackText = invalidText
if (feedbackText === null && props.required === true) {
feedbackText = 'This field is required.';
}
const feedback = (feedbackText !== null)
? <FormFeedback>{feedbackText}</FormFeedback>
: null;
return ( return (
<Col xs={12} md={6} xl={4} className="d-flex align-items-baseline justify-content-around"> <Col xs={12} md={6} xl={4} className="d-flex align-items-baseline">
<FormGroup> <FormGroup>
<Label for={props.name}>{label}</Label> <Label for={props.name}>{label}</Label>
{formElement} {formElement}
{helperText}
{feedback}
</FormGroup> </FormGroup>
</Col> </Col>
); );

View File

@ -1 +1 @@
export * from './FormBlock'; export * from '//components/Form/FormBlock';

View File

@ -22,3 +22,4 @@ export const Loader = (props) => {
</section> </section>
); );
}; };
Loader.displayName = 'Loader';

View File

@ -1,3 +1,4 @@
export * from './Bootstrap'; export * from '//components/Bootstrap';
export * from './Form'; export * from '//components/DOMForm';
export * from './Loader'; export * from '//components/Form';
export * from '//components/Loader';

View File

@ -1,14 +0,0 @@
/**
* Redux setup
*/
import { combineReducers, createStore } from 'redux';
import * as reducers from './reducers';
const configureStore = (defaultState = {}) => {
return createStore(combineReducers({
...reducers,
}), defaultState);
};
export default configureStore;

4
src/constants/build.js Normal file
View File

@ -0,0 +1,4 @@
const packageJson = require('../../package.json');
export const BUILD_ENV = process.env.NODE_ENV;
export const BUILD_VERSION = packageJson.version;

View File

@ -0,0 +1,52 @@
/**
* Exif field constants
*/
/*
* EXIF information from AnalogExif that doesn't fit under Cameras, Lenses, or Film
*
* ------------------
* Photo
* ------------------
* Aperture
* Exposure
* Exposure Bias
* Focal length
* Focal length @35mm equivalent
* Original Capture Time
* Digitized Time
* Location
* Altitude
* Exposure Number
* Image Source
* Filter(s) Used
* Roll Id
* Title
* Description
* Comments
* Keywords
* Scanner Manufacturer
* Scanner Model
* Scanner Software
* Exposure Program
* White Balance
* Light Source
* Metering Mode
*
* -------------------
* Developer
* -------------------
* Developer
* Process
* Developer maker
* Developer dilution
* Developing time
* Processing Laboratory
* Labratory Address
*
* --------------------
* Author
* --------------------
* Name
* Copyright
*/

View File

@ -1 +1 @@
export * from './redux-actions'; export * from './build';

View File

@ -1,2 +0,0 @@
export const OPEN_FILES = 'OPEN_FILES';
export const OPEN_FOLDER = 'OPEN_FOLDER';

View File

@ -1,11 +1,12 @@
import {app, BrowserWindow} from 'electron'; import {app, BrowserWindow} from 'electron';
import log from 'electron-log'; import log from 'electron-log';
import path from 'path'; import path from 'path';
import url from 'url';
log.transports.file.level = false; log.transports.file.level = false;
log.transports.console.level = 'info'; log.transports.console.level = 'info';
const DEV_MODE = process.env.NODE_ENV === 'development';
// Keep a global reference of the window object, if you don't, the window will // 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. // be closed automatically when the JavaScript object is garbage collected.
let mainWindow; let mainWindow;
@ -19,17 +20,18 @@ const createWindow = () => {
}, },
}); });
// 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);
// Open the DevTools. // Open the DevTools.
if (DEV_MODE) {
mainWindow.webContents.openDevTools({ mainWindow.webContents.openDevTools({
mode: 'bottom', mode: 'bottom',
}); });
}
// load the index.html of the app.
const startUrl = DEV_MODE
? 'https://localhost:3000'
: `file://${path.join(__dirname, '/../../build/index.html')}`;
mainWindow.loadURL(startUrl);
// Emitted when the window is closed. // Emitted when the window is closed.
mainWindow.on('closed', () => { mainWindow.on('closed', () => {

View File

@ -3,7 +3,7 @@ const log = require('electron-log');
const net = require('net'); const net = require('net');
const port = process.env.PORT ? (process.env.PORT - 100) : 3000; const port = process.env.PORT ? (process.env.PORT - 100) : 3000;
process.env.ELECTRON_START_URL = `http://localhost:${port}`; process.env.ELECTRON_START_URL = `https://localhost:${port}`;
log.transports.file.level = false; log.transports.file.level = false;
const client = new net.Socket(); const client = new net.Socket();

View File

@ -1 +1 @@
export * from './web-socket'; export * from '//helpers/web-socket';

View File

@ -1,11 +1,6 @@
const JSONMessage = (messageType, data) => { export const JSONMessage = (messageType, data) => {
// return new Blob([messageType, JSON.stringify(data)], {type: 'application/json'});
return JSON.stringify([ return JSON.stringify([
messageType, messageType,
data, data,
]); ]);
}; };
module.exports = {
JSONMessage,
};

View File

@ -1,13 +1,5 @@
import { render } from 'inferno'; import { render } from 'inferno';
import { Provider } from 'inferno-redux'; import 'inferno-devtools';
import { App } from '//App';
import configureStore from './configureStore'; render(<App />, document.getElementById('app'));
import { App } from './App';
const store = configureStore();
render((
<Provider store={store}>
<App />
</Provider>
), document.getElementById('app'));

View File

@ -1,2 +0,0 @@
export * from './receiveReducer';
export * from './sendReducer';

View File

@ -1,13 +0,0 @@
/**
* Reducer for received websocket messages
*
* @param {object} state
* @param {object} action
* @return {object} newState
*/
export const receiveReducer = (state = {}, action) => {
switch (action.type) {
default:
return state;
}
};

View File

@ -1,13 +0,0 @@
/**
* Reducer for websocket-based actions
*
* @param {object} state
* @param {object} action
* @return {object} newState
*/
export const sendReducer = (state = {}, action) => {
switch (action.type) {
default:
return state;
}
};

View File

@ -1,5 +1,3 @@
import { linkEvent, Component } from 'inferno';
import { import {
Button, Button,
Card, Card,
@ -8,41 +6,47 @@ import {
CardFooter, CardFooter,
CardTitle, CardTitle,
Col, Col,
Form,
Row, Row,
} from '../../components/Bootstrap'; } from '//components/Bootstrap';
import { DOMForm } from '//components';
import { FormBlock } from '../../components/Form'; import { FormBlock } from '//components/Form';
export class CameraAddView extends Component { /*
constructor (props) { * Fields from AnalogExif
super(props); *
* Manufacturer
* Model
* Serial Number
* Film Format
* Flash Manufacturer
* Flash Model
*/
this.state = { function logFormData (formData) {
form: { const data = {};
valid: {}, formData.forEach((value, key) => {
values: {}, data[key] = value;
},
};
}
handleFormChange (instance, e) {
instance.setState({
form: {
...instance.state.form,
values: {
...instance.state.form.values,
[e.target.id]: e.target.value,
},
},
}); });
console.log(data);
} }
render () { function handleFormChange (formData) {
// logFormData(formData);
}
function handleSave (formData) {
logFormData(formData);
}
export function CameraAddView (props) {
return ( return (
<Row className="full-height"> <Row className="full-height">
<Col sm={12} md={8} lg={4} className="abs-center"> <Col sm={12} md={8} lg={4} className="abs-center">
<Form onKeyDown={ linkEvent(this, this.handleFormChange) }> <DOMForm
onChange={handleFormChange}
onSubmit={handleSave}
>
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>Add a Camera</CardTitle> <CardTitle>Add a Camera</CardTitle>
@ -53,24 +57,42 @@ export class CameraAddView extends Component {
label="Brand" label="Brand"
name="brand" name="brand"
required required
value={this.state.form.values['brand']}
/> />
<FormBlock <FormBlock
label="Model" label="Model"
name="model" name="model"
required required
value={this.state.form.values['model']} />
<FormBlock
label="Lens Mount"
name="mount"
required
/>
<FormBlock
label="Serial"
name="serial"
required
/> />
<FormBlock <FormBlock
label="Film Format" label="Film Format"
name="film-format" name="film-format"
value={this.state.form.values['film-format']}
> >
<select className="custom-select" id="film-format" name="film-format"> <select
className="custom-select"
id="film-format"
name="film-format"
>
<option value="">&nbsp;</option>
<optgroup label="Miniature Format">
<option value="110">110</option> <option value="110">110</option>
<option value="135">35mm (135)</option>
</optgroup>
<optgroup label="Medium Format">
<option value="120">120</option> <option value="120">120</option>
<option value="127">127</option> <option value="127">127</option>
<option value="135">135</option> <option value="220">220</option>
<option value="620">620</option>
</optgroup>
</select> </select>
</FormBlock> </FormBlock>
</Row> </Row>
@ -83,9 +105,8 @@ export class CameraAddView extends Component {
</Row> </Row>
</CardFooter> </CardFooter>
</Card> </Card>
</Form> </DOMForm>
</Col> </Col>
</Row> </Row>
); );
} }
}

View File

@ -1,3 +1,5 @@
export const CameraListView = () => { export const CameraListView = () => {
return <div />; return (
<div />
);
}; };

View File

@ -1,2 +1,2 @@
export * from './CameraAddView'; export * from '//views/Camera/CameraAddView';
export * from './CameraListView'; export * from '//views/Camera/CameraListView';

View File

@ -1,5 +1,3 @@
import { linkEvent, Component } from 'inferno';
import { import {
Button, Button,
Card, Card,
@ -8,83 +6,115 @@ import {
CardFooter, CardFooter,
CardTitle, CardTitle,
Col, Col,
Form, FormGroup,
FormText,
Input,
InputGroup,
InputGroupAddon,
Label,
Row, Row,
} from '../../components/Bootstrap'; } from '//components/Bootstrap';
import { FormBlock } from '../../components/Form'; import {FormBlock} from '//components/Form';
import {DOMForm} from '//components';
export class FilmAddView extends Component { /*
constructor (props) { * Fields from AnalogExif
super(props); *
* Manufacturer
* Name
* Alias
* Grain
* ISO Rating
*/
this.state = { function logFormData (formData) {
form: { const data = {};
valid: {}, formData.forEach((value, key) => {
values: {}, data[key] = value;
},
};
}
handleFormChange (instance, e) {
instance.setState({
form: {
...instance.state.form,
values: {
...instance.state.form.values,
[e.target.id]: e.target.value,
},
},
}); });
console.log(data);
} }
render () { function handleFormChange (formData) {
// logFormData(formData);
}
function handleSave (formData) {
logFormData(formData);
}
export function FilmAddView () {
return ( return (
<Row className="full-height"> <Row class="full-height">
<Col sm={12} md={8} lg={4} className="abs-center"> <Col sm={12} class="abs-center">
<Form onKeyDown={ linkEvent(this, this.handleFormChange) }> <DOMForm onChange={handleFormChange} onSubmit={handleSave}>
<Card> <Card>
<CardHeader> <CardHeader>
<CardTitle>Add a Film</CardTitle> <CardTitle>Add a Film</CardTitle>
</CardHeader> </CardHeader>
<CardBody> <CardBody>
<Row className="align-items-baseline"> <Row class="form-row align-items-baseline">
<FormBlock <FormBlock
label="Brand" label="Manufacturer"
name="brand" name="brand"
required required
value={this.state.form.values['brand']}
/> />
<FormBlock <FormBlock
helpText="e.g. Ektar, Fujicolor, etc."
label="Film Name" label="Film Name"
name="film-name" name="film-name"
required required
value={this.state.form.values['film-name']}
/> />
<FormBlock <Col sm={12} md={6} lg={4}>
label="Film Speed (ISO)" <FormGroup>
<Label for="film-speed-asa">Film Speed (IS0)</Label>
<InputGroup>
<Input
max="6400" max="6400"
maxLength="4"
min="1"
name="film-speed-asa" name="film-speed-asa"
placeholder="100"
required required
type="number" type="number"
value={this.state.form.values['film-speed-asa']}
/> />
<FormBlock <InputGroupAddon addonType="append">/</InputGroupAddon>
label="Film Speed (DIN)" <Input
max="39"
maxLength="2"
min="1"
name="film-speed-din" name="film-speed-din"
placeholder="21"
required
size="2"
step="1"
type="number" type="number"
value={this.state.form.values['film-speed-din']}
/> />
<InputGroupAddon addonType="append">&deg;</InputGroupAddon>
</InputGroup>
<FormText>Film Sensitivity</FormText>
</FormGroup>
</Col>
<FormBlock <FormBlock
label="Film Format" label="Film Format"
name="film-format" name="film-format"
value={this.state.form.values['film-format']}
> >
<select className="custom-select" id="film-format" name="film-format"> <select
<option value="110">110</option> className="custom-select"
id="film-format"
name="film-format"
>
<optgroup label="Miniature Format">
<option value="110">110 (Pocket Instamatic)</option>
<option selected value="135">35mm (135)</option>
</optgroup>
<optgroup label="Medium Format">
<option value="120">120</option> <option value="120">120</option>
<option value="127">127</option> <option value="127">127</option>
<option value="135">135</option> <option value="220">220</option>
<option value="620">620</option>
</optgroup>
</select> </select>
</FormBlock> </FormBlock>
</Row> </Row>
@ -97,9 +127,8 @@ export class FilmAddView extends Component {
</Row> </Row>
</CardFooter> </CardFooter>
</Card> </Card>
</Form> </DOMForm>
</Col> </Col>
</Row> </Row>
); );
} }
}

View File

@ -1 +1 @@
export * from './FilmAddView'; export * from '//views/Film/FilmAddView';

View File

@ -1,13 +1,54 @@
import bindAll from 'lodash-es/bindAll';
import { Component } from 'inferno';
import { import {
Button, Button,
Col, Col,
Container, Container,
Jumbotron, Jumbotron,
Modal,
ModalBody,
ModalFooter,
ModalHeader,
Row, Row,
} from '../components/Bootstrap'; } from '//components/Bootstrap';
import { JSONMessage } from '../helpers/web-socket';
function handleDrop (e) { export class HomeView extends Component {
constructor (props) {
super(props);
this.state = {
exifData: [],
showModal: false,
};
bindAll(this, [
'bindEvents',
'handleDrop',
'showErrorDialog',
'showOpenDialog',
'showSaveDialog',
'toggleErrorModal',
]);
}
componentDidMount () {
this.bindEvents();
}
bindEvents () {
this.context.ws.subscribe('parsed-exif-tags', data => {
this.setState({
exifData: data,
});
});
}
handleDragOver (e) {
e.preventDefault();
e.stopPropagation();
}
handleDrop (e) {
e.preventDefault(); e.preventDefault();
e.stopPropagation(); e.stopPropagation();
@ -16,32 +57,37 @@ function handleDrop (e) {
draggedFiles.push(f.path); draggedFiles.push(f.path);
} }
window.clientWS.send(JSONMessage('dropped-files', draggedFiles)); const newTransfer = { ...e.dataTransfer };
console.info(newTransfer);
this.context.ws.sendJSON('dropped-files', draggedFiles);
} }
function handleDragOver (e) { showErrorDialog () {
e.preventDefault(); this.context.ws.sendJSON(
e.stopPropagation();
}
function showOpenDialog () {
window.clientWS.send(JSONMessage('show-open-dialog', {}));
}
function showSaveDialog () {
window.clientWS.send(JSONMessage('show-save-dialog', {}));
}
function showErrorDialog () {
window.clientWS.send(JSONMessage(
'show-error-box', 'show-error-box',
'Looks like there was a problem. (╥﹏╥) \n (╯°□°)╯︵ ┻━┻' 'Looks like there was a problem. (╥﹏╥) \n (╯°□°)╯︵ ┻━┻'
)); );
} }
export const HomeView = (props) => { showOpenDialog () {
this.context.ws.sendJSON('show-open-dialog');
}
showSaveDialog () {
this.context.ws.sendJSON('show-save-dialog');
}
toggleErrorModal () {
this.setState(prevState => ({
showModal: !prevState.showModal,
}));
}
render () {
return ( return (
<Jumbotron onDrop={handleDrop} onDragover={handleDragOver}> <main>
<Jumbotron onDrop={this.handleDrop} onDragover={this.handleDragOver}>
<Container className="App"> <Container className="App">
<Row> <Row>
<header className="App-header"> <header className="App-header">
@ -54,17 +100,39 @@ export const HomeView = (props) => {
</p> </p>
</Row> </Row>
<Row> <Row>
<Col md={4}> <Col md={3}>
<Button onClick={showOpenDialog}>Show Open Dialog</Button> <Button onClick={this.showOpenDialog}>Show Open Dialog</Button>
</Col> </Col>
<Col md={4}> <Col md={3}>
<Button onClick={showSaveDialog}>Show Save Dialog</Button> <Button onClick={this.showSaveDialog}>Show Save Dialog</Button>
</Col> </Col>
<Col md={4}> <Col md={3}>
<Button onClick={showErrorDialog}>Show Error Dialog</Button> <Button onClick={this.showErrorDialog}>Show Error Dialog</Button>
</Col>
<Col md={3}>
<Button onClick={this.toggleErrorModal}>Show Error Modal</Button>
</Col>
</Row>
<Row>
<Col md={12}>
<h3>Parsed Exif Data</h3>
<pre>{JSON.stringify(this.state.exifData, null, 2)}</pre>
</Col> </Col>
</Row> </Row>
</Container> </Container>
</Jumbotron> </Jumbotron>
<Modal fade isOpen={this.state.showModal} toggle={this.toggleErrorModal}>
<ModalHeader toggle={this.toggleErrorModal}>
Error Title
</ModalHeader>
<ModalBody>
Looks like there was a problem. ()<br />(°°
</ModalBody>
<ModalFooter>
<Button color="primary" onClick={this.toggleErrorModal}>Close</Button>
</ModalFooter>
</Modal>
</main>
); );
}; }
}

View File

@ -0,0 +1,90 @@
import {
Button,
Card,
CardBody,
CardHeader,
CardFooter,
CardTitle,
Col,
Row,
} from '//components/Bootstrap';
import {FormBlock} from '//components/Form';
import {DOMForm} from '//components';
/*
* Fields from AnalogExif
*
* Manufacturer
* Model
* Serial Number
* Maximum Aperture
*/
function logFormData (formData) {
const data = {};
formData.forEach((value, key) => {
data[key] = value;
});
console.log(data);
}
function handleFormChange (formData) {
// logFormData(formData);
}
function handleSave (formData) {
logFormData(formData);
}
export function LensesAddView () {
return (
<Row className="full-height">
<Col sm={12} md={8} lg={4} className="abs-center">
<DOMForm onChange={handleFormChange} onSubmit={handleSave}>
<Card>
<CardHeader>
<CardTitle>Add a Lens</CardTitle>
</CardHeader>
<CardBody>
<Row className="align-items-baseline">
<FormBlock
label="Brand"
name="brand"
required
/>
<FormBlock
label="Model"
name="model"
required
/>
<FormBlock
label="Lens Mount"
name="mount"
required
/>
<FormBlock
label="Serial"
name="serial"
required
/>
<FormBlock
label="Maximum Aperture"
name="max-aperture"
type="number"
required
/>
</Row>
</CardBody>
<CardFooter>
<Row>
<Col xs={12}>
<Button color="primary" type="submit">Save</Button>
</Col>
</Row>
</CardFooter>
</Card>
</DOMForm>
</Col>
</Row>
);
}

View File

@ -1 +1 @@
export * from './LensesListView'; export * from '//views/Lenses/LensesListView';

View File

@ -1,6 +1,6 @@
import { Alert, Row } from '../components/Bootstrap'; import { Alert, Row } from '//components/Bootstrap';
export const OopsView = (props) => ( export const OopsView = () => (
<Row className="align-items-center justify-content-center full-height"> <Row className="align-items-center justify-content-center full-height">
<Alert className="abs-center" color="danger" style={{padding: '5em'}} tag="main"> <Alert className="abs-center" color="danger" style={{padding: '5em'}} tag="main">
<h1>Oops!</h1> <h1>Oops!</h1>

View File

@ -1,4 +1,5 @@
export * from './Camera'; export * from '//views/Camera';
export * from './Film'; export * from '//views/Film';
export * from './HomeView'; export * from '//views/HomeView';
export * from './OopsView'; export * from '//views/Lenses';
export * from '//views/OopsView';

8673
yarn.lock

File diff suppressed because it is too large Load Diff