This commit is contained in:
병준 박 2019-11-29 06:45:47 +09:00
parent dbfd0fd765
commit 1810bbbd29
459 changed files with 40550 additions and 3335 deletions

5
.prettierrc Normal file
View File

@ -0,0 +1,5 @@
{
"trailingComma": "none",
"tabWidth": 2,
"singleQuote": true
}

View File

@ -7,8 +7,10 @@
"editor.trimAutoWhitespace": true, "editor.trimAutoWhitespace": true,
"files.trimTrailingWhitespace": true, "files.trimTrailingWhitespace": true,
"files.trimFinalNewlines": true, "files.trimFinalNewlines": true,
"files.watcherExclude": {
"**/dist/electron/win-unpacked/**": true
},
"go.testFlags": ["-v"], "go.testFlags": ["-v"],
"go.testTimeout": "100s", "go.testTimeout": "100s",
"prettier.singleQuote": true,
"debug.node.autoAttach": "on" "debug.node.autoAttach": "on"
} }

View File

@ -30,18 +30,52 @@
"styles": ["projects/ucap-webmessenger-app/src/styles.scss"], "styles": ["projects/ucap-webmessenger-app/src/styles.scss"],
"scripts": [], "scripts": [],
"customWebpackConfig": { "customWebpackConfig": {
"path": "./config/renderer.webpack.config.js", "path": "./config/angular.webpack.config.js"
"mergeStrategies": { "externals": "replace" }
} }
}, },
"configurations": { "configurations": {
"production": { "browser-development": {
"fileReplacements": [ "fileReplacements": [
{ {
"replace": "projects/ucap-webmessenger-app/src/environments/environment.ts", "replace": "projects/ucap-webmessenger-app/src/environments/environment.ts",
"with": "projects/ucap-webmessenger-app/src/environments/environment.prod.ts" "with": "projects/ucap-webmessenger-app/src/environments/environment-browser.dev.ts"
} }
], ],
"outputPath": "dist/ucap-webmessenger-app-browser",
"polyfills": "projects/ucap-webmessenger-app/src/polyfills-es5.ts",
"tsConfig": "projects/ucap-webmessenger-app/tsconfig-es5.app.json",
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"budgets": [
{
"type": "initial",
"maximumWarning": "2mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
},
"browser-production": {
"fileReplacements": [
{
"replace": "projects/ucap-webmessenger-app/src/environments/environment.ts",
"with": "projects/ucap-webmessenger-app/src/environments/environment-browser.prod.ts"
}
],
"outputPath": "dist/ucap-webmessenger-app-browser",
"polyfills": "projects/ucap-webmessenger-app/src/polyfills-es5.ts",
"tsConfig": "projects/ucap-webmessenger-app/tsconfig-es5.app.json",
"optimization": true, "optimization": true,
"outputHashing": "all", "outputHashing": "all",
"sourceMap": false, "sourceMap": false,
@ -51,6 +85,36 @@
"extractLicenses": true, "extractLicenses": true,
"vendorChunk": false, "vendorChunk": false,
"buildOptimizer": true, "buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "4mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
},
"renderer-development": {
"fileReplacements": [
{
"replace": "projects/ucap-webmessenger-app/src/environments/environment.ts",
"with": "projects/ucap-webmessenger-app/src/environments/environment-renderer.dev.ts"
}
],
"tsConfig": "projects/ucap-webmessenger-app/tsconfig-es5.app.json",
"optimization": false,
"outputHashing": "all",
"sourceMap": true,
"extractCss": true,
"namedChunks": false,
"aot": false,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": false,
"budgets": [ "budgets": [
{ {
"type": "initial", "type": "initial",
@ -63,17 +127,57 @@
"maximumError": "10kb" "maximumError": "10kb"
} }
] ]
},
"renderer-production": {
"fileReplacements": [
{
"replace": "projects/ucap-webmessenger-app/src/environments/environment.ts",
"with": "projects/ucap-webmessenger-app/src/environments/environment-renderer.prod.ts"
}
],
"tsConfig": "projects/ucap-webmessenger-app/tsconfig-es5.app.json",
"optimization": true,
"outputHashing": "all",
"sourceMap": false,
"extractCss": true,
"namedChunks": false,
"aot": true,
"extractLicenses": true,
"vendorChunk": false,
"buildOptimizer": true,
"budgets": [
{
"type": "initial",
"maximumWarning": "4mb",
"maximumError": "5mb"
},
{
"type": "anyComponentStyle",
"maximumWarning": "6kb",
"maximumError": "10kb"
}
]
} }
} }
}, },
"serve": { "serve": {
"builder": "@angular-builders/custom-webpack:dev-server", "builder": "@angular-builders/custom-webpack:dev-server",
"options": { "options": {
"browserTarget": "ucap-webmessenger-app:build" "browserTarget": "ucap-webmessenger-app:build",
"disableHostCheck": true
}, },
"configurations": { "configurations": {
"production": { "browser-development": {
"browserTarget": "ucap-webmessenger-app:build:production" "browserTarget": "ucap-webmessenger-app:build:browser-development"
},
"browser-production": {
"browserTarget": "ucap-webmessenger-app:build:browser-production"
},
"renderer-development": {
"browserTarget": "ucap-webmessenger-app:build:renderer-development"
},
"renderer-production": {
"browserTarget": "ucap-webmessenger-app:build:renderer-production"
} }
} }
}, },
@ -84,7 +188,7 @@
} }
}, },
"test": { "test": {
"builder": "@angular-devkit/build-angular:karma", "builder": "@angular-builders/custom-webpack:karma",
"options": { "options": {
"main": "projects/ucap-webmessenger-app/src/test.ts", "main": "projects/ucap-webmessenger-app/src/test.ts",
"polyfills": "projects/ucap-webmessenger-app/src/polyfills.ts", "polyfills": "projects/ucap-webmessenger-app/src/polyfills.ts",
@ -95,7 +199,10 @@
"projects/ucap-webmessenger-app/src/assets" "projects/ucap-webmessenger-app/src/assets"
], ],
"styles": ["projects/ucap-webmessenger-app/src/styles.scss"], "styles": ["projects/ucap-webmessenger-app/src/styles.scss"],
"scripts": [] "scripts": [],
"customWebpackConfig": {
"path": "./config/angular.webpack.config.js"
}
} }
}, },
"lint": { "lint": {
@ -256,6 +363,40 @@
} }
} }
}, },
"ucap-webmessenger-api-message": {
"projectType": "library",
"root": "projects/ucap-webmessenger-api-message",
"sourceRoot": "projects/ucap-webmessenger-api-message/src",
"prefix": "ucap-api-message",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ucap-webmessenger-api-message/tsconfig.lib.json",
"project": "projects/ucap-webmessenger-api-message/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/ucap-webmessenger-api-message/src/test.ts",
"tsConfig": "projects/ucap-webmessenger-api-message/tsconfig.spec.json",
"karmaConfig": "projects/ucap-webmessenger-api-message/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/ucap-webmessenger-api-message/tsconfig.lib.json",
"projects/ucap-webmessenger-api-message/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
}
}
}
},
"ucap-webmessenger-api": { "ucap-webmessenger-api": {
"projectType": "library", "projectType": "library",
"root": "projects/ucap-webmessenger-api", "root": "projects/ucap-webmessenger-api",
@ -588,6 +729,39 @@
} }
} }
}, },
"ucap-webmessenger-ui-settings": {
"projectType": "library",
"root": "projects/ucap-webmessenger-ui-settings",
"sourceRoot": "projects/ucap-webmessenger-ui-settings/src",
"prefix": "ucap-settings",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ucap-webmessenger-ui-settings/tsconfig.lib.json",
"project": "projects/ucap-webmessenger-ui-settings/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/ucap-webmessenger-ui-settings/src/test.ts",
"tsConfig": "projects/ucap-webmessenger-ui-settings/tsconfig.spec.json",
"karmaConfig": "projects/ucap-webmessenger-ui-settings/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/ucap-webmessenger-ui-settings/tsconfig.lib.json",
"projects/ucap-webmessenger-ui-settings/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
}
}
}
},
"ucap-webmessenger-protocol": { "ucap-webmessenger-protocol": {
"projectType": "library", "projectType": "library",
"root": "projects/ucap-webmessenger-protocol", "root": "projects/ucap-webmessenger-protocol",
@ -1182,72 +1356,6 @@
} }
} }
}, },
"ucap-webmessenger-native": {
"projectType": "library",
"root": "projects/ucap-webmessenger-native",
"sourceRoot": "projects/ucap-webmessenger-native/src",
"prefix": "ucap-native",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ucap-webmessenger-native/tsconfig.lib.json",
"project": "projects/ucap-webmessenger-native/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/ucap-webmessenger-native/src/test.ts",
"tsConfig": "projects/ucap-webmessenger-native/tsconfig.spec.json",
"karmaConfig": "projects/ucap-webmessenger-native/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/ucap-webmessenger-native/tsconfig.lib.json",
"projects/ucap-webmessenger-native/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
}
}
}
},
"ucap-webmessenger-native-electron": {
"projectType": "library",
"root": "projects/ucap-webmessenger-native-electron",
"sourceRoot": "projects/ucap-webmessenger-native-electron/src",
"prefix": "ucap-native-electron",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ucap-webmessenger-native-electron/tsconfig.lib.json",
"project": "projects/ucap-webmessenger-native-electron/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/ucap-webmessenger-native-electron/src/test.ts",
"tsConfig": "projects/ucap-webmessenger-native-electron/tsconfig.spec.json",
"karmaConfig": "projects/ucap-webmessenger-native-electron/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/ucap-webmessenger-native-electron/tsconfig.lib.json",
"projects/ucap-webmessenger-native-electron/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
}
}
}
},
"ucap-webmessenger-web-socket": { "ucap-webmessenger-web-socket": {
"projectType": "library", "projectType": "library",
"root": "projects/ucap-webmessenger-web-socket", "root": "projects/ucap-webmessenger-web-socket",
@ -1413,6 +1521,72 @@
} }
} }
}, },
"ucap-webmessenger-native": {
"projectType": "library",
"root": "projects/ucap-webmessenger-native",
"sourceRoot": "projects/ucap-webmessenger-native/src",
"prefix": "ucap-native",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ucap-webmessenger-native/tsconfig.lib.json",
"project": "projects/ucap-webmessenger-native/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/ucap-webmessenger-native/src/test.ts",
"tsConfig": "projects/ucap-webmessenger-native/tsconfig.spec.json",
"karmaConfig": "projects/ucap-webmessenger-native/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/ucap-webmessenger-native/tsconfig.lib.json",
"projects/ucap-webmessenger-native/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
}
}
}
},
"ucap-webmessenger-native-electron": {
"projectType": "library",
"root": "projects/ucap-webmessenger-native-electron",
"sourceRoot": "projects/ucap-webmessenger-native-electron/src",
"prefix": "ucap-native-electron",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ucap-webmessenger-native-electron/tsconfig.lib.json",
"project": "projects/ucap-webmessenger-native-electron/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/ucap-webmessenger-native-electron/src/test.ts",
"tsConfig": "projects/ucap-webmessenger-native-electron/tsconfig.spec.json",
"karmaConfig": "projects/ucap-webmessenger-native-electron/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/ucap-webmessenger-native-electron/tsconfig.lib.json",
"projects/ucap-webmessenger-native-electron/tsconfig.spec.json"
],
"exclude": ["**/node_modules/**"]
}
}
}
},
"ucap-webmessenger-native-browser": { "ucap-webmessenger-native-browser": {
"projectType": "library", "projectType": "library",
"root": "projects/ucap-webmessenger-native-browser", "root": "projects/ucap-webmessenger-native-browser",
@ -1445,76 +1619,6 @@
} }
} }
} }
},
"ucap-webmessenger-electron-notification": {
"projectType": "library",
"root": "projects/ucap-webmessenger-electron-notification",
"sourceRoot": "projects/ucap-webmessenger-electron-notification/src",
"prefix": "ucap-electron-notification",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ucap-webmessenger-electron-notification/tsconfig.lib.json",
"project": "projects/ucap-webmessenger-electron-notification/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/ucap-webmessenger-electron-notification/src/test.ts",
"tsConfig": "projects/ucap-webmessenger-electron-notification/tsconfig.spec.json",
"karmaConfig": "projects/ucap-webmessenger-electron-notification/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/ucap-webmessenger-electron-notification/tsconfig.lib.json",
"projects/ucap-webmessenger-electron-notification/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
},
"ucap-webmessenger-electron-core": {
"projectType": "library",
"root": "projects/ucap-webmessenger-electron-core",
"sourceRoot": "projects/ucap-webmessenger-electron-core/src",
"prefix": "ucap-electron-core",
"architect": {
"build": {
"builder": "@angular-devkit/build-ng-packagr:build",
"options": {
"tsConfig": "projects/ucap-webmessenger-electron-core/tsconfig.lib.json",
"project": "projects/ucap-webmessenger-electron-core/ng-package.json"
}
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"main": "projects/ucap-webmessenger-electron-core/src/test.ts",
"tsConfig": "projects/ucap-webmessenger-electron-core/tsconfig.spec.json",
"karmaConfig": "projects/ucap-webmessenger-electron-core/karma.conf.js"
}
},
"lint": {
"builder": "@angular-devkit/build-angular:tslint",
"options": {
"tsConfig": [
"projects/ucap-webmessenger-electron-core/tsconfig.lib.json",
"projects/ucap-webmessenger-electron-core/tsconfig.spec.json"
],
"exclude": [
"**/node_modules/**"
]
}
}
}
} }
}, },
"defaultProject": "ucap-webmessenger-app" "defaultProject": "ucap-webmessenger-app"

