Registering an injection
From a service, callthis.inject(...):
src/main/services/my-plugin.ts
The call returns an unregister function. Wrap it in
this.setup(...) so it cleans up on hot reload.
Reading injections
useInjections({ kind }) returns the live list of injections whose meta.kind matches.
Rendering an injection
<View name="..."> looks up the injection and renders its value as a React component. args is passed to the component as a prop and is also available via useViewArgs() in any child.
Meta conventions
The framework does not readmeta. Consumers do. The conventional keys are:
Registering from React
useRegisterInjection registers an injection while the calling component is mounted, and unregisters on unmount. Use it when the value can only be constructed inside React, for example a CodeMirror extension built from a hook’s state.
Injecting without a value
With nometa, the framework just imports the module. The module’s top-level code runs, but nothing is added to the registry.
Advice
Advice is a kind of injection that replaces or wraps a specific exported function or component anywhere in the app. It is registered withthis.advise(...), which targets the export by its source file and export name.
type field controls how the wrapper relates to the original:
replacesubstitutes the original entirely.aroundruns in place of the original. It receives the next function in the chain as its first argument; call it (or don’t) to decide whether the original runs.beforeruns first with the original arguments.afterruns last and receives the result followed by the original arguments. Returning a value other thanundefinedoverrides the result.
this.advise(...) is sugar over this.inject(...) with meta.kind: "advice". For the full reference, including how the wrapper module should be written for each type, see Advice.
Hot reloading
Adding, removing, or editing athis.inject(...) call invalidates the renderer prelude and reloads the window. Edits inside the injection module itself hot-replace through Vite.
