Update editor, workspace, Git services, appearance, and project guides

This commit is contained in:
Knotty Wyvern
2026-10-11 09:41:16 -07:00
parent a8b1defb9d
commit 909894b9c8
153 changed files with 7967 additions and 775 deletions
+23 -3
View File
@@ -23,17 +23,21 @@ export class ExternalSession {
private contributions: Dispose[] = [];
private registry: ContributionRegistry;
readonly id: string;
private services: Pick<PluginApi, "workspace" | "settings" | "assets"> & { completionTransport?: NonNullable<PluginApi["completion"]>["transport"] };
private services: Pick<PluginApi, "workspace" | "settings" | "assets"> & { openFile?: PluginApi["openFile"]; git?: PluginApi["git"]; completionTransport?: NonNullable<PluginApi["completion"]>["transport"] };
private changed: () => void;
private show: PluginApi["openView"];
private close?: PluginApi["closeView"];
private replace?: PluginApi["replaceView"];
private replaceDocument?: PluginApi["replaceDocumentWithView"];
private receiveTab?: (data: string) => void | Promise<void>;
private openDocument: (path: string) => Promise<void>;
private renameDocument?: PluginApi["renameDocument"];
constructor(id: string, services: Pick<PluginApi, "workspace" | "settings" | "assets"> & { completionTransport?: NonNullable<PluginApi["completion"]>["transport"] }, changed: () => void, show: PluginApi["openView"], registry: ContributionRegistry = pluginHost, openDocument: (path: string) => Promise<void> = async () => { throw new Error("Document views are unavailable."); }, renameDocument?: PluginApi["renameDocument"], close?: PluginApi["closeView"]) {
constructor(id: string, services: Pick<PluginApi, "workspace" | "settings" | "assets"> & { openFile?: PluginApi["openFile"]; git?: PluginApi["git"]; completionTransport?: NonNullable<PluginApi["completion"]>["transport"] }, changed: () => void, show: PluginApi["openView"], registry: ContributionRegistry = pluginHost, openDocument: (path: string) => Promise<void> = async () => { throw new Error("Document views are unavailable."); }, renameDocument?: PluginApi["renameDocument"], close?: PluginApi["closeView"], replace?: PluginApi["replaceView"], replaceDocument?: PluginApi["replaceDocumentWithView"]) {
this.openDocument = openDocument;
this.renameDocument = renameDocument;
this.close = close;
this.replace = replace;
this.replaceDocument = replaceDocument;
this.registry = registry; this.id = id; this.services = services; this.changed = changed; this.show = show;
}
private check() { if (this.stopped) throw new Error("This plugin is disabled."); }
@@ -45,6 +49,19 @@ export class ExternalSession {
};
const api: PluginApi = {
id: this.id, signal: this.controller.signal,
...(this.services.git ? { git: {
status: () => { this.check(); return this.services.git!.status(); },
diff: (path: string, staged: boolean) => { this.check(); return this.services.git!.diff(path, staged); },
stage: (paths: string[]) => { this.check(); return this.services.git!.stage(paths); },
unstage: (paths: string[]) => { this.check(); return this.services.git!.unstage(paths); },
commit: (message: string) => { this.check(); return this.services.git!.commit(message); },
blame: (path: string, line: number) => { this.check(); return this.services.git!.blame(path, line); },
push: () => { this.check(); return this.services.git!.push(); },
pull: () => { this.check(); return this.services.git!.pull(); },
graph: () => { this.check(); return this.services.git!.graph(); },
commitDetails: (commit: string) => { this.check(); return this.services.git!.commitDetails!(commit); },
commitDiff: (commit: string, path: string) => { this.check(); return this.services.git!.commitDiff!(commit, path); },
} } : {}),
completion: {
version: 1,
registerProvider: provider => { this.check(); const off = completionHub.registerProvider({ ...provider, id: this.id + ":" + provider.id }); this.contributions.push(off); return off; },
@@ -57,7 +74,7 @@ export class ExternalSession {
},
contribute: (key, value) => { this.check(); this.contributions.push(this.registry.register(this.id, key, value)); },
registerCommand: item => { if (item.category !== undefined && !["open", "action"].includes(item.category)) throw new Error("Unknown plugin command category."); if (typeof item.run !== "function") throw new Error("A command needs a run function."); register(this.commands, item); },
registerView: item => { if ([item.settings, item.launcher].some(value => value !== undefined && typeof value !== "boolean")) throw new Error("Plugin view access options must be boolean."); if (item.placement !== undefined && !["dialog", "editor"].includes(item.placement)) throw new Error("Unknown plugin view placement."); if (typeof item.mount !== "function") throw new Error("A view needs a mount function."); register(this.views, item); },
registerView: item => { if ([item.settings, item.launcher, item.navigation, item.toolbar].some(value => value !== undefined && typeof value !== "boolean")) throw new Error("Plugin view access options must be boolean."); if (item.placement !== undefined && !["dialog", "editor", "sidebar"].includes(item.placement)) throw new Error("Unknown plugin view placement."); if (typeof item.mount !== "function") throw new Error("A view needs a mount function."); register(this.views, item); },
registerTabDrop: receive => { this.check(); if (typeof receive !== "function" || this.receiveTab) throw new Error("Invalid or duplicate tab receiver."); this.receiveTab = receive; },
updateViewTitle: (id, title) => {
this.check(); const view = this.views.get(id);
@@ -76,9 +93,12 @@ export class ExternalSession {
register(this.documentTypes, item);
},
openDocument: path => { this.check(); return this.openDocument(path); },
...(this.services.openFile ? { openFile: (path: string) => { this.check(); return this.services.openFile!(path); } } : {}),
...(this.renameDocument ? { renameDocument: (document: PluginDocumentContext, name: string) => { this.check(); return this.renameDocument!(document, name); } } : {}),
openView: (id, options) => { this.check(); if (!this.views.has(id)) throw new Error("Unknown plugin view."); this.show(id, options); },
...(this.close ? { closeView: (id: string) => { this.check(); this.close!(id); } } : {}),
...(this.replace ? { replaceView: (currentId: string, nextId: string) => { this.check(); if (!this.views.has(currentId) || !this.views.has(nextId)) throw new Error("Unknown plugin view."); this.replace!(currentId, nextId); } } : {}),
...(this.replaceDocument ? { replaceDocumentWithView: (document: PluginDocumentContext, nextId: string) => { this.check(); if (!this.views.has(nextId)) throw new Error("Unknown plugin view."); this.replaceDocument!(document, nextId); } } : {}),
onDispose: cleanup => { this.check(); if (typeof cleanup !== "function") throw new Error("Cleanup must be a function."); this.cleanups.push(cleanup); },
workspace: {
...(this.services.workspace.subscribe ? { subscribe: (listener: () => void) => {