View File

@ -2,8 +2,16 @@ const path = require('path');
module.exports = (config, options) => { module.exports = (config, options) => {
const PRODUCTION = process.env.NODE_ENV === 'production'; const PRODUCTION = process.env.NODE_ENV === 'production';
const BROWSER = process.env.UCAP_ENV_RUNTIME === 'BROWSER';
if (!BROWSER) {
config.target = 'electron-renderer'; config.target = 'electron-renderer';
} else {
config.target = 'web';
config.node = {
fs: 'empty',
};
}
config.resolve.alias = { config.resolve.alias = {
...config.resolve.alias, ...config.resolve.alias,
@ -11,7 +19,7 @@ module.exports = (config, options) => {
__dirname, __dirname,
'..', '..',
'projects/ucap-webmessenger-ui/src/assets/scss' 'projects/ucap-webmessenger-ui/src/assets/scss'
) ),
}; };
return config; return config;

View File

@ -1,4 +1,3 @@
import * as fs from 'fs';
import * as Path from 'path'; import * as Path from 'path';
const projectRoot = Path.dirname(__dirname); const projectRoot = Path.dirname(__dirname);
@ -14,6 +13,6 @@ export function getEnviroments() {
__DEV__: channel === 'development', __DEV__: channel === 'development',
'process.platform': s(process.platform), 'process.platform': s(process.platform),
'process.env.NODE_ENV': s(process.env.NODE_ENV || 'development'), 'process.env.NODE_ENV': s(process.env.NODE_ENV || 'development'),
'process.env.TEST_ENV': s(process.env.TEST_ENV) 'process.env.TEST_ENV': s(process.env.TEST_ENV),
}; };
} }

