@opensumi/ide-terminal-next 3.0.2-next-1715826860.0 → 3.0.2-next-1715852509.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/node/easy-shell-intergration.d.ts +9 -0
- package/lib/node/easy-shell-intergration.d.ts.map +1 -0
- package/lib/node/easy-shell-intergration.js +54 -0
- package/lib/node/easy-shell-intergration.js.map +1 -0
- package/lib/node/index.d.ts.map +1 -1
- package/lib/node/index.js +0 -5
- package/lib/node/index.js.map +1 -1
- package/lib/node/pty.d.ts +0 -2
- package/lib/node/pty.d.ts.map +1 -1
- package/lib/node/pty.js +3 -7
- package/lib/node/pty.js.map +1 -1
- package/package.json +16 -16
- package/src/node/easy-shell-intergration.ts +53 -0
- package/src/node/index.ts +0 -5
- package/src/node/pty.ts +3 -6
- package/lib/node/shell-integration.service.d.ts +0 -21
- package/lib/node/shell-integration.service.d.ts.map +0 -1
- package/lib/node/shell-integration.service.js +0 -70
- package/lib/node/shell-integration.service.js.map +0 -1
- package/src/node/shell-integration.service.ts +0 -77
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
export declare const shellIntergrationDirPath: string;
|
|
2
|
+
export declare const bashIntergrationPath: string;
|
|
3
|
+
/**
|
|
4
|
+
注入的 bash initfile,用于 ShellIntergration 功能的搭建
|
|
5
|
+
后续会针对 ShellIntergation 做整体的架构设计,目前满足基础功能需求
|
|
6
|
+
*/
|
|
7
|
+
export declare const bashIntergrationContent: string;
|
|
8
|
+
export declare const initShellIntergrationFile: () => Promise<void>;
|
|
9
|
+
//# sourceMappingURL=easy-shell-intergration.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"easy-shell-intergration.d.ts","sourceRoot":"","sources":["../../src/node/easy-shell-intergration.ts"],"names":[],"mappings":"AAMA,eAAO,MAAM,wBAAwB,QAA8D,CAAC;AAEpG,eAAO,MAAM,oBAAoB,QAAgE,CAAC;AAElG;;;GAGG;AACH,eAAO,MAAM,uBAAuB,QAiCnC,CAAC;AAEF,eAAO,MAAM,yBAAyB,qBAGrC,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.initShellIntergrationFile = exports.bashIntergrationContent = exports.bashIntergrationPath = exports.shellIntergrationDirPath = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const os_1 = tslib_1.__importDefault(require("os"));
|
|
6
|
+
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
+
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
8
|
+
// 未来适配 OpenSumi 的时候需要调整
|
|
9
|
+
exports.shellIntergrationDirPath = path_1.default.join(os_1.default.tmpdir(), '.sumi-shell', 'shell-intergration');
|
|
10
|
+
exports.bashIntergrationPath = path_1.default.join(exports.shellIntergrationDirPath, 'bash-intergration.bash');
|
|
11
|
+
/**
|
|
12
|
+
注入的 bash initfile,用于 ShellIntergration 功能的搭建
|
|
13
|
+
后续会针对 ShellIntergation 做整体的架构设计,目前满足基础功能需求
|
|
14
|
+
*/
|
|
15
|
+
exports.bashIntergrationContent = String.raw `
|
|
16
|
+
|
|
17
|
+
if [ -r /etc/profile ]; then
|
|
18
|
+
. /etc/profile
|
|
19
|
+
fi
|
|
20
|
+
if [ -r ~/.bashrc ]; then
|
|
21
|
+
. ~/.bashrc
|
|
22
|
+
fi
|
|
23
|
+
if [ -r ~/.bash_profile ]; then
|
|
24
|
+
. ~/.bash_profile
|
|
25
|
+
elif [ -r ~/.bash_login ]; then
|
|
26
|
+
. ~/.bash_login
|
|
27
|
+
elif [ -r ~/.profile ]; then
|
|
28
|
+
. ~/.profile
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
__is_prompt_start() {
|
|
32
|
+
builtin printf '\e]6973;PS\a'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
__is_prompt_end() {
|
|
36
|
+
builtin printf '\e]6973;PE\a'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
__is_update_prompt() {
|
|
40
|
+
if [[ "$__is_custom_PS1" == "" || "$__is_custom_PS1" != "$PS1" ]]; then
|
|
41
|
+
__is_original_PS1=$PS1
|
|
42
|
+
__is_custom_PS1="\[$(__is_prompt_start)\]$__is_original_PS1\[$(__is_prompt_end)\]"
|
|
43
|
+
export PS1="$__is_custom_PS1"
|
|
44
|
+
fi
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
__is_update_prompt
|
|
48
|
+
`;
|
|
49
|
+
const initShellIntergrationFile = async () => {
|
|
50
|
+
await fs_extra_1.default.mkdirp(exports.shellIntergrationDirPath);
|
|
51
|
+
await fs_extra_1.default.writeFile(exports.bashIntergrationPath, exports.bashIntergrationContent);
|
|
52
|
+
};
|
|
53
|
+
exports.initShellIntergrationFile = initShellIntergrationFile;
|
|
54
|
+
//# sourceMappingURL=easy-shell-intergration.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"easy-shell-intergration.js","sourceRoot":"","sources":["../../src/node/easy-shell-intergration.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AACpB,wDAAwB;AAExB,gEAA0B;AAE1B,wBAAwB;AACX,QAAA,wBAAwB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,oBAAoB,CAAC,CAAC;AAEvF,QAAA,oBAAoB,GAAG,cAAI,CAAC,IAAI,CAAC,gCAAwB,EAAE,wBAAwB,CAAC,CAAC;AAElG;;;GAGG;AACU,QAAA,uBAAuB,GAAG,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiChD,CAAC;AAEK,MAAM,yBAAyB,GAAG,KAAK,IAAI,EAAE;IAClD,MAAM,kBAAE,CAAC,MAAM,CAAC,gCAAwB,CAAC,CAAC;IAC1C,MAAM,kBAAE,CAAC,SAAS,CAAC,4BAAoB,EAAE,+BAAuB,CAAC,CAAC;AACpE,CAAC,CAAC;AAHW,QAAA,yBAAyB,6BAGpC"}
|
package/lib/node/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAc,QAAQ,EAAE,MAAM,cAAc,CAAC;AACpD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAiBrD,qBACa,qBAAsB,SAAQ,UAAU;IACnD,SAAS,EAAE,QAAQ,EAAE,CAyBnB;IAEF,YAAY;;;QASV;CACH"}
|
package/lib/node/index.js
CHANGED
|
@@ -7,7 +7,6 @@ const ide_core_node_1 = require("@opensumi/ide-core-node");
|
|
|
7
7
|
const common_1 = require("../common");
|
|
8
8
|
const pty_1 = require("./pty");
|
|
9
9
|
const pty_manager_1 = require("./pty.manager");
|
|
10
|
-
const shell_integration_service_1 = require("./shell-integration.service");
|
|
11
10
|
const terminal_process_service_1 = require("./terminal.process.service");
|
|
12
11
|
const terminal_profile_service_1 = require("./terminal.profile.service");
|
|
13
12
|
const terminal_service_1 = require("./terminal.service");
|
|
@@ -28,10 +27,6 @@ let TerminalNodePtyModule = class TerminalNodePtyModule extends ide_core_node_1.
|
|
|
28
27
|
token: common_1.ITerminalProcessService,
|
|
29
28
|
useClass: terminal_process_service_1.TerminalProcessServiceImpl,
|
|
30
29
|
},
|
|
31
|
-
{
|
|
32
|
-
token: shell_integration_service_1.IShellIntegrationService,
|
|
33
|
-
useClass: shell_integration_service_1.ShellIntegrationService,
|
|
34
|
-
},
|
|
35
30
|
{
|
|
36
31
|
token: pty_1.IPtyService,
|
|
37
32
|
useClass: pty_1.PtyService,
|
package/lib/node/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;AAAA,qCAAoD;AACpD,2DAAqD;AAErD,sCAMmB;AAEnB,+BAAgD;AAChD,+CAA0E;AAC1E,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/node/index.ts"],"names":[],"mappings":";;;;AAAA,qCAAoD;AACpD,2DAAqD;AAErD,sCAMmB;AAEnB,+BAAgD;AAChD,+CAA0E;AAC1E,yEAAwE;AACxE,yEAAqG;AACrG,yDAAyD;AACzD,uEAAsE;AAG/D,IAAM,qBAAqB,GAA3B,MAAM,qBAAsB,SAAQ,0BAAU;IAA9C;;QACL,cAAS,GAAe;YACtB;gBACE,KAAK,EAAE,6BAAoB;gBAC3B,QAAQ,EAAE,sCAAmB;aAC9B;YACD;gBACE,KAAK,EAAE,+BAAsB;gBAC7B,QAAQ,EAAE,mDAAyB;aACpC;YACD;gBACE,KAAK,EAAE,gCAAuB;gBAC9B,QAAQ,EAAE,qDAA0B;aACrC;YACD;gBACE,KAAK,EAAE,iBAAW;gBAClB,QAAQ,EAAE,gBAAU;aACrB;YACD;gBACE,KAAK,EAAE,sDAA2B;gBAClC,QAAQ,EAAE,qDAA0B;aACrC;YACD;gBACE,KAAK,EAAE,oCAAsB;gBAC7B,QAAQ,EAAE,+BAAiB;aAC5B;SACF,CAAC;QAEF,iBAAY,GAAG;YACb;gBACE,WAAW,EAAE,6BAAoB;gBACjC,KAAK,EAAE,+BAAsB;aAC9B;YACD;gBACE,WAAW,EAAE,6BAAoB;gBACjC,KAAK,EAAE,gCAAuB;aAC/B;SACF,CAAC;IACJ,CAAC;CAAA,CAAA;AAtCY,qBAAqB;IADjC,IAAA,eAAU,GAAE;GACA,qBAAqB,CAsCjC;AAtCY,sDAAqB"}
|
package/lib/node/pty.d.ts
CHANGED
|
@@ -4,14 +4,12 @@ import { IShellLaunchConfig, ITerminalLaunchError } from '../common';
|
|
|
4
4
|
import { IProcessExitEvent, IProcessReadyEvent } from '../common/process';
|
|
5
5
|
import { IPtyProcessProxy } from '../common/pty';
|
|
6
6
|
import { IPtyServiceManager } from './pty.manager';
|
|
7
|
-
import { IShellIntegrationService } from './shell-integration.service';
|
|
8
7
|
export declare const IPtyService: unique symbol;
|
|
9
8
|
export declare class PtyService extends Disposable {
|
|
10
9
|
id: string;
|
|
11
10
|
readonly shellLaunchConfig: IShellLaunchConfig;
|
|
12
11
|
protected readonly logger: INodeLogger;
|
|
13
12
|
protected readonly ptyServiceManager: IPtyServiceManager;
|
|
14
|
-
protected readonly shellIntegrationService: IShellIntegrationService;
|
|
15
13
|
protected readonly _ptyOptions: pty.IPtyForkOptions | pty.IWindowsPtyForkOptions;
|
|
16
14
|
private _ptyProcess;
|
|
17
15
|
private readonly _onData;
|
package/lib/node/pty.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pty.d.ts","sourceRoot":"","sources":["../../src/node/pty.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,UAAU,EAAW,WAAW,EAAwB,MAAM,yBAAyB,CAAC;AAGjG,OAAO,EAAE,kBAAkB,EAAE,oBAAoB,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,iBAAiB,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AAC1E,OAAO,EAAE,gBAAgB,EAAoB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"pty.d.ts","sourceRoot":"","sources":["../../src/node/pty.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,GAAG,MAAM,UAAU,CAAC;AAIhC,OAAO,EAAE,UAAU,EAAW,WAAW,EAAwB,MAAM,yBAAyB,CAAC;AAGjG,OAAO,EAAE,kBAA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mBAAmB,IAAI,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;IAiChE,KAAK,IAAI,OAAO,CAAC,oBAAoB,GAAG,SAAS,CAAC;cAgExC,eAAe;IAwC/B,OAAO,CAAC,cAAc;IAMtB,QAAQ;IASR,YAAY;IAIZ,MAAM;IAIA,MAAM;IAOZ,MAAM,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM;IASjC,SAAS,CAAC,IAAI,EAAE,MAAM;CAGvB"}
|
package/lib/node/pty.js
CHANGED
|
@@ -14,9 +14,9 @@ const osLocale = tslib_1.__importStar(require("os-locale"));
|
|
|
14
14
|
const di_1 = require("@opensumi/di");
|
|
15
15
|
const ide_core_node_1 = require("@opensumi/ide-core-node");
|
|
16
16
|
const shell_path_1 = require("@opensumi/ide-core-node/lib/bootstrap/shell-path");
|
|
17
|
+
const easy_shell_intergration_1 = require("./easy-shell-intergration");
|
|
17
18
|
const pty_manager_1 = require("./pty.manager");
|
|
18
19
|
const shell_1 = require("./shell");
|
|
19
|
-
const shell_integration_service_1 = require("./shell-integration.service");
|
|
20
20
|
exports.IPtyService = Symbol('IPtyService');
|
|
21
21
|
let PtyService = class PtyService extends ide_core_node_1.Disposable {
|
|
22
22
|
get pty() {
|
|
@@ -153,12 +153,12 @@ let PtyService = class PtyService extends ide_core_node_1.Disposable {
|
|
|
153
153
|
// HACK: 这里的处理逻辑有些黑,后续需要整体去整理下 Shell Intergration,然后整体优化一下
|
|
154
154
|
// 如果是启动 bash,则使用 init file 植入 Intergration 能力
|
|
155
155
|
if ((_a = options.executable) === null || _a === void 0 ? void 0 : _a.includes('bash')) {
|
|
156
|
-
|
|
156
|
+
await (0, easy_shell_intergration_1.initShellIntergrationFile)();
|
|
157
157
|
if (!options.args) {
|
|
158
158
|
options.args = [];
|
|
159
159
|
}
|
|
160
160
|
if (Array.isArray(options.args)) {
|
|
161
|
-
options.args.push('--init-file',
|
|
161
|
+
options.args.push('--init-file', easy_shell_intergration_1.bashIntergrationPath);
|
|
162
162
|
}
|
|
163
163
|
}
|
|
164
164
|
this._ptyOptions['env'] = ptyEnv;
|
|
@@ -251,10 +251,6 @@ tslib_1.__decorate([
|
|
|
251
251
|
(0, di_1.Autowired)(pty_manager_1.PtyServiceManagerToken),
|
|
252
252
|
tslib_1.__metadata("design:type", Object)
|
|
253
253
|
], PtyService.prototype, "ptyServiceManager", void 0);
|
|
254
|
-
tslib_1.__decorate([
|
|
255
|
-
(0, di_1.Autowired)(shell_integration_service_1.IShellIntegrationService),
|
|
256
|
-
tslib_1.__metadata("design:type", Object)
|
|
257
|
-
], PtyService.prototype, "shellIntegrationService", void 0);
|
|
258
254
|
PtyService = tslib_1.__decorate([
|
|
259
255
|
(0, di_1.Injectable)({ multiple: true }),
|
|
260
256
|
tslib_1.__metadata("design:paramtypes", [String, Object, Number, Number])
|
package/lib/node/pty.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pty.js","sourceRoot":"","sources":["../../src/node/pty.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;AAEhG,sIAAsI;AAEtI,2BAA8B;AAC9B,oDAAoB;AAEpB,+DAA+B;AAE/B,4DAAsC;AAEtC,qCAAqD;AACrD,2DAAiG;AACjG,iFAAgF;AAMhF,+CAA2E;AAC3E,mCAAyC;
|
|
1
|
+
{"version":3,"file":"pty.js","sourceRoot":"","sources":["../../src/node/pty.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;;;;AAEhG,sIAAsI;AAEtI,2BAA8B;AAC9B,oDAAoB;AAEpB,+DAA+B;AAE/B,4DAAsC;AAEtC,qCAAqD;AACrD,2DAAiG;AACjG,iFAAgF;AAMhF,uEAA4F;AAC5F,+CAA2E;AAC3E,mCAAyC;AAE5B,QAAA,WAAW,GAAG,MAAM,CAAC,aAAa,CAAC,CAAC;AAG1C,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,0BAAU;IA2BxC,IAAI,GAAG;QACL,OAAO,IAAI,C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E,QAAQ,EAAE,IAAI,EAAE,CAAC;;GAClB,UAAU,CA2QtB;AA3QY,gCAAU"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-terminal-next",
|
|
3
|
-
"version": "3.0.2-next-
|
|
3
|
+
"version": "3.0.2-next-1715852509.0",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -17,10 +17,10 @@
|
|
|
17
17
|
"url": "git@github.com:opensumi/core.git"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@opensumi/ide-connection": "3.0.2-next-
|
|
21
|
-
"@opensumi/ide-core-common": "3.0.2-next-
|
|
22
|
-
"@opensumi/ide-core-node": "3.0.2-next-
|
|
23
|
-
"@opensumi/ide-file-service": "3.0.2-next-
|
|
20
|
+
"@opensumi/ide-connection": "3.0.2-next-1715852509.0",
|
|
21
|
+
"@opensumi/ide-core-common": "3.0.2-next-1715852509.0",
|
|
22
|
+
"@opensumi/ide-core-node": "3.0.2-next-1715852509.0",
|
|
23
|
+
"@opensumi/ide-file-service": "3.0.2-next-1715852509.0",
|
|
24
24
|
"node-pty": "1.0.0",
|
|
25
25
|
"os-locale": "^4.0.0",
|
|
26
26
|
"xterm": "5.3.0",
|
|
@@ -30,18 +30,18 @@
|
|
|
30
30
|
"xterm-addon-webgl": "0.15.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@opensumi/ide-components": "3.0.2-next-
|
|
34
|
-
"@opensumi/ide-core-browser": "3.0.2-next-
|
|
35
|
-
"@opensumi/ide-dev-tool": "3.0.2-next-
|
|
36
|
-
"@opensumi/ide-editor": "3.0.2-next-
|
|
37
|
-
"@opensumi/ide-main-layout": "3.0.2-next-
|
|
38
|
-
"@opensumi/ide-overlay": "3.0.2-next-
|
|
39
|
-
"@opensumi/ide-status-bar": "3.0.2-next-
|
|
40
|
-
"@opensumi/ide-theme": "3.0.2-next-
|
|
41
|
-
"@opensumi/ide-variable": "3.0.2-next-
|
|
42
|
-
"@opensumi/ide-workspace": "3.0.2-next-
|
|
33
|
+
"@opensumi/ide-components": "3.0.2-next-1715852509.0",
|
|
34
|
+
"@opensumi/ide-core-browser": "3.0.2-next-1715852509.0",
|
|
35
|
+
"@opensumi/ide-dev-tool": "3.0.2-next-1715852509.0",
|
|
36
|
+
"@opensumi/ide-editor": "3.0.2-next-1715852509.0",
|
|
37
|
+
"@opensumi/ide-main-layout": "3.0.2-next-1715852509.0",
|
|
38
|
+
"@opensumi/ide-overlay": "3.0.2-next-1715852509.0",
|
|
39
|
+
"@opensumi/ide-status-bar": "3.0.2-next-1715852509.0",
|
|
40
|
+
"@opensumi/ide-theme": "3.0.2-next-1715852509.0",
|
|
41
|
+
"@opensumi/ide-variable": "3.0.2-next-1715852509.0",
|
|
42
|
+
"@opensumi/ide-workspace": "3.0.2-next-1715852509.0",
|
|
43
43
|
"@types/http-proxy": "^1.17.2",
|
|
44
44
|
"http-proxy": "^1.18.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "b9909c18c2f917ee73f6e19fdc2f5f33dbc616c7"
|
|
47
47
|
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import os from 'os';
|
|
2
|
+
import path from 'path';
|
|
3
|
+
|
|
4
|
+
import fs from 'fs-extra';
|
|
5
|
+
|
|
6
|
+
// 未来适配 OpenSumi 的时候需要调整
|
|
7
|
+
export const shellIntergrationDirPath = path.join(os.tmpdir(), '.sumi-shell', 'shell-intergration');
|
|
8
|
+
|
|
9
|
+
export const bashIntergrationPath = path.join(shellIntergrationDirPath, 'bash-intergration.bash');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
注入的 bash initfile,用于 ShellIntergration 功能的搭建
|
|
13
|
+
后续会针对 ShellIntergation 做整体的架构设计,目前满足基础功能需求
|
|
14
|
+
*/
|
|
15
|
+
export const bashIntergrationContent = String.raw`
|
|
16
|
+
|
|
17
|
+
if [ -r /etc/profile ]; then
|
|
18
|
+
. /etc/profile
|
|
19
|
+
fi
|
|
20
|
+
if [ -r ~/.bashrc ]; then
|
|
21
|
+
. ~/.bashrc
|
|
22
|
+
fi
|
|
23
|
+
if [ -r ~/.bash_profile ]; then
|
|
24
|
+
. ~/.bash_profile
|
|
25
|
+
elif [ -r ~/.bash_login ]; then
|
|
26
|
+
. ~/.bash_login
|
|
27
|
+
elif [ -r ~/.profile ]; then
|
|
28
|
+
. ~/.profile
|
|
29
|
+
fi
|
|
30
|
+
|
|
31
|
+
__is_prompt_start() {
|
|
32
|
+
builtin printf '\e]6973;PS\a'
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
__is_prompt_end() {
|
|
36
|
+
builtin printf '\e]6973;PE\a'
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
__is_update_prompt() {
|
|
40
|
+
if [[ "$__is_custom_PS1" == "" || "$__is_custom_PS1" != "$PS1" ]]; then
|
|
41
|
+
__is_original_PS1=$PS1
|
|
42
|
+
__is_custom_PS1="\[$(__is_prompt_start)\]$__is_original_PS1\[$(__is_prompt_end)\]"
|
|
43
|
+
export PS1="$__is_custom_PS1"
|
|
44
|
+
fi
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
__is_update_prompt
|
|
48
|
+
`;
|
|
49
|
+
|
|
50
|
+
export const initShellIntergrationFile = async () => {
|
|
51
|
+
await fs.mkdirp(shellIntergrationDirPath);
|
|
52
|
+
await fs.writeFile(bashIntergrationPath, bashIntergrationContent);
|
|
53
|
+
};
|
package/src/node/index.ts
CHANGED
|
@@ -11,7 +11,6 @@ import {
|
|
|
11
11
|
|
|
12
12
|
import { IPtyService, PtyService } from './pty';
|
|
13
13
|
import { PtyServiceManager, PtyServiceManagerToken } from './pty.manager';
|
|
14
|
-
import { IShellIntegrationService, ShellIntegrationService } from './shell-integration.service';
|
|
15
14
|
import { TerminalProcessServiceImpl } from './terminal.process.service';
|
|
16
15
|
import { ITerminalProfileServiceNode, TerminalProfileServiceNode } from './terminal.profile.service';
|
|
17
16
|
import { TerminalServiceImpl } from './terminal.service';
|
|
@@ -32,10 +31,6 @@ export class TerminalNodePtyModule extends NodeModule {
|
|
|
32
31
|
token: ITerminalProcessService,
|
|
33
32
|
useClass: TerminalProcessServiceImpl,
|
|
34
33
|
},
|
|
35
|
-
{
|
|
36
|
-
token: IShellIntegrationService,
|
|
37
|
-
useClass: ShellIntegrationService,
|
|
38
|
-
},
|
|
39
34
|
{
|
|
40
35
|
token: IPtyService,
|
|
41
36
|
useClass: PtyService,
|
package/src/node/pty.ts
CHANGED
|
@@ -20,9 +20,9 @@ import { IShellLaunchConfig, ITerminalLaunchError } from '../common';
|
|
|
20
20
|
import { IProcessExitEvent, IProcessReadyEvent } from '../common/process';
|
|
21
21
|
import { IPtyProcessProxy, IPtySpawnOptions } from '../common/pty';
|
|
22
22
|
|
|
23
|
+
import { bashIntergrationPath, initShellIntergrationFile } from './easy-shell-intergration';
|
|
23
24
|
import { IPtyServiceManager, PtyServiceManagerToken } from './pty.manager';
|
|
24
25
|
import { findExecutable } from './shell';
|
|
25
|
-
import { IShellIntegrationService } from './shell-integration.service';
|
|
26
26
|
|
|
27
27
|
export const IPtyService = Symbol('IPtyService');
|
|
28
28
|
|
|
@@ -34,9 +34,6 @@ export class PtyService extends Disposable {
|
|
|
34
34
|
@Autowired(PtyServiceManagerToken)
|
|
35
35
|
protected readonly ptyServiceManager: IPtyServiceManager;
|
|
36
36
|
|
|
37
|
-
@Autowired(IShellIntegrationService)
|
|
38
|
-
protected readonly shellIntegrationService: IShellIntegrationService;
|
|
39
|
-
|
|
40
37
|
protected readonly _ptyOptions: pty.IPtyForkOptions | pty.IWindowsPtyForkOptions;
|
|
41
38
|
private _ptyProcess: IPtyProcessProxy | undefined;
|
|
42
39
|
|
|
@@ -189,12 +186,12 @@ export class PtyService extends Disposable {
|
|
|
189
186
|
// HACK: 这里的处理逻辑有些黑,后续需要整体去整理下 Shell Intergration,然后整体优化一下
|
|
190
187
|
// 如果是启动 bash,则使用 init file 植入 Intergration 能力
|
|
191
188
|
if (options.executable?.includes('bash')) {
|
|
192
|
-
|
|
189
|
+
await initShellIntergrationFile();
|
|
193
190
|
if (!options.args) {
|
|
194
191
|
options.args = [];
|
|
195
192
|
}
|
|
196
193
|
if (Array.isArray(options.args)) {
|
|
197
|
-
options.args.push('--init-file',
|
|
194
|
+
options.args.push('--init-file', bashIntergrationPath);
|
|
198
195
|
}
|
|
199
196
|
}
|
|
200
197
|
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export interface IShellIntegrationService {
|
|
2
|
-
initBashInitFile(): Promise<string>;
|
|
3
|
-
getBashIntegrationContent(): Promise<string>;
|
|
4
|
-
}
|
|
5
|
-
export declare const shellIntegrationDirPath: string;
|
|
6
|
-
export declare const bashIntegrationPath: string;
|
|
7
|
-
export declare const IShellIntegrationService: unique symbol;
|
|
8
|
-
/**
|
|
9
|
-
* 可通过重写此 Service 做到自定义的 Bash 注入
|
|
10
|
-
* 后续增加 ZSH 的支持
|
|
11
|
-
*/
|
|
12
|
-
export declare class ShellIntegrationService implements IShellIntegrationService {
|
|
13
|
-
/**
|
|
14
|
-
注入的 bash initFile,用于 ShellIntegration 功能的搭建
|
|
15
|
-
可覆写此文件,实现自定义的注入
|
|
16
|
-
*注意*:要保持 prompt_start 和 prompt_end 的注入,否则会影响 IDE 的终端智能
|
|
17
|
-
*/
|
|
18
|
-
getBashIntegrationContent(): Promise<string>;
|
|
19
|
-
initBashInitFile(): Promise<string>;
|
|
20
|
-
}
|
|
21
|
-
//# sourceMappingURL=shell-integration.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shell-integration.service.d.ts","sourceRoot":"","sources":["../../src/node/shell-integration.service.ts"],"names":[],"mappings":"AAOA,MAAM,WAAW,wBAAwB;IAEvC,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;IAGpC,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC9C;AAGD,eAAO,MAAM,uBAAuB,QAA6D,CAAC;AAElG,eAAO,MAAM,mBAAmB,QAA8D,CAAC;AAE/F,eAAO,MAAM,wBAAwB,eAAqC,CAAC;AAE3E;;;GAGG;AACH,qBACa,uBAAwB,YAAW,wBAAwB;IACtE;;;;MAIE;IACI,yBAAyB,IAAI,OAAO,CAAC,MAAM,CAAC;IAsC5C,gBAAgB,IAAI,OAAO,CAAC,MAAM,CAAC;CAK1C"}
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ShellIntegrationService = exports.IShellIntegrationService = exports.bashIntegrationPath = exports.shellIntegrationDirPath = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const os_1 = tslib_1.__importDefault(require("os"));
|
|
6
|
-
const path_1 = tslib_1.__importDefault(require("path"));
|
|
7
|
-
const fs_extra_1 = tslib_1.__importDefault(require("fs-extra"));
|
|
8
|
-
const di_1 = require("@opensumi/di");
|
|
9
|
-
// 未来适配 OpenSumi 的时候需要调整
|
|
10
|
-
exports.shellIntegrationDirPath = path_1.default.join(os_1.default.tmpdir(), '.sumi-shell', 'shell-integration');
|
|
11
|
-
exports.bashIntegrationPath = path_1.default.join(exports.shellIntegrationDirPath, 'bash-integration.bash');
|
|
12
|
-
exports.IShellIntegrationService = Symbol('IShellIntegrationService');
|
|
13
|
-
/**
|
|
14
|
-
* 可通过重写此 Service 做到自定义的 Bash 注入
|
|
15
|
-
* 后续增加 ZSH 的支持
|
|
16
|
-
*/
|
|
17
|
-
let ShellIntegrationService = class ShellIntegrationService {
|
|
18
|
-
/**
|
|
19
|
-
注入的 bash initFile,用于 ShellIntegration 功能的搭建
|
|
20
|
-
可覆写此文件,实现自定义的注入
|
|
21
|
-
*注意*:要保持 prompt_start 和 prompt_end 的注入,否则会影响 IDE 的终端智能
|
|
22
|
-
*/
|
|
23
|
-
async getBashIntegrationContent() {
|
|
24
|
-
return String.raw `
|
|
25
|
-
|
|
26
|
-
if [ -r /etc/profile ]; then
|
|
27
|
-
. /etc/profile
|
|
28
|
-
fi
|
|
29
|
-
if [ -r ~/.bashrc ]; then
|
|
30
|
-
. ~/.bashrc
|
|
31
|
-
fi
|
|
32
|
-
if [ -r ~/.bash_profile ]; then
|
|
33
|
-
. ~/.bash_profile
|
|
34
|
-
elif [ -r ~/.bash_login ]; then
|
|
35
|
-
. ~/.bash_login
|
|
36
|
-
elif [ -r ~/.profile ]; then
|
|
37
|
-
. ~/.profile
|
|
38
|
-
fi
|
|
39
|
-
|
|
40
|
-
__is_prompt_start() {
|
|
41
|
-
builtin printf '\e]6973;PS\a' # 标记 Shell Prompt Start,使其可被 IDE 上层感知,用于终端智能
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
__is_prompt_end() {
|
|
45
|
-
builtin printf '\e]6973;PE\a' # 用于标记 Shell Prompt End,作用同上
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
__is_update_prompt() {
|
|
49
|
-
if [[ "$__is_custom_PS1" == "" || "$__is_custom_PS1" != "$PS1" ]]; then
|
|
50
|
-
__is_original_PS1=$PS1
|
|
51
|
-
__is_custom_PS1="\[$(__is_prompt_start)\]$__is_original_PS1\[$(__is_prompt_end)\]"
|
|
52
|
-
export PS1="$__is_custom_PS1"
|
|
53
|
-
fi
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
__is_update_prompt
|
|
57
|
-
`;
|
|
58
|
-
}
|
|
59
|
-
// 可被集成侧覆写以自定义 Bash 注入文件
|
|
60
|
-
async initBashInitFile() {
|
|
61
|
-
await fs_extra_1.default.mkdirp(exports.shellIntegrationDirPath);
|
|
62
|
-
await fs_extra_1.default.writeFile(exports.bashIntegrationPath, await this.getBashIntegrationContent());
|
|
63
|
-
return exports.bashIntegrationPath;
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
ShellIntegrationService = tslib_1.__decorate([
|
|
67
|
-
(0, di_1.Injectable)()
|
|
68
|
-
], ShellIntegrationService);
|
|
69
|
-
exports.ShellIntegrationService = ShellIntegrationService;
|
|
70
|
-
//# sourceMappingURL=shell-integration.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"shell-integration.service.js","sourceRoot":"","sources":["../../src/node/shell-integration.service.ts"],"names":[],"mappings":";;;;AAAA,oDAAoB;AACpB,wDAAwB;AAExB,gEAA0B;AAE1B,qCAA0C;AAU1C,wBAAwB;AACX,QAAA,uBAAuB,GAAG,cAAI,CAAC,IAAI,CAAC,YAAE,CAAC,MAAM,EAAE,EAAE,aAAa,EAAE,mBAAmB,CAAC,CAAC;AAErF,QAAA,mBAAmB,GAAG,cAAI,CAAC,IAAI,CAAC,+BAAuB,EAAE,uBAAuB,CAAC,CAAC;AAElF,QAAA,wBAAwB,GAAG,MAAM,CAAC,0BAA0B,CAAC,CAAC;AAE3E;;;GAGG;AAEI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IAClC;;;;MAIE;IACF,KAAK,CAAC,yBAAyB;QAC7B,OAAO,MAAM,CAAC,GAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;KAiChB,CAAC;IACJ,CAAC;IAED,wBAAwB;IACxB,KAAK,CAAC,gBAAgB;QACpB,MAAM,kBAAE,CAAC,MAAM,CAAC,+BAAuB,CAAC,CAAC;QACzC,MAAM,kBAAE,CAAC,SAAS,CAAC,2BAAmB,EAAE,MAAM,IAAI,CAAC,yBAAyB,EAAE,CAAC,CAAC;QAChF,OAAO,2BAAmB,CAAC;IAC7B,CAAC;CACF,CAAA;AAjDY,uBAAuB;IADnC,IAAA,eAAU,GAAE;GACA,uBAAuB,CAiDnC;AAjDY,0DAAuB"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
import os from 'os';
|
|
2
|
-
import path from 'path';
|
|
3
|
-
|
|
4
|
-
import fs from 'fs-extra';
|
|
5
|
-
|
|
6
|
-
import { Injectable } from '@opensumi/di';
|
|
7
|
-
|
|
8
|
-
export interface IShellIntegrationService {
|
|
9
|
-
// 初始化 Bash 注入文件,幂等设计,返回注入文件路径
|
|
10
|
-
initBashInitFile(): Promise<string>;
|
|
11
|
-
|
|
12
|
-
// 获取 Bash 注入文件的 Content 内容
|
|
13
|
-
getBashIntegrationContent(): Promise<string>;
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
// 未来适配 OpenSumi 的时候需要调整
|
|
17
|
-
export const shellIntegrationDirPath = path.join(os.tmpdir(), '.sumi-shell', 'shell-integration');
|
|
18
|
-
|
|
19
|
-
export const bashIntegrationPath = path.join(shellIntegrationDirPath, 'bash-integration.bash');
|
|
20
|
-
|
|
21
|
-
export const IShellIntegrationService = Symbol('IShellIntegrationService');
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* 可通过重写此 Service 做到自定义的 Bash 注入
|
|
25
|
-
* 后续增加 ZSH 的支持
|
|
26
|
-
*/
|
|
27
|
-
@Injectable()
|
|
28
|
-
export class ShellIntegrationService implements IShellIntegrationService {
|
|
29
|
-
/**
|
|
30
|
-
注入的 bash initFile,用于 ShellIntegration 功能的搭建
|
|
31
|
-
可覆写此文件,实现自定义的注入
|
|
32
|
-
*注意*:要保持 prompt_start 和 prompt_end 的注入,否则会影响 IDE 的终端智能
|
|
33
|
-
*/
|
|
34
|
-
async getBashIntegrationContent(): Promise<string> {
|
|
35
|
-
return String.raw`
|
|
36
|
-
|
|
37
|
-
if [ -r /etc/profile ]; then
|
|
38
|
-
. /etc/profile
|
|
39
|
-
fi
|
|
40
|
-
if [ -r ~/.bashrc ]; then
|
|
41
|
-
. ~/.bashrc
|
|
42
|
-
fi
|
|
43
|
-
if [ -r ~/.bash_profile ]; then
|
|
44
|
-
. ~/.bash_profile
|
|
45
|
-
elif [ -r ~/.bash_login ]; then
|
|
46
|
-
. ~/.bash_login
|
|
47
|
-
elif [ -r ~/.profile ]; then
|
|
48
|
-
. ~/.profile
|
|
49
|
-
fi
|
|
50
|
-
|
|
51
|
-
__is_prompt_start() {
|
|
52
|
-
builtin printf '\e]6973;PS\a' # 标记 Shell Prompt Start,使其可被 IDE 上层感知,用于终端智能
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
__is_prompt_end() {
|
|
56
|
-
builtin printf '\e]6973;PE\a' # 用于标记 Shell Prompt End,作用同上
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
__is_update_prompt() {
|
|
60
|
-
if [[ "$__is_custom_PS1" == "" || "$__is_custom_PS1" != "$PS1" ]]; then
|
|
61
|
-
__is_original_PS1=$PS1
|
|
62
|
-
__is_custom_PS1="\[$(__is_prompt_start)\]$__is_original_PS1\[$(__is_prompt_end)\]"
|
|
63
|
-
export PS1="$__is_custom_PS1"
|
|
64
|
-
fi
|
|
65
|
-
}
|
|
66
|
-
|
|
67
|
-
__is_update_prompt
|
|
68
|
-
`;
|
|
69
|
-
}
|
|
70
|
-
|
|
71
|
-
// 可被集成侧覆写以自定义 Bash 注入文件
|
|
72
|
-
async initBashInitFile(): Promise<string> {
|
|
73
|
-
await fs.mkdirp(shellIntegrationDirPath);
|
|
74
|
-
await fs.writeFile(bashIntegrationPath, await this.getBashIntegrationContent());
|
|
75
|
-
return bashIntegrationPath;
|
|
76
|
-
}
|
|
77
|
-
}
|