From 81d65cc1ca828c12aa3cad380774bc56b7ac7b5c Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Wed, 25 Sep 2024 10:11:36 +0300 Subject: [PATCH] Move window modules into common folder --- src/auto-updater/index.js | 6 +++--- src/change-sync-frequency.js | 2 +- src/enforce-macos-app-location.js | 2 +- src/error-manager/show-modal-dialog.js | 4 ++-- src/export-db.js | 2 +- src/helpers/is-main-win-available.js | 2 +- src/initialize-app.js | 6 +++--- src/make-single-instance.js | 2 +- src/manage-worker-messages.js | 2 +- src/pause-app.js | 2 +- src/print-to-pdf/index.js | 2 +- src/restore-db/index.js | 4 ++-- src/show-docs/index.js | 4 ++-- src/show-notification/show-sync-notification.js | 2 +- .../show-trx-tax-report-notification.js | 2 +- src/trigger-electron-load.js | 2 +- .../change-loading-win-visibility-state.js | 4 ++-- .../index.js} | 16 ++++++++-------- .../layouts/app-init-error.html | 4 ++-- src/{ => window-creators}/layouts/app-init.html | 6 +++--- src/{ => window-creators}/preload.js | 0 .../window-event-manager.js} | 2 +- src/{ => window-creators}/window-state-keeper.js | 2 +- src/{ => window-creators}/windows.js | 0 24 files changed, 40 insertions(+), 40 deletions(-) rename src/{ => window-creators}/change-loading-win-visibility-state.js (98%) rename src/{window-creators.js => window-creators/index.js} (93%) rename src/{ => window-creators}/layouts/app-init-error.html (91%) rename src/{ => window-creators}/layouts/app-init.html (95%) rename src/{ => window-creators}/preload.js (100%) rename src/{window-event-manager/index.js => window-creators/window-event-manager.js} (98%) rename src/{ => window-creators}/window-state-keeper.js (98%) rename src/{ => window-creators}/windows.js (100%) diff --git a/src/auto-updater/index.js b/src/auto-updater/index.js index 6be6aad8..1e01e9de 100644 --- a/src/auto-updater/index.js +++ b/src/auto-updater/index.js @@ -14,11 +14,11 @@ const yaml = require('js-yaml') const log = require('../error-manager/log') const BfxMacUpdater = require('./bfx.mac.updater') -const wins = require('../windows') +const wins = require('../window-creators/windows') const { showLoadingWindow, hideLoadingWindow -} = require('../change-loading-win-visibility-state') +} = require('../window-creators/change-loading-win-visibility-state') const { closeAlert } = require('../modal-dialog-src/utils') @@ -26,7 +26,7 @@ const parseEnvValToBool = require('../helpers/parse-env-val-to-bool') const { WINDOW_EVENT_NAMES, addOnceProcEventHandler -} = require('../window-event-manager') +} = require('../window-creators/window-event-manager') const MENU_ITEM_IDS = require('../create-menu/menu.item.ids') diff --git a/src/change-sync-frequency.js b/src/change-sync-frequency.js index 1b6f81cd..a2d9a83a 100644 --- a/src/change-sync-frequency.js +++ b/src/change-sync-frequency.js @@ -29,7 +29,7 @@ const getAlertCustomClassObj = require( const { WINDOW_EVENT_NAMES, addOnceProcEventHandler -} = require('./window-event-manager') +} = require('./window-creators/window-event-manager') const _getSchedulerRule = (timeFormat, alertRes) => { if (timeFormat.value === 'days') { diff --git a/src/enforce-macos-app-location.js b/src/enforce-macos-app-location.js index ae16b33f..0562c20b 100644 --- a/src/enforce-macos-app-location.js +++ b/src/enforce-macos-app-location.js @@ -6,7 +6,7 @@ const productName = require('./helpers/product-name') const { showLoadingWindow, hideLoadingWindow -} = require('./change-loading-win-visibility-state') +} = require('./window-creators/change-loading-win-visibility-state') module.exports = async () => { if ( diff --git a/src/error-manager/show-modal-dialog.js b/src/error-manager/show-modal-dialog.js index 3fd09959..d73db5d9 100644 --- a/src/error-manager/show-modal-dialog.js +++ b/src/error-manager/show-modal-dialog.js @@ -7,7 +7,7 @@ const { Converter } = require('showdown') const Alert = require('electron-alert') const { rootPath } = require('electron-root-path') -const wins = require('../windows') +const wins = require('../window-creators/windows') const spawn = require('../helpers/spawn') const getAlertCustomClassObj = require( '../helpers/get-alert-custom-class-obj' @@ -21,7 +21,7 @@ const { const { WINDOW_EVENT_NAMES, addOnceProcEventHandler -} = require('../window-event-manager') +} = require('../window-creators/window-event-manager') const mdStyle = fs.readFileSync(path.join( rootPath, 'node_modules', 'github-markdown-css/github-markdown.css' diff --git a/src/export-db.js b/src/export-db.js index 07aeefd5..2c7c1945 100644 --- a/src/export-db.js +++ b/src/export-db.js @@ -10,7 +10,7 @@ const showMessageModalDialog = require('./show-message-modal-dialog') const { showLoadingWindow, hideLoadingWindow -} = require('./change-loading-win-visibility-state') +} = require('./window-creators/change-loading-win-visibility-state') const { DEFAULT_ARCHIVE_DB_FILE_NAME, DB_FILE_NAME, diff --git a/src/helpers/is-main-win-available.js b/src/helpers/is-main-win-available.js index d15444fd..827014c1 100644 --- a/src/helpers/is-main-win-available.js +++ b/src/helpers/is-main-win-available.js @@ -1,6 +1,6 @@ 'use strict' -const wins = require('../windows') +const wins = require('../window-creators/windows') module.exports = ( win = wins?.mainWindow, diff --git a/src/initialize-app.js b/src/initialize-app.js index 014b6c18..85710b5a 100644 --- a/src/initialize-app.js +++ b/src/initialize-app.js @@ -7,7 +7,7 @@ const { REPORT_FILES_PATH_VERSION } = require('./const') const triggerSyncAfterUpdates = require('./trigger-sync-after-updates') const triggerElectronLoad = require('./trigger-electron-load') -const wins = require('./windows') +const wins = require('./window-creators/windows') const runServer = require('./run-server') const appStates = require('./app-states') const { @@ -16,7 +16,7 @@ const { } = require('./window-creators') const { hideLoadingWindow -} = require('./change-loading-win-visibility-state') +} = require('./window-creators/change-loading-win-visibility-state') const makeOrReadSecretKey = require('./make-or-read-secret-key') const { configsKeeperFactory @@ -43,7 +43,7 @@ const manageWorkerMessages = require( ) const printToPDF = require('./print-to-pdf') -const pathToLayouts = path.join(__dirname, 'layouts') +const pathToLayouts = path.join(__dirname, 'window-creators/layouts') const pathToLayoutAppInitErr = path .join(pathToLayouts, 'app-init-error.html') diff --git a/src/make-single-instance.js b/src/make-single-instance.js index 3f5ea961..8af7f7fc 100644 --- a/src/make-single-instance.js +++ b/src/make-single-instance.js @@ -2,7 +2,7 @@ const { app } = require('electron') -const windows = require('./windows') +const windows = require('./window-creators/windows') module.exports = () => { const isGottenLock = app.requestSingleInstanceLock() diff --git a/src/manage-worker-messages.js b/src/manage-worker-messages.js index 2cbd7265..8ee967c9 100644 --- a/src/manage-worker-messages.js +++ b/src/manage-worker-messages.js @@ -2,7 +2,7 @@ const { app, BrowserWindow } = require('electron') -const wins = require('./windows') +const wins = require('./window-creators/windows') const relaunch = require('./relaunch') const showMessageModalDialog = require( './show-message-modal-dialog' diff --git a/src/pause-app.js b/src/pause-app.js index 5fea210b..3883dd78 100644 --- a/src/pause-app.js +++ b/src/pause-app.js @@ -3,7 +3,7 @@ const ipcs = require('./ipcs') const { showLoadingWindow -} = require('./change-loading-win-visibility-state') +} = require('./window-creators/change-loading-win-visibility-state') const _closeServer = () => { return new Promise((resolve, reject) => { diff --git a/src/print-to-pdf/index.js b/src/print-to-pdf/index.js index 460738e6..0aaf2b2f 100644 --- a/src/print-to-pdf/index.js +++ b/src/print-to-pdf/index.js @@ -5,7 +5,7 @@ const fs = require('fs/promises') const path = require('path') const ipcs = require('../ipcs') -const wins = require('../windows') +const wins = require('../window-creators/windows') const PROCESS_MESSAGES = require( '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' diff --git a/src/restore-db/index.js b/src/restore-db/index.js index 200e03fb..46c8e71a 100644 --- a/src/restore-db/index.js +++ b/src/restore-db/index.js @@ -7,7 +7,7 @@ const Alert = require('electron-alert') const { rootPath } = require('electron-root-path') const ipcs = require('../ipcs') -const wins = require('../windows') +const wins = require('../window-creators/windows') const { deserializeError } = require('../helpers/utils') @@ -29,7 +29,7 @@ const { const { WINDOW_EVENT_NAMES, addOnceProcEventHandler -} = require('../window-event-manager') +} = require('../window-creators/window-event-manager') const fontsStyle = fs.readFileSync(path.join( rootPath, 'bfx-report-ui/build/fonts/roboto.css' diff --git a/src/show-docs/index.js b/src/show-docs/index.js index b9072f49..5f7f3a6b 100644 --- a/src/show-docs/index.js +++ b/src/show-docs/index.js @@ -7,7 +7,7 @@ const { Converter } = require('showdown') const Alert = require('electron-alert') const { rootPath } = require('electron-root-path') -const wins = require('../windows') +const wins = require('../window-creators/windows') const isMainWinAvailable = require( '../helpers/is-main-win-available' ) @@ -26,7 +26,7 @@ const mdUserManual = fs.readFileSync( const { WINDOW_EVENT_NAMES, addOnceProcEventHandler -} = require('../window-event-manager') +} = require('../window-creators/window-event-manager') const mdStyle = fs.readFileSync(path.join( rootPath, 'node_modules', 'github-markdown-css/github-markdown.css' diff --git a/src/show-notification/show-sync-notification.js b/src/show-notification/show-sync-notification.js index b63099a4..8aeceda9 100644 --- a/src/show-notification/show-sync-notification.js +++ b/src/show-notification/show-sync-notification.js @@ -3,7 +3,7 @@ const PROCESS_MESSAGES = require( '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' ) -const wins = require('../windows') +const wins = require('../window-creators/windows') const { isWindowInvisible } = require('../helpers/manage-window') const showNotification = require('./') diff --git a/src/show-notification/show-trx-tax-report-notification.js b/src/show-notification/show-trx-tax-report-notification.js index 02be5289..869ca964 100644 --- a/src/show-notification/show-trx-tax-report-notification.js +++ b/src/show-notification/show-trx-tax-report-notification.js @@ -3,7 +3,7 @@ const PROCESS_MESSAGES = require( '../../bfx-reports-framework/workers/loc.api/process.message.manager/process.messages' ) -const wins = require('../windows') +const wins = require('../window-creators/windows') const { isWindowInvisible } = require('../helpers/manage-window') const showNotification = require('./') diff --git a/src/trigger-electron-load.js b/src/trigger-electron-load.js index ad2c27bd..8a6d0b21 100644 --- a/src/trigger-electron-load.js +++ b/src/trigger-electron-load.js @@ -3,7 +3,7 @@ const path = require('path') const fs = require('fs') -const wins = require('./windows') +const wins = require('./window-creators/windows') const pathToTriggerElectronLoad = path.join( __dirname, '../bfx-report-ui/build/triggerElectronLoad.js' diff --git a/src/change-loading-win-visibility-state.js b/src/window-creators/change-loading-win-visibility-state.js similarity index 98% rename from src/change-loading-win-visibility-state.js rename to src/window-creators/change-loading-win-visibility-state.js index 727e1e80..cbc6677a 100644 --- a/src/change-loading-win-visibility-state.js +++ b/src/window-creators/change-loading-win-visibility-state.js @@ -7,7 +7,7 @@ const { hideWindow, showWindow, centerWindow -} = require('./helpers/manage-window') +} = require('../helpers/manage-window') let intervalMarker @@ -158,7 +158,7 @@ const showLoadingWindow = async (opts = {}) => { typeof wins.loadingWindow !== 'object' || wins.loadingWindow.isDestroyed() ) { - await require('./window-creators') + await require('.') .createLoadingWindow() } diff --git a/src/window-creators.js b/src/window-creators/index.js similarity index 93% rename from src/window-creators.js rename to src/window-creators/index.js index 104230f4..c9bddda1 100644 --- a/src/window-creators.js +++ b/src/window-creators/index.js @@ -9,11 +9,11 @@ const isDevEnv = process.env.NODE_ENV === 'development' const isMac = process.platform === 'darwin' const wins = require('./windows') -const ipcs = require('./ipcs') -const serve = require('./serve') -const appStates = require('./app-states') +const ipcs = require('../ipcs') +const serve = require('../serve') +const appStates = require('../app-states') const windowStateKeeper = require('./window-state-keeper') -const createMenu = require('./create-menu') +const createMenu = require('../create-menu') const { showLoadingWindow, hideLoadingWindow @@ -22,10 +22,10 @@ const { showWindow, hideWindow, centerWindow -} = require('./helpers/manage-window') -const isBfxApiStaging = require('./helpers/is-bfx-api-staging') +} = require('../helpers/manage-window') +const isBfxApiStaging = require('../helpers/is-bfx-api-staging') -const publicDir = path.join(__dirname, '../bfx-report-ui/build') +const publicDir = path.join(__dirname, '../../bfx-report-ui/build') const loadURL = serve({ directory: publicDir }) const pathToLayouts = path.join(__dirname, 'layouts') @@ -90,7 +90,7 @@ const _createWindow = async ( y: !y ? bounds.y : y, - icon: path.join(__dirname, '../build/icons/512x512.png'), + icon: path.join(__dirname, '../../build/icons/512x512.png'), backgroundColor: '#172d3e', show: false, ...props, diff --git a/src/layouts/app-init-error.html b/src/window-creators/layouts/app-init-error.html similarity index 91% rename from src/layouts/app-init-error.html rename to src/window-creators/layouts/app-init-error.html index 12a9fca3..a6415129 100644 --- a/src/layouts/app-init-error.html +++ b/src/window-creators/layouts/app-init-error.html @@ -3,8 +3,8 @@ - - + + Bitfinex Reports