Skip to content

Commit

Permalink
feat: upgrade opensumi to 3.4.3 (#198)
Browse files Browse the repository at this point in the history
  • Loading branch information
bytemain authored Oct 15, 2024
1 parent bf78c2e commit ed1f678
Show file tree
Hide file tree
Showing 14 changed files with 552 additions and 536 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"description": "codeblitzjs",
"main": "index.js",
"engines": {
"opensumi": "3.3.3"
"opensumi": "3.4.4-next-1728882643.0"
},
"scripts": {
"prepare": "husky install",
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@
"opensumi codeblitzjs"
],
"engines": {
"opensumi": "3.3.3",
"opensumi": "3.4.4-next-1728882643.0",
"node": ">=18.0.0"
},
"dependencies": {
"@codeblitzjs/ide-common": "workspace:*",
"@opensumi/extension-installer": "^0.0.1",
"@opensumi/ide-extension": "3.3.3",
"@opensumi/ide-extension": "3.4.4-next-1728882643.0",
"commander": "^7.2.0",
"fs-extra": "^9.0.1",
"lodash.pick": "^4.4.0",
Expand Down
84 changes: 42 additions & 42 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -33,48 +33,48 @@
"@codeblitzjs/ide-plugin": "workspace:*",
"@codeblitzjs/ide-registry": "workspace:*",
"@codeblitzjs/ide-sumi-core": "workspace:*",
"@opensumi/ide-addons": "3.3.3",
"@opensumi/ide-ai-native": "3.3.3",
"@opensumi/ide-comments": "3.3.3",
"@opensumi/ide-core-browser": "3.3.3",
"@opensumi/ide-core-common": "3.3.3",
"@opensumi/ide-debug": "3.3.3",
"@opensumi/ide-decoration": "3.3.3",
"@opensumi/ide-design": "3.3.3",
"@opensumi/ide-editor": "3.3.3",
"@opensumi/ide-explorer": "3.3.3",
"@opensumi/ide-express-file-server": "3.3.3",
"@opensumi/ide-extension": "3.3.3",
"@opensumi/ide-extension-storage": "3.3.3",
"@opensumi/ide-file-scheme": "3.3.3",
"@opensumi/ide-file-service": "3.3.3",
"@opensumi/ide-file-tree-next": "3.3.3",
"@opensumi/ide-i18n": "3.3.3",
"@opensumi/ide-keymaps": "3.3.3",
"@opensumi/ide-logs": "3.3.3",
"@opensumi/ide-main-layout": "3.3.3",
"@opensumi/ide-markdown": "3.3.3",
"@opensumi/ide-markers": "3.3.3",
"@opensumi/ide-menu-bar": "3.3.3",
"@opensumi/ide-monaco": "3.3.3",
"@opensumi/ide-monaco-enhance": "3.3.3",
"@opensumi/ide-opened-editor": "3.3.3",
"@opensumi/ide-outline": "3.3.3",
"@opensumi/ide-output": "3.3.3",
"@opensumi/ide-overlay": "3.3.3",
"@opensumi/ide-preferences": "3.3.3",
"@opensumi/ide-quick-open": "3.3.3",
"@opensumi/ide-scm": "3.3.3",
"@opensumi/ide-search": "3.3.3",
"@opensumi/ide-status-bar": "3.3.3",
"@opensumi/ide-storage": "3.3.3",
"@opensumi/ide-testing": "3.3.3",
"@opensumi/ide-theme": "3.3.3",
"@opensumi/ide-toolbar": "3.3.3",
"@opensumi/ide-variable": "3.3.3",
"@opensumi/ide-webview": "3.3.3",
"@opensumi/ide-workspace": "3.3.3",
"@opensumi/ide-workspace-edit": "3.3.3",
"@opensumi/ide-addons": "3.4.4-next-1728882643.0",
"@opensumi/ide-ai-native": "3.4.4-next-1728882643.0",
"@opensumi/ide-comments": "3.4.4-next-1728882643.0",
"@opensumi/ide-core-browser": "3.4.4-next-1728882643.0",
"@opensumi/ide-core-common": "3.4.4-next-1728882643.0",
"@opensumi/ide-debug": "3.4.4-next-1728882643.0",
"@opensumi/ide-decoration": "3.4.4-next-1728882643.0",
"@opensumi/ide-design": "3.4.4-next-1728882643.0",
"@opensumi/ide-editor": "3.4.4-next-1728882643.0",
"@opensumi/ide-explorer": "3.4.4-next-1728882643.0",
"@opensumi/ide-express-file-server": "3.4.4-next-1728882643.0",
"@opensumi/ide-extension": "3.4.4-next-1728882643.0",
"@opensumi/ide-extension-storage": "3.4.4-next-1728882643.0",
"@opensumi/ide-file-scheme": "3.4.4-next-1728882643.0",
"@opensumi/ide-file-service": "3.4.4-next-1728882643.0",
"@opensumi/ide-file-tree-next": "3.4.4-next-1728882643.0",
"@opensumi/ide-i18n": "3.4.4-next-1728882643.0",
"@opensumi/ide-keymaps": "3.4.4-next-1728882643.0",
"@opensumi/ide-logs": "3.4.4-next-1728882643.0",
"@opensumi/ide-main-layout": "3.4.4-next-1728882643.0",
"@opensumi/ide-markdown": "3.4.4-next-1728882643.0",
"@opensumi/ide-markers": "3.4.4-next-1728882643.0",
"@opensumi/ide-menu-bar": "3.4.4-next-1728882643.0",
"@opensumi/ide-monaco": "3.4.4-next-1728882643.0",
"@opensumi/ide-monaco-enhance": "3.4.4-next-1728882643.0",
"@opensumi/ide-opened-editor": "3.4.4-next-1728882643.0",
"@opensumi/ide-outline": "3.4.4-next-1728882643.0",
"@opensumi/ide-output": "3.4.4-next-1728882643.0",
"@opensumi/ide-overlay": "3.4.4-next-1728882643.0",
"@opensumi/ide-preferences": "3.4.4-next-1728882643.0",
"@opensumi/ide-quick-open": "3.4.4-next-1728882643.0",
"@opensumi/ide-scm": "3.4.4-next-1728882643.0",
"@opensumi/ide-search": "3.4.4-next-1728882643.0",
"@opensumi/ide-status-bar": "3.4.4-next-1728882643.0",
"@opensumi/ide-storage": "3.4.4-next-1728882643.0",
"@opensumi/ide-testing": "3.4.4-next-1728882643.0",
"@opensumi/ide-theme": "3.4.4-next-1728882643.0",
"@opensumi/ide-toolbar": "3.4.4-next-1728882643.0",
"@opensumi/ide-variable": "3.4.4-next-1728882643.0",
"@opensumi/ide-webview": "3.4.4-next-1728882643.0",
"@opensumi/ide-workspace": "3.4.4-next-1728882643.0",
"@opensumi/ide-workspace-edit": "3.4.4-next-1728882643.0",
"@opensumi/textmate-languages": "^2.7.0",
"tslib": "^2.2.0"
},
Expand Down
60 changes: 36 additions & 24 deletions packages/core/src/core/diff-viewer/internal/base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
import { fsExtra, isFilesystemReady } from '@codeblitzjs/ide-sumi-core';
import { InlineChatHandler } from '@opensumi/ide-ai-native/lib/browser/widget/inline-chat/inline-chat.handler';
import { AppConfig, ClientAppContribution, EDITOR_COMMANDS } from '@opensumi/ide-core-browser';
import {
Disposable,
Expand All @@ -15,12 +14,13 @@ import {
URI,
} from '@opensumi/ide-core-common';
import { IResourceOpenOptions, WorkbenchEditorService } from '@opensumi/ide-editor';
import { Selection, SelectionDirection } from '@opensumi/ide-monaco';
import { ICodeEditor, Selection, SelectionDirection } from '@opensumi/ide-monaco';

import { Autowired } from '@opensumi/di';
import { InlineChatController } from '@opensumi/ide-ai-native/lib/browser/widget/inline-chat/inline-chat-controller';
import { LiveInlineDiffPreviewer } from '@opensumi/ide-ai-native/lib/browser/widget/inline-diff/inline-diff-previewer';
import { InlineDiffHandler } from '@opensumi/ide-ai-native/lib/browser/widget/inline-diff/inline-diff.handler';
import { InlineDiffController } from '@opensumi/ide-ai-native/lib/browser/widget/inline-diff/inline-diff.controller';
import { InlineDiffService } from '@opensumi/ide-ai-native/lib/browser/widget/inline-diff/inline-diff.service';
import {
IInlineStreamDiffSnapshotData,
InlineStreamDiffHandler,
Expand Down Expand Up @@ -53,12 +53,6 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
@Autowired(WorkbenchEditorService)
private readonly workbenchEditorService: WorkbenchEditorService;

@Autowired(InlineChatHandler)
protected inlineChatHandler: InlineChatHandler;

@Autowired(InlineDiffHandler)
protected inlineDiffHandler: InlineDiffHandler;

@Autowired(IEditorDocumentModelService)
private readonly editorDocumentModelService: IEditorDocumentModelService;

Expand All @@ -68,6 +62,9 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
@Autowired(ILogger)
protected logger: ILogger;

@Autowired(InlineDiffService)
protected inlineDiffService: InlineDiffService;

private readonly _onPartialEditEvent = this._disposables.add(new Emitter<IExtendPartialEditEvent>());
public readonly onPartialEditEvent: Event<IExtendPartialEditEvent> = this._onPartialEditEvent.event;

Expand Down Expand Up @@ -128,9 +125,9 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri

const editor = openResourceResult.group.codeEditor;
const index = openResourceResult.group.resources.indexOf(openResourceResult.resource);

const inlineDiffHandler = InlineDiffController.get(editor.monacoEditor)!;
if (oldContent === newContent) {
this.inlineDiffHandler.destroyPreviewer();
inlineDiffHandler.destroyPreviewer();
return;
}

Expand All @@ -144,7 +141,7 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
monacoModel.setValue(oldContent);
const fullRange = monacoModel.getFullModelRange();

const previewer = this.inlineDiffHandler.createDiffPreviewer(
const previewer = inlineDiffHandler.createDiffPreviewer(
editor.monacoEditor,
Selection.fromRange(fullRange, SelectionDirection.LTR),
{
Expand Down Expand Up @@ -226,7 +223,8 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
},
});

this.inlineDiffHandler.showPreviewerByStream(
const inlineDiffHandler = InlineDiffController.get(editor.monacoEditor)!;
inlineDiffHandler.showPreviewerByStream(
editor.monacoEditor,
{
crossSelection: Selection.fromRange(fullRange, SelectionDirection.LTR),
Expand Down Expand Up @@ -327,16 +325,17 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
}
}

getDiffInfoForUri = (uri: URI) => {
getDiffInfoForUri = (uri: URI, editor: ICodeEditor) => {
let resourceDiff: InlineStreamDiffHandler | undefined;
const controller = InlineDiffController.get(editor)!;

const previewer = this.inlineDiffHandler.getPreviewer() as LiveInlineDiffPreviewer;
const previewer = controller.getPreviewer() as LiveInlineDiffPreviewer;
if (previewer && previewer.isModel(uri.toString())) {
resourceDiff = previewer.getNode();
}

if (!resourceDiff) {
resourceDiff = (this.inlineDiffHandler as any)._previewerNodeStore.get(uri.toString()) as
resourceDiff = controller.getStoredState(uri.toString()) as
| InlineStreamDiffHandler
| undefined;
}
Expand All @@ -349,13 +348,22 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
};
};

getCurrentInlineDiffHandler() {
const editor = this.workbenchEditorService.currentEditor;
if (!editor) {
throw new Error('No active editor');
}

return InlineDiffController.get(editor.monacoEditor)!;
}

async initialize(): Promise<void> {
await isFilesystemReady();

const disposable = new Disposable();
this._disposables.add(disposable);

disposable.addDispose(this.inlineDiffHandler.onPartialEditEvent((e) => {
disposable.addDispose(this.inlineDiffService.onPartialEdit((e) => {
const path = e.uri.path;

this._onPartialEditEvent.fire({
Expand All @@ -379,7 +387,8 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
};

if (e?.uri) {
const diffInfo = this.getDiffInfoForUri(e.uri);
const editor = this.workbenchEditorService.currentEditor!;
const diffInfo = this.getDiffInfoForUri(e.uri, editor.monacoEditor);
event.diffNum = diffInfo.unresolved;
Object.assign(event, diffInfo);
}
Expand Down Expand Up @@ -414,15 +423,17 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
return await fsExtra.readFile(fullPath, 'utf-8');
},
acceptAllPartialEdit: async () => {
if (this.inlineDiffHandler) {
this.inlineDiffHandler.handleAction(
const handler = this.getCurrentInlineDiffHandler();
if (handler) {
handler.handleAction(
EResultKind.ACCEPT,
);
}
},
rejectAllPartialEdit: async () => {
if (this.inlineDiffHandler) {
this.inlineDiffHandler.handleAction(
const handler = this.getCurrentInlineDiffHandler();
if (handler) {
handler.handleAction(
EResultKind.DISCARD,
);
}
Expand All @@ -432,15 +443,16 @@ export class DiffViewerContribution implements ClientAppContribution, MenuContri
},
getCurrentTab: () => {
const allTabs = this.getAllTabs();
const currentEditorFilePath = this.getFilePathForEditor(this.workbenchEditorService.currentEditor!);
const editor = this.workbenchEditorService.currentEditor!;
const currentEditorFilePath = this.getFilePathForEditor(editor);
const currentTabIdx = allTabs.findIndex((tab) => {
return tab.filePath === currentEditorFilePath;
});
if (currentTabIdx === -1) {
return;
}
const uri = this.getFullPathUri(currentEditorFilePath);
const diffInfo = this.getDiffInfoForUri(uri);
const diffInfo = this.getDiffInfoForUri(uri, editor.monacoEditor);

const fileName = path.basename(currentEditorFilePath);
return {
Expand Down
16 changes: 8 additions & 8 deletions packages/sumi-core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,14 @@
"@codeblitzjs/ide-common": "workspace:*",
"@codeblitzjs/ide-registry": "workspace:*",
"@opensumi/di": "^1.0.0",
"@opensumi/ide-ai-native": "3.3.3",
"@opensumi/ide-core-browser": "3.3.3",
"@opensumi/ide-core-common": "3.3.3",
"@opensumi/ide-debug": "3.3.3",
"@opensumi/ide-extension": "3.3.3",
"@opensumi/ide-file-scheme": "3.3.3",
"@opensumi/ide-file-service": "3.3.3",
"@opensumi/ide-logs": "3.3.3",
"@opensumi/ide-ai-native": "3.4.4-next-1728882643.0",
"@opensumi/ide-core-browser": "3.4.4-next-1728882643.0",
"@opensumi/ide-core-common": "3.4.4-next-1728882643.0",
"@opensumi/ide-debug": "3.4.4-next-1728882643.0",
"@opensumi/ide-extension": "3.4.4-next-1728882643.0",
"@opensumi/ide-file-scheme": "3.4.4-next-1728882643.0",
"@opensumi/ide-file-service": "3.4.4-next-1728882643.0",
"@opensumi/ide-logs": "3.4.4-next-1728882643.0",
"assert": "^2.0.0",
"fs-extra-factory": "^0.2.1",
"iconv-lite-umd": "^0.6.8",
Expand Down
6 changes: 3 additions & 3 deletions packages/sumi-core/resources/manifest.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"webview": "webview.66e57793.js",
"webview/index.html": "webview.805ab470/index.html",
"worker-host": "worker-host.490aafa0.js"
"webview": "webview.9ae5c833.js",
"webview/index.html": "webview.25aac54e/index.html",
"worker-host": "worker-host.d80be369.js"
}
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en" style="width: 100%; height: 100%;"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Webview Panel Container</title><script crossorigin src="../webview.66e57793.js"></script></head><body style="margin: 0; overflow: hidden; width: 100%; height: 100%"></body></html>
<!doctype html><html lang="en" style="width: 100%; height: 100%;"><head><meta charset="UTF-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta http-equiv="X-UA-Compatible" content="ie=edge"><title>Webview Panel Container</title><script crossorigin src="../webview.9ae5c833.js"></script></head><body style="margin: 0; overflow: hidden; width: 100%; height: 100%"></body></html>
Loading

0 comments on commit ed1f678

Please sign in to comment.