-
Notifications
You must be signed in to change notification settings - Fork 2.5k
/
plugin-protocol.ts
1080 lines (911 loc) · 29.2 KB
/
plugin-protocol.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// *****************************************************************************
// Copyright (C) 2018 Red Hat, Inc. and others.
//
// This program and the accompanying materials are made available under the
// terms of the Eclipse Public License v. 2.0 which is available at
// http://www.eclipse.org/legal/epl-2.0.
//
// This Source Code may also be made available under the following Secondary
// Licenses when the conditions for such availability set forth in the Eclipse
// Public License v. 2.0 are satisfied: GNU General Public License, version 2
// with the GNU Classpath Exception which is available at
// https://www.gnu.org/software/classpath/license.html.
//
// SPDX-License-Identifier: EPL-2.0 OR GPL-2.0-only WITH Classpath-exception-2.0
// *****************************************************************************
import { RpcServer } from '@theia/core/lib/common/messaging/proxy-factory';
import { RPCProtocol } from './rpc-protocol';
import { Disposable } from '@theia/core/lib/common/disposable';
import { LogPart, KeysToAnyValues, KeysToKeysToAnyValue } from './types';
import { CharacterPair, CommentRule, PluginAPIFactory, Plugin, ThemeIcon } from './plugin-api-rpc';
import { ExtPluginApi } from './plugin-ext-api-contribution';
import { IJSONSchema, IJSONSchemaSnippet } from '@theia/core/lib/common/json-schema';
import { RecursivePartial } from '@theia/core/lib/common/types';
import { PreferenceSchema, PreferenceSchemaProperties } from '@theia/core/lib/common/preferences/preference-schema';
import { ProblemMatcherContribution, ProblemPatternContribution, TaskDefinition } from '@theia/task/lib/common';
import { ColorDefinition } from '@theia/core/lib/common/color';
import { ResourceLabelFormatter } from '@theia/core/lib/common/label-protocol';
import { PluginIdentifiers } from './plugin-identifiers';
export { PluginIdentifiers };
export const hostedServicePath = '/services/hostedPlugin';
/**
* Plugin engine (API) type, i.e. 'theiaPlugin', 'vscode', 'theiaHeadlessPlugin', etc.
*/
export type PluginEngine = string;
/**
* This interface describes a package.json object.
*/
export interface PluginPackage {
name: string;
// The publisher is not guaranteed to be defined for unpublished plugins. https://github.com/microsoft/vscode-vsce/commit/a38657ece04c20e4fbde15d5ac1ed39ca51cb856
publisher: string | undefined;
version: string;
engines: {
[type in PluginEngine]: string;
};
theiaPlugin?: {
frontend?: string;
backend?: string;
/* Requires the `@theia/plugin-ext-headless` extension. */
headless?: string;
};
main?: string;
browser?: string;
displayName: string;
description: string;
contributes?: PluginPackageContribution;
packagePath: string;
activationEvents?: string[];
extensionDependencies?: string[];
extensionPack?: string[];
l10n?: string;
icon?: string;
extensionKind?: Array<'ui' | 'workspace'>
}
export namespace PluginPackage {
export function toPluginUrl(pck: PluginPackage | PluginModel, relativePath: string): string {
return `hostedPlugin/${getPluginId(pck)}/${encodeURIComponent(relativePath)}`;
}
}
/**
* This interface describes a package.json contribution section object.
*/
export interface PluginPackageContribution {
authentication?: PluginPackageAuthenticationProvider[];
configuration?: RecursivePartial<PreferenceSchema> | RecursivePartial<PreferenceSchema>[];
configurationDefaults?: RecursivePartial<PreferenceSchemaProperties>;
languages?: PluginPackageLanguageContribution[];
grammars?: PluginPackageGrammarsContribution[];
customEditors?: PluginPackageCustomEditor[];
viewsContainers?: { [location: string]: PluginPackageViewContainer[] };
views?: { [location: string]: PluginPackageView[] };
viewsWelcome?: PluginPackageViewWelcome[];
commands?: PluginPackageCommand | PluginPackageCommand[];
menus?: { [location: string]: PluginPackageMenu[] };
submenus?: PluginPackageSubmenu[];
keybindings?: PluginPackageKeybinding | PluginPackageKeybinding[];
debuggers?: PluginPackageDebuggersContribution[];
snippets?: PluginPackageSnippetsContribution[];
themes?: PluginThemeContribution[];
iconThemes?: PluginIconThemeContribution[];
icons?: PluginIconContribution[];
colors?: PluginColorContribution[];
taskDefinitions?: PluginTaskDefinitionContribution[];
problemMatchers?: PluginProblemMatcherContribution[];
problemPatterns?: PluginProblemPatternContribution[];
jsonValidation?: PluginJsonValidationContribution[];
resourceLabelFormatters?: ResourceLabelFormatter[];
localizations?: PluginPackageLocalization[];
terminal?: PluginPackageTerminal;
notebooks?: PluginPackageNotebook[];
notebookRenderer?: PluginNotebookRendererContribution[];
}
export interface PluginPackageNotebook {
type: string;
displayName: string;
selector?: readonly { filenamePattern?: string; excludeFileNamePattern?: string }[];
priority?: string;
}
export interface PluginNotebookRendererContribution {
readonly id: string;
readonly displayName: string;
readonly mimeTypes: string[];
readonly entrypoint: string | { readonly extends: string; readonly path: string };
readonly requiresMessaging?: 'always' | 'optional' | 'never'
}
export interface PluginPackageAuthenticationProvider {
id: string;
label: string;
}
export interface PluginPackageTerminalProfile {
title: string;
id: string;
icon?: string;
}
export interface PluginPackageTerminal {
profiles: PluginPackageTerminalProfile[];
}
export interface PluginPackageLocalization {
languageId: string;
languageName?: string;
localizedLanguageName?: string;
translations: PluginPackageTranslation[];
minimalTranslations?: { [key: string]: string };
}
export interface PluginPackageTranslation {
id: string;
path: string;
}
export interface PluginPackageCustomEditor {
viewType: string;
displayName: string;
selector?: CustomEditorSelector[];
priority?: CustomEditorPriority;
}
export interface CustomEditorSelector {
readonly filenamePattern?: string;
}
export enum CustomEditorPriority {
default = 'default',
builtin = 'builtin',
option = 'option',
}
export interface PluginPackageViewContainer {
id: string;
title: string;
icon: string;
}
export enum PluginViewType {
Tree = 'tree',
Webview = 'webview'
}
export interface PluginPackageView {
id: string;
name: string;
when?: string;
type?: string;
}
export interface PluginPackageViewWelcome {
view: string;
contents: string;
when?: string;
}
export interface PluginPackageCommand {
command: string;
title: string;
original?: string;
category?: string;
icon?: string | { light: string; dark: string; };
enablement?: string;
}
export interface PluginPackageMenu {
command?: string;
submenu?: string;
alt?: string;
group?: string;
when?: string;
}
export interface PluginPackageSubmenu {
id: string;
label: string;
icon: IconUrl;
}
export interface PluginPackageKeybinding {
key?: string;
command: string;
when?: string;
mac?: string;
linux?: string;
win?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args?: any;
}
export interface PluginPackageGrammarsContribution {
language?: string;
scopeName: string;
path: string;
embeddedLanguages?: ScopeMap;
tokenTypes?: ScopeMap;
injectTo?: string[];
}
export interface ScopeMap {
[scopeName: string]: string;
}
export interface PluginPackageSnippetsContribution {
language?: string;
path?: string;
}
export interface PluginColorContribution {
id?: string;
description?: string;
defaults?: { light?: string, dark?: string, highContrast?: string };
}
export type PluginUiTheme = 'vs' | 'vs-dark' | 'hc-black';
export interface PluginThemeContribution {
id?: string;
label?: string;
description?: string;
path?: string;
uiTheme?: PluginUiTheme;
}
export interface PluginIconThemeContribution {
id?: string;
label?: string;
description?: string;
path?: string;
uiTheme?: PluginUiTheme;
}
export interface PluginIconContribution {
[id: string]: {
description: string;
default: { fontPath: string; fontCharacter: string } | string;
};
}
export interface PlatformSpecificAdapterContribution {
program?: string;
args?: string[];
runtime?: string;
runtimeArgs?: string[];
}
/**
* This interface describes a package.json debuggers contribution section object.
*/
export interface PluginPackageDebuggersContribution extends PlatformSpecificAdapterContribution {
type: string;
label?: string;
languages?: string[];
enableBreakpointsFor?: { languageIds: string[] };
configurationAttributes: { [request: string]: IJSONSchema };
configurationSnippets: IJSONSchemaSnippet[];
variables?: ScopeMap;
adapterExecutableCommand?: string;
win?: PlatformSpecificAdapterContribution;
winx86?: PlatformSpecificAdapterContribution;
windows?: PlatformSpecificAdapterContribution;
osx?: PlatformSpecificAdapterContribution;
linux?: PlatformSpecificAdapterContribution;
}
/**
* This interface describes a package.json languages contribution section object.
*/
export interface PluginPackageLanguageContribution {
id: string;
extensions?: string[];
filenames?: string[];
filenamePatterns?: string[];
firstLine?: string;
aliases?: string[];
mimetypes?: string[];
configuration?: string;
icon?: IconUrl;
}
export interface PluginPackageLanguageContributionConfiguration {
comments?: CommentRule;
brackets?: CharacterPair[];
autoClosingPairs?: (CharacterPair | AutoClosingPairConditional)[];
surroundingPairs?: (CharacterPair | AutoClosingPair)[];
wordPattern?: string;
indentationRules?: IndentationRules;
folding?: FoldingRules;
onEnterRules?: OnEnterRule[];
}
export interface PluginTaskDefinitionContribution {
type: string;
required: string[];
properties?: IJSONSchema['properties'];
}
export interface PluginProblemMatcherContribution extends ProblemMatcherContribution {
name: string;
}
export interface PluginProblemPatternContribution extends ProblemPatternContribution {
name: string;
}
export interface PluginJsonValidationContribution {
fileMatch: string | string[];
url: string;
}
export const PluginScanner = Symbol('PluginScanner');
/**
* This scanner process package.json object and returns plugin metadata objects.
*/
export interface PluginScanner {
/**
* The type of plugin's API (engine name)
*/
apiType: PluginEngine;
/**
* Creates plugin's model.
*
* @param {PluginPackage} plugin
* @returns {PluginModel}
*/
getModel(plugin: PluginPackage): PluginModel;
/**
* Creates plugin's lifecycle.
*
* @returns {PluginLifecycle}
*/
getLifecycle(plugin: PluginPackage): PluginLifecycle;
getContribution(plugin: PluginPackage): Promise<PluginContribution | undefined>;
/**
* A mapping between a dependency as its defined in package.json
* and its deployable form, e.g. `publisher.name` -> `vscode:extension/publisher.name`
*/
getDependencies(plugin: PluginPackage): Map<string, string> | undefined;
}
/**
* A plugin resolver is handling how to resolve a plugin link into a local resource.
*/
export const PluginDeployerResolver = Symbol('PluginDeployerResolver');
/**
* A resolver handle a set of resource
*/
export interface PluginDeployerResolver {
init?(pluginDeployerResolverInit: PluginDeployerResolverInit): void;
accept(pluginSourceId: string): boolean;
resolve(pluginResolverContext: PluginDeployerResolverContext, options?: PluginDeployOptions): Promise<void>;
}
export const PluginDeployerDirectoryHandler = Symbol('PluginDeployerDirectoryHandler');
export interface PluginDeployerDirectoryHandler {
accept(pluginDeployerEntry: PluginDeployerEntry): Promise<boolean>;
handle(context: PluginDeployerDirectoryHandlerContext): Promise<void>;
}
export const PluginDeployerFileHandler = Symbol('PluginDeployerFileHandler');
export interface PluginDeployerFileHandler {
accept(pluginDeployerEntry: PluginDeployerEntry): Promise<boolean>;
handle(context: PluginDeployerFileHandlerContext): Promise<void>;
}
export interface PluginDeployerResolverInit {
}
export interface PluginDeployerResolverContext {
addPlugin(pluginId: string, path: string): void;
getPlugins(): PluginDeployerEntry[];
getOriginId(): string;
}
export interface PluginDeployerStartContext {
readonly userEntries: string[]
readonly systemEntries: string[]
}
export const PluginDeployer = Symbol('PluginDeployer');
export interface PluginDeployer {
start(): Promise<void>;
}
export const PluginDeployerParticipant = Symbol('PluginDeployerParticipant');
/**
* A participant can hook into the plugin deployer lifecycle.
*/
export interface PluginDeployerParticipant {
onWillStart?(context: PluginDeployerStartContext): Promise<void>;
}
export enum PluginDeployerEntryType {
FRONTEND,
BACKEND,
HEADLESS // Deployed in the Theia Node server outside the context of a frontend/backend connection
}
/**
* Whether a plugin installed by a user or system.
*/
export enum PluginType {
System,
User
};
export interface UnresolvedPluginEntry {
id: string;
type?: PluginType;
}
export interface PluginDeployerEntry {
/**
* ID (before any resolution)
*/
id(): string;
/**
* Original resolved path
*/
originalPath(): string;
/**
* Local path on the filesystem.
*/
path(): string;
/**
* Get a specific entry
*/
getValue<T>(key: string): T;
/**
* Store a value
*/
storeValue<T>(key: string, value: T): void;
/**
* Update path
*/
updatePath(newPath: string): void;
getChanges(): string[];
isFile(): Promise<boolean>;
isDirectory(): Promise<boolean>;
/**
* Resolved if a resolver has handle this plugin
*/
isResolved(): boolean;
resolvedBy(): string;
/**
* Accepted when a handler is telling this location can go live
*/
isAccepted(...types: PluginDeployerEntryType[]): boolean;
accept(...types: PluginDeployerEntryType[]): void;
hasError(): boolean;
type: PluginType
/**
* A fs path to a directory where a plugin is located.
* Depending on a plugin format it can be different from `path`.
* Use `path` if you want to resolve something within a plugin, like `README.md` file.
* Use `rootPath` if you want to manipulate the entire plugin location, like delete or move it.
*/
rootPath: string
}
export interface PluginDeployerFileHandlerContext {
unzip(sourcePath: string, destPath: string): Promise<void>;
pluginEntry(): PluginDeployerEntry;
}
export interface PluginDeployerDirectoryHandlerContext {
copy(origin: string, target: string): Promise<void>;
pluginEntry(): PluginDeployerEntry;
}
/**
* This interface describes a plugin model object, which is populated from package.json.
*/
export interface PluginModel {
id: string;
name: string;
publisher: string;
version: string;
displayName: string;
description: string;
engine: {
type: PluginEngine;
version: string;
};
entryPoint: PluginEntryPoint;
packageUri: string;
/**
* @deprecated since 1.1.0 - because it lead to problems with getting a relative path
* needed by Icon Themes to correctly load Fonts, use packageUri instead.
*/
packagePath: string;
iconUrl?: string;
l10n?: string;
readmeUrl?: string;
licenseUrl?: string;
}
export interface PluginEntryPoint {
frontend?: string;
backend?: string;
headless?: string;
}
/**
* This interface describes some static plugin contributions.
*/
export interface PluginContribution {
activationEvents?: string[];
authentication?: AuthenticationProviderInformation[];
configuration?: PreferenceSchema[];
configurationDefaults?: PreferenceSchemaProperties;
languages?: LanguageContribution[];
grammars?: GrammarsContribution[];
customEditors?: CustomEditor[];
viewsContainers?: { [location: string]: ViewContainer[] };
views?: { [location: string]: View[] };
viewsWelcome?: ViewWelcome[];
commands?: PluginCommand[];
menus?: { [location: string]: Menu[] };
submenus?: Submenu[];
keybindings?: Keybinding[];
debuggers?: DebuggerContribution[];
snippets?: SnippetContribution[];
themes?: ThemeContribution[];
iconThemes?: IconThemeContribution[];
icons?: IconContribution[];
colors?: ColorDefinition[];
taskDefinitions?: TaskDefinition[];
problemMatchers?: ProblemMatcherContribution[];
problemPatterns?: ProblemPatternContribution[];
resourceLabelFormatters?: ResourceLabelFormatter[];
localizations?: Localization[];
terminalProfiles?: TerminalProfile[];
notebooks?: NotebookContribution[];
notebookRenderer?: NotebookRendererContribution[];
}
export interface NotebookContribution {
type: string;
displayName: string;
selector?: readonly { filenamePattern?: string; excludeFileNamePattern?: string }[];
priority?: string;
}
export interface NotebookRendererContribution {
readonly id: string;
readonly displayName: string;
readonly mimeTypes: string[];
readonly entrypoint: string | { readonly extends: string; readonly path: string };
readonly requiresMessaging?: 'always' | 'optional' | 'never'
}
export interface AuthenticationProviderInformation {
id: string;
label: string;
}
export interface TerminalProfile {
title: string,
id: string,
icon?: string
}
export interface Localization {
languageId: string;
languageName?: string;
localizedLanguageName?: string;
translations: Translation[];
minimalTranslations?: { [key: string]: string };
}
export interface Translation {
id: string;
path: string;
cachedContents?: { [scope: string]: { [key: string]: string } };
}
export interface SnippetContribution {
uri: string
source: string
language?: string
}
export type UiTheme = 'vs' | 'vs-dark' | 'hc-black';
export interface ThemeContribution {
id?: string;
label?: string;
description?: string;
uri: string;
uiTheme?: UiTheme;
}
export interface IconThemeContribution {
id: string;
label?: string;
description?: string;
uri: string;
uiTheme?: UiTheme;
}
export interface IconDefinition {
fontCharacter: string;
location: string;
}
export type IconDefaults = ThemeIcon | IconDefinition;
export interface IconContribution {
id: string;
extensionId: string;
description: string | undefined;
defaults: IconDefaults;
}
export namespace IconContribution {
export function isIconDefinition(defaults: IconDefaults): defaults is IconDefinition {
return 'fontCharacter' in defaults;
}
}
export interface GrammarsContribution {
format: 'json' | 'plist';
language?: string;
scope: string;
grammar?: string | object;
grammarLocation?: string;
embeddedLanguages?: ScopeMap;
tokenTypes?: ScopeMap;
injectTo?: string[];
balancedBracketScopes?: string[];
unbalancedBracketScopes?: string[];
}
/**
* The language contribution
*/
export interface LanguageContribution {
id: string;
extensions?: string[];
filenames?: string[];
filenamePatterns?: string[];
firstLine?: string;
aliases?: string[];
mimetypes?: string[];
configuration?: LanguageConfiguration;
/**
* @internal
*/
icon?: IconUrl;
}
export interface RegExpOptions {
pattern: string;
flags?: string;
}
export interface LanguageConfiguration {
brackets?: CharacterPair[];
indentationRules?: IndentationRules;
surroundingPairs?: AutoClosingPair[];
autoClosingPairs?: AutoClosingPairConditional[];
comments?: CommentRule;
folding?: FoldingRules;
wordPattern?: string | RegExpOptions;
onEnterRules?: OnEnterRule[];
}
/**
* This interface describes a package.json debuggers contribution section object.
*/
export interface DebuggerContribution extends PlatformSpecificAdapterContribution {
type: string,
label?: string,
languages?: string[],
enableBreakpointsFor?: {
languageIds: string[]
},
configurationAttributes?: {
[request: string]: IJSONSchema
},
configurationSnippets?: IJSONSchemaSnippet[],
variables?: ScopeMap,
adapterExecutableCommand?: string
win?: PlatformSpecificAdapterContribution;
winx86?: PlatformSpecificAdapterContribution;
windows?: PlatformSpecificAdapterContribution;
osx?: PlatformSpecificAdapterContribution;
linux?: PlatformSpecificAdapterContribution;
}
export interface IndentationRules {
increaseIndentPattern: string | RegExpOptions;
decreaseIndentPattern: string | RegExpOptions;
unIndentedLinePattern?: string | RegExpOptions;
indentNextLinePattern?: string | RegExpOptions;
}
export interface AutoClosingPair {
close: string;
open: string;
}
export interface AutoClosingPairConditional extends AutoClosingPair {
notIn?: string[];
}
export interface FoldingMarkers {
start: string | RegExpOptions;
end: string | RegExpOptions;
}
export interface FoldingRules {
offSide?: boolean;
markers?: FoldingMarkers;
}
export interface OnEnterRule {
beforeText: string | RegExpOptions;
afterText?: string | RegExpOptions;
previousLineText?: string | RegExpOptions;
action: EnterAction;
}
export interface EnterAction {
indent: 'none' | 'indent' | 'outdent' | 'indentOutdent';
appendText?: string;
removeText?: number;
}
/**
* Custom Editors contribution
*/
export interface CustomEditor {
viewType: string;
displayName: string;
selector: CustomEditorSelector[];
priority: CustomEditorPriority;
}
/**
* Views Containers contribution
*/
export interface ViewContainer {
id: string;
title: string;
iconUrl: string;
themeIcon?: string;
}
/**
* View contribution
*/
export interface View {
id: string;
name: string;
when?: string;
type?: string;
}
/**
* View Welcome contribution
*/
export interface ViewWelcome {
view: string;
content: string;
when?: string;
order: number;
}
export interface PluginCommand {
command: string;
title: string;
originalTitle?: string;
category?: string;
iconUrl?: IconUrl;
themeIcon?: string;
enablement?: string;
}
export type IconUrl = string | { light: string; dark: string; };
/**
* Menu contribution
*/
export interface Menu {
command?: string;
submenu?: string
alt?: string;
group?: string;
when?: string;
}
export interface Submenu {
id: string;
label: string;
icon?: IconUrl;
}
/**
* Keybinding contribution
*/
export interface Keybinding {
keybinding?: string;
command: string;
when?: string;
mac?: string;
linux?: string;
win?: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
args?: any;
}
/**
* This interface describes a plugin lifecycle object.
*/
export interface PluginLifecycle {
startMethod: string;
stopMethod: string;
/**
* Frontend module name, frontend plugin should expose this name.
*/
frontendModuleName?: string;
/**
* Path to the script which should do some initialization before frontend plugin is loaded.
*/
frontendInitPath?: string;
/**
* Path to the script which should do some initialization before backend plugin is loaded.
*/
backendInitPath?: string;
}
/**
* The export function of initialization module of backend plugin.
*/
export interface BackendInitializationFn {
(apiFactory: PluginAPIFactory, plugin: Plugin): void;
}
export interface BackendLoadingFn {
(rpc: RPCProtocol, plugin: Plugin): void;
}
export interface PluginContext {
subscriptions: Disposable[];
}
export interface ExtensionContext {
subscriptions: Disposable[];
}
export interface PluginMetadata {
host: string;
model: PluginModel;
lifecycle: PluginLifecycle;
isUnderDevelopment?: boolean;
outOfSync: boolean;
}
export const MetadataProcessor = Symbol('MetadataProcessor');
export interface MetadataProcessor {
process(pluginMetadata: PluginMetadata): void;
}
export function getPluginId(plugin: PluginPackage | PluginModel): string {
return `${plugin.publisher}_${plugin.name}`.replace(/\W/g, '_');
}
export function buildFrontendModuleName(plugin: PluginPackage | PluginModel): string {
return `${plugin.publisher}_${plugin.name}`.replace(/\W/g, '_');
}
export const HostedPluginClient = Symbol('HostedPluginClient');
export interface HostedPluginClient {
postMessage(pluginHost: string, buffer: Uint8Array): Promise<void>;
log(logPart: LogPart): void;
onDidDeploy(): void;
}
export interface PluginDependencies {
metadata: PluginMetadata
/**
* Actual listing of plugin dependencies.
* Mapping from {@link PluginIdentifiers.UnversionedId external representation} of plugin identity to a string
* that can be used to identify the resolver for the specific plugin case, e.g. with scheme `vscode://<id>`.
*/
mapping?: Map<string, string>
}
export const PluginDeployerHandler = Symbol('PluginDeployerHandler');
export interface PluginDeployerHandler {
deployFrontendPlugins(frontendPlugins: PluginDeployerEntry[]): Promise<number | undefined>;
deployBackendPlugins(backendPlugins: PluginDeployerEntry[]): Promise<number | undefined>;
getDeployedPluginsById(pluginId: string): DeployedPlugin[];
getDeployedPlugin(pluginId: PluginIdentifiers.VersionedId): DeployedPlugin | undefined;
/**
* Removes the plugin from the location it originally resided on disk.
* Unless `--uncompressed-plugins-in-place` is passed to the CLI, this operation is safe.
*/
uninstallPlugin(pluginId: PluginIdentifiers.VersionedId): Promise<boolean>;
/**
* Removes the plugin from the locations to which it had been deployed.
* This operation is not safe - references to deleted assets may remain.
*/
undeployPlugin(pluginId: PluginIdentifiers.VersionedId): Promise<boolean>;
getPluginDependencies(pluginToBeInstalled: PluginDeployerEntry): Promise<PluginDependencies | undefined>;
}
export interface GetDeployedPluginsParams {
pluginIds: PluginIdentifiers.VersionedId[]
}
export interface DeployedPlugin {
/**
* defaults to system
*/
type?: PluginType;
metadata: PluginMetadata;