From 606e6bcca2e190c25c25931333c9fa04ff25edb9 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Wed, 19 Mar 2025 15:35:12 +0800 Subject: [PATCH 01/57] Click the icon to show the window --- src/services/window.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/services/window.ts b/src/services/window.ts index c43e56415..8b5697609 100644 --- a/src/services/window.ts +++ b/src/services/window.ts @@ -162,7 +162,7 @@ async function createMainWindow(app: App) { if (mainWindow.isMinimized()) { mainWindow.restore(); } - + mainWindow.show(); mainWindow.focus(); } }); From be2064fbf04a329947128d6201b2a1030a2c1ff2 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Fri, 21 Mar 2025 11:08:33 +0800 Subject: [PATCH 02/57] Fix tray exception when multiple windows --- .../tray/new-windowTemplate-inverted.png | Bin 0 -> 348 bytes .../new-windowTemplate-inverted@1.25x.png | Bin 0 -> 427 bytes .../tray/new-windowTemplate-inverted@1.5x.png | Bin 0 -> 514 bytes .../tray/new-windowTemplate-inverted@2x.png | Bin 0 -> 649 bytes images/app-icons/tray/new-windowTemplate.png | Bin 0 -> 331 bytes .../tray/new-windowTemplate@1.25x.png | Bin 0 -> 409 bytes .../tray/new-windowTemplate@1.5x.png | Bin 0 -> 481 bytes .../app-icons/tray/new-windowTemplate@2x.png | Bin 0 -> 626 bytes src/services/tray.ts | 155 +++++++++++++----- src/services/window.ts | 48 +++++- translations/en/server.json | 3 +- 11 files changed, 156 insertions(+), 50 deletions(-) create mode 100644 images/app-icons/tray/new-windowTemplate-inverted.png create mode 100644 images/app-icons/tray/new-windowTemplate-inverted@1.25x.png create mode 100644 images/app-icons/tray/new-windowTemplate-inverted@1.5x.png create mode 100644 images/app-icons/tray/new-windowTemplate-inverted@2x.png create mode 100644 images/app-icons/tray/new-windowTemplate.png create mode 100644 images/app-icons/tray/new-windowTemplate@1.25x.png create mode 100644 images/app-icons/tray/new-windowTemplate@1.5x.png create mode 100644 images/app-icons/tray/new-windowTemplate@2x.png diff --git a/images/app-icons/tray/new-windowTemplate-inverted.png b/images/app-icons/tray/new-windowTemplate-inverted.png new file mode 100644 index 0000000000000000000000000000000000000000..b587fe0bbfbc27183bf610e90242885d6edcb539 GIT binary patch literal 348 zcmV-i0i*tjP)wJ0!)A#1C)P64hFae?vR9} zsWxA?lKKn;yaA8SN(0dgpaagLAp+FEGjR1!0_T3y*DKdw0b^jtdR!yh#`cM1_ZdWx zF40@y*l9mGSZ7gQLjJ$sPH|@a2>4v*Uk-dz4Lkq`z`oD*x@IdghAZzUzz6VZSpcV* z&#w}e2?uk_z4h}f@G=HZ0S~y4Kd<@A;XNq zvlTPTtvPZtTQ;*{%@$R|CdW4IT>@|lern+n_^4S^pEC{2i(^PwDq$bE_@%-fpf8Rg zp+`%^4#!G-=5feGunX*Io>gsd6>DDE0&uKS+yf6) zLedHcOJD-%0W)&52TTSg)+Pj)0?vVrpjPX0v|U$W8pPUC)CHb2y1;2bn8q9~a%`aE zl)wvcqV+>P&qjzEgl@a&{&n;Td3Rrd=iq8MU=ElKOzUXx_kC1zSR2zEjPrG5QV=Uk7I#7QCMUX*sx&164rKoLIVdN@8W_rScD0NW{V)pkOHy&{Ax~v=(ag57>yEptWf&6HqJ# zg)~Vt`F3|~-hsnr*S$C&8CZ7r?Cg2pnK@S%Lf|Mz-XeEX!V6slJWw@FOgJLOAp%Yx zGGJ~BBpmPuDD@mHfhf2JJOh>!A4OcuCa?;8ikL2h;5FeK@EJHYWxM+UTm`-Z&g)D9 za8cj~hIPsd={_T@0QkBM1l>z(C<%=(V)!;Mh-aSZNMrx2Zg&~D z-zN}x;3M!M@#=Sg2Yn;qqQ2!oks#U@(%Cx{mj<}#2rl#pT7`7>CNMg-r%FbB!YaUV zk=PkaC?5$P^TumE-!#4*hPudDw^|kO3h+oWKStS*k;#~@15X560*`?kdd{XrAc8Lg zFMwm_I5OZlaA7D3Kj7R;U>;ZpPAjoE={S(=4X|Kxei8z4l_!9AN~Io{F>_`ly9B%k zPMZIcctOku>%c3$UooL|O|^tKi>gu)h;FqFyfyM&L!d2pgs}uN8ChOiMP@?lVoUCz zR@mmoP&*04f@B+*=(1yCyrFE!9ibuSPs|P;+LgQkypUhtH5E+!wh!FV_BU?$x}*=7t=&-Er(cg#}RM##+Auw}7X>d9wn$J9~z3 zp?90ID^$r#G(`a0|dv={SIuH?T5BXe^clcf+IL8!~yi z0VbL3%)Hre{==R!&Zi6@IKw5-1!7|NWN$T4d4Lia3*cBbTLC-)&t{wo{T!YEbX;m* zz(Tgz5dKbO$C`b}z(5+O*TAjPep9eU z9Mclg`Ti=!ne-dr=Rg0fWlRO|3iN?1$%Wop0fHg~U;wOuPw^5MCO&^k*tj0d#V^wD zlfWAb?g6fWkviOHxpEiiLEl=wA0Dv;zExwiJy#QFk}JJ!RZ^KAQ!m+zN(Y9MgKPBq d*fdT$=N-zgNZA9LKn?%^002ovPDHLkV1mqFi_`!B literal 0 HcmV?d00001 diff --git a/images/app-icons/tray/new-windowTemplate@1.25x.png b/images/app-icons/tray/new-windowTemplate@1.25x.png new file mode 100644 index 0000000000000000000000000000000000000000..b52f2158d5ac4d95dfbd4cbf82f7cc5dafa810c5 GIT binary patch literal 409 zcmV;K0cQS*P)YU6vlt|=2o$~IQRe+2VMMw?mD=ZqV#!O-FyfYItkJT5Yz`ya1`7{L`0+@P2%!h zJ;o;5=m#eW=YPI)a^v_!0(j~n15&GS{2eY{9FPNBl6;H;(f0y4vvDiHP!4ru2rOeb zTNH}V zC@713Sc%C}^PG+F{Z_dQi4yDpyLwKl0z!o?cD4Ws1egL&fepjeI?xB2zwOW)T~i%(fqO|8I5r7=F-Is&Y@pZ4fJfj+_I=$?Ml?0B z(+-9GYv~h;(|rOS%xVN+4wyAVYbo~2KCYD<4hOQoNRY1RmjbJ?q64mgZD3Olao^6B zWX}}u1J6q06@Lj_+sXgy0bBJ8NY!oRdMKZy>=*D3C!%bA!HCNs00000NkvXXu0mjf DAmOSF literal 0 HcmV?d00001 diff --git a/images/app-icons/tray/new-windowTemplate@1.5x.png b/images/app-icons/tray/new-windowTemplate@1.5x.png new file mode 100644 index 0000000000000000000000000000000000000000..61172b73248887298524200e378fcb76181deecc GIT binary patch literal 481 zcmV<70UrK|P)Inm;DAry7I+LT zsR6A(Xj6KZ&ILjZIFKcqjyZ7X0c>F2TyFW=5TGetE(8Fm06)MfkP6HdRO)3Lz?*at z19(e%z<0^pPvQu)8A9HYEDKCdB6-cIP&wwc~1J0v86X+R8SF;F!x9}uN#I|_e3#9-O(H`(5#Z!?3o`HIFk+lH4 z`F9H2ZeT%Iy!+@a3jyp0w=ybz4d7TZL#-Q8VKh3s1Yk3o#3Ty256!cH=aVtbNVKK! zw$X#mRP=0+JO=11iCmP7%|OPN3McoPxY4w=naWH*cl6M^z*w{^UMG@GrK1H@!$=tc zm%vM2Mh11Nw_@J`ufUZqlEhuB>g#xPaG=>oMqe(dXLP=C*fRgU>6<@(Lrl(h?r+O4 XxGJCsS42yu00000NkvXXu0mjfzoF4= literal 0 HcmV?d00001 diff --git a/images/app-icons/tray/new-windowTemplate@2x.png b/images/app-icons/tray/new-windowTemplate@2x.png new file mode 100644 index 0000000000000000000000000000000000000000..a1ced05691f3434a8bfe412c9fed279be3363737 GIT binary patch literal 626 zcmV-&0*(ENP)=L;ko_j#}VOz-U)xX(EIvFk1(0 z3vd4ga--`QKwzu_FM!34k0KcJ5m*C0SP)J>SAlP0PIBx6SESQ90VshbU;#KXsJk3! z?@Q8E0?tQbAkjG$69~Sb<2Vp~Mf#;0T~jd}S3a^R1=fK*AuT$vyZ}~!hr^S;Lf}2{ zu4C&DfJb!z0Q5BHfox30VUJ$bWQ=m7IIB_0M-{D1d)5ZfS#7W5o^hJkd4V`+3&^)r zo+z?k>AP=oyKI^wZPRK^ithqX#B*&nYeK1l={E38N^{^Ta7W+iqyPlvi@*jjWsV~S zUII6of^ZGaJqPB1ZQ!CBOQJoF#Cr{#Gd;f(0Kv)&z+2#!_4 zA8Z3#`oC#P>pHM25U#56v;`2->L>8V@P8QqRlTEZ3m{dH`5`M(Q(Ai!y(3s(8XZYh zVEPE+MAi;8EDcOHzkt(CI4L)V8Wd+MC)hZ9`GEvZY;3g`EAf=`nN5+0KTdg z#NOM}(5jUc`vS)+-0hnmYHh_DA3IG5A M07*qoM6N<$f^Iq!cK`qY literal 0 HcmV?d00001 diff --git a/src/services/tray.ts b/src/services/tray.ts index c35e2c823..ab1dc0af0 100644 --- a/src/services/tray.ts +++ b/src/services/tray.ts @@ -1,4 +1,4 @@ -import { Menu, Tray } from "electron"; +import { Menu, Tray, BrowserWindow } from "electron"; import path from "path"; import windowService from "./window.js"; import optionService from "./options.js"; @@ -17,7 +17,7 @@ import cls from "./cls.js"; let tray: Tray; // `mainWindow.isVisible` doesn't work with `mainWindow.show` and `mainWindow.hide` - it returns `false` when the window // is minimized -let isVisible = true; +let windowVisibilityMap: Record = {};; // Dictionary for storing window ID and its visibility status function getTrayIconPath() { let name: string; @@ -37,53 +37,87 @@ function getIconPath(name: string) { return path.join(path.dirname(fileURLToPath(import.meta.url)), "../..", "images", "app-icons", "tray", `${name}Template${suffix}.png`); } -function registerVisibilityListener() { - const mainWindow = windowService.getMainWindow(); - if (!mainWindow) { +function registerVisibilityListener(window: BrowserWindow) { + if (!window) { return; } // They need to be registered before the tray updater is registered - mainWindow.on("show", () => { - isVisible = true; + window.on("show", () => { + windowVisibilityMap[window.id] = true; updateTrayMenu(); }); - mainWindow.on("hide", () => { - isVisible = false; + window.on("hide", () => { + windowVisibilityMap[window.id] = false; updateTrayMenu(); }); - mainWindow.on("minimize", updateTrayMenu); - mainWindow.on("maximize", updateTrayMenu); - if (!isMac) { - // macOS uses template icons which work great on dark & light themes. - nativeTheme.on("updated", updateTrayMenu); - } - ipcMain.on("reload-tray", updateTrayMenu); - i18next.on("languageChanged", updateTrayMenu); + window.on("minimize", updateTrayMenu); + window.on("maximize", updateTrayMenu); } -function updateTrayMenu() { - const mainWindow = windowService.getMainWindow(); - if (!mainWindow) { +function getWindowTitle(window: BrowserWindow | null) { + if (!window) { return; } + const title = window.getTitle(); + const titleWithoutAppName = title.replace(/\s-\s[^-]+$/, ''); // Remove the name of the app - function ensureVisible() { - if (mainWindow) { - mainWindow.show(); - mainWindow.focus(); + // Limit title maximum length to 17 + if (titleWithoutAppName.length > 20) { + return titleWithoutAppName.substring(0, 17) + '...'; + } + + return titleWithoutAppName; +} + +function updateWindowVisibilityMap(allWindows: BrowserWindow[]) { + const currentWindowIds: number[] = allWindows.map(window => window.id); + + // Deleting closed windows from windowVisibilityMap + for (const [id, visibility] of Object.entries(windowVisibilityMap)) { + const windowId = Number(id); + if (!currentWindowIds.includes(windowId)) { + delete windowVisibilityMap[windowId]; + } + } + + // Iterate through allWindows to make sure the ID of each window exists in windowVisibilityMap + allWindows.forEach(window => { + const windowId = window.id; + if (!(windowId in windowVisibilityMap)) { + // If it does not exist, it is the newly created window + windowVisibilityMap[windowId] = true; + registerVisibilityListener(window); + } + }); +} + + +function updateTrayMenu() { + const lastFocusedWindow = windowService.getLastFocusedWindow(); + const allWindows = windowService.getAllWindows(); + updateWindowVisibilityMap(allWindows); + + function ensureVisible(win: BrowserWindow) { + if (win) { + win.show(); + win.focus(); } } function triggerKeyboardAction(actionName: KeyboardActionNames) { - mainWindow?.webContents.send("globalShortcut", actionName); - ensureVisible(); + if (lastFocusedWindow){ + lastFocusedWindow.webContents.send("globalShortcut", actionName); + ensureVisible(lastFocusedWindow); + } } function openInSameTab(note: BNote | BRecentNote) { - mainWindow?.webContents.send("openInSameTab", note.noteId); - ensureVisible(); + if (lastFocusedWindow){ + lastFocusedWindow.webContents.send("openInSameTab", note.noteId); + ensureVisible(lastFocusedWindow); + } } function buildBookmarksMenu() { @@ -144,20 +178,44 @@ function updateTrayMenu() { return menuItems; } - const contextMenu = Menu.buildFromTemplate([ - { - label: t("tray.show-windows"), + const windowVisibilityMenuItems: Electron.MenuItemConstructorOptions[] = []; + + // Only call getWindowTitle if windowVisibilityMap has more than one window + const showTitle = Object.keys(windowVisibilityMap).length > 1; + + for (const idStr in windowVisibilityMap) { + const id = parseInt(idStr, 10); // Get the ID of the window and make sure it is a number + const isVisible = windowVisibilityMap[id]; + const win = allWindows.find(w => w.id === id); + if (!win) { + continue; + } + windowVisibilityMenuItems.push({ + label: showTitle ? `${t("tray.show-windows")}: ${getWindowTitle(win)}` : t("tray.show-windows"), type: "checkbox", checked: isVisible, click: () => { if (isVisible) { - mainWindow.hide(); + win.hide(); + windowVisibilityMap[id] = false; } else { - ensureVisible(); + ensureVisible(win); + windowVisibilityMap[id] = true; } } - }, + }); + } + + + const contextMenu = Menu.buildFromTemplate([ + ...windowVisibilityMenuItems, { type: "separator" }, + { + label: t("tray.open_new_window"), + type: "normal", + icon: getIconPath("new-window"), + click: () => triggerKeyboardAction("openNewWindow") + }, { label: t("tray.new-note"), type: "normal", @@ -188,7 +246,10 @@ function updateTrayMenu() { type: "normal", icon: getIconPath("close"), click: () => { - mainWindow.close(); + const windows = BrowserWindow.getAllWindows(); + windows.forEach(window => { + window.close(); + }); } } ]); @@ -197,16 +258,18 @@ function updateTrayMenu() { } function changeVisibility() { - const window = windowService.getMainWindow(); - if (!window) { + const lastFocusedWindow = windowService.getLastFocusedWindow(); + + if (!lastFocusedWindow) { return; } - if (isVisible) { - window.hide(); + // If the window is visible, hide it + if (windowVisibilityMap[lastFocusedWindow.id]) { + lastFocusedWindow.hide(); } else { - window.show(); - window.focus(); + lastFocusedWindow.show(); + lastFocusedWindow.focus(); } } @@ -221,9 +284,15 @@ function createTray() { tray.on("click", changeVisibility); updateTrayMenu(); - registerVisibilityListener(); + if (!isMac) { + // macOS uses template icons which work great on dark & light themes. + nativeTheme.on("updated", updateTrayMenu); + } + ipcMain.on("reload-tray", updateTrayMenu); + i18next.on("languageChanged", updateTrayMenu); } export default { - createTray + createTray, + updateTrayMenu }; diff --git a/src/services/window.ts b/src/services/window.ts index 8b5697609..12c125b6d 100644 --- a/src/services/window.ts +++ b/src/services/window.ts @@ -11,6 +11,7 @@ import remoteMain from "@electron/remote/main/index.js"; import { BrowserWindow, shell, type App, type BrowserWindowConstructorOptions, type WebContents } from "electron"; import { dialog, ipcMain } from "electron"; import { formatDownloadTitle, isDev, isMac, isWindows } from "./utils.js"; +import tray from "./tray.js"; import { fileURLToPath } from "url"; import { dirname } from "path"; @@ -19,6 +20,26 @@ import { t } from "i18next"; // Prevent the window being garbage collected let mainWindow: BrowserWindow | null; let setupWindow: BrowserWindow | null; +let allWindows: BrowserWindow[] = []; // // Used to store all windows, sorted by the order of focus. + +function trackWindowFocus(win: BrowserWindow) { + // We need to get the last focused window from allWindows. If the last window is closed, we return the previous window. + // Therefore, we need to push the window into the allWindows array every time it gets focused. + win.on("focus", () => { + allWindows = allWindows.filter(w => !w.isDestroyed() && w !== win); + allWindows.push(win); + if (!optionService.getOptionBool("disableTray")) { + tray.updateTrayMenu(); + } + }); + + win.on("closed", () => { + allWindows = allWindows.filter(w => !w.isDestroyed()); + if (!optionService.getOptionBool("disableTray")) { + tray.updateTrayMenu(); + } + }); +} async function createExtraWindow(extraWindowHash: string) { const spellcheckEnabled = optionService.getOptionBool("spellCheckEnabled"); @@ -42,6 +63,8 @@ async function createExtraWindow(extraWindowHash: string) { win.loadURL(`http://127.0.0.1:${port}/?extraWindow=1${extraWindowHash}`); configureWebContents(win.webContents, spellcheckEnabled); + + trackWindowFocus(win); } ipcMain.on("create-extra-window", (event, arg) => { @@ -154,18 +177,21 @@ async function createMainWindow(app: App) { configureWebContents(mainWindow.webContents, spellcheckEnabled); app.on("second-instance", (event, commandLine) => { + const lastFocusedWindow = getLastFocusedWindow(); if (commandLine.includes("--new-window")) { createExtraWindow(""); - } else if (mainWindow) { + } else if (lastFocusedWindow) { // Someone tried to run a second instance, we should focus our window. // see www.ts "requestSingleInstanceLock" for the rest of this logic with explanation - if (mainWindow.isMinimized()) { - mainWindow.restore(); + if (lastFocusedWindow.isMinimized()) { + lastFocusedWindow.restore(); } - mainWindow.show(); - mainWindow.focus(); + lastFocusedWindow.show(); + lastFocusedWindow.focus(); } }); + + trackWindowFocus(mainWindow); } function getWindowExtraOpts() { @@ -296,10 +322,20 @@ function getMainWindow() { return mainWindow; } +function getLastFocusedWindow() { + return allWindows.length > 0 ? allWindows[allWindows.length - 1] : null; +} + +function getAllWindows(){ + return allWindows; +} + export default { createMainWindow, createSetupWindow, closeSetupWindow, registerGlobalShortcuts, - getMainWindow + getMainWindow, + getLastFocusedWindow, + getAllWindows }; diff --git a/translations/en/server.json b/translations/en/server.json index f25927fd6..6267a0060 100644 --- a/translations/en/server.json +++ b/translations/en/server.json @@ -272,7 +272,8 @@ "bookmarks": "Bookmarks", "today": "Open today's journal note", "new-note": "New note", - "show-windows": "Show windows" + "show-windows": "Show windows", + "open_new_window": "Open new window" }, "migration": { "old_version": "Direct migration from your current version is not supported. Please upgrade to the latest v0.60.4 first and only then to this version.", From da59dd2ecefdccbbb8bf37fd235024cda333c8d8 Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Fri, 21 Mar 2025 13:56:21 +0800 Subject: [PATCH 03/57] Add Chinese translation --- translations/cn/server.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/translations/cn/server.json b/translations/cn/server.json index 619bb0c7a..aaaceb7e2 100644 --- a/translations/cn/server.json +++ b/translations/cn/server.json @@ -271,7 +271,8 @@ "bookmarks": "书签", "today": "打开今天的日记笔记", "new-note": "新建笔记", - "show-windows": "显示窗口" + "show-windows": "显示窗口", + "open_new_window": "打开新窗口" }, "migration": { "old_version": "由您当前版本的直接迁移不被支持。请先升级到最新的 v0.60.4 然后再到这个版本。", From 87c70cb46e8efcb722bc8c51f93d2e5ae0c31b2c Mon Sep 17 00:00:00 2001 From: SiriusXT <1160925501@qq.com> Date: Sun, 23 Mar 2025 10:44:01 +0800 Subject: [PATCH 04/57] Fixed focusing on old windows when opening new windows from tray --- src/services/tray.ts | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/services/tray.ts b/src/services/tray.ts index ab1dc0af0..2933e49fc 100644 --- a/src/services/tray.ts +++ b/src/services/tray.ts @@ -106,6 +106,12 @@ function updateTrayMenu() { } } + function openNewWindow() { + if (lastFocusedWindow){ + lastFocusedWindow.webContents.send("globalShortcut", "openNewWindow"); + } + } + function triggerKeyboardAction(actionName: KeyboardActionNames) { if (lastFocusedWindow){ lastFocusedWindow.webContents.send("globalShortcut", actionName); @@ -214,7 +220,7 @@ function updateTrayMenu() { label: t("tray.open_new_window"), type: "normal", icon: getIconPath("new-window"), - click: () => triggerKeyboardAction("openNewWindow") + click: () => openNewWindow() }, { label: t("tray.new-note"), From e0522fcd487180ae2feb97309624ddee57e76ad5 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Wed, 26 Mar 2025 02:11:39 +0000 Subject: [PATCH 05/57] fix(deps): update dependency mermaid to v11.6.0 --- package-lock.json | 24 ++++++++++++------------ package.json | 2 +- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/package-lock.json b/package-lock.json index 3f74e7b7b..650d1ea0c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -68,7 +68,7 @@ "leaflet-gpx": "2.1.2", "mark.js": "8.11.1", "marked": "15.0.7", - "mermaid": "11.5.0", + "mermaid": "11.6.0", "mime-types": "2.1.35", "multer": "1.4.5-lts.2", "normalize-strings": "1.1.1", @@ -3976,12 +3976,12 @@ } }, "node_modules/@mermaid-js/parser": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/@mermaid-js/parser/-/parser-0.3.0.tgz", - "integrity": "sha512-HsvL6zgE5sUPGgkIDlmAWR1HTNHz2Iy11BAWPTa4Jjabkpguy4Ze2gzfLrg6pdRuBvFwgUYyxiaNqZwrEEXepA==", + "version": "0.4.0", + "resolved": "https://registry.npmjs.org/@mermaid-js/parser/-/parser-0.4.0.tgz", + "integrity": "sha512-wla8XOWvQAwuqy+gxiZqY+c7FokraOTHRWMsbB4AgRx9Sy7zKslNyejy7E+a77qHfey5GXw/ik3IXv/NHMJgaA==", "license": "MIT", "dependencies": { - "langium": "3.0.0" + "langium": "3.3.1" } }, "node_modules/@mind-elixir/node-menu": { @@ -14418,9 +14418,9 @@ } }, "node_modules/langium": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/langium/-/langium-3.0.0.tgz", - "integrity": "sha512-+Ez9EoiByeoTu/2BXmEaZ06iPNXM6thWJp02KfBO/raSMyCJ4jw7AkWWa+zBCTm0+Tw1Fj9FOxdqSskyN5nAwg==", + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/langium/-/langium-3.3.1.tgz", + "integrity": "sha512-QJv/h939gDpvT+9SiLVlY7tZC3xB2qK57v0J04Sh9wpMb6MP1q8gB21L3WIo8T5P1MSMg3Ep14L7KkDCFG3y4w==", "license": "MIT", "dependencies": { "chevrotain": "~11.0.3", @@ -15104,14 +15104,14 @@ } }, "node_modules/mermaid": { - "version": "11.5.0", - "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.5.0.tgz", - "integrity": "sha512-IYhyukID3zzDj1EihKiN1lp+PXNImoJ3Iyz73qeDAgnus4BNGsJV1n471P4PyeGxPVONerZxignwGxGTSwZnlg==", + "version": "11.6.0", + "resolved": "https://registry.npmjs.org/mermaid/-/mermaid-11.6.0.tgz", + "integrity": "sha512-PE8hGUy1LDlWIHWBP05SFdqUHGmRcCcK4IzpOKPE35eOw+G9zZgcnMpyunJVUEOgb//KBORPjysKndw8bFLuRg==", "license": "MIT", "dependencies": { "@braintree/sanitize-url": "^7.0.4", "@iconify/utils": "^2.1.33", - "@mermaid-js/parser": "^0.3.0", + "@mermaid-js/parser": "^0.4.0", "@types/d3": "^7.4.3", "cytoscape": "^3.29.3", "cytoscape-cose-bilkent": "^4.1.0", diff --git a/package.json b/package.json index ec931d8bb..f790cf2f7 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "leaflet-gpx": "2.1.2", "mark.js": "8.11.1", "marked": "15.0.7", - "mermaid": "11.5.0", + "mermaid": "11.6.0", "mime-types": "2.1.35", "multer": "1.4.5-lts.2", "normalize-strings": "1.1.1", From 17d5fdb4b000481eb78d6efead400abc5ad15176 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sat, 15 Mar 2025 13:41:58 +0100 Subject: [PATCH 06/57] build(copy-dist): get rid of manual node_module copying this is useless at the moment, as all build processes are running "npm ci --omit=dev" anyways, i.e. they will just install everything remaining again --- bin/copy-dist.ts | 48 ------------------------------------------------ 1 file changed, 48 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index eaa79808e..67c3579a6 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -11,13 +11,6 @@ function log(...args: any[]) { } } -function copyNodeModuleFileOrFolder(source: string) { - const destination = path.join(DEST_DIR, source); - log(`Copying ${source} to ${destination}`); - fs.ensureDirSync(path.dirname(destination)); - fs.copySync(source, destination); -} - try { const assetsToCopy = new Set([ @@ -61,47 +54,6 @@ try { fs.copySync(dir, path.join(PUBLIC_DIR, path.basename(dir))); } - const nodeModulesFile = new Set([ - "node_modules/react/umd/react.production.min.js", - "node_modules/react/umd/react.development.js", - "node_modules/react-dom/umd/react-dom.production.min.js", - "node_modules/react-dom/umd/react-dom.development.js", - "node_modules/katex/dist/katex.min.js", - "node_modules/katex/dist/contrib/mhchem.min.js", - "node_modules/katex/dist/contrib/auto-render.min.js", - "node_modules/@highlightjs/cdn-assets/highlight.min.js", - ]); - - const nodeModulesFolder = new Set([ - "node_modules/@excalidraw/excalidraw/dist/prod/fonts/", - "node_modules/katex/dist/", - "node_modules/dayjs/", - "node_modules/boxicons/css/", - "node_modules/boxicons/fonts/", - "node_modules/jquery/dist/", - "node_modules/jquery-hotkeys/", - "node_modules/split.js/dist/", - "node_modules/i18next/", - "node_modules/i18next-http-backend/", - "node_modules/vanilla-js-wheel-zoom/dist/", - "node_modules/mark.js/dist/", - "node_modules/normalize.css/", - "node_modules/jquery.fancytree/dist/", - "node_modules/autocomplete.js/dist/", - "node_modules/codemirror/lib/", - "node_modules/codemirror/addon/", - "node_modules/codemirror/mode/", - "node_modules/codemirror/keymap/", - "node_modules/@highlightjs/cdn-assets/languages", - "node_modules/@highlightjs/cdn-assets/styles", - "node_modules/leaflet/dist" - ]); - - - - for (const nodeModuleItem of [...nodeModulesFile, ...nodeModulesFolder]) { - copyNodeModuleFileOrFolder(nodeModuleItem); - } console.log("Copying complete!") } catch(err) { From 164000029110227fb94c71ed5e245ffa321df30b Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:04:17 +0100 Subject: [PATCH 07/57] build(build-server): move "build:prepare-dist" call to build-server from copy-trilium in preparation to get rid of the file altogether - rest of the functionality will be merged into copy-dist.ts --- bin/build-server.sh | 6 ++++++ bin/copy-trilium.sh | 5 ----- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 052a8131b..fc1807ee0 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -26,6 +26,12 @@ NODE_VERSION=22.14.0 BUILD_DIR="./build" DIST_DIR="./dist" + +# Trigger the build +echo "Build start" +npm run build:prepare-dist +echo "Build finished" + ./bin/copy-trilium.sh NODE_FILENAME=node-v${NODE_VERSION}-linux-${ARCH} diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 55c5cf6de..b80c97632 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -10,11 +10,6 @@ if ! [[ $(which npm) ]]; then exit 1 fi -# Trigger the build -echo Build start -npm run build:prepare-dist -echo Build finished - # Patch package.json main sed -i 's|./dist/electron-main.js|electron-main.js|g' "$BUILD_DIR/package.json" From 89774929811ab3da35b3eaeb359f4cd26a77bc59 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:12:55 +0100 Subject: [PATCH 08/57] build(copy-dist): move "pruning" to copy-dist from copy-trilium.sh --- bin/copy-dist.ts | 4 ++++ bin/copy-trilium.sh | 3 --- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 67c3579a6..2505c31c3 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -1,5 +1,6 @@ import fs from "fs-extra"; import path from "path"; +import { execSync } from "node:child_process"; const DEST_DIR = "./build"; @@ -56,6 +57,9 @@ try { console.log("Copying complete!") + // TriliumNextTODO: for Docker this needs to run separately *after* build-stage + console.log("Pruning npm packages...") + execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); } catch(err) { console.error("Error during copy:", err) process.exit(1) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index b80c97632..515c3ccc6 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -13,9 +13,6 @@ fi # Patch package.json main sed -i 's|./dist/electron-main.js|electron-main.js|g' "$BUILD_DIR/package.json" -# run in subshell (so we return to original dir) -(cd $BUILD_DIR && npm ci --omit=dev) - if [[ -d "$BUILD_DIR"/node_modules ]]; then # cleanup of useless files in dependencies for d in 'image-q/demo' \ From 6fb270e4f8d8ed5c8a0367fb47ea59463b0bfade Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:17:46 +0100 Subject: [PATCH 09/57] build(copy-dist): copy over existing node_modules helps avoiding downloading the packages a 2nd time during our prune stage --- bin/copy-dist.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 2505c31c3..6d9fcf0e0 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -15,6 +15,7 @@ function log(...args: any[]) { try { const assetsToCopy = new Set([ + // copy node_module, to avoid downloading packages a 2nd time during pruning "./node_modules", "./images", "./libraries", From 8feb201d3d0c7a0490b8467fbdf006b5b3f7dbe2 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:21:21 +0100 Subject: [PATCH 10/57] build(electron-forge): set prune to false since we our own more "sophisticated" pruning during copy-dist, we need to set this to false, as otherwise build will fail --- forge.config.cjs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/forge.config.cjs b/forge.config.cjs index ba3d8c3ff..763cb80e8 100644 --- a/forge.config.cjs +++ b/forge.config.cjs @@ -18,6 +18,8 @@ module.exports = { // we run electron-forge inside the ./build folder, // to have it output to ./dist, we need to go up a directory first outDir: "../dist", + // we prune ourselves via copy-dist + prune: false, packagerConfig: { executableName: "trilium", name: APP_NAME, From bee7793d32a5dc01b2342d5caee075afa3b03174 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:30:52 +0100 Subject: [PATCH 11/57] build(copy-trilium): remove now unnecessary package.json patching this is not needed anymore since commit 6b9d8f0d677763f29d29abd0816b1a5d40e858c8 --- bin/copy-trilium.sh | 3 --- 1 file changed, 3 deletions(-) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 515c3ccc6..629138048 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -10,9 +10,6 @@ if ! [[ $(which npm) ]]; then exit 1 fi -# Patch package.json main -sed -i 's|./dist/electron-main.js|electron-main.js|g' "$BUILD_DIR/package.json" - if [[ -d "$BUILD_DIR"/node_modules ]]; then # cleanup of useless files in dependencies for d in 'image-q/demo' \ From 6260ea1532e284c67b450f20fd80808063a94f8b Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:50:59 +0100 Subject: [PATCH 12/57] build(copy-dist): add initial cleanupNodeModules functionality adapted from copy-trilium.sh --- bin/copy-dist.ts | 23 +++++++++++++++++++++++ bin/copy-trilium.sh | 5 ----- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 6d9fcf0e0..f5901225b 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -61,7 +61,30 @@ try { // TriliumNextTODO: for Docker this needs to run separately *after* build-stage console.log("Pruning npm packages...") execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); + + cleanupNodeModules(); + } catch(err) { console.error("Error during copy:", err) process.exit(1) } +function cleanupNodeModules() { + const nodeDir = fs.readdirSync(path.join(DEST_DIR, "./node_modules"), { recursive: true, withFileTypes: true }); + + const filterableDirs = new Set([ + "test", + "docs", + "demo", + "example", + ]); + + const filteredDirs = nodeDir + .filter(el => el.isDirectory() && filterableDirs.has(el.name)) + .map(el => path.join(DEST_DIR, el.parentPath, el.name)); + + filteredDirs.forEach(dir => { + fs.removeSync(dir); + }) + +} + diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 629138048..e99bf08b9 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -19,11 +19,6 @@ if [[ -d "$BUILD_DIR"/node_modules ]]; then '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do [[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d" done - - # delete all tests (there are often large images as test file for jimp etc.) - for d in 'test' 'docs' 'demo' 'example'; do - find "$BUILD_DIR"/node_modules -name "$d" -exec rm -rf {} + - done fi find $BUILD_DIR/libraries -name "*.map" -type f -delete From a9643174ccc5b990e9b846abe90e36e4ec000780 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 01:53:14 +0100 Subject: [PATCH 13/57] build(copy-dist): add further folders to list of filterableDirs same as before, but some of the modules use singular/plural, so just check for both --- bin/copy-dist.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index f5901225b..586650811 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -72,10 +72,14 @@ function cleanupNodeModules() { const nodeDir = fs.readdirSync(path.join(DEST_DIR, "./node_modules"), { recursive: true, withFileTypes: true }); const filterableDirs = new Set([ - "test", - "docs", "demo", + "demos", + "doc", + "docs", "example", + "examples", + "test", + "tests" ]); const filteredDirs = nodeDir From 8275f3c867fff674db44e938f96ce059fa3002df Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 02:10:47 +0100 Subject: [PATCH 14/57] build(copy-dist): execute filterableDirs cleanup in one chain --- bin/copy-dist.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 586650811..38413b1b9 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -82,13 +82,10 @@ function cleanupNodeModules() { "tests" ]); - const filteredDirs = nodeDir + nodeDir .filter(el => el.isDirectory() && filterableDirs.has(el.name)) - .map(el => path.join(DEST_DIR, el.parentPath, el.name)); - - filteredDirs.forEach(dir => { - fs.removeSync(dir); - }) + .map(el => path.join(DEST_DIR, el.parentPath, el.name)) + .forEach(dir => fs.removeSync(dir)); } From 6749d8084bb6f8b56aa330ef6d7d0d0790f3a29c Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 02:15:17 +0100 Subject: [PATCH 15/57] build(copy-dist): add further cleanupNodeModules functionality deleting of ts and map files from node_modules folder, adapted from copy-trilium.sh. --- bin/copy-dist.ts | 13 +++++++++++++ bin/copy-trilium.sh | 2 -- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 38413b1b9..9fb520907 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -87,5 +87,18 @@ function cleanupNodeModules() { .map(el => path.join(DEST_DIR, el.parentPath, el.name)) .forEach(dir => fs.removeSync(dir)); + + // Delete unnecessary files based on file extension + const filterableFileExt = new Set([ + "ts", + "map" + ]) + + nodeDir + // TriliumNextTODO: check if we can improve this naive file ext matching + .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) + .map(file => path.join(DEST_DIR, file.parentPath, file.name)) + .forEach(file => fs.removeSync(file)); + } diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index e99bf08b9..6aea1175c 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -22,7 +22,5 @@ if [[ -d "$BUILD_DIR"/node_modules ]]; then fi find $BUILD_DIR/libraries -name "*.map" -type f -delete -find $BUILD_DIR/node_modules -name "*.map" -type f -delete -find $BUILD_DIR -name "*.ts" -type f -delete unset f d BUILD_DIR From cd8401089d19532d1fa2dc5ebdea79200ec34630 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 16 Mar 2025 02:33:27 +0100 Subject: [PATCH 16/57] build(copy-trilium): update list of useless deps paths * image-q/demo -> doesn't exist anymore (and even if it did - previous cleanup step, would've removed this anyways) * @excalidraw/excalidraw/dist/* -> updated to point to the dev folder * boxicons -> only fonts and css folders are used, so remove the other ones * jimp -> updated paths and removed non-existent path fixing here for historical reasons, next step is to move these over to copy-dist.ts --- bin/copy-trilium.sh | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh index 6aea1175c..f6030a6ec 100755 --- a/bin/copy-trilium.sh +++ b/bin/copy-trilium.sh @@ -12,11 +12,11 @@ fi if [[ -d "$BUILD_DIR"/node_modules ]]; then # cleanup of useless files in dependencies - for d in 'image-q/demo' \ - '@excalidraw/excalidraw/dist/excalidraw-assets-dev' '@excalidraw/excalidraw/dist/excalidraw.development.js' '@excalidraw/excalidraw/dist/excalidraw-with-preact.development.js' \ + for d in \ + '@excalidraw/excalidraw/dist/dev' \ 'mermaid/dist/mermaid.js' \ - 'boxicons/svg' 'boxicons/node_modules/react'/* \ - '@jimp/plugin-print/fonts' 'jimp/browser' 'jimp/fonts'; do + 'boxicons/svg' 'boxicons/node_modules' 'boxicons/src' 'boxicons/iconjar' \ + '@jimp/plugin-print/fonts' 'jimp/dist/browser'; do [[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d" done fi From 1ceaafa1e88323eb106f00a451515f34d1e62bb2 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:02:03 +0100 Subject: [PATCH 17/57] build: move cleanupNodeModules to its own file this is necessary, since for Docker and electron-forge, we need to run this as an extra step after copy-dist for electron-forge: after it is done with its own "pruning", as we otherwise would need to also take care of certain electron related pruning for Docker: as a last step in the build stage --- Dockerfile | 1 + Dockerfile.alpine | 1 + bin/cleanupNodeModules.ts | 87 +++++++++++++++++++++++++++++++++++++++ bin/copy-dist.ts | 41 ++---------------- forge.config.cjs | 19 ++++++++- 5 files changed, 110 insertions(+), 39 deletions(-) create mode 100644 bin/cleanupNodeModules.ts diff --git a/Dockerfile b/Dockerfile index 4aac3160f..538f3e58f 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,6 +18,7 @@ RUN npm ci && \ /usr/src/app/build \ /tmp/node-compile-cache +#TODO: run cleanupNodeModules script #TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work # currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down), # as we install necessary dependencies in runtime buildstage anyways diff --git a/Dockerfile.alpine b/Dockerfile.alpine index f83789399..595d21561 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -18,6 +18,7 @@ RUN npm ci && \ /usr/src/app/build \ /tmp/node-compile-cache +#TODO: run cleanupNodeModules script #TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work # currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down), # as we install necessary dependencies in runtime buildstage anyways diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts new file mode 100644 index 000000000..2daf7c01b --- /dev/null +++ b/bin/cleanupNodeModules.ts @@ -0,0 +1,87 @@ +import fs from "fs-extra"; +import path from "path"; + +function main() { + if (process.argv.length !== 3) { + console.error("More than one path was supplied as argument. Aborting."); + process.exit(1); + } + + const basePath = process.argv[2]; + + if (!fs.existsSync(basePath)) { + console.error(`Supplied path '${basePath}' does not exist. Aborting.`) + process.exit(1); + } + + cleanupNodeModules(basePath); +} + +function cleanupNodeModules(basePath: string) { + const nodeDir = fs.readdirSync(path.join(basePath, "./node_modules"), { recursive: true, withFileTypes: true }); + //const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true }); + + /** + * Delete unnecessary folders + */ + const filterableDirs = new Set([ + "demo", + "demos", + "doc", + "docs", + "example", + "examples", + "test", + "tests" + ]); + + nodeDir + .filter(el => el.isDirectory() && filterableDirs.has(el.name)) + .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))); + + + /** + * Delete unnecessary files based on file extension + * TODO filter out useless (README).md files + */ + const filterableFileExt = new Set([ + "ts", + "map" + ]); + + nodeDir + // TriliumNextTODO: check if we can improve this naive file ext matching, without introducing any additional dependency + .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) + .forEach(file => fs.removeSync(path.join(file.parentPath, file.name))); + + + /** + * Delete specific unnecessary folders + * TODO: use basePath + * TODO: check if we want removeSync to throw an error, if path does not exist anymore -> currently it will silently fail + */ + const extraFoldersDelete = new Set([ + 'build/node_modules/@excalidraw/excalidraw/dist/dev', + 'build/node_modules/boxicons/svg', + 'build/node_modules/boxicons/node_modules', + 'build/node_modules/boxicons/src', + 'build/node_modules/boxicons/iconjar', + 'build/node_modules/@jimp/plugin-print/fonts', + 'build/node_modules/jimp/dist/browser' + // "node_modules/@excalidraw/excalidraw/dist/dev", + // "node_modules/jimp/browser", + // "node_modules/@jimp/plugin-print/fonts", + // "node_modules/jimp/dist/browser", + // "node_modules/jimp/fonts", + // "node_modules/boxicons/svg", + // "node_modules/boxicons/node_modules/react", + // "node_modules/mermaid/dist/mermaid.js" + ]); + + nodeDir + .filter(el => el.isDirectory() && extraFoldersDelete.has(path.join(el.parentPath, el.name))) + .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))) + +} + +main() \ No newline at end of file diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index 9fb520907..e04edee0c 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -28,6 +28,7 @@ try { "./README.md", "./forge.config.cjs", "./bin/tpl/", + "./bin/cleanupNodeModules.ts", "./bin/electron-forge/desktop.ejs", "./bin/electron-forge/sign-windows.cjs", "./src/views/", @@ -59,46 +60,12 @@ try { console.log("Copying complete!") // TriliumNextTODO: for Docker this needs to run separately *after* build-stage - console.log("Pruning npm packages...") - execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); - - cleanupNodeModules(); + // Disable for now, because this messes with electron-forge as well + //console.log("Pruning npm packages...") + //execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); } catch(err) { console.error("Error during copy:", err) process.exit(1) } -function cleanupNodeModules() { - const nodeDir = fs.readdirSync(path.join(DEST_DIR, "./node_modules"), { recursive: true, withFileTypes: true }); - - const filterableDirs = new Set([ - "demo", - "demos", - "doc", - "docs", - "example", - "examples", - "test", - "tests" - ]); - - nodeDir - .filter(el => el.isDirectory() && filterableDirs.has(el.name)) - .map(el => path.join(DEST_DIR, el.parentPath, el.name)) - .forEach(dir => fs.removeSync(dir)); - - - // Delete unnecessary files based on file extension - const filterableFileExt = new Set([ - "ts", - "map" - ]) - - nodeDir - // TriliumNextTODO: check if we can improve this naive file ext matching - .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) - .map(file => path.join(DEST_DIR, file.parentPath, file.name)) - .forEach(file => fs.removeSync(file)); - -} diff --git a/forge.config.cjs b/forge.config.cjs index 763cb80e8..1a7e5a3c6 100644 --- a/forge.config.cjs +++ b/forge.config.cjs @@ -1,5 +1,6 @@ const path = require("path"); const fs = require("fs-extra"); +const { execSync } = require("child_process"); const APP_NAME = "TriliumNext Notes"; const BIN_PATH = path.normalize("./bin/electron-forge"); @@ -18,8 +19,6 @@ module.exports = { // we run electron-forge inside the ./build folder, // to have it output to ./dist, we need to go up a directory first outDir: "../dist", - // we prune ourselves via copy-dist - prune: false, packagerConfig: { executableName: "trilium", name: APP_NAME, @@ -41,6 +40,22 @@ module.exports = { "translations/", "node_modules/@highlightjs/cdn-assets/styles" ], + afterPrune: [ + (buildPath, _electronVersion, _platform, _arch, callback) => { + // buildPath is a temporary directory that electron-packager creates - it's in the form of + // /tmp/electron-packager/tmp-SjJl0s/resources/app + try { + const cleanupNodeModulesScript = path.join(buildPath, "bin", "cleanupNodeModules.ts"); + // we don't have access to any devDeps like 'tsx' here, so use the built-in '--experimental-strip-types' flag instead + const command = `node --experimental-strip-types ${cleanupNodeModulesScript} '${buildPath}'`; + // execSync throws, if above returns any non-zero exit code + execSync(command); + callback() + } catch(err) { + callback(err) + } + } + ], afterComplete: [ (buildPath, _electronVersion, platform, _arch, callback) => { // Only move resources on non-macOS platforms From 3e3344b3294a6ba70460ee94474a3083d7c130d1 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:03:54 +0100 Subject: [PATCH 18/57] chore(scripts): remove now unneeded electron-forge:prepare --- package.json | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/package.json b/package.json index ec931d8bb..7d998ee90 100644 --- a/package.json +++ b/package.json @@ -38,10 +38,9 @@ "electron:switch": "electron-rebuild", "docs:edit": "cross-env NODE_OPTIONS=\"--import tsx\" TRILIUM_DATA_DIR=./data-docs TRILIUM_ENV=dev TRILIUM_PORT=37741 electron ./electron-docs-main.ts .", "docs:edit-nix": "electron-rebuild --version 33.3.1 && cross-env NODE_OPTIONS=\"--import tsx\" TRILIUM_DATA_DIR=./data-docs TRILIUM_PORT=37741 TRILIUM_ENV=dev nix-shell -p electron_33 --run \"electron ./electron-docs-main.ts .\"", - "electron-forge:prepare": "npm run build:prepare-dist", - "electron-forge:start": "npm run electron-forge:prepare && cd ./build && electron-forge start", - "electron-forge:make": "npm run electron-forge:prepare && cross-env DEBUG=electron-windows-installer:* electron-forge make ./build", - "electron-forge:package": "npm run electron-forge:prepare && cd ./build && electron-forge package", + "electron-forge:start": "npm run build:prepare-dist && cd ./build && electron-forge start", + "electron-forge:make": "npm run build:prepare-dist && cross-env DEBUG=electron-windows-installer:* electron-forge make ./build", + "electron-forge:package": "npm run build:prepare-dist && cd ./build && electron-forge package", "docs:build-backend": "rimraf ./docs/backend_api && typedoc ./docs/backend_api src/becca/entities/*.ts src/services/backend_script_api.ts src/services/sql.ts", "docs:build-frontend": "rimraf ./docs/frontend_api && jsdoc -c jsdoc-conf.json -d ./docs/frontend_api src/public/app/entities/*.js src/public/app/services/frontend_script_api.js src/public/app/widgets/basic_widget.js src/public/app/widgets/note_context_aware_widget.js src/public/app/widgets/right_panel_widget.js", "docs:build": "npm run docs:build-backend && npm run docs:build-frontend", @@ -232,7 +231,6 @@ "lorem-ipsum": "2.0.8", "mind-elixir": "4.4.3", "mini-css-extract-plugin": "2.9.2", - "node-abi": "4.2.0", "nodemon": "3.1.9", "postcss-loader": "8.1.1", "prettier": "3.5.3", From f79b925e490c962296a6521ba0fda09d404471f1 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:18:41 +0100 Subject: [PATCH 19/57] build(server): use cleanupNodeModules script --- bin/build-server.sh | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index fc1807ee0..26dc19ad3 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -25,6 +25,7 @@ NODE_VERSION=22.14.0 BUILD_DIR="./build" DIST_DIR="./dist" +CLEANUP_SCRIPT="./bin/cleanupNodeModules.ts" # Trigger the build @@ -32,7 +33,7 @@ echo "Build start" npm run build:prepare-dist echo "Build finished" -./bin/copy-trilium.sh +node --experimental-strip-types $CLEANUP_SCRIPT $BUILD_DIR NODE_FILENAME=node-v${NODE_VERSION}-linux-${ARCH} From 57ee61938d2abb5f40dd22aa902fcd2bda633fd5 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:19:48 +0100 Subject: [PATCH 20/57] build(copy-trilium): delete now unused script all of its functionality has been "absorbed" by the cross-platform copy-dist and cleanupNodeModules scripts, that can be used for all of our builds now --- bin/copy-trilium.sh | 26 -------------------------- 1 file changed, 26 deletions(-) delete mode 100755 bin/copy-trilium.sh diff --git a/bin/copy-trilium.sh b/bin/copy-trilium.sh deleted file mode 100755 index f6030a6ec..000000000 --- a/bin/copy-trilium.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env bash - -set -e # Fail on any command error -shopt -s globstar - -BUILD_DIR="./build" - -if ! [[ $(which npm) ]]; then - echo "Missing npm" - exit 1 -fi - -if [[ -d "$BUILD_DIR"/node_modules ]]; then - # cleanup of useless files in dependencies - for d in \ - '@excalidraw/excalidraw/dist/dev' \ - 'mermaid/dist/mermaid.js' \ - 'boxicons/svg' 'boxicons/node_modules' 'boxicons/src' 'boxicons/iconjar' \ - '@jimp/plugin-print/fonts' 'jimp/dist/browser'; do - [[ -e "$BUILD_DIR"/node_modules/"$d" ]] && rm -r "$BUILD_DIR"/node_modules/"$d" - done -fi - -find $BUILD_DIR/libraries -name "*.map" -type f -delete - -unset f d BUILD_DIR From 83da24b38d8a23d78ff8f607264390bbb1cd80ae Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Tue, 25 Mar 2025 09:21:40 +0100 Subject: [PATCH 21/57] build(dockerignore): add cleanupNodeModules as exception --- .dockerignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.dockerignore b/.dockerignore index 2ceb847c9..32795ae0a 100644 --- a/.dockerignore +++ b/.dockerignore @@ -35,6 +35,7 @@ npm-debug.log # exceptions !/bin/copy-dist.ts !/bin/electron-forge/sign-windows.cjs +!/bin/cleanupNodeModules.ts # temporary exception to make copy-dist inside Docker build not fail # TriliumNextTODO: make copy-dist *not* requiring to copy this file for builds other than electron-forge From b457fa2e874fafd65e1c539092f8c239c19a74f7 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:12:22 +0100 Subject: [PATCH 22/57] chore(cleanupNodeModules): rename nodeDir to nodeModulesContent --- bin/cleanupNodeModules.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index 2daf7c01b..072214ce9 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -18,7 +18,7 @@ function main() { } function cleanupNodeModules(basePath: string) { - const nodeDir = fs.readdirSync(path.join(basePath, "./node_modules"), { recursive: true, withFileTypes: true }); + const nodeModulesContent = fs.readdirSync(path.join(basePath, "./node_modules"), { recursive: true, withFileTypes: true }); //const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true }); /** @@ -35,7 +35,7 @@ function cleanupNodeModules(basePath: string) { "tests" ]); - nodeDir + nodeModulesContent .filter(el => el.isDirectory() && filterableDirs.has(el.name)) .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))); @@ -49,7 +49,7 @@ function cleanupNodeModules(basePath: string) { "map" ]); - nodeDir + nodeModulesContent // TriliumNextTODO: check if we can improve this naive file ext matching, without introducing any additional dependency .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) .forEach(file => fs.removeSync(path.join(file.parentPath, file.name))); @@ -78,7 +78,7 @@ function cleanupNodeModules(basePath: string) { // "node_modules/mermaid/dist/mermaid.js" ]); - nodeDir + nodeModulesContent .filter(el => el.isDirectory() && extraFoldersDelete.has(path.join(el.parentPath, el.name))) .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))) From 6fe23f9a136713f10c0b0bff541bb173b60cf579 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:15:33 +0100 Subject: [PATCH 23/57] chore(cleanupNodeModules): remove commented out paths extra note on mermaid: that should be packed by webpack now, so we just need to move it to devDeps and and we should be good --- bin/cleanupNodeModules.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index 072214ce9..975b83af3 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -68,14 +68,6 @@ function cleanupNodeModules(basePath: string) { 'build/node_modules/boxicons/iconjar', 'build/node_modules/@jimp/plugin-print/fonts', 'build/node_modules/jimp/dist/browser' - // "node_modules/@excalidraw/excalidraw/dist/dev", - // "node_modules/jimp/browser", - // "node_modules/@jimp/plugin-print/fonts", - // "node_modules/jimp/dist/browser", - // "node_modules/jimp/fonts", - // "node_modules/boxicons/svg", - // "node_modules/boxicons/node_modules/react", - // "node_modules/mermaid/dist/mermaid.js" ]); nodeModulesContent From 1150f78b158b93ac1329b9d35c82ad3537c5facd Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:18:16 +0100 Subject: [PATCH 24/57] build(cleanupNodeModules): use path.join and basePath for extraFoldersDelete --- bin/cleanupNodeModules.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index 975b83af3..2885f1484 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -18,7 +18,8 @@ function main() { } function cleanupNodeModules(basePath: string) { - const nodeModulesContent = fs.readdirSync(path.join(basePath, "./node_modules"), { recursive: true, withFileTypes: true }); + const nodeModulesDirPath = path.join(basePath, "node_modules"); + const nodeModulesContent = fs.readdirSync(nodeModulesDirPath, { recursive: true, withFileTypes: true }); //const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true }); /** @@ -39,7 +40,6 @@ function cleanupNodeModules(basePath: string) { .filter(el => el.isDirectory() && filterableDirs.has(el.name)) .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))); - /** * Delete unnecessary files based on file extension * TODO filter out useless (README).md files @@ -57,17 +57,16 @@ function cleanupNodeModules(basePath: string) { /** * Delete specific unnecessary folders - * TODO: use basePath * TODO: check if we want removeSync to throw an error, if path does not exist anymore -> currently it will silently fail */ const extraFoldersDelete = new Set([ - 'build/node_modules/@excalidraw/excalidraw/dist/dev', - 'build/node_modules/boxicons/svg', - 'build/node_modules/boxicons/node_modules', - 'build/node_modules/boxicons/src', - 'build/node_modules/boxicons/iconjar', - 'build/node_modules/@jimp/plugin-print/fonts', - 'build/node_modules/jimp/dist/browser' + path.join(nodeModulesDirPath, "@excalidraw", "excalidraw", "dist", "dev"), + path.join(nodeModulesDirPath, "boxicons", "svg"), + path.join(nodeModulesDirPath, "boxicons", "node_modules"), + path.join(nodeModulesDirPath, "boxicons", "src"), + path.join(nodeModulesDirPath, "boxicons", "iconjar"), + path.join(nodeModulesDirPath, "@jimp", "plugin-print", "fonts"), + path.join(nodeModulesDirPath, "jimp", "dist", "browser") // missing "@" in front of jimp is not a typo here ]); nodeModulesContent From 1528703ed98a7ce8ab6c259eb9bd0cec8911b84f Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:26:22 +0100 Subject: [PATCH 25/57] build(cleanupNodeModules): add some minimalistic logging --- bin/cleanupNodeModules.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index 2885f1484..e20004747 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -1,6 +1,12 @@ import fs from "fs-extra"; import path from "path"; +/** + * Example usage with node >= v22: + * node --experimental-strip-types bin/cleanupNodeModules.ts /path/to/build/folder + * Example usage with tsx: + * tsx bin/cleanupNodeModules.ts /path/to/build/folder + */ function main() { if (process.argv.length !== 3) { console.error("More than one path was supplied as argument. Aborting."); @@ -13,8 +19,9 @@ function main() { console.error(`Supplied path '${basePath}' does not exist. Aborting.`) process.exit(1); } - + console.log(`Starting node_modules pruning in '${basePath}'...`) cleanupNodeModules(basePath); + console.log("Successfully pruned node_modules.") } function cleanupNodeModules(basePath: string) { From 51f2e23c2f88631a2465de143500d1bbb7367cec Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:28:50 +0100 Subject: [PATCH 26/57] build(cleanupNodeModules): delete .bin folder this is only needed for executing package scripts -> which we don't do in production fixes #1499 --- bin/cleanupNodeModules.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index e20004747..c5df07da9 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -67,6 +67,7 @@ function cleanupNodeModules(basePath: string) { * TODO: check if we want removeSync to throw an error, if path does not exist anymore -> currently it will silently fail */ const extraFoldersDelete = new Set([ + path.join(nodeModulesDirPath, ".bin"), path.join(nodeModulesDirPath, "@excalidraw", "excalidraw", "dist", "dev"), path.join(nodeModulesDirPath, "boxicons", "svg"), path.join(nodeModulesDirPath, "boxicons", "node_modules"), From 0b428035ae0254642b101d0fc402f3e03aa9534a Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Wed, 26 Mar 2025 09:47:06 +0100 Subject: [PATCH 27/57] build(cleanupNodeModules): move removal of elements to its own function also added a logging function for debugging purposes --- bin/cleanupNodeModules.ts | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index c5df07da9..d811c95a1 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -45,7 +45,7 @@ function cleanupNodeModules(basePath: string) { nodeModulesContent .filter(el => el.isDirectory() && filterableDirs.has(el.name)) - .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))); + .forEach(dir => removeDirent(dir)); /** * Delete unnecessary files based on file extension @@ -59,7 +59,7 @@ function cleanupNodeModules(basePath: string) { nodeModulesContent // TriliumNextTODO: check if we can improve this naive file ext matching, without introducing any additional dependency .filter(el => el.isFile() && filterableFileExt.has(el.name.split(".").at(-1) || "")) - .forEach(file => fs.removeSync(path.join(file.parentPath, file.name))); + .forEach(dir => removeDirent(dir)); /** @@ -79,7 +79,17 @@ function cleanupNodeModules(basePath: string) { nodeModulesContent .filter(el => el.isDirectory() && extraFoldersDelete.has(path.join(el.parentPath, el.name))) - .forEach(dir => fs.removeSync(path.join(dir.parentPath, dir.name))) + .forEach(dir => removeDirent(dir)) +} + +function removeDirent(el: Dirent) { + const elementToDelete = path.join(el.parentPath, el.name); + fs.removeSync(elementToDelete); + + if (process.env.VERBOSE) { + console.log(`Deleted ${elementToDelete}`); + } + } From dcd64554ebf37995d692633371c62d7903ce3d1d Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Wed, 26 Mar 2025 19:33:11 +0200 Subject: [PATCH 28/57] style(next): fix Firefox scrollbar styles overriding WebKit scrollbar styles --- src/public/stylesheets/theme-next/forms.css | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/public/stylesheets/theme-next/forms.css b/src/public/stylesheets/theme-next/forms.css index ecab8bdc1..16fec7c1e 100644 --- a/src/public/stylesheets/theme-next/forms.css +++ b/src/public/stylesheets/theme-next/forms.css @@ -730,4 +730,13 @@ input[type="range"] { :root { scrollbar-color: var(--scrollbar-thumb-color) transparent; scrollbar-width: var(--scrollbar-thickness); +} + +@supports selector(::-webkit-scrollbar) { + /* Prevent the scrollbar-color and scrollbar-width properties to override the custom styles + * defined using ::-webkit-scrollbar. */ + :root { + scrollbar-color: unset; + scrollbar-width: unset; + } } \ No newline at end of file From cdcfab10114390a10fbfa12859133c8bc8fc7682 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Wed, 26 Mar 2025 19:47:37 +0200 Subject: [PATCH 29/57] style(next)/scrollbars: tweak size --- src/public/stylesheets/theme-next/forms.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/stylesheets/theme-next/forms.css b/src/public/stylesheets/theme-next/forms.css index 16fec7c1e..1c3945154 100644 --- a/src/public/stylesheets/theme-next/forms.css +++ b/src/public/stylesheets/theme-next/forms.css @@ -668,7 +668,7 @@ input[type="range"] { :root { --scrollbar-thickness: 10px; --scrollbar-thumb-thickness: 3px; - --scrollbar-thumb-hover-thickness: 8px; + --scrollbar-thumb-hover-thickness: 6px; --scrollbar-start-end-gap: 8px; } From 75431ca634860d6b0af15b434b209cc47e81f521 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 00:00:41 +0100 Subject: [PATCH 30/57] build: make running of npm ci in build scripts configurable * moved the running of npm ci from copy-dist to cleanupNodeModules * added flag to disable it (necessary for electron-forge) --- Dockerfile | 1 + Dockerfile.alpine | 5 ++++- bin/build-server.sh | 1 + bin/cleanupNodeModules.ts | 33 +++++++++++++++++++++++---------- bin/copy-dist.ts | 6 ------ forge.config.cjs | 2 +- 6 files changed, 30 insertions(+), 18 deletions(-) diff --git a/Dockerfile b/Dockerfile index 538f3e58f..0ee13f25d 100644 --- a/Dockerfile +++ b/Dockerfile @@ -40,6 +40,7 @@ COPY --from=builder /usr/src/app ./ RUN sed -i "/electron/d" package.json && \ npm ci --omit=dev && \ + node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \ npm cache clean --force && \ rm -rf /tmp/node-compile-cache diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 595d21561..943030943 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -35,8 +35,11 @@ COPY --from=builder /usr/src/app ./ RUN sed -i "/electron/d" package.json && \ npm ci --omit=dev && \ + node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \ npm cache clean --force && \ - rm -rf /tmp/node-compile-cache + rm -rf \ + /tmp/node-compile-cache \ + ./bin/cleanupNodeModules.ts # Add application user RUN adduser -s /bin/false node; exit 0 diff --git a/bin/build-server.sh b/bin/build-server.sh index 26dc19ad3..6677d7c19 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -33,6 +33,7 @@ echo "Build start" npm run build:prepare-dist echo "Build finished" +# pruning of unnecessary files and devDeps in node_modules node --experimental-strip-types $CLEANUP_SCRIPT $BUILD_DIR NODE_FILENAME=node-v${NODE_VERSION}-linux-${ARCH} diff --git a/bin/cleanupNodeModules.ts b/bin/cleanupNodeModules.ts index d811c95a1..bb3e90331 100644 --- a/bin/cleanupNodeModules.ts +++ b/bin/cleanupNodeModules.ts @@ -1,30 +1,43 @@ import fs from "fs-extra"; import path from "path"; +import type { Dirent } from "fs-extra"; +import { execSync } from "node:child_process"; /** * Example usage with node >= v22: - * node --experimental-strip-types bin/cleanupNodeModules.ts /path/to/build/folder + * node --experimental-strip-types bin/cleanupNodeModules.ts /path/to/build/folder [--skip-prune-dev-deps] * Example usage with tsx: - * tsx bin/cleanupNodeModules.ts /path/to/build/folder + * tsx bin/cleanupNodeModules.ts /path/to/build/folder [--skip-prune-dev-deps] */ function main() { - if (process.argv.length !== 3) { - console.error("More than one path was supplied as argument. Aborting."); + + if (process.argv.length > 4 || process.argv.length < 3) { + console.error("Usage: cleanupNodeModules.ts [path-to-build-folder] [--skip-prune-dev-deps]"); process.exit(1); } const basePath = process.argv[2]; + const pruneDevDeps = process.argv[3] !== "--skip-prune-dev-deps"; if (!fs.existsSync(basePath)) { - console.error(`Supplied path '${basePath}' does not exist. Aborting.`) + console.error(`Supplied path '${basePath}' does not exist. Aborting.`); process.exit(1); } - console.log(`Starting node_modules pruning in '${basePath}'...`) - cleanupNodeModules(basePath); - console.log("Successfully pruned node_modules.") + + console.log(`Starting pruning of node_modules ${!pruneDevDeps ? '(skipping npm pruning)' : ''} in '${basePath}'...`); + cleanupNodeModules(basePath, pruneDevDeps); + console.log("Successfully pruned node_modules."); } -function cleanupNodeModules(basePath: string) { +function cleanupNodeModules(basePath: string, pruneDevDeps: boolean = true) { + + // This needs to run for the server and Docker build, + // but needs to be skipped for electron-forge: its + // built-in pruning takes care of it already + if (pruneDevDeps) { + execSync(`npm ci --omit=dev --prefix ${basePath}`); + } + const nodeModulesDirPath = path.join(basePath, "node_modules"); const nodeModulesContent = fs.readdirSync(nodeModulesDirPath, { recursive: true, withFileTypes: true }); //const libDir = fs.readdirSync(path.join(basePath, "./libraries"), { recursive: true, withFileTypes: true }); @@ -82,6 +95,7 @@ function cleanupNodeModules(basePath: string) { .forEach(dir => removeDirent(dir)) } + function removeDirent(el: Dirent) { const elementToDelete = path.join(el.parentPath, el.name); fs.removeSync(elementToDelete); @@ -90,7 +104,6 @@ function removeDirent(el: Dirent) { console.log(`Deleted ${elementToDelete}`); } - } main() \ No newline at end of file diff --git a/bin/copy-dist.ts b/bin/copy-dist.ts index e04edee0c..404cf0991 100644 --- a/bin/copy-dist.ts +++ b/bin/copy-dist.ts @@ -1,6 +1,5 @@ import fs from "fs-extra"; import path from "path"; -import { execSync } from "node:child_process"; const DEST_DIR = "./build"; @@ -59,11 +58,6 @@ try { console.log("Copying complete!") - // TriliumNextTODO: for Docker this needs to run separately *after* build-stage - // Disable for now, because this messes with electron-forge as well - //console.log("Pruning npm packages...") - //execSync(`npm ci --omit=dev --prefix ${DEST_DIR}`); - } catch(err) { console.error("Error during copy:", err) process.exit(1) diff --git a/forge.config.cjs b/forge.config.cjs index 1a7e5a3c6..b94b2756e 100644 --- a/forge.config.cjs +++ b/forge.config.cjs @@ -47,7 +47,7 @@ module.exports = { try { const cleanupNodeModulesScript = path.join(buildPath, "bin", "cleanupNodeModules.ts"); // we don't have access to any devDeps like 'tsx' here, so use the built-in '--experimental-strip-types' flag instead - const command = `node --experimental-strip-types ${cleanupNodeModulesScript} '${buildPath}'`; + const command = `node --experimental-strip-types ${cleanupNodeModulesScript} '${buildPath}' --skip-prune-dev-deps`; // execSync throws, if above returns any non-zero exit code execSync(command); callback() From e9fa37c4eeecdc2fc6fb65d6fdd02774262300cc Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:04:10 +0100 Subject: [PATCH 31/57] chore(docker): remove TODO --- Dockerfile | 1 - Dockerfile.alpine | 1 - 2 files changed, 2 deletions(-) diff --git a/Dockerfile b/Dockerfile index 0ee13f25d..abf8b0920 100644 --- a/Dockerfile +++ b/Dockerfile @@ -18,7 +18,6 @@ RUN npm ci && \ /usr/src/app/build \ /tmp/node-compile-cache -#TODO: run cleanupNodeModules script #TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work # currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down), # as we install necessary dependencies in runtime buildstage anyways diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 943030943..40b00c48f 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -18,7 +18,6 @@ RUN npm ci && \ /usr/src/app/build \ /tmp/node-compile-cache -#TODO: run cleanupNodeModules script #TODO: improve node_modules handling in copy-dist/Dockerfile -> remove duplicated work # currently copy-dist will copy certain node_module folders, but in the Dockerfile we delete them again (to keep image size down), # as we install necessary dependencies in runtime buildstage anyways From d5bc9841e3e9bc76521221638dfa309f93b9ed7a Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:05:17 +0100 Subject: [PATCH 32/57] build(docker): use absolute path to stay consistent --- Dockerfile.alpine | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Dockerfile.alpine b/Dockerfile.alpine index 40b00c48f..88a450723 100644 --- a/Dockerfile.alpine +++ b/Dockerfile.alpine @@ -36,9 +36,9 @@ RUN sed -i "/electron/d" package.json && \ npm ci --omit=dev && \ node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \ npm cache clean --force && \ - rm -rf \ + rm -rf \ /tmp/node-compile-cache \ - ./bin/cleanupNodeModules.ts + /usr/src/app/bin/cleanupNodeModules.ts # Add application user RUN adduser -s /bin/false node; exit 0 From fa0358662a39716eb69178602c1419bb018798d6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:06:09 +0100 Subject: [PATCH 33/57] build(docker): add missing cleanupNodeModules removal to Dockerfile previously forgot to add this here as well -> had it only in the Dockerfile.alpine --- Dockerfile | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Dockerfile b/Dockerfile index abf8b0920..635a44d3b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -41,7 +41,9 @@ RUN sed -i "/electron/d" package.json && \ npm ci --omit=dev && \ node --experimental-strip-types ./bin/cleanupNodeModules.ts . --skip-prune-dev-deps && \ npm cache clean --force && \ - rm -rf /tmp/node-compile-cache + rm -rf \ + /tmp/node-compile-cache \ + /usr/src/app/bin/cleanupNodeModules.ts # Configure container EXPOSE 8080 From 6218ae6cd7a8919db248061a6ead505f2acd72b3 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:07:29 +0100 Subject: [PATCH 34/57] chore(docker): move exception below TODO comment --- .dockerignore | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.dockerignore b/.dockerignore index 32795ae0a..1ca391a43 100644 --- a/.dockerignore +++ b/.dockerignore @@ -34,11 +34,11 @@ npm-debug.log # exceptions !/bin/copy-dist.ts -!/bin/electron-forge/sign-windows.cjs !/bin/cleanupNodeModules.ts # temporary exception to make copy-dist inside Docker build not fail -# TriliumNextTODO: make copy-dist *not* requiring to copy this file for builds other than electron-forge +# TriliumNextTODO: make copy-dist *not* requiring to copy these file for builds other than electron-forge !forge.config.cjs !/bin/tpl -!/bin/electron-forge/desktop.ejs \ No newline at end of file +!/bin/electron-forge/desktop.ejs +!/bin/electron-forge/sign-windows.cjs \ No newline at end of file From 9fe37465c73ef9675b3e3168f0e53d22116d2fb3 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 09:35:48 +0100 Subject: [PATCH 35/57] build(electron-forge): use double quotes for the buildPath in afterPrune attempt to fix failing Windows build in CI, which uses cmd shell, which apparently treats single apostrophes differently --- forge.config.cjs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/forge.config.cjs b/forge.config.cjs index b94b2756e..8d5b5d22e 100644 --- a/forge.config.cjs +++ b/forge.config.cjs @@ -47,7 +47,7 @@ module.exports = { try { const cleanupNodeModulesScript = path.join(buildPath, "bin", "cleanupNodeModules.ts"); // we don't have access to any devDeps like 'tsx' here, so use the built-in '--experimental-strip-types' flag instead - const command = `node --experimental-strip-types ${cleanupNodeModulesScript} '${buildPath}' --skip-prune-dev-deps`; + const command = `node --experimental-strip-types ${cleanupNodeModulesScript} "${buildPath}" --skip-prune-dev-deps`; // execSync throws, if above returns any non-zero exit code execSync(command); callback() From a7d6f1e4d1cd966b751e998c26c7d54483aeef1c Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 27 Mar 2025 12:50:39 +0100 Subject: [PATCH 36/57] README.md: TriliumDroid link, documentation update --- README.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 0170c8135..aed59f2a7 100644 --- a/README.md +++ b/README.md @@ -79,10 +79,11 @@ xattr -c "/path/to/Trilium Next.app" ### Mobile -To use TriliumNext on a mobile device: +To use TriliumNext on a mobile device, you can use a mobile web browser to access the mobile interface of a server installation (see below). -* Use a mobile web browser to access the mobile interface of a server installation (see below) -* Use of a mobile app is not yet supported ([see here](https://github.com/TriliumNext/Notes/issues/72)) to track mobile improvements. +If you prefer a native Android app, you can use [TriliumDroid](https://apt.izzysoft.de/fdroid/index/apk/eu.fliegendewurst.triliumdroid). Report bugs and missing features at [their repository](https://github.com/FliegendeWurst/TriliumDroid). + +See issue https://github.com/TriliumNext/Notes/issues/72 for more information on mobile app support. ### Server @@ -107,7 +108,7 @@ npm run server:start ### Documentation -Head on over to our [Docs repo](https://github.com/TriliumNext/Docs) +We are currently transitioning to a new documentation mechanism, please check back later. ## 👏 Shoutouts From 8c4e504cd4448d5c95e9b65c51613408d029ff34 Mon Sep 17 00:00:00 2001 From: Arne Keller Date: Thu, 27 Mar 2025 14:23:55 +0100 Subject: [PATCH 37/57] README.md: link to old docs --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index aed59f2a7..428e832fa 100644 --- a/README.md +++ b/README.md @@ -108,7 +108,8 @@ npm run server:start ### Documentation -We are currently transitioning to a new documentation mechanism, please check back later. +We are currently transitioning to a new documentation mechanism. +Meanwhile you can still view the [archived Docs repository](https://github.com/TriliumNext/Docs). ## 👏 Shoutouts From 99bdf332365528ed13733fcccdb97778dadcc8d2 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 15:41:24 +0200 Subject: [PATCH 38/57] style(next): fix scrollbar appearance in code blocks --- src/public/stylesheets/theme-next/notes/text.css | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/public/stylesheets/theme-next/notes/text.css b/src/public/stylesheets/theme-next/notes/text.css index cf8aa4760..ac712c251 100644 --- a/src/public/stylesheets/theme-next/notes/text.css +++ b/src/public/stylesheets/theme-next/notes/text.css @@ -42,14 +42,9 @@ html .note-detail-editable-text :not(figure, .include-note, hr):first-child { overflow: auto; } -.ck-content pre code::-webkit-scrollbar { - height: 6px; -} - -.ck-content pre code::-webkit-scrollbar-thumb { - height: 4px; - border: none !important; - background: gray !important; +.ck-content pre code { + --scrollbar-thumb-color: gray; + --scrollbar-thumb-color-hover: gray; } .ck-content pre code::-webkit-scrollbar-track, From 4ab70fcb8add5672e8e9912926f2408b5559ae01 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 15:43:33 +0200 Subject: [PATCH 39/57] style(next): rename CSS variable --- src/public/stylesheets/theme-next-dark.css | 2 +- src/public/stylesheets/theme-next-light.css | 2 +- src/public/stylesheets/theme-next/forms.css | 4 ++-- src/public/stylesheets/theme-next/notes/text.css | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/public/stylesheets/theme-next-dark.css b/src/public/stylesheets/theme-next-dark.css index 84a0e0eb9..40740acd8 100644 --- a/src/public/stylesheets/theme-next-dark.css +++ b/src/public/stylesheets/theme-next-dark.css @@ -191,7 +191,7 @@ --right-pane-item-hover-color: white; --scrollbar-thumb-color: #fdfdfd5c; - --scrollbar-thumb-color-hover: #ffffff7d; + --scrollbar-thumb-hover-color: #ffffff7d; --scrollbar-border-color: unset; /* Deprecated */ --scrollbar-background-color: unset; /* Deprecated */ diff --git a/src/public/stylesheets/theme-next-light.css b/src/public/stylesheets/theme-next-light.css index 781a34a2b..3bfe849ee 100644 --- a/src/public/stylesheets/theme-next-light.css +++ b/src/public/stylesheets/theme-next-light.css @@ -190,7 +190,7 @@ --right-pane-item-hover-color: inherit; --scrollbar-thumb-color: #0000005c; - --scrollbar-thumb-color-hover: #00000066; + --scrollbar-thumb-hover-color: #00000066; --scrollbar-border-color: unset; /* Deprecated */ --scrollbar-background-color: unset; /* Deprecated */ diff --git a/src/public/stylesheets/theme-next/forms.css b/src/public/stylesheets/theme-next/forms.css index 1c3945154..09dc1408c 100644 --- a/src/public/stylesheets/theme-next/forms.css +++ b/src/public/stylesheets/theme-next/forms.css @@ -707,7 +707,7 @@ input[type="range"] { ::-webkit-scrollbar-thumb:hover { --s-thumb-thickness: var(--scrollbar-thumb-hover-thickness); - --s-thumb-color: var(--scrollbar-thumb-color-hover); + --s-thumb-color: var(--scrollbar-thumb-hover-color); } /* Scrollbar's increment/decrement buttons (repurposed as a scrollbar start/end gap) */ @@ -724,7 +724,7 @@ input[type="range"] { * Firefox scrollbars * * Unsupported features: --scrollbar-thumb-thickness, --scrollbar-thumb-hover-thickness, - * --scrollbar-start-end-gap, --scrollbar-thumb-color-hover. + * --scrollbar-start-end-gap, --scrollbar-thumb-hover-color. */ :root { diff --git a/src/public/stylesheets/theme-next/notes/text.css b/src/public/stylesheets/theme-next/notes/text.css index ac712c251..9d1c20e88 100644 --- a/src/public/stylesheets/theme-next/notes/text.css +++ b/src/public/stylesheets/theme-next/notes/text.css @@ -44,7 +44,7 @@ html .note-detail-editable-text :not(figure, .include-note, hr):first-child { .ck-content pre code { --scrollbar-thumb-color: gray; - --scrollbar-thumb-color-hover: gray; + --scrollbar-thumb-hover-color: gray; } .ck-content pre code::-webkit-scrollbar-track, From 10ea58a3686a97eccde50a9ff40bed631e6e6217 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 16:06:53 +0200 Subject: [PATCH 40/57] style(next)/scrollbars: restore the support for custom background color --- src/public/stylesheets/theme-next-dark.css | 2 +- src/public/stylesheets/theme-next-light.css | 2 +- src/public/stylesheets/theme-next/forms.css | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/public/stylesheets/theme-next-dark.css b/src/public/stylesheets/theme-next-dark.css index 40740acd8..2dbeb525c 100644 --- a/src/public/stylesheets/theme-next-dark.css +++ b/src/public/stylesheets/theme-next-dark.css @@ -192,8 +192,8 @@ --scrollbar-thumb-color: #fdfdfd5c; --scrollbar-thumb-hover-color: #ffffff7d; + --scrollbar-background-color: transparent; --scrollbar-border-color: unset; /* Deprecated */ - --scrollbar-background-color: unset; /* Deprecated */ --link-color: lightskyblue; diff --git a/src/public/stylesheets/theme-next-light.css b/src/public/stylesheets/theme-next-light.css index 3bfe849ee..46c116e39 100644 --- a/src/public/stylesheets/theme-next-light.css +++ b/src/public/stylesheets/theme-next-light.css @@ -191,8 +191,8 @@ --scrollbar-thumb-color: #0000005c; --scrollbar-thumb-hover-color: #00000066; + --scrollbar-background-color: transparent; --scrollbar-border-color: unset; /* Deprecated */ - --scrollbar-background-color: unset; /* Deprecated */ --link-color: blue; diff --git a/src/public/stylesheets/theme-next/forms.css b/src/public/stylesheets/theme-next/forms.css index 09dc1408c..ce6663380 100644 --- a/src/public/stylesheets/theme-next/forms.css +++ b/src/public/stylesheets/theme-next/forms.css @@ -674,6 +674,10 @@ input[type="range"] { /* Scrollbar's body */ +::-webkit-scrollbar-track { + background-color: var(--scrollbar-background-color); +} + ::-webkit-scrollbar:vertical { width: var(--scrollbar-thickness) !important; } From 25d83752e54cad5171fad50eb8688c500c927420 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 16:08:34 +0200 Subject: [PATCH 41/57] style(next): refactor --- src/public/stylesheets/theme-next/base.css | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/public/stylesheets/theme-next/base.css b/src/public/stylesheets/theme-next/base.css index 888b83ca9..aced7ab5d 100644 --- a/src/public/stylesheets/theme-next/base.css +++ b/src/public/stylesheets/theme-next/base.css @@ -95,8 +95,8 @@ font-size: 0.9rem !important; } -.dropdown-menu::-webkit-scrollbar-track { - background: var(--menu-background-color); +.dropdown-menu { + --scrollbar-background-color: var(--menu-background-color); } body.mobile .dropdown-menu { From 66cebf4ebfc8f6b7945b167ac1d0bec274f2c2b9 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 16:12:51 +0200 Subject: [PATCH 42/57] style(next)/scrollbars: add a remark --- src/public/stylesheets/theme-next/forms.css | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/public/stylesheets/theme-next/forms.css b/src/public/stylesheets/theme-next/forms.css index ce6663380..30e8eec22 100644 --- a/src/public/stylesheets/theme-next/forms.css +++ b/src/public/stylesheets/theme-next/forms.css @@ -714,7 +714,9 @@ input[type="range"] { --s-thumb-color: var(--scrollbar-thumb-hover-color); } -/* Scrollbar's increment/decrement buttons (repurposed as a scrollbar start/end gap) */ +/* Scrollbar's increment/decrement buttons (repurposed as a scrollbar start/end gap). + * This gap is useful also to avoid breaking the rounded corners of a container when a + * custom scrollbar background color is used. */ ::-webkit-scrollbar-button:vertical { height: var(--scrollbar-start-end-gap); From b9c4d8322360f7260fa68eb0700925a54090dd9b Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 18:26:21 +0200 Subject: [PATCH 43/57] style(next): improve the window dragging functionality for the horizontal toolbar layout --- src/public/stylesheets/theme-next/shell.css | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index 11958d494..446b5466c 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -895,6 +895,11 @@ body.layout-vertical.electron.platform-darwin .tab-row-container { body.layout-horizontal .tab-row-container { padding-top: calc((var(--tab-bar-height) - var(--tab-height))); + -webkit-app-region: drag; +} + +body.layout-horizontal .tab-row-container > * { + -webkit-app-region: no-drag; /* Limit the drag area only for the parent element */ } body.layout-horizontal .tab-row-widget-container { From b6565c3b13711422b96e86781ef471bc74c9cab9 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 18:40:49 +0200 Subject: [PATCH 44/57] style(next): improve the window dragging functionality also for the vertical toolbar layout --- src/public/stylesheets/theme-next/shell.css | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index 446b5466c..85b15557c 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -895,13 +895,20 @@ body.layout-vertical.electron.platform-darwin .tab-row-container { body.layout-horizontal .tab-row-container { padding-top: calc((var(--tab-bar-height) - var(--tab-height))); +} + +body.layout-horizontal .tab-row-container, +body.layout-vertical .tab-row-widget { -webkit-app-region: drag; } -body.layout-horizontal .tab-row-container > * { +body.layout-horizontal .tab-row-container > *, +body.layout-vertical .tab-row-widget > * { -webkit-app-region: no-drag; /* Limit the drag area only for the parent element */ } + + body.layout-horizontal .tab-row-widget-container { margin-top: 0; position: relative; From 63efa8ffe48fac8b994218ca355f13ab589309d8 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 18:46:03 +0200 Subject: [PATCH 45/57] style(next): improve the window dragging functionality for the vertical toolbar layout --- src/public/stylesheets/theme-next/shell.css | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index 85b15557c..dbb0fd354 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -898,12 +898,14 @@ body.layout-horizontal .tab-row-container { } body.layout-horizontal .tab-row-container, -body.layout-vertical .tab-row-widget { +body.layout-vertical .tab-row-widget, +body.layout-vertical #left-pane .quick-search { -webkit-app-region: drag; } body.layout-horizontal .tab-row-container > *, -body.layout-vertical .tab-row-widget > * { +body.layout-vertical .tab-row-widget > *, +body.layout-vertical #left-pane .quick-search > * { -webkit-app-region: no-drag; /* Limit the drag area only for the parent element */ } From 04a41ca5f492809b78feb9ffe43660579b4af734 Mon Sep 17 00:00:00 2001 From: Adorian Doran Date: Thu, 27 Mar 2025 18:50:26 +0200 Subject: [PATCH 46/57] style(next): add some remarks --- src/public/stylesheets/theme-next/shell.css | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index dbb0fd354..3183f3ea3 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -897,20 +897,21 @@ body.layout-horizontal .tab-row-container { padding-top: calc((var(--tab-bar-height) - var(--tab-height))); } +/* Define extra drag areas for Electron windows */ body.layout-horizontal .tab-row-container, body.layout-vertical .tab-row-widget, body.layout-vertical #left-pane .quick-search { -webkit-app-region: drag; } +/* Limit the drag area for the previous elements to include just to the element itself + and not its descendants also */ body.layout-horizontal .tab-row-container > *, body.layout-vertical .tab-row-widget > *, body.layout-vertical #left-pane .quick-search > * { - -webkit-app-region: no-drag; /* Limit the drag area only for the parent element */ + -webkit-app-region: no-drag; } - - body.layout-horizontal .tab-row-widget-container { margin-top: 0; position: relative; From cbf3ee9f6e957086134a464eeed46a3809f19058 Mon Sep 17 00:00:00 2001 From: --global Date: Thu, 27 Mar 2025 19:03:44 +0200 Subject: [PATCH 47/57] fix(ci): bring back ref name in artifact (fixes #1532) --- .github/actions/build-electron/action.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/actions/build-electron/action.yml b/.github/actions/build-electron/action.yml index 6c1b6d819..ccd7f93ff 100644 --- a/.github/actions/build-electron/action.yml +++ b/.github/actions/build-electron/action.yml @@ -81,7 +81,7 @@ runs: APPLE_ID: ${{ env.APPLE_ID }} APPLE_ID_PASSWORD: ${{ env.APPLE_ID_PASSWORD }} WINDOWS_SIGN_EXECUTABLE: ${{ env.WINDOWS_SIGN_EXECUTABLE }} - TRILIUM_ARTIFACT_NAME_HINT: TriliumNextNotes ${{ inputs.os }} ${{ inputs.arch }} + TRILIUM_ARTIFACT_NAME_HINT: TriliumNextNotes-${{ github.ref_name }}-${{ inputs.os }}-${{ inputs.arch }} run: | npm run electron-forge:make -- \ --arch=${{ inputs.arch }} \ From 1b6ab7e7f29a3bc88aff256148ee6d1596264221 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 27 Mar 2025 19:36:45 +0200 Subject: [PATCH 48/57] fix(dropdowns): overlap with quick search results --- src/public/stylesheets/style.css | 1 + 1 file changed, 1 insertion(+) diff --git a/src/public/stylesheets/style.css b/src/public/stylesheets/style.css index 1cfcd6c90..c6ae45c3a 100644 --- a/src/public/stylesheets/style.css +++ b/src/public/stylesheets/style.css @@ -307,6 +307,7 @@ button kbd { background-color: var(--menu-background-color) !important; user-select: none; -webkit-user-select: none; + --bs-dropdown-zindex: 999; } body.desktop .dropdown-menu { From 91242b6cab9d0b3c90e052054978bfca3accfdf6 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Thu, 27 Mar 2025 19:55:06 +0200 Subject: [PATCH 49/57] fix(next): regression in mica dark --- src/public/stylesheets/theme-next/shell.css | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/public/stylesheets/theme-next/shell.css b/src/public/stylesheets/theme-next/shell.css index 3183f3ea3..5552e482d 100644 --- a/src/public/stylesheets/theme-next/shell.css +++ b/src/public/stylesheets/theme-next/shell.css @@ -46,7 +46,7 @@ body.background-effects.platform-win32 { } @media (prefers-color-scheme: dark) { - body.background-effects.platform-win32 #launcher-pane { + body.background-effects.platform-win32 { --launcher-pane-horiz-border-color: rgba(0, 0, 0, 0.5); --launcher-pane-horiz-background-color: rgba(255, 255, 255, 0.09); } From 6336699618fa99a19ff9117094bd74bd71d6e56a Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 21:06:35 +0100 Subject: [PATCH 50/57] build(server): improve "node" folder cleanup * remove useless symlinks to non-existing files (npm, npx -> the actual file gets deleted by "rm -r $BUILD_DIR/node/lib/node_modules/npm" => fixes #1499 (this time fully ;-)) * remove unused corepack * remove useless CHANGELOG.md (LICENSE and README.md should of course still remain) --- bin/build-server.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/bin/build-server.sh b/bin/build-server.sh index 6677d7c19..e89c72d5a 100755 --- a/bin/build-server.sh +++ b/bin/build-server.sh @@ -45,7 +45,9 @@ mv $NODE_FILENAME node cd .. -rm -r $BUILD_DIR/node/lib/node_modules/npm \ +rm -r $BUILD_DIR/node/lib/node_modules/{npm,corepack} \ + $BUILD_DIR/node/bin/{npm,npx,corepack} \ + $BUILD_DIR/node/CHANGELOG.md \ $BUILD_DIR/node/include/node \ $BUILD_DIR/node_modules/electron* \ $BUILD_DIR/electron*.{js,map} From 1c04aa99634d11d2e6dfffcaf55fc5a39ee2b6a6 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Sun, 2 Mar 2025 23:00:15 +0100 Subject: [PATCH 51/57] chore: add dprint config add initial dprint configuration, settings partially taken from the prettier config, still might need some finetuning --- .dprint.json | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 .dprint.json diff --git a/.dprint.json b/.dprint.json new file mode 100644 index 000000000..21e6f8585 --- /dev/null +++ b/.dprint.json @@ -0,0 +1,44 @@ +{ + "typescript": { + "indentWidth": 4, + "quoteStyle": "preferDouble", + "semiColons": "prefer", + "quoteProps": "asNeeded", + "newLineKind": "lf", + "lineWidth": 200, + "trailingCommas": "never", + "arrayPattern.spaceAround": true, + "arrayExpression.spaceAround": true + }, + "json": { + }, + "markdown": { + }, + "dockerfile": { + }, + "malva": { + }, + "markup": { + }, + "yaml": { + }, + "excludes": [ + "**/node_modules", + "**/*-lock.json", + "*.html", + "*.md", + "*.yml", + "libraries/*", + "docs/*", + "src/public/app/doc_notes" + ], + "plugins": [ + "https://plugins.dprint.dev/typescript-0.94.0.wasm", + "https://plugins.dprint.dev/json-0.20.0.wasm", + "https://plugins.dprint.dev/markdown-0.18.0.wasm", + "https://plugins.dprint.dev/dockerfile-0.3.2.wasm", + "https://plugins.dprint.dev/g-plane/malva-v0.11.1.wasm", + "https://plugins.dprint.dev/g-plane/markup_fmt-v0.19.0.wasm", + "https://plugins.dprint.dev/g-plane/pretty_yaml-v0.5.0.wasm" + ] +} From f965be9f8f77a38fb32eca7a17f4b1c8782500e1 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 21:24:51 +0100 Subject: [PATCH 52/57] deps: add dprint as devDep --- package-lock.json | 163 ++++++++++++++++++++++++++++++++++++++++++---- package.json | 1 + 2 files changed, 150 insertions(+), 14 deletions(-) diff --git a/package-lock.json b/package-lock.json index b8c7e54aa..b68b7c5d6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -164,6 +164,7 @@ "bootstrap": "5.3.3", "cross-env": "7.0.3", "css-loader": "7.1.2", + "dprint": "0.49.1", "electron": "35.0.3", "eslint": "9.23.0", "esm": "3.2.25", @@ -175,7 +176,6 @@ "lorem-ipsum": "2.0.8", "mind-elixir": "4.4.3", "mini-css-extract-plugin": "2.9.2", - "node-abi": "4.2.0", "nodemon": "3.1.9", "postcss-loader": "8.1.1", "prettier": "3.5.3", @@ -568,6 +568,132 @@ "node": ">=14.17.0" } }, + "node_modules/@dprint/darwin-arm64": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/darwin-arm64/-/darwin-arm64-0.49.1.tgz", + "integrity": "sha512-ib6KcJWo/M5RJWXOQKhP664FG1hAvG7nrbkh+j8n+oXdzmbyDdXTP+zW+aM3/sIQUkGaZky1xy1j2VeScMEEHQ==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@dprint/darwin-x64": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/darwin-x64/-/darwin-x64-0.49.1.tgz", + "integrity": "sha512-vIVgnYxV7YYa1d6Uyz707RbgB9rwefGPam+rzaueFNPQjdOxPOTQDuMEJDS+Z3BlI00MfeoupIfIUGsXoM4dpQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "darwin" + ] + }, + "node_modules/@dprint/linux-arm64-glibc": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-glibc/-/linux-arm64-glibc-0.49.1.tgz", + "integrity": "sha512-ZeIh6qMPWLBBifDtU0XadpK36b4WoaTqCOt0rWKfoTjq1RAt78EgqETWp43Dbr6et/HvTgYdoWF0ZNEu2FJFFA==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/linux-arm64-musl": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-arm64-musl/-/linux-arm64-musl-0.49.1.tgz", + "integrity": "sha512-/nuRyx+TykN6MqhlSCRs/t3o1XXlikiwTc9emWdzMeLGllYvJrcht9gRJ1/q1SqwCFhzgnD9H7roxxfji1tc+Q==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/linux-riscv64-glibc": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-riscv64-glibc/-/linux-riscv64-glibc-0.49.1.tgz", + "integrity": "sha512-RHBqrnvGO+xW4Oh0QuToBqWtkXMcfjqa1TqbBFF03yopFzZA2oRKX83PhjTWgd/IglaOns0BgmaLJy/JBSxOfQ==", + "cpu": [ + "riscv64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/linux-x64-glibc": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-x64-glibc/-/linux-x64-glibc-0.49.1.tgz", + "integrity": "sha512-MjFE894mIQXOKBencuakKyzAI4KcDe/p0Y9lRp9YSw/FneR4QWH9VBH90h8fRxcIlWMArjFFJJAtsBnn5qgxeg==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/linux-x64-musl": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/linux-x64-musl/-/linux-x64-musl-0.49.1.tgz", + "integrity": "sha512-CvGBWOksHgrL1uzYqtPFvZz0+E82BzgoCIEHJeuYaveEn37qWZS5jqoCm/vz6BfoivE1dVuyyOT78Begj9KxkQ==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "linux" + ] + }, + "node_modules/@dprint/win32-arm64": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/win32-arm64/-/win32-arm64-0.49.1.tgz", + "integrity": "sha512-gQa4s82lMcXjfdxjWBQun6IJlXdPZZaIj2/2cqXWVEOYPKxAZ/JvGzt2pPG+i73h9KHjNLIV8M9ckqEH3oHufg==", + "cpu": [ + "arm64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, + "node_modules/@dprint/win32-x64": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/@dprint/win32-x64/-/win32-x64-0.49.1.tgz", + "integrity": "sha512-nPU6+hoVze5JJlgET7woYWElBw0IUaB/9XKTaglknQuUUfsmD75D9pkgJTxdIxl9Bg/i5O7c9wb3Nj4XNiTIfw==", + "cpu": [ + "x64" + ], + "dev": true, + "license": "MIT", + "optional": true, + "os": [ + "win32" + ] + }, "node_modules/@electron-forge/cli": { "version": "7.8.0", "resolved": "https://registry.npmjs.org/@electron-forge/cli/-/cli-7.8.0.tgz", @@ -10087,6 +10213,28 @@ "url": "https://github.com/fb55/domutils?sponsor=1" } }, + "node_modules/dprint": { + "version": "0.49.1", + "resolved": "https://registry.npmjs.org/dprint/-/dprint-0.49.1.tgz", + "integrity": "sha512-pO9XH79SyXybj2Vhc9ITZMEI8cJkdlQQRoD8oEfPH6Jjpp/7WX5kIgECVd3DBOjjAdCSiW6R47v3gJBx/qZVkw==", + "dev": true, + "hasInstallScript": true, + "license": "MIT", + "bin": { + "dprint": "bin.js" + }, + "optionalDependencies": { + "@dprint/darwin-arm64": "0.49.1", + "@dprint/darwin-x64": "0.49.1", + "@dprint/linux-arm64-glibc": "0.49.1", + "@dprint/linux-arm64-musl": "0.49.1", + "@dprint/linux-riscv64-glibc": "0.49.1", + "@dprint/linux-x64-glibc": "0.49.1", + "@dprint/linux-x64-musl": "0.49.1", + "@dprint/win32-arm64": "0.49.1", + "@dprint/win32-x64": "0.49.1" + } + }, "node_modules/draggabilly": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/draggabilly/-/draggabilly-3.0.0.tgz", @@ -15977,19 +16125,6 @@ "dev": true, "license": "MIT" }, - "node_modules/node-abi": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/node-abi/-/node-abi-4.2.0.tgz", - "integrity": "sha512-admQxilhDcmFJbUl4LQzGu+QyEijW9rctKRH2P7LNavAvln1bdK9OcujM3yi2KysKI41dxTrDtp6QfGEZeCbkg==", - "dev": true, - "license": "MIT", - "dependencies": { - "semver": "^7.6.3" - }, - "engines": { - "node": ">=22.12.0" - } - }, "node_modules/node-addon-api": { "version": "7.1.1", "resolved": "https://registry.npmjs.org/node-addon-api/-/node-addon-api-7.1.1.tgz", diff --git a/package.json b/package.json index 57141ffa8..55ea7a87d 100644 --- a/package.json +++ b/package.json @@ -220,6 +220,7 @@ "bootstrap": "5.3.3", "cross-env": "7.0.3", "css-loader": "7.1.2", + "dprint": "0.49.1", "electron": "35.0.3", "eslint": "9.23.0", "esm": "3.2.25", From cdc6ce2118ffd72b0aeef35144159c93d6cd9bcb Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 21:26:39 +0100 Subject: [PATCH 53/57] chore: remove prettier replaced by dprint due to its configurability --- .prettierignore | 6 ------ .prettierrc | 22 ---------------------- package-lock.json | 17 ----------------- package.json | 1 - 4 files changed, 46 deletions(-) delete mode 100644 .prettierignore delete mode 100644 .prettierrc diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 5e1d8fad5..000000000 --- a/.prettierignore +++ /dev/null @@ -1,6 +0,0 @@ -*.html -*.md -*.yml -libraries/* -docs/* -src/public/app/doc_notes/**/* \ No newline at end of file diff --git a/.prettierrc b/.prettierrc deleted file mode 100644 index 036c81de1..000000000 --- a/.prettierrc +++ /dev/null @@ -1,22 +0,0 @@ -{ - "printWidth": 200, - "tabWidth": 4, - "useTabs": false, - "semi": true, - "singleQuote": false, - "quoteProps": "as-needed", - "trailingComma": "none", - "bracketSpacing": true, - "arrowParens": "always", - "proseWrap": "preserve", - "htmlWhitespaceSensitivity": "css", - "endOfLine": "lf", - "overrides": [ - { - "files": ["*.json"], - "options": { - "tabWidth": 2 - } - } - ] -} diff --git a/package-lock.json b/package-lock.json index b68b7c5d6..1d6021055 100644 --- a/package-lock.json +++ b/package-lock.json @@ -178,7 +178,6 @@ "mini-css-extract-plugin": "2.9.2", "nodemon": "3.1.9", "postcss-loader": "8.1.1", - "prettier": "3.5.3", "rcedit": "4.0.1", "rimraf": "6.0.1", "sass": "1.86.0", @@ -17535,22 +17534,6 @@ "node": ">= 0.8.0" } }, - "node_modules/prettier": { - "version": "3.5.3", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-3.5.3.tgz", - "integrity": "sha512-QQtaxnoDJeAkDvDKWCLiwIXkTgRhwYDEQCghU9Z6q03iyek/rxRh/2lC3HB7P8sWT2xC/y5JDctPLBIGzHKbhw==", - "dev": true, - "license": "MIT", - "bin": { - "prettier": "bin/prettier.cjs" - }, - "engines": { - "node": ">=14" - }, - "funding": { - "url": "https://github.com/prettier/prettier?sponsor=1" - } - }, "node_modules/proc-log": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/proc-log/-/proc-log-2.0.1.tgz", diff --git a/package.json b/package.json index 55ea7a87d..7a31dbe84 100644 --- a/package.json +++ b/package.json @@ -234,7 +234,6 @@ "mini-css-extract-plugin": "2.9.2", "nodemon": "3.1.9", "postcss-loader": "8.1.1", - "prettier": "3.5.3", "rcedit": "4.0.1", "rimraf": "6.0.1", "sass": "1.86.0", From e95172e2db4f9366514d69513730a646ed782f88 Mon Sep 17 00:00:00 2001 From: Panagiotis Papadopoulos Date: Thu, 27 Mar 2025 21:29:18 +0100 Subject: [PATCH 54/57] build(scripts): replace prettier with dprint also renaming the script from "dev:prettier" to a more "generic" term "dev:format" --- package.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/package.json b/package.json index 7a31dbe84..7ef7a8055 100644 --- a/package.json +++ b/package.json @@ -58,8 +58,8 @@ "test:integration-mem-db": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", "test:integration-mem-db-dev": "cross-env TRILIUM_INTEGRATION_TEST=memory TRILIUM_PORT=8082 TRILIUM_ENV=dev TRILIUM_DATA_DIR=./integration-tests/db nodemon src/main.ts", "dev:watch-dist": "tsx ./bin/watch-dist.ts", - "dev:prettier-check": "prettier . --check", - "dev:prettier-fix": "prettier . --write", + "dev:format-check": "dprint check", + "dev:format-fix": "dprint fmt", "dev:linter-check": "eslint .", "dev:linter-fix": "eslint . --fix", "chore:update-build-info": "tsx bin/update-build-info.ts", From 9fe40e2ce6bb52f31b462c8a77bc7e8b557027eb Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 28 Mar 2025 02:43:19 +0000 Subject: [PATCH 55/57] chore(deps): update dependency electron to v35.1.2 --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index 1d6021055..ceb292d7e 100644 --- a/package-lock.json +++ b/package-lock.json @@ -165,7 +165,7 @@ "cross-env": "7.0.3", "css-loader": "7.1.2", "dprint": "0.49.1", - "electron": "35.0.3", + "electron": "35.1.2", "eslint": "9.23.0", "esm": "3.2.25", "globals": "16.0.0", @@ -10299,9 +10299,9 @@ } }, "node_modules/electron": { - "version": "35.0.3", - "resolved": "https://registry.npmjs.org/electron/-/electron-35.0.3.tgz", - "integrity": "sha512-kjQAYEWXSr2TyK19IZoF85dzFIBaYuX7Yp/C+34b5Y/jmI2z270CGie+RjmEGMMitsy0G8YJKftukhYMuWlK6g==", + "version": "35.1.2", + "resolved": "https://registry.npmjs.org/electron/-/electron-35.1.2.tgz", + "integrity": "sha512-ipYSDZEV3+PpHfJ8/oWlpMCvxwutX6xLvBz2HRPgEzSFzgLmGO7YXTjEow4DhDtCpGE+b95NTGoJaRAVQi5n7A==", "hasInstallScript": true, "license": "MIT", "dependencies": { diff --git a/package.json b/package.json index 7ef7a8055..b913a5b09 100644 --- a/package.json +++ b/package.json @@ -221,7 +221,7 @@ "cross-env": "7.0.3", "css-loader": "7.1.2", "dprint": "0.49.1", - "electron": "35.0.3", + "electron": "35.1.2", "eslint": "9.23.0", "esm": "3.2.25", "globals": "16.0.0", From def9bbeac75a93ec1c7181e83ef4ac1a5db3f703 Mon Sep 17 00:00:00 2001 From: "renovate[bot]" <29139614+renovate[bot]@users.noreply.github.com> Date: Fri, 28 Mar 2025 02:43:35 +0000 Subject: [PATCH 56/57] fix(deps): update dependency mime-types to v3 --- dump-db/package-lock.json | 30 ++++----- dump-db/package.json | 2 +- package-lock.json | 125 +++++++++++++++++++++++++++++++++++--- package.json | 2 +- 4 files changed, 134 insertions(+), 25 deletions(-) diff --git a/dump-db/package-lock.json b/dump-db/package-lock.json index 793a7071a..487116431 100644 --- a/dump-db/package-lock.json +++ b/dump-db/package-lock.json @@ -10,7 +10,7 @@ "license": "ISC", "dependencies": { "better-sqlite3": "^11.1.2", - "mime-types": "^2.1.34", + "mime-types": "^3.0.0", "sanitize-filename": "^1.6.3", "tsx": "^4.19.3", "yargs": "^17.3.1" @@ -762,19 +762,19 @@ } }, "node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", "engines": { "node": ">= 0.6" } }, "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", "dependencies": { - "mime-db": "1.52.0" + "mime-db": "^1.54.0" }, "engines": { "node": ">= 0.6" @@ -1594,16 +1594,16 @@ "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==" }, "mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==" + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==" }, "mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", "requires": { - "mime-db": "1.52.0" + "mime-db": "^1.54.0" } }, "mimic-response": { diff --git a/dump-db/package.json b/dump-db/package.json index 051cdbd2e..ecbf63c53 100644 --- a/dump-db/package.json +++ b/dump-db/package.json @@ -18,7 +18,7 @@ "homepage": "https://github.com/TriliumNext/Notes/blob/master/dump-db/README.md", "dependencies": { "better-sqlite3": "^11.1.2", - "mime-types": "^2.1.34", + "mime-types": "^3.0.0", "sanitize-filename": "^1.6.3", "tsx": "^4.19.3", "yargs": "^17.3.1" diff --git a/package-lock.json b/package-lock.json index 1d6021055..ae75166c1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -69,7 +69,7 @@ "mark.js": "8.11.1", "marked": "15.0.7", "mermaid": "11.6.0", - "mime-types": "2.1.35", + "mime-types": "3.0.1", "multer": "1.4.5-lts.2", "normalize-strings": "1.1.1", "normalize.css": "8.0.1", @@ -6971,6 +6971,27 @@ "node": ">= 0.6" } }, + "node_modules/accepts/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/accepts/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/accepts/node_modules/negotiator": { "version": "0.6.3", "resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.6.3.tgz", @@ -12446,6 +12467,27 @@ "node": ">= 6" } }, + "node_modules/form-data/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/form-data/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/formidable": { "version": "3.5.2", "resolved": "https://registry.npmjs.org/formidable/-/formidable-3.5.2.tgz", @@ -15779,21 +15821,21 @@ } }, "node_modules/mime-types": { - "version": "2.1.35", - "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-3.0.1.tgz", + "integrity": "sha512-xRc4oEhT6eaBpU1XF7AjpOFD+xQmXNB5OVKwp4tqCuBpHLS/ZbBDrc07mYTDqVMg6PfxUjjNp85O6Cd2Z/5HWA==", "license": "MIT", "dependencies": { - "mime-db": "1.52.0" + "mime-db": "^1.54.0" }, "engines": { "node": ">= 0.6" } }, "node_modules/mime-types/node_modules/mime-db": { - "version": "1.52.0", - "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "version": "1.54.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.54.0.tgz", + "integrity": "sha512-aU5EJuIN2WDemCcAp2vFBfp/m4EAhWJnUNSSw0ixs7/kXbd6Pg64EmwJkNdFhB8aWt1sH2CTXrLxo/iAGV3oPQ==", "license": "MIT", "engines": { "node": ">= 0.6" @@ -20720,6 +20762,27 @@ "node": ">= 0.6" } }, + "node_modules/type-is/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/type-is/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/typedarray": { "version": "0.0.6", "resolved": "https://registry.npmjs.org/typedarray/-/typedarray-0.0.6.tgz", @@ -21651,6 +21714,29 @@ } } }, + "node_modules/webpack-dev-middleware/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/webpack-dev-middleware/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/webpack-merge": { "version": "6.0.1", "resolved": "https://registry.npmjs.org/webpack-merge/-/webpack-merge-6.0.1.tgz", @@ -21676,6 +21762,29 @@ "node": ">=10.13.0" } }, + "node_modules/webpack/node_modules/mime-db": { + "version": "1.52.0", + "resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz", + "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", + "dev": true, + "license": "MIT", + "engines": { + "node": ">= 0.6" + } + }, + "node_modules/webpack/node_modules/mime-types": { + "version": "2.1.35", + "resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz", + "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", + "dev": true, + "license": "MIT", + "dependencies": { + "mime-db": "1.52.0" + }, + "engines": { + "node": ">= 0.6" + } + }, "node_modules/webworkify": { "version": "1.5.0", "resolved": "https://registry.npmjs.org/webworkify/-/webworkify-1.5.0.tgz", diff --git a/package.json b/package.json index 7ef7a8055..fe059f204 100644 --- a/package.json +++ b/package.json @@ -128,7 +128,7 @@ "mark.js": "8.11.1", "marked": "15.0.7", "mermaid": "11.6.0", - "mime-types": "2.1.35", + "mime-types": "3.0.1", "multer": "1.4.5-lts.2", "normalize-strings": "1.1.1", "normalize.css": "8.0.1", From 597874250acaaaa1e9004a0049c12bbc7337a212 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Fri, 28 Mar 2025 22:07:01 +0200 Subject: [PATCH 57/57] fix(electron): spacing increases when entering Chinese and digits (fixes #1327) --- src/public/app/widgets/type_widgets/editable_text.ts | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/public/app/widgets/type_widgets/editable_text.ts b/src/public/app/widgets/type_widgets/editable_text.ts index d4c8e6aae..71b31b2a0 100644 --- a/src/public/app/widgets/type_widgets/editable_text.ts +++ b/src/public/app/widgets/type_widgets/editable_text.ts @@ -47,6 +47,11 @@ const TPL = ` height: 100%; } + /* Workaround for #1327 */ + body.desktop.electron .note-detail-editable-text { + letter-spacing: -0.01px; + } + body.mobile .note-detail-editable-text { padding-left: 4px; }