mirror of
https://github.com/tiddly-gittly/TidGi-Desktop.git
synced 2026-01-02 07:12:40 -08:00
Introduces the watch-filesystem-adaptor TiddlyWiki plugin, enabling tag-based routing of tiddlers to sub-wikis by querying workspace info via worker thread IPC. Adds workerServiceCaller utility for worker-to-main service calls, updates workerAdapter and bindServiceAndProxy to support explicit service registration for workers, and documents the new IPC architecture. Updates wikiWorker and startNodeJSWiki to preload workspace ID and load the new plugin. Also updates the plugin build script to compile and copy the new plugin.
64 lines
3 KiB
JavaScript
64 lines
3 KiB
JavaScript
/* eslint-disable @typescript-eslint/no-unsafe-argument */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-return */
|
|
/* eslint-disable unicorn/prevent-abbreviations */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-assignment */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
/* eslint-disable @typescript-eslint/no-unsafe-call */
|
|
import esbuild from 'esbuild';
|
|
import { rimraf } from 'rimraf';
|
|
|
|
// put it here, so it can be loaded via `'+plugins/linonetwo/tidgi'` in cli, and get copied in scripts/afterPack.js when copying tiddlywiki (no need to copy this plugin again)
|
|
const tidgiIpcSyncadaptorOutDir = path.join(__dirname, '../node_modules/tiddlywiki/plugins/linonetwo/tidgi-ipc-syncadaptor');
|
|
// delete if exist
|
|
await rimraf(tidgiIpcSyncadaptorOutDir);
|
|
await fs.mkdirp(tidgiIpcSyncadaptorOutDir);
|
|
const tsconfigPath = path.join(__dirname, '../tsconfig.json');
|
|
const tidgiIpcSyncadaptorSourceFolder = '../src/services/wiki/plugin/ipcSyncAdaptor';
|
|
const sharedConfig = {
|
|
logLevel: 'info',
|
|
bundle: true,
|
|
// use node so we have `exports`, otherwise `module.adaptorClass` in $:/core/modules/startup.js will be undefined
|
|
platform: 'node',
|
|
minify: process.env.NODE_ENV === 'production',
|
|
outdir: tidgiIpcSyncadaptorOutDir,
|
|
tsconfig: tsconfigPath,
|
|
target: 'ESNEXT',
|
|
};
|
|
await Promise.all([
|
|
esbuild.build({
|
|
...sharedConfig,
|
|
entryPoints: [path.join(__dirname, tidgiIpcSyncadaptorSourceFolder, 'ipc-syncadaptor.ts')],
|
|
}),
|
|
esbuild.build({
|
|
...sharedConfig,
|
|
entryPoints: [path.join(__dirname, tidgiIpcSyncadaptorSourceFolder, 'electron-ipc-cat.ts')],
|
|
}),
|
|
esbuild.build({
|
|
...sharedConfig,
|
|
entryPoints: [path.join(__dirname, tidgiIpcSyncadaptorSourceFolder, 'fix-location-info.ts')],
|
|
}),
|
|
]);
|
|
const filterFunc = (src) => {
|
|
return !src.endsWith('.ts');
|
|
};
|
|
await fs.copy(path.join(__dirname, tidgiIpcSyncadaptorSourceFolder), tidgiIpcSyncadaptorOutDir, { filter: filterFunc });
|
|
|
|
const tidgiIpcSyncadaptorUISourceFolder = '../src/services/wiki/plugin/ipcSyncAdaptorUI';
|
|
const tidgiIpcSyncadaptorUIOutDir = path.join(__dirname, '../node_modules/tiddlywiki/plugins/linonetwo/tidgi-ipc-syncadaptor-ui');
|
|
// delete if exist
|
|
await rimraf(tidgiIpcSyncadaptorUIOutDir);
|
|
await fs.mkdirp(tidgiIpcSyncadaptorUIOutDir);
|
|
await fs.copy(path.join(__dirname, tidgiIpcSyncadaptorUISourceFolder), tidgiIpcSyncadaptorUIOutDir, { filter: filterFunc });
|
|
|
|
// Compile watch-filesystem-adaptor plugin
|
|
const watchFileSystemAdaptorSourceFolder = '../src/services/wiki/plugin/watchFileSystemAdaptor';
|
|
const watchFileSystemAdaptorOutDir = path.join(__dirname, '../node_modules/tiddlywiki/plugins/linonetwo/watch-filesystem-adaptor');
|
|
// delete if exist
|
|
await rimraf(watchFileSystemAdaptorOutDir);
|
|
await fs.mkdirp(watchFileSystemAdaptorOutDir);
|
|
await esbuild.build({
|
|
...sharedConfig,
|
|
entryPoints: [path.join(__dirname, watchFileSystemAdaptorSourceFolder, 'watch-filesystem-adaptor.ts')],
|
|
outdir: watchFileSystemAdaptorOutDir,
|
|
});
|
|
await fs.copy(path.join(__dirname, watchFileSystemAdaptorSourceFolder), watchFileSystemAdaptorOutDir, { filter: filterFunc });
|