@theia/plugin 1.37.1 → 1.38.0-next.27

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/plugin",
3
- "version": "1.37.1",
3
+ "version": "1.38.0-next.27+39dfc8ca1",
4
4
  "description": "Theia - Plugin API",
5
5
  "types": "./src/theia.d.ts",
6
6
  "publishConfig": {
@@ -27,10 +27,10 @@
27
27
  "watch": "theiaext watch"
28
28
  },
29
29
  "devDependencies": {
30
- "@theia/ext-scripts": "1.37.1"
30
+ "@theia/ext-scripts": "1.37.0"
31
31
  },
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "3bc4e97b2f730db070f596e97f3bd6e331ad8414"
35
+ "gitHead": "39dfc8ca1294b972c693e5c3b31f5f6685238d10"
36
36
  }
@@ -613,7 +613,153 @@ export module '@theia/plugin' {
613
613
 
614
614
  }
615
615
 
616
+ // #region DocumentPaste
617
+
618
+ // https://github.com/microsoft/vscode/issues/30066/
619
+
620
+ /**
621
+ * Provider invoked when the user copies and pastes code.
622
+ */
623
+ export interface DocumentPasteEditProvider {
624
+
625
+ /**
626
+ * Optional method invoked after the user copies text in a file.
627
+ *
628
+ * During {@link prepareDocumentPaste}, an extension can compute metadata that is attached to
629
+ * a {@link DataTransfer} and is passed back to the provider in {@link provideDocumentPasteEdits}.
630
+ *
631
+ * @param document Document where the copy took place.
632
+ * @param ranges Ranges being copied in the `document`.
633
+ * @param dataTransfer The data transfer associated with the copy. You can store additional values on this for later use in {@link provideDocumentPasteEdits}.
634
+ * @param token A cancellation token.
635
+ */
636
+ prepareDocumentPaste?(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): void | Thenable<void>;
637
+
638
+ /**
639
+ * Invoked before the user pastes into a document.
640
+ *
641
+ * In this method, extensions can return a workspace edit that replaces the standard pasting behavior.
642
+ *
643
+ * @param document Document being pasted into
644
+ * @param ranges Currently selected ranges in the document.
645
+ * @param dataTransfer The data transfer associated with the paste.
646
+ * @param token A cancellation token.
647
+ *
648
+ * @return Optional workspace edit that applies the paste. Return undefined to use standard pasting.
649
+ */
650
+ provideDocumentPasteEdits(document: TextDocument, ranges: readonly Range[], dataTransfer: DataTransfer, token: CancellationToken): ProviderResult<DocumentPasteEdit>;
651
+ }
652
+
653
+ /**
654
+ * An operation applied on paste
655
+ */
656
+ class DocumentPasteEdit {
657
+ /**
658
+ * The text or snippet to insert at the pasted locations.
659
+ */
660
+ insertText: string | SnippetString;
661
+
662
+ /**
663
+ * An optional additional edit to apply on paste.
664
+ */
665
+ additionalEdit?: WorkspaceEdit;
666
+
667
+ /**
668
+ * @param insertText The text or snippet to insert at the pasted locations.
669
+ */
670
+ constructor(insertText: string | SnippetString);
671
+ }
672
+
673
+ interface DocumentPasteProviderMetadata {
674
+ /**
675
+ * Mime types that `provideDocumentPasteEdits` should be invoked for.
676
+ *
677
+ * Use the special `files` mimetype to indicate the provider should be invoked if any files are present in the `DataTransfer`.
678
+ */
679
+ readonly pasteMimeTypes: readonly string[];
680
+ }
681
+
682
+ namespace languages {
683
+ export function registerDocumentPasteEditProvider(selector: DocumentSelector, provider: DocumentPasteEditProvider, metadata: DocumentPasteProviderMetadata): Disposable;
684
+ }
685
+ // #endregion
686
+
687
+ // #region SessionIdentityProvider
688
+ export namespace workspace {
689
+ /**
690
+ *
691
+ * @param scheme The URI scheme that this provider can provide edit session identities for.
692
+ * @param provider A provider which can convert URIs for workspace folders of scheme @param scheme to
693
+ * an edit session identifier which is stable across machines. This enables edit sessions to be resolved.
694
+ */
695
+ export function registerEditSessionIdentityProvider(scheme: string, provider: EditSessionIdentityProvider): Disposable;
696
+ }
697
+
698
+ export interface EditSessionIdentityProvider {
699
+ /**
700
+ *
701
+ * @param workspaceFolder The workspace folder to provide an edit session identity for.
702
+ * @param token A cancellation token for the request.
703
+ * @returns An string representing the edit session identity for the requested workspace folder.
704
+ */
705
+ provideEditSessionIdentity(workspaceFolder: WorkspaceFolder, token: CancellationToken): ProviderResult<string>;
706
+ }
707
+
616
708
  // #endregion
