mirror of
https://github.com/h-sphere/sql-seal.git
synced 2026-07-22 10:10:28 +00:00
* chore: reworking plugin internals into modules * feat: settings module is now working, added debug module, enabled new api module * chore: restoring external API * feat: refactoring project to use proper inversion of control * feat: plugins can now be loaded in any order * chore: final file migration, all typescript is in modules now * chore: fixing dependencies of cellParser * feat: csv and json views are only registered when they are not colliding with other plugins * feat: fixed library behaviour on canvas
55 lines
1.3 KiB
TypeScript
55 lines
1.3 KiB
TypeScript
import { Plugin } from "obsidian";
|
|
import {
|
|
PluginRegister,
|
|
SQLSealApi,
|
|
SQLSealRegisterApi,
|
|
} from "./pluginApi/sqlSealApi";
|
|
import { makeInjector } from "@hypersphere/dity";
|
|
import { ApiModule } from "./module";
|
|
import { RendererRegistry } from "../editor/renderer/rendererRegistry";
|
|
import { SqlSealDatabase } from "../database/database";
|
|
import { ModernCellParser } from "../syntaxHighlight/cellParser/ModernCellParser";
|
|
|
|
const SQLSEAL_API_KEY = "___sqlSeal";
|
|
const SQLSEAL_QUEUED_PLUGINS = "___sqlSeal_queue";
|
|
|
|
@(makeInjector<ApiModule, "factory">()([
|
|
"plugin",
|
|
"cellParser",
|
|
"rendererRegistry",
|
|
"db",
|
|
]))
|
|
export class ApiInit {
|
|
make(
|
|
plugin: Plugin,
|
|
cellParser: ModernCellParser,
|
|
rendererRegistry: RendererRegistry,
|
|
db: SqlSealDatabase,
|
|
) {
|
|
return () => {
|
|
const api = new SQLSealRegisterApi(
|
|
plugin,
|
|
cellParser,
|
|
rendererRegistry,
|
|
db,
|
|
);
|
|
(window as any)[SQLSEAL_API_KEY] = api;
|
|
plugin.register(() => {
|
|
delete (window as any)[SQLSEAL_API_KEY];
|
|
});
|
|
|
|
const queuedPlugins = (window as any)[SQLSEAL_QUEUED_PLUGINS] as
|
|
| PluginRegister[]
|
|
| undefined;
|
|
if (!queuedPlugins) {
|
|
return;
|
|
}
|
|
|
|
queuedPlugins.forEach((pl) => {
|
|
api.registerForPluginNew(pl);
|
|
});
|
|
|
|
(window as any)[SQLSEAL_QUEUED_PLUGINS] = [];
|
|
};
|
|
}
|
|
}
|