import { Injector } from '@opensumi/di'; import { Disposable, ErrorResponse, IDisposable, ReplyResponse } from '@opensumi/ide-core-common'; import { WorkbenchEditorService } from '@opensumi/ide-editor'; import { ICodeEditor, IPosition, ITextModel, Selection } from '@opensumi/ide-monaco'; import { EResultKind } from '../inline-chat/inline-chat.service'; import { AIInlineContentWidget } from '../inline-chat/inline-content-widget'; import { BaseInlineStreamDiffHandler } from '../inline-stream-diff/inline-stream-diff.handler'; import { InlineDiffWidget } from './inline-diff-widget'; export interface IDiffPreviewerOptions { disposeWhenEditorClosed: boolean; /** * 是否隐藏接受部分编辑的 widget,用于只展示 diff 的场景 */ hideAcceptPartialEditWidget?: boolean; /** * 默认情况下,removed widget 会在 `runWhenIdle` 内被添加,如果需要立即添加,可以设置为 true */ renderRemovedWidgetImmediately?: boolean; /** * 是否为回退模式,即 setValue 内容作为 original,编辑器 getValue 内容作为 modified */ reverse?: boolean; } export interface IInlineDiffPreviewerNode extends IDisposable { previewerOptions: IDiffPreviewerOptions; setPreviewerOptions(options: IDiffPreviewerOptions): void; } export declare abstract class BaseInlineDiffPreviewer extends Disposable { protected readonly monacoEditor: ICodeEditor; protected readonly injector: Injector; protected readonly editorService: WorkbenchEditorService; protected inlineContentWidget: AIInlineContentWidget | null; protected selection: Selection; protected model: ITextModel; modelId: string; constructor(monacoEditor: ICodeEditor); protected formatIndentation(content: string): string; protected node: N | undefined; getNode(): N | undefined; mountWidget(contentWidget: AIInlineContentWidget): void; layout(): void; onReady(exec: () => void): IDisposable; protected abstract createNode(reverse?: boolean): N; abstract onData(data: ReplyResponse): void; abstract handleAction(action: EResultKind): void; abstract getPosition(): IPosition; create(selection: Selection, options?: IDiffPreviewerOptions): void; attachNode(node: N | undefined): void; show(line: number, heightInLines: number): void; onLineCount(event: (count: number) => void): IDisposable; setValue(content: string): void; getValue(): string; getOriginValue(): string; onError(error: ErrorResponse): void; onAbort(): void; onEnd(): void; revealFirstDiff(): void; /** * 会新建一个渲染层的实例 * 或重新赋值渲染层的数据 * 适用于首次渲染 */ render(): void; /** * 仅隐藏渲染层,而不销毁实例 */ hide(): void; /** * 恢复渲染层 * 适用于非首次渲染 */ resume(): void; isModel(uri: string): boolean; } export declare class SideBySideInlineDiffWidget extends BaseInlineDiffPreviewer { static AI_DIFF_WIDGET_ID: string; createNode(): InlineDiffWidget; mountWidget(contentWidget: AIInlineContentWidget): void; getPosition(): IPosition; layout(): void; onReady(exec: () => void): IDisposable; show(line: number, heightInLines: number): void; setValue(content: string): void; getValue(): string; getOriginValue(): string; handleAction(action: EResultKind): void; onLineCount(event: (count: number) => void): Disposable; onData(data: ReplyResponse): void; onError(error: ErrorResponse): void; onAbort(): void; onEnd(): void; } export declare class LiveInlineDiffPreviewer extends BaseInlineDiffPreviewer { private listenNode; createNode(reverse?: boolean): BaseInlineStreamDiffHandler; getPosition(): IPosition; handleAction(action: EResultKind): void; onLineCount(): IDisposable; layout(): void; render(): void; hide(): void; resume(): void; onData(data: ReplyResponse): void; onAbort(): void; onEnd(): void; getValue(): string; getOriginValue(): string; setValue(content: string): void; revealFirstDiff(): void; } //# sourceMappingURL=inline-diff-previewer.d.ts.map