@theia/terminal 1.34.2 → 1.34.3

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 (121) hide show
  1. package/LICENSE +641 -641
  2. package/README.md +30 -30
  3. package/lib/browser/base/terminal-service.d.ts +34 -34
  4. package/lib/browser/base/terminal-service.js +7 -7
  5. package/lib/browser/base/terminal-widget.d.ts +184 -184
  6. package/lib/browser/base/terminal-widget.js +34 -34
  7. package/lib/browser/index.d.ts +1 -1
  8. package/lib/browser/index.js +28 -28
  9. package/lib/browser/search/terminal-search-container.d.ts +3 -3
  10. package/lib/browser/search/terminal-search-container.js +28 -28
  11. package/lib/browser/search/terminal-search-widget.d.ts +30 -30
  12. package/lib/browser/search/terminal-search-widget.js +147 -147
  13. package/lib/browser/shell-terminal-profile.d.ts +19 -19
  14. package/lib/browser/shell-terminal-profile.js +39 -39
  15. package/lib/browser/terminal-contribution.d.ts +3 -3
  16. package/lib/browser/terminal-contribution.js +20 -20
  17. package/lib/browser/terminal-copy-on-selection-handler.d.ts +10 -10
  18. package/lib/browser/terminal-copy-on-selection-handler.js +103 -103
  19. package/lib/browser/terminal-file-link-provider.d.ts +24 -24
  20. package/lib/browser/terminal-file-link-provider.js +200 -200
  21. package/lib/browser/terminal-frontend-contribution.d.ts +112 -112
  22. package/lib/browser/terminal-frontend-contribution.js +994 -994
  23. package/lib/browser/terminal-frontend-module.d.ts +5 -5
  24. package/lib/browser/terminal-frontend-module.js +115 -115
  25. package/lib/browser/terminal-keybinding-contexts.d.ts +15 -15
  26. package/lib/browser/terminal-keybinding-contexts.js +71 -71
  27. package/lib/browser/terminal-link-helpers.d.ts +27 -27
  28. package/lib/browser/terminal-link-helpers.js +155 -155
  29. package/lib/browser/terminal-link-provider.d.ts +51 -51
  30. package/lib/browser/terminal-link-provider.js +197 -197
  31. package/lib/browser/terminal-preferences.d.ts +61 -61
  32. package/lib/browser/terminal-preferences.js +329 -329
  33. package/lib/browser/terminal-profile-service.d.ts +55 -55
  34. package/lib/browser/terminal-profile-service.js +149 -149
  35. package/lib/browser/terminal-quick-open-service.d.ts +36 -36
  36. package/lib/browser/terminal-quick-open-service.js +137 -137
  37. package/lib/browser/terminal-theme-service.d.ts +21 -21
  38. package/lib/browser/terminal-theme-service.js +218 -218
  39. package/lib/browser/terminal-url-link-provider.d.ts +11 -11
  40. package/lib/browser/terminal-url-link-provider.js +76 -76
  41. package/lib/browser/terminal-widget-impl.d.ts +173 -173
  42. package/lib/browser/terminal-widget-impl.js +769 -769
  43. package/lib/common/base-terminal-protocol.d.ts +100 -100
  44. package/lib/common/base-terminal-protocol.js +88 -88
  45. package/lib/common/shell-terminal-protocol.d.ts +29 -29
  46. package/lib/common/shell-terminal-protocol.js +22 -22
  47. package/lib/common/terminal-common-module.d.ts +7 -7
  48. package/lib/common/terminal-common-module.js +31 -31
  49. package/lib/common/terminal-protocol.d.ts +12 -12
  50. package/lib/common/terminal-protocol.js +21 -21
  51. package/lib/common/terminal-watcher.d.ts +13 -13
  52. package/lib/common/terminal-watcher.js +70 -70
  53. package/lib/node/base-terminal-server.d.ts +36 -36
  54. package/lib/node/base-terminal-server.js +252 -252
  55. package/lib/node/buffering-stream.d.ts +39 -39
  56. package/lib/node/buffering-stream.js +75 -75
  57. package/lib/node/buffering-stream.spec.d.ts +1 -1
  58. package/lib/node/buffering-stream.spec.js +43 -43
  59. package/lib/node/index.d.ts +1 -1
  60. package/lib/node/index.js +28 -28
  61. package/lib/node/shell-process.d.ts +26 -26
  62. package/lib/node/shell-process.js +106 -106
  63. package/lib/node/shell-terminal-server.d.ts +14 -14
  64. package/lib/node/shell-terminal-server.js +114 -114
  65. package/lib/node/shell-terminal-server.spec.d.ts +1 -1
  66. package/lib/node/shell-terminal-server.spec.js +35 -35
  67. package/lib/node/terminal-backend-contribution.d.ts +9 -9
  68. package/lib/node/terminal-backend-contribution.js +75 -75
  69. package/lib/node/terminal-backend-contribution.slow-spec.d.ts +1 -1
  70. package/lib/node/terminal-backend-contribution.slow-spec.js +54 -54
  71. package/lib/node/terminal-backend-module.d.ts +11 -11
  72. package/lib/node/terminal-backend-module.js +69 -69
  73. package/lib/node/terminal-server.d.ts +9 -9
  74. package/lib/node/terminal-server.js +64 -64
  75. package/lib/node/terminal-server.spec.d.ts +1 -1
  76. package/lib/node/terminal-server.spec.js +41 -41
  77. package/lib/node/test/terminal-test-container.d.ts +2 -2
  78. package/lib/node/test/terminal-test-container.js +40 -40
  79. package/lib/package.spec.js +25 -25
  80. package/package.json +9 -9
  81. package/src/browser/base/terminal-service.ts +60 -60
  82. package/src/browser/base/terminal-widget.ts +244 -244
  83. package/src/browser/index.ts +17 -17
  84. package/src/browser/search/terminal-search-container.ts +28 -28
  85. package/src/browser/search/terminal-search-widget.tsx +161 -161
  86. package/src/browser/shell-terminal-profile.ts +40 -40
  87. package/src/browser/style/terminal-search.css +93 -93
  88. package/src/browser/style/terminal.css +33 -33
  89. package/src/browser/terminal-contribution.ts +19 -19
  90. package/src/browser/terminal-copy-on-selection-handler.ts +92 -92
  91. package/src/browser/terminal-file-link-provider.ts +200 -200
  92. package/src/browser/terminal-frontend-contribution.ts +1048 -1048
  93. package/src/browser/terminal-frontend-module.ts +139 -139
  94. package/src/browser/terminal-keybinding-contexts.ts +52 -52
  95. package/src/browser/terminal-link-helpers.ts +187 -187
  96. package/src/browser/terminal-link-provider.ts +203 -203
  97. package/src/browser/terminal-preferences.ts +427 -427
  98. package/src/browser/terminal-profile-service.ts +170 -170
  99. package/src/browser/terminal-quick-open-service.ts +132 -132
  100. package/src/browser/terminal-theme-service.ts +209 -209
  101. package/src/browser/terminal-url-link-provider.ts +66 -66
  102. package/src/browser/terminal-widget-impl.ts +827 -827
  103. package/src/common/base-terminal-protocol.ts +183 -183
  104. package/src/common/shell-terminal-protocol.ts +50 -50
  105. package/src/common/terminal-common-module.ts +30 -30
  106. package/src/common/terminal-protocol.ts +32 -32
  107. package/src/common/terminal-watcher.ts +69 -69
  108. package/src/node/base-terminal-server.ts +279 -279
  109. package/src/node/buffering-stream.spec.ts +46 -46
  110. package/src/node/buffering-stream.ts +95 -95
  111. package/src/node/index.ts +17 -17
  112. package/src/node/shell-process.ts +101 -101
  113. package/src/node/shell-terminal-server.spec.ts +40 -40
  114. package/src/node/shell-terminal-server.ts +95 -95
  115. package/src/node/terminal-backend-contribution.slow-spec.ts +63 -63
  116. package/src/node/terminal-backend-contribution.ts +60 -60
  117. package/src/node/terminal-backend-module.ts +82 -82
  118. package/src/node/terminal-server.spec.ts +47 -47
  119. package/src/node/terminal-server.ts +52 -52
  120. package/src/node/test/terminal-test-container.ts +39 -39
  121. package/src/package.spec.ts +28 -28
