Commit 9b70fa87 authored by Matija Obreza's avatar Matija Obreza
Browse files

Merge branch '11-add-module-counter' into 'master'

Add module: counter

Closes #11

See merge request grin-global/grin-global-ui!10
parents 77e1a021 9fff44bd
......@@ -9,3 +9,4 @@ react-loadable.json
*.snap
packages/client/lib
packages/i18n/lib
packages/counter/lib
......@@ -19,6 +19,7 @@
"workspaces": [
"packages/i18n",
"packages/client",
"packages/counter",
"packages/ui-express"
],
"devDependencies": {
......
{
"presets": [
[
"env",
{
"modules": false,
"targets": {
"browsers": ["last 2 versions", "safari >= 7"]
}
}
],
"react"
],
"compact": false,
"retainLines": true,
"minified": false,
"inputSourceMap": false,
"sourceMaps": false,
"plugins": [
"transform-object-rest-spread",
"babel-plugin-syntax-dynamic-import",
]
}
<!DOCTYPE html>
<html>
<head>
<title>Hi!</title>
<base href="/" />
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, minimum-scale=1, initial-scale=1, user-scalable=yes" />
<meta name="author" content="Genesys Team, helpdesk@genesys-pgr.org" />
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="http://browsehappy.com/">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="the-app"></div>
</body>
</html>
<?xml version="1.0" encoding="utf-8"?>
<!-- Generator: Adobe Illustrator 22.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
<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"
viewBox="0 0 24 24" enable-background="new 0 0 24 24" xml:space="preserve">
<circle fill="#2B2924" cx="12" cy="12" r="12"/>
<path fill="#FFFFFF" d="M17,7H7C6.3,7,5.8,7.6,5.8,8.3l0,7.5C5.8,16.4,6.3,17,7,17h10c0.7,0,1.2-0.6,1.2-1.2V8.3
C18.2,7.6,17.7,7,17,7z M17,15.7H7V9.5l5,3.1l5-3.1V15.7z M12,11.4L7,8.3h10L12,11.4z"/>
</svg>
const path = require('path');
const webpack = require('webpack');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const ScriptExtHtmlWebpackPlugin = require('script-ext-html-webpack-plugin');
const HtmlWebpackExcludeAssetsPlugin = require('html-webpack-exclude-assets-plugin');
const MiniCssExtractPlugin = require('mini-css-extract-plugin');
const WebpackChunkHash = require('webpack-chunk-hash');
const ManifestPlugin = require('webpack-manifest-plugin');
const CopyWebpackPlugin = require('copy-webpack-plugin');
const GitRevisionPlugin = require('git-revision-webpack-plugin');
const gitRevisionPlugin = new GitRevisionPlugin();
const ReactLoadable = require('react-loadable/webpack');
const fs = require('fs');
const HOST = process.env.HOST || '0.0.0.0';
const PORT = process.env.PORT || 3000;
module.exports = {
stats: {
colors: true
},
devServer: {
hot: true,
inline: true,
// contentBase: path.join(__dirname, '../'),
compress: true,
port: PORT,
host: HOST,
watchOptions: {
ignored: /node_modules/
},
overlay: {
warnings: true,
errors: true
},
clientLogLevel: 'warning',
historyApiFallback: {
disableDotRule: true
},
},
entry: {
gringlobal: ['babel-polyfill', './demo/entrypoint.tsx'],
},
output: {
filename: '[name].[hash].js',
chunkFilename: '[name].[hash].js',
path: path.join(process.cwd(), 'target/app/assets'),
publicPath: ''
},
resolve: {
extensions: ['.ts', '.tsx', '.js', '.jsx'],
modules: [path.resolve('./src'), path.resolve('./server'), 'node_modules'],
alias: {
'@gringlobal/counter': path.resolve(__dirname, '../src'),
'@gringlobal/i18n': path.resolve(__dirname, '../../i18n/src'),
'server': path.resolve(__dirname, '../server'),
}
},
module: {
rules: [
{
test: /\.tsx?$/,
enforce: 'pre',
loader: 'eslint-loader',
exclude: /node_modules/,
},
{
test: /\.tsx?$/,
use: [
{
loader: 'awesome-typescript-loader',
},
],
},
]
},
plugins: [
/* new webpack.optimize.CommonsChunkPlugin({
name: 'vendor',
minChunks: Infinity
}),*/
// MD5 chunkhash
new WebpackChunkHash(),
// We use the generated manifest.js to look for current server.[hash].js and vendor.[chunkhash].js
new ManifestPlugin({
basePath: '/html/'
}),
new HtmlWebpackPlugin({
title: 'Seed counter', // The title to use for the generated HTML document
filename: 'index.html', // The file to write the HTML to
// minify: {...}, // Pass a html-minifier options object to minify the output
xhtml: true,
excludeAssets: [/server(\..+)*\.js/],
template: './assets/html/index.html',
// chunksSortMode: sortedChunks(['vendor', 'common', 'gringlobal']),
// chunks: ['vendor', 'common', 'gringlobal'],
favicon: 'favicon.ico',
}),
// Defer/Async scripts
new ScriptExtHtmlWebpackPlugin({
defaultAttribute: 'async',
// async: [ 'gringlobal' ],
}),
// Keep CSS separate
new MiniCssExtractPlugin({
filename: '[name].[hash].css',
chunkFilename: '[name].[hash].css'
}),
new HtmlWebpackExcludeAssetsPlugin(),
new CopyWebpackPlugin([
{ from: 'assets/examples', to: 'examples' },
]),
],
optimization: {
splitChunks: {
chunks: 'all',
cacheGroups: {
vendor: {
test: /[\\/]node_modules[\\/]/,
name: 'vendors',
chunks: 'all'
}
},
},
}
};
const webpack = require('webpack');
const webpackMerge = require('webpack-merge');
const commonConfig = require('./webpack-base.config.js');
module.exports = webpackMerge.smart(commonConfig, {
mode: 'development',
devtool: 'source-map',
entry: {},
plugins: [
new webpack.LoaderOptionsPlugin({
minimize: false,
debug: true,
options: {
tslint: {
failOnHint: false
}
}
}),
// new webpack.DefinePlugin({
// 'process.env': {
// API_URL: JSON.stringify(API_URL),
// CLIENT_ID: JSON.stringify(CLIENT_ID),
// CLIENT_SECRET: JSON.stringify(CLIENT_SECRET),
// GOOGLE_CLIENT_ID: JSON.stringify(GOOGLE_CLIENT_ID),
// PROJECT_VERSION: JSON.stringify(gitRevisionPlugin.version()),
// PROJECT_COMMITHASH: JSON.stringify(gitRevisionPlugin.commithash()),
// }
// }),
// hot module replacement for webpack-dev-server
new webpack.HotModuleReplacementPlugin()
],
});
import * as React from 'react';
import { ProcessImage } from './ProcessImage';
import { withStyles } from '@material-ui/core/styles';
const styles = {
root: {
height: '100%',
display: 'flex',
flexDirection: 'column' as 'column',
},
content: {
flex: '1 0 auto',
},
};
class App extends React.Component<any> {
public render(): React.ReactNode {
const { classes } = this.props;
return (
<div className={ classes.root }>
<ProcessImage />
</div>
);
}
}
export default withStyles(styles)(App);
import * as React from 'react';
import { count } from '@gringlobal/counter/counter';
export class ProcessImage extends React.Component<any> {
private MAX_PROCESSING_WIDTH: number = 300;
public state = {
count: 0,
};
private count = () => {
console.log(`Counting ${this.MAX_PROCESSING_WIDTH}`);
this.setState({ count: count(this.state.count) });
}
public render(): React.ReactNode {
return (
<div>
<div>
<form>
<input type="file" id="myfile" />
<input type="reset" value="Clear" />
</form>
</div>
<h1>Count: { this.state.count }</h1>
<img src="examples/G32 seed.jpg" />
<button onClick={ this.count }>Count</button>
<h1>Debugger</h1>
<div id="canvases" />
</div>
);
}
}
import * as React from 'react';
import * as ReactDOM from 'react-dom';
import App from './App';
ReactDOM.render(
<App />,
document.getElementById('the-app'),
);
{
"name": "@gringlobal/counter",
"version": "0.0.1",
"license": "Apache-2.0",
"scripts": {
"clean": "rimraf lib",
"build": "yarn run clean & tsc",
"start:dev": "cross-env NODE_OPTIONS=--max_old_space_size=8192 webpack-dev-server --config config/webpack-development.config.js"
},
"dependencies": {
"@material-ui/styles": "^4.9.6",
"react": "^16.12.0",
"react-dom": "^16.12.0",
"react-i18next": "^11.3.1",
"react-loadable": "^5.5.0",
"react-redux": "^7.1.3",
"react-router": "^5.1.2",
"react-router-dom": "^5.1.2"
},
"devDependencies": {
"@types/node": "13.5.3",
"@types/react": "^16.9.0",
"@types/react-router": "^5.1.0",
"@types/react-router-dom": "^5.1.0",
"@types/webpack-env": "^1.15.1",
"awesome-typescript-loader": "^5.2.1",
"babel-core": "^6.26.3",
"babel-eslint": "^10.0.3",
"babel-plugin-module-resolver": "^4.0.0",
"babel-plugin-react-transform": "^3.0.0",
"babel-plugin-syntax-dynamic-import": "^6.18.0",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-polyfill": "^6.26.0",
"babel-preset-env": "^1.7.0",
"babel-preset-react": "^6.24.1",
"babel-preset-typescript": "^7.0.0-alpha.19",
"copy-webpack-plugin": "^5.1.1",
"cross-env": "^7.0.0",
"eslint": "^6.8.0",
"eslint-config-airbnb": "^18.0.1",
"eslint-config-prettier": "^6.10.0",
"eslint-loader": "^3.0.3",
"eslint-plugin-import": "^2.20.0",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-prefer-arrow": "^1.1.7",
"eslint-plugin-react": "^7.18.0",
"html-webpack-exclude-assets-plugin": "0.0.7",
"html-webpack-plugin": "^3.2.0",
"lerna": "^3.20.2",
"react-hot-loader": "^4.12.18",
"rimraf": "^3.0.1",
"ts-node": "^8.6.2",
"tslint": "^6.0.0",
"tslint-loader": "^3.5.4",
"tslint-react": "^4.2.0",
"typescript": "^3.7.5",
"webpack": "^4.41.5",
"webpack-chunk-hash": "^0.6.0",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.10.1",
"webpack-hot-middleware": "^2.25.0",
"webpack-manifest-plugin": "^2.2.0",
"webpack-merge": "^4.2.2"
}
}
export const count = (current) => {
return current + 1;
}
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": ".",
"paths": {
"@gringlobal/counter/*": [
"./src/*"
],
"*": [
"*",
"node_modules"
]
},
"outDir": "./lib",
"module": "esnext",
"target": "esnext",
"jsx": "react",
"moduleResolution": "node"
},
"include": [
"./demo/*",
"./src/*"
],
"exclude": [
"node_modules",
"lib",
"typings/main",
"typings/main.d.ts"
],
"awesomeTypescriptLoaderOptions": {
"useCache": true,
"cacheDirectory": ".awesome-typescript-loader-cache",
"useBabel": true
}
}
......@@ -50,6 +50,9 @@ module.exports = {
compress: true,
port: PORT,
host: HOST,
watchOptions: {
ignored: /node_modules/
},
overlay: {
warnings: true,
errors: true
......
......@@ -189,6 +189,11 @@
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.7.4.tgz#f14932887422c9056b15a8d222a9074a7dfa2831"
integrity sha512-fxfMSBMX3tlIbKUdtGKxqB1fyrH6gVrX39Gsv3y8lRYKUqlgDt3UMqQyGnR1bQMa2B8aGnhLZokZgg8vT0Le+A==
 
"@emotion/hash@^0.8.0":
version "0.8.0"
resolved "https://registry.yarnpkg.com/@emotion/hash/-/hash-0.8.0.tgz#bbbff68978fefdbe68ccb533bc8cbe1d1afb5413"
integrity sha512-kBJtf7PH6aWwZ6fka3zQ0p6SBYzx4fl1LoZXE2RrnYST9Xljm7WfKJrU4g/Xr3Beg72MLrp1AWNUmuYJTL7Cow==
"@emotion/is-prop-valid@^0.7.3":
version "0.7.3"
resolved "https://registry.yarnpkg.com/@emotion/is-prop-valid/-/is-prop-valid-0.7.3.tgz#a6bf4fa5387cbba59d44e698a4680f481a8da6cc"
......@@ -1192,6 +1197,28 @@
jss-plugin-vendor-prefixer "^10.0.3"
prop-types "^15.7.2"
 
"@material-ui/styles@^4.9.6":
version "4.9.6"
resolved "https://registry.yarnpkg.com/@material-ui/styles/-/styles-4.9.6.tgz#924a30bf7c9b91af9c8f19c12c8573b8a4ecd085"
integrity sha512-ijgwStEkw1OZ6gCz18hkjycpr/3lKs1hYPi88O/AUn4vMuuGEGAIrqKVFq/lADmZUNF3DOFIk8LDkp7zmjPxtA==
dependencies:
"@babel/runtime" "^7.4.4"
"@emotion/hash" "^0.8.0"
"@material-ui/types" "^5.0.0"
"@material-ui/utils" "^4.9.6"
clsx "^1.0.2"
csstype "^2.5.2"
hoist-non-react-statics "^3.3.2"
jss "^10.0.3"
jss-plugin-camel-case "^10.0.3"
jss-plugin-default-unit "^10.0.3"
jss-plugin-global "^10.0.3"
jss-plugin-nested "^10.0.3"
jss-plugin-props-sort "^10.0.3"
jss-plugin-rule-value-function "^10.0.3"
jss-plugin-vendor-prefixer "^10.0.3"
prop-types "^15.7.2"
"@material-ui/system@^4.9.3":
version "4.9.3"
resolved "https://registry.yarnpkg.com/@material-ui/system/-/system-4.9.3.tgz#ee48990d7941237fdaf21b7b399981d614bb0875"
......@@ -1215,6 +1242,15 @@
prop-types "^15.7.2"
react-is "^16.8.0"
 
"@material-ui/utils@^4.9.6":
version "4.9.6"
resolved "https://registry.yarnpkg.com/@material-ui/utils/-/utils-4.9.6.tgz#5f1f9f6e4df9c8b6a263293b68c94834248ff157"
integrity sha512-gqlBn0JPPTUZeAktn1rgMcy9Iczrr74ecx31tyZLVGdBGGzsxzM6PP6zeS7FuoLS6vG4hoZP7hWnOoHtkR0Kvw==
dependencies:
"@babel/runtime" "^7.4.4"
prop-types "^15.7.2"
react-is "^16.8.0"
"@mrmlnc/readdir-enhanced@^2.2.1":
version "2.2.1"
resolved "https://registry.yarnpkg.com/@mrmlnc/readdir-enhanced/-/readdir-enhanced-2.2.1.tgz#524af240d1a360527b730475ecfa1344aa540dde"
......@@ -2479,6 +2515,31 @@ babel-code-frame@^6.26.0:
esutils "^2.0.2"
js-tokens "^3.0.2"
 
babel-core@^6.26.0, babel-core@^6.26.3:
version "6.26.3"
resolved "https://registry.yarnpkg.com/babel-core/-/babel-core-6.26.3.tgz#b2e2f09e342d0f0c88e2f02e067794125e75c207"
integrity sha512-6jyFLuDmeidKmUEb3NM+/yawG0M2bDZ9Z1qbZP59cyHLz8kYGKYwpJP0UwUKKUiTRNvxfLesJnTedqczP7cTDA==
dependencies:
babel-code-frame "^6.26.0"
babel-generator "^6.26.0"
babel-helpers "^6.24.1"
babel-messages "^6.23.0"
babel-register "^6.26.0"
babel-runtime "^6.26.0"
babel-template "^6.26.0"
babel-traverse "^6.26.0"
babel-types "^6.26.0"
babylon "^6.18.0"
convert-source-map "^1.5.1"
debug "^2.6.9"
json5 "^0.5.1"
lodash "^4.17.4"
minimatch "^3.0.4"
path-is-absolute "^1.0.1"
private "^0.1.8"
slash "^1.0.0"
source-map "^0.5.7"
babel-eslint@^10.0.3:
version "10.0.3"
resolved "https://registry.yarnpkg.com/babel-eslint/-/babel-eslint-10.0.3.tgz#81a2c669be0f205e19462fed2482d33e4687a88a"
......@@ -2491,6 +2552,20 @@ babel-eslint@^10.0.3:
eslint-visitor-keys "^1.0.0"
resolve "^1.12.0"
 
babel-generator@^6.26.0:
version "6.26.1"
resolved "https://registry.yarnpkg.com/babel-generator/-/babel-generator-6.26.1.tgz#1844408d3b8f0d35a404ea7ac180f087a601bd90"
integrity sha512-HyfwY6ApZj7BYTcJURpM5tznulaBvyio7/0d4zFOeMPUmfxkCjHocCuoLa2SAGzBI8AREcH3eP3758F672DppA==
dependencies:
babel-messages "^6.23.0"
babel-runtime "^6.26.0"
babel-types "^6.26.0"
detect-indent "^4.0.0"
jsesc "^1.3.0"
lodash "^4.17.4"
source-map "^0.5.7"
trim-right "^1.0.1"
babel-helper-builder-binary-assignment-operator-visitor@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-helper-builder-binary-assignment-operator-visitor/-/babel-helper-builder-binary-assignment-operator-visitor-6.24.1.tgz#cce4517ada356f4220bcae8a02c2b346f9a56664"
......@@ -2605,6 +2680,14 @@ babel-helper-replace-supers@^6.24.1:
babel-traverse "^6.24.1"
babel-types "^6.24.1"
 
babel-helpers@^6.24.1:
version "6.24.1"
resolved "https://registry.yarnpkg.com/babel-helpers/-/babel-helpers-6.24.1.tgz#3471de9caec388e5c850e597e58a26ddf37602b2"
integrity sha1-NHHenK7DiOXIUOWX5Yom3fN2ArI=
dependencies:
babel-runtime "^6.22.0"
babel-template "^6.24.1"
babel-jest@^25.1.0:
version "25.1.0"
resolved "https://registry.yarnpkg.com/babel-jest/-/babel-jest-25.1.0.tgz#206093ac380a4b78c4404a05b3277391278f80fb"
......@@ -3079,6 +3162,19 @@ babel-preset-typescript@^7.0.0-alpha.19:
babel-plugin-syntax-object-rest-spread "7.0.0-alpha.19"
babel-plugin-transform-typescript "7.0.0-alpha.19"
 
babel-register@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-register/-/babel-register-6.26.0.tgz#6ed021173e2fcb486d7acb45c6009a856f647071"
integrity sha1-btAhFz4vy0htestFxgCahW9kcHE=
dependencies:
babel-core "^6.26.0"
babel-runtime "^6.26.0"
core-js "^2.5.0"
home-or-tmp "^2.0.0"
lodash "^4.17.4"
mkdirp "^0.5.1"
source-map-support "^0.4.15"
babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0:
version "6.26.0"
resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"
......@@ -4220,7 +4316,7 @@ conventional-recommended-bump@^5.0.0:
meow "^4.0.0"
q "^1.5.1"
 
convert-source-map@1.7.0, convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.5.0, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
convert-source-map@1.7.0, convert-source-map@^1.1.0, convert-source-map@^1.4.0, convert-source-map@^1.5.0, convert-source-map@^1.5.1, convert-source-map@^1.6.0, convert-source-map@^1.7.0:
version "1.7.0"
resolved "https://registry.yarnpkg.com/convert-source-map/-/convert-source-map-1.7.0.tgz#17a2cb882d7f77d3490585e2ce6c524424a3a442"
integrity sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==
......@@ -4892,6 +4988,13 @@ detect-file@^1.0.0:
resolved "https://registry.yarnpkg.com/detect-file/-/detect-file-1.0.0.tgz#f0d66d03672a825cb1b73bdb3fe62310c8e552b7"
integrity sha1-8NZtA2cqglyxtzvbP+YjEMjlUrc=
 
detect-indent@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-4.0.0.tgz#f76d064352cdf43a1cb6ce619c4ee3a9475de208"
integrity sha1-920GQ1LN9Docts5hnE7jqUdd4gg=
dependencies:
repeating "^2.0.0"
detect-indent@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/detect-indent/-/detect-indent-5.0.0.tgz#3871cc0a6a002e8c3e5b3cf7f336264675f06b9d"
......@@ -6885,6 +6988,14 @@ hoist-non-react-statics@^3.1.0, hoist-non-react-statics@^3.2.0, hoist-non-react-
dependencies: