From 7b8a273a3ca2c14c229905e56773437478442fb7 Mon Sep 17 00:00:00 2001 From: Adam Setch Date: Sun, 29 Sep 2024 11:17:16 -0400 Subject: [PATCH 1/9] refactor: main typescript Signed-off-by: Adam Setch --- config/webpack.config.common.js | 15 -- config/webpack.config.main.base.js | 25 ++ config/webpack.config.main.prod.js | 20 ++ config/webpack.config.prod.js | 14 -- config/webpack.config.renderer.base.js | 42 ++++ config/webpack.config.renderer.prod.js | 20 ++ config/webpack.paths.js | 2 - package.json | 12 +- pnpm-lock.yaml | 227 ++++++++++++++++++ src/main/{first-run.js => first-run.ts} | 12 +- src/main/{main.js => main.ts} | 37 ++- .../components/primitives/EmojiText.tsx | 2 +- src/{main/index.html => renderer/index.ejs} | 2 - src/renderer/index.tsx | 2 +- 14 files changed, 365 insertions(+), 67 deletions(-) create mode 100644 config/webpack.config.main.base.js create mode 100644 config/webpack.config.main.prod.js delete mode 100644 config/webpack.config.prod.js create mode 100644 config/webpack.config.renderer.base.js create mode 100644 config/webpack.config.renderer.prod.js rename src/main/{first-run.js => first-run.ts} (84%) rename src/main/{main.js => main.ts} (92%) rename src/{main/index.html => renderer/index.ejs} (96%) diff --git a/config/webpack.config.common.js b/config/webpack.config.common.js index f3c9416..1018ba7 100644 --- a/config/webpack.config.common.js +++ b/config/webpack.config.common.js @@ -1,24 +1,9 @@ -const path = require('node:path'); const webpack = require('webpack'); -const webpackPaths = require('./webpack.paths'); /** * @type {webpack.Configuration} */ const configuration = { - devtool: 'inline-source-map', - - mode: 'development', - - target: 'electron-renderer', - - entry: [path.join(webpackPaths.srcRendererPath, 'index.tsx')], - - output: { - path: webpackPaths.buildRendererPath, - filename: 'renderer.js', - }, - module: { rules: [ { diff --git a/config/webpack.config.main.base.js b/config/webpack.config.main.base.js new file mode 100644 index 0000000..55bd373 --- /dev/null +++ b/config/webpack.config.main.base.js @@ -0,0 +1,25 @@ +const path = require('node:path'); +const webpack = require('webpack'); +const webpackPaths = require('./webpack.paths'); +const baseConfig = require('./webpack.config.common'); +const { merge } = require('webpack-merge'); + +/** + * @type {webpack.Configuration} + */ +const configuration = { + devtool: 'inline-source-map', + + mode: 'development', + + target: 'electron-main', + + entry: [path.join(webpackPaths.srcMainPath, 'main.ts')], + + output: { + path: webpackPaths.buildPath, + filename: 'main.js', + }, +}; + +module.exports = merge(baseConfig, configuration); diff --git a/config/webpack.config.main.prod.js b/config/webpack.config.main.prod.js new file mode 100644 index 0000000..79f95b5 --- /dev/null +++ b/config/webpack.config.main.prod.js @@ -0,0 +1,20 @@ +const { merge } = require('webpack-merge'); +const baseConfig = require('./webpack.config.main.base'); +const webpack = require('webpack'); +const TerserPlugin = require('terser-webpack-plugin'); + +/** + * @type {webpack.Configuration} + */ +const configuration = { + devtool: 'source-map', + + mode: 'production', + + optimization: { + minimize: true, + minimizer: [new TerserPlugin()], + }, +}; + +module.exports = merge(baseConfig, configuration); diff --git a/config/webpack.config.prod.js b/config/webpack.config.prod.js deleted file mode 100644 index 54a0fc4..0000000 --- a/config/webpack.config.prod.js +++ /dev/null @@ -1,14 +0,0 @@ -const { merge } = require('webpack-merge'); -const commonConfig = require('./webpack.config.common'); -const webpack = require('webpack'); - -/** - * @type {webpack.Configuration} - */ -const configuration = { - devtool: 'source-map', - - mode: 'production', -}; - -module.exports = merge(commonConfig, configuration); diff --git a/config/webpack.config.renderer.base.js b/config/webpack.config.renderer.base.js new file mode 100644 index 0000000..81c2bb1 --- /dev/null +++ b/config/webpack.config.renderer.base.js @@ -0,0 +1,42 @@ +const path = require('node:path'); +const webpack = require('webpack'); +const webpackPaths = require('./webpack.paths'); +const baseConfig = require('./webpack.config.common'); +const { merge } = require('webpack-merge'); +const HtmlWebpackPlugin = require('html-webpack-plugin'); + +/** + * @type {webpack.Configuration} + */ +const configuration = { + devtool: 'inline-source-map', + + mode: 'development', + + target: 'electron-renderer', + + entry: [path.join(webpackPaths.srcRendererPath, 'index.tsx')], + + output: { + path: webpackPaths.buildPath, + filename: 'renderer.js', + }, + + plugins: [ + new HtmlWebpackPlugin({ + filename: path.join('index.html'), + template: path.join(webpackPaths.srcRendererPath, 'index.ejs'), + minify: { + collapseWhitespace: true, + removeAttributeQuotes: true, + removeComments: true, + }, + isBrowser: false, + // env: process.env.NODE_ENV, + // isDevelopment: process.env.NODE_ENV !== 'production', + // nodeModules: webpackPaths.appNodeModulesPath, + }), + ], +}; + +module.exports = merge(baseConfig, configuration); diff --git a/config/webpack.config.renderer.prod.js b/config/webpack.config.renderer.prod.js new file mode 100644 index 0000000..f29997c --- /dev/null +++ b/config/webpack.config.renderer.prod.js @@ -0,0 +1,20 @@ +const { merge } = require('webpack-merge'); +const baseConfig = require('./webpack.config.renderer.base'); +const webpack = require('webpack'); +const TerserPlugin = require('terser-webpack-plugin'); + +/** + * @type {webpack.Configuration} + */ +const configuration = { + devtool: 'source-map', + + mode: 'production', + + optimization: { + minimize: true, + minimizer: [new TerserPlugin()], + }, +}; + +module.exports = merge(baseConfig, configuration); diff --git a/config/webpack.paths.js b/config/webpack.paths.js index d1bc5e0..274eee4 100644 --- a/config/webpack.paths.js +++ b/config/webpack.paths.js @@ -11,7 +11,6 @@ const releasePath = path.join(rootPath, 'release'); const distPath = path.join(rootPath, 'dist'); const buildPath = path.join(rootPath, 'build'); -const buildRendererPath = path.join(buildPath, 'js'); module.exports = { rootPath, @@ -21,5 +20,4 @@ module.exports = { releasePath, distPath, buildPath, - buildRendererPath, }; diff --git a/package.json b/package.json index 0512416..0616e7b 100644 --- a/package.json +++ b/package.json @@ -2,15 +2,15 @@ "name": "atlassify", "version": "1.2.0", "description": "Atlassian notifications on your menu bar.", - "main": "src/main/main.js", + "main": "build/main.js", "scripts": { "clean": "rimraf build coverage node_modules", "build": "concurrently --names 'main,renderer' --prefix-colors 'blue,green' 'pnpm build:main' 'pnpm build:renderer'", - "build:main": "echo 'not implemented yet'", - "build:renderer": "webpack --config ./config/webpack.config.prod.js", + "build:main": "webpack --config ./config/webpack.config.main.prod.js", + "build:renderer": "webpack --config ./config/webpack.config.renderer.prod.js", "watch": "concurrently --names 'main,renderer' --prefix-colors 'blue,green' 'pnpm watch:main' 'pnpm watch:renderer'", - "watch:main": "echo 'not implemented yet'", - "watch:renderer": "webpack --watch --config ./config/webpack.config.common.js", + "watch:main": "webpack --watch --config ./config/webpack.config.main.base.js", + "watch:renderer": "webpack --watch --config ./config/webpack.config.renderer.base.js", "make:linux": "electron-builder --linux", "make:macos": "electron-builder --mac", "make:win": "electron-builder --win", @@ -157,6 +157,7 @@ "electron": "32.1.2", "electron-builder": "25.0.5", "graphql-tag": "2.12.6", + "html-webpack-plugin": "5.6.0", "husky": "9.1.6", "jest": "29.7.0", "jest-environment-jsdom": "29.7.0", @@ -167,6 +168,7 @@ "rimraf": "6.0.1", "style-loader": "4.0.0", "tailwindcss": "3.4.13", + "terser-webpack-plugin": "5.3.10", "ts-jest": "29.2.5", "ts-node": "10.9.2", "webpack": "5.95.0", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 52a97bc..dc22308 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -144,6 +144,9 @@ importers: graphql-tag: specifier: 2.12.6 version: 2.12.6(graphql@16.8.1) + html-webpack-plugin: + specifier: 5.6.0 + version: 5.6.0(webpack@5.95.0(webpack-cli@5.1.4)) husky: specifier: 9.1.6 version: 9.1.6 @@ -174,6 +177,9 @@ importers: tailwindcss: specifier: 3.4.13 version: 3.4.13(ts-node@10.9.2(@types/node@20.16.10)(typescript@5.6.2)) + terser-webpack-plugin: + specifier: 5.3.10 + version: 5.3.10(webpack@5.95.0(webpack-cli@5.1.4)) ts-jest: specifier: 29.2.5 version: 29.2.5(@babel/core@7.24.3)(@jest/transform@29.7.0)(@jest/types@29.6.3)(babel-jest@29.7.0(@babel/core@7.24.3))(jest@29.7.0(@types/node@20.16.10)(babel-plugin-macros@3.1.0)(ts-node@10.9.2(@types/node@20.16.10)(typescript@5.6.2)))(typescript@5.6.2) @@ -951,6 +957,9 @@ packages: '@types/history@4.7.11': resolution: {integrity: sha512-qjDJRrmvBMiTx+jyLxvLfJU7UznFuokDv4f3WRuriHKERccVpFU+8XMQUAbDzoiJCsmexxRExQeMwwCdamSKDA==} + '@types/html-minifier-terser@6.1.0': + resolution: {integrity: sha512-oh/6byDPnL1zeNXFrDXFLyZjkr1MsBG667IM792caf1L2UPOOMf65NFzjUH/ltyfwjAGfs1rsX1eftK0jC/KIg==} + '@types/http-cache-semantics@4.0.4': resolution: {integrity: sha512-1m0bIFVc7eJWyve9S0RnuRgcQqF/Xd5QsUZAZeQFr1Q3/p9JWoQQEqmVy+DPTNpGXwhgIetAoYF8JSc33q29QA==} @@ -1320,6 +1329,9 @@ packages: bluebird@3.7.2: resolution: {integrity: sha512-XpNj6GDQzdfW+r2Wnn7xiSAd7TM3jzkxGXBGTtWKuSXv1xUV+azxAm8jdWZN06QTQk+2N2XB9jRDkvbmQmcRtg==} + boolbase@1.0.0: + resolution: {integrity: sha512-JZOSA7Mo9sNGB8+UjSgzdLtokWAky1zbztM3WRLCbZ70/3cTANmQmOdR7y2g+J0e2WXywy1yS468tY+IruqEww==} + boolean@3.2.0: resolution: {integrity: sha512-d0II/GO9uf9lfUHH2BQsjxzRJZBdsjgsBiW4BvhWk/3qoKwQFjIDVN19PfX8F2D/r9PCMTtLWjYVCFrpeYUzsw==} @@ -1388,6 +1400,9 @@ packages: resolution: {integrity: sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==} engines: {node: '>=6'} + camel-case@4.1.2: + resolution: {integrity: sha512-gxGWBrTT1JuMx6R+o5PTXMmUnhnVzLQ9SNutD4YqKtI6ap897t3tKECYla6gCWEkplXnlNybEkZg9GEGxKFCgw==} + camelcase-css@2.0.1: resolution: {integrity: sha512-QOSvevhslijgYwRx6Rv7zKdMF8lbRmx+uQGx2+vDc+KI/eBnsy9kit5aj23AgGu3pa4t9AgwbnXWqS+iOY+2aA==} engines: {node: '>= 6'} @@ -1437,6 +1452,10 @@ packages: cjs-module-lexer@1.2.3: resolution: {integrity: sha512-0TNiGstbQmCFwt4akjjBg5pLRTSyj/PkWQ1ZoO2zntmg9yLqSRxwEa4iCfQLGjqhiqBfOJa7W/E8wfGrTDmlZQ==} + clean-css@5.3.3: + resolution: {integrity: sha512-D5J+kHaVb/wKSFcyyV75uCn8fiY4sV38XJoe4CUyGQ+mOU/fMVYUdH1hJC+CJQ5uY3EnW27SbJYS4X8BiLrAFg==} + engines: {node: '>= 10.0'} + clean-stack@2.2.0: resolution: {integrity: sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==} engines: {node: '>=6'} @@ -1518,6 +1537,10 @@ packages: resolution: {integrity: sha512-P0CysNDQ7rtVw4QIQtm+MRxV66vKFSvlsQvGYXZWR3qFU0jlMKHZZZgw8e+8DSah4UDKMqnknRDQz+xuQXQ/Zg==} engines: {node: '>= 6'} + commander@8.3.0: + resolution: {integrity: sha512-OkTL9umf+He2DZkUq8f8J9of7yL6RJKI24dVITBmNfZBmri9zYZQrKkuXiKhyfPSu8tUhnVBB1iKXevvnlR4Ww==} + engines: {node: '>= 12'} + compare-version@0.1.2: resolution: {integrity: sha512-pJDh5/4wrEnXX/VWRZvruAGHkzKdr46z11OlTPN+VrATlWWhSKewNCJ1futCO5C7eJB3nPMFZA1LeYtcFboZ2A==} engines: {node: '>=0.10.0'} @@ -1604,6 +1627,13 @@ packages: webpack: optional: true + css-select@4.3.0: + resolution: {integrity: sha512-wPpOYtnsVontu2mODhA19JrqWxNsfdatRKd64kmpRbQgh1KtItko5sTnEpPdpSaJszTOhEMlF/RPz28qj4HqhQ==} + + css-what@6.1.0: + resolution: {integrity: sha512-HTUrgRJ7r4dsZKU6GjmpfRK1O76h97Z8MfS1G0FozR+oF2kG6Vfe8JE6zwrkbxigziPHinCJ+gCPjA9EaBDtRw==} + engines: {node: '>= 6'} + cssesc@3.0.0: resolution: {integrity: sha512-/Tb/JcjK111nNScGob5MNtsntNM1aCNUDipB/TkwZFhyDrrE47SOx/18wF2bbjgc3ZzCSKW1T5nt5EbFoAz/Vg==} engines: {node: '>=4'} @@ -1729,11 +1759,30 @@ packages: dom-accessibility-api@0.5.16: resolution: {integrity: sha512-X7BJ2yElsnOJ30pZF4uIIDfBEVgF4XEBxL9Bxhy6dnrm5hkzqmsWHGTiHqRiITNhMyFLyAiWndIJP7Z1NTteDg==} + dom-converter@0.2.0: + resolution: {integrity: sha512-gd3ypIPfOMr9h5jIKq8E3sHOTCjeirnl0WK5ZdS1AW0Odt0b1PaWaHdJ4Qk4klv+YB9aJBS7mESXjFoDQPu6DA==} + + dom-serializer@1.4.1: + resolution: {integrity: sha512-VHwB3KfrcOOkelEG2ZOfxqLZdfkil8PtJi4P8N2MMXucZq2yLp75ClViUlOVwyoHEDjYU433Aq+5zWP61+RGag==} + + domelementtype@2.3.0: + resolution: {integrity: sha512-OLETBj6w0OsagBwdXnPdN0cnMfF9opN69co+7ZrbfPGrdpPVNBUj02spi6B1N7wChLQiPn4CSH/zJvXw56gmHw==} + domexception@4.0.0: resolution: {integrity: sha512-A2is4PLG+eeSfoTMA95/s4pvAoSo2mKtiM5jlHkAVewmiO8ISFTFKZjH7UAM1Atli/OT/7JHOrJRJiMKUZKYBw==} engines: {node: '>=12'} deprecated: Use your platform's native DOMException instead + domhandler@4.3.1: + resolution: {integrity: sha512-GrwoxYN+uWlzO8uhUXRl0P+kHE4GtVPfYzVLcUxPL7KNdHKj66vvlhiweIHqYYXWlw+T8iLMp42Lm67ghw4WMQ==} + engines: {node: '>= 4'} + + domutils@2.8.0: + resolution: {integrity: sha512-w96Cjofp72M5IIhpjgobBimYEfoPjx1Vx0BSX9P30WBdZW2WIKU0T1Bd0kz2eNZ9ikjKgHbEyKx8BB6H1L3h3A==} + + dot-case@3.0.4: + resolution: {integrity: sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==} + dotenv-expand@11.0.6: resolution: {integrity: sha512-8NHi73otpWsZGBSZwwknTXS5pqMOrk9+Ssrna8xCaxkzEpU9OTf9R5ArQGVw03//Zmk9MOwLPng9WwndvpAJ5g==} engines: {node: '>=12'} @@ -1813,6 +1862,9 @@ packages: resolution: {integrity: sha512-LMHl3dXhTcfv8gM4kEzIUeTQ+7fpdA0l2tUf34BddXPkz2A5xJ5L/Pchd5BL6rdccM9QGvu0sWZzK1Z1t4wwyg==} engines: {node: '>=10.13.0'} + entities@2.2.0: + resolution: {integrity: sha512-p92if5Nz619I0w+akJrLZH0MX0Pb5DX39XOwQTtXSdQQOaYH03S1uIQp4mhOZtAXrxq4ViO67YTiLBo2638o9A==} + entities@4.5.0: resolution: {integrity: sha512-V0hjH4dGPh9Ao5p0MoRY6BVqtwCjhz6vI5LT8AJ55H+4g9/4vbHx1I54fS0XuclLhDHArPQCiMjDxjaL8fPxhw==} engines: {node: '>=0.12'} @@ -2150,6 +2202,10 @@ packages: resolution: {integrity: sha512-0hJU9SCPvmMzIBdZFqNPXWa6dqh7WdH0cII9y+CyS8rG3nL48Bclra9HmKhVVUHyPWNH5Y7xDwAB7bfgSjkUMQ==} engines: {node: '>= 0.4'} + he@1.2.0: + resolution: {integrity: sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==} + hasBin: true + hoist-non-react-statics@3.3.2: resolution: {integrity: sha512-/gGivxi8JPKWNm/W0jSmzcMPpfpPLc3dY/6GxhX2hQ9iGj3aDfklV4ET7NjKpSinLpJ5vafa9iiGIEZg10SfBw==} @@ -2164,6 +2220,26 @@ packages: html-escaper@2.0.2: resolution: {integrity: sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==} + html-minifier-terser@6.1.0: + resolution: {integrity: sha512-YXxSlJBZTP7RS3tWnQw74ooKa6L9b9i9QYXY21eUEvhZ3u9XLfv6OnFsQq6RxkhHygsaUMvYsZRV5rU/OVNZxw==} + engines: {node: '>=12'} + hasBin: true + + html-webpack-plugin@5.6.0: + resolution: {integrity: sha512-iwaY4wzbe48AfKLZ/Cc8k0L+FKG6oSNRaZ8x5A/T/IVDGyXcbHncM9TdDa93wn0FsSm82FhTKW7f3vS61thXAw==} + engines: {node: '>=10.13.0'} + peerDependencies: + '@rspack/core': 0.x || 1.x + webpack: ^5.20.0 + peerDependenciesMeta: + '@rspack/core': + optional: true + webpack: + optional: true + + htmlparser2@6.1.0: + resolution: {integrity: sha512-gyyPk6rgonLFEDGoeRgQNaEUvdJ4ktTmmUh/h2t7s+M8oPpIPxgNACWa+6ESR57kXstwqPiCut0V8NRpcwgU7A==} + http-cache-semantics@4.1.1: resolution: {integrity: sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ==} @@ -2633,6 +2709,9 @@ packages: resolution: {integrity: sha512-lyuxPGr/Wfhrlem2CL/UcnUc1zcqKAImBDzukY7Y5F/yQiNdko6+fRLevlw1HgMySw7f611UIY408EtxRSoK3Q==} hasBin: true + lower-case@2.0.2: + resolution: {integrity: sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==} + lowercase-keys@2.0.0: resolution: {integrity: sha512-tqNXrS78oMOE73NMxK4EMLQsQowWf8jKooH9g7xPavRT706R6bkQJ6DY2Te7QukaZsulxa30wQ7bk0pm4XiHmA==} engines: {node: '>=8'} @@ -2803,6 +2882,9 @@ packages: neo-async@2.6.2: resolution: {integrity: sha512-Yd3UES5mWCSqR+qNT93S3UoYUkqAZ9lLg8a7g9rimsWmYGK8cVToA4/sF3RrshdyV3sAGMXVUmpMYOw+dLpOuw==} + no-case@3.0.4: + resolution: {integrity: sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==} + nock@13.5.5: resolution: {integrity: sha512-XKYnqUrCwXC8DGG1xX4YH5yNIrlh9c065uaMZZHUoeUUINTOyt+x/G+ezYk0Ft6ExSREVIs+qBJDK503viTfFA==} engines: {node: '>= 10.13'} @@ -2854,6 +2936,9 @@ packages: engines: {node: ^12.13.0 || ^14.15.0 || >=16.0.0} deprecated: This package is no longer supported. + nth-check@2.1.1: + resolution: {integrity: sha512-lqjrjmaOoAnWfMmBPL+XNnynZh2+swxiX3WUE0s4yEHI6m+AwrK2UZOimIRl3X/4QctVqS8AiZjFqyOGrMXb/w==} + nwsapi@2.2.7: resolution: {integrity: sha512-ub5E4+FBPKwAZx0UwIQOjYWGHTEq5sPqHQNRN8Z9e4A7u3Tj1weLJsL59yH9vmvqEtBHaOmT6cYQKIZOxp35FQ==} @@ -2907,6 +2992,9 @@ packages: package-json-from-dist@1.0.0: resolution: {integrity: sha512-dATvCeZN/8wQsGywez1mzHtTlP22H8OEfPrVMLNr4/eGa+ijtLn/6M5f0dY8UKNrC2O9UCU6SSoG3qRKnt7STw==} + param-case@3.0.4: + resolution: {integrity: sha512-RXlj7zCYokReqWpOPH9oYivUzLYZ5vAPIfEmCTNViosC78F8F0H9y7T7gG2M39ymgutxF5gcFEsyZQSph9Bp3A==} + parent-module@1.0.1: resolution: {integrity: sha512-GQ2EWRpQV8/o+Aw8YqtfZZPfNRWZYkbidE9k5rpl/hC3vtHHBfGm2Ifi6qWV+coDGkrUKZAxE3Lot5kcsRlh+g==} engines: {node: '>=6'} @@ -2918,6 +3006,9 @@ packages: parse5@7.1.2: resolution: {integrity: sha512-Czj1WaSVpaoj0wbhMzLmWD69anp2WH7FXMB9n1Sy8/ZFF9jolSQVMu1Ij5WIyGmcBmhk7EOndpO4mIpihVqAXw==} + pascal-case@3.1.2: + resolution: {integrity: sha512-uWlGT3YSnK9x3BQJaOdcZwrnV6hPpd8jFH1/ucpiLRPh/2zCVJKS19E4GvYHvaCcACn3foXZ0cLB9Wrx1KGe5g==} + path-exists@4.0.0: resolution: {integrity: sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==} engines: {node: '>=8'} @@ -3056,6 +3147,9 @@ packages: resolution: {integrity: sha512-56rxCq7G/XfB4EkXq9Egn5GCqugWvDFjafDOThIdMBsI15iqPqR5r15TfSr1YPYeEI19YeaXMCbY6u88Y76GLQ==} engines: {node: ^10 || ^12 || >=14} + pretty-error@4.0.0: + resolution: {integrity: sha512-AoJ5YMAcXKYxKhuJGdcvse+Voc6v1RgnsR3nWcYU7q4t6z0Q6T86sv5Zq8VIRbOWWFpvdGE83LtdSMNd+6Y0xw==} + pretty-format@27.5.1: resolution: {integrity: sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==} engines: {node: ^10.13.0 || ^12.13.0 || ^14.15.0 || >=15.0.0} @@ -3235,6 +3329,13 @@ packages: regenerator-runtime@0.14.1: resolution: {integrity: sha512-dYnhHh0nJoMfnkZs6GmmhFknAGRrLznOu5nc9ML+EJxGvrx6H7teuevqVqCuPcPK//3eDrrjQhehXVx9cnkGdw==} + relateurl@0.2.7: + resolution: {integrity: sha512-G08Dxvm4iDN3MLM0EsP62EDV9IuhXPR6blNz6Utcp7zyV3tr4HVNINt6MpaRWbxoOHT3Q7YN2P+jaHX8vUbgog==} + engines: {node: '>= 0.10'} + + renderkid@3.0.0: + resolution: {integrity: sha512-q/7VIQA8lmM1hF+jn+sFSPWGlMkSAeNYcPLmDQx2zzuiDfaLrOmumR8iaUKlenFgh0XRPIUeSPlH3A+AW3Z5pg==} + require-directory@2.1.1: resolution: {integrity: sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==} engines: {node: '>=0.10.0'} @@ -3755,6 +3856,9 @@ packages: util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} + utila@0.4.0: + resolution: {integrity: sha512-Z0DbgELS9/L/75wZbro8xAnT50pBVFQZ+hUEueGDU5FN51YSCYM+jdxsfCiHjwNP/4LCDD0i/graKpeBnOXKRA==} + v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} @@ -5190,6 +5294,8 @@ snapshots: '@types/history@4.7.11': {} + '@types/html-minifier-terser@6.1.0': {} + '@types/http-cache-semantics@4.0.4': {} '@types/istanbul-lib-coverage@2.0.6': {} @@ -5687,6 +5793,8 @@ snapshots: bluebird@3.7.2: {} + boolbase@1.0.0: {} + boolean@3.2.0: optional: true @@ -5822,6 +5930,11 @@ snapshots: callsites@3.1.0: {} + camel-case@4.1.2: + dependencies: + pascal-case: 3.1.2 + tslib: 2.6.2 + camelcase-css@2.0.1: {} camelcase@5.3.1: {} @@ -5865,6 +5978,10 @@ snapshots: cjs-module-lexer@1.2.3: {} + clean-css@5.3.3: + dependencies: + source-map: 0.6.1 + clean-stack@2.2.0: {} cli-cursor@3.1.0: @@ -5931,6 +6048,8 @@ snapshots: commander@5.1.0: {} + commander@8.3.0: {} + compare-version@0.1.2: {} compress-commons@4.1.2: @@ -6038,6 +6157,16 @@ snapshots: optionalDependencies: webpack: 5.95.0(webpack-cli@5.1.4) + css-select@4.3.0: + dependencies: + boolbase: 1.0.0 + css-what: 6.1.0 + domhandler: 4.3.1 + domutils: 2.8.0 + nth-check: 2.1.1 + + css-what@6.1.0: {} + cssesc@3.0.0: {} cssom@0.3.8: {} @@ -6156,10 +6285,37 @@ snapshots: dom-accessibility-api@0.5.16: {} + dom-converter@0.2.0: + dependencies: + utila: 0.4.0 + + dom-serializer@1.4.1: + dependencies: + domelementtype: 2.3.0 + domhandler: 4.3.1 + entities: 2.2.0 + + domelementtype@2.3.0: {} + domexception@4.0.0: dependencies: webidl-conversions: 7.0.0 + domhandler@4.3.1: + dependencies: + domelementtype: 2.3.0 + + domutils@2.8.0: + dependencies: + dom-serializer: 1.4.1 + domelementtype: 2.3.0 + domhandler: 4.3.1 + + dot-case@3.0.4: + dependencies: + no-case: 3.0.4 + tslib: 2.6.2 + dotenv-expand@11.0.6: dependencies: dotenv: 16.4.5 @@ -6280,6 +6436,8 @@ snapshots: graceful-fs: 4.2.11 tapable: 2.2.1 + entities@2.2.0: {} + entities@4.5.0: {} env-paths@2.2.1: {} @@ -6634,6 +6792,8 @@ snapshots: dependencies: function-bind: 1.1.2 + he@1.2.0: {} + hoist-non-react-statics@3.3.2: dependencies: react-is: 16.13.1 @@ -6648,6 +6808,33 @@ snapshots: html-escaper@2.0.2: {} + html-minifier-terser@6.1.0: + dependencies: + camel-case: 4.1.2 + clean-css: 5.3.3 + commander: 8.3.0 + he: 1.2.0 + param-case: 3.0.4 + relateurl: 0.2.7 + terser: 5.30.0 + + html-webpack-plugin@5.6.0(webpack@5.95.0(webpack-cli@5.1.4)): + dependencies: + '@types/html-minifier-terser': 6.1.0 + html-minifier-terser: 6.1.0 + lodash: 4.17.21 + pretty-error: 4.0.0 + tapable: 2.2.1 + optionalDependencies: + webpack: 5.95.0(webpack-cli@5.1.4) + + htmlparser2@6.1.0: + dependencies: + domelementtype: 2.3.0 + domhandler: 4.3.1 + domutils: 2.8.0 + entities: 2.2.0 + http-cache-semantics@4.1.1: {} http-proxy-agent@5.0.0: @@ -7297,6 +7484,10 @@ snapshots: dependencies: js-tokens: 4.0.0 + lower-case@2.0.2: + dependencies: + tslib: 2.6.2 + lowercase-keys@2.0.0: {} lru-cache@10.2.0: {} @@ -7457,6 +7648,11 @@ snapshots: neo-async@2.6.2: {} + no-case@3.0.4: + dependencies: + lower-case: 2.0.2 + tslib: 2.6.2 + nock@13.5.5: dependencies: debug: 4.3.4 @@ -7518,6 +7714,10 @@ snapshots: gauge: 4.0.4 set-blocking: 2.0.0 + nth-check@2.1.1: + dependencies: + boolbase: 1.0.0 + nwsapi@2.2.7: {} object-assign@4.1.1: {} @@ -7569,6 +7769,11 @@ snapshots: package-json-from-dist@1.0.0: {} + param-case@3.0.4: + dependencies: + dot-case: 3.0.4 + tslib: 2.6.2 + parent-module@1.0.1: dependencies: callsites: 3.1.0 @@ -7584,6 +7789,11 @@ snapshots: dependencies: entities: 4.5.0 + pascal-case@3.1.2: + dependencies: + no-case: 3.0.4 + tslib: 2.6.2 + path-exists@4.0.0: {} path-is-absolute@1.0.1: {} @@ -7698,6 +7908,11 @@ snapshots: picocolors: 1.1.0 source-map-js: 1.2.1 + pretty-error@4.0.0: + dependencies: + lodash: 4.17.21 + renderkid: 3.0.0 + pretty-format@27.5.1: dependencies: ansi-regex: 5.0.1 @@ -7886,6 +8101,16 @@ snapshots: regenerator-runtime@0.14.1: {} + relateurl@0.2.7: {} + + renderkid@3.0.0: + dependencies: + css-select: 4.3.0 + dom-converter: 0.2.0 + htmlparser2: 6.1.0 + lodash: 4.17.21 + strip-ansi: 6.0.1 + require-directory@2.1.1: {} requires-port@1.0.0: {} @@ -8395,6 +8620,8 @@ snapshots: util-deprecate@1.0.2: {} + utila@0.4.0: {} + v8-compile-cache-lib@3.0.1: {} v8-to-istanbul@9.2.0: diff --git a/src/main/first-run.js b/src/main/first-run.ts similarity index 84% rename from src/main/first-run.js rename to src/main/first-run.ts index c470e9b..46bafff 100644 --- a/src/main/first-run.js +++ b/src/main/first-run.ts @@ -1,9 +1,9 @@ -const { app, dialog } = require('electron'); -const fs = require('node:fs'); -const path = require('node:path'); -const log = require('electron-log'); +import fs from 'node:fs'; +import path from 'node:path'; +import { app, dialog } from 'electron'; +import log from 'electron-log'; -async function onFirstRunMaybe() { +export async function onFirstRunMaybe() { if (isFirstRun()) { await promptMoveToApplicationsFolder(); } @@ -54,5 +54,3 @@ function isFirstRun() { return true; } - -module.exports = { onFirstRunMaybe }; diff --git a/src/main/main.js b/src/main/main.ts similarity index 92% rename from src/main/main.js rename to src/main/main.ts index 206cdfa..be43b83 100644 --- a/src/main/main.js +++ b/src/main/main.ts @@ -1,21 +1,21 @@ -const { - ipcMain: ipc, - app, - nativeTheme, - globalShortcut, +import fs from 'node:fs'; +import os from 'node:os'; +import path from 'node:path'; +import { Menu, - dialog, MenuItem, + app, + dialog, + globalShortcut, + ipcMain as ipc, + nativeTheme, safeStorage, -} = require('electron'); -const { menubar } = require('menubar'); -const { onFirstRunMaybe } = require('./first-run'); -const path = require('node:path'); -const log = require('electron-log'); -const fs = require('node:fs'); -const os = require('node:os'); -const { autoUpdater } = require('electron-updater'); -const { updateElectronApp } = require('update-electron-app'); +} from 'electron'; +import log from 'electron-log'; +import { autoUpdater } from 'electron-updater'; +import { menubar } from 'menubar'; +import { updateElectronApp } from 'update-electron-app'; +import { onFirstRunMaybe } from './first-run'; log.initialize(); @@ -24,10 +24,7 @@ const idleIcon = getIconPath('tray-idleTemplate.png'); const idleAlternateIcon = getIconPath('tray-idle-white.png'); const activeIcon = getIconPath('tray-active.png'); -/** - * @type {Electron.BrowserWindowConstructorOptions} - */ -const browserWindowOpts = { +const browserWindowOpts: Electron.BrowserWindowConstructorOptions = { width: 500, height: 400, minWidth: 500, @@ -293,5 +290,5 @@ function resetApp() { } function getIconPath(iconName) { - return path.resolve(__dirname, '../../assets/images', iconName); + return path.resolve(__dirname, '../assets/images', iconName); } diff --git a/src/renderer/components/primitives/EmojiText.tsx b/src/renderer/components/primitives/EmojiText.tsx index 70d0fcc..2f51ac9 100644 --- a/src/renderer/components/primitives/EmojiText.tsx +++ b/src/renderer/components/primitives/EmojiText.tsx @@ -24,7 +24,7 @@ export const EmojiText: FC = ({ text }) => { callback: (icon: string, options: TwemojiOptions, _variant: string) => { const source = path.resolve( getDirectoryPath(), - '../../node_modules/@discordapp/twemoji/dist', + '../node_modules/@discordapp/twemoji/dist', ); return ''.concat(source, '/', options.size, '/', icon, options.ext); diff --git a/src/main/index.html b/src/renderer/index.ejs similarity index 96% rename from src/main/index.html rename to src/renderer/index.ejs index 5f3655e..7e901d1 100644 --- a/src/main/index.html +++ b/src/renderer/index.ejs @@ -11,8 +11,6 @@
- -