@@ -1,253 +1,253 @@
1
- "use strict";
2
- // *****************************************************************************
3
- // Copyright (C) 2017 Ericsson and others.
4
- //
5
- // This program and the accompanying materials are made available under the
6
- // terms of the Eclipse Public License v. 2.0 which is available at
7
- // http://www.eclipse.org/legal/epl-2.0.
8
- //
9
- // This Source Code may also be made available under the following Secondary
10
- // Licenses when the conditions for such availability set forth in the Eclipse
11
- // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
- // with the GNU Classpath Exception which is available at
13
- // https://www.gnu.org/software/classpath/license.html.
14
- //
15
- // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
- // *****************************************************************************
17
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
- return c > 3 && r && Object.defineProperty(target, key, r), r;
22
- };
23
- var __metadata = (this && this.__metadata) || function (k, v) {
24
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
- };
26
- var __param = (this && this.__param) || function (paramIndex, decorator) {
27
- return function (target, key) { decorator(target, key, paramIndex); }
28
- };
29
- Object.defineProperty(exports, "__esModule", { value: true });
30
- exports.MergedEnvironmentVariableCollectionImpl = exports.BaseTerminalServer = void 0;
31
- const inversify_1 = require("@theia/core/shared/inversify");
32
- const common_1 = require("@theia/core/lib/common");
33
- const base_terminal_protocol_1 = require("../common/base-terminal-protocol");
34
- const node_1 = require("@theia/process/lib/node");
35
- const shell_process_1 = require("./shell-process");
36
- let BaseTerminalServer = class BaseTerminalServer {
37
- constructor(processManager, logger) {
38
- this.processManager = processManager;
39
- this.logger = logger;
40
- this.client = undefined;
41
- this.terminalToDispose = new Map();
42
- this.collections = new Map();
43
- processManager.onDelete(id => {
44
- const toDispose = this.terminalToDispose.get(id);
45
- if (toDispose !== undefined) {
46
- toDispose.dispose();
47
- this.terminalToDispose.delete(id);
48
- }
49
- });
50
- this.mergedCollection = this.resolveMergedCollection();
51
- }
52
- async attach(id) {
53
- const term = this.processManager.get(id);
54
- if (term && term instanceof node_1.TerminalProcess) {
55
- return term.id;
56
- }
57
- else {
58
- this.logger.warn(`Couldn't attach - can't find terminal with id: ${id} `);
59
- return -1;
60
- }
61
- }
62
- async onAttachAttempted(id) {
63
- const terminal = this.processManager.get(id);
64
- if (terminal instanceof node_1.TaskTerminalProcess) {
65
- terminal.attachmentAttempted = true;
66
- if (terminal.exited) {
67
- // Didn't execute `unregisterProcess` on terminal `exit` event to enable attaching task output to terminal,
68
- // Fixes https://github.com/eclipse-theia/theia/issues/2961
69
- terminal.unregisterProcess();
70
- }
71
- }
72
- }
73
- async getProcessId(id) {
74
- const terminal = this.processManager.get(id);
75
- if (!(terminal instanceof node_1.TerminalProcess)) {
76
- throw new Error(`terminal "${id}" does not exist`);
77
- }
78
- return terminal.pid;
79
- }
80
- async getProcessInfo(id) {
81
- const terminal = this.processManager.get(id);
82
- if (!(terminal instanceof node_1.TerminalProcess)) {
83
- throw new Error(`terminal "${id}" does not exist`);
84
- }
85
- return {
86
- executable: terminal.executable,
87
- arguments: terminal.arguments,
88
- };
89
- }
90
- async getCwdURI(id) {
91
- const terminal = this.processManager.get(id);
92
- if (!(terminal instanceof node_1.TerminalProcess)) {
93
- throw new Error(`terminal "${id}" does not exist`);
94
- }
95
- return terminal.getCwdURI();
96
- }
97
- async close(id) {
98
- const term = this.processManager.get(id);
99
- if (term instanceof node_1.TerminalProcess) {
100
- term.kill();
101
- }
102
- }
103
- async getDefaultShell() {
104
- return shell_process_1.ShellProcess.getShellExecutablePath();
105
- }
106
- dispose() {
107
- // noop
108
- }
109
- async resize(id, cols, rows) {
110
- const term = this.processManager.get(id);
111
- if (term && term instanceof node_1.TerminalProcess) {
112
- term.resize(cols, rows);
113
- }
114
- else {
115
- console.warn("Couldn't resize terminal " + id + ", because it doesn't exist.");
116
- }
117
- }
118
- /* Set the client to receive notifications on. */
119
- setClient(client) {
120
- this.client = client;
121
- if (!this.client) {
122
- return;
123
- }
124
- this.client.updateTerminalEnvVariables();
125
- }
126
- postCreate(term) {
127
- const toDispose = new common_1.DisposableCollection();
128
- toDispose.push(term.onError(error => {
129
- this.logger.error(`Terminal pid: ${term.pid} error: ${error}, closing it.`);
130
- if (this.client !== undefined) {
131
- this.client.onTerminalError({
132
- 'terminalId': term.id,
133
- 'error': new Error(`Failed to execute terminal process (${error.code})`),
134
- });
135
- }
136
- }));
137
- toDispose.push(term.onExit(event => {
138
- if (this.client !== undefined) {
139
- this.client.onTerminalExitChanged({
140
- 'terminalId': term.id,
141
- 'code': event.code,
142
- 'signal': event.signal
143
- });
144
- }
145
- }));
146
- this.terminalToDispose.set(term.id, toDispose);
147
- }
148
- /*---------------------------------------------------------------------------------------------
149
- * Copyright (c) Microsoft Corporation. All rights reserved.
150
- * Licensed under the MIT License. See License.txt in the project root for license information.
151
- *--------------------------------------------------------------------------------------------*/
152
- // some code copied and modified from https://github.com/microsoft/vscode/blob/1.49.0/src/vs/workbench/contrib/terminal/common/environmentVariableService.ts
153
- setCollection(extensionIdentifier, persistent, collection) {
154
- const translatedCollection = { persistent, map: new Map(collection) };
155
- this.collections.set(extensionIdentifier, translatedCollection);
156
- this.updateCollections();
157
- }
158
- deleteCollection(extensionIdentifier) {
159
- this.collections.delete(extensionIdentifier);
160
- this.updateCollections();
161
- }
162
- updateCollections() {
163
- this.persistCollections();
164
- this.mergedCollection = this.resolveMergedCollection();
165
- }
166
- persistCollections() {
167
- const collectionsJson = [];
168
- this.collections.forEach((collection, extensionIdentifier) => {
169
- if (collection.persistent) {
170
- collectionsJson.push({
171
- extensionIdentifier,
172
- collection: [...this.collections.get(extensionIdentifier).map.entries()]
173
- });
174
- }
175
- });
176
- if (this.client) {
177
- const stringifiedJson = JSON.stringify(collectionsJson);
178
- this.client.storeTerminalEnvVariables(stringifiedJson);
179
- }
180
- }
181
- resolveMergedCollection() {
182
- return new MergedEnvironmentVariableCollectionImpl(this.collections);
183
- }
184
- };
185
- BaseTerminalServer = __decorate([
186
- (0, inversify_1.injectable)(),
187
- __param(0, (0, inversify_1.inject)(node_1.ProcessManager)),
188
- __param(1, (0, inversify_1.inject)(common_1.ILogger)),
189
- __param(1, (0, inversify_1.named)('terminal')),
190
- __metadata("design:paramtypes", [node_1.ProcessManager, Object])
191
- ], BaseTerminalServer);
192
- exports.BaseTerminalServer = BaseTerminalServer;
193
- /*---------------------------------------------------------------------------------------------
194
- * Copyright (c) Microsoft Corporation. All rights reserved.
195
- * Licensed under the MIT License. See License.txt in the project root for license information.
196
- *--------------------------------------------------------------------------------------------*/
197
- // some code copied and modified from https://github.com/microsoft/vscode/blob/1.49.0/src/vs/workbench/contrib/terminal/common/environmentVariableCollection.ts
198
- class MergedEnvironmentVariableCollectionImpl {
199
- constructor(collections) {
200
- this.map = new Map();
201
- collections.forEach((collection, extensionIdentifier) => {
202
- const it = collection.map.entries();
203
- let next = it.next();
204
- while (!next.done) {
205
- const variable = next.value[0];
206
- let entry = this.map.get(variable);
207
- if (!entry) {
208
- entry = [];
209
- this.map.set(variable, entry);
210
- }
211
- // If the first item in the entry is replace ignore any other entries as they would
212
- // just get replaced by this one.
213
- if (entry.length > 0 && entry[0].type === base_terminal_protocol_1.EnvironmentVariableMutatorType.Replace) {
214
- next = it.next();
215
- continue;
216
- }
217
- // Mutators get applied in the reverse order than they are created
218
- const mutator = next.value[1];
219
- entry.unshift({
220
- extensionIdentifier,
221
- value: mutator.value,
222
- type: mutator.type
223
- });
224
- next = it.next();
225
- }
226
- });
227
- }
228
- applyToProcessEnvironment(env) {
229
- let lowerToActualVariableNames;
230
- if (common_1.isWindows) {
231
- lowerToActualVariableNames = {};
232
- Object.keys(env).forEach(e => lowerToActualVariableNames[e.toLowerCase()] = e);
233
- }
234
- this.map.forEach((mutators, variable) => {
235
- const actualVariable = common_1.isWindows ? lowerToActualVariableNames[variable.toLowerCase()] || variable : variable;
236
- mutators.forEach(mutator => {
237
- switch (mutator.type) {
238
- case base_terminal_protocol_1.EnvironmentVariableMutatorType.Append:
239
- env[actualVariable] = (env[actualVariable] || '') + mutator.value;
240
- break;
241
- case base_terminal_protocol_1.EnvironmentVariableMutatorType.Prepend:
242
- env[actualVariable] = mutator.value + (env[actualVariable] || '');
243
- break;
244
- case base_terminal_protocol_1.EnvironmentVariableMutatorType.Replace:
245
- env[actualVariable] = mutator.value;
246
- break;
247
- }
248
- });
249
- });
250
- }
251
- }
252
- exports.MergedEnvironmentVariableCollectionImpl = MergedEnvironmentVariableCollectionImpl;
1
+ "use strict";
2
+ // *****************************************************************************
3
+ // Copyright (C) 2017 Ericsson and others.
4
+ //
5
+ // This program and the accompanying materials are made available under the
6
+ // terms of the Eclipse Public License v. 2.0 which is available at
7
+ // http://www.eclipse.org/legal/epl-2.0.
8
+ //
9
+ // This Source Code may also be made available under the following Secondary
10
+ // Licenses when the conditions for such availability set forth in the Eclipse
11
+ // Public License v. 2.0 are satisfied: GNU General Public License, version 2
12
+ // with the GNU Classpath Exception which is available at
13
+ // https://www.gnu.org/software/classpath/license.html.
14
+ //
15
+ // SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
16
+ // *****************************************************************************
17
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
18
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
19
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
20
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
21
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
22
+ };
23
+ var __metadata = (this && this.__metadata) || function (k, v) {
24
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
25
+ };
26
+ var __param = (this && this.__param) || function (paramIndex, decorator) {
27
+ return function (target, key) { decorator(target, key, paramIndex); }
28
+ };
29
+ Object.defineProperty(exports, "__esModule", { value: true });
30
+ exports.MergedEnvironmentVariableCollectionImpl = exports.BaseTerminalServer = void 0;
31
+ const inversify_1 = require("@theia/core/shared/inversify");
32
+ const common_1 = require("@theia/core/lib/common");
33
+ const base_terminal_protocol_1 = require("../common/base-terminal-protocol");
34
+ const node_1 = require("@theia/process/lib/node");
35
+ const shell_process_1 = require("./shell-process");
36
+ let BaseTerminalServer = class BaseTerminalServer {
37
+ constructor(processManager, logger) {
38
+ this.processManager = processManager;
39
+ this.logger = logger;
40
+ this.client = undefined;
41
+ this.terminalToDispose = new Map();
42
+ this.collections = new Map();
43
+ processManager.onDelete(id => {
44
+ const toDispose = this.terminalToDispose.get(id);
45
+ if (toDispose !== undefined) {
46
+ toDispose.dispose();
47
+ this.terminalToDispose.delete(id);
48
+ }
49
+ });
50
+ this.mergedCollection = this.resolveMergedCollection();
51
+ }
52
+ async attach(id) {
53
+ const term = this.processManager.get(id);
54
+ if (term && term instanceof node_1.TerminalProcess) {
55
+ return term.id;
56
+ }
57
+ else {
58
+ this.logger.warn(`Couldn't attach - can't find terminal with id: ${id} `);
59
+ return -1;
60
+ }
61
+ }
62
+ async onAttachAttempted(id) {
63
+ const terminal = this.processManager.get(id);
64
+ if (terminal instanceof node_1.TaskTerminalProcess) {
65
+ terminal.attachmentAttempted = true;
66
+ if (terminal.exited) {
67
+ // Didn't execute `unregisterProcess` on terminal `exit` event to enable attaching task output to terminal,
68
+ // Fixes https://github.com/eclipse-theia/theia/issues/2961
69
+ terminal.unregisterProcess();
70
+ }
71
+ }
72
+ }
73
+ async getProcessId(id) {
74
+ const terminal = this.processManager.get(id);
75
+ if (!(terminal instanceof node_1.TerminalProcess)) {
76
+ throw new Error(`terminal "${id}" does not exist`);
77
+ }
78
+ return terminal.pid;
79
+ }
80
+ async getProcessInfo(id) {
81
+ const terminal = this.processManager.get(id);
82
+ if (!(terminal instanceof node_1.TerminalProcess)) {
83
+ throw new Error(`terminal "${id}" does not exist`);
84
+ }
85
+ return {
86
+ executable: terminal.executable,
87
+ arguments: terminal.arguments,
88
+ };
89
+ }
90
+ async getCwdURI(id) {
91
+ const terminal = this.processManager.get(id);
92
+ if (!(terminal instanceof node_1.TerminalProcess)) {
93
+ throw new Error(`terminal "${id}" does not exist`);
94
+ }
95
+ return terminal.getCwdURI();
96
+ }
97
+ async close(id) {
98
+ const term = this.processManager.get(id);
99
+ if (term instanceof node_1.TerminalProcess) {
100
+ term.kill();
101
+ }
102
+ }
103
+ async getDefaultShell() {
104
+ return shell_process_1.ShellProcess.getShellExecutablePath();
105
+ }
106
+ dispose() {
107
+ // noop
108
+ }
109
+ async resize(id, cols, rows) {
110
+ const term = this.processManager.get(id);
111
+ if (term && term instanceof node_1.TerminalProcess) {
112
+ term.resize(cols, rows);
113
+ }
114
+ else {
115
+ console.warn("Couldn't resize terminal " + id + ", because it doesn't exist.");
116
+ }
117
+ }
118
+ /* Set the client to receive notifications on. */
119
+ setClient(client) {
120
+ this.client = client;
121
+ if (!this.client) {
122
+ return;
123
+ }
124
+ this.client.updateTerminalEnvVariables();
125
+ }
126
+ postCreate(term) {
127
+ const toDispose = new common_1.DisposableCollection();
128
+ toDispose.push(term.onError(error => {
129
+ this.logger.error(`Terminal pid: ${term.pid} error: ${error}, closing it.`);
130
+ if (this.client !== undefined) {
131
+ this.client.onTerminalError({
132
+ 'terminalId': term.id,
133
+ 'error': new Error(`Failed to execute terminal process (${error.code})`),
134
+ });
135
+ }
136
+ }));
137
+ toDispose.push(term.onExit(event => {
138
+ if (this.client !== undefined) {
139
+ this.client.onTerminalExitChanged({
140
+ 'terminalId': term.id,
141
+ 'code': event.code,
142
+ 'signal': event.signal
143
+ });
144
+ }
145
+ }));
146
+ this.terminalToDispose.set(term.id, toDispose);
147
+ }
148
+ /*---------------------------------------------------------------------------------------------
149
+ * Copyright (c) Microsoft Corporation. All rights reserved.
150
+ * Licensed under the MIT License. See License.txt in the project root for license information.
151
+ *--------------------------------------------------------------------------------------------*/
152
+ // some code copied and modified from https://github.com/microsoft/vscode/blob/1.49.0/src/vs/workbench/contrib/terminal/common/environmentVariableService.ts
153
+ setCollection(extensionIdentifier, persistent, collection) {
154
+ const translatedCollection = { persistent, map: new Map(collection) };
155
+ this.collections.set(extensionIdentifier, translatedCollection);
156
+ this.updateCollections();
157
+ }
158
+ deleteCollection(extensionIdentifier) {
159
+ this.collections.delete(extensionIdentifier);
160
+ this.updateCollections();
161
+ }
162
+ updateCollections() {
163
+ this.persistCollections();
164
+ this.mergedCollection = this.resolveMergedCollection();
165
+ }
166
+ persistCollections() {
167
+ const collectionsJson = [];
168
+ this.collections.forEach((collection, extensionIdentifier) => {
169
+ if (collection.persistent) {
170
+ collectionsJson.push({
171
+ extensionIdentifier,
172
+ collection: [...this.collections.get(extensionIdentifier).map.entries()]
173
+ });
174
+ }
175
+ });
176
+ if (this.client) {
177
+ const stringifiedJson = JSON.stringify(collectionsJson);
178
+ this.client.storeTerminalEnvVariables(stringifiedJson);
179
+ }
180
+ }
181
+ resolveMergedCollection() {
182
+ return new MergedEnvironmentVariableCollectionImpl(this.collections);
183
+ }
184
+ };
185
+ BaseTerminalServer = __decorate([
186
+ (0, inversify_1.injectable)(),
187
+ __param(0, (0, inversify_1.inject)(node_1.ProcessManager)),
188
+ __param(1, (0, inversify_1.inject)(common_1.ILogger)),
189
+ __param(1, (0, inversify_1.named)('terminal')),
190
+ __metadata("design:paramtypes", [node_1.ProcessManager, Object])
191
+ ], BaseTerminalServer);
192
+ exports.BaseTerminalServer = BaseTerminalServer;
193
+ /*---------------------------------------------------------------------------------------------
194
+ * Copyright (c) Microsoft Corporation. All rights reserved.
195
+ * Licensed under the MIT License. See License.txt in the project root for license information.
196
+ *--------------------------------------------------------------------------------------------*/
197
+ // some code copied and modified from https://github.com/microsoft/vscode/blob/1.49.0/src/vs/workbench/contrib/terminal/common/environmentVariableCollection.ts
198
+ class MergedEnvironmentVariableCollectionImpl {
199
+ constructor(collections) {
200
+ this.map = new Map();
201
+ collections.forEach((collection, extensionIdentifier) => {
202
+ const it = collection.map.entries();
203
+ let next = it.next();
204
+ while (!next.done) {
205
+ const variable = next.value[0];
206
+ let entry = this.map.get(variable);
207
+ if (!entry) {
208
+ entry = [];
209
+ this.map.set(variable, entry);
210
+ }
211
+ // If the first item in the entry is replace ignore any other entries as they would
212
+ // just get replaced by this one.
213
+ if (entry.length > 0 && entry[0].type === base_terminal_protocol_1.EnvironmentVariableMutatorType.Replace) {
214
+ next = it.next();
215
+ continue;
216
+ }
217
+ // Mutators get applied in the reverse order than they are created
218
+ const mutator = next.value[1];
219
+ entry.unshift({
220
+ extensionIdentifier,
221
+ value: mutator.value,
222
+ type: mutator.type
223
+ });
224
+ next = it.next();
225
+ }
226
+ });
227
+ }
228
+ applyToProcessEnvironment(env) {
229
+ let lowerToActualVariableNames;
230
+ if (common_1.isWindows) {
231
+ lowerToActualVariableNames = {};
232
+ Object.keys(env).forEach(e => lowerToActualVariableNames[e.toLowerCase()] = e);
233
+ }
234
+ this.map.forEach((mutators, variable) => {
235
+ const actualVariable = common_1.isWindows ? lowerToActualVariableNames[variable.toLowerCase()] || variable : variable;
236
+ mutators.forEach(mutator => {
237
+ switch (mutator.type) {
238
+ case base_terminal_protocol_1.EnvironmentVariableMutatorType.Append:
239
+ env[actualVariable] = (env[actualVariable] || '') + mutator.value;
240
+ break;
241
+ case base_terminal_protocol_1.EnvironmentVariableMutatorType.Prepend:
242
+ env[actualVariable] = mutator.value + (env[actualVariable] || '');
243
+ break;
244
+ case base_terminal_protocol_1.EnvironmentVariableMutatorType.Replace:
245
+ env[actualVariable] = mutator.value;
246
+ break;
247
+ }
248
+ });
249
+ });
250
+ }
251
+ }
252
+ exports.MergedEnvironmentVariableCollectionImpl = MergedEnvironmentVariableCollectionImpl;
253
253
  //# sourceMappingURL=base-terminal-server.js.map