709
+
710
+ // #region ProfileContentHandler
711
+
712
+ export interface ProfileContentHandler {
713
+ readonly name: string;
714
+ saveProfile(name: string, content: string, token: CancellationToken): Thenable<Uri | null>;
715
+ readProfile(uri: Uri, token: CancellationToken): Thenable<string | null>;
716
+ }
717
+
718
+ export namespace window {
719
+ export function registerProfileContentHandler(id: string, profileContentHandler: ProfileContentHandler): Disposable;
720
+ }
721
+
722
+ // #endregion ProfileContentHandler
723
+
724
+ // #region TerminalQuickFixProvider
725
+
726
+ export namespace window {
727
+ /**
728
+ * @param provider A terminal quick fix provider
729
+ * @return A {@link Disposable} that un-registers the provider when being disposed
730
+ */
731
+ export function registerTerminalQuickFixProvider(id: string, provider: TerminalQuickFixProvider): Disposable;
732
+ }
733
+
734
+ export interface TerminalQuickFixProvider {
735
+ /**
736
+ * Provides terminal quick fixes
737
+ * @param commandMatchResult The command match result for which to provide quick fixes
738
+ * @param token A cancellation token indicating the result is no longer needed
739
+ * @return Terminal quick fix(es) if any
740
+ */
741
+ provideTerminalQuickFixes(commandMatchResult: TerminalCommandMatchResult, token: CancellationToken): TerminalQuickFix[] | TerminalQuickFix | undefined;
742
+ }
743
+
744
+ export interface TerminalCommandMatchResult {
745
+ commandLine: string;
746
+ commandLineMatch: RegExpMatchArray;
747
+ outputMatch?: {
748
+ regexMatch: RegExpMatchArray;
749
+ outputLines?: string[];
750
+ };
751
+ }
752
+
753
+ interface TerminalQuickFix {
754
+ type: TerminalQuickFixType;
755
+ }
756
+
757
+ enum TerminalQuickFixType {
758
+ command = 'command',
759
+ opener = 'opener'
760
+ }
761
+
762
+ // #endRegion TerminalQuickFixProvider
617
763
  }
618
764
 
619
765
  /**
package/src/theia.d.ts CHANGED
@@ -22,6 +22,7 @@
22
22
  *--------------------------------------------------------------------------------------------*/
23
23
  import './theia-extra';
24
24
  import './theia-proposed';
25
+ import './theia.proposed.externalUriOpener';
25
26
 
26
27
  /* eslint-disable @typescript-eslint/no-explicit-any */
27
28
  /* eslint-disable max-len */
