Skip to content

Build your personal knowledge base with Trilium Notes

feat(build-docs): expose electronApi as a variabile

Elian Doran446b490dcc88
diff --git a/apps/build-docs/src/electron_api_entrypoint.ts b/apps/build-docs/src/electron_api_entrypoint.ts
index 4665737515..dd1a05b4e7 100644
--- a/apps/build-docs/src/electron_api_entrypoint.ts
+++ b/apps/build-docs/src/electron_api_entrypoint.ts
@@ -14,11 +14,15 @@
* interface below is the contract both the preload script
* (`satisfies ElectronApi`) and the client (`window.electronApi`) share.
*
- * Entry point: {@link ElectronApi}
+ * The entire API is exposed as a single global: {@link electronApi}
*
* @module Electron API
*/
+import type {
+ ElectronApi
+} from "../../../packages/commons/src/lib/electron_api_interface.js";
+
export type {
ElectronApi,
ElectronClipboardApi,
@@ -31,3 +35,16 @@ export type {
ElectronTrayApi,
ElectronWindowApi
} from "../../../packages/commons/src/lib/electron_api_interface.js";
+
+/**
+ * The `window.electronApi` global gives the renderer access to Electron-only
+ * functionality through the preload bridge. See {@link ElectronApi} for the
+ * full surface.
+ *
+ * Only available in the Electron desktop build — `window.electronApi` is
+ * `undefined` in the browser/server build and in the standalone (WASM) build,
+ * so always guard calls with `if (window.electronApi)` from frontend scripts.
+ */
+// @ts-expect-error - ElectronApi is exposed at runtime by the preload script;
+// no constructable class exists here, so we simulate the value for TypeDoc.
+export const electronApi: ElectronApi = {};