@@ -1,40 +1,40 @@
1
- /// <reference types="node" />
2
- import { Emitter, Event } from '@theia/core/lib/common/event';
3
- export interface BufferingStreamOptions {
4
- /**
5
- * Max size in bytes of the chunks being emitted.
6
- */
7
- maxChunkSize?: number;
8
- /**
9
- * Amount of time in milliseconds to wait between the moment we start
10
- * buffering data and when we emit the buffered chunk.
11
- */
12
- emitInterval?: number;
13
- }
14
- /**
15
- * This component will buffer whatever is pushed to it and emit chunks back
16
- * every {@link BufferingStreamOptions.emitInterval}. It will also ensure that
17
- * the emitted chunks never exceed {@link BufferingStreamOptions.maxChunkSize}.
18
- */
19
- export declare class BufferingStream<T> {
20
- protected buffer?: T;
21
- protected timeout?: NodeJS.Timeout;
22
- protected maxChunkSize: number;
23
- protected emitInterval: number;
24
- protected onDataEmitter: Emitter<T>;
25
- protected readonly concat: (left: T, right: T) => T;
26
- protected readonly slice: (what: T, start?: number, end?: number) => T;
27
- protected readonly length: (what: T) => number;
28
- constructor(options: BufferingStreamOptions | undefined, concat: (left: T, right: T) => T, slice: (what: T, start?: number, end?: number) => T, length: (what: T) => number);
29
- get onData(): Event<T>;
30
- push(chunk: T): void;
31
- dispose(): void;
32
- protected emitBufferedChunk(): void;
33
- }
34
- export declare class StringBufferingStream extends BufferingStream<string> {
35
- constructor(options?: BufferingStreamOptions);
36
- }
37
- export declare class BufferBufferingStream extends BufferingStream<Buffer> {
38
- constructor(options?: BufferingStreamOptions);
39
- }
1
+ /// <reference types="node" />
2
+ import { Emitter, Event } from '@theia/core/lib/common/event';
3
+ export interface BufferingStreamOptions {
4
+ /**
5
+ * Max size in bytes of the chunks being emitted.
6
+ */
7
+ maxChunkSize?: number;
8
+ /**
9
+ * Amount of time in milliseconds to wait between the moment we start
10
+ * buffering data and when we emit the buffered chunk.
11
+ */
12
+ emitInterval?: number;
13
+ }
14
+ /**
15
+ * This component will buffer whatever is pushed to it and emit chunks back
16
+ * every {@link BufferingStreamOptions.emitInterval}. It will also ensure that
17
+ * the emitted chunks never exceed {@link BufferingStreamOptions.maxChunkSize}.
18
+ */
19
+ export declare class BufferingStream<T> {
20
+ protected buffer?: T;
21
+ protected timeout?: NodeJS.Timeout;
22
+ protected maxChunkSize: number;
23
+ protected emitInterval: number;
24
+ protected onDataEmitter: Emitter<T>;
25
+ protected readonly concat: (left: T, right: T) => T;
26
+ protected readonly slice: (what: T, start?: number, end?: number) => T;
27
+ protected readonly length: (what: T) => number;
28
+ constructor(options: BufferingStreamOptions | undefined, concat: (left: T, right: T) => T, slice: (what: T, start?: number, end?: number) => T, length: (what: T) => number);
29
+ get onData(): Event<T>;
30
+ push(chunk: T): void;
31
+ dispose(): void;
32
+ protected emitBufferedChunk(): void;
33
+ }
34
+ export declare class StringBufferingStream extends BufferingStream<string> {
35
+ constructor(options?: BufferingStreamOptions);
36
+ }
37
+ export declare class BufferBufferingStream extends BufferingStream<Buffer> {
38
+ constructor(options?: BufferingStreamOptions);
39
+ }
40
40
  //# sourceMappingURL=buffering-stream.d.ts.map