mirror of
				https://github.com/zadam/trilium.git
				synced 2025-10-31 11:39:01 +01:00 
			
		
		
		
	server-esm: Solve a few straightforward cases
This commit is contained in:
		
							parent
							
								
									013f25a49b
								
							
						
					
					
						commit
						fe385bf2e4
					
				| @ -1,5 +1,6 @@ | |||||||
| import noteTypeService from "../services/note_types.js"; | import noteTypeService from "../services/note_types.js"; | ||||||
| import dateUtils from "../services/date_utils.js"; | import dateUtils from "../services/date_utils.js"; | ||||||
|  | import becca from "../becca/becca.js"; | ||||||
| 
 | 
 | ||||||
| function mandatory(obj: unknown) { | function mandatory(obj: unknown) { | ||||||
|     if (obj === undefined) { |     if (obj === undefined) { | ||||||
| @ -64,8 +65,6 @@ function isNoteId(obj: unknown) { | |||||||
|         return; |         return; | ||||||
|     } |     } | ||||||
| 
 | 
 | ||||||
|     const becca = require('../becca/becca'); |  | ||||||
| 
 |  | ||||||
|     if (typeof obj !== 'string') { |     if (typeof obj !== 'string') { | ||||||
|         return `'${obj}' is not a valid noteId`; |         return `'${obj}' is not a valid noteId`; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -1,7 +1,6 @@ | |||||||
|  | import { ipcMain } from "electron"; | ||||||
| import { Application } from "express"; | import { Application } from "express"; | ||||||
| 
 | 
 | ||||||
| const ipcMain = require('electron').ipcMain; |  | ||||||
| 
 |  | ||||||
| interface Response { | interface Response { | ||||||
|     statusCode: number; |     statusCode: number; | ||||||
|     getHeader: (name: string) => string; |     getHeader: (name: string) => string; | ||||||
|  | |||||||
| @ -7,11 +7,11 @@ import assetPath from "../services/asset_path.js"; | |||||||
| import appPath from "../services/app_path.js"; | import appPath from "../services/app_path.js"; | ||||||
| import { Request, Response } from 'express'; | import { Request, Response } from 'express'; | ||||||
| 
 | 
 | ||||||
| function setupPage(req: Request, res: Response) { | async function setupPage(req: Request, res: Response) { | ||||||
|     if (sqlInit.isDbInitialized()) { |     if (sqlInit.isDbInitialized()) { | ||||||
|         if (utils.isElectron()) { |         if (utils.isElectron()) { | ||||||
|             const windowService = require('../services/window'); |             const windowService = (await import("../services/window")).default; | ||||||
|             const { app } = require('electron'); |             const { app } = await import("electron"); | ||||||
|             windowService.createMainWindow(app); |             windowService.createMainWindow(app); | ||||||
|             windowService.closeSetupWindow(); |             windowService.closeSetupWindow(); | ||||||
|         } |         } | ||||||
|  | |||||||
| @ -16,6 +16,7 @@ import sanitizeAttributeName from "./sanitize_attribute_name.js"; | |||||||
| import noteTypesService from "../services/note_types.js"; | import noteTypesService from "../services/note_types.js"; | ||||||
| import { BranchRow } from '../becca/entities/rows'; | import { BranchRow } from '../becca/entities/rows'; | ||||||
| import { EntityChange } from './entity_changes_interface'; | import { EntityChange } from './entity_changes_interface'; | ||||||
|  | import becca_loader from "../becca/becca_loader.js"; | ||||||
| const noteTypes = noteTypesService.getNoteTypeNames(); | const noteTypes = noteTypesService.getNoteTypeNames(); | ||||||
| 
 | 
 | ||||||
| class ConsistencyChecks { | class ConsistencyChecks { | ||||||
| @ -825,7 +826,7 @@ class ConsistencyChecks { | |||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         if (this.reloadNeeded) { |         if (this.reloadNeeded) { | ||||||
|             require('../becca/becca_loader').reload("consistency checks need becca reload"); |             becca_loader.reload("consistency checks need becca reload"); | ||||||
|         } |         } | ||||||
| 
 | 
 | ||||||
|         return !this.unrecoveredConsistencyErrors; |         return !this.unrecoveredConsistencyErrors; | ||||||
|  | |||||||
| @ -16,7 +16,7 @@ interface NotSyncedOpts { | |||||||
|     syncProxy?: string; |     syncProxy?: string; | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts = {}) { | async function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts = {}) { | ||||||
|     optionService.createOption('openNoteContexts', JSON.stringify([ |     optionService.createOption('openNoteContexts', JSON.stringify([ | ||||||
|         { |         { | ||||||
|             notePath: 'root', |             notePath: 'root', | ||||||
| @ -37,7 +37,7 @@ function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts = {}) { | |||||||
|     let theme = 'dark'; // default based on the poll in https://github.com/zadam/trilium/issues/2516
 |     let theme = 'dark'; // default based on the poll in https://github.com/zadam/trilium/issues/2516
 | ||||||
| 
 | 
 | ||||||
|     if (utils.isElectron()) { |     if (utils.isElectron()) { | ||||||
|         const {nativeTheme} = require('electron'); |         const {nativeTheme} = await import("electron"); | ||||||
| 
 | 
 | ||||||
|         theme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light'; |         theme = nativeTheme.shouldUseDarkColors ? 'dark' : 'light'; | ||||||
|     } |     } | ||||||
|  | |||||||
| @ -2,6 +2,8 @@ | |||||||
| 
 | 
 | ||||||
| import log from "./log.js"; | import log from "./log.js"; | ||||||
| import dataEncryptionService from "./encryption/data_encryption.js"; | import dataEncryptionService from "./encryption/data_encryption.js"; | ||||||
|  | import options from "./options.js"; | ||||||
|  | import ws from "./ws.js"; | ||||||
| 
 | 
 | ||||||
| let dataKey: Buffer | null = null; | let dataKey: Buffer | null = null; | ||||||
| 
 | 
 | ||||||
| @ -56,7 +58,6 @@ function touchProtectedSession() { | |||||||
| } | } | ||||||
| 
 | 
 | ||||||
| function checkProtectedSessionExpiration() { | function checkProtectedSessionExpiration() { | ||||||
|     const options = require('./options'); |  | ||||||
|     const protectedSessionTimeout = options.getOptionInt('protectedSessionTimeout'); |     const protectedSessionTimeout = options.getOptionInt('protectedSessionTimeout'); | ||||||
|     if (isProtectedSessionAvailable() |     if (isProtectedSessionAvailable() | ||||||
|         && lastProtectedSessionOperationDate |         && lastProtectedSessionOperationDate | ||||||
| @ -66,7 +67,7 @@ function checkProtectedSessionExpiration() { | |||||||
| 
 | 
 | ||||||
|         log.info("Expiring protected session"); |         log.info("Expiring protected session"); | ||||||
| 
 | 
 | ||||||
|         require('./ws').reloadFrontend("leaving protected session"); |         ws.reloadFrontend("leaving protected session"); | ||||||
|     } |     } | ||||||
| } | } | ||||||
| 
 | 
 | ||||||
|  | |||||||
| @ -17,7 +17,7 @@ let setupWindow: BrowserWindow | null; | |||||||
| async function createExtraWindow(extraWindowHash: string) { | async function createExtraWindow(extraWindowHash: string) { | ||||||
|     const spellcheckEnabled = optionService.getOptionBool('spellCheckEnabled'); |     const spellcheckEnabled = optionService.getOptionBool('spellCheckEnabled'); | ||||||
| 
 | 
 | ||||||
|     const { BrowserWindow } = require('electron'); |     const { BrowserWindow } = await import('electron'); | ||||||
| 
 | 
 | ||||||
|     const win = new BrowserWindow({ |     const win = new BrowserWindow({ | ||||||
|         width: 1000, |         width: 1000, | ||||||
| @ -43,7 +43,7 @@ ipcMain.on('create-extra-window', (event, arg) => { | |||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
| async function createMainWindow(app: App) { | async function createMainWindow(app: App) { | ||||||
|     const windowStateKeeper = require('electron-window-state'); // should not be statically imported
 |     const windowStateKeeper = (await import('electron-window-state')).default; // should not be statically imported
 | ||||||
| 
 | 
 | ||||||
|     const mainWindowState = windowStateKeeper({ |     const mainWindowState = windowStateKeeper({ | ||||||
|         // default window width & height, so it's usable on a 1600 * 900 display (including some extra panels etc.)
 |         // default window width & height, so it's usable on a 1600 * 900 display (including some extra panels etc.)
 | ||||||
| @ -53,7 +53,7 @@ async function createMainWindow(app: App) { | |||||||
| 
 | 
 | ||||||
|     const spellcheckEnabled = optionService.getOptionBool('spellCheckEnabled'); |     const spellcheckEnabled = optionService.getOptionBool('spellCheckEnabled'); | ||||||
| 
 | 
 | ||||||
|     const { BrowserWindow } = require('electron'); // should not be statically imported
 |     const { BrowserWindow } = (await import('electron')); // should not be statically imported
 | ||||||
| 
 | 
 | ||||||
|     mainWindow = new BrowserWindow({ |     mainWindow = new BrowserWindow({ | ||||||
|         x: mainWindowState.x, |         x: mainWindowState.x, | ||||||
| @ -100,7 +100,11 @@ function configureWebContents(webContents: WebContents, spellcheckEnabled: boole | |||||||
|     remoteMain.enable(webContents); |     remoteMain.enable(webContents); | ||||||
| 
 | 
 | ||||||
|     mainWindow.webContents.setWindowOpenHandler((details) => { |     mainWindow.webContents.setWindowOpenHandler((details) => { | ||||||
|         require('electron').shell.openExternal(details.url); |         async function openExternal() { | ||||||
|  |             (await import('electron')).shell.openExternal(details.url); | ||||||
|  |         } | ||||||
|  |          | ||||||
|  |         openExternal(); | ||||||
|         return { action: 'deny' } |         return { action: 'deny' } | ||||||
|     }); |     }); | ||||||
| 
 | 
 | ||||||
|  | |||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user
	 Elian Doran
						Elian Doran