@opensumi/ide-editor 3.3.4-next-1726129502.0 → 3.3.4-next-1726136311.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/browser/editor-collection.service.d.ts +2 -0
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +15 -1
- package/lib/browser/editor-collection.service.js.map +1 -1
- package/lib/browser/index.d.ts.map +1 -1
- package/lib/browser/index.js +5 -0
- package/lib/browser/index.js.map +1 -1
- package/lib/browser/notebook.service.d.ts +20 -0
- package/lib/browser/notebook.service.d.ts.map +1 -0
- package/lib/browser/notebook.service.js +24 -0
- package/lib/browser/notebook.service.js.map +1 -0
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +1 -0
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/editor.d.ts +1 -0
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js.map +1 -1
- package/lib/common/index.d.ts +4 -3
- package/lib/common/index.d.ts.map +1 -1
- package/lib/common/index.js +4 -3
- package/lib/common/index.js.map +1 -1
- package/lib/common/language.d.ts +1 -0
- package/lib/common/language.d.ts.map +1 -1
- package/lib/common/notebook.d.ts +169 -0
- package/lib/common/notebook.d.ts.map +1 -0
- package/lib/common/notebook.js +26 -0
- package/lib/common/notebook.js.map +1 -0
- package/package.json +14 -14
- package/src/browser/editor-collection.service.ts +18 -1
- package/src/browser/index.ts +6 -0
- package/src/browser/notebook.service.ts +19 -0
- package/src/browser/workbench-editor.service.ts +1 -0
- package/src/common/editor.ts +2 -0
- package/src/common/index.ts +4 -3
- package/src/common/language.ts +1 -0
- package/src/common/notebook.ts +196 -0
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { Event, IRange, UriComponents } from '@opensumi/ide-core-common';
|
|
3
|
+
export declare enum NotebookCellsChangeType {
|
|
4
|
+
ModelChange = 1,
|
|
5
|
+
Move = 2,
|
|
6
|
+
ChangeCellLanguage = 5,
|
|
7
|
+
Initialize = 6,
|
|
8
|
+
ChangeCellMetadata = 7,
|
|
9
|
+
Output = 8,
|
|
10
|
+
OutputItem = 9,
|
|
11
|
+
ChangeCellContent = 10,
|
|
12
|
+
ChangeDocumentMetadata = 11,
|
|
13
|
+
ChangeCellInternalMetadata = 12,
|
|
14
|
+
ChangeCellMime = 13,
|
|
15
|
+
Unknown = 100
|
|
16
|
+
}
|
|
17
|
+
export type NotebookCellTextModelSplice<T> = [start: number, deleteCount: number, newItems: T[]];
|
|
18
|
+
/**
|
|
19
|
+
* [start, end]
|
|
20
|
+
*/
|
|
21
|
+
export interface ICellRange {
|
|
22
|
+
/**
|
|
23
|
+
* zero based index
|
|
24
|
+
*/
|
|
25
|
+
start: number;
|
|
26
|
+
/**
|
|
27
|
+
* zero based index
|
|
28
|
+
*/
|
|
29
|
+
end: number;
|
|
30
|
+
}
|
|
31
|
+
export declare enum CellKind {
|
|
32
|
+
Markup = 1,
|
|
33
|
+
Code = 2
|
|
34
|
+
}
|
|
35
|
+
export interface NotebookCellMetadata {
|
|
36
|
+
/**
|
|
37
|
+
* custom metadata
|
|
38
|
+
*/
|
|
39
|
+
[key: string]: unknown;
|
|
40
|
+
}
|
|
41
|
+
export interface ICellExecutionError {
|
|
42
|
+
message: string;
|
|
43
|
+
stack: string | undefined;
|
|
44
|
+
uri: UriComponents;
|
|
45
|
+
location: IRange | undefined;
|
|
46
|
+
}
|
|
47
|
+
export type NotebookDocumentMetadata = Record<string, unknown>;
|
|
48
|
+
export interface NotebookCellInternalMetadata {
|
|
49
|
+
executionId?: string;
|
|
50
|
+
executionOrder?: number;
|
|
51
|
+
lastRunSuccess?: boolean;
|
|
52
|
+
runStartTime?: number;
|
|
53
|
+
runStartTimeAdjustment?: number;
|
|
54
|
+
runEndTime?: number;
|
|
55
|
+
renderDuration?: {
|
|
56
|
+
[key: string]: number;
|
|
57
|
+
};
|
|
58
|
+
error?: ICellExecutionError;
|
|
59
|
+
}
|
|
60
|
+
export interface NotebookOutputItemDto {
|
|
61
|
+
readonly mime: string;
|
|
62
|
+
readonly valueBytes: Buffer;
|
|
63
|
+
}
|
|
64
|
+
export interface NotebookOutputDto {
|
|
65
|
+
items: NotebookOutputItemDto[];
|
|
66
|
+
outputId: string;
|
|
67
|
+
metadata?: Record<string, any>;
|
|
68
|
+
}
|
|
69
|
+
export interface NotebookCellDto {
|
|
70
|
+
handle: number;
|
|
71
|
+
uri: UriComponents;
|
|
72
|
+
eol: string;
|
|
73
|
+
source: string[];
|
|
74
|
+
language: string;
|
|
75
|
+
mime?: string;
|
|
76
|
+
cellKind: CellKind;
|
|
77
|
+
outputs: NotebookOutputDto[];
|
|
78
|
+
metadata?: NotebookCellMetadata;
|
|
79
|
+
internalMetadata?: NotebookCellInternalMetadata;
|
|
80
|
+
}
|
|
81
|
+
export interface NotebookCellDataDto {
|
|
82
|
+
source: string;
|
|
83
|
+
language: string;
|
|
84
|
+
mime: string | undefined;
|
|
85
|
+
cellKind: CellKind;
|
|
86
|
+
outputs: NotebookOutputDto[];
|
|
87
|
+
metadata?: NotebookCellMetadata;
|
|
88
|
+
internalMetadata?: NotebookCellInternalMetadata;
|
|
89
|
+
}
|
|
90
|
+
export interface NotebookDataDto {
|
|
91
|
+
readonly cells: NotebookCellDataDto[];
|
|
92
|
+
readonly metadata: NotebookDocumentMetadata;
|
|
93
|
+
}
|
|
94
|
+
export interface NotebookCellsChangeLanguageEvent {
|
|
95
|
+
readonly kind: NotebookCellsChangeType.ChangeCellLanguage;
|
|
96
|
+
readonly index: number;
|
|
97
|
+
readonly language: string;
|
|
98
|
+
}
|
|
99
|
+
export interface NotebookCellsChangeMimeEvent {
|
|
100
|
+
readonly kind: NotebookCellsChangeType.ChangeCellMime;
|
|
101
|
+
readonly index: number;
|
|
102
|
+
readonly mime: string | undefined;
|
|
103
|
+
}
|
|
104
|
+
export interface NotebookCellsChangeMetadataEvent {
|
|
105
|
+
readonly kind: NotebookCellsChangeType.ChangeCellMetadata;
|
|
106
|
+
readonly index: number;
|
|
107
|
+
readonly metadata: NotebookCellMetadata;
|
|
108
|
+
}
|
|
109
|
+
export interface NotebookCellsChangeInternalMetadataEvent {
|
|
110
|
+
readonly kind: NotebookCellsChangeType.ChangeCellInternalMetadata;
|
|
111
|
+
readonly index: number;
|
|
112
|
+
readonly internalMetadata: NotebookCellInternalMetadata;
|
|
113
|
+
}
|
|
114
|
+
export interface NotebookCellContentChangeEvent {
|
|
115
|
+
readonly kind: NotebookCellsChangeType.ChangeCellContent;
|
|
116
|
+
readonly index: number;
|
|
117
|
+
}
|
|
118
|
+
export type NotebookRawContentEventDto = {
|
|
119
|
+
readonly kind: NotebookCellsChangeType.ModelChange;
|
|
120
|
+
readonly changes: NotebookCellTextModelSplice<NotebookCellDto>[];
|
|
121
|
+
} | {
|
|
122
|
+
readonly kind: NotebookCellsChangeType.Move;
|
|
123
|
+
readonly index: number;
|
|
124
|
+
readonly length: number;
|
|
125
|
+
readonly newIdx: number;
|
|
126
|
+
} | {
|
|
127
|
+
readonly kind: NotebookCellsChangeType.Output;
|
|
128
|
+
readonly index: number;
|
|
129
|
+
readonly outputs: NotebookOutputDto[];
|
|
130
|
+
} | {
|
|
131
|
+
readonly kind: NotebookCellsChangeType.OutputItem;
|
|
132
|
+
readonly index: number;
|
|
133
|
+
readonly outputId: string;
|
|
134
|
+
readonly outputItems: NotebookOutputItemDto[];
|
|
135
|
+
readonly append: boolean;
|
|
136
|
+
} | NotebookCellsChangeLanguageEvent | NotebookCellsChangeMimeEvent | NotebookCellsChangeMetadataEvent | NotebookCellsChangeInternalMetadataEvent | NotebookCellContentChangeEvent;
|
|
137
|
+
export interface NotebookCellsChangedEventDto {
|
|
138
|
+
readonly rawEvents: NotebookRawContentEventDto[];
|
|
139
|
+
readonly versionId: number;
|
|
140
|
+
}
|
|
141
|
+
export interface INotebookModelAddedData {
|
|
142
|
+
uri: UriComponents;
|
|
143
|
+
versionId: number;
|
|
144
|
+
cells: NotebookCellDto[];
|
|
145
|
+
viewType: string;
|
|
146
|
+
metadata?: NotebookDocumentMetadata;
|
|
147
|
+
}
|
|
148
|
+
export interface NotebookDocumentChangeDto {
|
|
149
|
+
uri: UriComponents;
|
|
150
|
+
event: NotebookCellsChangedEventDto;
|
|
151
|
+
isDirty: boolean;
|
|
152
|
+
metadata?: NotebookDocumentMetadata;
|
|
153
|
+
}
|
|
154
|
+
export declare const INotebookService: unique symbol;
|
|
155
|
+
export interface INotebookService {
|
|
156
|
+
createNotebook: (data?: NotebookDataDto) => Promise<{
|
|
157
|
+
uri: UriComponents;
|
|
158
|
+
}>;
|
|
159
|
+
openNotebook: (uriComponents: UriComponents) => Promise<{
|
|
160
|
+
uri: UriComponents;
|
|
161
|
+
}>;
|
|
162
|
+
saveNotebook: (uriComponents: UriComponents) => Promise<boolean>;
|
|
163
|
+
onDidOpenNotebookDocument: Event<INotebookModelAddedData>;
|
|
164
|
+
onDidCloseNotebookDocument: Event<UriComponents>;
|
|
165
|
+
onDidSaveNotebookDocument: Event<UriComponents>;
|
|
166
|
+
onDidChangeNotebookDocument: Event<NotebookDocumentChangeDto>;
|
|
167
|
+
}
|
|
168
|
+
export declare const notebookCellScheme = "vscode-notebook-cell";
|
|
169
|
+
//# sourceMappingURL=notebook.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notebook.d.ts","sourceRoot":"","sources":["../../src/common/notebook.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAEzE,oBAAY,uBAAuB;IACjC,WAAW,IAAI;IACf,IAAI,IAAI;IACR,kBAAkB,IAAI;IACtB,UAAU,IAAI;IACd,kBAAkB,IAAI;IACtB,MAAM,IAAI;IACV,UAAU,IAAI;IACd,iBAAiB,KAAK;IACtB,sBAAsB,KAAK;IAC3B,0BAA0B,KAAK;IAC/B,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,KAAK,CAAC,yBAAyB,CAAC,CAAC;CAC/D;AAED,eAAO,MAAM,kBAAkB,yBAAyB,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.notebookCellScheme = exports.INotebookService = exports.CellKind = exports.NotebookCellsChangeType = void 0;
|
|
4
|
+
var NotebookCellsChangeType;
|
|
5
|
+
(function (NotebookCellsChangeType) {
|
|
6
|
+
NotebookCellsChangeType[NotebookCellsChangeType["ModelChange"] = 1] = "ModelChange";
|
|
7
|
+
NotebookCellsChangeType[NotebookCellsChangeType["Move"] = 2] = "Move";
|
|
8
|
+
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellLanguage"] = 5] = "ChangeCellLanguage";
|
|
9
|
+
NotebookCellsChangeType[NotebookCellsChangeType["Initialize"] = 6] = "Initialize";
|
|
10
|
+
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellMetadata"] = 7] = "ChangeCellMetadata";
|
|
11
|
+
NotebookCellsChangeType[NotebookCellsChangeType["Output"] = 8] = "Output";
|
|
12
|
+
NotebookCellsChangeType[NotebookCellsChangeType["OutputItem"] = 9] = "OutputItem";
|
|
13
|
+
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellContent"] = 10] = "ChangeCellContent";
|
|
14
|
+
NotebookCellsChangeType[NotebookCellsChangeType["ChangeDocumentMetadata"] = 11] = "ChangeDocumentMetadata";
|
|
15
|
+
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellInternalMetadata"] = 12] = "ChangeCellInternalMetadata";
|
|
16
|
+
NotebookCellsChangeType[NotebookCellsChangeType["ChangeCellMime"] = 13] = "ChangeCellMime";
|
|
17
|
+
NotebookCellsChangeType[NotebookCellsChangeType["Unknown"] = 100] = "Unknown";
|
|
18
|
+
})(NotebookCellsChangeType = exports.NotebookCellsChangeType || (exports.NotebookCellsChangeType = {}));
|
|
19
|
+
var CellKind;
|
|
20
|
+
(function (CellKind) {
|
|
21
|
+
CellKind[CellKind["Markup"] = 1] = "Markup";
|
|
22
|
+
CellKind[CellKind["Code"] = 2] = "Code";
|
|
23
|
+
})(CellKind = exports.CellKind || (exports.CellKind = {}));
|
|
24
|
+
exports.INotebookService = Symbol('INotebookService');
|
|
25
|
+
exports.notebookCellScheme = 'vscode-notebook-cell';
|
|
26
|
+
//# sourceMappingURL=notebook.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"notebook.js","sourceRoot":"","sources":["../../src/common/notebook.ts"],"names":[],"mappings":";;;AAEA,IAAY,uBAaX;AAbD,WAAY,uBAAuB;IACjC,mFAAe,CAAA;IACf,qEAAQ,CAAA;IACR,iGAAsB,CAAA;IACtB,iFAAc,CAAA;IACd,iGAAsB,CAAA;IACtB,yEAAU,CAAA;IACV,iFAAc,CAAA;IACd,gGAAsB,CAAA;IACtB,0GAA2B,CAAA;IAC3B,kHAA+B,CAAA;IAC/B,0FAAmB,CAAA;IACnB,6EAAa,CAAA;AACf,CAAC,EAbW,uBAAuB,GAAvB,+BAAuB,KAAvB,+BAAuB,QAalC;AAmBD,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,2CAAU,CAAA;IACV,uCAAQ,CAAA;AACV,CAAC,EAHW,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAGnB;AAiJY,QAAA,gBAAgB,GAAG,MAAM,CAAC,kBAAkB,CAAC,CAAC;AAa9C,QAAA,kBAAkB,GAAG,sBAAsB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-editor",
|
|
3
|
-
"version": "3.3.4-next-
|
|
3
|
+
"version": "3.3.4-next-1726136311.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
"url": "git@github.com:opensumi/core.git"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@opensumi/ide-core-common": "3.3.4-next-
|
|
21
|
-
"@opensumi/ide-core-node": "3.3.4-next-
|
|
22
|
-
"@opensumi/ide-file-service": "3.3.4-next-
|
|
23
|
-
"@opensumi/ide-monaco": "3.3.4-next-
|
|
24
|
-
"@opensumi/ide-utils": "3.3.4-next-
|
|
20
|
+
"@opensumi/ide-core-common": "3.3.4-next-1726136311.0",
|
|
21
|
+
"@opensumi/ide-core-node": "3.3.4-next-1726136311.0",
|
|
22
|
+
"@opensumi/ide-file-service": "3.3.4-next-1726136311.0",
|
|
23
|
+
"@opensumi/ide-monaco": "3.3.4-next-1726136311.0",
|
|
24
|
+
"@opensumi/ide-utils": "3.3.4-next-1726136311.0",
|
|
25
25
|
"vscode-oniguruma": "1.5.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@opensumi/ide-components": "3.3.4-next-
|
|
29
|
-
"@opensumi/ide-core-browser": "3.3.4-next-
|
|
30
|
-
"@opensumi/ide-dev-tool": "3.3.4-next-
|
|
31
|
-
"@opensumi/ide-overlay": "3.3.4-next-
|
|
32
|
-
"@opensumi/ide-quick-open": "3.3.4-next-
|
|
33
|
-
"@opensumi/ide-theme": "3.3.4-next-
|
|
34
|
-
"@opensumi/ide-workspace": "3.3.4-next-
|
|
28
|
+
"@opensumi/ide-components": "3.3.4-next-1726136311.0",
|
|
29
|
+
"@opensumi/ide-core-browser": "3.3.4-next-1726136311.0",
|
|
30
|
+
"@opensumi/ide-dev-tool": "3.3.4-next-1726136311.0",
|
|
31
|
+
"@opensumi/ide-overlay": "3.3.4-next-1726136311.0",
|
|
32
|
+
"@opensumi/ide-quick-open": "3.3.4-next-1726136311.0",
|
|
33
|
+
"@opensumi/ide-theme": "3.3.4-next-1726136311.0",
|
|
34
|
+
"@opensumi/ide-workspace": "3.3.4-next-1726136311.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "4229b468fbb0cb27a83bc32e81cb556abda329e0"
|
|
37
37
|
}
|
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
Emitter as EventEmitter,
|
|
10
10
|
ILineChange,
|
|
11
11
|
ISelection,
|
|
12
|
+
LRUCache,
|
|
12
13
|
OnEvent,
|
|
13
14
|
URI,
|
|
14
15
|
WithEventBus,
|
|
@@ -604,6 +605,8 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
604
605
|
|
|
605
606
|
public onRefOpen = this._onRefOpen.event;
|
|
606
607
|
|
|
608
|
+
private diffEditorModelCache = new LRUCache<string, monaco.editor.IDiffEditorViewModel>(100);
|
|
609
|
+
|
|
607
610
|
protected saveCurrentState() {
|
|
608
611
|
if (this.currentUri) {
|
|
609
612
|
const state = this.monacoDiffEditor.saveViewState();
|
|
@@ -635,6 +638,11 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
635
638
|
);
|
|
636
639
|
}
|
|
637
640
|
|
|
641
|
+
disposeModel(originalUri: string, modifiedUri: string) {
|
|
642
|
+
const key = `${originalUri}-${modifiedUri}`;
|
|
643
|
+
this.diffEditorModelCache.delete(key);
|
|
644
|
+
}
|
|
645
|
+
|
|
638
646
|
async compare(
|
|
639
647
|
originalDocModelRef: IEditorDocumentModelRef,
|
|
640
648
|
modifiedDocModelRef: IEditorDocumentModelRef,
|
|
@@ -649,7 +657,13 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
649
657
|
}
|
|
650
658
|
const original = this.originalDocModel.getMonacoModel();
|
|
651
659
|
const modified = this.modifiedDocModel.getMonacoModel();
|
|
652
|
-
const
|
|
660
|
+
const key = `${original.uri.toString()}-${modified.uri.toString()}`;
|
|
661
|
+
let model = this.diffEditorModelCache.get(key);
|
|
662
|
+
if (!model) {
|
|
663
|
+
model = this.monacoDiffEditor.createViewModel({ original, modified });
|
|
664
|
+
this.diffEditorModelCache.set(key, model);
|
|
665
|
+
}
|
|
666
|
+
|
|
653
667
|
this.monacoDiffEditor.setModel(model);
|
|
654
668
|
|
|
655
669
|
if (rawUri) {
|
|
@@ -658,6 +672,7 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
658
672
|
this.currentUri = URI.from({
|
|
659
673
|
scheme: DIFF_SCHEME,
|
|
660
674
|
query: URI.stringifyQuery({
|
|
675
|
+
name,
|
|
661
676
|
original: this.originalDocModel!.uri.toString(),
|
|
662
677
|
modified: this.modifiedDocModel!.uri.toString(),
|
|
663
678
|
}),
|
|
@@ -682,6 +697,8 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
682
697
|
currentEditor.revealRangeInCenter(range);
|
|
683
698
|
});
|
|
684
699
|
});
|
|
700
|
+
} else {
|
|
701
|
+
this.restoreState();
|
|
685
702
|
}
|
|
686
703
|
this._onRefOpen.fire(originalDocModelRef);
|
|
687
704
|
this._onRefOpen.fire(modifiedDocModelRef);
|
package/src/browser/index.ts
CHANGED
|
@@ -52,6 +52,7 @@ import {
|
|
|
52
52
|
MonacoCommandService,
|
|
53
53
|
} from './monaco-contrib/command/command.service';
|
|
54
54
|
import { TextmateService } from './monaco-contrib/tokenizer/textmate.service';
|
|
55
|
+
import { NotebookService } from './notebook.service';
|
|
55
56
|
import { EditorPreferenceContribution } from './preference/contribution';
|
|
56
57
|
import { EditorPreferences, editorPreferenceSchema } from './preference/schema';
|
|
57
58
|
import { ResourceServiceImpl } from './resource.service';
|
|
@@ -65,6 +66,7 @@ import {
|
|
|
65
66
|
IEditorFeatureRegistry,
|
|
66
67
|
IEditorTabService,
|
|
67
68
|
ILanguageStatusService,
|
|
69
|
+
INotebookService,
|
|
68
70
|
} from './types';
|
|
69
71
|
import { WorkbenchEditorServiceImpl } from './workbench-editor.service';
|
|
70
72
|
export * from './doc-cache';
|
|
@@ -169,6 +171,10 @@ export class EditorModule extends BrowserModule {
|
|
|
169
171
|
token: IEditorTabService,
|
|
170
172
|
useClass: EditorTabService,
|
|
171
173
|
},
|
|
174
|
+
{
|
|
175
|
+
token: INotebookService,
|
|
176
|
+
useClass: NotebookService,
|
|
177
|
+
},
|
|
172
178
|
EditorPreferenceContribution,
|
|
173
179
|
DefaultDiffEditorContribution,
|
|
174
180
|
MergeEditorContribution,
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Injectable } from '@opensumi/di';
|
|
2
|
+
import { Emitter, Event, UriComponents, WithEventBus } from '@opensumi/ide-core-browser';
|
|
3
|
+
|
|
4
|
+
import type { INotebookModelAddedData, INotebookService, NotebookDataDto, NotebookDocumentChangeDto } from './types';
|
|
5
|
+
|
|
6
|
+
@Injectable()
|
|
7
|
+
export class NotebookService extends WithEventBus implements INotebookService {
|
|
8
|
+
createNotebook: (data?: NotebookDataDto) => Promise<{ uri: UriComponents }>;
|
|
9
|
+
openNotebook: (uriComponents: UriComponents) => Promise<{ uri: UriComponents }>;
|
|
10
|
+
saveNotebook: (uriComponents: UriComponents) => Promise<boolean>;
|
|
11
|
+
protected _onDidOpenNotebookDocument = new Emitter<INotebookModelAddedData>();
|
|
12
|
+
onDidOpenNotebookDocument: Event<INotebookModelAddedData> = this._onDidOpenNotebookDocument.event;
|
|
13
|
+
protected _onDidCloseNotebookDocument = new Emitter<UriComponents>();
|
|
14
|
+
onDidCloseNotebookDocument: Event<UriComponents> = this._onDidCloseNotebookDocument.event;
|
|
15
|
+
protected _onDidSaveNotebookDocument = new Emitter<UriComponents>();
|
|
16
|
+
onDidSaveNotebookDocument: Event<UriComponents> = this._onDidSaveNotebookDocument.event;
|
|
17
|
+
protected _onDidChangeNotebookDocument = new Emitter<NotebookDocumentChangeDto>();
|
|
18
|
+
onDidChangeNotebookDocument: Event<NotebookDocumentChangeDto> = this._onDidChangeNotebookDocument.event;
|
|
19
|
+
}
|
|
@@ -1568,6 +1568,7 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1568
1568
|
const query = uri.getParsedQuery();
|
|
1569
1569
|
this.doDisposeDocRef(new URI(query.original));
|
|
1570
1570
|
this.doDisposeDocRef(new URI(query.modified));
|
|
1571
|
+
this.diffEditor.disposeModel(query.original, query.modified);
|
|
1571
1572
|
} else if (uri.scheme === 'mergeEditor') {
|
|
1572
1573
|
this.mergeEditor && this.mergeEditor.dispose();
|
|
1573
1574
|
} else {
|
package/src/common/editor.ts
CHANGED
package/src/common/index.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
export * from './components';
|
|
1
2
|
export * from './doc-cache';
|
|
2
3
|
export * from './editor';
|
|
3
|
-
export * from './resource';
|
|
4
4
|
export * from './language';
|
|
5
|
-
export * from './utils';
|
|
6
5
|
export * from './language-status';
|
|
7
|
-
export * from './
|
|
6
|
+
export * from './notebook';
|
|
7
|
+
export * from './resource';
|
|
8
|
+
export * from './utils';
|
package/src/common/language.ts
CHANGED
|
@@ -201,6 +201,7 @@ export interface LanguageFilter {
|
|
|
201
201
|
scheme?: string;
|
|
202
202
|
pattern?: string | IRelativePattern;
|
|
203
203
|
hasAccessToAllModels?: boolean;
|
|
204
|
+
notebookType?: string;
|
|
204
205
|
}
|
|
205
206
|
|
|
206
207
|
export type LanguageSelector = string | LanguageFilter | (string | LanguageFilter)[];
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Event, IRange, UriComponents } from '@opensumi/ide-core-common';
|
|
2
|
+
|
|
3
|
+
export enum NotebookCellsChangeType {
|
|
4
|
+
ModelChange = 1,
|
|
5
|
+
Move = 2,
|
|
6
|
+
ChangeCellLanguage = 5,
|
|
7
|
+
Initialize = 6,
|
|
8
|
+
ChangeCellMetadata = 7,
|
|
9
|
+
Output = 8,
|
|
10
|
+
OutputItem = 9,
|
|
11
|
+
ChangeCellContent = 10,
|
|
12
|
+
ChangeDocumentMetadata = 11,
|
|
13
|
+
ChangeCellInternalMetadata = 12,
|
|
14
|
+
ChangeCellMime = 13,
|
|
15
|
+
Unknown = 100,
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export type NotebookCellTextModelSplice<T> = [start: number, deleteCount: number, newItems: T[]];
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* [start, end]
|
|
22
|
+
*/
|
|
23
|
+
export interface ICellRange {
|
|
24
|
+
/**
|
|
25
|
+
* zero based index
|
|
26
|
+
*/
|
|
27
|
+
start: number;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* zero based index
|
|
31
|
+
*/
|
|
32
|
+
end: number;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
export enum CellKind {
|
|
36
|
+
Markup = 1,
|
|
37
|
+
Code = 2,
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface NotebookCellMetadata {
|
|
41
|
+
/**
|
|
42
|
+
* custom metadata
|
|
43
|
+
*/
|
|
44
|
+
[key: string]: unknown;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
export interface ICellExecutionError {
|
|
48
|
+
message: string;
|
|
49
|
+
stack: string | undefined;
|
|
50
|
+
uri: UriComponents;
|
|
51
|
+
location: IRange | undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
export type NotebookDocumentMetadata = Record<string, unknown>;
|
|
55
|
+
export interface NotebookCellInternalMetadata {
|
|
56
|
+
executionId?: string;
|
|
57
|
+
executionOrder?: number;
|
|
58
|
+
lastRunSuccess?: boolean;
|
|
59
|
+
runStartTime?: number;
|
|
60
|
+
runStartTimeAdjustment?: number;
|
|
61
|
+
runEndTime?: number;
|
|
62
|
+
renderDuration?: { [key: string]: number };
|
|
63
|
+
error?: ICellExecutionError;
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export interface NotebookOutputItemDto {
|
|
67
|
+
readonly mime: string;
|
|
68
|
+
readonly valueBytes: Buffer;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export interface NotebookOutputDto {
|
|
72
|
+
items: NotebookOutputItemDto[];
|
|
73
|
+
outputId: string;
|
|
74
|
+
metadata?: Record<string, any>;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export interface NotebookCellDto {
|
|
78
|
+
handle: number;
|
|
79
|
+
uri: UriComponents;
|
|
80
|
+
eol: string;
|
|
81
|
+
source: string[];
|
|
82
|
+
language: string;
|
|
83
|
+
mime?: string;
|
|
84
|
+
cellKind: CellKind;
|
|
85
|
+
outputs: NotebookOutputDto[];
|
|
86
|
+
metadata?: NotebookCellMetadata;
|
|
87
|
+
internalMetadata?: NotebookCellInternalMetadata;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export interface NotebookCellDataDto {
|
|
91
|
+
source: string;
|
|
92
|
+
language: string;
|
|
93
|
+
mime: string | undefined;
|
|
94
|
+
cellKind: CellKind;
|
|
95
|
+
outputs: NotebookOutputDto[];
|
|
96
|
+
metadata?: NotebookCellMetadata;
|
|
97
|
+
internalMetadata?: NotebookCellInternalMetadata;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface NotebookDataDto {
|
|
101
|
+
readonly cells: NotebookCellDataDto[];
|
|
102
|
+
readonly metadata: NotebookDocumentMetadata;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export interface NotebookCellsChangeLanguageEvent {
|
|
106
|
+
readonly kind: NotebookCellsChangeType.ChangeCellLanguage;
|
|
107
|
+
readonly index: number;
|
|
108
|
+
readonly language: string;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
export interface NotebookCellsChangeMimeEvent {
|
|
112
|
+
readonly kind: NotebookCellsChangeType.ChangeCellMime;
|
|
113
|
+
readonly index: number;
|
|
114
|
+
readonly mime: string | undefined;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
export interface NotebookCellsChangeMetadataEvent {
|
|
118
|
+
readonly kind: NotebookCellsChangeType.ChangeCellMetadata;
|
|
119
|
+
readonly index: number;
|
|
120
|
+
readonly metadata: NotebookCellMetadata;
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
export interface NotebookCellsChangeInternalMetadataEvent {
|
|
124
|
+
readonly kind: NotebookCellsChangeType.ChangeCellInternalMetadata;
|
|
125
|
+
readonly index: number;
|
|
126
|
+
readonly internalMetadata: NotebookCellInternalMetadata;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export interface NotebookCellContentChangeEvent {
|
|
130
|
+
readonly kind: NotebookCellsChangeType.ChangeCellContent;
|
|
131
|
+
readonly index: number;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
export type NotebookRawContentEventDto =
|
|
135
|
+
| {
|
|
136
|
+
readonly kind: NotebookCellsChangeType.ModelChange;
|
|
137
|
+
readonly changes: NotebookCellTextModelSplice<NotebookCellDto>[];
|
|
138
|
+
}
|
|
139
|
+
| {
|
|
140
|
+
readonly kind: NotebookCellsChangeType.Move;
|
|
141
|
+
readonly index: number;
|
|
142
|
+
readonly length: number;
|
|
143
|
+
readonly newIdx: number;
|
|
144
|
+
}
|
|
145
|
+
| {
|
|
146
|
+
readonly kind: NotebookCellsChangeType.Output;
|
|
147
|
+
readonly index: number;
|
|
148
|
+
readonly outputs: NotebookOutputDto[];
|
|
149
|
+
}
|
|
150
|
+
| {
|
|
151
|
+
readonly kind: NotebookCellsChangeType.OutputItem;
|
|
152
|
+
readonly index: number;
|
|
153
|
+
readonly outputId: string;
|
|
154
|
+
readonly outputItems: NotebookOutputItemDto[];
|
|
155
|
+
readonly append: boolean;
|
|
156
|
+
}
|
|
157
|
+
| NotebookCellsChangeLanguageEvent
|
|
158
|
+
| NotebookCellsChangeMimeEvent
|
|
159
|
+
| NotebookCellsChangeMetadataEvent
|
|
160
|
+
| NotebookCellsChangeInternalMetadataEvent
|
|
161
|
+
| NotebookCellContentChangeEvent;
|
|
162
|
+
|
|
163
|
+
export interface NotebookCellsChangedEventDto {
|
|
164
|
+
readonly rawEvents: NotebookRawContentEventDto[];
|
|
165
|
+
readonly versionId: number;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export interface INotebookModelAddedData {
|
|
169
|
+
uri: UriComponents;
|
|
170
|
+
versionId: number;
|
|
171
|
+
cells: NotebookCellDto[];
|
|
172
|
+
viewType: string;
|
|
173
|
+
metadata?: NotebookDocumentMetadata;
|
|
174
|
+
}
|
|
175
|
+
|
|
176
|
+
export interface NotebookDocumentChangeDto {
|
|
177
|
+
uri: UriComponents;
|
|
178
|
+
event: NotebookCellsChangedEventDto;
|
|
179
|
+
isDirty: boolean;
|
|
180
|
+
metadata?: NotebookDocumentMetadata;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
export const INotebookService = Symbol('INotebookService');
|
|
184
|
+
|
|
185
|
+
export interface INotebookService {
|
|
186
|
+
createNotebook: (data?: NotebookDataDto) => Promise<{ uri: UriComponents }>;
|
|
187
|
+
openNotebook: (uriComponents: UriComponents) => Promise<{ uri: UriComponents }>;
|
|
188
|
+
saveNotebook: (uriComponents: UriComponents) => Promise<boolean>;
|
|
189
|
+
|
|
190
|
+
onDidOpenNotebookDocument: Event<INotebookModelAddedData>;
|
|
191
|
+
onDidCloseNotebookDocument: Event<UriComponents>;
|
|
192
|
+
onDidSaveNotebookDocument: Event<UriComponents>;
|
|
193
|
+
onDidChangeNotebookDocument: Event<NotebookDocumentChangeDto>;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
export const notebookCellScheme = 'vscode-notebook-cell';
|