Skip to content

Build your personal knowledge base with Trilium Notes

chore(client-standalone): basic integration for assets

Elian Doranc0bf294457e7
diff --git a/apps/client-standalone/package.json b/apps/client-standalone/package.json
index 11a353d3f5..747a05f3d9 100644
--- a/apps/client-standalone/package.json
+++ b/apps/client-standalone/package.json
@@ -1,16 +1,85 @@
{
"name": "@triliumnext/client-standalone",
"version": "1.0.0",
- "description": "",
- "main": "index.js",
+ "description": "Standalone client for TriliumNext with SQLite WASM backend",
+ "private": true,
+ "license": "AGPL-3.0-only",
"scripts": {
- "test": "echo \"Error: no test specified\" && exit 1"
+ "build": "cross-env NODE_OPTIONS=--max-old-space-size=4096 vite build",
+ "dev": "vite dev",
+ "test": "vitest",
+ "coverage": "vitest --coverage"
},
"dependencies": {
+ "@excalidraw/excalidraw": "0.18.0",
+ "@fullcalendar/core": "6.1.20",
+ "@fullcalendar/daygrid": "6.1.20",
+ "@fullcalendar/interaction": "6.1.20",
+ "@fullcalendar/list": "6.1.20",
+ "@fullcalendar/multimonth": "6.1.20",
+ "@fullcalendar/timegrid": "6.1.20",
+ "@maplibre/maplibre-gl-leaflet": "0.1.3",
+ "@mermaid-js/layout-elk": "0.2.0",
+ "@mind-elixir/node-menu": "5.0.1",
+ "@popperjs/core": "2.11.8",
+ "@preact/signals": "2.5.1",
"@sqlite.org/sqlite-wasm": "3.51.1-build2",
+ "@triliumnext/ckeditor5": "workspace:*",
+ "@triliumnext/codemirror": "workspace:*",
"@triliumnext/commons": "workspace:*",
"@triliumnext/core": "workspace:*",
+ "@triliumnext/highlightjs": "workspace:*",
+ "@triliumnext/share-theme": "workspace:*",
+ "@triliumnext/split.js": "workspace:*",
+ "@zumer/snapdom": "2.0.1",
+ "autocomplete.js": "0.38.1",
+ "bootstrap": "5.3.8",
+ "boxicons": "2.1.4",
+ "clsx": "2.1.1",
+ "color": "5.0.3",
+ "debounce": "3.0.0",
+ "draggabilly": "3.0.0",
+ "force-graph": "1.51.0",
+ "globals": "17.0.0",
+ "i18next": "25.7.3",
+ "i18next-http-backend": "3.0.2",
+ "jquery": "3.7.1",
+ "jquery.fancytree": "2.38.5",
"js-sha1": "0.7.0",
- "js-sha512": "0.9.0"
+ "js-sha512": "0.9.0",
+ "jsplumb": "2.15.6",
+ "katex": "0.16.27",
+ "knockout": "3.5.1",
+ "leaflet": "1.9.4",
+ "leaflet-gpx": "2.2.0",
+ "mark.js": "8.11.1",
+ "marked": "17.0.1",
+ "mermaid": "11.12.2",
+ "mind-elixir": "5.4.0",
+ "normalize.css": "8.0.1",
+ "panzoom": "9.4.3",
+ "preact": "10.28.1",
+ "react-i18next": "16.5.1",
+ "react-window": "2.2.3",
+ "reveal.js": "5.2.1",
+ "svg-pan-zoom": "3.6.2",
+ "tabulator-tables": "6.3.1",
+ "vanilla-js-wheel-zoom": "9.0.4"
+ },
+ "devDependencies": {
+ "@ckeditor/ckeditor5-inspector": "5.0.0",
+ "@preact/preset-vite": "2.10.2",
+ "@types/bootstrap": "5.2.10",
+ "@types/jquery": "3.5.33",
+ "@types/leaflet": "1.9.21",
+ "@types/leaflet-gpx": "1.3.8",
+ "@types/mark.js": "8.11.12",
+ "@types/reveal.js": "5.2.2",
+ "@types/tabulator-tables": "6.3.1",
+ "copy-webpack-plugin": "13.0.1",
+ "cross-env": "7.0.3",
+ "happy-dom": "20.0.11",
+ "script-loader": "0.7.2",
+ "vite-plugin-static-copy": "3.1.4"
}
}
diff --git a/apps/client-standalone/src/vite-env.d.ts b/apps/client-standalone/src/vite-env.d.ts
new file mode 100644
index 0000000000..28ae7076ee
--- /dev/null
+++ b/apps/client-standalone/src/vite-env.d.ts
@@ -0,0 +1,9 @@
+/// <reference types="vite/client" />
+
+interface ImportMetaEnv {
+ readonly VITE_APP_TITLE: string
+}
+
+interface ImportMeta {
+ readonly env: ImportMetaEnv
+}
diff --git a/apps/client-standalone/tsconfig.app.json b/apps/client-standalone/tsconfig.app.json
new file mode 100644
index 0000000000..07d36e7acf
--- /dev/null
+++ b/apps/client-standalone/tsconfig.app.json
@@ -0,0 +1,26 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "compilerOptions": {
+ "lib": [
+ "ES2022",
+ "dom",
+ "dom.iterable"
+ ],
+ "skipLibCheck": true,
+ "types": [
+ "vite/client"
+ ],
+ "jsx": "react-jsx",
+ "jsxImportSource": "preact"
+ },
+ "include": [
+ "src/**/*",
+ "../client/src/**/*"
+ ],
+ "exclude": [
+ "src/**/*.spec.ts",
+ "src/**/*.test.ts",
+ "../client/src/**/*.spec.ts",
+ "../client/src/**/*.test.ts"
+ ]
+}
\ No newline at end of file
diff --git a/apps/client-standalone/tsconfig.json b/apps/client-standalone/tsconfig.json
new file mode 100644
index 0000000000..a12172e9b2
--- /dev/null
+++ b/apps/client-standalone/tsconfig.json
@@ -0,0 +1,7 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "references": [
+ { "path": "./tsconfig.app.json" },
+ { "path": "./tsconfig.spec.json" }
+ ]
+}
\ No newline at end of file
diff --git a/apps/client-standalone/tsconfig.spec.json b/apps/client-standalone/tsconfig.spec.json
new file mode 100644
index 0000000000..856955c7fc
--- /dev/null
+++ b/apps/client-standalone/tsconfig.spec.json
@@ -0,0 +1,18 @@
+{
+ "extends": "../../tsconfig.base.json",
+ "compilerOptions": {
+ "lib": [
+ "ES2022",
+ "dom",
+ "dom.iterable"
+ ],
+ "types": [
+ "vitest/globals",
+ "happy-dom"
+ ]
+ },
+ "include": [
+ "src/**/*.spec.ts",
+ "src/**/*.test.ts"
+ ]
+}
\ No newline at end of file
diff --git a/apps/client-standalone/vite.config.mts b/apps/client-standalone/vite.config.mts
index c505e86b1d..fbbc23dca2 100644
--- a/apps/client-standalone/vite.config.mts
+++ b/apps/client-standalone/vite.config.mts
@@ -1,20 +1,81 @@
+import preact from "@preact/preset-vite";
import { defineConfig } from 'vite';
import { join } from 'path';
import { viteStaticCopy } from 'vite-plugin-static-copy';
const assets = ["assets", "stylesheets", "fonts", "translations"];
+const isDev = process.env.NODE_ENV === "development";
+
+// Always copy SQLite WASM files so they're available to the module
+const sqliteWasmPlugin = viteStaticCopy({
+ targets: [
+ {
+ // Copy the entire jswasm directory to maintain the module's expected structure
+ src: "../../node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm/*",
+ dest: "node_modules/@sqlite.org/sqlite-wasm/sqlite-wasm/jswasm"
+ }
+ ]
+});
+
+let plugins: any = [
+ preact({
+ babel: {
+ compact: !isDev
+ }
+ }),
+ sqliteWasmPlugin, // Always include SQLite WASM files
+ viteStaticCopy({
+ targets: assets.map((asset) => ({
+ src: `../client/src/${asset}/*`,
+ dest: asset
+ }))
+ })
+];
+
+if (!isDev) {
+ plugins = [
+ ...plugins,
+ viteStaticCopy({
+ structured: true,
+ targets: [
+ {
+ src: "../../node_modules/@excalidraw/excalidraw/dist/prod/fonts/*",
+ dest: "",
+ }
+ ]
+ })
+ ]
+}
+
export default defineConfig(() => ({
root: __dirname,
+ cacheDir: '../../node_modules/.vite/apps/client-standalone',
base: "",
- plugins: [
- viteStaticCopy({
- targets: assets.map((asset) => ({
- src: `../${asset}/*`,
- dest: asset
- }))
- })
- ],
+ plugins,
+ resolve: {
+ alias: [
+ {
+ find: "react",
+ replacement: "preact/compat"
+ },
+ {
+ find: "react-dom",
+ replacement: "preact/compat"
+ },
+ {
+ find: "@client",
+ replacement: join(__dirname, "../client/src")
+ }
+ ],
+ dedupe: [
+ "react",
+ "react-dom",
+ "preact",
+ "preact/compat",
+ "preact/hooks"
+ ]
+ },
server: {
watch: {
ignored: ['!**/node_modules/@triliumnext/**']
@@ -42,6 +103,9 @@ export default defineConfig(() => ({
}
}
},
+ test: {
+ environment: "happy-dom"
+ },
define: {
"process.env.IS_PREACT": JSON.stringify("true"),
}