View File

@ -12,28 +12,39 @@ export const externals = [nodeExternals()];
// externals.push('devtron'); // externals.push('devtron');
// } // }
const outputDir = 'dist/main'; const outputDir = 'dist/ucap-webmessenger-electron';
const mainConfig: webpack.Configuration = { const mainConfig: webpack.Configuration = {
entry: { main: path.resolve(__dirname, '..', 'main/src/index') }, entry: {
main: path.resolve(
__dirname,
'..',
'electron-projects/ucap-webmessenger-electron/src/index'
),
},
target: 'electron-main', target: 'electron-main',
mode: enviroments.__DEV__ ? 'development' : 'production', mode: enviroments.__DEV__ ? 'development' : 'production',
devtool: 'source-map', devtool: 'source-map',
optimization: { optimization: {
noEmitOnErrors: true noEmitOnErrors: true,
}, },
externals, externals,
output: { output: {
filename: '[name].js', filename: '[name].js',
path: path.resolve(__dirname, '..', outputDir) path: path.resolve(__dirname, '..', outputDir),
}, },
module: { module: {
rules: [ rules: [
{ {
test: /\.tsx?$/, test: /\.tsx?$/,
include: [ include: [
path.resolve(__dirname, '..', 'main/src'), path.resolve(
path.resolve(__dirname, '..', 'projects') __dirname,
'..',
'electron-projects/ucap-webmessenger-electron/src'
),
path.resolve(__dirname, '..', 'electron-projects'),
path.resolve(__dirname, '..', 'projects'),
], ],
use: [ use: [
{ {
@ -43,21 +54,21 @@ const mainConfig: webpack.Configuration = {
configFileName: path.resolve( configFileName: path.resolve(
__dirname, __dirname,
'..', '..',
'main/tsconfig.main.json' 'electron-projects/ucap-webmessenger-electron/tsconfig.electron.json'
) ),
} },
} },
], ],
exclude: /node_modules/ exclude: /node_modules/,
}, },
{ {
test: /\.node$/, test: /\.node$/,
loader: 'awesome-node-loader', loader: 'awesome-node-loader',
options: { options: {
name: '[name].[ext]' name: '[name].[ext]',
} },
} },
] ],
}, },
plugins: [ plugins: [
new CleanWebpackPlugin({ verbose: false }), new CleanWebpackPlugin({ verbose: false }),
@ -66,15 +77,16 @@ const mainConfig: webpack.Configuration = {
new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/), new webpack.IgnorePlugin(/^\.\/locale$/, /moment$/),
new webpack.DefinePlugin( new webpack.DefinePlugin(
Object.assign({}, enviroments, { Object.assign({}, enviroments, {
__PROCESS_KIND__: JSON.stringify('main') __PROCESS_KIND__: JSON.stringify('main'),
}) })
), ),
new CopyWebpackPlugin([ new CopyWebpackPlugin([
{ {
from: 'main/resources/**/*', from: 'ucap-webmessenger-electron/resources/**/*',
to: path.resolve(__dirname, '..', 'dist') to: path.resolve(__dirname, '..', 'dist'),
} context: 'electron-projects',
]) },
]),
], ],
resolve: { resolve: {
extensions: ['.js', '.ts'], extensions: ['.js', '.ts'],
@ -82,12 +94,17 @@ const mainConfig: webpack.Configuration = {
'@ucap-webmessenger/electron-core': path.resolve( '@ucap-webmessenger/electron-core': path.resolve(
__dirname, __dirname,
'..', '..',
'projects/ucap-webmessenger-electron-core/src/public-api' 'electron-projects/ucap-webmessenger-electron-core/src/public-api'
), ),
'@ucap-webmessenger/electron-notification': path.resolve( '@ucap-webmessenger/electron-notification': path.resolve(
__dirname, __dirname,
'..', '..',
'projects/ucap-webmessenger-electron-notification/src/public-api' 'electron-projects/ucap-webmessenger-electron-notification/src/public-api'
),
'@ucap-webmessenger/core': path.resolve(
__dirname,
'..',
'projects/ucap-webmessenger-core/src/public-api'
), ),
'@ucap-webmessenger/native': path.resolve( '@ucap-webmessenger/native': path.resolve(
__dirname, __dirname,
@ -98,14 +115,19 @@ const mainConfig: webpack.Configuration = {
__dirname, __dirname,
'..', '..',
'projects/ucap-webmessenger-native-electron/src/public-api' 'projects/ucap-webmessenger-native-electron/src/public-api'
) ),
'@ucap-webmessenger/electron': path.resolve(
__dirname,
'..',
'electron-projects/ucap-webmessenger-electron/src/public-api'
),
}, },
modules: [path.resolve(__dirname, '..', 'node_modules/')] modules: [path.resolve(__dirname, '..', 'node_modules/')],
}, },
node: { node: {
__dirname: false, __dirname: false,
__filename: false __filename: false,
} },
}; };
export default [mainConfig]; export default [mainConfig];

10
docker/docker-compose.yml Normal file
View File

@ -0,0 +1,10 @@
version: '3.1'
services:
nginx:
image: nginx:1.17.5-alpine
volumes:
- ../dist/web:/usr/share/nginx/html:ro
- ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
ports:
- 8099:80

40
docker/nginx/nginx.conf Normal file
View File

@ -0,0 +1,40 @@
worker_processes 4;
events { worker_connections 1024; }
http {
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 30m;
#See http://blog.argteam.com/coding/hardening-node-js-for-production-part-2-using-nginx-to-avoid-node-js-load
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
gzip_vary on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;
gzip_buffers 16 8k;
server {
listen 80;
server_name localhost;
location / {
root /usr/share/nginx/html;
index index.html;
expires -1;
add_header Pragma "no-cache";
add_header Cache-Control "no-store, no-cache, must-revalidate, post-check=0, pre-check=0";
try_files $uri$args $uri$args/ $uri $uri/ /index.html =404;
}
}
}

View File

