diff --git a/Gruntfile.js b/Gruntfile.js index a7f39370..888b000d 100644 --- a/Gruntfile.js +++ b/Gruntfile.js @@ -15,7 +15,7 @@ }, dist: { files: { - 'dist/css/app.css': 'scss/app.scss', + 'dist/ui/css/app.css': 'scss/app.scss', }, }, }, @@ -25,7 +25,7 @@ }, target: { files: { - 'dist/css/app.min.css': ['dist/css/app.css'], + 'dist/ui/css/app.min.css': ['dist/ui/css/app.css'], }, }, }, diff --git a/package-lock.json b/package-lock.json index 42550304..d775cc50 100644 --- a/package-lock.json +++ b/package-lock.json @@ -525,6 +525,21 @@ "integrity": "sha512-7EJYyKTL7tFR8+gDbB6Wwz/arpGa0Mywk1TJbNzKzHtzbwVmY4HR9WqS5VV7dsBUKQmPNr192jHr/VpBluj/hg==", "dev": true }, + "@types/yargs": { + "version": "15.0.12", + "resolved": "https://registry.npmjs.org/@types/yargs/-/yargs-15.0.12.tgz", + "integrity": "sha512-f+fD/fQAo3BCbCDlrUpznF1A5Zp9rB0noS5vnoormHSIPFKL0Z2DcUJ3Gxp5ytH4uLRNxy7AwYUC9exZzqGMAw==", + "dev": true, + "requires": { + "@types/yargs-parser": "*" + } + }, + "@types/yargs-parser": { + "version": "20.2.0", + "resolved": "https://registry.npmjs.org/@types/yargs-parser/-/yargs-parser-20.2.0.tgz", + "integrity": "sha512-37RSHht+gzzgYeobbG+KWryeAW8J33Nhr69cjTqSYymXVZEN9NbRYWoYlRtDhHKPVT1FyNKwaTPC1NynKZpzRA==", + "dev": true + }, "@types/yauzl": { "version": "2.9.1", "resolved": "https://registry.npmjs.org/@types/yauzl/-/yauzl-2.9.1.tgz", @@ -3493,6 +3508,47 @@ "yargs": "^15.0.1" }, "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + }, + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "requires": { + "color-convert": "^2.0.1" + } + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" + }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + }, "debug": { "version": "4.3.1", "resolved": "https://registry.npmjs.org/debug/-/debug-4.3.1.tgz", @@ -3500,6 +3556,101 @@ "requires": { "ms": "2.1.2" } + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } }, @@ -3773,6 +3924,12 @@ "dev": true, "optional": true }, + "escalade": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz", + "integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==", + "dev": true + }, "escape-string-regexp": { "version": "1.0.5", "resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-1.0.5.tgz", @@ -9163,6 +9320,18 @@ "yargs": "^15.3.1" }, "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, "chalk": { "version": "2.4.2", "resolved": "https://registry.npmjs.org/chalk/-/chalk-2.4.2.tgz", @@ -9174,6 +9343,38 @@ "supports-color": "^5.3.0" } }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, "figures": { "version": "3.2.0", "resolved": "https://registry.npmjs.org/figures/-/figures-3.2.0.tgz", @@ -9199,6 +9400,12 @@ "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", "dev": true }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, "locate-path": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz", @@ -9241,6 +9448,26 @@ "lru-cache": "^6.0.0" } }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, "supports-color": { "version": "5.5.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-5.5.0.tgz", @@ -9249,6 +9476,96 @@ "requires": { "has-flag": "^3.0.0" } + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + } + } + }, + "yargs": { + "version": "15.4.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", + "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.2" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "requires": { + "p-try": "^2.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + } + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } } } }, @@ -10143,50 +10460,51 @@ "dev": true }, "yargs": { - "version": "15.4.1", - "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.4.1.tgz", - "integrity": "sha512-aePbxDmcYW++PaqBsJ+HYUFwCdv4LVvdnhBy78E57PIor8/OVvhMrADFFEDh8DHDFRv/O9i3lPhsENjO7QX0+A==", - "requires": { - "cliui": "^6.0.0", - "decamelize": "^1.2.0", - "find-up": "^4.1.0", - "get-caller-file": "^2.0.1", + "version": "16.2.0", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz", + "integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==", + "dev": true, + "requires": { + "cliui": "^7.0.2", + "escalade": "^3.1.1", + "get-caller-file": "^2.0.5", "require-directory": "^2.1.1", - "require-main-filename": "^2.0.0", - "set-blocking": "^2.0.0", "string-width": "^4.2.0", - "which-module": "^2.0.0", - "y18n": "^4.0.0", - "yargs-parser": "^18.1.2" + "y18n": "^5.0.5", + "yargs-parser": "^20.2.2" }, "dependencies": { "ansi-regex": { "version": "5.0.0", "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", - "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==" + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true }, "ansi-styles": { "version": "4.3.0", "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, "requires": { "color-convert": "^2.0.1" } }, "cliui": { - "version": "6.0.0", - "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", - "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "version": "7.0.4", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz", + "integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==", + "dev": true, "requires": { "string-width": "^4.2.0", "strip-ansi": "^6.0.0", - "wrap-ansi": "^6.2.0" + "wrap-ansi": "^7.0.0" } }, "color-convert": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, "requires": { "color-name": "~1.1.4" } @@ -10194,52 +10512,26 @@ "color-name": { "version": "1.1.4", "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", - "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==" + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true }, "emoji-regex": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", - "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==" - }, - "find-up": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", - "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", - "requires": { - "locate-path": "^5.0.0", - "path-exists": "^4.0.0" - } + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true }, "is-fullwidth-code-point": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", - "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" - }, - "locate-path": { - "version": "5.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", - "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", - "requires": { - "p-locate": "^4.1.0" - } - }, - "p-locate": { - "version": "4.1.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", - "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", - "requires": { - "p-limit": "^2.2.0" - } - }, - "path-exists": { - "version": "4.0.0", - "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", - "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==" + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true }, "string-width": { "version": "4.2.0", "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, "requires": { "emoji-regex": "^8.0.0", "is-fullwidth-code-point": "^3.0.0", @@ -10250,37 +10542,35 @@ "version": "6.0.0", "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, "requires": { "ansi-regex": "^5.0.0" } }, "wrap-ansi": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", - "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "version": "7.0.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz", + "integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==", + "dev": true, "requires": { "ansi-styles": "^4.0.0", "string-width": "^4.1.0", "strip-ansi": "^6.0.0" } + }, + "y18n": { + "version": "5.0.5", + "resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.5.tgz", + "integrity": "sha512-hsRUr4FFrvhhRH12wOdfs38Gy7k2FFzB9qgN9v3aLykRq0dRcdcpz5C9FxdS2NuhOrI/628b/KSTJ3rwHysYSg==", + "dev": true } } }, "yargs-parser": { - "version": "18.1.3", - "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", - "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", - "requires": { - "camelcase": "^5.0.0", - "decamelize": "^1.2.0" - }, - "dependencies": { - "camelcase": { - "version": "5.3.1", - "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", - "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==" - } - } + "version": "20.2.4", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz", + "integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==", + "dev": true }, "yauzl": { "version": "2.10.0", diff --git a/package.json b/package.json index fab97fab..bb3a9f24 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,7 @@ "repository": "https://github.com/kunalnagar/encrypt0r", "license": "MIT", "author": "Kunal Nagar ", - "main": "src/main.js", + "main": "dist/electron/main.js", "scripts": { "prebuild": "rm -rf dist", "build": "npm run build:tsc && npm run build:copy && npm run build-grunt && npm run build-mac-x64 && npm run build-win-x86 && npm run build-win-x64 && npm run build-linux-x64 && npm run build-linux-deb", @@ -25,11 +25,11 @@ "build-mac-x64": "electron-packager . --overwrite --platform=darwin --arch=x64 --icon=assets/icons/icon.icns --prune=true --out=release-builds", "build-win-x64": "electron-packager . --overwrite --asar --platform=win32 --arch=x64 --icon=assets/icons/icon.ico --prune=true --out=release-builds", "build-win-x86": "electron-packager . --overwrite --asar --platform=win32 --arch=ia32 --icon=assets/icons/icon.ico --prune=true --out=release-builds", - "build:copy": "cp src/index.html dist/", + "build:copy": "cp src/ui/index.html dist/ui/", "build:tsc": "tsc", "build:tsc:watch": "tsc --watch", "deploy": "sh ./scripts/deploy.sh", - "dev": "npm run prebuild && npm run build:tsc && npm run build:copy && npm run build-grunt && electron dist/main.js & npm run build:tsc:watch & grunt watch", + "dev": "npm run prebuild && npm run build:tsc && npm run build:copy && npm run build-grunt && electron . & npm run build:tsc:watch & grunt watch", "lint": "eslint src/ --ext .ts --max-warnings 0", "lint:fix": "eslint --fix src/ --ext .ts --max-warnings 0", "release": "npm run prebuild && npm run build:tsc && npm run build:copy && npm run build-grunt && npm run build-mac-x64 && npm run zip-mac-x64 && npm run build-win-x86 && npm run zip-win-x86 && npm run build-win-x64 && npm run zip-win-x64 && npm run build-linux-x64 && npm run zip-linux-x64 && npm run build-linux-deb && npm run zip-linux-deb", @@ -67,6 +67,7 @@ "@babel/eslint-parser": "^7.12.1", "@types/jquery": "^3.5.5", "@types/node": "^14.14.19", + "@types/yargs": "^15.0.12", "@typescript-eslint/eslint-plugin": "^4.11.1", "@typescript-eslint/parser": "^4.11.1", "electron": "^11.1.1", @@ -89,6 +90,7 @@ "sort-package-json": "^1.48.0", "standard-version": "^9.1.0", "time-grunt": "^2.0.0", - "typescript": "^4.1.3" + "typescript": "^4.1.3", + "yargs": "^16.2.0" } } diff --git a/src/Crypto.ts b/src/business-logic/Crypto.ts similarity index 65% rename from src/Crypto.ts rename to src/business-logic/Crypto.ts index d342b368..1d1a2ed7 100644 --- a/src/Crypto.ts +++ b/src/business-logic/Crypto.ts @@ -1,15 +1,21 @@ import { EventEmitter } from 'events'; import { ReadStream, WriteStream } from 'fs'; +import { pipeline } from 'stream'; -import { getCipher, getDecipher } from './utils/cipher'; -import { compress, decompress } from './utils/compress'; -import { getFileSize } from './utils/file-size'; +import { + EVENT_DESTINATION_STREAM_FINISH, + EVENT_NOTICE, + EVENT_SOURCE_STREAM_PROGRESS, +} from '../constants'; +import { getCipher, getDecipher } from './helpers/cipher'; +import { compress, decompress } from './helpers/compress'; +import { getFileSize } from './helpers/file-size'; import { getInitializationVector, getInitializationVectorStream, -} from './utils/initialization-vector'; -import { calculateProgress } from './utils/progress'; -import { getDestinationStream, getSourceStream } from './utils/stream'; +} from './helpers/initialization-vector'; +import { calculateProgress } from './helpers/progress'; +import { getDestinationStream, getSourceStream } from './helpers/stream'; export interface ICrypto extends EventEmitter { encrypt(): void; @@ -40,11 +46,19 @@ export default class Crypto extends EventEmitter implements ICrypto { const cipher = getCipher(this._passphrase, initializationVector); const sourceStream = getSourceStream(this._sourceFilePath); const destinationStream = getDestinationStream(this._destinationFilePath); - sourceStream - .pipe(compress()) - .pipe(cipher) - .pipe(initializationVectorStream) - .pipe(destinationStream); + pipeline( + sourceStream, + compress(), + cipher, + initializationVectorStream, + destinationStream, + (err) => { + if (err) { + console.error(err); + this.emit(EVENT_NOTICE, 'Oops! Something went wrong!'); + } + }, + ); this._handleSourceStream(sourceStream); this._handleDestinationStream(destinationStream); } @@ -60,7 +74,18 @@ export default class Crypto extends EventEmitter implements ICrypto { initializationVectorStream.on('data', (chunk) => { const initializationVector = chunk as Buffer; const decipher = getDecipher(this._passphrase, initializationVector); - sourceStream.pipe(decipher).pipe(decompress()).pipe(destinationStream); + pipeline( + sourceStream, + decipher, + decompress(), + destinationStream, + (err) => { + if (err) { + console.error(err); + this.emit(EVENT_NOTICE, 'Oops! Something went wrong!'); + } + }, + ); }); this._handleSourceStream(sourceStream); this._handleDestinationStream(destinationStream); @@ -72,7 +97,7 @@ export default class Crypto extends EventEmitter implements ICrypto { sourceStream.on('data', (chunk) => { currentSize += chunk.length; this.emit( - 'crypto:source_stream:progress', + EVENT_SOURCE_STREAM_PROGRESS, calculateProgress(currentSize, totalSize), ); }); @@ -80,7 +105,7 @@ export default class Crypto extends EventEmitter implements ICrypto { private _handleDestinationStream(destinationStream: WriteStream) { destinationStream.on('finish', () => { - this.emit('crypto:destination_stream:finish'); + this.emit(EVENT_DESTINATION_STREAM_FINISH); }); } } diff --git a/src/utils/cipher.ts b/src/business-logic/helpers/cipher.ts similarity index 100% rename from src/utils/cipher.ts rename to src/business-logic/helpers/cipher.ts diff --git a/src/utils/compress.ts b/src/business-logic/helpers/compress.ts similarity index 100% rename from src/utils/compress.ts rename to src/business-logic/helpers/compress.ts diff --git a/src/utils/file-size.ts b/src/business-logic/helpers/file-size.ts similarity index 100% rename from src/utils/file-size.ts rename to src/business-logic/helpers/file-size.ts diff --git a/src/utils/initialization-vector.ts b/src/business-logic/helpers/initialization-vector.ts similarity index 100% rename from src/utils/initialization-vector.ts rename to src/business-logic/helpers/initialization-vector.ts diff --git a/src/utils/progress.ts b/src/business-logic/helpers/progress.ts similarity index 100% rename from src/utils/progress.ts rename to src/business-logic/helpers/progress.ts diff --git a/src/utils/stream.ts b/src/business-logic/helpers/stream.ts similarity index 100% rename from src/utils/stream.ts rename to src/business-logic/helpers/stream.ts diff --git a/src/utils/vector.ts b/src/business-logic/helpers/vector.ts similarity index 100% rename from src/utils/vector.ts rename to src/business-logic/helpers/vector.ts diff --git a/src/constants.ts b/src/constants.ts new file mode 100644 index 00000000..f87c6646 --- /dev/null +++ b/src/constants.ts @@ -0,0 +1,8 @@ +export const EVENT_LOG = 'encrypt0r:log'; +export const EVENT_ENCRYPT = 'encrypt0r:encrypt'; +export const EVENT_DECRYPT = 'encrypt0r:decrypt'; +export const EVENT_RESET = 'encrypt0r:reset'; +export const EVENT_NOTICE = 'encrypt0r:notice'; +export const EVENT_SOURCE_STREAM_PROGRESS = 'encrypt0r:source_stream:progress'; +export const EVENT_DESTINATION_STREAM_FINISH = + 'encrypt0r:destination_stream:progress'; diff --git a/src/electron/main.ts b/src/electron/main.ts new file mode 100644 index 00000000..a4b61d05 --- /dev/null +++ b/src/electron/main.ts @@ -0,0 +1,102 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { app, BrowserWindow, dialog, ipcMain } from 'electron'; +import { IpcMainEvent } from 'electron/main'; +import log from 'electron-log'; +import path from 'path'; + +import Crypto from '../business-logic/Crypto'; +import { + EVENT_DECRYPT, + EVENT_DESTINATION_STREAM_FINISH, + EVENT_ENCRYPT, + EVENT_LOG, + EVENT_NOTICE, + EVENT_SOURCE_STREAM_PROGRESS, +} from '../constants'; + +const createWindow = (): BrowserWindow => { + let mainWindow: BrowserWindow | null = new BrowserWindow({ + width: 600, + height: 600, + webPreferences: { + devTools: true, + nodeIntegration: true, + }, + icon: path.join('../../assets/icons/png/64x64.png'), + }); + mainWindow.loadFile('dist/ui/index.html'); + mainWindow.on('closed', () => { + mainWindow = null; + }); + return mainWindow; +}; + +const handleMode = async (eventName: string, event: IpcMainEvent, arg: any) => { + const sourceFilePath = arg.filePath as string; + let destinationFilePath = `${arg.filePath as string}`; + const passphrase = arg.passphrase as string; + let verb = ''; + if (eventName === EVENT_ENCRYPT) { + verb = 'Encrypting'; + destinationFilePath += '.enc'; + } else if (eventName === EVENT_DECRYPT) { + verb = 'Decrypting'; + destinationFilePath = destinationFilePath.replace('.enc', ''); + } + const file = await dialog.showSaveDialog({ + defaultPath: destinationFilePath, + }); + if (!file.canceled) { + const crypto = new Crypto( + sourceFilePath, + file.filePath as string, + passphrase, + ); + if (eventName === EVENT_ENCRYPT) { + crypto.encrypt(); + } else { + crypto.decrypt(); + } + crypto.on(EVENT_NOTICE, (data) => { + event.sender.send(EVENT_NOTICE, data); + }); + crypto.on(EVENT_SOURCE_STREAM_PROGRESS, (progress) => { + event.sender.send(EVENT_NOTICE, `${verb}...${progress}%`); + }); + crypto.on(EVENT_DESTINATION_STREAM_FINISH, () => { + event.sender.send( + EVENT_NOTICE, + `Done! File has been saved to: ${file.filePath}`, + ); + }); + } +}; + +app.on('ready', () => { + console.log('ready'); + createWindow(); +}); + +app.on('window-all-closed', () => { + console.log('window-all-closed', process.platform); + if (process.platform === 'darwin') { + app.quit(); + } +}); + +app.on('activate', () => { + console.log('activate'); + createWindow(); +}); + +ipcMain.on(EVENT_LOG, (e, arg) => { + log.debug(arg); +}); + +ipcMain.on(EVENT_ENCRYPT, async (e, arg) => { + handleMode(EVENT_ENCRYPT, e, arg); +}); + +ipcMain.on(EVENT_DECRYPT, async (e, arg) => { + handleMode(EVENT_DECRYPT, e, arg); +}); diff --git a/src/electron/ui-adapter.ts b/src/electron/ui-adapter.ts new file mode 100644 index 00000000..9450574b --- /dev/null +++ b/src/electron/ui-adapter.ts @@ -0,0 +1,27 @@ +/* eslint-disable @typescript-eslint/no-explicit-any */ +import { ipcRenderer } from 'electron'; +import $ from 'jquery'; + +import { + EVENT_DECRYPT, + EVENT_ENCRYPT, + EVENT_LOG, + EVENT_NOTICE, +} from '../constants'; + +const $window = $(window); + +const sendEventToElectron = (eventName: string, data?: any) => + ipcRenderer.send(eventName, data); + +$window.on(EVENT_LOG, (e, data) => sendEventToElectron(EVENT_LOG, data)); +$window.on(EVENT_ENCRYPT, (e, data) => + sendEventToElectron(EVENT_ENCRYPT, data), +); +$window.on(EVENT_DECRYPT, (e, data) => + sendEventToElectron(EVENT_DECRYPT, data), +); + +ipcRenderer.on(EVENT_NOTICE, (e, data) => { + $window.trigger(EVENT_NOTICE, data); +}); diff --git a/src/main.ts b/src/main.ts deleted file mode 100644 index 46c7a574..00000000 --- a/src/main.ts +++ /dev/null @@ -1,112 +0,0 @@ -import { app, BrowserWindow, dialog, ipcMain } from 'electron'; -import log from 'electron-log'; -import path from 'path'; - -import Crypto, { ICrypto } from './Crypto'; - -let mainWindow: BrowserWindow | null; - -function createWindow() { - mainWindow = new BrowserWindow({ - width: 600, - height: 600, - webPreferences: { - nodeIntegration: true, - }, - icon: path.join(__dirname, 'assets/icons/png/64x64.png'), - }); - mainWindow.loadFile('index.html'); - log.info('created main window and loaded main page'); - mainWindow.on('closed', () => { - mainWindow = null; - log.info('closed main window'); - }); -} - -app.on('ready', createWindow); - -app.on('window-all-closed', () => { - if (process.platform !== 'darwin') { - app.quit(); - } -}); - -app.on('activate', () => { - if (mainWindow === null) { - createWindow(); - } -}); - -ipcMain.on('event:log', (e, arg) => { - log.debug(arg); -}); - -ipcMain.on('action:encrypt_decrypt', async (e, arg) => { - log.info('encrypting or decrypting...'); - let popupFileName; - if (arg.action === 'encrypt') { - popupFileName = `${arg.filePath}.enc`; - } else if (arg.action === 'decrypt') { - popupFileName = arg.filePath.replace('.enc', ''); - } - let crypto: ICrypto; - try { - const file = await dialog.showSaveDialog({ - defaultPath: popupFileName, - }); - if (typeof file !== 'undefined') { - crypto = new Crypto( - arg.filePath, - file.filePath as string, - arg.passphrase, - ); - if (arg.action === 'encrypt') { - log.info(`Encrypting ${file.filePath} with password `); - crypto.encrypt(); - crypto.on('crypto:source_stream:progress', (progress) => { - e.sender.send('notice-status', `Encrypting...${progress}%`); - }); - crypto.on('crypto:destination_stream:finish', () => { - log.info('File successfully encrypted!'); - e.sender.send( - 'notice-status', - `Done! File has been saved to: ${file.filePath}`, - ); - }); - } else if (arg.action === 'decrypt') { - log.info(`Decrypting ${file.filePath} with password `); - crypto.decrypt(); - crypto.on('crypto:source_stream:progress', (progress) => { - e.sender.send('notice-status', `Decrypting...${progress}%`); - }); - crypto.on('crypto:destination_stream:finish', () => { - log.info('File successfully decrypted!'); - e.sender.send( - 'notice-status', - `Done! File has been saved to: ${file.filePath}`, - ); - }); - crypto.on('error', (reason) => { - if (reason === 'BAD_DECRYPT') { - e.sender.send( - 'notice-status', - 'Oops. The passphrase is incorrect.', - ); - } - }); - } - } else { - log.warn('Destination file location not selected'); - e.sender.send( - 'notice-status', - 'Oops. Destination file location not selected. Please try again!', - ); - } - } catch (err) { - log.error('Something went wrong', err); - e.sender.send( - 'notice-status', - 'Oops. Something went wrong. Please reset and try again.', - ); - } -}); diff --git a/src/index.html b/src/ui/index.html similarity index 81% rename from src/index.html rename to src/ui/index.html index b40d54a1..d4f8dedc 100644 --- a/src/index.html +++ b/src/ui/index.html @@ -2,7 +2,7 @@ - encrypt0r + encrypt0r - A simple way to encrypt and decrypt your files @@ -36,10 +36,11 @@

Drag file here

- diff --git a/src/renderer.ts b/src/ui/ui.ts similarity index 63% rename from src/renderer.ts rename to src/ui/ui.ts index 18dd9f55..4249753f 100644 --- a/src/renderer.ts +++ b/src/ui/ui.ts @@ -1,10 +1,17 @@ /* eslint-disable @typescript-eslint/ban-ts-comment */ -import { ipcRenderer } from 'electron'; import $ from 'jquery'; +import { + EVENT_DECRYPT, + EVENT_ENCRYPT, + EVENT_LOG, + EVENT_NOTICE, +} from '../constants'; + $(function () { let filePath = ''; + const $window = $(window); const $areaChoices = $('#area_choices'); const $areaDrag = $('#area_drag'); const $filePath = $('#file_path'); @@ -22,16 +29,14 @@ $(function () { $btnReset.show(); $fieldPassphrase.show(); if ($that.attr('id') === 'choice_encrypt') { - ipcRenderer.send('event:log', { - action: 'click', - element: 'choice_encrypt', + $window.trigger(EVENT_LOG, { + message: 'choice_encrypt', }); $btnEncrypt.show(); $btnDecrypt.hide(); } else { - ipcRenderer.send('event:log', { - action: 'click', - element: 'choice_decrypt', + $window.trigger(EVENT_LOG, { + message: 'choice_decrypt', }); $btnEncrypt.hide(); $btnDecrypt.show(); @@ -48,9 +53,8 @@ $(function () { $filePath.empty(); $fieldPassphrase.val('').hide(); filePath = ''; - ipcRenderer.send('event:log', { - action: 'click', - element: 'choice_reset', + $window.trigger(EVENT_LOG, { + message: 'choice_reset', }); }); @@ -62,23 +66,19 @@ $(function () { const file = e.originalEvent.dataTransfer.files[0]; filePath = file.path; $filePath.html(file.path); - ipcRenderer.send('event:log', { - action: 'drag_drop', - filePath: file.path, + $window.trigger(EVENT_LOG, { + message: 'drag_drop', + filePath, }); return false; }); $btnEncrypt.on('click', function () { - if ($fieldPassphrase.val()) { - ipcRenderer.send('event:log', { - action: 'click', - element: 'choice_encrypt', - }); - ipcRenderer.send('action:encrypt_decrypt', { - action: 'encrypt', + const passphrase = $fieldPassphrase.val(); + if (passphrase) { + $window.trigger(EVENT_ENCRYPT, { filePath, - passphrase: $fieldPassphrase.val(), + passphrase, }); } else { $fieldNotice.html('Passphrase is required'); @@ -86,15 +86,11 @@ $(function () { }); $btnDecrypt.on('click', function () { - if ($fieldPassphrase.val()) { - ipcRenderer.send('event:log', { - action: 'click', - element: 'choice_decrypt', - }); - ipcRenderer.send('action:encrypt_decrypt', { - action: 'decrypt', + const passphrase = $fieldPassphrase.val(); + if (passphrase) { + $window.trigger(EVENT_DECRYPT, { filePath, - passphrase: $fieldPassphrase.val(), + passphrase, }); } else { $fieldNotice.html('Passphrase is required'); @@ -106,7 +102,7 @@ $(function () { e.stopPropagation(); }); - ipcRenderer.on('notice-status', (e, notice) => { - $fieldNotice.html(notice); + $window.on(EVENT_NOTICE, (e, data) => { + $fieldNotice.html(data); }); });