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
feat(client): get glob to be populated
Elian Doran0d4558fee17f
diff --git a/apps/client/src/desktop.html b/apps/client/src/desktop.htmlindex e237fef67d..3eb4153f1b 100644--- a/apps/client/src/desktop.html+++ b/apps/client/src/desktop.html@@ -24,6 +24,20 @@<!-- This works even when the user directly changes --root-background in CSS --><div id="background-color-tracker" style="position: absolute; visibility: hidden; color: var(--root-background); transition: color 1ms;"></div>+ <!-- Bootstrap (request server for required information) -->+ <script>+ async function bootstrap() {+ const response = await fetch("./bootstrap");+ const json = await response.json();++ window.glob = {+ ...json,+ activeDialog: null+ };+ }+ bootstrap();+ </script>+<!-- Required for correct loading of scripts in Electron --><script>if (typeof module === 'object') {window.module = module; module = undefined;}diff --git a/apps/server/src/assets/views/desktop.ejs b/apps/server/src/assets/views/desktop.ejsindex 96f617bd79..a0e395226f 100644--- a/apps/server/src/assets/views/desktop.ejs+++ b/apps/server/src/assets/views/desktop.ejs@@ -4,15 +4,12 @@<style id="trilium-icon-packs"><%- iconPackCss %></style>- <script src="<%= appPath %>/runtime.js" crossorigin type="module"></script></head><bodyclass="desktop heading-style-<%= headingStyle %> layout-<%= layoutOrientation %> platform-<%= platform %> <%= isElectron ? 'electron' : '' %> <%= hasNativeTitleBar ? 'native-titlebar' : '' %> <%= hasBackgroundEffects ? 'background-effects' : '' %>"lang="<%= currentLocale.id %>" dir="<%= currentLocale.rtl ? 'rtl' : 'ltr' %>">-<%- include("./partials/windowGlobal.ejs", locals) %>-<link href="<%= assetPath %>/stylesheets/ckeditor-theme.css" rel="stylesheet"><link href="api/fonts" rel="stylesheet"><link href="<%= assetPath %>/stylesheets/theme-light.css" rel="stylesheet">diff --git a/apps/server/src/assets/views/partials/windowGlobal.ejs b/apps/server/src/assets/views/partials/windowGlobal.ejsdeleted file mode 100644index 31911bc683..0000000000--- a/apps/server/src/assets/views/partials/windowGlobal.ejs+++ /dev/null@@ -1,25 +0,0 @@-<script type="text/javascript">- global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */-- window.glob = {- device: "<%= device %>",- baseApiUrl: "<%= baseApiUrl %>",- activeDialog: null,- maxEntityChangeIdAtLoad: <%= maxEntityChangeIdAtLoad %>,- maxEntityChangeSyncIdAtLoad: <%= maxEntityChangeSyncIdAtLoad %>,- instanceName: '<%= instanceName %>',- csrfToken: '<%= csrfToken %>',- isDev: <%= isDev %>,- appCssNoteIds: <%- JSON.stringify(appCssNoteIds) %>,- isMainWindow: <%= isMainWindow %>,- isProtectedSessionAvailable: <%= isProtectedSessionAvailable %>,- triliumVersion: "<%= triliumVersion %>",- assetPath: "<%= assetPath %>",- appPath: "<%= appPath %>",- platform: "<%= platform %>",- hasNativeTitleBar: <%= hasNativeTitleBar %>,- TRILIUM_SAFE_MODE: <%= !!process.env.TRILIUM_SAFE_MODE %>,- isRtl: <%= !!currentLocale.rtl %>,- iconRegistry: <%- JSON.stringify(iconRegistry) %>- };-</script>\ No newline at end of filediff --git a/apps/server/src/routes/index.ts b/apps/server/src/routes/index.tsindex 30c390c316..da0174999f 100644--- a/apps/server/src/routes/index.ts+++ b/apps/server/src/routes/index.ts@@ -31,6 +31,7 @@ export function bootstrap(req: Request, res: Response) {const themeNote = attributeService.getNoteWithLabel("appTheme", theme);const nativeTitleBarVisible = options.nativeTitleBarVisible === "true";const iconPacks = getIconPacks();+ const currentLocale = getCurrentLocale();res.send({device: view,@@ -43,9 +44,10 @@ export function bootstrap(req: Request, res: Response) {isElectron,hasNativeTitleBar: isElectron && nativeTitleBarVisible,hasBackgroundEffects: isElectron && isWindows11 && !nativeTitleBarVisible && options.backgroundEffects === "true",- mainFontSize: parseInt(options.mainFontSize),- treeFontSize: parseInt(options.treeFontSize),- detailFontSize: parseInt(options.detailFontSize),+ // TODO: These font size don't actually seem to be used.+ mainFontSize: parseInt(options.mainFontSize, 10),+ treeFontSize: parseInt(options.treeFontSize, 10),+ detailFontSize: parseInt(options.detailFontSize, 10),maxEntityChangeIdAtLoad: sql.getValue("SELECT COALESCE(MAX(id), 0) FROM entity_changes"),maxEntityChangeSyncIdAtLoad: sql.getValue("SELECT COALESCE(MAX(id), 0) FROM entity_changes WHERE isSynced = 1"),instanceName: config.General ? config.General.instanceName : null,@@ -57,14 +59,16 @@ export function bootstrap(req: Request, res: Response) {assetPath,appPath,baseApiUrl: 'api/',- currentLocale: getCurrentLocale(),+ currentLocale,+ isRtl: !!currentLocale.rtl,iconPackCss: iconPacks.map(p => generateCss(p, p.builtin? `${assetPath}/fonts/${p.fontAttachmentId}.${MIME_TO_EXTENSION_MAPPINGS[p.fontMime]}`: `api/attachments/download/${p.fontAttachmentId}`)).filter(Boolean).join("\n\n"),- iconRegistry: generateIconRegistry(iconPacks)+ iconRegistry: generateIconRegistry(iconPacks),+ TRILIUM_SAFE_MODE: !!process.env.TRILIUM_SAFE_MODE});}