@ -1,10 +1,10 @@
{ {
"productName": "WooriTalk", "productName": "UCapMessenger",
"appId": "lgcns.ucap.messenger", "appId": "com.lgucap.messenger",
"asar": true, "asar": true,
"protocols": { "protocols": {
"name": "WooriTalk", "name": "UCapMessenger",
"schemes": ["WooriTalk"] "schemes": ["UCapMessenger"]
}, },
"publish": { "publish": {
"provider": "generic", "provider": "generic",
@ -12,19 +12,19 @@
}, },
"mac": { "mac": {
"target": ["default"], "target": ["default"],
"icon": "./resources/installer/woori.icns" "icon": "./dist/ucap-webmessenger-electron/resources/installer/woori.icns"
}, },
"dmg": { "dmg": {
"title": "WooriTalk", "title": "UCapMessenger",
"icon": "./resources/installer/woori.icns" "icon": "./dist/ucap-webmessenger-electron/resources/installer/woori.icns"
}, },
"win": { "win": {
"target": ["zip", "nsis"], "target": ["zip", "nsis"],
"icon": "./resources/installer/woori_256x256.ico" "icon": "./dist/ucap-webmessenger-electron/resources/image/16_16.ico"
}, },
"linux": { "linux": {
"target": ["AppImage", "deb", "rpm", "zip", "tar.gz"], "target": ["AppImage", "deb", "rpm", "zip", "tar.gz"],
"icon": "./resources/linuxicon" "icon": "./dist/ucap-webmessenger-electron/resources/linuxicon"
}, },
"nsis": { "nsis": {
"oneClick": false, "oneClick": false,
@ -33,8 +33,8 @@
"differentialPackage": true "differentialPackage": true
}, },
"directories": { "directories": {
"buildResources": "resources/installer/", "buildResources": "./dist/ucap-webmessenger-electron/resources/installer/",
"output": "dist-electron/", "output": "./dist/electron/",
"app": "." "app": "."
} }
} }

View File

@ -0,0 +1,34 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(
__dirname,
'../../coverage/ucap-webmessenger-electron-core'
),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

View File

@ -0,0 +1,5 @@
{
"name": "@ucap-webmessenger/electron-core",
"version": "0.0.1",
"peerDependencies": {}
}

View File

@ -0,0 +1,13 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": ["dom", "es2018"]
},
"exclude": ["src/test.ts", "**/*.spec.ts"]
}

View File

@ -0,0 +1,9 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/spec",
"types": ["jasmine", "node"]
},
"files": ["src/test.ts"],
"include": ["**/*.spec.ts", "**/*.d.ts"]
}

View File

@ -0,0 +1,34 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(
__dirname,
'../../coverage/ucap-webmessenger-electron-notification'
),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

View File

