mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-03-13 10:11:37 -07:00
feat: publish tidgi-shared npm for types, and place tidgi.service
This commit is contained in:
parent
544a8b1bf3
commit
593ed2d29c
10 changed files with 533 additions and 16 deletions
|
|
@ -1,6 +1,6 @@
|
|||
// Auto-attach services to global.service - MUST import before using services
|
||||
import './services';
|
||||
import { native } from './services';
|
||||
import { native, service } from './services';
|
||||
import { onWorkerServicesReady } from './servicesReady';
|
||||
|
||||
import { getTidGiAuthHeaderWithToken } from '@/constants/auth';
|
||||
|
|
@ -222,6 +222,19 @@ export function startNodeJSWiki(configs: IStartNodeJSWikiConfigs): Observable<IW
|
|||
: [homePath, '--version'];
|
||||
wikiInstance.boot.argv = [...fullBootArgv];
|
||||
|
||||
/**
|
||||
* Attach service proxies to `$tw.tidgi.service` so that TiddlyWiki route modules
|
||||
* (which run in vm.runInContext sandbox) can access them.
|
||||
* The sandbox injects `$tw` but NOT `globalThis` or `global`,
|
||||
* so `$tw.tidgi.service` is the only way for plugins to reach IPC service proxies.
|
||||
*/
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
||||
if (!(wikiInstance as any).tidgi) {
|
||||
(wikiInstance as any).tidgi = {};
|
||||
}
|
||||
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-explicit-any
|
||||
(wikiInstance as any).tidgi.service = service;
|
||||
|
||||
wikiInstance.hooks.addHook('th-server-command-post-start', function(_server: unknown, nodeServer: Server) {
|
||||
nodeServer.on('error', function(error: Error) {
|
||||
observer.next({ type: 'control', actions: WikiControlActions.error, message: error.message, argv: fullBootArgv });
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue