From f3dd26d98aaafee6700aba4fcaeaf4eb2367be82 Mon Sep 17 00:00:00 2001 From: linonetwo Date: Thu, 12 Feb 2026 21:45:33 +0800 Subject: [PATCH] Update TidGiServiceAPI.md --- docs/TidGiServiceAPI.md | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/docs/TidGiServiceAPI.md b/docs/TidGiServiceAPI.md index 798e0467..c9a6f9b4 100644 --- a/docs/TidGiServiceAPI.md +++ b/docs/TidGiServiceAPI.md @@ -9,9 +9,9 @@ TidGi exposes the same service proxies in two places: - Plugin runtime (TW sandbox): `$tw.tidgi.service` - Frontend runtime (renderer): `window.service` -## Usage in plugins (TiddlyWiki route modules) +## Usage in plugins (TiddlyWiki modules) -Route modules run inside TiddlyWiki’s VM sandbox, so `globalThis` is not the worker’s real global. Use `$tw.tidgi.service`. +TiddlyWiki modules should use `$tw.tidgi.service`. In the BrowserView (renderer) build, it is mounted during boot by a startup module. In the wiki worker build, it is attached before boot. Example: @@ -32,8 +32,9 @@ await window.service.workspace.getActiveWorkspace(); ## How the API is wired - Service proxies are created in the wiki worker and preload using `electron-ipc-cat`. -- Renderer (WebView): `src/preload/common/exportServices.ts` exposes proxies via `contextBridge`, assigns `window.service`, and attaches `$tw.tidgi.service` after `$tw` is ready. -- Wiki worker: `startNodeJSWiki.ts` attaches the same proxies to `$tw.tidgi.service` before TiddlyWiki boot, so route modules can access them inside the sandbox. +- Renderer (BrowserView): `src/preload/common/exportServices.ts` exposes proxies via `contextBridge` and assigns `window.service`. +- Renderer (BrowserView): `src/services/wiki/plugin/ipcSyncAdaptor/Startup/mount-tidgi-service.ts` (published as a startup module) mounts `window.service` to `$tw.tidgi.service` during TiddlyWiki boot. +- Wiki worker: `src/services/wiki/wikiWorker/startNodeJSWiki.ts` attaches the same proxies to `$tw.tidgi.service` before TiddlyWiki boot, so modules can access them inside the worker. ## Types for plugins