GUIDE 20 / 28 · NATIVE 2.0.7

Runtime & native compatibility

Know the Node VM boundary, supplied globals, unsupported imports and trust model before porting a plugin.

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#

SuppliedAbsent from the plugin sandbox
module.exports, routed console, fs, path, __dirnamerequire, process, ES-module import loader
setTimeout, clearTimeout, setInterval, clearIntervalAutomatic timer cleanup on disable/reload
Buffer and standard JavaScript intrinsicsBrowser window, document, navigator
context.fetchA directly supplied fetch or AbortController global
context.ui and documented hooksElectron ipcRenderer, desktopCapturer, app, BrowserWindow

Port an older plugin#

  1. Identify every Electron import and renderer assumption.
  2. Replace supported configuration, log, notification and networking work with context methods.
  3. Export hooks through module.exports and register native UI actions.
  4. Use plugin-owned local files via fs/path for persistence.
  5. Move UI markup to tab.content, escaping variable data.
  6. 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.