@@ -7565,6 +7566,15 @@ export module '@theia/plugin' {
7565
7566
  */
7566
7567
  export const onDidChangeTelemetryEnabled: Event<boolean>;
7567
7568
 
7569
+ /**
7570
+ * Creates a new {@link TelemetryLogger telemetry logger}.
7571
+ *
7572
+ * @param sender The telemetry sender that is used by the telemetry logger.
7573
+ * @param options Options for the telemetry logger.
7574
+ * @returns A new telemetry logger
7575
+ */
7576
+ export function createTelemetryLogger(sender: TelemetrySender, options?: TelemetryLoggerOptions): TelemetryLogger;
7577
+
7568
7578
  /**
7569
7579
  * The name of a remote. Defined by extensions, popular samples are `wsl` for the Windows
7570
7580
  * Subsystem for Linux or `ssh-remote` for remotes using a secure shell.
@@ -14209,6 +14219,144 @@ export module '@theia/plugin' {
14209
14219
  close(tabGroup: TabGroup | readonly TabGroup[], preserveFocus?: boolean): Thenable<boolean>;
14210
14220
  }
14211
14221
 
14222
+ /**
14223
+ * A special value wrapper denoting a value that is safe to not clean.
14224
+ * This is to be used when you can guarantee no identifiable information is contained in the value and the cleaning is improperly redacting it.
14225
+ */
14226
+ export class TelemetryTrustedValue<T = any> {
14227
+ readonly value: T;
14228
+
14229
+ constructor(value: T);
14230
+ }
14231
+
14232
+ /**
14233
+ * A telemetry logger which can be used by extensions to log usage and error telemetry.
14234
+ *
14235
+ * A logger wraps around a {@link TelemetrySender sender} but it guarantees that
14236
+ * - user settings to disable or tweak telemetry are respected, and that
14237
+ * - potential sensitive data is removed
14238
+ *
14239
+ * It also enables an "echo UI" that prints whatever data is send and it allows the editor
14240
+ * to forward unhandled errors to the respective extensions.
14241
+ *
14242
+ * To get an instance of a `TelemetryLogger`, use
14243
+ * {@link env.createTelemetryLogger `createTelemetryLogger`}.
14244
+ */
14245
+ export interface TelemetryLogger {
14246
+
14247
+ /**
14248
+ * An {@link Event} which fires when the enablement state of usage or error telemetry changes.
14249
+ */
14250
+ readonly onDidChangeEnableStates: Event<TelemetryLogger>;
14251
+
14252
+ /**
14253
+ * Whether or not usage telemetry is enabled for this logger.
14254
+ */
14255
+ readonly isUsageEnabled: boolean;
14256
+
14257
+ /**
14258
+ * Whether or not error telemetry is enabled for this logger.
14259
+ */
14260
+ readonly isErrorsEnabled: boolean;
14261
+
14262
+ /**
14263
+ * Log a usage event.
14264
+ *
14265
+ * After completing cleaning, telemetry setting checks, and data mix-in calls `TelemetrySender.sendEventData` to log the event.
14266
+ * Automatically supports echoing to extension telemetry output channel.
14267
+ * @param eventName The event name to log
14268
+ * @param data The data to log
14269
+ */
14270
+ logUsage(eventName: string, data?: Record<string, any | TelemetryTrustedValue>): void;
14271
+
14272
+ /**
14273
+ * Log an error event.
14274
+ *
14275
+ * After completing cleaning, telemetry setting checks, and data mix-in calls `TelemetrySender.sendEventData` to log the event. Differs from `logUsage` in that it will log the event if the telemetry setting is Error+.
14276
+ * Automatically supports echoing to extension telemetry output channel.
14277
+ * @param eventName The event name to log
14278
+ * @param data The data to log
14279
+ */
14280
+ logError(eventName: string, data?: Record<string, any | TelemetryTrustedValue>): void;
14281
+
14282
+ /**
14283
+ * Log an error event.
14284
+ *
14285
+ * Calls `TelemetrySender.sendErrorData`. Does cleaning, telemetry checks, and data mix-in.
14286
+ * Automatically supports echoing to extension telemetry output channel.
14287
+ * Will also automatically log any exceptions thrown within the extension host process.
14288
+ * @param error The error object which contains the stack trace cleaned of PII
14289
+ * @param data Additional data to log alongside the stack trace
14290
+ */
14291
+ logError(error: Error, data?: Record<string, any | TelemetryTrustedValue>): void;
14292
+
14293
+ /**
14294
+ * Dispose this object and free resources.
14295
+ */
14296
+ dispose(): void;
14297
+ }
14298
+
14299
+ /**
14300
+ * The telemetry sender is the contract between a telemetry logger and some telemetry service. **Note** that extensions must NOT
14301
+ * call the methods of their sender directly as the logger provides extra guards and cleaning.
14302
+ *
14303
+ * ```js
14304
+ * const sender: vscode.TelemetrySender = {...};
14305
+ * const logger = vscode.env.createTelemetryLogger(sender);
14306
+ *
14307
+ * // GOOD - uses the logger
14308
+ * logger.logUsage('myEvent', { myData: 'myValue' });
14309
+ *
14310
+ * // BAD - uses the sender directly: no data cleansing, ignores user settings, no echoing to the telemetry output channel etc
14311
+ * sender.logEvent('myEvent', { myData: 'myValue' });
14312
+ * ```
14313
+ */
14314
+ export interface TelemetrySender {
14315
+ /**
14316
+ * Function to send event data without a stacktrace. Used within a {@link TelemetryLogger}
14317
+ *
14318
+ * @param eventName The name of the event which you are logging
14319
+ * @param data A serializable key value pair that is being logged
14320
+ */
14321
+ sendEventData(eventName: string, data?: Record<string, any>): void;
14322
+
14323
+ /**
14324
+ * Function to send an error. Used within a {@link TelemetryLogger}
14325
+ *
14326
+ * @param error The error being logged
14327
+ * @param data Any additional data to be collected with the exception
14328
+ */
14329
+ sendErrorData(error: Error, data?: Record<string, any>): void;
14330
+
14331
+ /**
14332
+ * Optional flush function which will give this sender a chance to send any remaining events
14333
+ * as its {@link TelemetryLogger} is being disposed
14334
+ */
14335
+ flush?(): void | Thenable<void>;
14336
+ }
14337
+
14338
+ /**
14339
+ * Options for creating a {@link TelemetryLogger}
14340
+ */
14341
+ export interface TelemetryLoggerOptions {
14342
+ /**
14343
+ * Whether or not you want to avoid having the built-in common properties such as os, extension name, etc injected into the data object.
14344
+ * Defaults to `false` if not defined.
14345
+ */
14346
+ readonly ignoreBuiltInCommonProperties?: boolean;
14347
+
14348
+ /**
14349
+ * Whether or not unhandled errors on the extension host caused by your extension should be logged to your sender.
14350
+ * Defaults to `false` if not defined.
14351
+ */
14352
+ readonly ignoreUnhandledErrors?: boolean;
14353
+
14354
+ /**
14355
+ * Any additional common properties which should be injected into the data object.
14356
+ */
14357
+ readonly additionalCommonProperties?: Record<string, any>;
14358
+ }
14359
+
14212
14360
  /**
14213
14361
  * Represents a notebook editor that is attached to a {@link NotebookDocument notebook}.
14214
14362
  */
@@ -0,0 +1,158 @@
1
+ // *****************************************************************************
2
+ // Copyright (C) 2023 Ericsson and others.
3
+ //
4
+ // This program and the accompanying materials are made available under the
5
+ // terms of the Eclipse Public License v. 2.0 which is available at
6
+ // http://www.eclipse.org/legal/epl-2.0.
7
+ //
8
+ // This Source Code may also be made available under the following Secondary
9
+ // Licenses when the conditions for such availability set forth in the Eclipse
10
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
11
+ // with the GNU Classpath Exception which is available at
12
+ // https://www.gnu.org/software/classpath/license.html.
13
+ //
14
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
15
+ // *****************************************************************************
16
+
17
+ /*---------------------------------------------------------------------------------------------
18
+ * Copyright (c) Microsoft Corporation. All rights reserved.
19
+ * Licensed under the MIT License. See License.txt in the project root for license information.
20
+ *--------------------------------------------------------------------------------------------*/
21
+ // code copied and modified from https://vscode.dev/github/microsoft/vscode/blob/1.77.3/src/vscode-dts/vscode.proposed.externalUriOpener.d.ts
22
+
23
+ export module '@theia/plugin' {
24
+ /**
25
+ * Details if an `ExternalUriOpener` can open a uri.
26
+ *
27
+ * The priority is also used to rank multiple openers against each other and determine
28
+ * if an opener should be selected automatically or if the user should be prompted to
29
+ * select an opener.
30
+ *
31
+ * The editor will try to use the best available opener, as sorted by `ExternalUriOpenerPriority`.
32
+ * If there are multiple potential "best" openers for a URI, then the user will be prompted
33
+ * to select an opener.
34
+ */
35
+ export enum ExternalUriOpenerPriority {
36
+ /**
37
+ * The opener is disabled and will never be shown to users.
38
+ *
39
+ * Note that the opener can still be used if the user specifically
40
+ * configures it in their settings.
41
+ */
42
+ None = 0,
43
+
44
+ /**
45
+ * The opener can open the uri but will not cause a prompt on its own
46
+ * since the editor always contributes a built-in `Default` opener.
47
+ */
48
+ Option = 1,
49
+
50
+ /**
51
+ * The opener can open the uri.
52
+ *
53
+ * The editor's built-in opener has `Default` priority. This means that any additional `Default`
54
+ * openers will cause the user to be prompted to select from a list of all potential openers.
55
+ */
56
+ Default = 2,
57
+
58
+ /**
59
+ * The opener can open the uri and should be automatically selected over any
60
+ * default openers, include the built-in one from the editor.
61
+ *
62
+ * A preferred opener will be automatically selected if no other preferred openers
63
+ * are available. If multiple preferred openers are available, then the user
64
+ * is shown a prompt with all potential openers (not just preferred openers).
65
+ */
66
+ Preferred = 3,
67
+ }
68
+
69
+ /**
70
+ * Handles opening uris to external resources, such as http(s) links.
71
+ *
72
+ * Extensions can implement an `ExternalUriOpener` to open `http` links to a webserver
73
+ * inside of the editor instead of having the link be opened by the web browser.
74
+ *
75
+ * Currently openers may only be registered for `http` and `https` uris.
76
+ */
77
+ export interface ExternalUriOpener {
78
+
79
+ /**
80
+ * Check if the opener can open a uri.
81
+ *
82
+ * @param uri The uri being opened. This is the uri that the user clicked on. It has
83
+ * not yet gone through port forwarding.
84
+ * @param token Cancellation token indicating that the result is no longer needed.
85
+ *
86
+ * @return Priority indicating if the opener can open the external uri.
87
+ */
88
+ canOpenExternalUri(uri: Uri, token: CancellationToken): ExternalUriOpenerPriority | Thenable<ExternalUriOpenerPriority>;
89
+
90
+ /**
91
+ * Open a uri.
92
+ *
93
+ * This is invoked when:
94
+ *
95
+ * - The user clicks a link which does not have an assigned opener. In this case, first `canOpenExternalUri`
96
+ * is called and if the user selects this opener, then `openExternalUri` is called.
97
+ * - The user sets the default opener for a link in their settings and then visits a link.
98
+ *
99
+ * @param resolvedUri The uri to open. This uri may have been transformed by port forwarding, so it
100
+ * may not match the original uri passed to `canOpenExternalUri`. Use `ctx.originalUri` to check the
101
+ * original uri.
102
+ * @param ctx Additional information about the uri being opened.
103
+ * @param token Cancellation token indicating that opening has been canceled.
104
+ *
105
+ * @return Thenable indicating that the opening has completed.
106
+ */
107
+ openExternalUri(resolvedUri: Uri, ctx: OpenExternalUriContext, token: CancellationToken): Thenable<void> | void;
108
+ }
109
+
110
+ /**
111
+ * Additional information about the uri being opened.
112
+ */
113
+ export interface OpenExternalUriContext {
114
+ /**
115
+ * The uri that triggered the open.
116
+ *
117
+ * This is the original uri that the user clicked on or that was passed to `openExternal.`
118
+ * Due to port forwarding, this may not match the `resolvedUri` passed to `openExternalUri`.
119
+ */
120
+ readonly sourceUri: Uri;
121
+ }
122
+
123
+ /**
124
+ * Additional metadata about a registered `ExternalUriOpener`.
125
+ */
126
+ interface ExternalUriOpenerMetadata {
127
+
128
+ /**
129
+ * List of uri schemes the opener is triggered for.
130
+ *
131
+ * Currently only `http` and `https` are supported.
132
+ */
133
+ readonly schemes: readonly string[];
134
+
135
+ /**
136
+ * Text displayed to the user that explains what the opener does.
137
+ *
138
+ * For example, 'Open in browser preview'
139
+ */
140
+ readonly label: string;
141
+ }
142
+
143
+ export namespace window {
144
+ /**
145
+ * Register a new `ExternalUriOpener`.
146
+ *
147
+ * When a uri is about to be opened, an `onOpenExternalUri:SCHEME` activation event is fired.
148
+ *
149
+ * @param id Unique id of the opener, such as `myExtension.browserPreview`. This is used in settings
150
+ * and commands to identify the opener.
151
+ * @param opener Opener to register.
152
+ * @param metadata Additional information about the opener.
153
+ *
154
+ * @returns Disposable that unregisters the opener.
155
+ */
156
+ export function registerExternalUriOpener(id: string, opener: ExternalUriOpener, metadata: ExternalUriOpenerMetadata): Disposable;
157
+ }
158
+ }