@theia/plugin-ext 1.35.0 → 1.36.0-next.21
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/common/plugin-protocol.d.ts +14 -10
- package/lib/common/plugin-protocol.d.ts.map +1 -1
- package/lib/common/plugin-protocol.js.map +1 -1
- package/lib/hosted/browser/hosted-plugin.d.ts.map +1 -1
- package/lib/hosted/browser/hosted-plugin.js +6 -4
- package/lib/hosted/browser/hosted-plugin.js.map +1 -1
- package/lib/hosted/node/hosted-plugin-deployer-handler.js +1 -1
- package/lib/hosted/node/hosted-plugin-deployer-handler.js.map +1 -1
- package/lib/hosted/node/plugin-host-rpc.js +2 -2
- package/lib/hosted/node/plugin-host-rpc.js.map +1 -1
- package/lib/main/browser/main-file-system-event-service.d.ts.map +1 -1
- package/lib/main/browser/main-file-system-event-service.js +6 -9
- package/lib/main/browser/main-file-system-event-service.js.map +1 -1
- package/lib/main/browser/plugin-contribution-handler.d.ts.map +1 -1
- package/lib/main/browser/plugin-contribution-handler.js +4 -1
- package/lib/main/browser/plugin-contribution-handler.js.map +1 -1
- package/lib/main/node/handlers/plugin-theia-directory-handler.js +1 -1
- package/lib/main/node/handlers/plugin-theia-directory-handler.js.map +1 -1
- package/lib/plugin/plugin-context.d.ts +2 -1
- package/lib/plugin/plugin-context.d.ts.map +1 -1
- package/lib/plugin/plugin-context.js +8 -2
- package/lib/plugin/plugin-context.js.map +1 -1
- package/lib/plugin/tree/tree-views.d.ts +6 -3
- package/lib/plugin/tree/tree-views.d.ts.map +1 -1
- package/lib/plugin/tree/tree-views.js +32 -25
- package/lib/plugin/tree/tree-views.js.map +1 -1
- package/lib/plugin/types-impl.d.ts +1 -1
- package/lib/plugin/types-impl.d.ts.map +1 -1
- package/lib/plugin/types-impl.js +3 -0
- package/lib/plugin/types-impl.js.map +1 -1
- package/lib/plugin/webview-views.js +2 -2
- package/lib/plugin/webview-views.js.map +1 -1
- package/package.json +26 -26
- package/src/common/plugin-protocol.ts +15 -10
- package/src/hosted/browser/hosted-plugin.ts +6 -4
- package/src/hosted/node/hosted-plugin-deployer-handler.ts +1 -1
- package/src/hosted/node/plugin-host-rpc.ts +2 -2
- package/src/main/browser/main-file-system-event-service.ts +6 -9
- package/src/main/browser/plugin-contribution-handler.ts +6 -3
- package/src/main/node/handlers/plugin-theia-directory-handler.ts +1 -1
- package/src/plugin/plugin-context.ts +9 -2
- package/src/plugin/tree/tree-views.ts +33 -26
- package/src/plugin/types-impl.ts +4 -1
- package/src/plugin/webview-views.ts +2 -2
|
@@ -21,7 +21,7 @@ import { TextmateRegistry, getEncodedLanguageId, MonacoTextmateService, GrammarD
|
|
|
21
21
|
import { MenusContributionPointHandler } from './menus/menus-contribution-handler';
|
|
22
22
|
import { PluginViewRegistry } from './view/plugin-view-registry';
|
|
23
23
|
import { PluginCustomEditorRegistry } from './custom-editors/plugin-custom-editor-registry';
|
|
24
|
-
import { PluginContribution, IndentationRules, FoldingRules, ScopeMap, DeployedPlugin, GrammarsContribution, EnterAction, OnEnterRule } from '../../common';
|
|
24
|
+
import { PluginContribution, IndentationRules, FoldingRules, ScopeMap, DeployedPlugin, GrammarsContribution, EnterAction, OnEnterRule, RegExpOptions } from '../../common';
|
|
25
25
|
import {
|
|
26
26
|
DefaultUriLabelProviderContribution,
|
|
27
27
|
LabelProviderContribution,
|
|
@@ -488,11 +488,14 @@ export class PluginContributionHandler {
|
|
|
488
488
|
return Disposable.NULL;
|
|
489
489
|
}
|
|
490
490
|
|
|
491
|
-
private createRegex(value: string | undefined): RegExp | undefined {
|
|
491
|
+
private createRegex(value: string | RegExpOptions | undefined): RegExp | undefined {
|
|
492
492
|
if (typeof value === 'string') {
|
|
493
493
|
return new RegExp(value, '');
|
|
494
494
|
}
|
|
495
|
-
|
|
495
|
+
if (typeof value == 'undefined') {
|
|
496
|
+
return undefined;
|
|
497
|
+
}
|
|
498
|
+
return new RegExp(value.pattern, value.flags);
|
|
496
499
|
}
|
|
497
500
|
|
|
498
501
|
private convertIndentationRules(rules?: IndentationRules): monaco.languages.IndentationRule | undefined {
|
|
@@ -34,7 +34,7 @@ export class PluginTheiaDirectoryHandler implements PluginDeployerDirectoryHandl
|
|
|
34
34
|
|
|
35
35
|
accept(resolvedPlugin: PluginDeployerEntry): boolean {
|
|
36
36
|
|
|
37
|
-
console.
|
|
37
|
+
console.debug('PluginTheiaDirectoryHandler: accepting plugin with path', resolvedPlugin.path());
|
|
38
38
|
|
|
39
39
|
// handle only directories
|
|
40
40
|
if (resolvedPlugin.isFile()) {
|
|
@@ -753,7 +753,8 @@ export function createAPIFactory(
|
|
|
753
753
|
|
|
754
754
|
const extensions: typeof theia.extensions = Object.freeze({
|
|
755
755
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
756
|
-
getExtension<T = any>(extensionId: string): theia.Extension<T> | undefined {
|
|
756
|
+
getExtension<T = any>(extensionId: string, includeFromDifferentExtensionHosts: boolean = false): theia.Extension<T> | undefined {
|
|
757
|
+
includeFromDifferentExtensionHosts = false;
|
|
757
758
|
const plg = pluginManager.getPluginById(extensionId.toLowerCase());
|
|
758
759
|
if (plg) {
|
|
759
760
|
return new PluginExt(pluginManager, plg);
|
|
@@ -764,6 +765,10 @@ export function createAPIFactory(
|
|
|
764
765
|
get all(): readonly theia.Extension<any>[] {
|
|
765
766
|
return pluginManager.getAllPlugins().map(plg => new PluginExt(pluginManager, plg));
|
|
766
767
|
},
|
|
768
|
+
get allAcrossExtensionHosts(): readonly theia.Extension<any>[] {
|
|
769
|
+
// we only support one extension host ATM so equivalent to calling "all()"
|
|
770
|
+
return this.all;
|
|
771
|
+
},
|
|
767
772
|
get onDidChange(): theia.Event<void> {
|
|
768
773
|
return pluginManager.onDidChange;
|
|
769
774
|
}
|
|
@@ -1369,13 +1374,15 @@ export class PluginExt<T> extends Plugin<T> implements ExtensionPlugin<T> {
|
|
|
1369
1374
|
extensionPath: string;
|
|
1370
1375
|
extensionUri: theia.Uri;
|
|
1371
1376
|
extensionKind: ExtensionKind;
|
|
1377
|
+
isFromDifferentExtensionHost: boolean;
|
|
1372
1378
|
|
|
1373
|
-
constructor(protected override readonly pluginManager: PluginManager, plugin: InternalPlugin) {
|
|
1379
|
+
constructor(protected override readonly pluginManager: PluginManager, plugin: InternalPlugin, isFromDifferentExtensionHost = false) {
|
|
1374
1380
|
super(pluginManager, plugin);
|
|
1375
1381
|
|
|
1376
1382
|
this.extensionPath = this.pluginPath;
|
|
1377
1383
|
this.extensionUri = this.pluginUri;
|
|
1378
1384
|
this.extensionKind = ExtensionKind.UI; // stub as a local extension (not running on a remote workspace)
|
|
1385
|
+
this.isFromDifferentExtensionHost = isFromDifferentExtensionHost;
|
|
1379
1386
|
}
|
|
1380
1387
|
|
|
1381
1388
|
override get isActive(): boolean {
|
|
@@ -34,7 +34,6 @@ import { URI } from '@theia/core/shared/vscode-uri';
|
|
|
34
34
|
import { UriComponents } from '@theia/core/lib/common/uri';
|
|
35
35
|
|
|
36
36
|
export class TreeViewsExtImpl implements TreeViewsExt {
|
|
37
|
-
|
|
38
37
|
private proxy: TreeViewsMain;
|
|
39
38
|
|
|
40
39
|
private readonly treeViews = new Map<string, TreeViewExtImpl<any>>();
|
|
@@ -45,9 +44,9 @@ export class TreeViewsExtImpl implements TreeViewsExt {
|
|
|
45
44
|
commandRegistry.registerArgumentProcessor({
|
|
46
45
|
processArgument: arg => {
|
|
47
46
|
if (TreeViewItemReference.is(arg)) {
|
|
48
|
-
return this.
|
|
47
|
+
return this.toTreeElement(arg);
|
|
49
48
|
} else if (Array.isArray(arg)) {
|
|
50
|
-
return arg.map(param => TreeViewItemReference.is(param) ? this.
|
|
49
|
+
return arg.map(param => TreeViewItemReference.is(param) ? this.toTreeElement(param) : param);
|
|
51
50
|
} else {
|
|
52
51
|
return arg;
|
|
53
52
|
}
|
|
@@ -62,8 +61,8 @@ export class TreeViewsExtImpl implements TreeViewsExt {
|
|
|
62
61
|
return this.getTreeView(treeViewId).handleDrop!(treeItemId, dataTransferItems, token);
|
|
63
62
|
}
|
|
64
63
|
|
|
65
|
-
protected
|
|
66
|
-
return this.treeViews.get(treeViewItemRef.viewId)?.
|
|
64
|
+
protected toTreeElement(treeViewItemRef: TreeViewItemReference): any {
|
|
65
|
+
return this.treeViews.get(treeViewItemRef.viewId)?.getElement(treeViewItemRef.itemId);
|
|
67
66
|
}
|
|
68
67
|
|
|
69
68
|
registerTreeDataProvider<T>(plugin: Plugin, treeViewId: string, treeDataProvider: TreeDataProvider<T>): PluginDisposable {
|
|
@@ -186,6 +185,10 @@ interface TreeExtNode<T> extends Disposable {
|
|
|
186
185
|
}
|
|
187
186
|
|
|
188
187
|
class TreeViewExtImpl<T> implements Disposable {
|
|
188
|
+
private static readonly ID_COMPUTED = 'c';
|
|
189
|
+
private static readonly ID_ITEM = 'i';
|
|
190
|
+
|
|
191
|
+
private nextItemId: 0;
|
|
189
192
|
|
|
190
193
|
private readonly onDidExpandElementEmitter = new Emitter<TreeViewExpansionEvent<T>>();
|
|
191
194
|
readonly onDidExpandElement = this.onDidExpandElementEmitter.event;
|
|
@@ -274,7 +277,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
274
277
|
this.proxy.$setDescription(this.treeViewId, this._description);
|
|
275
278
|
}
|
|
276
279
|
|
|
277
|
-
|
|
280
|
+
getElement(treeItemId: string): T | undefined {
|
|
278
281
|
return this.nodes.get(treeItemId)?.value;
|
|
279
282
|
}
|
|
280
283
|
|
|
@@ -312,14 +315,9 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
312
315
|
// parent is inconsistent
|
|
313
316
|
return undefined;
|
|
314
317
|
}
|
|
315
|
-
const
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
while (possibleIndex-- > 0) {
|
|
319
|
-
const candidateId = this.buildTreeItemId(parentId, possibleIndex, idLabel);
|
|
320
|
-
if (this.nodes.has(candidateId)) {
|
|
321
|
-
return chain.concat(candidateId);
|
|
322
|
-
}
|
|
318
|
+
const candidateId = this.buildTreeItemId(parentId, treeItem);
|
|
319
|
+
if (this.nodes.has(candidateId)) {
|
|
320
|
+
return chain.concat(candidateId);
|
|
323
321
|
}
|
|
324
322
|
// couldn't calculate consistent parent chain and id
|
|
325
323
|
return undefined;
|
|
@@ -335,7 +333,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
335
333
|
return typeof treeItemLabel === 'object' ? treeItemLabel.highlights : undefined;
|
|
336
334
|
}
|
|
337
335
|
|
|
338
|
-
private
|
|
336
|
+
private getItemLabel(treeItem: TreeItem): string | undefined {
|
|
339
337
|
let idLabel = this.getTreeItemLabel(treeItem);
|
|
340
338
|
// Use resource URI if label is not set
|
|
341
339
|
if (idLabel === undefined && treeItem.resourceUri) {
|
|
@@ -348,8 +346,18 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
348
346
|
return idLabel;
|
|
349
347
|
}
|
|
350
348
|
|
|
351
|
-
private buildTreeItemId(parentId: string,
|
|
352
|
-
|
|
349
|
+
private buildTreeItemId(parentId: string, item: TreeItem): string {
|
|
350
|
+
// build tree id according to https://code.visualstudio.com/api/references/vscode-api#TreeItem
|
|
351
|
+
// note: the front end tree implementation cannot handle reparenting items, hence the id is set to the "path" of individual ids
|
|
352
|
+
let id = typeof item.id === 'string' ? item.id : this.getItemLabel(item);
|
|
353
|
+
if (id) {
|
|
354
|
+
// we use '' as the id of the root, we don't consider that a valid id
|
|
355
|
+
// since '' is falsy, we'll never get '' in this branch
|
|
356
|
+
id = TreeViewExtImpl.ID_ITEM + id;
|
|
357
|
+
} else {
|
|
358
|
+
id = TreeViewExtImpl.ID_COMPUTED + this.nextItemId++;
|
|
359
|
+
}
|
|
360
|
+
return `${parentId}/${id}`;
|
|
353
361
|
}
|
|
354
362
|
|
|
355
363
|
async getChildren(parentId: string): Promise<TreeViewItem[] | undefined> {
|
|
@@ -369,20 +377,19 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
369
377
|
// ask data provider for children for cached element
|
|
370
378
|
const result = await this.options.treeDataProvider.getChildren(parent);
|
|
371
379
|
if (result) {
|
|
372
|
-
const treeItemPromises = result.map(async
|
|
380
|
+
const treeItemPromises = result.map(async value => {
|
|
373
381
|
|
|
374
382
|
// Ask data provider for a tree item for the value
|
|
375
383
|
// Data provider must return theia.TreeItem
|
|
376
384
|
const treeItem = await this.options.treeDataProvider.getTreeItem(value);
|
|
377
385
|
// Convert theia.TreeItem to the TreeViewItem
|
|
378
386
|
|
|
379
|
-
const label = this.
|
|
387
|
+
const label = this.getItemLabel(treeItem);
|
|
380
388
|
const highlights = this.getTreeItemLabelHighlights(treeItem);
|
|
381
|
-
const idLabel = this.getTreeItemIdLabel(treeItem);
|
|
382
389
|
|
|
383
390
|
// Generate the ID
|
|
384
391
|
// ID is used for caching the element
|
|
385
|
-
const id =
|
|
392
|
+
const id = this.buildTreeItemId(parentId, treeItem);
|
|
386
393
|
|
|
387
394
|
const toDisposeElement = new DisposableCollection();
|
|
388
395
|
const node: TreeExtNode<T> = {
|
|
@@ -467,7 +474,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
467
474
|
|
|
468
475
|
async onExpanded(treeItemId: string): Promise<any> {
|
|
469
476
|
// get element from a cache
|
|
470
|
-
const cachedElement = this.
|
|
477
|
+
const cachedElement = this.getElement(treeItemId);
|
|
471
478
|
|
|
472
479
|
// fire an event
|
|
473
480
|
if (cachedElement) {
|
|
@@ -479,7 +486,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
479
486
|
|
|
480
487
|
async onCollapsed(treeItemId: string): Promise<any> {
|
|
481
488
|
// get element from a cache
|
|
482
|
-
const cachedElement = this.
|
|
489
|
+
const cachedElement = this.getElement(treeItemId);
|
|
483
490
|
|
|
484
491
|
// fire an event
|
|
485
492
|
if (cachedElement) {
|
|
@@ -513,7 +520,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
513
520
|
get selectedElements(): T[] {
|
|
514
521
|
const items: T[] = [];
|
|
515
522
|
for (const id of this.selectedItemIds) {
|
|
516
|
-
const item = this.
|
|
523
|
+
const item = this.getElement(id);
|
|
517
524
|
if (item) {
|
|
518
525
|
items.push(item);
|
|
519
526
|
}
|
|
@@ -554,7 +561,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
554
561
|
async onDragStarted(treeItemIds: string[], token: CancellationToken): Promise<UriComponents[] | undefined> {
|
|
555
562
|
const treeItems: T[] = [];
|
|
556
563
|
for (const id of treeItemIds) {
|
|
557
|
-
const item = this.
|
|
564
|
+
const item = this.getElement(id);
|
|
558
565
|
if (item) {
|
|
559
566
|
treeItems.push(item);
|
|
560
567
|
}
|
|
@@ -571,7 +578,7 @@ class TreeViewExtImpl<T> implements Disposable {
|
|
|
571
578
|
}
|
|
572
579
|
|
|
573
580
|
async handleDrop(treeItemId: string | undefined, dataTransferItems: [string, string | DataTransferFileDTO][], token: CancellationToken): Promise<void> {
|
|
574
|
-
const treeItem = treeItemId ? this.
|
|
581
|
+
const treeItem = treeItemId ? this.getElement(treeItemId) : undefined;
|
|
575
582
|
const dropTransfer = new DataTransfer();
|
|
576
583
|
if (this.options.dragAndDropController?.handleDrop) {
|
|
577
584
|
this.localDataTransfer.forEach((item, type) => {
|
package/src/plugin/types-impl.ts
CHANGED
|
@@ -404,10 +404,13 @@ export class Position {
|
|
|
404
404
|
return result!;
|
|
405
405
|
}
|
|
406
406
|
|
|
407
|
-
static isPosition(other:
|
|
407
|
+
static isPosition(other: unknown): other is Position {
|
|
408
408
|
if (!other) {
|
|
409
409
|
return false;
|
|
410
410
|
}
|
|
411
|
+
if (typeof other !== 'object' || Array.isArray(other)) {
|
|
412
|
+
return false;
|
|
413
|
+
}
|
|
411
414
|
if (other instanceof Position) {
|
|
412
415
|
return true;
|
|
413
416
|
}
|
|
@@ -167,8 +167,8 @@ export class WebviewViewExtImpl implements theia.WebviewView {
|
|
|
167
167
|
|
|
168
168
|
set title(value: string | undefined) {
|
|
169
169
|
this.assertNotDisposed();
|
|
170
|
-
if (this.
|
|
171
|
-
this.
|
|
170
|
+
if (this._title !== value) {
|
|
171
|
+
this._title = value;
|
|
172
172
|
this.proxy.$setWebviewViewTitle(this.handle, value);
|
|
173
173
|
}
|
|
174
174
|
}
|