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:
28
packages/shim/src/ignis-api.js
Normal file
28
packages/shim/src/ignis-api.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// Public Ignis API surface. The documented way for plugins (and Ignis-internal code) to reach shim services.
|
||||
// WIP, may expand to cover more shared functionality.
|
||||
|
||||
export function installIgnisApi(wsClient) {
|
||||
window.__ignis = window.__ignis || {};
|
||||
|
||||
// Live getters so vault info reflects whatever init.js / vault-switch code has set.
|
||||
Object.defineProperty(window.__ignis, "vault", {
|
||||
get() {
|
||||
return {
|
||||
id: window.__currentVaultId || null,
|
||||
path: window.__vaultConfig?.path || null,
|
||||
};
|
||||
},
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
});
|
||||
|
||||
window.__ignis.ws = {
|
||||
subscribe: wsClient.subscribe,
|
||||
send: wsClient.send,
|
||||
channel: wsClient.channel,
|
||||
isOpen: wsClient.isOpen,
|
||||
onStateChange: wsClient.onStateChange,
|
||||
};
|
||||
|
||||
window.__ignis.plugins = window.__ignis.plugins || {};
|
||||
}
|
||||
Reference in New Issue
Block a user