@theia/plugin 1.63.0-next.52 → 1.63.1

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.
Files changed (2) hide show
  1. package/package.json +3 -3
  2. package/src/theia.d.ts +220 -15
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@theia/plugin",
3
- "version": "1.63.0-next.52+176018e53",
3
+ "version": "1.63.1",
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.62.0"
30
+ "@theia/ext-scripts": "1.63.1"
31
31
  },
32
32
  "nyc": {
33
33
  "extends": "../../configs/nyc.json"
34
34
  },
35
- "gitHead": "176018e53e62cafec9b25b23ac9f0b4826b6d0f7"
35
+ "gitHead": "c1f24d58391fec06087b0c4526ce97aa248c3405"
36
36
  }
package/src/theia.d.ts CHANGED
@@ -1454,6 +1454,24 @@ export module '@theia/plugin' {
1454
1454
  */
1455
1455
  readonly languageId: string;
1456
1456
 
1457
+ /**
1458
+ * The file encoding of this document that will be used when the document is saved.
1459
+ *
1460
+ * Use the {@link workspace.onDidChangeTextDocument onDidChangeTextDocument}-event to
1461
+ * get notified when the document encoding changes.
1462
+ *
1463
+ * Note that the possible encoding values are currently defined as any of the following:
1464
+ * 'utf8', 'utf8bom', 'utf16le', 'utf16be', 'windows1252', 'iso88591', 'iso88593',
1465
+ * 'iso885915', 'macroman', 'cp437', 'windows1256', 'iso88596', 'windows1257',
1466
+ * 'iso88594', 'iso885914', 'windows1250', 'iso88592', 'cp852', 'windows1251',
1467
+ * 'cp866', 'cp1125', 'iso88595', 'koi8r', 'koi8u', 'iso885913', 'windows1253',
1468
+ * 'iso88597', 'windows1255', 'iso88598', 'iso885910', 'iso885916', 'windows1254',
1469
+ * 'iso88599', 'windows1258', 'gbk', 'gb18030', 'cp950', 'big5hkscs', 'shiftjis',
1470
+ * 'eucjp', 'euckr', 'windows874', 'iso885911', 'koi8ru', 'koi8t', 'gb2312',
1471
+ * 'cp865', 'cp850'.
1472
+ */
1473
+ readonly encoding: string;
1474
+
1457
1475
  /**
1458
1476
  * The version number of this document (it will strictly increase after each
1459
1477
  * change, including undo/redo).
@@ -7871,29 +7889,75 @@ export module '@theia/plugin' {
7871
7889
  * Opens a document. Will return early if this document is already open. Otherwise
7872
7890
  * the document is loaded and the {@link workspace.onDidOpenTextDocument didOpen}-event fires.
7873
7891
  *
7874
- * The document is denoted by an {@link Uri uri}. Depending on the {@link Uri.scheme scheme} the
7892
+ * The document is denoted by an {@link Uri}. Depending on the {@link Uri.scheme scheme} the
7875
7893
  * following rules apply:
7876
- * * `file`-scheme: Open a file on disk, will be rejected if the file does not exist or cannot be loaded.
7877
- * * `untitled`-scheme: A new file that should be saved on disk, e.g. `untitled:c:\frodo\new.js`. The language
7878
- * will be derived from the file name.
7879
- * * For all other schemes the registered text document content {@link TextDocumentContentProvider providers} are consulted.
7894
+ * * `file`-scheme: Open a file on disk (`openTextDocument(Uri.file(path))`). Will be rejected if the file
7895
+ * does not exist or cannot be loaded.
7896
+ * * `untitled`-scheme: Open a blank untitled file with associated path (`openTextDocument(Uri.file(path).with({ scheme: 'untitled' }))`).
7897
+ * The language will be derived from the file name.
7898
+ * * For all other schemes contributed {@link TextDocumentContentProvider text document content providers} and
7899
+ * {@link FileSystemProvider file system providers} are consulted.
7880
7900
  *
7881
7901
  * *Note* that the lifecycle of the returned document is owned by the editor and not by the extension. That means an
7882
- * [`onDidClose`](#workspace.onDidCloseTextDocument)-event can occur at any time after opening it.
7902
+ * {@linkcode workspace.onDidCloseTextDocument onDidClose}-event can occur at any time after opening it.
7883
7903
  *
7884
7904
  * @param uri Identifies the resource to open.
7885
- * @return A promise that resolves to a {@link TextDocument document}.
7905
+ * @returns A promise that resolves to a {@link TextDocument document}.
7886
7906
  */
7887
- export function openTextDocument(uri: Uri): Thenable<TextDocument | undefined>;
7907
+ export function openTextDocument(uri: Uri, options?: {
7908
+ /**
7909
+ * The {@link TextDocument.encoding encoding} of the document to use
7910
+ * for decoding the underlying buffer to text. If omitted, the encoding
7911
+ * will be guessed based on the file content and/or the editor settings
7912
+ * unless the document is already opened.
7913
+ *
7914
+ * Opening a text document that was already opened with a different encoding
7915
+ * has the potential of changing the text contents of the text document.
7916
+ * Specifically, when the encoding results in a different set of characters
7917
+ * than the previous encoding. As such, an error is thrown for dirty documents
7918
+ * when the specified encoding is different from the encoding of the document.
7919
+ *
7920
+ * See {@link TextDocument.encoding} for more information about valid
7921
+ * values for encoding. Using an unsupported encoding will fallback to the
7922
+ * default encoding for the document.
7923
+ *
7924
+ * *Note* that if you open a document with an encoding that does not
7925
+ * support decoding the underlying bytes, content may be replaced with
7926
+ * substitution characters as appropriate.
7927
+ */
7928
+ readonly encoding?: string;
7929
+ }): Thenable<TextDocument>;
7888
7930
 
7889
7931
  /**
7890
- * A short-hand for `openTextDocument(Uri.file(fileName))`.
7932
+ * A short-hand for `openTextDocument(Uri.file(path))`.
7891
7933
  *
7892
- * @see {@link openTextDocument openTextDocument}
7893
- * @param fileName A name of a file on disk.
7894
- * @return A promise that resolves to a {@link TextDocument document}.
7934
+ * @see {@link workspace.openTextDocument}
7935
+ * @param path A path of a file on disk.
7936
+ * @returns A promise that resolves to a {@link TextDocument document}.
7895
7937
  */
7896
- export function openTextDocument(fileName: string): Thenable<TextDocument | undefined>;
7938
+ export function openTextDocument(path: string, options?: {
7939
+ /**
7940
+ * The {@link TextDocument.encoding encoding} of the document to use
7941
+ * for decoding the underlying buffer to text. If omitted, the encoding
7942
+ * will be guessed based on the file content and/or the editor settings
7943
+ * unless the document is already opened.
7944
+ *
7945
+ * Opening a text document that was already opened with a different encoding
7946
+ * has the potential of changing the text contents of the text document.
7947
+ * Specifically, when the encoding results in a different set of characters
7948
+ * than the previous encoding. As such, an error is thrown for dirty documents
7949
+ * when the specified encoding is different from the encoding of the document.
7950
+ *
7951
+ * See {@link TextDocument.encoding} for more information about valid
7952
+ * values for encoding. Using an unsupported encoding will fallback to the
7953
+ * default encoding for the document.
7954
+ *
7955
+ * *Note* that if you open a document with an encoding that does not
7956
+ * support decoding the underlying bytes, content may be replaced with
7957
+ * substitution characters as appropriate.
7958
+ */
7959
+ readonly encoding?: string;
7960
+ }): Thenable<TextDocument>;
7897
7961
 
7898
7962
  /**
7899
7963
  * Opens an untitled text document. The editor will prompt the user for a file
@@ -7901,9 +7965,26 @@ export module '@theia/plugin' {
7901
7965
  * specify the *language* and/or the *content* of the document.
7902
7966
  *
7903
7967
  * @param options Options to control how the document will be created.
7904
- * @return A promise that resolves to a {@link TextDocument document}.
7968
+ * @returns A promise that resolves to a {@link TextDocument document}.
7905
7969
  */
7906
- export function openTextDocument(options?: { language?: string; content?: string; }): Thenable<TextDocument | undefined>;
7970
+ export function openTextDocument(options?: {
7971
+ /**
7972
+ * The {@link TextDocument.languageId language} of the document.
7973
+ */
7974
+ language?: string;
7975
+ /**
7976
+ * The initial contents of the document.
7977
+ */
7978
+ content?: string;
7979
+ /**
7980
+ * The {@link TextDocument.encoding encoding} of the document.
7981
+ *
7982
+ * See {@link TextDocument.encoding} for more information about valid
7983
+ * values for encoding. Using an unsupported encoding will fallback to the
7984
+ * default encoding for the document.
7985
+ */
7986
+ readonly encoding?: string;
7987
+ }): Thenable<TextDocument>;
7907
7988
 
7908
7989
  /**
7909
7990
  * Open a notebook. Will return early if this notebook is already {@link NotebookDocument loaded}.
@@ -8138,6 +8219,130 @@ export module '@theia/plugin' {
8138
8219
  * Event that fires when the current workspace has been trusted.
8139
8220
  */
8140
8221
  export const onDidGrantWorkspaceTrust: Event<void>;
8222
+
8223
+ /**
8224
+ * Decodes the content from a `Uint8Array` to a `string`. You MUST
8225
+ * provide the entire content at once to ensure that the encoding
8226
+ * can properly apply. Do not use this method to decode content
8227
+ * in chunks, as that may lead to incorrect results.
8228
+ *
8229
+ * Will pick an encoding based on settings and the content of the
8230
+ * buffer (for example byte order marks).
8231
+ *
8232
+ * *Note* that if you decode content that is unsupported by the
8233
+ * encoding, the result may contain substitution characters as
8234
+ * appropriate.
8235
+ *
8236
+ * @throws This method will throw an error when the content is binary.
8237
+ *
8238
+ * @param content The text content to decode as a `Uint8Array`.
8239
+ * @returns A thenable that resolves to the decoded `string`.
8240
+ */
8241
+ export function decode(content: Uint8Array): Thenable<string>;
8242
+
8243
+ /**
8244
+ * Decodes the content from a `Uint8Array` to a `string` using the
8245
+ * provided encoding. You MUST provide the entire content at once
8246
+ * to ensure that the encoding can properly apply. Do not use this
8247
+ * method to decode content in chunks, as that may lead to incorrect
8248
+ * results.
8249
+ *
8250
+ * *Note* that if you decode content that is unsupported by the
8251
+ * encoding, the result may contain substitution characters as
8252
+ * appropriate.
8253
+ *
8254
+ * @throws This method will throw an error when the content is binary.
8255
+ *
8256
+ * @param content The text content to decode as a `Uint8Array`.
8257
+ * @param options Additional context for picking the encoding.
8258
+ * @returns A thenable that resolves to the decoded `string`.
8259
+ */
8260
+ export function decode(content: Uint8Array, options: {
8261
+ /**
8262
+ * Allows to explicitly pick the encoding to use.
8263
+ * See {@link TextDocument.encoding} for more information
8264
+ * about valid values for encoding.
8265
+ * Using an unsupported encoding will fallback to the
8266
+ * default configured encoding.
8267
+ */
8268
+ readonly encoding: string;
8269
+ }): Thenable<string>;
8270
+
8271
+ /**
8272
+ * Decodes the content from a `Uint8Array` to a `string`. You MUST
8273
+ * provide the entire content at once to ensure that the encoding
8274
+ * can properly apply. Do not use this method to decode content
8275
+ * in chunks, as that may lead to incorrect results.
8276
+ *
8277
+ * The encoding is picked based on settings and the content
8278
+ * of the buffer (for example byte order marks).
8279
+ *
8280
+ * *Note* that if you decode content that is unsupported by the
8281
+ * encoding, the result may contain substitution characters as
8282
+ * appropriate.
8283
+ *
8284
+ * @throws This method will throw an error when the content is binary.
8285
+ *
8286
+ * @param content The content to decode as a `Uint8Array`.
8287
+ * @param options Additional context for picking the encoding.
8288
+ * @returns A thenable that resolves to the decoded `string`.
8289
+ */
8290
+ export function decode(content: Uint8Array, options: {
8291
+ /**
8292
+ * The URI that represents the file if known. This information
8293
+ * is used to figure out the encoding related configuration
8294
+ * for the file if any.
8295
+ */
8296
+ readonly uri: Uri;
8297
+ }): Thenable<string>;
8298
+
8299
+ /**
8300
+ * Encodes the content of a `string` to a `Uint8Array`.
8301
+ *
8302
+ * Will pick an encoding based on settings.
8303
+ *
8304
+ * @param content The content to decode as a `string`.
8305
+ * @returns A thenable that resolves to the encoded `Uint8Array`.
8306
+ */
8307
+ export function encode(content: string): Thenable<Uint8Array>;
8308
+
8309
+ /**
8310
+ * Encodes the content of a `string` to a `Uint8Array` using the
8311
+ * provided encoding.
8312
+ *
8313
+ * @param content The content to decode as a `string`.
8314
+ * @param options Additional context for picking the encoding.
8315
+ * @returns A thenable that resolves to the encoded `Uint8Array`.
8316
+ */
8317
+ export function encode(content: string, options: {
8318
+ /**
8319
+ * Allows to explicitly pick the encoding to use.
8320
+ * See {@link TextDocument.encoding} for more information
8321
+ * about valid values for encoding.
8322
+ * Using an unsupported encoding will fallback to the
8323
+ * default configured encoding.
8324
+ */
8325
+ readonly encoding: string;
8326
+ }): Thenable<Uint8Array>;
8327
+
8328
+ /**
8329
+ * Encodes the content of a `string` to a `Uint8Array`.
8330
+ *
8331
+ * The encoding is picked based on settings.
8332
+ *
8333
+ * @param content The content to decode as a `string`.
8334
+ * @param options Additional context for picking the encoding.
8335
+ * @returns A thenable that resolves to the encoded `Uint8Array`.
8336
+ */
8337
+ export function encode(content: string, options: {
8338
+ /**
8339
+ * The URI that represents the file if known. This information
8340
+ * is used to figure out the encoding related configuration
8341
+ * for the file if any.
8342
+ */
8343
+ readonly uri: Uri;
8344
+ }): Thenable<Uint8Array>;
8345
+
8141
8346
  }
8142
8347
 
8143
8348
  export interface WorkspaceTrustRequestButton {