Files
likang 1fde96c05e
CI / typecheck + test + build (push) Has been cancelled
打通vibemake
2026-11-05 16:21:37 +08:00

31 lines
1014 B
TypeScript

// SPDX-License-Identifier: GPL-3.0-or-later
/** Optional host port. Native editors do not know about accounts or HTTP. */
export interface ProjectSnapshotParticipant {
flush: () => void | Promise<void>;
isBusy?: () => boolean;
isDirty?: () => boolean;
}
export interface ProjectSnapshotHost {
readonly scope: string;
register(key: string, participant: ProjectSnapshotParticipant): () => void;
modified(): void;
save(): Promise<void>;
command?(action: 'open' | 'new' | 'save-as' | 'download'): void;
writeFile(path: string, bytes: Uint8Array): void;
relativePath?(path: string): string;
storeLibrary(
kind: 'symbols' | 'footprints',
nickname: string,
text: string,
itemName?: string,
): void;
}
let host: ProjectSnapshotHost | null = null;
export const projectSnapshotHost = (): ProjectSnapshotHost | null => host;
export function installProjectSnapshotHost(next: ProjectSnapshotHost): () => void {
host = next;
return () => {
if (host === next) host = null;
};
}