Release RuneStone 0.1.4 with installable plugins and settings

This commit is contained in:
Knotty Wyvern
2026-10-04 15:05:51 -07:00
parent 0268c5c9f0
commit 6b7af0d527
82 changed files with 4150 additions and 212 deletions
+27
View File
@@ -0,0 +1,27 @@
import type { Contributions } from "./contracts.ts";
/** Contributions belong to installed package sessions. This registry never loads code. */
export class ContributionRegistry {
private entries = new Map<keyof Contributions, { owner: string; value: Contributions[keyof Contributions] }>();
private listeners = new Set<(revision: number) => void>();
private revision = 0;
get<K extends keyof Contributions>(key: K): Contributions[K] | undefined {
return this.entries.get(key)?.value as Contributions[K] | undefined;
}
register<K extends keyof Contributions>(owner: string, key: K, value: Contributions[K]): () => void {
if (key !== "terminal" && key !== "tableFormulas") throw new Error("Unknown plugin contribution.");
if (this.entries.has(key)) throw new Error(`Contribution already registered: ${key}`);
const entry = { owner, value };
this.entries.set(key, entry); this.emit();
return () => {
if (this.entries.get(key) !== entry) return;
this.entries.delete(key); this.emit();
};
}
subscribe = (listener: (revision: number) => void) => {
this.listeners.add(listener); listener(this.revision);
return () => { this.listeners.delete(listener); };
};
private emit() { this.revision++; for (const listener of this.listeners) listener(this.revision); }
}
export const pluginHost = new ContributionRegistry();