Files
openidea/src/features/plugins/points.tsx
T
Deng Liuanddengliu 79accd1311 perf(settings): split Settings and auxiliary window boot out of the Workbench module (#4044)
Native auxiliary windows (settings, comparison, diff, deployment) all booted src/main.tsx, which statically imported the Workbench and every workbench feature (CodeMirror, xterm, editor extensions) even when the Settings window rendered none of them. main.tsx is now a small window-kind router with one boot module per window kind, and the settings pages, core plugin points and plugin theme runtime are registered from editor-free modules, so the Settings window loads no Workbench, @codemirror, @xterm or @/editor modules (about 57% less JS and a third less heap per Settings window). A static test keeps the Settings boot isolated.

Part of #3942

Co-authored-by: dengliu <5108773+dengliu@users.noreply.github.com>
2026-11-18 18:32:14 +08:00

34 lines
1.3 KiB
TypeScript

/**
* Client side of the first-party UI extension points: how each validated
* declaration is projected onto the workbench, and how its items appear on
* the plugin details page. One `defineUiPoint` per contribution type.
*/
import type { PluginEditor } from "@/bindings";
import { activeEditor } from "@/editor/api";
import { defineCoreUiPoints } from "./corePoints";
import { providePluginEditorContext } from "./editorContext";
import { defineViewUiPoints } from "./uiPoints";
export { commandArgs, pluginActionId } from "./corePoints";
function activePluginEditor(): PluginEditor | null {
const editor = activeEditor();
if (!editor?.ctx.path) return null;
const { doc, selection } = editor.view.state;
const pos = (offset: number) => {
const line = doc.lineAt(offset);
return { line: line.number - 1, col: offset - line.from };
};
return {
path: editor.ctx.path,
language: editor.ctx.language,
selections: selection.ranges.map((r) => ({ start: pos(r.from), end: pos(r.to) })),
};
}
/** Registers the client side of every first-party UI point. */
export function defineBuiltinUiPoints(): () => void {
const disposers = [providePluginEditorContext(activePluginEditor), defineCoreUiPoints(), defineViewUiPoints()];
return () => disposers.reverse().forEach((d) => d());
}