Skip to content

Build your personal knowledge base with Trilium Notes

refactor(client): get rid of runtime in favor of bootstrap script

Elian Doran2e845a9faa74
diff --git a/apps/client/src/index.ts b/apps/client/src/index.ts
index 32f08fd3a4..df5c6a8537 100644
--- a/apps/client/src/index.ts
+++ b/apps/client/src/index.ts
@@ -1,9 +1,16 @@
+import $ from "jquery";
+
async function bootstrap() {
+ (window as any).$ = $;
+ (window as any).jQuery = $;
+
await setupGlob();
+ await loadBootstrapCss();
loadStylesheets();
loadIcons();
setBodyAttributes();
await loadScripts();
+ hideSplash();
}
async function setupGlob() {
@@ -17,6 +24,15 @@ async function setupGlob() {
};
}
+async function loadBootstrapCss() {
+ // We have to selectively import Bootstrap CSS based on text direction.
+ if (document.body.dir === "rtl") {
+ await import("bootstrap/dist/css/bootstrap.rtl.min.css");
+ } else {
+ await import("bootstrap/dist/css/bootstrap.min.css");
+ }
+}
+
function loadStylesheets() {
const { assetPath, themeCssUrl, themeUseNextAsBase } = window.glob;
const cssToLoad: string[] = [];
@@ -70,7 +86,6 @@ function setBodyAttributes() {
}
async function loadScripts() {
- await import("./runtime.js");
if (glob.device === "mobile") {
await import("./mobile.js");
} else {
@@ -78,4 +93,8 @@ async function loadScripts() {
}
}
+function hideSplash() {
+ $("body").show();
+}
+
bootstrap();
diff --git a/apps/client/src/runtime.ts b/apps/client/src/runtime.ts
deleted file mode 100644
index 4c82481b17..0000000000
--- a/apps/client/src/runtime.ts
+++ /dev/null
@@ -1,15 +0,0 @@
-import $ from "jquery";
-
-async function loadBootstrap() {
- if (document.body.dir === "rtl") {
- await import("bootstrap/dist/css/bootstrap.rtl.min.css");
- } else {
- await import("bootstrap/dist/css/bootstrap.min.css");
- }
-}
-
-(window as any).$ = $;
-(window as any).jQuery = $;
-await loadBootstrap();
-
-$("body").show();
diff --git a/apps/client/vite.config.mts b/apps/client/vite.config.mts
index 09f44950e2..b4298563d6 100644
--- a/apps/client/vite.config.mts
+++ b/apps/client/vite.config.mts
@@ -74,7 +74,6 @@ export default defineConfig(() => ({
login: join(__dirname, "src", "login.ts"),
setup: join(__dirname, "src", "setup.ts"),
set_password: join(__dirname, "src", "set_password.ts"),
- runtime: join(__dirname, "src", "runtime.ts"),
print: join(__dirname, "src", "print.tsx")
},
output: {