Principle:AFK surf Open agent Manager Wiring
| Knowledge Sources | |
|---|---|
| Domains | Extensions, Plugin_System, BlockSuite |
| Last Updated | 2026-10-25 00:00 GMT |
Overview
Pattern of assembling an extension manager with provider classes, configuring each provider's options, querying extensions per scope, and wiring the results into the editor and collection.
Description
A manager (StoreExtensionManager or ViewExtensionManager) is constructed with a list of provider classes. configure(Provider, options) sets the options for a provider — accepting a direct value, an updater function prev => next, or undefined to clear. get(scope) returns the flattened ExtensionType[] for that scope by running each provider's setup. The wiring is: spread viewManager.get('page')/get('edgeless') into editor.pageSpecs/editor.edgelessSpecs; assign storeExtensionManager.get('store') to collection.storeExtensions. Downstream code (commands, services) fetch the manager at runtime via DI using ViewExtensionManagerIdentifier. The split between store and view managers keeps store-scoped (data) and view-scoped (UI) extensions on separate wiring paths.
Usage
Apply this principle after authoring provider classes — to assemble, configure, and inject the resulting extensions into the editor and collection. The configure/get/DI triplet is the integration seam between extension authoring and the editor runtime.
Theoretical Basis
The manager is a provider registry + resolver. configure(P, opts) memoizes options per provider; get(scope) folds the provider list into an extension list by invoking setup(scope, options_P) for each P. The DI identifier exposes the manager as a service so runtime code can re-query scopes (e.g. preview-page) without holding a reference.
Pseudo-code:
const viewManager = new ViewExtensionManager([MyViewProvider]);
viewManager.configure(MyViewProvider, { theme: 'dark' });
editor.pageSpecs = [...viewManager.get('page'), ...common];
// Runtime DI:
const vm = std.get(ViewExtensionManagerIdentifier);
vm.get('preview-page');