@codingame/monaco-vscode-views-service-override 11.1.2 → 12.0.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/index.d.ts +34 -2
- package/index.js +569 -12
- package/package.json +42 -11
- package/service-override/tools/editor.d.ts +286 -0
- package/service-override/tools/views.d.ts +105 -0
- package/tools/editor.js +0 -662
- package/tools/views.js +0 -306
- package/tools.js +0 -44
- package/views.js +0 -566
package/tools/views.js
DELETED
|
@@ -1,306 +0,0 @@
|
|
|
1
|
-
import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
|
|
2
|
-
import { Extensions } from 'vscode/vscode/vs/workbench/common/views';
|
|
3
|
-
export { ViewContainerLocation } from 'vscode/vscode/vs/workbench/common/views';
|
|
4
|
-
import { MutableDisposable, DisposableStore } from 'vscode/vscode/vs/base/common/lifecycle';
|
|
5
|
-
import { size, $ } from 'vscode/vscode/vs/base/browser/dom';
|
|
6
|
-
import { ViewPane } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPane';
|
|
7
|
-
import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
|
|
8
|
-
import { ViewPaneContainer } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
|
|
9
|
-
export { ViewPaneContainer } from 'vscode/vscode/vs/workbench/browser/parts/views/viewPaneContainer';
|
|
10
|
-
import { URI } from 'vscode/vscode/vs/base/common/uri';
|
|
11
|
-
import { Codicon } from 'vscode/vscode/vs/base/common/codicons';
|
|
12
|
-
export { RegisteredEditorPriority } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService';
|
|
13
|
-
import { IEditorResolverService } from 'vscode/vscode/vs/workbench/services/editor/common/editorResolverService.service';
|
|
14
|
-
import { EditorInput } from 'vscode/vscode/vs/workbench/common/editor/editorInput';
|
|
15
|
-
export { EditorInput } from 'vscode/vscode/vs/workbench/common/editor/editorInput';
|
|
16
|
-
import { EditorExtensions } from 'vscode/vscode/vs/workbench/common/editor';
|
|
17
|
-
export { EditorInputCapabilities } from 'vscode/vscode/vs/workbench/common/editor';
|
|
18
|
-
import { registerAction2, Action2, MenuId } from 'vscode/vscode/vs/platform/actions/common/actions';
|
|
19
|
-
import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommonCategories';
|
|
20
|
-
import { ContextKeyExpr } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
|
|
21
|
-
import { BaseActionViewItem } from 'vscode/vscode/vs/base/browser/ui/actionbar/actionViewItems';
|
|
22
|
-
import { EditorPaneDescriptor } from 'vscode/vscode/vs/workbench/browser/editor';
|
|
23
|
-
import { EditorPane } from 'vscode/vscode/vs/workbench/browser/parts/editor/editorPane';
|
|
24
|
-
import { ITelemetryService } from 'vscode/vscode/vs/platform/telemetry/common/telemetry.service';
|
|
25
|
-
import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage.service';
|
|
26
|
-
import { IThemeService } from 'vscode/vscode/vs/platform/theme/common/themeService.service';
|
|
27
|
-
import { DomScrollableElement } from 'vscode/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
|
|
28
|
-
export { DomScrollableElement } from 'vscode/vscode/vs/base/browser/ui/scrollbar/scrollableElement';
|
|
29
|
-
import { assertIsDefined, assertAllDefined } from 'vscode/vscode/vs/base/common/types';
|
|
30
|
-
export { ConfirmResult } from 'vscode/vscode/vs/platform/dialogs/common/dialogs';
|
|
31
|
-
export { AbstractResourceEditorInput } from 'vscode/vscode/vs/workbench/common/editor/resourceEditorInput';
|
|
32
|
-
export { AbstractTextResourceEditorInput } from 'vscode/vscode/vs/workbench/common/editor/textResourceEditorInput';
|
|
33
|
-
export { Parts } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService';
|
|
34
|
-
import { IWorkbenchLayoutService } from 'vscode/vscode/vs/workbench/services/layout/browser/layoutService.service';
|
|
35
|
-
import { StandaloneServices } from 'vscode/vscode/vs/editor/standalone/browser/standaloneServices';
|
|
36
|
-
export { SplitView } from 'vscode/vscode/vs/base/browser/ui/splitview/splitview';
|
|
37
|
-
import { withReadyServices } from 'vscode/services';
|
|
38
|
-
|
|
39
|
-
class InjectedEditorPane extends EditorPane {
|
|
40
|
-
constructor(id, group) {
|
|
41
|
-
super(id, group, StandaloneServices.get(ITelemetryService), StandaloneServices.get(IThemeService), StandaloneServices.get(IStorageService));
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
class SimpleEditorPane extends InjectedEditorPane {
|
|
45
|
-
constructor() {
|
|
46
|
-
super(...arguments);
|
|
47
|
-
this.inputDisposable = this._register(new MutableDisposable());
|
|
48
|
-
}
|
|
49
|
-
createEditor(parent) {
|
|
50
|
-
this.container = this.initialize();
|
|
51
|
-
this.wrapper = document.createElement('div');
|
|
52
|
-
this.wrapper.append(this.container);
|
|
53
|
-
this.scrollbar = this._register(new DomScrollableElement(this.wrapper, {
|
|
54
|
-
horizontal: 1 ,
|
|
55
|
-
vertical: 1
|
|
56
|
-
}));
|
|
57
|
-
parent.appendChild(this.scrollbar.getDomNode());
|
|
58
|
-
const observer = new ResizeObserver(() => {
|
|
59
|
-
assertIsDefined(this.scrollbar).scanDomNode();
|
|
60
|
-
});
|
|
61
|
-
observer.observe(this.container);
|
|
62
|
-
this._register({
|
|
63
|
-
dispose() {
|
|
64
|
-
observer.disconnect();
|
|
65
|
-
}
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
async setInput(input, editorOptions, context, token) {
|
|
69
|
-
await super.setInput(input, editorOptions, context, token);
|
|
70
|
-
if (token.isCancellationRequested) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this.inputDisposable.value = await this.renderInput?.(input, editorOptions, context, token);
|
|
74
|
-
assertIsDefined(this.scrollbar).scanDomNode();
|
|
75
|
-
}
|
|
76
|
-
layout(dimension) {
|
|
77
|
-
const [wrapper, scrollbar] = assertAllDefined(this.wrapper, this.scrollbar);
|
|
78
|
-
size(wrapper, dimension.width, dimension.height);
|
|
79
|
-
scrollbar.scanDomNode();
|
|
80
|
-
}
|
|
81
|
-
focus() {
|
|
82
|
-
const container = assertIsDefined(this.container);
|
|
83
|
-
container.focus();
|
|
84
|
-
}
|
|
85
|
-
clearInput() {
|
|
86
|
-
this.inputDisposable.clear();
|
|
87
|
-
super.clearInput();
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
class SimpleEditorInput extends EditorInput {
|
|
91
|
-
constructor(resource, closeHandler) {
|
|
92
|
-
super();
|
|
93
|
-
this.closeHandler = closeHandler;
|
|
94
|
-
this.dirty = false;
|
|
95
|
-
this._capabilities = 0;
|
|
96
|
-
this.resource = resource;
|
|
97
|
-
}
|
|
98
|
-
get capabilities() {
|
|
99
|
-
return this._capabilities;
|
|
100
|
-
}
|
|
101
|
-
addCapability(capability) {
|
|
102
|
-
this._capabilities |= capability;
|
|
103
|
-
this._onDidChangeCapabilities.fire();
|
|
104
|
-
}
|
|
105
|
-
removeCapability(capability) {
|
|
106
|
-
this._capabilities &= ~capability;
|
|
107
|
-
this._onDidChangeCapabilities.fire();
|
|
108
|
-
}
|
|
109
|
-
get editorId() {
|
|
110
|
-
return this.typeId;
|
|
111
|
-
}
|
|
112
|
-
setName(name) {
|
|
113
|
-
this.name = name;
|
|
114
|
-
this._onDidChangeLabel.fire();
|
|
115
|
-
}
|
|
116
|
-
setTitle(title) {
|
|
117
|
-
this.title = title;
|
|
118
|
-
this._onDidChangeLabel.fire();
|
|
119
|
-
}
|
|
120
|
-
setDescription(description) {
|
|
121
|
-
this.description = description;
|
|
122
|
-
this._onDidChangeLabel.fire();
|
|
123
|
-
}
|
|
124
|
-
getLabelValue(label, verbosity) {
|
|
125
|
-
if (typeof label === 'string') {
|
|
126
|
-
return label;
|
|
127
|
-
}
|
|
128
|
-
switch (verbosity) {
|
|
129
|
-
case 0 :
|
|
130
|
-
return label.short;
|
|
131
|
-
case 2 :
|
|
132
|
-
return label.long;
|
|
133
|
-
case 1 :
|
|
134
|
-
default:
|
|
135
|
-
return label.medium;
|
|
136
|
-
}
|
|
137
|
-
}
|
|
138
|
-
getName() {
|
|
139
|
-
return this.name ?? 'Unnamed';
|
|
140
|
-
}
|
|
141
|
-
getTitle(verbosity) {
|
|
142
|
-
return this.getLabelValue(this.title ?? this.getName(), verbosity);
|
|
143
|
-
}
|
|
144
|
-
getDescription(verbosity) {
|
|
145
|
-
return this.getLabelValue(this.description ?? this.getName(), verbosity);
|
|
146
|
-
}
|
|
147
|
-
isDirty() {
|
|
148
|
-
return this.dirty;
|
|
149
|
-
}
|
|
150
|
-
setDirty(dirty) {
|
|
151
|
-
this.dirty = dirty;
|
|
152
|
-
this._onDidChangeDirty.fire();
|
|
153
|
-
}
|
|
154
|
-
toUntyped() {
|
|
155
|
-
if (this.resource == null) {
|
|
156
|
-
return undefined;
|
|
157
|
-
}
|
|
158
|
-
return {
|
|
159
|
-
resource: this.resource
|
|
160
|
-
};
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function registerEditorPane(typeId, name, ctor, inputCtors) {
|
|
164
|
-
return ( Registry.as(EditorExtensions.EditorPane)).registerEditorPane(EditorPaneDescriptor.create(ctor, typeId, name), ( inputCtors.map((ctor) => new SyncDescriptor(ctor))));
|
|
165
|
-
}
|
|
166
|
-
function registerEditor(globPattern, editorInfo, editorOptions, factory) {
|
|
167
|
-
return withReadyServices((servicesAccessor) => {
|
|
168
|
-
const resolverService = servicesAccessor.get(IEditorResolverService);
|
|
169
|
-
return resolverService.registerEditor(globPattern, editorInfo, editorOptions, factory);
|
|
170
|
-
});
|
|
171
|
-
}
|
|
172
|
-
function registerEditorSerializer(editorTypeId, ctor) {
|
|
173
|
-
return ( Registry.as(EditorExtensions.EditorFactory)).registerEditorSerializer(editorTypeId, ctor);
|
|
174
|
-
}
|
|
175
|
-
const viewContainerRegistry = ( Registry.as(Extensions.ViewContainersRegistry));
|
|
176
|
-
const viewRegistry = ( Registry.as(Extensions.ViewsRegistry));
|
|
177
|
-
function registerCustomView(options) {
|
|
178
|
-
const iconUrl = options.icon != null ? ( URI.parse(options.icon)) : undefined;
|
|
179
|
-
const viewContainer = options.viewContainer ??
|
|
180
|
-
viewContainerRegistry.registerViewContainer({
|
|
181
|
-
id: options.id,
|
|
182
|
-
title: { value: options.name, original: options.name },
|
|
183
|
-
order: options.order,
|
|
184
|
-
ctorDescriptor: new SyncDescriptor(ViewPaneContainer, [
|
|
185
|
-
options.id,
|
|
186
|
-
{ mergeViewWithContainerWhenSingleView: true }
|
|
187
|
-
]),
|
|
188
|
-
hideIfEmpty: true,
|
|
189
|
-
icon: iconUrl
|
|
190
|
-
}, options.location, {
|
|
191
|
-
isDefault: options.default
|
|
192
|
-
});
|
|
193
|
-
const views = [
|
|
194
|
-
{
|
|
195
|
-
id: options.id,
|
|
196
|
-
name: {
|
|
197
|
-
value: options.name,
|
|
198
|
-
original: options.name
|
|
199
|
-
},
|
|
200
|
-
ctorDescriptor: new SyncDescriptor(class extends ViewPane {
|
|
201
|
-
renderBody(container) {
|
|
202
|
-
super.renderBody(container);
|
|
203
|
-
this.wrapper = document.createElement('div');
|
|
204
|
-
this.scrollbar = this._register(new DomScrollableElement(this.wrapper, {
|
|
205
|
-
horizontal: 1 ,
|
|
206
|
-
vertical: 1
|
|
207
|
-
}));
|
|
208
|
-
this.container = $('.view-pane-content');
|
|
209
|
-
this.container.style.display = 'flex';
|
|
210
|
-
this.container.style.alignItems = 'stretch';
|
|
211
|
-
this._register(options.renderBody(this.container, this.scrollbar));
|
|
212
|
-
this.wrapper.append(this.container);
|
|
213
|
-
container.appendChild(this.scrollbar.getDomNode());
|
|
214
|
-
const observer = new ResizeObserver(() => {
|
|
215
|
-
assertIsDefined(this.scrollbar).scanDomNode();
|
|
216
|
-
});
|
|
217
|
-
observer.observe(this.container);
|
|
218
|
-
this._register({
|
|
219
|
-
dispose() {
|
|
220
|
-
observer.disconnect();
|
|
221
|
-
}
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
getActionViewItem(action, actionOptions) {
|
|
225
|
-
const customAction = (options.actions ?? []).find((customAction) => customAction.id === action.id);
|
|
226
|
-
if (customAction?.render != null) {
|
|
227
|
-
return new (class extends BaseActionViewItem {
|
|
228
|
-
constructor() {
|
|
229
|
-
super(null, action);
|
|
230
|
-
this.render = customAction.render;
|
|
231
|
-
}
|
|
232
|
-
})();
|
|
233
|
-
}
|
|
234
|
-
return super.getActionViewItem(action, actionOptions);
|
|
235
|
-
}
|
|
236
|
-
layoutBody(height, width) {
|
|
237
|
-
const [wrapper, scrollbar] = assertAllDefined(this.wrapper, this.scrollbar);
|
|
238
|
-
size(wrapper, width, height);
|
|
239
|
-
scrollbar.scanDomNode();
|
|
240
|
-
}
|
|
241
|
-
}),
|
|
242
|
-
canMoveView: options.canMoveView ?? true,
|
|
243
|
-
canToggleVisibility: options.canToggleVisibility ?? false,
|
|
244
|
-
hideByDefault: options.hideByDefault ?? false,
|
|
245
|
-
collapsed: options.collapsed ?? false,
|
|
246
|
-
order: options.order,
|
|
247
|
-
containerIcon: iconUrl
|
|
248
|
-
}
|
|
249
|
-
];
|
|
250
|
-
viewRegistry.registerViews(views, viewContainer);
|
|
251
|
-
const disposableCollection = new DisposableStore();
|
|
252
|
-
disposableCollection.add({
|
|
253
|
-
dispose() {
|
|
254
|
-
viewRegistry.deregisterViews(views, viewContainer);
|
|
255
|
-
if (options.viewContainer == null) {
|
|
256
|
-
viewContainerRegistry.deregisterViewContainer(viewContainer);
|
|
257
|
-
}
|
|
258
|
-
}
|
|
259
|
-
});
|
|
260
|
-
for (const action of options.actions ?? []) {
|
|
261
|
-
disposableCollection.add(registerAction2(class extends Action2 {
|
|
262
|
-
constructor() {
|
|
263
|
-
super({
|
|
264
|
-
id: action.id,
|
|
265
|
-
title: { value: action.title, original: action.title },
|
|
266
|
-
category: Categories.View,
|
|
267
|
-
menu: [
|
|
268
|
-
{
|
|
269
|
-
id: MenuId.ViewTitle,
|
|
270
|
-
when: ( ContextKeyExpr.equals('view', options.id)),
|
|
271
|
-
group: 'navigation',
|
|
272
|
-
order: action.order
|
|
273
|
-
},
|
|
274
|
-
{
|
|
275
|
-
id: MenuId.CommandPalette
|
|
276
|
-
}
|
|
277
|
-
],
|
|
278
|
-
tooltip: action.tooltip,
|
|
279
|
-
icon: action.icon != null ? Codicon[action.icon] : undefined
|
|
280
|
-
});
|
|
281
|
-
this.run = action.run ?? (async () => { });
|
|
282
|
-
}
|
|
283
|
-
}));
|
|
284
|
-
}
|
|
285
|
-
return disposableCollection;
|
|
286
|
-
}
|
|
287
|
-
function isPartVisibile(part) {
|
|
288
|
-
return StandaloneServices.get(IWorkbenchLayoutService).isVisible(part, window);
|
|
289
|
-
}
|
|
290
|
-
function setPartVisibility(part, visible) {
|
|
291
|
-
StandaloneServices.get(IWorkbenchLayoutService).setPartHidden(!visible, part, window);
|
|
292
|
-
}
|
|
293
|
-
const onDidChangePanelPosition = (listener) => {
|
|
294
|
-
return StandaloneServices.get(IWorkbenchLayoutService).onDidChangePanelPosition(listener);
|
|
295
|
-
};
|
|
296
|
-
function getPanelPosition() {
|
|
297
|
-
return StandaloneServices.get(IWorkbenchLayoutService).getPanelPosition();
|
|
298
|
-
}
|
|
299
|
-
const onDidChangeSideBarPosition = (listener) => {
|
|
300
|
-
return StandaloneServices.get(IWorkbenchLayoutService).onDidChangeSideBarPosition(listener);
|
|
301
|
-
};
|
|
302
|
-
function getSideBarPosition() {
|
|
303
|
-
return StandaloneServices.get(IWorkbenchLayoutService).getSideBarPosition();
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
export { InjectedEditorPane as EditorPane, SimpleEditorInput, SimpleEditorPane, getPanelPosition, getSideBarPosition, isPartVisibile, onDidChangePanelPosition, onDidChangeSideBarPosition, registerCustomView, registerEditor, registerEditorPane, registerEditorSerializer, setPartVisibility, viewContainerRegistry, viewRegistry };
|
package/tools.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
function unsupported() {
|
|
2
|
-
throw new Error('unsupported');
|
|
3
|
-
}
|
|
4
|
-
function memoized(fct) {
|
|
5
|
-
let v = null;
|
|
6
|
-
return (...args) => {
|
|
7
|
-
if (v == null) {
|
|
8
|
-
v = fct(...args);
|
|
9
|
-
}
|
|
10
|
-
return v;
|
|
11
|
-
};
|
|
12
|
-
}
|
|
13
|
-
function memoizedConstructor(ctor) {
|
|
14
|
-
return new Proxy(ctor, {
|
|
15
|
-
construct: memoized((target, args) => {
|
|
16
|
-
return Reflect.construct(ctor, args);
|
|
17
|
-
})
|
|
18
|
-
});
|
|
19
|
-
}
|
|
20
|
-
async function sleep(duration) {
|
|
21
|
-
await new Promise((resolve) => setTimeout(resolve, duration));
|
|
22
|
-
}
|
|
23
|
-
function throttle(fct, merge, delay) {
|
|
24
|
-
let lastPromise = Promise.resolve();
|
|
25
|
-
let toConsume = null;
|
|
26
|
-
return async (param) => {
|
|
27
|
-
if (toConsume == null) {
|
|
28
|
-
toConsume = param;
|
|
29
|
-
lastPromise = lastPromise
|
|
30
|
-
.then(async () => await sleep(delay))
|
|
31
|
-
.then(async () => {
|
|
32
|
-
const _toConsume = toConsume;
|
|
33
|
-
toConsume = null;
|
|
34
|
-
await fct(_toConsume);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
toConsume = merge(toConsume, param);
|
|
39
|
-
}
|
|
40
|
-
await lastPromise;
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export { memoized, memoizedConstructor, sleep, throttle, unsupported };
|