mirror of
https://github.com/Nystik-gh/ignis.git
synced 2026-06-17 04:35:53 +00:00
expose Ignis API, implement shared ws client
This commit is contained in:
@@ -3,6 +3,7 @@ const path = require("path");
|
||||
const express = require("express");
|
||||
const { discoverPlugins } = require("./discovery");
|
||||
const configStore = require("./config-store");
|
||||
const { getVersion } = require("../version");
|
||||
|
||||
let discoveredPlugins = new Map();
|
||||
const loadedPlugins = new Map();
|
||||
@@ -171,6 +172,23 @@ async function enablePluginForVault(pluginId, vaultId) {
|
||||
if (loaded?.module?.onVaultEnabled) {
|
||||
await loaded.module.onVaultEnabled(vaultId, vaultPath);
|
||||
}
|
||||
|
||||
// Broadcast to any open tabs on this vault so they load the plugin properly.
|
||||
if (discovered.obsidianPlugin && discovered.bundledPluginId) {
|
||||
const v = `?v=${getVersion()}`;
|
||||
const entry = {
|
||||
id: discovered.bundledPluginId,
|
||||
scriptUrl: `/${discovered.bundledPluginId}.js${v}`,
|
||||
cssUrl: `/${discovered.bundledPluginId}.css${v}`,
|
||||
manifest: discovered.bundledManifest,
|
||||
};
|
||||
|
||||
serverCtx.wss?.broadcastToVault?.(vaultId, {
|
||||
type: "virtual-plugin-enable",
|
||||
vault: vaultId,
|
||||
entry,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
async function disablePluginForVault(pluginId, vaultId) {
|
||||
@@ -200,6 +218,14 @@ async function disablePluginForVault(pluginId, vaultId) {
|
||||
if (updated.length === 0) {
|
||||
await unloadPlugin(pluginId);
|
||||
}
|
||||
|
||||
if (discovered.bundledPluginId) {
|
||||
serverCtx.wss?.broadcastToVault?.(vaultId, {
|
||||
type: "virtual-plugin-disable",
|
||||
vault: vaultId,
|
||||
id: discovered.bundledPluginId,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
function getBundledPluginDirs() {
|
||||
|
||||
Reference in New Issue
Block a user