Build your personal knowledge base with Trilium Notes
TypeScript electronelectron-appknowledge-baseknowledge-graphknowledge-managementknowledge-management-graphlocal-firstnote-managmentnote-takernote-takingnotebooknotesnotes-apppersonal-knowledge-basepersonal-wikiscriptableself-hostedself-hostingwiki
chore(standalone): addres requested changes
Elian Dorana7001beced6d
diff --git a/apps/client-standalone/src/lightweight/browser_routes.ts b/apps/client-standalone/src/lightweight/browser_routes.tsindex b014bc729b..8eed93c4ea 100644--- a/apps/client-standalone/src/lightweight/browser_routes.ts+++ b/apps/client-standalone/src/lightweight/browser_routes.ts@@ -259,7 +259,6 @@ function bootstrapRoute(): BootstrapDefinition {if (!isDbInitialized) {return {...commonItems,- isStandalone: true,baseApiUrl: "../api/",isProtectedSessionAvailable: false,};diff --git a/packages/trilium-core/src/routes/api/note_map.ts b/packages/trilium-core/src/routes/api/note_map.tsindex 603cfa8033..82ce821ed9 100644--- a/packages/trilium-core/src/routes/api/note_map.ts+++ b/packages/trilium-core/src/routes/api/note_map.ts@@ -15,13 +15,13 @@ function buildDescendantCountMap(noteIdsToCount: string[]) {throw new Error("noteIdsToCount: type error");}- const noteIdToCountMap = Object.create(null);+ const noteIdToCountMap: Record<string, number> = Object.create(null);- function getCount(noteId: string) {+ function getCount(noteId: string): number {if (!(noteId in noteIdToCountMap)) {const note = becca.getNote(noteId);if (!note) {- return;+ return 0;}const hiddenImageNoteIds = note.getRelations("imageLink").map((rel) => rel.value);@@ -258,7 +258,6 @@ export function findExcerpts(sourceNote: BNote, referencedNoteId: string) {removeImages(document);for (const linkEl of document.querySelectorAll("a")) {- console.log("Got ", linkEl.innerHTML);const href = linkEl.getAttribute("href");if (!href || !href.endsWith(referencedNoteId)) {diff --git a/packages/trilium-core/src/routes/helpers.ts b/packages/trilium-core/src/routes/helpers.tsindex 7d17678602..d12344c097 100644--- a/packages/trilium-core/src/routes/helpers.ts+++ b/packages/trilium-core/src/routes/helpers.ts@@ -3,7 +3,7 @@ import becca from "../becca/becca";import BNote from "../becca/entities/bnote";import protected_session from "../services/protected_session";import BAttachment from "../becca/entities/battachment";-import { utils } from "..";+import { getContentDisposition } from "../services/utils/index";export function downloadNoteInt(noteId: string, res: Response, contentDisposition = true) {const note = becca.getNote(noteId);@@ -23,7 +23,7 @@ export function downloadData(noteOrAttachment: BNote | BAttachment, res: Responsif (contentDisposition) {const fileName = noteOrAttachment.getFileName();- res.setHeader("Content-Disposition", utils.getContentDisposition(fileName));+ res.setHeader("Content-Disposition", getContentDisposition(fileName));}res.setHeader("Cache-Control", "no-cache, no-store, must-revalidate");diff --git a/packages/trilium-core/src/services/bootstrap_utils.ts b/packages/trilium-core/src/services/bootstrap_utils.tsindex 10ecb93417..9d857145f1 100644--- a/packages/trilium-core/src/services/bootstrap_utils.ts+++ b/packages/trilium-core/src/services/bootstrap_utils.ts@@ -6,6 +6,7 @@ import optionService from "./options";import { getCurrentLocale } from "./i18n";import attributes from "./attributes";import BNote from "../becca/entities/bnote";+import { getPlatform } from "./platform";export default function getSharedBootstrapItems(assetPath: string, dbInitialized: boolean) {const sql = getSql();@@ -20,7 +21,6 @@ export default function getSharedBootstrapItems(assetPath: string, dbInitializedlayoutOrientation: "vertical" as const,headingStyle: "plain" as const,componentId: "",- appCssNoteIds: getAppCssNoteIds(),...getIconConfig(assetPath)};@@ -29,7 +29,8 @@ export default function getSharedBootstrapItems(assetPath: string, dbInitializedreturn {...commonItems,themeCssUrl: false as const,- themeUseNextAsBase: "next" as const+ themeUseNextAsBase: "next" as const,+ appCssNoteIds: []};}@@ -46,6 +47,7 @@ export default function getSharedBootstrapItems(assetPath: string, dbInitializedisProtectedSessionAvailable: protected_session.isProtectedSessionAvailable(),themeCssUrl: getThemeCssUrl(theme, commonItems.assetPath, themeNote) as string | false,themeUseNextAsBase: themeNote?.getAttributeValue("label", "appThemeBase") as "next" | "next-light" | "next-dark",+ appCssNoteIds: getAppCssNoteIds(),}}@@ -81,7 +83,7 @@ function getThemeCssUrl(theme: string, assetPath: string, themeNote: BNote | nulreturn `${assetPath}/stylesheets/theme-next-light.css`;} else if (theme === "next-dark") {return `${assetPath}/stylesheets/theme-next-dark.css`;- } else if (!process.env.TRILIUM_SAFE_MODE && themeNote) {+ } else if (!getPlatform().getEnv("TRILIUM_SAFE_MODE") && themeNote) {return `api/notes/download/${themeNote.noteId}`;}// baseline light themediff --git a/packages/trilium-core/src/services/utils/index.spec.ts b/packages/trilium-core/src/services/utils/index.spec.tsindex 295c172056..7ebbf4df0e 100644--- a/packages/trilium-core/src/services/utils/index.spec.ts+++ b/packages/trilium-core/src/services/utils/index.spec.ts@@ -505,19 +505,19 @@ describe.todo("#getResourceDir", () => {});describe("#isElectron", () => {it("should export a boolean", () => {- expect(utils.isElectron).toBeTypeOf("boolean");+ expect(utils.isElectron()).toBeTypeOf("boolean");});});describe("#isMac", () => {it("should export a boolean", () => {- expect(utils.isMac).toBeTypeOf("boolean");+ expect(utils.isMac()).toBeTypeOf("boolean");});});describe("#isWindows", () => {it("should export a boolean", () => {- expect(utils.isWindows).toBeTypeOf("boolean");+ expect(utils.isWindows()).toBeTypeOf("boolean");});});diff --git a/packages/trilium-core/src/services/utils/index.ts b/packages/trilium-core/src/services/utils/index.tsindex f417db8aa6..0a73c6b8e3 100644--- a/packages/trilium-core/src/services/utils/index.ts+++ b/packages/trilium-core/src/services/utils/index.ts@@ -276,7 +276,7 @@ export function stringToInt(val: string | undefined) {* @returns An array of patterns to match both with and without trailing slash*/export function normalizeCustomHandlerPattern(pattern: string | null | undefined): (string | null | undefined)[] {- if (!pattern || typeof pattern !== 'string') {+ if (!pattern || typeof pattern !== "string") {return [pattern];}@@ -287,32 +287,32 @@ export function normalizeCustomHandlerPattern(pattern: string | null | undefined}// If pattern already ends with optional trailing slash, return as-is- if (pattern.endsWith('/?$') || pattern.endsWith('/?)')) {+ if (pattern.endsWith("/?$") || pattern.endsWith("/?)")) {return [pattern];}// If pattern ends with $, handle it specially- if (pattern.endsWith('$')) {+ if (pattern.endsWith("$")) {const basePattern = pattern.slice(0, -1);// If already ends with slash, create both versions- if (basePattern.endsWith('/')) {- const withoutSlash = `${basePattern.slice(0, -1) }$`;+ if (basePattern.endsWith("/")) {+ const withoutSlash = `${basePattern.slice(0, -1)}$`;const withSlash = pattern;return [withoutSlash, withSlash];}// Add optional trailing slash- const withSlash = `${basePattern }/?$`;+ const withSlash = `${basePattern}/?$`;return [withSlash];}// For patterns without $, add both versions- if (pattern.endsWith('/')) {+ if (pattern.endsWith("/")) {const withoutSlash = pattern.slice(0, -1);return [withoutSlash, pattern];}- const withSlash = `${pattern }/`;+ const withSlash = `${pattern}/`;return [pattern, withSlash];}