added chat worker prod bundle

This commit is contained in:
Rohan Sircar 2020-07-26 12:41:57 +05:30
parent ecfcecb53c
commit 3eb617f272
7 changed files with 27 additions and 12 deletions

2
.gitignore vendored
View File

@ -36,6 +36,8 @@ bundle.min.js
adminBundle.js adminBundle.js
adminBundle.min.js adminBundle.min.js
worker.js worker.js
chatWorker.js
chatWorker.min.js
node node
src/main/javascript/node/ src/main/javascript/node/
dist dist

View File

@ -13,8 +13,8 @@ module.exports = function (grunt) {
dest: "src/main/resources/static/js/bundle.min.js", dest: "src/main/resources/static/js/bundle.min.js",
}, },
chat_worker: { chat_worker: {
src: "src/main/resources/static/js/worker.js", src: "src/main/resources/static/js/chatWorker.js",
dest: "src/main/resources/static/js/worker.js", dest: "src/main/resources/static/js/chatWorker.min.js",
}, },
admin_bundle: { admin_bundle: {
src: "src/main/resources/static/js/adminBundle.js", src: "src/main/resources/static/js/adminBundle.js",
@ -22,24 +22,26 @@ module.exports = function (grunt) {
}, },
}, },
banner: dedent(` banner: dedent(`
/*
* ----------------------------------------- * -----------------------------------------
* @date <%= grunt.template.today("yyyy-mm-dd") %> * @date <%= grunt.template.today("yyyy-mm-dd") %>
* @project Chatto * @project Chatto
* @author nova * @author nova
* @license GPL * @license GPL
* ----------------------------------------- * -----------------------------------------
*/
`), `),
usebanner: { usebanner: {
dist: { dist: {
options: { options: {
position: "top", position: "top",
banner: "/*! \n<%= banner %> */ ", banner: "<%= banner %>",
}, },
files: { files: {
src: [ src: [
"src/main/resources/static/js/bundle.min.js", "src/main/resources/static/js/bundle.min.js",
"src/main/resources/static/js/adminBundle.min.js", "src/main/resources/static/js/adminBundle.min.js",
"src/main/resources/static/js/worker.js", "src/main/resources/static/js/chatWorker.min.js",
], ],
}, },
}, },
@ -47,7 +49,7 @@ module.exports = function (grunt) {
browserify: { browserify: {
chat_worker_dev: { chat_worker_dev: {
src: "src/main/frontend/workers/encryption-worker/main.ts", src: "src/main/frontend/workers/encryption-worker/main.ts",
dest: "src/main/resources/static/js/worker.js", dest: "src/main/resources/static/js/chatWorker.js",
options: { options: {
browserifyOptions: { browserifyOptions: {
debug: true, debug: true,
@ -75,7 +77,7 @@ module.exports = function (grunt) {
}, },
chat_worker_prod: { chat_worker_prod: {
src: "src/main/frontend/workers/encryption-worker/main.ts", src: "src/main/frontend/workers/encryption-worker/main.ts",
dest: "src/main/resources/static/js/worker.js", dest: "src/main/resources/static/js/chatWorker.js",
}, },
admin_bundle_dev: { admin_bundle_dev: {
src: "src/main/frontend/admin/main.ts", src: "src/main/frontend/admin/main.ts",

View File

@ -4,9 +4,13 @@ import { SJCLEncryptionService } from "./SJCLEncryptionService";
import PromiseWorker from "promise-worker"; import PromiseWorker from "promise-worker";
export class EncryptionServiceFactory { export class EncryptionServiceFactory {
private static readonly _worker = new Worker('/js/worker.js'); private static readonly _worker = new Worker(
private static readonly _promiseWorker = new PromiseWorker(EncryptionServiceFactory._worker); localStorage.getItem("CHAT_WORKER_BUNDLE") || "chat-worker-error.js"
public static getEncryptionService(): EncryptionService { );
return new SJCLEncryptionService(this._promiseWorker) private static readonly _promiseWorker = new PromiseWorker(
} EncryptionServiceFactory._worker
);
public static getEncryptionService(): EncryptionService {
return new SJCLEncryptionService(this._promiseWorker);
}
} }

View File

@ -7,4 +7,5 @@ spring.http.log-request-details=false
logging.level.org.springframework.cache = INFO logging.level.org.springframework.cache = INFO
chat-bundle=bundle.min.js chat-bundle=bundle.min.js
admin-bundle=adminBundle.min.js admin-bundle=adminBundle.min.js
chat-worker-bundle=chatWorker.min.js
chatto.frontend.log-level=INFO chatto.frontend.log-level=INFO

View File

@ -29,6 +29,7 @@ logging.level.org.springframework.cache=DEBUG
chatto.token.timeout-duration=30 chatto.token.timeout-duration=30
chat-bundle=bundle.js chat-bundle=bundle.js
admin-bundle=adminBundle.js admin-bundle=adminBundle.js
chat-worker-bundle=chatWorker.js
# spring.devtools.add-properties=false # spring.devtools.add-properties=false
chatto.frontend.log-level=TRACE chatto.frontend.log-level=TRACE
chatto.frontend.chat-page-size=9 chatto.frontend.chat-page-size=9

View File

@ -13,6 +13,8 @@
</div> </div>
<script src="./../../javascript/bundle.js" th:src="@{'/js/' + ${@environment.getProperty('chat-bundle')}}" <script src="./../../javascript/bundle.js" th:src="@{'/js/' + ${@environment.getProperty('chat-bundle')}}"
defer></script> defer></script>
<script src="./../../javascript/bundle.js" th:src="@{'/js/' + ${@environment.getProperty('chat-worker-bundle')}}"
defer></script>
<link rel="stylesheet" th:href="@{/css/chat.css}" href="../../resources/static/css/chat.css"> <link rel="stylesheet" th:href="@{/css/chat.css}" href="../../resources/static/css/chat.css">
</head> </head>

View File

@ -64,6 +64,9 @@
let loglevel = /*[[${@environment.getProperty('chatto.frontend.log-level')}]]*/ "DEBUG"; let loglevel = /*[[${@environment.getProperty('chatto.frontend.log-level')}]]*/ "DEBUG";
window.log.setLevel(loglevel) window.log.setLevel(loglevel)
let chatWorkerBundle = /*[[${@environment.getProperty('chat-worker-bundle')}]]*/ "chatWorker.js";
localStorage.setItem('CHAT_WORKER_BUNDLE', "/js/" + chatWorkerBundle)
let chatPageSize = /*[[${@environment.getProperty('chatto.frontend.chat-page-size')}]]*/ 9; let chatPageSize = /*[[${@environment.getProperty('chatto.frontend.chat-page-size')}]]*/ 9;
localStorage.setItem("CHAT_PAGE_SIZE", chatPageSize); localStorage.setItem("CHAT_PAGE_SIZE", chatPageSize);
</script> </script>