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(client-standalone): create empty project
Elian Doran1e381b13ca7b
diff --git a/apps/client-standalone/package.json b/apps/client-standalone/package.jsonnew file mode 100644index 0000000000..55befe3603--- /dev/null+++ b/apps/client-standalone/package.json@@ -0,0 +1,9 @@+{+ "name": "@triliumnext/client-standalone",+ "version": "1.0.0",+ "description": "",+ "main": "index.js",+ "scripts": {+ "test": "echo \"Error: no test specified\" && exit 1"+ }+}diff --git a/apps/client-standalone/src/index.html b/apps/client-standalone/src/index.htmlnew file mode 100644index 0000000000..81ef3b387b--- /dev/null+++ b/apps/client-standalone/src/index.html@@ -0,0 +1,133 @@+<!DOCTYPE html>+<html lang="en">+ <head>+ <meta charset="utf-8">+ <link rel="shortcut icon" href="favicon.ico">+ <meta name="mobile-web-app-capable" content="yes">+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />+ <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, viewport-fit=cover" />+ <!-- <link rel="manifest" crossorigin="use-credentials" href="manifest.webmanifest"> -->+ <title>Trilium Notes</title>+ </head>++ <body id="trilium-app">+ <noscript><%= t("javascript-required") %></noscript>++ <script>+ // hide body to reduce flickering on the startup. This is done through JS and not CSS to not hide <noscript>+ document.getElementsByTagName("body")[0].style.display = "none";+ </script>++ <div class="dropdown-menu dropdown-menu-sm" id="context-menu-container" style="display: none"></div>++ <!-- Required for match the PWA's top bar color with the theme -->+ <!-- 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>++ <!-- Inject service worker -->+ <script type="module">+ import { attachServiceWorkerBridge, startLocalServerWorker } from "./local-bridge.js";++ // 1) Start local worker ASAP (so /bootstrap is fast)+ startLocalServerWorker();++ // 2) Bridge SW -> local worker+ attachServiceWorkerBridge();++ // 3) Register SW+ if ("serviceWorker" in navigator) {+ const reg = await navigator.serviceWorker.register("./sw.js", { scope: "/src/" });+ // Optionally wait for activation+ await navigator.serviceWorker.ready;+ }+ </script>++ <!-- Bootstrap (request server for required information) -->+ <script>+ async function bootstrap() {+ await setupGlob();+ loadStylesheets();+ loadIcons();+ setBodyAttributes();+ await loadScripts();+ }++ async function setupGlob() {+ const response = await fetch("/bootstrap");+ console.log("Service worker state", navigator.serviceWorker.controller);+ console.log("Resp", response);+ const json = await response.json();+ console.log("Bootstrap", json);++ global = globalThis; /* fixes https://github.com/webpack/webpack/issues/10035 */+ window.glob = {+ ...json,+ activeDialog: null+ };+ }++ function loadStylesheets() {+ const { assetPath, themeCssUrl, themeUseNextAsBase } = window.glob;+ const cssToLoad = [];+ cssToLoad.push(`${assetPath}/stylesheets/theme-light.css`);+ if (themeCssUrl) {+ cssToLoad.push(themeCssUrl);+ }+ if (themeUseNextAsBase === "next") {+ cssToLoad.push(`${assetPath}/stylesheets/theme-next.css`)+ } else if (themeUseNextAsBase === "next-dark") {+ cssToLoad.push(`${assetPath}/stylesheets/theme-next-dark.css`)+ } else if (themeUseNextAsBase === "next-light") {+ cssToLoad.push(`${assetPath}/stylesheets/theme-next-light.css`)+ }+ cssToLoad.push(`${assetPath}/stylesheets/style.css`);++ for (const href of cssToLoad) {+ const linkEl = document.createElement("link");+ linkEl.href = href;+ linkEl.rel = "stylesheet";+ document.body.appendChild(linkEl);+ }+ }++ function loadIcons() {+ const styleEl = document.createElement("style");+ styleEl.innerText = window.glob.iconPackCss;+ document.head.appendChild(styleEl);+ }++ function setBodyAttributes() {+ const { device, headingStyle, layoutOrientation, platform, isElectron, hasNativeTitleBar, hasBackgroundEffects, currentLocale } = window.glob;+ const classesToSet = [+ device,+ `heading-style-${headingStyle}`,+ `layout-${layoutOrientation}`,+ `platform-${platform}`,+ isElectron && "isElectron",+ hasNativeTitleBar && "native-titlebar",+ hasBackgroundEffects && "background-effects"+ ].filter(Boolean);++ for (const classToSet of classesToSet) {+ document.body.classList.add(classToSet);+ }++ document.body.lang = currentLocale.id;+ document.body.dir = currentLocale.rtl ? "rtl" : "ltr";+ }++ async function loadScripts() {+ const assetPath = glob.assetPath;+ await import(`./${assetPath}/runtime.js`);+ await import(`./${assetPath}/desktop.js`);+ }++ bootstrap();+ </script>++ <!-- Required for correct loading of scripts in Electron -->+ <script>+ if (typeof module === 'object') {window.module = module; module = undefined;}+ </script>+ </body>+</html>\ No newline at end of filediff --git a/apps/client-standalone/vite.config.mts b/apps/client-standalone/vite.config.mtsnew file mode 100644index 0000000000..5adb366482--- /dev/null+++ b/apps/client-standalone/vite.config.mts@@ -0,0 +1,33 @@+import { defineConfig } from 'vite';+import { join } from 'path';+import { viteStaticCopy } from 'vite-plugin-static-copy';++const assets = ["assets", "stylesheets", "fonts", "translations"];++export default defineConfig(() => ({+ root: __dirname,+ base: "",+ plugins: [+ viteStaticCopy({+ targets: assets.map((asset) => ({+ src: `../${asset}/*`,+ dest: asset+ }))+ })+ ],+ server: {+ watch: {+ ignored: ['!**/node_modules/@triliumnext/**']+ }+ },+ build: {+ target: "esnext",+ outDir: join(__dirname, 'dist'),+ emptyOutDir: true,+ rollupOptions: {+ input: {+ main: join(__dirname, 'src', 'index.html')+ }+ }+ }+}));\ No newline at end of file