feat: add HoloLake personal channel module runtime
This commit is contained in:
parent
bb96d5eb89
commit
a106b23f9b
21 changed files with 786 additions and 31 deletions
|
|
@ -57,6 +57,38 @@ export interface SearchResult {
|
|||
line: number;
|
||||
}
|
||||
|
||||
export interface ModuleManifest {
|
||||
id: string;
|
||||
name: string;
|
||||
version: string;
|
||||
kind: 'native-application';
|
||||
state: 'LIVE';
|
||||
description: string;
|
||||
capabilities: string[];
|
||||
dataPolicy: string;
|
||||
}
|
||||
|
||||
export interface ChannelModuleState {
|
||||
id: string;
|
||||
installed: boolean;
|
||||
mounted: boolean;
|
||||
order: number;
|
||||
}
|
||||
|
||||
export interface ChannelState {
|
||||
schema: 'hololake.personal-channel-state/v1';
|
||||
channelId: string;
|
||||
revision: number;
|
||||
updatedAt: string;
|
||||
modules: ChannelModuleState[];
|
||||
}
|
||||
|
||||
export interface ChannelReceipt {
|
||||
id: string;
|
||||
after: ChannelState;
|
||||
reversible: true;
|
||||
}
|
||||
|
||||
export interface DiffResult {
|
||||
additions: number;
|
||||
deletions: number;
|
||||
|
|
@ -66,6 +98,23 @@ export interface DiffResult {
|
|||
// ─── API 方法 ───
|
||||
|
||||
export const api = {
|
||||
async getModules(): Promise<ModuleManifest[]> {
|
||||
const data = await request<{ registry: ModuleManifest[] }>('/modules');
|
||||
return data.registry;
|
||||
},
|
||||
|
||||
async getChannel(): Promise<ChannelState> {
|
||||
const data = await request<{ channel: ChannelState }>('/channel');
|
||||
return data.channel;
|
||||
},
|
||||
|
||||
async patchChannel(input: { operation: 'set_module_state'; moduleId: string; installed?: boolean; mounted?: boolean }): Promise<{ channel: ChannelState; receipt: ChannelReceipt }> {
|
||||
return request('/channel/patch', { method: 'POST', body: JSON.stringify(input) });
|
||||
},
|
||||
|
||||
async undoChannel(receiptId: string): Promise<{ channel: ChannelState; receipt: ChannelReceipt }> {
|
||||
return request(`/channel/undo/${encodeURIComponent(receiptId)}`, { method: 'POST' });
|
||||
},
|
||||
/** 获取文档树 */
|
||||
getTree: () =>
|
||||
request<{ ok: true; tree: DocTreeNode[] }>('/tree').then(d => d.tree),
|
||||
|
|
|
|||
Loading…
Reference in a new issue