Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(code): fix editorconfig for src/public
Elian Doranb321d99076a5
diff --git a/src/public/app/desktop.js b/src/public/app/desktop.jsindex 2621592e15..8dc5ebdff1 100644--- a/src/public/app/desktop.js+++ b/src/public/app/desktop.js@@ -16,7 +16,7 @@ bundleService.getWidgetBundlesByParent().then(async widgetBundles => {// A dynamic import is required for layouts since they initialize components which require translations.const DesktopLayout = (await import("./layouts/desktop_layout.js")).default;- appContext.setLayout(new DesktopLayout(widgetBundles));+ appContext.setLayout(new DesktopLayout(widgetBundles));appContext.start().catch((e) => {toastService.showPersistent({@@ -47,16 +47,16 @@ if (utils.isElectron()) {function initOnElectron() {const electron = utils.dynamicRequire('electron');electron.ipcRenderer.on('globalShortcut', async (event, actionName) => appContext.triggerCommand(actionName));-- const electronRemote = utils.dynamicRequire("@electron/remote");- const currentWindow = electronRemote.getCurrentWindow();++ const electronRemote = utils.dynamicRequire("@electron/remote");+ const currentWindow = electronRemote.getCurrentWindow();const style = window.getComputedStyle(document.body);initTransparencyEffects(style, currentWindow);if (options.get("nativeTitleBarVisible") !== "true") {initTitleBarButtons(style, currentWindow);- }+ }}function initTitleBarButtons(style, currentWindow) {@@ -68,7 +68,7 @@ function initTitleBarButtons(style, currentWindow) {currentWindow.setTitleBarOverlay({ color, symbolColor });}};-+applyWindowsOverlay();// Register for changes to the native title bar colors.@@ -80,7 +80,7 @@ function initTitleBarButtons(style, currentWindow) {const xOffset = parseInt(style.getPropertyValue("--native-titlebar-darwin-x-offset"), 10);const yOffset = parseInt(style.getPropertyValue("--native-titlebar-darwin-y-offset"), 10);currentWindow.setWindowButtonPosition({ x: xOffset, y: yOffset });- }+ }}function initTransparencyEffects(style, currentWindow) {@@ -88,4 +88,4 @@ function initTransparencyEffects(style, currentWindow) {const material = style.getPropertyValue("--background-material");currentWindow.setBackgroundMaterial(material);}-}\ No newline at end of file+}diff --git a/src/public/app/server_types.ts b/src/public/app/server_types.tsindex cdbb1c9ec3..e3e87c7714 100644--- a/src/public/app/server_types.ts+++ b/src/public/app/server_types.ts@@ -1,18 +1,18 @@// TODO: Deduplicate with src/services/entity_changes_interface.tsexport interface EntityChange {- id?: number | null;- noteId?: string;- entityName: string;- entityId: string;- entity?: any;- positions?: Record<string, number>;- hash: string;- utcDateChanged?: string;- utcDateModified?: string;- utcDateCreated?: string;- isSynced: boolean | 1 | 0;- isErased: boolean | 1 | 0;- componentId?: string | null;- changeId?: string | null;- instanceId?: string | null;-}\ No newline at end of file+ id?: number | null;+ noteId?: string;+ entityName: string;+ entityId: string;+ entity?: any;+ positions?: Record<string, number>;+ hash: string;+ utcDateChanged?: string;+ utcDateModified?: string;+ utcDateCreated?: string;+ isSynced: boolean | 1 | 0;+ isErased: boolean | 1 | 0;+ componentId?: string | null;+ changeId?: string | null;+ instanceId?: string | null;+}diff --git a/src/public/app/types.d.ts b/src/public/app/types.d.tsindex 147ca34d61..876f57193c 100644--- a/src/public/app/types.d.ts+++ b/src/public/app/types.d.ts@@ -48,8 +48,8 @@ type RequireMethod = (moduleName: string) => any;declare global {interface Window {logError(message: string);- logInfo(message: string);-+ logInfo(message: string);+process?: ElectronProcess;glob?: CustomGlobals;}@@ -75,10 +75,10 @@ declare global {suggestion: (suggestion: Suggestion) => string | undefined}};-+interface JQuery {autocomplete: (action?: "close" | "open" | "destroy" | "val" | AutoCompleteConfig, args?: AutoCompleteArg[] | string) => JQuery<?>;-+getSelectedNotePath(): string | undefined;getSelectedNoteId(): string | null;setSelectedNotePath(notePath: string | null | undefined);@@ -88,7 +88,7 @@ declare global {}var logError: (message: string, e?: Error) => void;- var logInfo: (message: string) => void;+ var logInfo: (message: string) => void;var glob: CustomGlobals;var require: RequireMethod;var __non_webpack_require__: RequireMethod | undefined;@@ -132,7 +132,7 @@ declare global {interface MermaidLoader {}- var mermaid: {+ var mermaid: {mermaidAPI: MermaidApi;registerLayoutLoaders(loader: MermaidLoader);parse(content: string, opts: {@@ -140,7 +140,7 @@ declare global {}): {config: {layout: string;- }+ }}};var MERMAID_ELK: MermaidLoader;diff --git a/src/public/stylesheets/calendar.css b/src/public/stylesheets/calendar.cssindex c8c17d8e5d..1a54afed76 100644--- a/src/public/stylesheets/calendar.css+++ b/src/public/stylesheets/calendar.css@@ -111,4 +111,3 @@.calendar-dropdown-widget .calendar-date:not(.calendar-date-active) {cursor: pointer;}-diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.cssindex ea623f6379..50462b2130 100644--- a/src/public/stylesheets/style.css+++ b/src/public/stylesheets/style.css@@ -20,7 +20,7 @@}:root {- --submenu-opening-delay: 300ms;+ --submenu-opening-delay: 300ms;}html {@@ -30,7 +30,7 @@ html {body {/* Fix for CKEditor block gutter icon "stretching" body and causing scrollbar to appear after pressing enter- on the last line of the editor. */+ on the last line of the editor. */position: fixed;width: 100%;height: 100%;@@ -38,7 +38,7 @@ body {color: var(--main-text-color);font-family: var(--main-font-family);font-size: var(--main-font-size);-+--native-titlebar-foreground: var(--main-text-color);--native-titlebar-darwin-x-offset: 10;--native-titlebar-darwin-y-offset: 12;@@ -1097,7 +1097,7 @@ body:not(.mobile) #launcher-pane.horizontal .dropdown-submenu > .dropdown-menu {cursor: pointer;border: none;color: var(--launcher-pane-text-color);- background-color: var(--launcher-pane-background-color);+ background-color: var(--launcher-pane-background-color);}#launcher-pane.vertical .launcher-button {@@ -1297,7 +1297,7 @@ body.electron.platform-darwin:not(.native-titlebar) .tab-row-container {width: 24px;height: 24px;color: var(--launcher-pane-text-color);- margin: 8px 10px;+ margin: 8px 10px;font-size: 18px;}@@ -1313,4 +1313,4 @@ body.electron.platform-darwin:not(.native-titlebar) .tab-row-container {border-color: var(--hover-item-border-color);background: var(--hover-item-background-color);color: var(--hover-item-text-color);-}\ No newline at end of file+}diff --git a/src/public/stylesheets/theme-dark.css b/src/public/stylesheets/theme-dark.cssindex d058b93515..a80a2df1d1 100644--- a/src/public/stylesheets/theme-dark.css+++ b/src/public/stylesheets/theme-dark.css@@ -100,4 +100,4 @@ body .todo-list input[type="checkbox"]:not(:checked):before {.ck-content pre {box-shadow: 1px 1px 3px rgba(0, 0, 0, 0.6) !important;-}\ No newline at end of file+}diff --git a/src/public/stylesheets/theme-light.css b/src/public/stylesheets/theme-light.cssindex 0b59979ee5..3bf9810bef 100644--- a/src/public/stylesheets/theme-light.css+++ b/src/public/stylesheets/theme-light.css@@ -1,6 +1,6 @@/* Light theme is special since it's also baseline/default so when a theme does not define some variable then- value from this theme will be used. For this reason this theme uses "html" instead of ":root"- since it's less "specific" and thus serves as default */+ value from this theme will be used. For this reason this theme uses "html" instead of ":root"+ since it's less "specific" and thus serves as default */html {/* either light or dark, colored theme with darker tones are also dark, used e.g. for note map node colors */--theme-style: light;diff --git a/src/public/stylesheets/theme-next-dark.css b/src/public/stylesheets/theme-next-dark.cssindex ad85706e48..05b481901e 100644--- a/src/public/stylesheets/theme-next-dark.css+++ b/src/public/stylesheets/theme-next-dark.css@@ -9,7 +9,7 @@--native-titlebar-background: #00000000;--main-background-color: #333;- --main-text-color: #ccc;+ --main-text-color: #ccc;--main-border-color: #454545;--subtle-border-color: #313131;--dropdown-border-color: #292929;@@ -81,7 +81,7 @@--left-pane-item-action-button-hover-background: #ffffffad;--left-pane-item-action-button-hover-shadow: 2px 2px 3px rgba(0, 0, 0, .15);--left-pane-item-selected-action-button-hover-shadow: 2px 2px 10px rgba(0, 0, 0, .25);-+--launcher-pane-background-color: #1a1a1a;--launcher-pane-horizontal-background-color: #282828;--launcher-pane-horizontal-border-color: rgb(22, 22, 22);@@ -145,8 +145,8 @@--tooltip-shadow-color: rgba(0, 0, 0, 0.4);}-/*- * Dark color scheme tweaks+/*+ * Dark color scheme tweaks*/body ::-webkit-calendar-picker-indicator {@@ -167,4 +167,4 @@ body .todo-list input[type="checkbox"]:not(:checked):before {.btn-close {filter: invert(1);-}\ No newline at end of file+}diff --git a/src/public/stylesheets/theme-next-light.css b/src/public/stylesheets/theme-next-light.cssindex 1d06abc9da..8ad0ee213a 100644--- a/src/public/stylesheets/theme-next-light.css+++ b/src/public/stylesheets/theme-next-light.css@@ -1,5 +1,5 @@/* Import the Next theme base style */-@import url(./theme-next/base.css);+@import url(./theme-next/base.css);/** Color scheme@@ -7,7 +7,7 @@:root {--theme-style: light;--native-titlebar-background: #ffffff00;-+--main-background-color: white;--main-text-color: black;--main-border-color: #dbdbdb;@@ -16,33 +16,33 @@--dropdown-shadow-opacity: .2;--dropdown-item-icon-destructive-color: #ec5138;--disabled-tooltip-icon-color: #004382;-- --accented-background-color: #f5f5f5;-++ --accented-background-color: #f5f5f5;+--button-background-color: transparent;--button-border-color: #ddd;--button-text-color: black;--button-border-radius: 5px;--button-disabled-background-color: #ddd;--button-disabled-text-color: black;-+--primary-button-background-color: #6c757d;--primary-button-text-color: white;--primary-button-border-color: #6c757d;-+--muted-text-color: #666;-+--input-text-color: black;--input-background-color: transparent;-+--hover-item-text-color: black;--hover-item-background-color: #0000001a;--hover-item-border-color: transparent;-+--active-item-text-color: var(--left-pane-text-color);--active-item-background-color: #ddd;--active-item-border-color: transparent;-+--menu-text-color: #272727;--menu-background-color: #ffffffd9;--menu-item-icon-color: #727272;@@ -50,17 +50,17 @@--menu-item-keyboard-shortcut-color: #666666a8;--menu-item-arrow-color: #00000080;--menu-item-delimiter-color: #00000030;-+--modal-background-color: white;--modal-backdrop-color: black;-+--quick-search-background: #00000012;--quick-search-color: #06060682;--quick-search-hover-background: #00000020;--quick-search-focus-border: #00000029;--quick-search-focus-background: #ffffff80;--quick-search-focus-color: #000;-+--left-pane-collapsed-border-color: #0000000d;--left-pane-background-color: #f2f2f2;--left-pane-text-color: #383838;@@ -73,7 +73,7 @@--left-pane-item-action-button-hover-background: white;--left-pane-item-action-button-hover-shadow: 2px 2px 3px rgba(0, 0, 0, .15);--left-pane-item-selected-action-button-hover-shadow: 2px 2px 10px rgba(0, 0, 0, .25);-+--launcher-pane-background-color: #e8e8e8;--launcher-pane-horizontal-background-color: #fafafa;--launcher-pane-horizontal-border-color: rgba(0, 0, 0, 0.1);@@ -81,65 +81,65 @@--launcher-pane-button-hover-color: black;--launcher-pane-button-hover-background: white;--launcher-pane-button-hover-shadow: 4px 4px 4px rgba(0, 0, 0, .075);-+--protected-session-active-icon-color: #16b516;--sync-status-error-pulse-color: #ff5528;-+--root-background: var(--left-pane-background-color);-+--gutter-color: transparent;--gutter-hover-color: #bfbfbf;-+--tab-close-button-hover-background: #c95a5a;--tab-close-button-hover-color: white;-+--active-tab-background-color: white;--active-tab-hover-background-color: var(--active-tab-background-color);--active-tab-text-color: black;--active-tab-shadow: 3px 3px 6px rgba(0, 0, 0, .1), -1px -1px 3px rgba(0, 0, 0, .05);--active-tab-dragging-shadow: var(--active-tab-shadow), 0 0 20px rgba(0, 0, 0, .1);-+--inactive-tab-background-color: transparent;--inactive-tab-hover-background-color: #00000016;--inactive-tab-text-color: #4e4e4e;-+--new-tab-button-background: #d8d8d8;--new-tab-button-color: #3a3a3a;--new-tab-button-shadow: 2px 2px 4px rgba(0, 0, 0, .2);--new-tab-button-hover-background: white;--new-tab-button-hover-color: black;-+--right-pane-item-hover-background: #ececec;--right-pane-item-hover-color: inherit;-+--scrollbar-border-color: #ddd;--scrollbar-background-color: #ddd;--link-color: blue;-- --mermaid-theme: default;-++ --mermaid-theme: default;+--code-block-box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.1), 0px 0px 2px rgba(0, 0, 0, 0.2);-+--card-background-color: var(--accented-background-color);--card-background-hover-color: #f9f9f9;--card-background-press-color: #efefef;--card-border-color: #eaeaea;--card-shadow-color: rgba(0, 0, 0, 0.1);--card-box-shadow: 0 0 12px var(--card-shadow-color);-+--calendar-color: var(--menu-text-color);--calendar-weekday-labels-color: var(--muted-text-color);--calendar-day-hover-color: var(--hover-item-text-color);--calendar-day-hover-background: var(--active-item-background-color);--calendar-day-highlight-background: #80808024;-+--timeline-bullet-color: #a5a5a5;--timeline-bullet-hover-color: black;--timeline-connector-color: #f1f1f1;--timeline-connector-active-color: #ddd;--timeline-connector-hover-blend-mode: multiply;-+--tooltip-background-color: rgba(255, 255, 255, 0.85);--tooltip-foreground-color: #000000ba;--tooltip-shadow-color: rgba(0, 0, 0, .15);- }\ No newline at end of file+ }diff --git a/src/public/stylesheets/theme-next.css b/src/public/stylesheets/theme-next.cssindex 4dffcdae55..c740a30064 100644--- a/src/public/stylesheets/theme-next.css+++ b/src/public/stylesheets/theme-next.css@@ -1,7 +1,7 @@-/* Import the light color scheme.+/* Import the light color scheme.* This is the base color scheme, always active and overridden by the dark* color scheme stylesheet when necessary. */@import url(./theme-next-light.css);/* Import the dark color scheme when the system preference is set to dark mode */-@import url(./theme-next-dark.css) (prefers-color-scheme: dark);\ No newline at end of file+@import url(./theme-next-dark.css) (prefers-color-scheme: dark);diff --git a/src/public/stylesheets/theme.css b/src/public/stylesheets/theme.cssindex f8ac50dd47..35a22e516c 100644--- a/src/public/stylesheets/theme.css+++ b/src/public/stylesheets/theme.css@@ -1,7 +1,7 @@-/* Import the light color scheme.+/* Import the light color scheme.* This is the base color scheme, always active and overridden by the dark* color scheme stylesheet when necessary. */@import url(./theme-light.css);/* Import the dark color scheme when the system preference is set to dark mode */-@import url(./theme-dark.css) (prefers-color-scheme: dark);\ No newline at end of file+@import url(./theme-dark.css) (prefers-color-scheme: dark);diff --git a/src/routes/api/autocomplete.ts b/src/routes/api/autocomplete.tsindex 3e4487d085..1ec55bfb6c 100644--- a/src/routes/api/autocomplete.ts+++ b/src/routes/api/autocomplete.ts@@ -15,7 +15,7 @@ function getAutocomplete(req: Request) {}const query = (req.query.query || "").trim();const fastSearch = String(req.query.fastSearch).toLowerCase() === "false" ? false : true;-+const activeNoteId = req.query.activeNoteId || 'none';let results;@@ -49,18 +49,18 @@ function getRecentNotes(activeNoteId: string) {}const recentNotes = becca.getRecentNotesFromQuery(`- SELECT- recent_notes.*- FROM+ SELECT+ recent_notes.*+ FROMrecent_notesJOIN notes USING(noteId)- WHERE+ WHEREnotes.isDeleted = 0AND notes.noteId != ?${extraCondition}- ORDER BY+ ORDER BYutcDateCreated DESC- LIMIT 200`, params);+ LIMIT 200`, params);return recentNotes.map(rn => {const notePathArray = rn.notePath.split('/');diff --git a/src/routes/api/files.ts b/src/routes/api/files.tsindex 753aeabf82..2eb3ee37b8 100644--- a/src/routes/api/files.ts+++ b/src/routes/api/files.ts@@ -176,7 +176,7 @@ function saveToTmpDir(fileName: string, content: string | Buffer, entityType: stif (typeof content === "string") {fs.writeSync(tmpObj.fd, content);} else {- fs.writeSync(tmpObj.fd, content);+ fs.writeSync(tmpObj.fd, content);}fs.closeSync(tmpObj.fd);diff --git a/src/routes/api/image.ts b/src/routes/api/image.tsindex 1d0bcb9c2a..5c8bd417e3 100644--- a/src/routes/api/image.ts+++ b/src/routes/api/image.ts@@ -107,7 +107,7 @@ function updateImage(req: Request) {message: "Invalid image content."};}-+imageService.updateImage(noteId, file.buffer, file.originalname);return { uploaded: true };diff --git a/src/routes/api/notes.ts b/src/routes/api/notes.tsindex c47aad91ce..7f3c02124a 100644--- a/src/routes/api/notes.ts+++ b/src/routes/api/notes.ts@@ -219,9 +219,9 @@ function getDeleteNotesPreview(req: Request) {brokenRelations = sql.getRows<AttributeRow>(`SELECT attr.noteId, attr.name, attr.valueFROM attributes attr- JOIN param_list ON param_list.paramId = attr.value+ JOIN param_list ON param_list.paramId = attr.valueWHERE attr.isDeleted = 0- AND attr.type = 'relation'`).filter(attr => attr.noteId && !noteIdsToBeDeleted.has(attr.noteId));+ AND attr.type = 'relation'`).filter(attr => attr.noteId && !noteIdsToBeDeleted.has(attr.noteId));}return {diff --git a/src/routes/api/recent_changes.ts b/src/routes/api/recent_changes.tsindex 788ae17e0b..8cf0a37c0d 100644--- a/src/routes/api/recent_changes.ts+++ b/src/routes/api/recent_changes.ts@@ -25,7 +25,7 @@ function getRecentChanges(req: Request) {let recentChanges = [];const revisionRows = sql.getRows<RecentChangeRow>(`- SELECT+ SELECTnotes.noteId,notes.isDeleted AS current_isDeleted,notes.deleteId AS current_deleteId,@@ -34,7 +34,7 @@ function getRecentChanges(req: Request) {revisions.title,revisions.utcDateCreated AS utcDate,revisions.dateCreated AS date- FROM+ FROMrevisionsJOIN notes USING(noteId)`);diff --git a/src/routes/api/revisions.ts b/src/routes/api/revisions.tsindex 0d55faee32..9dfb8824e3 100644--- a/src/routes/api/revisions.ts+++ b/src/routes/api/revisions.ts@@ -35,9 +35,9 @@ function getRevisionBlob(req: Request) {function getRevisions(req: Request) {return becca.getRevisionsFromQuery(`SELECT revisions.*,- LENGTH(blobs.content) AS contentLength+ LENGTH(blobs.content) AS contentLengthFROM revisions- JOIN blobs ON revisions.blobId = blobs.blobId+ JOIN blobs ON revisions.blobId = blobs.blobIdWHERE revisions.noteId = ?ORDER BY revisions.utcDateCreated DESC`, [req.params.noteId]);}@@ -158,9 +158,9 @@ function getEditedNotesOnDate(req: Request) {SELECT notes.*FROM notesWHERE noteId IN (- SELECT noteId FROM notes+ SELECT noteId FROM notesWHERE notes.dateCreated LIKE :date- OR notes.dateModified LIKE :date+ OR notes.dateModified LIKE :dateUNION ALLSELECT noteId FROM revisionsWHERE revisions.dateLastEdited LIKE :datediff --git a/src/routes/api/sql.ts b/src/routes/api/sql.tsindex 9e2f6b09af..703a38065f 100644--- a/src/routes/api/sql.ts+++ b/src/routes/api/sql.ts@@ -40,7 +40,7 @@ function execute(req: Request) {const pivot = query.indexOf('\n');query = pivot > 0 ? query.substr(pivot + 1).trim() : "";}-+if (!query) {continue;}diff --git a/src/routes/api/stats.ts b/src/routes/api/stats.tsindex aa948930ef..769fe1c4b8 100644--- a/src/routes/api/stats.ts+++ b/src/routes/api/stats.ts@@ -11,9 +11,9 @@ function getNoteSize(req: Request) {LEFT JOIN notes ON notes.blobId = blobs.blobId AND notes.noteId = ? AND notes.isDeleted = 0LEFT JOIN attachments ON attachments.blobId = blobs.blobId AND attachments.ownerId = ? AND attachments.isDeleted = 0LEFT JOIN revisions ON revisions.blobId = blobs.blobId AND revisions.noteId = ?- WHERE notes.noteId IS NOT NULL- OR attachments.attachmentId IS NOT NULL- OR revisions.revisionId IS NOT NULL`, [noteId, noteId, noteId]);+ WHERE notes.noteId IS NOT NULL+ OR attachments.attachmentId IS NOT NULL+ OR revisions.revisionId IS NOT NULL`, [noteId, noteId, noteId]);const noteSize = Object.values(blobSizes).reduce((acc, blobSize) => acc + blobSize, 0);diff --git a/src/routes/api/sync.ts b/src/routes/api/sync.tsindex 6089ae42c9..2f4766b295 100644--- a/src/routes/api/sync.ts+++ b/src/routes/api/sync.ts@@ -103,7 +103,7 @@ function getChanged(req: Request) {SELECT *FROM entity_changesWHERE isSynced = 1- AND id > ?+ AND id > ?ORDER BY idLIMIT 1000`, [lastEntityChangeId]);@@ -130,11 +130,11 @@ function getChanged(req: Request) {entityChanges: entityChangeRecords,lastEntityChangeId,outstandingPullCount: sql.getValue(`- SELECT COUNT(id)- FROM entity_changes- WHERE isSynced = 1- AND instanceId != ?- AND id > ?`, [clientInstanceId, lastEntityChangeId])+ SELECT COUNT(id)+ FROM entity_changes+ WHERE isSynced = 1+ AND instanceId != ?+ AND id > ?`, [clientInstanceId, lastEntityChangeId])};}diff --git a/src/routes/assets.ts b/src/routes/assets.tsindex 3b7c9ce9d8..fab3d61397 100644--- a/src/routes/assets.ts+++ b/src/routes/assets.ts@@ -18,22 +18,22 @@ const persistentCacheStatic = (root: string, options?: serveStatic.ServeStaticOpasync function register(app: express.Application) {const srcRoot = path.join(path.dirname(fileURLToPath(import.meta.url)), '..');if (env.isDev()) {- const webpack = (await import("webpack")).default;- const webpackMiddleware = (await import("webpack-dev-middleware")).default;- const productionConfig = (await import("../../webpack.config.js")).default;+ const webpack = (await import("webpack")).default;+ const webpackMiddleware = (await import("webpack-dev-middleware")).default;+ const productionConfig = (await import("../../webpack.config.js")).default;- const frontendCompiler = webpack({+ const frontendCompiler = webpack({mode: "development",entry: productionConfig.entry,module: productionConfig.module,resolve: productionConfig.resolve,devtool: productionConfig.devtool,target: productionConfig.target- });-- app.use(`/${assetPath}/app`, webpackMiddleware(frontendCompiler));+ });++ app.use(`/${assetPath}/app`, webpackMiddleware(frontendCompiler));} else {- app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, 'public/app')));+ app.use(`/${assetPath}/app`, persistentCacheStatic(path.join(srcRoot, 'public/app')));}app.use(`/${assetPath}/app-dist`, persistentCacheStatic(path.join(srcRoot, 'public/app-dist')));app.use(`/${assetPath}/fonts`, persistentCacheStatic(path.join(srcRoot, 'public/fonts')));@@ -56,19 +56,19 @@ async function register(app: express.Application) {// KaTeXapp.use(- `/${assetPath}/node_modules/katex/dist/katex.min.js`,- persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/katex.min.js')));+ `/${assetPath}/node_modules/katex/dist/katex.min.js`,+ persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/katex.min.js')));app.use(- `/${assetPath}/node_modules/katex/dist/contrib/mhchem.min.js`,- persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/contrib/mhchem.min.js')));+ `/${assetPath}/node_modules/katex/dist/contrib/mhchem.min.js`,+ persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/contrib/mhchem.min.js')));app.use(- `/${assetPath}/node_modules/katex/dist/contrib/auto-render.min.js`,- persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/contrib/auto-render.min.js')));+ `/${assetPath}/node_modules/katex/dist/contrib/auto-render.min.js`,+ persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/contrib/auto-render.min.js')));// expose the whole dist folderapp.use(`/node_modules/katex/dist/`,- express.static(path.join(srcRoot, '..', 'node_modules/katex/dist/')));+ express.static(path.join(srcRoot, '..', 'node_modules/katex/dist/')));app.use(`/${assetPath}/node_modules/katex/dist/`,- persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/')));+ persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/katex/dist/')));app.use(`/${assetPath}/node_modules/dayjs/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/dayjs/')));app.use(`/${assetPath}/node_modules/force-graph/dist/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/force-graph/dist/')));@@ -98,9 +98,9 @@ async function register(app: express.Application) {app.use(`/${assetPath}/node_modules/jsplumb/dist/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/jsplumb/dist/')));app.use(`/${assetPath}/node_modules/vanilla-js-wheel-zoom/dist/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/vanilla-js-wheel-zoom/dist/')));-+app.use(`/${assetPath}/node_modules/mark.js/dist/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/mark.js/dist/')));-+// Deprecated, https://www.npmjs.com/package/autocomplete.js?activeTab=readmeapp.use(`/${assetPath}/node_modules/autocomplete.js/dist/`, persistentCacheStatic(path.join(srcRoot, '..', 'node_modules/autocomplete.js/dist/')));diff --git a/src/routes/setup.ts b/src/routes/setup.tsindex 34d886aec5..d2ade1d88a 100644--- a/src/routes/setup.ts+++ b/src/routes/setup.ts@@ -10,7 +10,7 @@ import { Request, Response } from 'express';function setupPage(req: Request, res: Response) {if (sqlInit.isDbInitialized()) {if (utils.isElectron()) {- handleElectronRedirect();+ handleElectronRedirect();} else {res.redirect('.');}diff --git a/src/services/anonymization.ts b/src/services/anonymization.tsindex 8c34122b61..81eb26be49 100644--- a/src/services/anonymization.ts+++ b/src/services/anonymization.ts@@ -23,10 +23,10 @@ UPDATE attributes SET name = 'name', value = 'value' WHERE type = 'label' AND naUPDATE attributes SET name = 'name' WHERE type = 'relation' AND name NOT IN (${builtinAttrNames});UPDATE branches SET prefix = 'prefix' WHERE prefix IS NOT NULL AND prefix != 'recovered';UPDATE options SET value = 'anonymized' WHERE name IN- ('documentId', 'documentSecret', 'encryptedDataKey',- 'passwordVerificationHash', 'passwordVerificationSalt',- 'passwordDerivedKeySalt', 'username', 'syncServerHost', 'syncProxy')- AND value != '';+ ('documentId', 'documentSecret', 'encryptedDataKey',+ 'passwordVerificationHash', 'passwordVerificationSalt',+ 'passwordDerivedKeySalt', 'username', 'syncServerHost', 'syncProxy')+ AND value != '';VACUUM;`;@@ -37,15 +37,15 @@ VACUUM;function getLightAnonymizationScript() {return `UPDATE blobs SET content = 'text' WHERE content IS NOT NULL AND blobId NOT IN (SELECT blobId FROM notes WHERE mime IN ('application/javascript;env=backend', 'application/javascript;env=frontend')- UNION ALL+ UNION ALLSELECT blobId FROM revisions WHERE mime IN ('application/javascript;env=backend', 'application/javascript;env=frontend'));UPDATE options SET value = 'anonymized' WHERE name IN- ('documentId', 'documentSecret', 'encryptedDataKey',- 'passwordVerificationHash', 'passwordVerificationSalt',- 'passwordDerivedKeySalt', 'username', 'syncServerHost', 'syncProxy')- AND value != '';`;+ ('documentId', 'documentSecret', 'encryptedDataKey',+ 'passwordVerificationHash', 'passwordVerificationSalt',+ 'passwordDerivedKeySalt', 'username', 'syncServerHost', 'syncProxy')+ AND value != '';`;}async function createAnonymizedCopy(type: "full" | "light") {diff --git a/src/services/api-interface.ts b/src/services/api-interface.tsindex a474b09d59..14432eb439 100644--- a/src/services/api-interface.ts+++ b/src/services/api-interface.ts@@ -14,4 +14,4 @@ export interface SetupStatusResponse {export interface SetupSyncSeedResponse {syncVersion: number;options: OptionRow[]-}\ No newline at end of file+}diff --git a/src/services/app_icon.ts b/src/services/app_icon.tsindex 4385bf20a7..43613e4e57 100644--- a/src/services/app_icon.ts+++ b/src/services/app_icon.ts@@ -48,7 +48,7 @@ function installLocalAppIcon() {fs.writeFile(desktopFilePath, getDesktopFileContent(), function (err) {if (err) {- log.error("Desktop icon installation to ~/.local/share/applications failed.");+ log.error("Desktop icon installation to ~/.local/share/applications failed.");}});}@@ -66,7 +66,7 @@ function escapePath(path: string) {}function getExePath() {- return path.resolve(resourceDir.ELECTRON_APP_ROOT_DIR, 'trilium');+ return path.resolve(resourceDir.ELECTRON_APP_ROOT_DIR, 'trilium');}export default {diff --git a/src/services/attributes.ts b/src/services/attributes.tsindex 8f17249e2e..25b54724be 100644--- a/src/services/attributes.ts+++ b/src/services/attributes.ts@@ -65,11 +65,11 @@ function getAttributeNames(type: string, nameLike: string) {nameLike = nameLike.toLowerCase();let names = sql.getColumn<string>(- `SELECT DISTINCT name- FROM attributes- WHERE isDeleted = 0- AND type = ?- AND name LIKE ?`, [type, `%${nameLike}%`]);+ `SELECT DISTINCT name+ FROM attributes+ WHERE isDeleted = 0+ AND type = ?+ AND name LIKE ?`, [type, `%${nameLike}%`]);for (const attr of BUILTIN_ATTRIBUTES) {if (attr.type === type && attr.name.toLowerCase().includes(nameLike) && !names.includes(attr.name)) {diff --git a/src/services/backend_script_api.ts b/src/services/backend_script_api.tsindex 02b14549c5..2c3e0af05c 100644--- a/src/services/backend_script_api.ts+++ b/src/services/backend_script_api.ts@@ -61,53 +61,53 @@ interface NoteAndBranch {interface Api {/**- * Note where the script started executing (entrypoint).- * As an analogy, in C this would be the file which contains the main() function of the current process.- */+ * Note where the script started executing (entrypoint).+ * As an analogy, in C this would be the file which contains the main() function of the current process.+ */startNote?: BNote | null;/**- * Note where the script is currently executing. This comes into play when your script is spread in multiple code- * notes, the script starts in "startNote", but then through function calls may jump into another note (currentNote).- * A similar concept in C would be __FILE__- * Don't mix this up with the concept of active note.- */+ * Note where the script is currently executing. This comes into play when your script is spread in multiple code+ * notes, the script starts in "startNote", but then through function calls may jump into another note (currentNote).+ * A similar concept in C would be __FILE__+ * Don't mix this up with the concept of active note.+ */currentNote: BNote;/**- * Entity whose event triggered this execution- */+ * Entity whose event triggered this execution+ */originEntity?: AbstractBeccaEntity<any> | null;-+/**- * Axios library for HTTP requests. See {@link https://axios-http.com} for documentation- * @deprecated use native (browser compatible) fetch() instead- */+ * Axios library for HTTP requests. See {@link https://axios-http.com} for documentation+ * @deprecated use native (browser compatible) fetch() instead+ */axios: typeof axios;/**- * day.js library for date manipulation. See {@link https://day.js.org} for documentation- */+ * day.js library for date manipulation. See {@link https://day.js.org} for documentation+ */dayjs: typeof dayjs;/**- * xml2js library for XML parsing. See {@link https://github.com/Leonidas-from-XIV/node-xml2js} for documentation- */+ * xml2js library for XML parsing. See {@link https://github.com/Leonidas-from-XIV/node-xml2js} for documentation+ */xml2js: typeof xml2js;/**- * cheerio library for HTML parsing and manipulation. See {@link https://cheerio.js.org} for documentation- */+ * cheerio library for HTML parsing and manipulation. See {@link https://cheerio.js.org} for documentation+ */cheerio: typeof cheerio;-+/**- * Instance name identifies particular Trilium instance. It can be useful for scripts- * if some action needs to happen on only one specific instance.- */+ * Instance name identifies particular Trilium instance. It can be useful for scripts+ * if some action needs to happen on only one specific instance.+ */getInstanceName(): string | null;-+getNote(noteId: string): BNote | null;getBranch(branchId: string): BBranch | null;getAttribute(attachmentId: string): BAttribute | null;@@ -118,78 +118,78 @@ interface Api {getOption(optionName: string): BOption | null;getOptions(): BOption[];getAttribute(attributeId: string): BAttribute | null;-+/**- * This is a powerful search method - you can search by attributes and their values, e.g.:- * "#dateModified =* MONTH AND #log". See {@link https://triliumnext.github.io/Docs/Wiki/search.html} for full documentation for all options- */+ * This is a powerful search method - you can search by attributes and their values, e.g.:+ * "#dateModified =* MONTH AND #log". See {@link https://triliumnext.github.io/Docs/Wiki/search.html} for full documentation for all options+ */searchForNotes(query: string, searchParams: SearchParams): BNote[];-+/**- * This is a powerful search method - you can search by attributes and their values, e.g.:- * "#dateModified =* MONTH AND #log". See {@link https://triliumnext.github.io/Docs/Wiki/search.html} for full documentation for all options- */+ * This is a powerful search method - you can search by attributes and their values, e.g.:+ * "#dateModified =* MONTH AND #log". See {@link https://triliumnext.github.io/Docs/Wiki/search.html} for full documentation for all options+ */searchForNote(query: string, searchParams: SearchParams): BNote | null;-+/**- * Retrieves notes with given label name & value- *- * @param name - attribute name- * @param value - attribute value- */+ * Retrieves notes with given label name & value+ *+ * @param name - attribute name+ * @param value - attribute value+ */getNotesWithLabel(name: string, value?: string): BNote[];/**- * Retrieves first note with given label name & value- *- * @param name - attribute name- * @param value - attribute value- */+ * Retrieves first note with given label name & value+ *+ * @param name - attribute name+ * @param value - attribute value+ */getNoteWithLabel(name: string, value?: string): BNote | null;/**- * If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.- *- * @param prefix - if branch is created between note and parent note, set this prefix- */+ * If there's no branch between note and parent note, create one. Otherwise, do nothing. Returns the new or existing branch.+ *+ * @param prefix - if branch is created between note and parent note, set this prefix+ */ensureNoteIsPresentInParent(noteId: string, parentNoteId: string, prefix: string): {branch: BBranch | null};/**- * If there's a branch between note and parent note, remove it. Otherwise, do nothing.- */+ * If there's a branch between note and parent note, remove it. Otherwise, do nothing.+ */ensureNoteIsAbsentFromParent(noteId: string, parentNoteId: string): void;/**- * Based on the value, either create or remove branch between note and parent note.- *- * @param present - true if we want the branch to exist, false if we want it gone- * @param prefix - if branch is created between note and parent note, set this prefix- */+ * Based on the value, either create or remove branch between note and parent note.+ *+ * @param present - true if we want the branch to exist, false if we want it gone+ * @param prefix - if branch is created between note and parent note, set this prefix+ */toggleNoteInParent(present: true, noteId: string, parentNoteId: string, prefix: string): void;/**- * Create text note. See also createNewNote() for more options.- */+ * Create text note. See also createNewNote() for more options.+ */createTextNote(parentNoteId: string, title: string, content: string): NoteAndBranch;/**- * Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and- * JSON MIME type. See also createNewNote() for more options.- */+ * Create data note - data in this context means object serializable to JSON. Created note will be of type 'code' and+ * JSON MIME type. See also createNewNote() for more options.+ */createDataNote(parentNoteId: string, title: string, content: {}): NoteAndBranch;/**- * @returns object contains newly created entities note and branch- */+ * @returns object contains newly created entities note and branch+ */createNewNote(params: NoteParams): NoteAndBranch;/**- * @deprecated please use createTextNote() with similar API for simpler use cases or createNewNote() for more complex needs- * @param parentNoteId - create new note under this parent- * @returns object contains newly created entities note and branch- */+ * @deprecated please use createTextNote() with similar API for simpler use cases or createNewNote() for more complex needs+ * @param parentNoteId - create new note under this parent+ * @returns object contains newly created entities note and branch+ */createNote(parentNoteId: string, title: string, content: string, extraOptions: Omit<NoteParams, "title" | "content" | "type" | "parentNoteId"> & {/** should the note be JSON */json?: boolean;@@ -200,37 +200,37 @@ interface Api {logSpacedUpdates: Record<string, SpacedUpdate>;/**- * Log given message to trilium logs and log pane in UI- */+ * Log given message to trilium logs and log pane in UI+ */log(message: string): void;/**- * Returns root note of the calendar.- */+ * Returns root note of the calendar.+ */getRootCalendarNote(): BNote | null;/**- * Returns day note for given date. If such note doesn't exist, it is created.- *- * @method- * @param date in YYYY-MM-DD format- * @param rootNote - specify calendar root note, normally leave empty to use the default calendar- */+ * Returns day note for given date. If such note doesn't exist, it is created.+ *+ * @method+ * @param date in YYYY-MM-DD format+ * @param rootNote - specify calendar root note, normally leave empty to use the default calendar+ */getDayNote(date: string, rootNote?: BNote): BNote | null;/**- * Returns today's day note. If such note doesn't exist, it is created.- *- * @param rootNote specify calendar root note, normally leave empty to use the default calendar- */+ * Returns today's day note. If such note doesn't exist, it is created.+ *+ * @param rootNote specify calendar root note, normally leave empty to use the default calendar+ */getTodayNote(rootNote?: BNote): BNote | null;/**- * Returns note for the first date of the week of the given date.- *- * @param date in YYYY-MM-DD format- * @param rootNote - specify calendar root note, normally leave empty to use the default calendar- */+ * Returns note for the first date of the week of the given date.+ *+ * @param date in YYYY-MM-DD format+ * @param rootNote - specify calendar root note, normally leave empty to use the default calendar+ */getWeekNote(date: string, options: {// TODO: Deduplicate type with date_notes.ts once ES modules are added./** either "monday" (default) or "sunday" */@@ -238,90 +238,90 @@ interface Api {}, rootNote: BNote): BNote | null;/**- * Returns month note for given date. If such a note doesn't exist, it is created.- *- * @param date in YYYY-MM format- * @param rootNote - specify calendar root note, normally leave empty to use the default calendar- */+ * Returns month note for given date. If such a note doesn't exist, it is created.+ *+ * @param date in YYYY-MM format+ * @param rootNote - specify calendar root note, normally leave empty to use the default calendar+ */getMonthNote(date: string, rootNote: BNote): BNote | null;/**- * Returns year note for given year. If such a note doesn't exist, it is created.- *- * @param year in YYYY format- * @param rootNote - specify calendar root note, normally leave empty to use the default calendar- */+ * Returns year note for given year. If such a note doesn't exist, it is created.+ *+ * @param year in YYYY format+ * @param rootNote - specify calendar root note, normally leave empty to use the default calendar+ */getYearNote(year: string, rootNote?: BNote): BNote | null;/**- * Sort child notes of a given note.- */+ * Sort child notes of a given note.+ */sortNotes(parentNoteId: string, sortConfig: {/** 'title', 'dateCreated', 'dateModified' or a label name- * See {@link https://triliumnext.github.io/Docs/Wiki/sorting.html} for details. */+ * See {@link https://triliumnext.github.io/Docs/Wiki/sorting.html} for details. */sortBy?: string;reverse?: boolean;foldersFirst?: boolean;}): void;/**- * This method finds note by its noteId and prefix and either sets it to the given parentNoteId- * or removes the branch (if parentNoteId is not given).- *- * This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.- *- * @deprecated this method is pretty confusing and serves specialized purpose only- */+ * This method finds note by its noteId and prefix and either sets it to the given parentNoteId+ * or removes the branch (if parentNoteId is not given).+ *+ * This method looks similar to toggleNoteInParent() but differs because we're looking up branch by prefix.+ *+ * @deprecated this method is pretty confusing and serves specialized purpose only+ */setNoteToParent(noteId: string, prefix: string, parentNoteId: string | null): void;/**- * This functions wraps code which is supposed to be running in transaction. If transaction already- * exists, then we'll use that transaction.- *- * @param func- * @returns result of func callback- */+ * This functions wraps code which is supposed to be running in transaction. If transaction already+ * exists, then we'll use that transaction.+ *+ * @param func+ * @returns result of func callback+ */transactional(func: () => void): any;/**- * Return randomly generated string of given length. This random string generation is NOT cryptographically secure.- *- * @param length of the string- * @returns random string- */+ * Return randomly generated string of given length. This random string generation is NOT cryptographically secure.+ *+ * @param length of the string+ * @returns random string+ */randomString(length: number): string;/**- * @param to escape- * @returns escaped string- */+ * @param to escape+ * @returns escaped string+ */escapeHtml(string: string): string;/**- * @param string to unescape- * @returns unescaped string- */+ * @param string to unescape+ * @returns unescaped string+ */unescapeHtml(string: string): string;/**- * sql- * @type {module:sql}- */+ * sql+ * @type {module:sql}+ */sql: any;getAppInfo(): typeof appInfo;/**- * Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.- */+ * Creates a new launcher to the launchbar. If the launcher (id) already exists, it will be updated.+ */createOrUpdateLauncher(opts: {/** id of the launcher, only alphanumeric at least 6 characters long */id: string;/** one of- * - "note" - activating the launcher will navigate to the target note (specified in targetNoteId param)- * - "script" - activating the launcher will execute the script (specified in scriptNoteId param)- * - "customWidget" - the launcher will be rendered with a custom widget (specified in widgetNoteId param)- */+ * - "note" - activating the launcher will navigate to the target note (specified in targetNoteId param)+ * - "script" - activating the launcher will execute the script (specified in scriptNoteId param)+ * - "customWidget" - the launcher will be rendered with a custom widget (specified in widgetNoteId param)+ */type: "note" | "script" | "customWidget";title: string;/** if true, will be created in the "Visible launchers", otherwise in "Available launchers" */@@ -339,44 +339,44 @@ interface Api {}): { note: BNote };/**- * @param format - either 'html' or 'markdown'- */+ * @param format - either 'html' or 'markdown'+ */exportSubtreeToZipFile(noteId: string, format: "markdown" | "html", zipFilePath: string): Promise<void>;/**- * Executes given anonymous function on the frontend(s).- * Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.- * Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all- * instances execute the given function.- *- * @param script - script to be executed on the frontend- * @param params - list of parameters to the anonymous function to be sent to frontend- * @returns no return value is provided.- */+ * Executes given anonymous function on the frontend(s).+ * Internally, this serializes the anonymous function into string and sends it to frontend(s) via WebSocket.+ * Note that there can be multiple connected frontend instances (e.g. in different tabs). In such case, all+ * instances execute the given function.+ *+ * @param script - script to be executed on the frontend+ * @param params - list of parameters to the anonymous function to be sent to frontend+ * @returns no return value is provided.+ */runOnFrontend(script: () => void | string, params: []): void;/**- * Sync process can make data intermittently inconsistent. Scripts which require strong data consistency- * can use this function to wait for a possible sync process to finish and prevent new sync process from starting- * while it is running.- *- * Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case- * you need to make some DB changes, you need to surround your call with api.transactional(...)- *- * @param callback - function to be executed while sync process is not running- * @returns resolves once the callback is finished (callback is awaited)- */+ * Sync process can make data intermittently inconsistent. Scripts which require strong data consistency+ * can use this function to wait for a possible sync process to finish and prevent new sync process from starting+ * while it is running.+ *+ * Because this is an async process, the inner callback doesn't have automatic transaction handling, so in case+ * you need to make some DB changes, you need to surround your call with api.transactional(...)+ *+ * @param callback - function to be executed while sync process is not running+ * @returns resolves once the callback is finished (callback is awaited)+ */runOutsideOfSync(callback: () => void): Promise<void>;/**- * @param backupName - If the backupName is e.g. "now", then the backup will be written to "backup-now.db" file- * @returns resolves once the backup is finished- */+ * @param backupName - If the backupName is e.g. "now", then the backup will be written to "backup-now.db" file+ * @returns resolves once the backup is finished+ */backupNow(backupName: string): Promise<string>;- /**- * This object contains "at your risk" and "no BC guarantees" objects for advanced use cases.- */+ /**+ * This object contains "at your risk" and "no BC guarantees" objects for advanced use cases.+ */__private: {/** provides access to the backend in-memory object graph, see {@link Becca} */becca: Becca;@@ -392,9 +392,9 @@ interface Api {*/function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {this.startNote = apiParams.startNote;-+this.currentNote = currentNote;-+this.originEntity = apiParams.originEntity;for (const key in apiParams) {@@ -416,7 +416,7 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {this.getOption = optionName => becca.getOption(optionName);this.getOptions = () => optionsService.getOptions();this.getAttribute = attributeId => becca.getAttribute(attributeId);-+this.searchForNotes = (query, searchParams = {}) => {if (searchParams.includeArchivedNotes === undefined) {searchParams.includeArchivedNotes = true;@@ -432,14 +432,14 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {return becca.getNotes(noteIds);};-+this.searchForNote = (query, searchParams = {}) => {const notes = this.searchForNotes(query, searchParams);return notes.length > 0 ? notes[0] : null;};- this.getNotesWithLabel = attributeService.getNotesWithLabel;+ this.getNotesWithLabel = attributeService.getNotesWithLabel;this.getNoteWithLabel = attributeService.getNoteWithLabel;this.ensureNoteIsPresentInParent = cloningService.ensureNoteIsPresentInParent;this.ensureNoteIsAbsentFromParent = cloningService.ensureNoteIsAbsentFromParent;@@ -458,9 +458,9 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {type: 'code',mime: 'application/json'});-+this.createNewNote = noteService.createNewNote;-+this.createNote = (parentNoteId, title, content = "", _extraOptions = {}) => {const parentNote = becca.getNote(parentNoteId);if (!parentNote) {@@ -507,7 +507,7 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {this.logMessages = {};this.logSpacedUpdates = {};-+this.log = message => {log.info(message);@@ -555,7 +555,7 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {this.sql = sql;this.getAppInfo = () => appInfo;-+this.createOrUpdateLauncher = opts => {if (!opts.id) { throw new Error("ID is a mandatory parameter for api.createOrUpdateLauncher(opts)"); }if (!opts.id.match(/[a-z0-9]{6,1000}/i)) { throw new Error(`ID must be an alphanumeric string at least 6 characters long.`); }@@ -650,10 +650,10 @@ function BackendScriptApi(this: Api, currentNote: BNote, apiParams: ApiParams) {});}};-+this.runOutsideOfSync = syncMutex.doExclusively;this.backupNow = backupService.backupNow;-+this.__private = {becca}diff --git a/src/services/backend_script_api_interface.ts b/src/services/backend_script_api_interface.tsindex a315a1d24a..9ea6f57215 100644--- a/src/services/backend_script_api_interface.ts+++ b/src/services/backend_script_api_interface.ts@@ -8,4 +8,4 @@ export interface ApiParams {pathParams?: string[],req?: Request,res?: Response-}\ No newline at end of file+}diff --git a/src/services/blob-interface.ts b/src/services/blob-interface.tsindex 8bfcf13225..a0e6052785 100644--- a/src/services/blob-interface.ts+++ b/src/services/blob-interface.ts@@ -2,4 +2,4 @@ export interface Blob {blobId: string;content: string | Buffer;utcDateModified: string;-}\ No newline at end of file+}diff --git a/src/services/code_block_theme.ts b/src/services/code_block_theme.tsindex e92199e74e..6035994250 100644--- a/src/services/code_block_theme.ts+++ b/src/services/code_block_theme.ts@@ -1,6 +1,6 @@/*** @module- *+ ** Manages the server-side functionality of the code blocks feature, mostly for obtaining the available themes for syntax highlighting.*/@@ -23,11 +23,11 @@ interface ColorTheme {/*** Returns all the supported syntax highlighting themes for code blocks, in groups.- *+ ** The return value is an object where the keys represent groups in their human-readable name (e.g. "Light theme")* and the values are an array containing the information about every theme. There is also a special group with no* title (empty string) which should be displayed at the top of the listing pages, without a group.- *+ ** @returns the supported themes, grouped.*/export function listSyntaxHighlightingThemes() {@@ -55,9 +55,9 @@ function getStylesDirectory() {/*** Reads all the predefined themes by listing all minified CSSes from a given directory.- *+ ** The theme names are mapped against a known list in order to provide more descriptive names such as "Visual Studio 2015 (Dark)" instead of "vs2015".- *+ ** @param path the path to read from. Usually this is the highlight.js `styles` directory.* @returns the list of themes.*/@@ -65,13 +65,13 @@ function readThemesFromFileSystem(path: string): ColorTheme[] {return fs.readdirSync(path).filter((el) => el.endsWith(".min.css")).map((name) => {- const nameWithoutExtension = name.replace(".min.css", "");+ const nameWithoutExtension = name.replace(".min.css", "");let title = nameWithoutExtension.replace(/-/g, " ");if (title in themeNames) {title = (themeNames as Record<string, string>)[title];}-+return {val: `default:${nameWithoutExtension}`,title: title@@ -82,7 +82,7 @@ function readThemesFromFileSystem(path: string): ColorTheme[] {/*** Groups a list of themes by dark or light themes. This is done simply by checking whether "Dark" is present in the given theme, otherwise it's considered a light theme.* This generally only works if the theme has a known human-readable name (see {@link #readThemesFromFileSystem()})- *+ ** @param listOfThemes the list of themes to be grouped.* @returns the grouped themes by light or dark.*/@@ -102,4 +102,4 @@ function groupThemesByLightOrDark(listOfThemes: ColorTheme[]) {output[t("code_block.theme_group_light")] = lightThemes;output[t("code_block.theme_group_dark")] = darkThemes;return output;-}\ No newline at end of file+}diff --git a/src/services/code_block_theme_names.json b/src/services/code_block_theme_names.jsonindex 1b5706af07..f1095e321c 100644--- a/src/services/code_block_theme_names.json+++ b/src/services/code_block_theme_names.json@@ -72,4 +72,4 @@"vs2015": "Visual Studio 2015 (Dark)","xcode": "Xcode (Light)","xt256": "xt256 (Dark)"-}\ No newline at end of file+}diff --git a/src/services/consistency_checks.ts b/src/services/consistency_checks.tsindex b2bb50a6a6..acbca97151 100644--- a/src/services/consistency_checks.ts+++ b/src/services/consistency_checks.ts@@ -23,12 +23,12 @@ class ConsistencyChecks {private autoFix: boolean;private unrecoveredConsistencyErrors: boolean;- private fixedIssues: boolean;+ private fixedIssues: boolean;private reloadNeeded: boolean;/**- * @param autoFix - automatically fix all encountered problems. False is only for debugging during development (fail fast)- */+ * @param autoFix - automatically fix all encountered problems. False is only for debugging during development (fail fast)+ */constructor(autoFix: boolean) {this.autoFix = autoFix;this.unrecoveredConsistencyErrors = false;@@ -138,9 +138,9 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT branchId, branches.noteIdFROM branches- LEFT JOIN notes USING (noteId)+ LEFT JOIN notes USING (noteId)WHERE branches.isDeleted = 0- AND notes.noteId IS NULL`,+ AND notes.noteId IS NULL`,({branchId, noteId}) => {if (this.autoFix) {const branch = becca.getBranch(branchId);@@ -160,10 +160,10 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT branchId, branches.parentNoteId AS parentNoteIdFROM branches- LEFT JOIN notes ON notes.noteId = branches.parentNoteId+ LEFT JOIN notes ON notes.noteId = branches.parentNoteIdWHERE branches.isDeleted = 0- AND branches.noteId != 'root'- AND notes.noteId IS NULL`,+ AND branches.noteId != 'root'+ AND notes.noteId IS NULL`,({branchId, parentNoteId}) => {if (this.autoFix) {// Delete the old branch and recreate it with root as parent.@@ -205,9 +205,9 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT attributeId, attributes.noteIdFROM attributes- LEFT JOIN notes USING (noteId)+ LEFT JOIN notes USING (noteId)WHERE attributes.isDeleted = 0- AND notes.noteId IS NULL`,+ AND notes.noteId IS NULL`,({attributeId, noteId}) => {if (this.autoFix) {const attribute = becca.getAttribute(attributeId);@@ -227,10 +227,10 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT attributeId, attributes.value AS noteIdFROM attributes- LEFT JOIN notes ON notes.noteId = attributes.value+ LEFT JOIN notes ON notes.noteId = attributes.valueWHERE attributes.isDeleted = 0- AND attributes.type = 'relation'- AND notes.noteId IS NULL`,+ AND attributes.type = 'relation'+ AND notes.noteId IS NULL`,({attributeId, noteId}) => {if (this.autoFix) {const attribute = becca.getAttribute(attributeId);@@ -255,7 +255,7 @@ class ConsistencyChecks {UNION ALLSELECT revisionId FROM revisions)- AND attachments.isDeleted = 0`,+ AND attachments.isDeleted = 0`,({attachmentId, ownerId}) => {if (this.autoFix) {const attachment = becca.getAttachment(attachmentId);@@ -282,11 +282,11 @@ class ConsistencyChecks {// another check might create missing branchthis.findAndFixIssues(`SELECT branchId,- noteId+ noteIdFROM branches- JOIN notes USING (noteId)+ JOIN notes USING (noteId)WHERE notes.isDeleted = 1- AND branches.isDeleted = 0`,+ AND branches.isDeleted = 0`,({branchId, noteId}) => {if (this.autoFix) {const branch = becca.getBranch(branchId);@@ -303,11 +303,11 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT branchId,- parentNoteId+ parentNoteIdFROM branches- JOIN notes AS parentNote ON parentNote.noteId = branches.parentNoteId+ JOIN notes AS parentNote ON parentNote.noteId = branches.parentNoteIdWHERE parentNote.isDeleted = 1- AND branches.isDeleted = 0+ AND branches.isDeleted = 0`, ({branchId, parentNoteId}) => {if (this.autoFix) {const branch = becca.getBranch(branchId);@@ -327,9 +327,9 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT DISTINCT notes.noteIdFROM notes- LEFT JOIN branches ON notes.noteId = branches.noteId AND branches.isDeleted = 0+ LEFT JOIN branches ON notes.noteId = branches.noteId AND branches.isDeleted = 0WHERE notes.isDeleted = 0- AND branches.branchId IS NULL+ AND branches.branchId IS NULL`, ({noteId}) => {if (this.autoFix) {const branch = new BBranch({@@ -349,21 +349,21 @@ class ConsistencyChecks {// there should be a unique relationship between note and its parentthis.findAndFixIssues(`SELECT noteId,- parentNoteId+ parentNoteIdFROM branchesWHERE branches.isDeleted = 0GROUP BY branches.parentNoteId,- branches.noteId+ branches.noteIdHAVING COUNT(1) > 1`,({noteId, parentNoteId}) => {if (this.autoFix) {const branchIds = sql.getColumn<string>(`SELECT branchId- FROM branches- WHERE noteId = ?- and parentNoteId = ?- and isDeleted = 0- ORDER BY utcDateModified`, [noteId, parentNoteId]);+ FROM branches+ WHERE noteId = ?+ and parentNoteId = ?+ and isDeleted = 0+ ORDER BY utcDateModified`, [noteId, parentNoteId]);const branches = branchIds.map(branchId => becca.getBranch(branchId));@@ -393,11 +393,11 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT attachmentId,- attachments.ownerId AS noteId+ attachments.ownerId AS noteIdFROM attachments- JOIN notes ON notes.noteId = attachments.ownerId+ JOIN notes ON notes.noteId = attachments.ownerIdWHERE notes.isDeleted = 1- AND attachments.isDeleted = 0`,+ AND attachments.isDeleted = 0`,({attachmentId, noteId}) => {if (this.autoFix) {const attachment = becca.getAttachment(attachmentId);@@ -420,7 +420,7 @@ class ConsistencyChecks {SELECT noteId, typeFROM notesWHERE isDeleted = 0- AND type NOT IN (${noteTypesStr})`,+ AND type NOT IN (${noteTypesStr})`,({noteId, type}) => {if (this.autoFix) {const note = becca.getNote(noteId);@@ -439,7 +439,7 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT notes.noteId, notes.isProtected, notes.type, notes.mimeFROM notes- LEFT JOIN blobs USING (blobId)+ LEFT JOIN blobs USING (blobId)WHERE blobs.blobId IS NULLAND notes.isDeleted = 0`,({noteId, isProtected, type, mime}) => {@@ -494,10 +494,10 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT notes.noteId, notes.type, notes.mimeFROM notes- JOIN blobs USING (blobId)+ JOIN blobs USING (blobId)WHERE isDeleted = 0- AND isProtected = 0- AND content IS NULL`,+ AND isProtected = 0+ AND content IS NULL`,({noteId, type, mime}) => {if (this.autoFix) {const note = becca.getNote(noteId);@@ -520,7 +520,7 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT revisions.revisionId, blobs.blobIdFROM revisions- LEFT JOIN blobs USING (blobId)+ LEFT JOIN blobs USING (blobId)WHERE blobs.blobId IS NULL`,({revisionId, blobId}) => {if (this.autoFix) {@@ -537,7 +537,7 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT attachments.attachmentId, blobs.blobIdFROM attachments- LEFT JOIN blobs USING (blobId)+ LEFT JOIN blobs USING (blobId)WHERE blobs.blobId IS NULL`,({attachmentId, blobId}) => {if (this.autoFix) {@@ -554,17 +554,17 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT parentNoteIdFROM branches- JOIN notes ON notes.noteId = branches.parentNoteId+ JOIN notes ON notes.noteId = branches.parentNoteIdWHERE notes.isDeleted = 0- AND notes.type == 'search'- AND branches.isDeleted = 0`,+ AND notes.type == 'search'+ AND branches.isDeleted = 0`,({parentNoteId}) => {if (this.autoFix) {const branchIds = sql.getColumn<string>(`SELECT branchIdFROM branchesWHERE isDeleted = 0- AND parentNoteId = ?`, [parentNoteId]);+ AND parentNoteId = ?`, [parentNoteId]);const branches = branchIds.map(branchId => becca.getBranch(branchId));@@ -594,8 +594,8 @@ class ConsistencyChecks {SELECT attributeIdFROM attributesWHERE isDeleted = 0- AND type = 'relation'- AND value = ''`,+ AND type = 'relation'+ AND value = ''`,({attributeId}) => {if (this.autoFix) {const relation = becca.getAttribute(attributeId);@@ -612,11 +612,11 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT attributeId,- type+ typeFROM attributesWHERE isDeleted = 0- AND type != 'label'- AND type != 'relation'`,+ AND type != 'label'+ AND type != 'relation'`,({attributeId, type}) => {if (this.autoFix) {const attribute = becca.getAttribute(attributeId);@@ -634,11 +634,11 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT attributeId,- attributes.noteId+ attributes.noteIdFROM attributesJOIN notes ON attributes.noteId = notes.noteIdWHERE attributes.isDeleted = 0- AND notes.isDeleted = 1`,+ AND notes.isDeleted = 1`,({attributeId, noteId}) => {if (this.autoFix) {const attribute = becca.getAttribute(attributeId);@@ -655,12 +655,12 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT attributeId,- attributes.value AS targetNoteId+ attributes.value AS targetNoteIdFROM attributesJOIN notes ON attributes.value = notes.noteIdWHERE attributes.type = 'relation'- AND attributes.isDeleted = 0- AND notes.isDeleted = 1`,+ AND attributes.isDeleted = 0+ AND notes.isDeleted = 1`,({attributeId, targetNoteId}) => {if (this.autoFix) {const attribute = becca.getAttribute(attributeId);@@ -680,7 +680,7 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT ${key} as entityIdFROM ${entityName}- LEFT JOIN entity_changes ec ON ec.entityName = '${entityName}' AND ec.entityId = ${entityName}.${key}+ LEFT JOIN entity_changes ec ON ec.entityName = '${entityName}' AND ec.entityId = ${entityName}.${key}WHERE ec.id IS NULL`,({entityId}) => {const entityRow = sql.getRow<EntityChange>(`SELECT * FROM ${entityName} WHERE ${key} = ?`, [entityId]);@@ -703,12 +703,12 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT id, entityId- FROM entity_changes- LEFT JOIN ${entityName} ON entityId = ${entityName}.${key}+ FROM entity_changes+ LEFT JOIN ${entityName} ON entityId = ${entityName}.${key}WHERE- entity_changes.isErased = 0- AND entity_changes.entityName = '${entityName}'- AND ${entityName}.${key} IS NULL`,+ entity_changes.isErased = 0+ AND entity_changes.entityName = '${entityName}'+ AND ${entityName}.${key} IS NULL`,({id, entityId}) => {if (this.autoFix) {sql.execute("DELETE FROM entity_changes WHERE entityName = ? AND entityId = ?", [entityName, entityId]);@@ -721,11 +721,11 @@ class ConsistencyChecks {this.findAndFixIssues(`SELECT id, entityId- FROM entity_changes- JOIN ${entityName} ON entityId = ${entityName}.${key}+ FROM entity_changes+ JOIN ${entityName} ON entityId = ${entityName}.${key}WHERE- entity_changes.isErased = 1- AND entity_changes.entityName = '${entityName}'`,+ entity_changes.isErased = 1+ AND entity_changes.entityName = '${entityName}'`,({id, entityId}) => {if (this.autoFix) {sql.execute(`DELETE FROM ${entityName} WHERE ${key} = ?`, [entityId]);diff --git a/src/services/content_hash.ts b/src/services/content_hash.tsindex 4e5ffc568d..70a3314294 100644--- a/src/services/content_hash.ts+++ b/src/services/content_hash.ts@@ -18,12 +18,12 @@ function getEntityHashes() {const hashRows = sql.disableSlowQueryLogging(() => sql.getRawRows<HashRow>(`SELECT entityName,- entityId,- hash,- isErased+ entityId,+ hash,+ isErasedFROM entity_changesWHERE isSynced = 1- AND entityName != 'note_reordering'`)+ AND entityName != 'note_reordering'`));// sorting is faster in memorydiff --git a/src/services/encryption/password.ts b/src/services/encryption/password.tsindex 89ed7add83..05397cf2a8 100644--- a/src/services/encryption/password.ts+++ b/src/services/encryption/password.ts@@ -29,7 +29,7 @@ function changePassword(currentPassword: string, newPassword: string) {optionService.setOption('passwordDerivedKeySalt', utils.randomSecureToken(32));const newPasswordVerificationKey = utils.toBase64(myScryptService.getVerificationHash(newPassword));-+if (decryptedDataKey) {// TODO: what should happen if the decrypted data key is null?passwordEncryptionService.setDataKey(newPassword, decryptedDataKey);diff --git a/src/services/entity_changes.ts b/src/services/entity_changes.tsindex 8937b49cdb..892e2a8bc6 100644--- a/src/services/entity_changes.ts+++ b/src/services/entity_changes.ts@@ -39,9 +39,9 @@ function putEntityChange(origEntityChange: EntityChange) {ec.isErased = ec.isErased ? 1 : 0;ec.id = sql.replace("entity_changes", ec);- if (ec.id) {- maxEntityChangeId = Math.max(maxEntityChangeId, ec.id);- }+ if (ec.id) {+ maxEntityChangeId = Math.max(maxEntityChangeId, ec.id);+ }cls.putEntityChange(ec);}@@ -95,7 +95,7 @@ function addEntityChangesForSector(entityName: string, sector: string) {function addEntityChangesForDependingEntity(sector: string, tableName: string, primaryKeyColumn: string) {// problem in blobs might be caused by problem in entity referencing the blobconst dependingEntityChanges = sql.getRows<EntityChange>(`- SELECT dep_change.*+ SELECT dep_change.*FROM entity_changes orig_sectorJOIN ${tableName} ON ${tableName}.blobId = orig_sector.entityIdJOIN entity_changes dep_change ON dep_change.entityName = '${tableName}' AND dep_change.entityId = ${tableName}.${primaryKeyColumn}@@ -110,11 +110,11 @@ function addEntityChangesForDependingEntity(sector: string, tableName: string, pfunction cleanupEntityChangesForMissingEntities(entityName: string, entityPrimaryKey: string) {sql.execute(`- DELETE- FROM entity_changes- WHERE+ DELETE+ FROM entity_changes+ WHEREisErased = 0- AND entityName = '${entityName}'+ AND entityName = '${entityName}'AND entityId NOT IN (SELECT ${entityPrimaryKey} FROM ${entityName})`);}diff --git a/src/services/entity_changes_interface.ts b/src/services/entity_changes_interface.tsindex 11eb69ccb6..e69eb5c37e 100644--- a/src/services/entity_changes_interface.ts+++ b/src/services/entity_changes_interface.ts@@ -1,27 +1,27 @@export interface EntityChange {- id?: number | null;- noteId?: string;- entityName: string;- entityId: string;- entity?: any;- positions?: Record<string, number>;- hash: string;- utcDateChanged?: string;- utcDateModified?: string;- utcDateCreated?: string;- isSynced: boolean | 1 | 0;- isErased: boolean | 1 | 0;- componentId?: string | null;- changeId?: string | null;- instanceId?: string | null;+ id?: number | null;+ noteId?: string;+ entityName: string;+ entityId: string;+ entity?: any;+ positions?: Record<string, number>;+ hash: string;+ utcDateChanged?: string;+ utcDateModified?: string;+ utcDateCreated?: string;+ isSynced: boolean | 1 | 0;+ isErased: boolean | 1 | 0;+ componentId?: string | null;+ changeId?: string | null;+ instanceId?: string | null;}export interface EntityRow {- isDeleted?: boolean;- content?: Buffer | string;+ isDeleted?: boolean;+ content?: Buffer | string;}export interface EntityChangeRecord {- entityChange: EntityChange;- entity?: EntityRow;+ entityChange: EntityChange;+ entity?: EntityRow;}diff --git a/src/services/env.ts b/src/services/env.tsindex 28f39fea6a..5a7e45f35b 100644--- a/src/services/env.ts+++ b/src/services/env.ts@@ -4,4 +4,4 @@ function isDev() {export default {isDev-};\ No newline at end of file+};diff --git a/src/services/erase.ts b/src/services/erase.tsindex f02595de8c..d026757007 100644--- a/src/services/erase.ts+++ b/src/services/erase.ts@@ -100,9 +100,9 @@ function eraseUnusedBlobs() {LEFT JOIN notes ON notes.blobId = blobs.blobIdLEFT JOIN attachments ON attachments.blobId = blobs.blobIdLEFT JOIN revisions ON revisions.blobId = blobs.blobId- WHERE notes.noteId IS NULL- AND attachments.attachmentId IS NULL- AND revisions.revisionId IS NULL`);+ WHERE notes.noteId IS NULL+ AND attachments.attachmentId IS NULL+ AND revisions.revisionId IS NULL`);if (unusedBlobIds.length === 0) {return;@@ -181,7 +181,7 @@ export function startScheduledCleanup() {// first cleanup kickoff 5 minutes after startupsetTimeout(cls.wrap(() => eraseDeletedEntities()), 5 * 60 * 1000);setTimeout(cls.wrap(() => eraseScheduledAttachments()), 6 * 60 * 1000);-+setInterval(cls.wrap(() => eraseDeletedEntities()), 4 * 3600 * 1000);setInterval(cls.wrap(() => eraseScheduledAttachments()), 3600 * 1000);});diff --git a/src/services/export/md.ts b/src/services/export/md.tsindex 3d80d0f158..ece07d0435 100644--- a/src/services/export/md.ts+++ b/src/services/export/md.ts@@ -8,25 +8,25 @@ let instance: TurndownService | null = null;const fencedCodeBlockFilter: TurndownService.Rule = {filter: function (node, options) {return (- options.codeBlockStyle === 'fenced' &&- node.nodeName === 'PRE' &&- node.firstChild !== null &&- node.firstChild.nodeName === 'CODE'+ options.codeBlockStyle === 'fenced' &&+ node.nodeName === 'PRE' &&+ node.firstChild !== null &&+ node.firstChild.nodeName === 'CODE')},replacement: function (content, node, options) {if (!node.firstChild || !("getAttribute" in node.firstChild) || typeof node.firstChild.getAttribute !== "function") {- return content;+ return content;}const className = node.firstChild.getAttribute('class') || ''const language = rewriteLanguageTag((className.match(/language-(\S+)/) || [null, ''])[1]);return (- '\n\n' + options.fence + language + '\n' +- node.firstChild.textContent +- '\n' + options.fence + '\n\n'+ '\n\n' + options.fence + language + '\n' ++ node.firstChild.textContent ++ '\n' + options.fence + '\n\n')}};@@ -34,7 +34,7 @@ const fencedCodeBlockFilter: TurndownService.Rule = {function toMarkdown(content: string) {if (instance === null) {instance = new TurndownService({ codeBlockStyle: 'fenced' });- // Filter is heavily based on: https://github.com/mixmark-io/turndown/issues/274#issuecomment-458730974+ // Filter is heavily based on: https://github.com/mixmark-io/turndown/issues/274#issuecomment-458730974instance.addRule('fencedCodeBlock', fencedCodeBlockFilter);instance.use(turndownPluginGfm.gfm);}@@ -44,7 +44,7 @@ function toMarkdown(content: string) {function rewriteLanguageTag(source: string) {if (!source) {- return source;+ return source;}if (source === "text-x-trilium-auto") {diff --git a/src/services/export/zip.ts b/src/services/export/zip.tsindex 75feeebc6a..0cf350102e 100644--- a/src/services/export/zip.ts+++ b/src/services/export/zip.ts@@ -63,7 +63,7 @@ async function exportToZip(taskContext: TaskContext, branch: BBranch, format: "hif (fileName.length > 30) {// We use regex to match the extension to preserve multiple dots in extensions (e.g. .tar.gz).let match = fileName.match(/(\.[a-zA-Z0-9_.!#-]+)$/);- let ext = match ? match[0] : '';+ let ext = match ? match[0] : '';// Crop the extension if extension length exceeds 30const croppedExt = ext.slice(-30);// Crop the file name section and append the cropped extension@@ -324,9 +324,9 @@ async function exportToZip(taskContext: TaskContext, branch: BBranch, format: "h</head><body><div class="content">- <h1 data-trilium-h1>${htmlTitle}</h1>-- <div class="ck-content">${content}</div>+ <h1 data-trilium-h1>${htmlTitle}</h1>++ <div class="ck-content">${content}</div></div></body></html>`;diff --git a/src/services/hidden_subtree.ts b/src/services/hidden_subtree.tsindex 3f0c01bdbc..9e29375fd4 100644--- a/src/services/hidden_subtree.ts+++ b/src/services/hidden_subtree.ts@@ -281,7 +281,7 @@ interface CheckHiddenExtraOpts {restoreNames?: boolean;}-function checkHiddenSubtree(force = false, extraOpts: CheckHiddenExtraOpts = {}) {+function checkHiddenSubtree(force = false, extraOpts: CheckHiddenExtraOpts = {}) {if (!force && !migrationService.isDbUpToDate()) {// on-delete hook might get triggered during some future migration and cause havoclog.info("Will not check hidden subtree until migration is finished.");diff --git a/src/services/host.ts b/src/services/host.tsindex 5b73ab8fbd..1324df0404 100644--- a/src/services/host.ts+++ b/src/services/host.ts@@ -6,8 +6,8 @@ function getHost() {if (envHost && !utils.isElectron) {return envHost;}-+return config['Network']['host'] || '0.0.0.0';}-export default getHost();\ No newline at end of file+export default getHost();diff --git a/src/services/i18n.ts b/src/services/i18n.tsindex 87fb88e844..98342ae0d6 100644--- a/src/services/i18n.ts+++ b/src/services/i18n.ts@@ -11,19 +11,19 @@ export async function initializeTranslations() {// Initialize translationsawait i18next.use(Backend).init({- lng: getCurrentLanguage(),- fallbackLng: "en",- ns: "server",- backend: {- loadPath: join(resourceDir, "translations/{{lng}}/{{ns}}.json")- }+ lng: getCurrentLanguage(),+ fallbackLng: "en",+ ns: "server",+ backend: {+ loadPath: join(resourceDir, "translations/{{lng}}/{{ns}}.json")+ }});}function getCurrentLanguage() {let language;if (sql_init.isDbInitialized()) {- language = options.getOptionOrNull("locale");+ language = options.getOptionOrNull("locale");}if (!language) {diff --git a/src/services/image.ts b/src/services/image.tsindex dca97c48ab..12ba420c3d 100644--- a/src/services/image.ts+++ b/src/services/image.ts@@ -208,7 +208,7 @@ async function resize(buffer: Buffer, quality: number) {const start = Date.now();- const image = await Jimp.read(buffer);+ const image = await Jimp.read(buffer);if (image.bitmap.width > image.bitmap.height && image.bitmap.width > imageMaxWidthHeight) {image.resize({ w: imageMaxWidthHeight });diff --git a/src/services/import/common.ts b/src/services/import/common.tsindex 75c61fb35e..72b5eff4df 100644--- a/src/services/import/common.ts+++ b/src/services/import/common.ts@@ -2,4 +2,4 @@ export interface File {originalname: string;mimetype: string;buffer: string | Buffer;-}\ No newline at end of file+}diff --git a/src/services/import/enex.ts b/src/services/import/enex.tsindex b6aa420724..543523a92e 100644--- a/src/services/import/enex.ts+++ b/src/services/import/enex.ts@@ -240,8 +240,8 @@ function importEnex(taskContext: TaskContext, file: File, parentNote: BNote): Prfunction updateDates(note: BNote, utcDateCreated?: string, utcDateModified?: string) {// it's difficult to force custom dateCreated and dateModified to Note entity, so we do it post-creation with SQLsql.execute(`- UPDATE notes- SET dateCreated = ?,+ UPDATE notes+ SET dateCreated = ?,utcDateCreated = ?,dateModified = ?,utcDateModified = ?@@ -314,7 +314,7 @@ function importEnex(taskContext: TaskContext, file: File, parentNote: BNote): Prif (typeof resource.content !== "string") {throw new Error("Missing or wrong content type for resource.");}-+const resourceNote = noteService.createNewNote({parentNoteId: noteEntity.noteId,title: resource.title,diff --git a/src/services/import/mime.ts b/src/services/import/mime.tsindex 8b8316a59d..55119e4ca1 100644--- a/src/services/import/mime.ts+++ b/src/services/import/mime.ts@@ -114,4 +114,4 @@ export default {getMime,getType,normalizeMimeType-};\ No newline at end of file+};diff --git a/src/services/import/single.ts b/src/services/import/single.tsindex c20fec3b0a..a1308a8078 100644--- a/src/services/import/single.ts+++ b/src/services/import/single.ts@@ -160,9 +160,9 @@ function importHtml(taskContext: TaskContext, file: File, parentNote: BNote) {if (taskContext?.data?.safeImport) {content = htmlSanitizer.sanitize(content);- }+ }+-const {note} = noteService.createNewNote({parentNoteId: parentNote.noteId,title,@@ -171,9 +171,9 @@ function importHtml(taskContext: TaskContext, file: File, parentNote: BNote) {mime: 'text/html',isProtected: parentNote.isProtected && protectedSessionService.isProtectedSessionAvailable(),});-+taskContext.increaseProgressCount();-+return note;}diff --git a/src/services/keyboard_actions.ts b/src/services/keyboard_actions.tsindex e08417b11f..ecf6590412 100644--- a/src/services/keyboard_actions.ts+++ b/src/services/keyboard_actions.ts@@ -13,7 +13,7 @@ function getDefaultKeyboardActions() {if (!t("keyboard_actions.note-navigation")) {throw new Error("Keyboard actions loaded before translations.");}-+const DEFAULT_KEYBOARD_ACTIONS: KeyboardShortcut[] = [{separator: t("keyboard_actions.note-navigation")@@ -76,8 +76,8 @@ function getDefaultKeyboardActions() {description: t("keyboard_actions.sort-child-notes"),scope: "note-tree"},--++{separator: t("keyboard_actions.creating-and-moving-notes")},@@ -149,11 +149,11 @@ function getDefaultKeyboardActions() {defaultShortcuts: ["CommandOrControl+Shift+X"],scope: "window"},-+{separator: t("keyboard_actions.note-clipboard")},-+{actionName: "copyNotesToClipboard",defaultShortcuts: ["CommandOrControl+C"],@@ -196,8 +196,8 @@ function getDefaultKeyboardActions() {description: t("keyboard_actions.duplicate-subtree"),scope: "note-tree"},--++{separator: t("keyboard_actions.tabs-and-windows")},@@ -303,8 +303,8 @@ function getDefaultKeyboardActions() {description: t("keyboard_actions.last-tab"),scope: "window"},--++{separator: t("keyboard_actions.dialogs")},@@ -350,12 +350,12 @@ function getDefaultKeyboardActions() {description: t("keyboard_actions.show-help"),scope: "window"},--++{separator: t("keyboard_actions.text-note-operations")},-+{actionName: "addLinkToText",defaultShortcuts: ["CommandOrControl+L"],@@ -398,11 +398,11 @@ function getDefaultKeyboardActions() {description: t("keyboard_actions.edit-readonly-note"),scope: "window"},-+{separator: t("keyboard_actions.attributes-labels-and-relations")},-+{actionName: "addNewLabel",defaultShortcuts: ["Alt+L"],@@ -415,11 +415,11 @@ function getDefaultKeyboardActions() {description: t("keyboard_actions.create-new-relation"),scope: "window"},-+{separator: t("keyboard_actions.ribbon-tabs")},-+{actionName: "toggleRibbonTabClassicEditor",defaultShortcuts: [],@@ -492,11 +492,11 @@ function getDefaultKeyboardActions() {description: t("keyboard_actions.toggle-similar-notes"),scope: "window"},-+{separator: t("keyboard_actions.other")},-+{actionName: "toggleRightPane",defaultShortcuts: [],@@ -601,10 +601,10 @@ function getDefaultKeyboardActions() {];/*- * Apply macOS-specific tweaks.- */+ * Apply macOS-specific tweaks.+ */const platformModifier = isMac ? 'Meta' : 'Ctrl';-+for (const action of DEFAULT_KEYBOARD_ACTIONS) {if (action.defaultShortcuts) {action.defaultShortcuts = action.defaultShortcuts.map(shortcut => shortcut.replace("CommandOrControl", platformModifier));diff --git a/src/services/keyboard_actions_interface.ts b/src/services/keyboard_actions_interface.tsindex 31493a8e91..c4b8f8a259 100644--- a/src/services/keyboard_actions_interface.ts+++ b/src/services/keyboard_actions_interface.ts@@ -5,16 +5,16 @@ export interface KeyboardShortcut {defaultShortcuts?: string[];effectiveShortcuts?: string[];/**- * Scope here means on which element the keyboard shortcuts are attached - this means that for the shortcut to work,- * the focus has to be inside the element.- *- * So e.g. shortcuts with "note-tree" scope work only when the focus is in note tree.- * This allows to have the same shortcut have different actions attached based on the context- * e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor.- */+ * Scope here means on which element the keyboard shortcuts are attached - this means that for the shortcut to work,+ * the focus has to be inside the element.+ *+ * So e.g. shortcuts with "note-tree" scope work only when the focus is in note tree.+ * This allows to have the same shortcut have different actions attached based on the context+ * e.g. CTRL-C in note tree does something a bit different from CTRL-C in the text editor.+ */scope?: "window" | "note-tree" | "text-detail" | "code-detail";}export interface KeyboardShortcutWithRequiredActionName extends KeyboardShortcut {actionName: string;-}\ No newline at end of file+}diff --git a/src/services/migration.ts b/src/services/migration.tsindex 4355a99a59..27d0308f2a 100644--- a/src/services/migration.ts+++ b/src/services/migration.ts@@ -75,8 +75,8 @@ async function migrate() {await executeMigration(mig);sql.execute(`UPDATE options- SET value = ?- WHERE name = ?`, [mig.dbVersion.toString(), "dbVersion"]);+ SET value = ?+ WHERE name = ?`, [mig.dbVersion.toString(), "dbVersion"]);log.info(`Migration to version ${mig.dbVersion} has been successful.`);} catch (e: any) {diff --git a/src/services/note-interface.ts b/src/services/note-interface.tsindex 194085bdb5..5d86587a96 100644--- a/src/services/note-interface.ts+++ b/src/services/note-interface.ts@@ -24,4 +24,4 @@ export interface NoteParams {utcDateCreated?: string;ignoreForbiddenParents?: boolean;target?: "into";-}\ No newline at end of file+}diff --git a/src/services/notes.ts b/src/services/notes.tsindex 5c983f9846..14a44020f5 100644--- a/src/services/notes.ts+++ b/src/services/notes.ts@@ -490,7 +490,7 @@ async function downloadImage(noteId: string, imageUrl: string) {const title = path.basename(parsedUrl.pathname || "");const attachment = imageService.saveImageToAttachment(noteId, imageBuffer, title, true, true);-+if (attachment.attachmentId) {imageUrlToAttachmentIdMapping[imageUrl] = attachment.attachmentId;} else {@@ -810,11 +810,11 @@ function undeleteBranch(branchId: string, deleteId: string, taskContext: TaskConnoteEntity.save();const attributeRows = sql.getRows<AttributeRow>(`- SELECT * FROM attributes- WHERE isDeleted = 1- AND deleteId = ?- AND (noteId = ?- OR (type = 'relation' AND value = ?))`, [deleteId, noteRow.noteId, noteRow.noteId]);+ SELECT * FROM attributes+ WHERE isDeleted = 1+ AND deleteId = ?+ AND (noteId = ?+ OR (type = 'relation' AND value = ?))`, [deleteId, noteRow.noteId, noteRow.noteId]);for (const attributeRow of attributeRows) {// relation might point to a note which hasn't been undeleted yet and would thus throw up@@ -824,8 +824,8 @@ function undeleteBranch(branchId: string, deleteId: string, taskContext: TaskConconst attachmentRows = sql.getRows<AttachmentRow>(`SELECT * FROM attachmentsWHERE isDeleted = 1- AND deleteId = ?- AND ownerId = ?`, [deleteId, noteRow.noteId]);+ AND deleteId = ?+ AND ownerId = ?`, [deleteId, noteRow.noteId]);for (const attachmentRow of attachmentRows) {new BAttachment(attachmentRow).save();@@ -835,8 +835,8 @@ function undeleteBranch(branchId: string, deleteId: string, taskContext: TaskConSELECT branches.branchIdFROM branchesWHERE branches.isDeleted = 1- AND branches.deleteId = ?- AND branches.parentNoteId = ?`, [deleteId, noteRow.noteId]);+ AND branches.deleteId = ?+ AND branches.parentNoteId = ?`, [deleteId, noteRow.noteId]);for (const childBranchId of childBranchIds) {undeleteBranch(childBranchId, deleteId, taskContext);@@ -853,9 +853,9 @@ function getUndeletedParentBranchIds(noteId: string, deleteId: string) {FROM branchesJOIN notes AS parentNote ON parentNote.noteId = branches.parentNoteIdWHERE branches.noteId = ?- AND branches.isDeleted = 1- AND branches.deleteId = ?- AND parentNote.isDeleted = 0`, [noteId, deleteId]);+ AND branches.isDeleted = 1+ AND branches.deleteId = ?+ AND parentNote.isDeleted = 0`, [noteId, deleteId]);}function scanForLinks(note: BNote, content: string | Buffer) {@@ -941,7 +941,7 @@ function duplicateSubtreeWithoutRoot(origNoteId: string, newNoteId: string) {if (origNote == null) {throw new Error("Unable to find note to duplicate.");}-+const noteIdMapping = getNoteIdMapping(origNote);for (const childBranch of origNote.getChildBranches()) {if (childBranch) {diff --git a/src/services/options.ts b/src/services/options.tsindex af535449ed..5230f62666 100644--- a/src/services/options.ts+++ b/src/services/options.ts@@ -1,12 +1,12 @@/*** @module- *+ ** Options are key-value pairs that are used to store information such as user preferences (for example* the current theme, sync server information), but also information about the state of the application.- *+ ** Although options internally are represented as strings, their value can be interpreted as a number or* boolean by calling the appropriate methods from this service (e.g. {@link #getOptionInt}).\- *+ ** Generally options are shared across multiple instances of the application via the sync mechanism,* however it is possible to have options that are local to an instance. For example, the user can select* a theme on a device and it will not affect other devices.@@ -90,7 +90,7 @@ function setOption(name: string, value: string | number | boolean) {/*** Creates a new option in the database, with the given name, value and whether it should be synced.- *+ ** @param name the name of the option to be created.* @param value the value of the option, as a string. It can then be interpreted as other types such as a number of boolean.* @param isSynced `true` if the value should be synced across multiple instances (e.g. locale) or `false` if it should be local-only (e.g. theme).diff --git a/src/services/options_init.ts b/src/services/options_init.tsindex 2ad06e5088..a48de12e34 100644--- a/src/services/options_init.ts+++ b/src/services/options_init.ts@@ -26,17 +26,17 @@ interface NotSyncedOpts {interface DefaultOption {name: string;/**- * The value to initialize the option with, if the option is not already present in the database.- *- * If a function is passed in instead, the function is called if the option does not exist (with access to the current options) and the return value is used instead. Useful to migrate a new option with a value depending on some other option that might be initialized.- */+ * The value to initialize the option with, if the option is not already present in the database.+ *+ * If a function is passed in instead, the function is called if the option does not exist (with access to the current options) and the return value is used instead. Useful to migrate a new option with a value depending on some other option that might be initialized.+ */value: string | ((options: OptionMap) => string);isSynced: boolean;}/*** Initializes the default options for new databases only.- *+ ** @param initialized `true` if the database has been fully initialized (i.e. a new database was created), or `false` if the database is created for sync.* @param opts additional options to be initialized, for example the sync configuration.*/@@ -56,10 +56,10 @@ async function initNotSyncedOptions(initialized: boolean, opts: NotSyncedOpts =optionService.createOption('initialized', initialized ? 'true' : 'false', false);optionService.createOption('lastSyncedPull', '0', false);- optionService.createOption('lastSyncedPush', '0', false);+ optionService.createOption('lastSyncedPush', '0', false);optionService.createOption('theme', 'next', false);-+optionService.createOption('syncServerHost', opts.syncServerHost || '', false);optionService.createOption('syncServerTimeout', '120000', false);optionService.createOption('syncProxy', opts.syncProxy || '', false);@@ -155,7 +155,7 @@ const defaultOptions: DefaultOption[] = [/*** Initializes the options, by checking which options from {@link #allDefaultOptions()} are missing and registering them. It will also check some environment variables such as safe mode, to make any necessary adjustments.- *+ ** This method is called regardless of whether a new database is created, or an existing database is used.*/function initStartupOptions() {diff --git a/src/services/request.ts b/src/services/request.tsindex d7be952337..3fa70e5e74 100644--- a/src/services/request.ts+++ b/src/services/request.ts@@ -29,13 +29,13 @@ interface Request {end(payload?: string): void;}-interface Client {+interface Client {request(opts: ClientOpts): Request;}async function exec<T>(opts: ExecOpts): Promise<T> {const client = getClient(opts);-+// hack for cases where electron.net does not work, but we don't want to set proxyif (opts.proxy === 'noproxy') {opts.proxy = null;diff --git a/src/services/request_interface.ts b/src/services/request_interface.tsindex 56ec828cb5..a918bac45f 100644--- a/src/services/request_interface.ts+++ b/src/services/request_interface.ts@@ -17,4 +17,4 @@ export interface ExecOpts {},timeout: number;body?: string | {};-}\ No newline at end of file+}diff --git a/src/services/script.ts b/src/services/script.tsindex 5b4004bb5d..d421ca385b 100644--- a/src/services/script.ts+++ b/src/services/script.ts@@ -27,7 +27,7 @@ function executeNote(note: BNote, apiParams: ApiParams) {if (!bundle) {throw new Error("Unable to determine bundle.");}-+return executeBundle(bundle, apiParams);}diff --git a/src/services/script_context.ts b/src/services/script_context.tsindex d36c0d492a..313c6fcc78 100644--- a/src/services/script_context.ts+++ b/src/services/script_context.ts@@ -12,7 +12,7 @@ class ScriptContext {notes: {};apis: {};allNotes: BNote[];-+constructor(allNotes: BNote[], apiParams: ApiParams) {this.allNotes = allNotes;this.modules = {};diff --git a/src/services/search/note_set.ts b/src/services/search/note_set.tsindex 6f56452b73..aa95964480 100644--- a/src/services/search/note_set.ts+++ b/src/services/search/note_set.ts@@ -3,9 +3,9 @@import BNote from "../../becca/entities/bnote.js";class NoteSet {-+private noteIdSet: Set<string>;-+notes: BNote[];sorted: boolean;diff --git a/src/services/search/search_context.ts b/src/services/search/search_context.tsindex 17e75d7955..8e6fdb5957 100644--- a/src/services/search/search_context.ts+++ b/src/services/search/search_context.ts@@ -4,7 +4,7 @@ import hoistedNoteService from "../hoisted_note.js";import { SearchParams } from './services/types.js';class SearchContext {-+fastSearch: boolean;includeArchivedNotes: boolean;includeHiddenNotes: boolean;diff --git a/src/services/search/search_result.ts b/src/services/search/search_result.tsindex 45a85c3862..3e26080610 100644--- a/src/services/search/search_result.ts+++ b/src/services/search/search_result.ts@@ -42,8 +42,8 @@ class SearchResult {else if (normalizedTitle.startsWith(normalizedQuery)) {this.score += 500; // Increased to give more weight to prefix matches}- else if (normalizedTitle.includes(` ${normalizedQuery} `) ||- normalizedTitle.startsWith(`${normalizedQuery} `) ||+ else if (normalizedTitle.includes(` ${normalizedQuery} `) ||+ normalizedTitle.startsWith(`${normalizedQuery} `) ||normalizedTitle.endsWith(` ${normalizedQuery}`)) {this.score += 300; // Increased to better distinguish word matches}diff --git a/src/services/setup.ts b/src/services/setup.tsindex b632e8d08b..2f38cc0ac1 100644--- a/src/services/setup.ts+++ b/src/services/setup.ts@@ -88,7 +88,7 @@ async function setupSyncFromSyncServer(syncServerHost: string, syncProxy: string}await sqlInit.createDatabaseForSync(resp.options, syncServerHost, syncProxy);-+triggerSync();return { result: 'success' };diff --git a/src/services/sql.ts b/src/services/sql.tsindex d2b14c6699..9dfafbc4db 100644--- a/src/services/sql.ts+++ b/src/services/sql.ts@@ -19,7 +19,7 @@ let statementCache: Record<string, Statement> = {};function buildDatabase() {if (process.env.TRILIUM_INTEGRATION_TEST === "memory") {- return buildIntegrationTestDatabase();+ return buildIntegrationTestDatabase();}return new Database(dataDir.DOCUMENT_PATH);@@ -95,8 +95,8 @@ function upsert<T extends {}>(tableName: string, primaryKey: string, rec: T) {const updateMarks = keys.map(colName => `${colName} = @${colName}`).join(", ");- const query = `INSERT INTO ${tableName} (${columns}) VALUES (${questionMarks})- ON CONFLICT (${primaryKey}) DO UPDATE SET ${updateMarks}`;+ const query = `INSERT INTO ${tableName} (${columns}) VALUES (${questionMarks})+ ON CONFLICT (${primaryKey}) DO UPDATE SET ${updateMarks}`;for (const idx in rec) {if (rec[idx] === true || rec[idx] === false) {@@ -345,60 +345,60 @@ export default {replace,/**- * Get single value from the given query - first column from first returned row.- *- * @param query - SQL query with ? used as parameter placeholder- * @param params - array of params if needed- * @returns single value- */+ * Get single value from the given query - first column from first returned row.+ *+ * @param query - SQL query with ? used as parameter placeholder+ * @param params - array of params if needed+ * @returns single value+ */getValue,/**- * Get first returned row.- *- * @param query - SQL query with ? used as parameter placeholder- * @param params - array of params if needed- * @returns - map of column name to column value- */+ * Get first returned row.+ *+ * @param query - SQL query with ? used as parameter placeholder+ * @param params - array of params if needed+ * @returns - map of column name to column value+ */getRow,getRowOrNull,/**- * Get all returned rows.- *- * @param query - SQL query with ? used as parameter placeholder- * @param params - array of params if needed- * @returns - array of all rows, each row is a map of column name to column value- */+ * Get all returned rows.+ *+ * @param query - SQL query with ? used as parameter placeholder+ * @param params - array of params if needed+ * @returns - array of all rows, each row is a map of column name to column value+ */getRows,getRawRows,iterateRows,getManyRows,/**- * Get a map of first column mapping to second column.- *- * @param query - SQL query with ? used as parameter placeholder- * @param params - array of params if needed- * @returns - map of first column to second column- */+ * Get a map of first column mapping to second column.+ *+ * @param query - SQL query with ? used as parameter placeholder+ * @param params - array of params if needed+ * @returns - map of first column to second column+ */getMap,/**- * Get a first column in an array.- *- * @param query - SQL query with ? used as parameter placeholder- * @param params - array of params if needed- * @returns array of first column of all returned rows- */+ * Get a first column in an array.+ *+ * @param query - SQL query with ? used as parameter placeholder+ * @param params - array of params if needed+ * @returns array of first column of all returned rows+ */getColumn,/**- * Execute SQL- *- * @param query - SQL query with ? used as parameter placeholder- * @param params - array of params if needed- */+ * Execute SQL+ *+ * @param query - SQL query with ? used as parameter placeholder+ * @param params - array of params if needed+ */execute,executeMany,executeScript,diff --git a/src/services/sql_init.ts b/src/services/sql_init.tsindex 85ddef3343..0bcf77002c 100644--- a/src/services/sql_init.ts+++ b/src/services/sql_init.ts@@ -22,7 +22,7 @@ const dbReady = utils.deferred<void>();function schemaExists() {return !!sql.getValue(`SELECT name FROM sqlite_master- WHERE type = 'table' AND name = 'options'`);+ WHERE type = 'table' AND name = 'options'`);}function isDbInitialized() {@@ -87,7 +87,7 @@ async function createInitialDatabase() {isExpanded: true,notePosition: 10}).save();-+optionsInitService.initDocumentOptions();optionsInitService.initNotSyncedOptions(true, {});optionsInitService.initStartupOptions();@@ -131,7 +131,7 @@ async function createDatabaseForSync(options: OptionRow[], syncServerHost = '',// We have to import async since options init requires keyboard actions which require translations.const optionsInitService = (await import("./options_init.js")).default;-+sql.transactional(() => {sql.executeScript(schema);@@ -171,22 +171,22 @@ function initializeDb() {cls.init(initDbConnection);log.info(`DB size: ${getDbSize()} KB`);-+dbReady.then(() => {if (config.General && config.General.noBackup === true) {log.info("Disabling scheduled backups.");-+return;}-+setInterval(() => backup.regularBackup(), 4 * 60 * 60 * 1000);-+// kickoff first backup soon after start upsetTimeout(() => backup.regularBackup(), 5 * 60 * 1000);-+// optimize is usually inexpensive no-op, so running it semi-frequently is not a big dealsetTimeout(() => optimize(), 60 * 60 * 1000);-+setInterval(() => optimize(), 10 * 60 * 60 * 1000);});}diff --git a/src/services/sync.ts b/src/services/sync.tsindex 5864edb069..9d62b2fc09 100644--- a/src/services/sync.ts+++ b/src/services/sync.ts@@ -153,7 +153,7 @@ async function doLogin(): Promise<SyncContext> {return syncContext;}-async function pullChanges(syncContext: SyncContext) {+async function pullChanges(syncContext: SyncContext) {while (true) {const lastSyncedPull = getLastSyncedPull();const logMarkerId = utils.randomString(10); // to easily pair sync events between client and server logsdiff --git a/src/services/task_context.ts b/src/services/task_context.tsindex 0f3557674f..64e57a000d 100644--- a/src/services/task_context.ts+++ b/src/services/task_context.ts@@ -14,7 +14,7 @@ class TaskContext {private lastSentCountTs: number;data: TaskData | null;noteDeletionHandlerTriggered: boolean;-+constructor(taskId: string, taskType: string | null = null, data: {} | null = {}) {this.taskId = taskId;this.taskType = taskType;diff --git a/src/services/utils.ts b/src/services/utils.tsindex 1c7a7e12ba..887abde0b4 100644--- a/src/services/utils.ts+++ b/src/services/utils.ts@@ -272,14 +272,14 @@ function timeLimit<T>(promise: Promise<T>, limitMs: number, errorMessage?: strin}interface DeferredPromise<T> extends Promise<T> {- resolve: (value: T | PromiseLike<T>) => void,- reject: (reason?: any) => void+ resolve: (value: T | PromiseLike<T>) => void,+ reject: (reason?: any) => void}function deferred<T>(): DeferredPromise<T> {return (() => {let resolve!: (value: T | PromiseLike<T>) => void;- let reject!: (reason?: any) => void;+ let reject!: (reason?: any) => void;let promise = new Promise<T>((res, rej) => {resolve = res;@@ -321,7 +321,7 @@ function isString(x: any) {/*** Returns the directory for resources. On Electron builds this corresponds to the `resources` subdirectory inside the distributable package.* On development builds, this simply refers to the root directory of the application.- *+ ** @returns the resource dir.*/export function getResourceDir() {@@ -329,7 +329,7 @@ export function getResourceDir() {return process.resourcesPath;} else {return join(dirname(fileURLToPath(import.meta.url)), "..", "..");- }+ }}export default {diff --git a/src/services/window.ts b/src/services/window.tsindex 0ef8ca3355..2f5b345db8 100644--- a/src/services/window.ts+++ b/src/services/window.ts@@ -58,7 +58,7 @@ async function createMainWindow(app: App) {}]);}-+const windowStateKeeper = (await import('electron-window-state')).default; // should not be statically importedconst mainWindowState = windowStateKeeper({@@ -71,7 +71,7 @@ async function createMainWindow(app: App) {const { BrowserWindow } = (await import('electron')); // should not be statically imported-+mainWindow = new BrowserWindow({x: mainWindowState.x,@@ -84,7 +84,7 @@ async function createMainWindow(app: App) {contextIsolation: false,spellcheck: spellcheckEnabled,webviewTag: true- },+ },icon: getIcon(),...getWindowExtraOpts()});@@ -99,7 +99,7 @@ async function createMainWindow(app: App) {app.on('second-instance', (event, commandLine) => {if (commandLine.includes('--new-window')) {- createExtraWindow("");+ createExtraWindow("");} else if (mainWindow) {// Someone tried to run a second instance, we should focus our window.// see www.ts "requestSingleInstanceLock" for the rest of this logic with explanation@@ -146,7 +146,7 @@ function configureWebContents(webContents: WebContents, spellcheckEnabled: booleasync function openExternal() {(await import('electron')).shell.openExternal(details.url);}-+openExternal();return { action: 'deny' }});diff --git a/src/services/ws.ts b/src/services/ws.tsindex 8f9f5b418b..9bb56cfbfc 100644--- a/src/services/ws.ts+++ b/src/services/ws.ts@@ -35,12 +35,12 @@ interface Message {shrinkImages?: boolean} | null,lastSyncedPush?: number | null,-+progressCount?: number;taskId?: string;taskType?: string | null;message?: string;- reason?: string;+ reason?: string;result?: string | Record<string, string | undefined>;script?: string;