2021-05-25 17:50:51 +02:00
|
|
|
import PluginService from '@joplin/lib/services/plugins/PluginService';
|
|
|
|
import PluginRunner from '../app/services/plugins/PluginRunner';
|
|
|
|
|
|
|
|
export interface PluginServiceOptions {
|
2024-04-05 13:16:49 +02:00
|
|
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- Old code before rule was applied
|
2021-05-25 17:50:51 +02:00
|
|
|
getState?(): Record<string, any>;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function newPluginService(appVersion = '1.4', options: PluginServiceOptions = null): PluginService {
|
|
|
|
options = options || {};
|
|
|
|
|
|
|
|
const runner = new PluginRunner();
|
|
|
|
const service = new PluginService();
|
|
|
|
service.initialize(
|
|
|
|
appVersion,
|
|
|
|
{
|
|
|
|
joplin: {},
|
|
|
|
},
|
|
|
|
runner,
|
|
|
|
{
|
|
|
|
dispatch: () => {},
|
|
|
|
getState: options.getState ? options.getState : () => {},
|
2023-08-22 12:58:53 +02:00
|
|
|
},
|
2021-05-25 17:50:51 +02:00
|
|
|
);
|
|
|
|
return service;
|
|
|
|
}
|
|
|
|
|
|
|
|
export function newPluginScript(script: string) {
|
|
|
|
return `
|
|
|
|
/* joplin-manifest:
|
|
|
|
{
|
|
|
|
"id": "org.joplinapp.plugins.PluginTest",
|
|
|
|
"manifest_version": 1,
|
|
|
|
"app_min_version": "1.4",
|
|
|
|
"name": "JS Bundle test",
|
|
|
|
"version": "1.0.0"
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
|
|
|
|
${script}
|
|
|
|
`;
|
|
|
|
}
|