03a4410272
主要工作是共享同一套“画布内核与通用 UI 源码”,网站和 Tauri 只分别实现宿主适配层。 --------- Co-authored-by: 段舒康 <kdletters@qq.com> Co-authored-by: kdletters <kdletters@qq.com> Reviewed-on: http://192.168.35.82/git/GenarrativeAI/Genarrative/pulls/136 Co-authored-by: menghao <mh18530625731@163.com> Co-committed-by: menghao <mh18530625731@163.com>
60 lines
1.7 KiB
TypeScript
60 lines
1.7 KiB
TypeScript
import type {
|
|
ImageCanvasAssetPort,
|
|
ImageCanvasCompletionPort,
|
|
ImageCanvasGenerationPort,
|
|
ImageCanvasHostCapabilities,
|
|
ImageCanvasHostPort,
|
|
ImageCanvasProjectPort,
|
|
} from '@genarrative/image-canvas-core';
|
|
|
|
import type {
|
|
EditorAssetSnapshot,
|
|
EditorProjectSnapshot,
|
|
} from '../../../services/image-editor/editorProjectClient';
|
|
|
|
export type WebImageCanvasHostServices = {
|
|
requestLogin: () => void;
|
|
openAccount: () => void;
|
|
openWallet: () => void;
|
|
navigateToProject: (projectId: string) => void;
|
|
readCurrentProject: () => EditorProjectSnapshot | null;
|
|
resolveCloudAsset: (resourceId: string) => EditorAssetSnapshot | null;
|
|
};
|
|
|
|
export type WebImageCanvasHostAdapter = ImageCanvasHostPort & {
|
|
readonly kind: 'web';
|
|
readonly web: WebImageCanvasHostServices;
|
|
};
|
|
|
|
const WEB_IMAGE_CANVAS_CAPABILITIES: ImageCanvasHostCapabilities = {
|
|
account: true,
|
|
wallet: true,
|
|
cloudAssetLibrary: true,
|
|
localProject: false,
|
|
externalEditorGeneration: false,
|
|
advancedBackgroundRemoval: true,
|
|
};
|
|
|
|
/**
|
|
* Composes the existing website workflows behind shared host ports. The
|
|
* website remains the owner of auth, wallet, routing and editorProjectClient;
|
|
* shared canvas modules only receive the four semantic port groups.
|
|
*/
|
|
export function createWebImageCanvasHostAdapter(input: {
|
|
project: ImageCanvasProjectPort;
|
|
asset: ImageCanvasAssetPort;
|
|
generation: ImageCanvasGenerationPort;
|
|
completion: ImageCanvasCompletionPort;
|
|
web: WebImageCanvasHostServices;
|
|
}): WebImageCanvasHostAdapter {
|
|
return {
|
|
kind: 'web',
|
|
capabilities: WEB_IMAGE_CANVAS_CAPABILITIES,
|
|
project: input.project,
|
|
asset: input.asset,
|
|
generation: input.generation,
|
|
completion: input.completion,
|
|
web: input.web,
|
|
};
|
|
}
|