Where a plugin executes#
Plugin JavaScript executes in the bundled Node backend through vm.Script and a per-module VM context. It does not execute in the website or the visible WebView2 DOM. Hooks receive a context created by the manager; tab content is a separate renderer output.
The evaluator exposes real fs/path modules and timers. The VM is a compatibility boundary, not a security mechanism for untrusted code. Review source from third parties before using it. Node's own vm documentation describes this boundary.
Supported versus absent globals#
| Supplied | Absent from the plugin sandbox |
|---|---|
| module.exports, routed console, fs, path, __dirname | require, process, ES-module import loader |
| setTimeout, clearTimeout, setInterval, clearInterval | Automatic timer cleanup on disable/reload |
| Buffer and standard JavaScript intrinsics | Browser window, document, navigator |
| context.fetch | A directly supplied fetch or AbortController global |
| context.ui and documented hooks | Electron ipcRenderer, desktopCapturer, app, BrowserWindow |
Port an older plugin#
- Identify every Electron import and renderer assumption.
- Replace supported configuration, log, notification and networking work with context methods.
- Export hooks through module.exports and register native UI actions.
- Use plugin-owned local files via fs/path for persistence.
- Move UI markup to tab.content, escaping variable data.
- Document unavailable features explicitly rather than calling an invented API.
A native app can use some compatibility-named classes internally; that does not mean Electron APIs are available to plugins.
Current boundaries#
Disabled modules are still evaluated at load time, so avoid top-level side effects. The API has no permission declarations, lifecycle disposal callbacks or resource quota enforcement. Asynchronous initialization must handle its own rejection, and permanently running timers require careful redesign.
For extension work that changes recording state, filesystem authorization or bridge commands, make an explicit application-source change with validation and tests. A plugin should remain within the public context documented in the API reference.
Implementation reference: PluginManager.evaluatePluginCode; src/native/runtime.ts · native 2.0.7.