mirror of
https://github.com/BetterSEQTA/BetterSEQTA-Plus.git
synced 2026-06-05 19:24:39 +00:00
47 lines
1.2 KiB
TypeScript
47 lines
1.2 KiB
TypeScript
import type { Plugin } from '@/plugins/core/types';
|
|
import { BasePlugin } from '@/plugins/core/settings';
|
|
import { defineSettings, booleanSetting, Setting } from '@/plugins/core/settingsHelpers';
|
|
|
|
// Step 1: Define settings with proper typing
|
|
const settings = defineSettings({
|
|
someSetting: booleanSetting({
|
|
default: true,
|
|
title: "Test Plugin",
|
|
description: "Some random setting",
|
|
})
|
|
});
|
|
|
|
// Step 2: Create the plugin class with @Setting decorators
|
|
class TestPluginClass extends BasePlugin<typeof settings> {
|
|
@Setting(settings.someSetting)
|
|
someSetting!: boolean;
|
|
}
|
|
|
|
// Step 3: Instantiate and plug it in
|
|
const settingsInstance = new TestPluginClass();
|
|
|
|
const testPlugin: Plugin<typeof settings> = {
|
|
id: 'test',
|
|
name: 'Test Plugin',
|
|
description: 'A test plugin for BetterSEQTA+',
|
|
version: '1.0.0',
|
|
settings: settingsInstance.settings,
|
|
|
|
run: async (api) => {
|
|
console.log('Test plugin running');
|
|
|
|
const { unregister } = api.seqta.onPageChange((page) => {
|
|
console.log('Page changed to', page);
|
|
|
|
console.log('Current setting value:', api.settings.someSetting);
|
|
});
|
|
|
|
return () => {
|
|
console.log('Test plugin stopped');
|
|
unregister();
|
|
}
|
|
}
|
|
};
|
|
|
|
export default testPlugin;
|