mirror of
https://github.com/Kong/insomnia.git
synced 2026-06-15 11:30:07 -04:00
Remove INSOMNIA_ENABLE_PLUGIN_BRIDGE rollback switch
Lock in the bridge as the permanent path — plugins always run in the hidden plugin window via window.main.plugins IPC. The legacy invokePluginMethod fallback in renderer-bridge.ts is removed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,32 +1,13 @@
|
||||
import type { PluginBridgeMetrics, PluginsBridgeAPI } from './bridge-types';
|
||||
import { invokePluginMethod } from './invoke-method';
|
||||
|
||||
// Phase 1a rollback switch: set INSOMNIA_ENABLE_PLUGIN_BRIDGE=false to fall
|
||||
// back to running plugins directly in the renderer (legacy behaviour).
|
||||
// This module lives in the renderer bundle (not the preload) so the heavy
|
||||
// plugin-system deps it pulls in don't inflate the preload.
|
||||
const bridgeEnabled = process.env.INSOMNIA_ENABLE_PLUGIN_BRIDGE !== 'false';
|
||||
import type { PluginsBridgeAPI } from './bridge-types';
|
||||
|
||||
function call<M extends keyof Omit<PluginsBridgeAPI, 'getBridgeMetrics'>>(
|
||||
method: M,
|
||||
args?: Parameters<PluginsBridgeAPI[M]>[0],
|
||||
): ReturnType<PluginsBridgeAPI[M]> {
|
||||
if (bridgeEnabled) {
|
||||
const fn = (window.main.plugins[method] as (...a: any[]) => any);
|
||||
return fn(args) as ReturnType<PluginsBridgeAPI[M]>;
|
||||
}
|
||||
return invokePluginMethod(method as any, args) as ReturnType<PluginsBridgeAPI[M]>;
|
||||
const fn = (window.main.plugins[method] as (...a: any[]) => any);
|
||||
return fn(args) as ReturnType<PluginsBridgeAPI[M]>;
|
||||
}
|
||||
|
||||
const emptyBridgeMetrics: PluginBridgeMetrics = {
|
||||
windowStartups: 0,
|
||||
windowCrashes: 0,
|
||||
windowStartupMsLast: null,
|
||||
windowReady: false,
|
||||
pendingInvocations: 0,
|
||||
perMethod: {},
|
||||
};
|
||||
|
||||
export const plugins: PluginsBridgeAPI = {
|
||||
getThemes: () => call('getThemes'),
|
||||
getPlugins: () => call('getPlugins'),
|
||||
@@ -45,8 +26,5 @@ export const plugins: PluginsBridgeAPI = {
|
||||
hasResponseHooks: () => call('hasResponseHooks'),
|
||||
applyRequestHooks: args => call('applyRequestHooks', args),
|
||||
applyResponseHooks: args => call('applyResponseHooks', args),
|
||||
getBridgeMetrics: () =>
|
||||
bridgeEnabled
|
||||
? window.main.plugins.getBridgeMetrics()
|
||||
: Promise.resolve(emptyBridgeMetrics),
|
||||
getBridgeMetrics: () => window.main.plugins.getBridgeMetrics(),
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user