Make Project Management a native feature
- Move the storage and model of the plugin into src/lib/features/pm/ as pure TypeScript, so the skill can still bundle them. - Move the DOM interface onto the host menus, the shared tooltip, and the host icons. - A ribbon button opens Project Management. Board tabs keep the owner runestone.pm and the board-<hex> view IDs through view patterns. - Read only .runestone/pm/. Offer the plugin migration, with backups, for legacy notes. - A save, move, or delete reads only that card again. Watcher paths reach the feature. - Add Settings → Project Management and the projectManagement section. View states move to localStorage. - Background reads the boards from workspace.json. Remove api.backgrounds and the boards service. - Add yaml 2.9.1. Use the host markdown-it. - Move 18 plugin test files to tests/unit/features/pm/ and add native tests.
This commit is contained in:
@@ -2,14 +2,12 @@ import { pluginHost, type ContributionRegistry } from "./registry.ts";
|
||||
import { completionHub } from "../completion/hub.ts";
|
||||
import { registerCompletionInput } from "../completion/input.ts";
|
||||
import { showActionMenu } from "../ui/managedActionMenu.ts";
|
||||
import { backgroundHub } from "./backgrounds.ts";
|
||||
import { serviceHub as defaultServiceHub, type ServiceHub } from "./services.ts";
|
||||
import type { Dispose, FilesApi, FilesTransport, PluginApi, PluginCommand, PluginModule, PluginView, PluginDocumentType, PluginDocumentContext } from "./sdk.ts";
|
||||
|
||||
/** The host services that a session gives to its plugin. The host binds them to the plugin ID. */
|
||||
export type SessionServices = Pick<PluginApi, "workspace" | "settings" | "assets"> & {
|
||||
/** True gives the plugin `api.backgrounds`: the background frames of each target. */
|
||||
openFile?: PluginApi["openFile"]; backgrounds?: boolean;
|
||||
openFile?: PluginApi["openFile"];
|
||||
completionTransport?: NonNullable<PluginApi["completion"]>["transport"];
|
||||
files?: FilesTransport; serviceHub?: ServiceHub;
|
||||
};
|
||||
@@ -33,8 +31,6 @@ export class ExternalSession {
|
||||
private mounted = new Set<Dispose>();
|
||||
private contributions: Dispose[] = [];
|
||||
private registry: ContributionRegistry;
|
||||
private backgroundOwner = Symbol('plugin backgrounds');
|
||||
private backgroundSubscriptions = new Set<() => void>();
|
||||
private serviceOwner = Symbol('plugin services');
|
||||
private serviceSubscriptions = new Set<() => void>();
|
||||
readonly id: string;
|
||||
@@ -66,19 +62,6 @@ export class ExternalSession {
|
||||
id: this.id, signal: this.controller.signal,
|
||||
...(this.services.files ? { files: this.filesApi(this.services.files) } : {}),
|
||||
services: this.servicesApi(this.services.serviceHub ?? defaultServiceHub),
|
||||
...(this.services.backgrounds ? { backgrounds: {
|
||||
version: 1 as const,
|
||||
set: (target: string, frame: import('./backgroundContracts.ts').BackgroundFrame | null) => { this.check(); backgroundHub.set(this.backgroundOwner, target, frame); },
|
||||
get: (target: string) => { this.check(); return backgroundHub.get(target); },
|
||||
subscribe: (listener: (target: string) => void) => {
|
||||
this.check();
|
||||
if (typeof listener !== 'function') throw new Error('A background listener must be a function.');
|
||||
const off = backgroundHub.subscribe(target => { if (!this.stopped) listener(target); });
|
||||
const cleanup = () => { off(); this.backgroundSubscriptions.delete(cleanup); };
|
||||
this.backgroundSubscriptions.add(cleanup);
|
||||
return cleanup;
|
||||
},
|
||||
} } : {}),
|
||||
ui: { showActionMenu: options => { this.check(); const menu = showActionMenu(options, this.controller.signal); return { close: () => menu.close() }; } },
|
||||
completion: {
|
||||
version: 1,
|
||||
@@ -231,8 +214,6 @@ export class ExternalSession {
|
||||
stop(): Promise<void> {
|
||||
if (this.stopping) return this.stopping;
|
||||
this.stopped = true; this.controller.abort(); this.commands.clear(); this.views.clear(); this.documentTypes.clear(); this.receiveTab = undefined; this.changed();
|
||||
for (const off of this.backgroundSubscriptions) off();
|
||||
backgroundHub.removeOwner(this.backgroundOwner);
|
||||
for (const off of this.serviceSubscriptions) off();
|
||||
(this.services.serviceHub ?? defaultServiceHub).removeOwner(this.serviceOwner);
|
||||
for (const remove of this.contributions.splice(0)) remove();
|
||||
|
||||
Reference in New Issue
Block a user