@ -40,7 +40,7 @@ export const DefaultElectronNotificationOptions: ElectronNotificationOptions = {
borderRadius: 5, borderRadius: 5,
displayTime: 5000, displayTime: 5000,
animationSteps: 5, animationSteps: 5,
animationStepMs: 5, animationStepMs: 20,
appIcon: null, appIcon: null,
pathToModule: '', pathToModule: '',
logging: true, logging: true,

View File

@ -3,7 +3,7 @@ import { ElectronNotificationEventType } from '../types/event.type';
export interface ElectronNotificationEvent { export interface ElectronNotificationEvent {
type: ElectronNotificationEventType; type: ElectronNotificationEventType;
id: number; id: number;
close?: (reason: any) => void; close?: (reason?: any) => void;
} }
export interface ElectronNotification { export interface ElectronNotification {

View File

@ -1,10 +1,11 @@
import * as path from 'path'; import * as path from 'path';
import * as url from 'url'; import * as url from 'url';
import * as fse from 'fs-extra';
import { AnimationQueue } from '../utils/animation-queue'; import { AnimationQueue } from '../utils/animation-queue';
import { import {
ElectronNotificationOptions, ElectronNotificationOptions,
DefaultElectronNotificationOptions DefaultElectronNotificationOptions,
} from '../models/electron-notification-options'; } from '../models/electron-notification-options';
import { screen, BrowserWindow, ipcMain, IpcMainEvent, shell } from 'electron'; import { screen, BrowserWindow, ipcMain, IpcMainEvent, shell } from 'electron';
import { ElectronNotification } from '../models/electron-notification'; import { ElectronNotification } from '../models/electron-notification';
@ -42,12 +43,12 @@ export class ElectronNotificationService {
constructor(options?: ElectronNotificationOptions) { constructor(options?: ElectronNotificationOptions) {
this.customOptions = { this.customOptions = {
...DefaultElectronNotificationOptions ...DefaultElectronNotificationOptions,
}; };
if (!!options) { if (!!options) {
this.customOptions = { this.customOptions = {
...this.customOptions, ...this.customOptions,
...options ...options,
}; };
} }
@ -59,7 +60,7 @@ export class ElectronNotificationService {
if (!!options) { if (!!options) {
this.customOptions = { this.customOptions = {
...this.customOptions, ...this.customOptions,
...options ...options,
}; };
} }
this.calcDimensions(); this.calcDimensions();
@ -88,7 +89,7 @@ export class ElectronNotificationService {
this.animationQueue.push({ this.animationQueue.push({
context: this, context: this,
func: this.showNotification, func: this.showNotification,
args: [notification] args: [notification],
}); });
return notification.id; return notification.id;
} }
@ -123,7 +124,7 @@ export class ElectronNotificationService {
this.lowerRightCornerPosition = { this.lowerRightCornerPosition = {
x: display.bounds.x + display.workArea.x + display.workAreaSize.width, x: display.bounds.x + display.workArea.x + display.workAreaSize.width,
y: display.bounds.y + display.workArea.y + display.workAreaSize.height y: display.bounds.y + display.workArea.y + display.workAreaSize.height,
}; };
this.calcDimensions(); this.calcDimensions();
@ -176,7 +177,7 @@ export class ElectronNotificationService {
notificationWindow[onClickElectronNotification]({ notificationWindow[onClickElectronNotification]({
type: ElectronNotificationEventType.Click, type: ElectronNotificationEventType.Click,
id: notification.id, id: notification.id,
close: self.buildCloseNotificationSafely(onClose) close: self.buildCloseNotificationSafely(onClose),
}); });
delete notificationWindow[onClickElectronNotification]; delete notificationWindow[onClickElectronNotification];
} }
@ -187,17 +188,17 @@ export class ElectronNotificationService {
private calcDimensions() { private calcDimensions() {
this.totalDimension = { this.totalDimension = {
width: this.customOptions.width + this.customOptions.padding, width: this.customOptions.width + this.customOptions.padding,
height: this.customOptions.height + this.customOptions.padding height: this.customOptions.height + this.customOptions.padding,
}; };
this.firstPosition = { this.firstPosition = {
x: this.lowerRightCornerPosition.x = this.totalDimension.width, x: this.lowerRightCornerPosition.x - this.totalDimension.width,
y: this.lowerRightCornerPosition.y = this.totalDimension.height y: this.lowerRightCornerPosition.y - this.totalDimension.height,
}; };
this.nextInsertPosition = { this.nextInsertPosition = {
x: this.firstPosition.x, x: this.firstPosition.x,
y: this.firstPosition.y y: this.firstPosition.y,
}; };
} }
@ -211,18 +212,12 @@ export class ElectronNotificationService {
private updateTemplatePath() { private updateTemplatePath() {
try { try {
import('fs') fse.statSync(this.customOptions.templatePath).isFile();
.then(fs => {
fs.statSync(this.customOptions.templatePath).isFile();
this.templateUrl = url.format({ this.templateUrl = url.format({
pathname: this.customOptions.templatePath, pathname: this.customOptions.templatePath,
protocol: 'file:', protocol: 'file:',
slashes: true slashes: true,
});
})
.catch(reason => {
throw reason;
}); });
} catch (e) { } catch (e) {
console.log( console.log(
@ -237,26 +232,27 @@ export class ElectronNotificationService {
} }
private showNotification(notification: ElectronNotification): Promise<any> { private showNotification(notification: ElectronNotification): Promise<any> {
const self = this;
return new Promise<any>((resolve, reject) => { return new Promise<any>((resolve, reject) => {
if (this.activeNotifications.length < this.maxVisibleNotifications) { if (this.activeNotifications.length < this.maxVisibleNotifications) {
this.getWindow().then(notificationWindow => { self.getWindow().then(notificationWindow => {
this.calcInsertPosition(); self.calcInsertPosition();
notificationWindow.setPosition( notificationWindow.setPosition(
this.nextInsertPosition.x, self.nextInsertPosition.x,
this.nextInsertPosition.y self.nextInsertPosition.y
); );
this.activeNotifications.push(notificationWindow); self.activeNotifications.push(notificationWindow);
const displayTime = !!notification.displayTime const displayTime = !!notification.displayTime
? notification.displayTime ? notification.displayTime
: this.customOptions.displayTime; : self.customOptions.displayTime;
let timeoutId: any; let timeoutId: any;
const onClose = this.buildCloseNotification( const onClose = self.buildCloseNotification(
notificationWindow, notificationWindow,
notification, notification,
() => timeoutId () => timeoutId
); );
const onCloseNotificationSafely = this.buildCloseNotificationSafely( const onCloseNotificationSafely = self.buildCloseNotificationSafely(
onClose onClose
); );
timeoutId = setTimeout(() => { timeoutId = setTimeout(() => {
@ -270,11 +266,11 @@ export class ElectronNotificationService {
notification.onShow({ notification.onShow({
type: ElectronNotificationEventType.Show, type: ElectronNotificationEventType.Show,
id: notification.id, id: notification.id,
close: onCloseNotificationSafely close: onCloseNotificationSafely,
}); });
} }
if (!!notification.onClose) { if (!!notification.onClick) {
notificationWindow[onClickElectronNotification] = notificationWindow[onClickElectronNotification] =
notification.onClick; notification.onClick;
} else { } else {
@ -296,7 +292,7 @@ export class ElectronNotificationService {
resolve(notificationWindow); resolve(notificationWindow);
}); });
} else { } else {
this.notificationQueue.push(notification); self.notificationQueue.push(notification);
resolve(); resolve();
} }
}); });
@ -307,24 +303,25 @@ export class ElectronNotificationService {
notification: ElectronNotification, notification: ElectronNotification,
timeoutIdFunc?: () => number timeoutIdFunc?: () => number
) { ) {
const self = this;
return (e: ElectronNotificationEventType): Promise<void> => { return (e: ElectronNotificationEventType): Promise<void> => {
if (notificationWindow.isDestroyed()) { if (notificationWindow.isDestroyed()) {
return; return;
} }
if (this.closedNotifications.has(notification.id)) { if (self.closedNotifications.has(notification.id)) {
this.closedNotifications.delete(notification.id); self.closedNotifications.delete(notification.id);
return new Promise<void>(resolve => { return new Promise<void>(resolve => {
resolve(); resolve();
}); });
} else { } else {
this.closedNotifications.set(notification.id, true); self.closedNotifications.set(notification.id, true);
} }
if (!!notificationWindow[onCloseElectronNotification]) { if (!!notificationWindow[onCloseElectronNotification]) {
notificationWindow[onCloseElectronNotification]({ notificationWindow[onCloseElectronNotification]({
type: e, type: e,
id: notification.id id: notification.id,
}); });
delete notificationWindow[onCloseElectronNotification]; delete notificationWindow[onCloseElectronNotification];
} }
@ -334,29 +331,30 @@ export class ElectronNotificationService {
if (!!timeoutIdFunc) { if (!!timeoutIdFunc) {
clearTimeout(timeoutIdFunc()); clearTimeout(timeoutIdFunc());
} }
const i = this.activeNotifications.indexOf(notificationWindow); const i = self.activeNotifications.indexOf(notificationWindow);
this.activeNotifications.splice(i, 1); self.activeNotifications.splice(i, 1);
this.inactiveWindows.push(notificationWindow); self.inactiveWindows.push(notificationWindow);
notificationWindow.hide(); notificationWindow.hide();
this.checkForQueuedNotifications(); self.checkForQueuedNotifications();
return this.moveOneDown(i); return self.moveOneDown(i);
}; };
} }
private buildCloseNotificationSafely( private buildCloseNotificationSafely(
onClose: (e: ElectronNotificationEventType) => any onClose: (e: ElectronNotificationEventType) => any
) { ) {
const self = this;
return (reason: any) => { return (reason: any) => {
if (!reason) { if (!reason) {
reason = 'closedByAPI'; reason = 'closedByAPI';
this.animationQueue.push({
context: this,
func: onClose,
args: [reason]
});
} }
self.animationQueue.push({
context: self,
func: onClose,
args: [reason],
});
}; };
} }
@ -368,30 +366,31 @@ export class ElectronNotificationService {
this.animationQueue.push({ this.animationQueue.push({
context: this, context: this,
func: this.showNotification, func: this.showNotification,
args: [this.notificationQueue.shift()] args: [this.notificationQueue.shift()],
}); });
} }
} }
private getWindow(): Promise<BrowserWindow> { private getWindow(): Promise<BrowserWindow> {
const slef = this;
return new Promise<BrowserWindow>((resolve, reject) => { return new Promise<BrowserWindow>((resolve, reject) => {
if (0 < this.inactiveWindows.length) { if (0 < slef.inactiveWindows.length) {
resolve(this.inactiveWindows.pop()); resolve(slef.inactiveWindows.pop());
} else { } else {
const windowProperties = this.customOptions.defaultWindow; const windowProperties = slef.customOptions.defaultWindow;
windowProperties.width = this.customOptions.width; windowProperties.width = slef.customOptions.width;
windowProperties.height = this.customOptions.height; windowProperties.height = slef.customOptions.height;
const notificationWindow = new BrowserWindow(windowProperties); const notificationWindow = new BrowserWindow(windowProperties);
notificationWindow.setVisibleOnAllWorkspaces(true); notificationWindow.setVisibleOnAllWorkspaces(true);
notificationWindow.loadURL(this.templatePath); notificationWindow.loadURL(slef.templatePath);
notificationWindow.webContents.on( notificationWindow.webContents.on(
ElectronWebContentsChannel.DidFinishLoad, ElectronWebContentsChannel.DidFinishLoad,
() => { () => {
// Done // Done
notificationWindow.webContents.send( notificationWindow.webContents.send(
Channel.loadConfig, Channel.loadConfig,
this.customOptions slef.customOptions
); );
resolve(notificationWindow); resolve(notificationWindow);
} }
@ -407,20 +406,21 @@ export class ElectronNotificationService {
} }
private moveOneDown(startPos: number): Promise<void> { private moveOneDown(startPos: number): Promise<void> {
const self = this;
return new Promise<void>(async (resolve, reject) => { return new Promise<void>(async (resolve, reject) => {
if (startPos >= this.activeNotifications.length || -1 === startPos) { if (startPos >= self.activeNotifications.length || -1 === startPos) {
resolve(); resolve();
return; return;
} }
const aryNotificationPos: number[] = []; const aryNotificationPos: number[] = [];
for (let i = startPos; i < this.activeNotifications.length; i++) { for (let i = startPos; i < self.activeNotifications.length; i++) {
aryNotificationPos.push(i); aryNotificationPos.push(i);
} }
await Promise.all( await Promise.all(
aryNotificationPos.map(async index => { aryNotificationPos.map(async index => {
await this.moveNotificationAnimation(index); await self.moveNotificationAnimation(index);
}) })
); );
resolve(); resolve();
@ -428,28 +428,29 @@ export class ElectronNotificationService {
} }
private moveNotificationAnimation(index: number): Promise<void> { private moveNotificationAnimation(index: number): Promise<void> {
const self = this;
return new Promise<void>((resolve, reject) => { return new Promise<void>((resolve, reject) => {
const notificationWindow = this.activeNotifications[index]; const notificationWindow = self.activeNotifications[index];
const newY = const newY =
this.lowerRightCornerPosition.y - self.lowerRightCornerPosition.y -
this.totalDimension.height * (index + 1); self.totalDimension.height * (index + 1);
const startY = notificationWindow.getPosition()[1]; const startY = notificationWindow.getPosition()[1];
const step = (newY - startY) / this.customOptions.animationSteps; const step = (newY - startY) / self.customOptions.animationSteps;
let curStep = 1; let curStep = 1;
const animationInterval = setInterval(() => { const animationInterval = setInterval(() => {
// Abort condition // Abort condition
if (curStep === this.customOptions.animationSteps) { if (curStep === self.customOptions.animationSteps) {
notificationWindow.setPosition(this.firstPosition.x, newY); notificationWindow.setPosition(self.firstPosition.x, newY);
clearInterval(animationInterval); clearInterval(animationInterval);
return resolve(); return resolve();
} }
// Move one step down // Move one step down
notificationWindow.setPosition( notificationWindow.setPosition(
this.firstPosition.x, self.firstPosition.x,
Math.trunc(startY + curStep * step) Math.trunc(startY + curStep * step)
); );
curStep++; curStep++;
}, this.customOptions.animationStepMs); }, self.customOptions.animationStepMs);
}); });
} }
} }

View File

@ -0,0 +1,12 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"outDir": "../../out-tsc/lib",
"target": "es2015",
"declaration": true,
"inlineSources": true,
"types": [],
"lib": ["dom", "es2018"]
},
"exclude": ["src/test.ts", "**/*.spec.ts"]
}

View File

@ -0,0 +1,24 @@
# UcapWebmessengerElectron
This library was generated with [Angular CLI](https://github.com/angular/angular-cli) version 8.2.11.
## Code scaffolding
Run `ng generate component component-name --project ucap-webmessenger-electron` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module --project ucap-webmessenger-electron`.
> Note: Don't forget to add `--project ucap-webmessenger-electron` or else it will be added to the default project in your `angular.json` file.
## Build
Run `ng build ucap-webmessenger-electron` to build the project. The build artifacts will be stored in the `dist/` directory.
## Publishing
After building your library with `ng build ucap-webmessenger-electron`, go to the dist folder `cd dist/ucap-webmessenger-electron` and run `npm publish`.
## Running unit tests
Run `ng test ucap-webmessenger-electron` to execute the unit tests via [Karma](https://karma-runner.github.io).
## Further help
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI README](https://github.com/angular/angular-cli/blob/master/README.md).

View File

@ -0,0 +1,34 @@
// Karma configuration file, see link for more information
// https://karma-runner.github.io/1.0/config/configuration-file.html
module.exports = function(config) {
config.set({
basePath: '',
frameworks: ['jasmine'],
plugins: [
require('karma-jasmine'),
require('karma-chrome-launcher'),
require('karma-jasmine-html-reporter'),
require('karma-coverage-istanbul-reporter')
],
client: {
clearContext: false // leave Jasmine Spec Runner output visible in browser
},
coverageIstanbulReporter: {
dir: require('path').join(
__dirname,
'../../coverage/ucap-webmessenger-electron'
),
reports: ['html', 'lcovonly', 'text-summary'],
fixWebpackSourcePaths: true
},
reporters: ['progress', 'kjhtml'],
port: 9876,
colors: true,
logLevel: config.LOG_INFO,
autoWatch: true,
browsers: ['Chrome'],
singleRun: false,
restartOnFileChange: true
});
};

View File

@ -0,0 +1,5 @@
{
"name": "@ucap-webmessenger/electron",
"version": "0.0.1",
"peerDependencies": {}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 104 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 503 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 886 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 551 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 999 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 107 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

View File

Before

Width:  |  Height:  |  Size: 31 KiB

After

Width:  |  Height:  |  Size: 31 KiB

View File

Before

Width:  |  Height:  |  Size: 20 KiB

After

Width:  |  Height:  |  Size: 20 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 18 KiB

After

Width:  |  Height:  |  Size: 18 KiB

View File

Before

Width:  |  Height:  |  Size: 226 B

After

Width:  |  Height:  |  Size: 226 B

View File

@ -26,7 +26,7 @@ export class AppWindow {
private minWidth = 960; private minWidth = 960;
private minHeight = 660; private minHeight = 660;
public constructor() { public constructor(private appIconPath: string) {
const savedWindowState = windowStateKeeper({ const savedWindowState = windowStateKeeper({
defaultWidth: this.minWidth, defaultWidth: this.minWidth,
defaultHeight: this.minHeight defaultHeight: this.minHeight
@ -52,7 +52,7 @@ export class AppWindow {
nodeIntegration: true nodeIntegration: true
}, },
acceptFirstMouse: true, acceptFirstMouse: true,
icon: path.join(__dirname, 'resources/image', 'ico_64_64.png') icon: this.appIconPath
}; };
if (__DARWIN__) { if (__DARWIN__) {
@ -60,7 +60,6 @@ export class AppWindow {
} else if (__WIN32__) { } else if (__WIN32__) {
windowOptions.frame = false; windowOptions.frame = false;
} else if (__LINUX__) { } else if (__LINUX__) {
windowOptions.icon = path.join(__dirname, 'static', 'icon-logo.png');
} }
this.window = new BrowserWindow(windowOptions); this.window = new BrowserWindow(windowOptions);
@ -85,6 +84,19 @@ export class AppWindow {
e.preventDefault(); e.preventDefault();
} }
}); });
} else if (__WIN32__) {
this.window.on(ElectronBrowserWindowChannel.Minimize, e => {
if (!quitting) {
e.preventDefault();
this.window.hide();
}
});
this.window.on(ElectronBrowserWindowChannel.Close, e => {
if (!quitting) {
e.preventDefault();
this.window.hide();
}
});
} }
if (__WIN32__) { if (__WIN32__) {
@ -200,6 +212,10 @@ export class AppWindow {
this.window.show(); this.window.show();
} }
public hide() {
this.window.hide();
}
/** /**
* Get the time (in milliseconds) spent loading the page. * Get the time (in milliseconds) spent loading the page.
* *

View File

@ -1,4 +1,12 @@
import { app, ipcMain, IpcMainEvent, remote } from 'electron'; import {
app,
ipcMain,
IpcMainEvent,
remote,
Tray,
Menu,
dialog
} from 'electron';
import * as path from 'path'; import * as path from 'path';
import * as url from 'url'; import * as url from 'url';
import * as fse from 'fs-extra'; import * as fse from 'fs-extra';
@ -12,7 +20,9 @@ import {
UpdaterChannel, UpdaterChannel,
FileChannel, FileChannel,
IdleStateChannel, IdleStateChannel,
NotificationChannel NotificationChannel,
ChatChannel,
MessengerChannel
} from '@ucap-webmessenger/native-electron'; } from '@ucap-webmessenger/native-electron';
import { ElectronNotificationService } from '@ucap-webmessenger/electron-notification'; import { ElectronNotificationService } from '@ucap-webmessenger/electron-notification';
@ -24,7 +34,12 @@ import { IdleChecker } from './lib/idle-checker';
import { NotificationRequest } from '@ucap-webmessenger/native'; import { NotificationRequest } from '@ucap-webmessenger/native';
import { ElectronAppChannel } from '@ucap-webmessenger/electron-core'; import { ElectronAppChannel } from '@ucap-webmessenger/electron-core';
const appIconPath = __LINUX__
? path.join(__dirname, 'static', 'icon-logo.png')
: path.join(__dirname, 'resources/image', 'ico_64_64.png');
let appWindow: AppWindow | null = null; let appWindow: AppWindow | null = null;
let appTray: Tray | null = null;
const launchTime = now(); const launchTime = now();
let readyTime: number | null = null; let readyTime: number | null = null;
@ -90,7 +105,7 @@ if (isDuplicateInstance) {
} }
function createWindow() { function createWindow() {
const window = new AppWindow(); const window = new AppWindow(appIconPath);
if (__DEV__) { if (__DEV__) {
// const { // const {
@ -142,6 +157,48 @@ function createWindow() {
appWindow = window; appWindow = window;
} }
function createTray() {
appTray = new Tray(appIconPath);
const contextMenu = Menu.buildFromTemplate([
{
label: '로그아웃',
// accelerator: 'Q',
// selector: 'terminate:',
click: () => {
appWindow.show();
appWindow.browserWindow.webContents.send(MessengerChannel.Logout);
}
},
{
label: '설정',
// accelerator: 'Q',
// selector: 'terminate:',
click: () => {
appWindow.show();
appWindow.browserWindow.webContents.send(MessengerChannel.ShowSetting);
}
},
{ label: '버전', submenu: [{ label: 'Ver. ' + app.getVersion() }] },
{
label: '종료',
// accelerator: 'Q',
// selector: 'terminate:',
click: () => {
// 메신저에 로그아웃 후 종료
appWindow = null;
app.exit();
}
}
]);
appTray.setToolTip('UCapMessenger');
appTray.setContextMenu(contextMenu);
appTray.on('click', () => {
appWindow.isVisible() ? appWindow.hide() : appWindow.show();
});
}
// This method will be called when Electron has finished // This method will be called when Electron has finished
// initialization and is ready to create browser windows. // initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs. // Some APIs can only be used after this event occurs.
@ -154,10 +211,12 @@ app.on(ElectronAppChannel.Ready, () => {
createWindow(); createWindow();
createTray();
notificationService = new ElectronNotificationService({ notificationService = new ElectronNotificationService({
width: 340, width: 340,
height: 100, height: 100,
padding: 10, padding: 0,
borderRadius: 0, borderRadius: 0,
// appIcon: iconPath, // appIcon: iconPath,
displayTime: 5000, displayTime: 5000,
@ -240,8 +299,9 @@ ipcMain.on(
try { try {
const buffer: Buffer = args[0]; const buffer: Buffer = args[0];
const fileName: string = args[1]; const fileName: string = args[1];
const mimeType: string = args[2];
let savePath: string = path.join( let savePath: string = path.join(
!!args[2] ? args[2] : DefaultFolder.downloads(), !!args[3] ? args[3] : DefaultFolder.downloads(),
fileName fileName
); );
savePath = await FileUtil.uniqueFileName(savePath); savePath = await FileUtil.uniqueFileName(savePath);
@ -289,12 +349,15 @@ ipcMain.on(
'resources/notification/sound/messageAlarm.mp3' 'resources/notification/sound/messageAlarm.mp3'
) )
: '', : '',
onClick: () => { onClick: e => {
console.log('onClick'); appWindow.browserWindow.webContents.send(
ChatChannel.OpenRoom,
noti.roomSeq
);
appWindow.show();
e.close();
} }
}); });
console.log('Channel.notify', noti);
} }
); );

View File

@ -51,11 +51,9 @@ export class IdleChecker {
// global.opt_idleTimeLimit = limitedMin; // global.opt_idleTimeLimit = limitedMin;
this.startChecker(); this.startChecker();
console.log('RESET IDLE TIMER in ' + limitedMin + 'm');
} }
public startChecker() { public startChecker() {
console.log('Idle Checker Start');
if (!this.intervalObject) { if (!this.intervalObject) {
this.intervalObject = setInterval(() => { this.intervalObject = setInterval(() => {
this.doCheckIdle(); this.doCheckIdle();
@ -64,7 +62,6 @@ export class IdleChecker {
} }
public destoryChecker() { public destoryChecker() {
console.log('Idle Checker Destory');
if (!!this.intervalObject) { if (!!this.intervalObject) {
clearInterval(this.intervalObject); clearInterval(this.intervalObject);
} }

View File

@ -1,7 +1,7 @@
{ {
"compilerOptions": { "compilerOptions": {
"baseUrl": "./", "baseUrl": "./",
"outDir": "../dist/main", "outDir": "../../dist/main",
"sourceMap": true, "sourceMap": true,
"declaration": false, "declaration": false,
"module": "commonjs", "module": "commonjs",
@ -14,19 +14,24 @@
"lib": ["es2017", "es2016", "es2015", "dom"], "lib": ["es2017", "es2016", "es2015", "dom"],
"paths": { "paths": {
"@ucap-webmessenger/electron-core": [ "@ucap-webmessenger/electron-core": [
"../projects/ucap-webmessenger-electron-core/src/public-api" "../ucap-webmessenger-electron-core/src/public-api"
], ],
"@ucap-webmessenger/electron-notification": [ "@ucap-webmessenger/electron-notification": [
"../projects/ucap-webmessenger-electron-notification/src/public-api" "../ucap-webmessenger-electron-notification/src/public-api"
],
"@ucap-webmessenger/core": [
"../../projects/ucap-webmessenger-core/src/public-api"
], ],
"@ucap-webmessenger/native": [ "@ucap-webmessenger/native": [
"../projects/ucap-webmessenger-native/src/public-api" "../../projects/ucap-webmessenger-native/src/public-api"
], ],
"@ucap-webmessenger/native-electron": [ "@ucap-webmessenger/native-electron": [
"../projects/ucap-webmessenger-native-electron/src/public-api" "../../projects/ucap-webmessenger-native-electron/src/public-api"
],
"@ucap-webmessenger/electron": [
"../../projects/ucap-webmessenger-electron/src/public-api"
] ]
} }
}, },
"exclude": ["../../node_modules", "**/*.spec.ts"]
"exclude": ["../node_modules", "**/*.spec.ts"]
} }

View File

@ -0,0 +1,7 @@
{
"extends": "../../tslint.json",
"rules": {
"directive-selector": [true, "attribute", "ucapElectron", "camelCase"],
"component-selector": [true, "element", "ucap-electron", "kebab-case"]
}
}

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.8 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 504 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 7.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 897 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 117 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 105 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.9 KiB

896
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -2,21 +2,31 @@
"name": "ucap-webmessenger", "name": "ucap-webmessenger",
"version": "0.0.0", "version": "0.0.0",
"scripts": { "scripts": {
"postinstall": "electron-builder install-app-deps",
"ng": "ng", "ng": "ng",
"start": "npm-run-all -p start:renderer start:main", "start": "npm-run-all -p start:renderer start:main",
"start:main": "wait-on http-get://localhost:4200/ && npm run build:main:dev && electron --nolazy --inspect-brk=9229 .", "start:main": "wait-on http-get://localhost:4200/ && npm run build:main:development && electron --nolazy --inspect-brk=9229 .",
"start:renderer": "ng serve", "start:renderer": "cross-env UCAP_ENV_RUNTIME=ELECTRON ng serve -c renderer-development",
"start:web": "cross-env UCAP_ENV=WEB ng serve", "start:browser": "cross-env UCAP_ENV_RUNTIME=BROWSER ng serve -c browser-development -o",
"start:production": "npm run build:renderer && npm run build:main:prod && electron --nolazy --inspect-brk=9229 .", "build": "npm-run-all -p build:renderer build:main:production",
"build:renderer": "cross-env NODE_ENV=production ng build --base-href ./", "build:renderer": "cross-env NODE_ENV=production ng build -c renderer-development --base-href ./",
"build:main:dev": "cross-env NODE_ENV=development TS_NODE_PROJECT='./config/tsconfig.webpack.json' parallel-webpack --config=config/main.webpack.config.ts", "build:browser": "cross-env UCAP_ENV_RUNTIME=BROWSER ng build -c browser-development --base-href ./NextMessenger_POC",
"build:main:prod": "cross-env NODE_ENV=production TS_NODE_PROJECT='./config/tsconfig.webpack.json' NODE_OPTIONS='--max_old_space_size=4096' parallel-webpack --config=config/main.webpack.config.ts", "build:main:development": "cross-env NODE_ENV=development TS_NODE_PROJECT='./config/tsconfig.webpack.json' parallel-webpack --config=config/main.webpack.config.ts",
"build:main:production": "cross-env NODE_ENV=production TS_NODE_PROJECT='./config/tsconfig.webpack.json' NODE_OPTIONS='--max_old_space_size=4096' parallel-webpack --config=config/main.webpack.config.ts",
"electron:local": "electron .",
"electron:windows": "npm run build && electron-builder build --windows",
"electron:mac": "npm run build && electron-builder build --mac",
"electron:linux": "npm run build && electron-builder build --linux",
"test": "ng test", "test": "ng test",
"lint": "ng lint", "lint": "ng lint",
"e2e": "ng e2e" "e2e": "ng e2e"
}, },
"private": true, "private": true,
"dependencies": { "dependencies": {
"@angular/core": "~8.2.12",
"electron-window-state": "^5.0.3",
"fs-extra": "^8.1.0",
"rxjs": "^6.5.2",
"tslib": "^1.10.0" "tslib": "^1.10.0"
}, },
"devDependencies": { "devDependencies": {
@ -29,7 +39,6 @@
"@angular/common": "~8.2.12", "@angular/common": "~8.2.12",
"@angular/compiler": "~8.2.12", "@angular/compiler": "~8.2.12",
"@angular/compiler-cli": "~8.2.12", "@angular/compiler-cli": "~8.2.12",
"@angular/core": "~8.2.12",
"@angular/flex-layout": "^8.0.0-beta.27", "@angular/flex-layout": "^8.0.0-beta.27",
"@angular/forms": "~8.2.12", "@angular/forms": "~8.2.12",
"@angular/language-service": "~8.2.12", "@angular/language-service": "~8.2.12",
@ -60,8 +69,11 @@
"@types/webpack": "^4.39.5", "@types/webpack": "^4.39.5",
"@types/webpack-merge": "^4.1.5", "@types/webpack-merge": "^4.1.5",
"@types/webpack-node-externals": "^1.6.3", "@types/webpack-node-externals": "^1.6.3",
"angular-split": "^3.0.2",
"autolinker": "^3.11.1",
"awesome-node-loader": "^1.1.1", "awesome-node-loader": "^1.1.1",
"awesome-typescript-loader": "^5.2.1", "awesome-typescript-loader": "^5.2.1",
"classlist.js": "^1.1.20150312",
"clean-webpack-plugin": "^3.0.0", "clean-webpack-plugin": "^3.0.0",
"copy-webpack-plugin": "^5.0.4", "copy-webpack-plugin": "^5.0.4",
"codelyzer": "^5.0.0", "codelyzer": "^5.0.0",
@ -70,17 +82,15 @@
"cross-env": "^5.2.1", "cross-env": "^5.2.1",
"detect-browser": "^4.6.0", "detect-browser": "^4.6.0",
"devtron": "^1.4.0", "devtron": "^1.4.0",
"electron": "^6.1.2", "electron": "^7.1.1",
"electron-builder": "^21.2.0", "electron-builder": "^21.2.0",
"electron-debug": "^3.0.1", "electron-debug": "^3.0.1",
"electron-devtools-installer": "^2.2.4", "electron-devtools-installer": "^2.2.4",
"electron-log": "^3.0.8", "electron-log": "^3.0.9",
"electron-reload": "^1.5.0", "electron-reload": "^1.5.0",
"electron-store": "^4.0.0", "electron-store": "^5.1.0",
"electron-updater": "^4.1.2", "electron-updater": "^4.2.0",
"electron-window-state": "^5.0.3",
"file-saver": "^2.0.2", "file-saver": "^2.0.2",
"fs-extra": "^8.1.0",
"filesize": "^4.1.2", "filesize": "^4.1.2",
"hammerjs": "^2.0.8", "hammerjs": "^2.0.8",
"jasmine-core": "~3.4.0", "jasmine-core": "~3.4.0",
@ -95,11 +105,11 @@
"ngrx-store-freeze": "^0.2.4", "ngrx-store-freeze": "^0.2.4",
"ngx-logger": "^4.0.5", "ngx-logger": "^4.0.5",
"ngx-perfect-scrollbar": "^8.0.0", "ngx-perfect-scrollbar": "^8.0.0",
"rimraf": "^3.0.0",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"parallel-webpack": "^2.4.0", "parallel-webpack": "^2.4.0",
"protractor": "~5.4.0", "protractor": "~5.4.0",
"queueing-subject": "^0.3.4", "queueing-subject": "^0.3.4",
"rxjs": "^6.5.2",
"semver": "^6.3.0", "semver": "^6.3.0",
"ts-node": "~7.0.0", "ts-node": "~7.0.0",
"tsickle": "^0.37.0", "tsickle": "^0.37.0",
@ -107,10 +117,11 @@
"tslint": "~5.15.0", "tslint": "~5.15.0",
"typescript": "~3.5.3", "typescript": "~3.5.3",
"wait-on": "^3.3.0", "wait-on": "^3.3.0",
"web-animations-js": "^2.3.2",
"webpack": "4.39.2", "webpack": "4.39.2",
"webpack-cli": "^3.3.7", "webpack-cli": "^3.3.7",
"webpack-node-externals": "^1.7.2", "webpack-node-externals": "^1.7.2",
"zone.js": "~0.9.1" "zone.js": "~0.9.1"
}, },
"main": "./dist/main/main.js" "main": "./dist/ucap-webmessenger-electron/main.js"
} }

View File

@ -0,0 +1,7 @@
import { ModuleConfig as CoreModuleConfig } from '@ucap-webmessenger/core';
import { Urls } from './urls';
export interface ModuleConfig extends CoreModuleConfig<Urls> {
acceptableFileExtensions: string[];
}

Some files were not shown because too many files have changed in this diff Show More