TidGi-Desktop/packages/tidgi-shared
linonetwo b677088a48 Expose TidGi services to $tw.tidgi and add types
Make TidGi IPC service proxies available inside the TiddlyWiki sandbox and provide typings for plugin authors. Added docs (docs/TidGiServiceAPI.md), bumped tidgi-shared to 0.1.2, and introduced shared type files (packages/tidgi-shared/src/{global.d.ts,tidgiGlobal.ts}) and tsconfig include for .d.ts files. Preload now exposes service via contextBridge and attaches it to $tw.tidgi.service (with DOMContentLoaded retry). Updated various wiki plugin files to use $tw.tidgi.service instead of window.service, adjusted worker-side service exports (no automatic global attach), and updated startNodeJSWiki to safely inject service into the wiki sandbox with proper typing. Added runtime TiddlyWiki type augmentations (src/types/tidgi-tw.d.ts). These changes ensure plugins running in the VM can reliably access typed service proxies.
2026-02-10 02:41:32 +08:00
..
src Expose TidGi services to $tw.tidgi and add types 2026-02-10 02:41:32 +08:00
.gitignore feat: publish tidgi-shared npm for types, and place tidgi.service 2026-02-09 23:16:49 +08:00
package.json Expose TidGi services to $tw.tidgi and add types 2026-02-10 02:41:32 +08:00
README.md feat: publish tidgi-shared npm for types, and place tidgi.service 2026-02-09 23:16:49 +08:00
tsconfig.json Expose TidGi services to $tw.tidgi and add types 2026-02-10 02:41:32 +08:00
tsup.config.ts feat: publish tidgi-shared npm for types, and place tidgi.service 2026-02-09 23:16:49 +08:00

tidgi-shared

Shared service interfaces, IPC descriptors, and constants for TidGi plugins.

This package re-exports all TidGi Desktop service interface types so that external TiddlyWiki plugins and projects can reference them without depending on the full TidGi-Desktop codebase.

Install

pnpm add tidgi-shared

Usage

import type { IGitServerService, IWorkspaceService, IGitService } from 'tidgi-shared';

For TiddlyWiki route modules running in TidGi's wiki worker, access services via $tw.tidgi.service:

import type { IGitServerService, IWorkspaceService, IGitService } from 'tidgi-shared';

interface ITidGiGlobalService {
  gitServer?: IGitServerService;
  workspace: IWorkspaceService;
  git: IGitService;
}

const tidgiService = ($tw as typeof $tw & { tidgi?: { service?: ITidGiGlobalService } }).tidgi?.service;

Building

pnpm run build

What's Included

  • All TidGi service interfaces (25 services)
  • IPC descriptors for electron-ipc-cat proxy
  • Channel constants for IPC communication
  • Shared types (IService, SupportedStorageServices, etc.)
  • Window properties and metadata types