@opensumi/ide-core-node 2.12.1-next-079c1930

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 (53) hide show
  1. package/lib/bootstrap/app.d.ts +161 -0
  2. package/lib/bootstrap/app.d.ts.map +1 -0
  3. package/lib/bootstrap/app.js +206 -0
  4. package/lib/bootstrap/app.js.map +1 -0
  5. package/lib/bootstrap/index.d.ts +3 -0
  6. package/lib/bootstrap/index.d.ts.map +1 -0
  7. package/lib/bootstrap/index.js +6 -0
  8. package/lib/bootstrap/index.js.map +1 -0
  9. package/lib/bootstrap/inner-providers.d.ts +3 -0
  10. package/lib/bootstrap/inner-providers.d.ts.map +1 -0
  11. package/lib/bootstrap/inner-providers.js +28 -0
  12. package/lib/bootstrap/inner-providers.js.map +1 -0
  13. package/lib/bootstrap/shell-path.d.ts +2 -0
  14. package/lib/bootstrap/shell-path.d.ts.map +1 -0
  15. package/lib/bootstrap/shell-path.js +108 -0
  16. package/lib/bootstrap/shell-path.js.map +1 -0
  17. package/lib/common-module/common.server.d.ts +5 -0
  18. package/lib/common-module/common.server.d.ts.map +1 -0
  19. package/lib/common-module/common.server.js +16 -0
  20. package/lib/common-module/common.server.js.map +1 -0
  21. package/lib/common-module/credential.server.d.ts +16 -0
  22. package/lib/common-module/credential.server.d.ts.map +1 -0
  23. package/lib/common-module/credential.server.js +90 -0
  24. package/lib/common-module/credential.server.js.map +1 -0
  25. package/lib/common-module/cryptr.server.d.ts +14 -0
  26. package/lib/common-module/cryptr.server.d.ts.map +1 -0
  27. package/lib/common-module/cryptr.server.js +44 -0
  28. package/lib/common-module/cryptr.server.js.map +1 -0
  29. package/lib/common-module/index.d.ts +22 -0
  30. package/lib/common-module/index.d.ts.map +1 -0
  31. package/lib/common-module/index.js +50 -0
  32. package/lib/common-module/index.js.map +1 -0
  33. package/lib/connection.d.ts +12 -0
  34. package/lib/connection.d.ts.map +1 -0
  35. package/lib/connection.js +102 -0
  36. package/lib/connection.js.map +1 -0
  37. package/lib/hash-calculate/hash-calculate.contribution.d.ts +6 -0
  38. package/lib/hash-calculate/hash-calculate.contribution.d.ts.map +1 -0
  39. package/lib/hash-calculate/hash-calculate.contribution.js +27 -0
  40. package/lib/hash-calculate/hash-calculate.contribution.js.map +1 -0
  41. package/lib/index.d.ts +7 -0
  42. package/lib/index.d.ts.map +1 -0
  43. package/lib/index.js +12 -0
  44. package/lib/index.js.map +1 -0
  45. package/lib/logger/node-logger.d.ts +23 -0
  46. package/lib/logger/node-logger.d.ts.map +1 -0
  47. package/lib/logger/node-logger.js +61 -0
  48. package/lib/logger/node-logger.js.map +1 -0
  49. package/lib/node-module.d.ts +4 -0
  50. package/lib/node-module.d.ts.map +1 -0
  51. package/lib/node-module.js +8 -0
  52. package/lib/node-module.js.map +1 -0
  53. package/package.json +27 -0
@@ -0,0 +1,161 @@
1
+ /// <reference types="node" />
2
+ import { Injector, ConstructorOf } from '@opensumi/di';
3
+ import Koa from 'koa';
4
+ import http from 'http';
5
+ import https from 'https';
6
+ import net from 'net';
7
+ import cp from 'child_process';
8
+ import { MaybePromise, ContributionProvider } from '@opensumi/ide-core-common';
9
+ import { RPCServiceCenter } from '../connection';
10
+ import { NodeModule } from '../node-module';
11
+ import { WebSocketHandler } from '@opensumi/ide-connection/lib/node';
12
+ import { LogLevel, ILogService } from '@opensumi/ide-core-common';
13
+ export declare type ModuleConstructor = ConstructorOf<NodeModule>;
14
+ export declare type ContributionConstructor = ConstructorOf<ServerAppContribution>;
15
+ export declare const AppConfig: unique symbol;
16
+ export interface MarketplaceRequest {
17
+ path?: string;
18
+ headers?: {
19
+ [header: string]: string | string[] | undefined;
20
+ };
21
+ }
22
+ export interface MarketplaceConfig {
23
+ endpoint: string;
24
+ extensionDir: string;
25
+ showBuiltinExtensions: boolean;
26
+ accountId: string;
27
+ masterKey: string;
28
+ transformRequest?: (request: MarketplaceRequest) => MarketplaceRequest;
29
+ ignoreId: string[];
30
+ }
31
+ interface Config {
32
+ /**
33
+ * 初始化的 DI 实例,一般可在外部进行 DI 初始化之后传入,便于提前进行一些依赖的初始化
34
+ */
35
+ injector: Injector;
36
+ /**
37
+ * 设置落盘日志级别,默认为 Info 级别的log落盘
38
+ */
39
+ logLevel?: LogLevel;
40
+ /**
41
+ * 设置日志的目录,默认:~/.sumi/logs
42
+ */
43
+ logDir?: string;
44
+ /**
45
+ * @deprecated 可通过在传入的 `injector` 初始化 `ILogService` 进行实现替换
46
+ * 外部设置的 ILogService,替换默认的 logService
47
+ */
48
+ LogServiceClass?: ConstructorOf<ILogService>;
49
+ /**
50
+ * 启用插件进程的最大个数
51
+ */
52
+ maxExtProcessCount?: number;
53
+ /**
54
+ * 插件日志自定义实现路径
55
+ */
56
+ extLogServiceClassPath?: string;
57
+ /**
58
+ * 插件进程关闭时间
59
+ */
60
+ processCloseExitThreshold?: number;
61
+ /**
62
+ * 终端 pty 进程退出时间
63
+ */
64
+ terminalPtyCloseThreshold?: number;
65
+ /**
66
+ * 访问静态资源允许的 origin
67
+ */
68
+ staticAllowOrigin?: string;
69
+ /**
70
+ * 访问静态资源允许的路径,用于配置静态资源的白名单规则
71
+ */
72
+ staticAllowPath?: string[];
73
+ /**
74
+ * 文件服务禁止访问的路径,使用 glob 匹配
75
+ */
76
+ blockPatterns?: string[];
77
+ /**
78
+ * 获取插件进程句柄方法
79
+ * @deprecated 自测 1.30.0 后,不在提供给 IDE 后端发送插件进程的方法
80
+ */
81
+ onDidCreateExtensionHostProcess?: (cp: cp.ChildProcess) => void;
82
+ /**
83
+ * 插件 Node 进程入口文件
84
+ */
85
+ extHost?: string;
86
+ /**
87
+ * 插件进程存放用于通信的 sock 地址
88
+ * 默认为 /tmp
89
+ */
90
+ extHostIPCSockPath?: string;
91
+ /**
92
+ * 插件进程 fork 配置
93
+ */
94
+ extHostForkOptions?: Partial<cp.ForkOptions>;
95
+ /**
96
+ * 配置关闭 keytar 校验能力,默认开启
97
+ */
98
+ disableKeytar?: boolean;
99
+ }
100
+ export interface AppConfig extends Partial<Config> {
101
+ marketplace: MarketplaceConfig;
102
+ }
103
+ export interface IServerAppOpts extends Partial<Config> {
104
+ modules?: ModuleConstructor[];
105
+ contributions?: ContributionConstructor[];
106
+ modulesInstances?: NodeModule[];
107
+ webSocketHandler?: WebSocketHandler[];
108
+ marketplace?: Partial<MarketplaceConfig>;
109
+ use?(middleware: Koa.Middleware<Koa.ParameterizedContext<any, {}>>): void;
110
+ }
111
+ export declare const ServerAppContribution: unique symbol;
112
+ export interface ServerAppContribution {
113
+ initialize?(app: IServerApp): MaybePromise<void>;
114
+ onStart?(app: IServerApp): MaybePromise<void>;
115
+ onStop?(app: IServerApp): MaybePromise<void>;
116
+ onWillUseElectronMain?(): void;
117
+ }
118
+ export interface IServerApp {
119
+ use(middleware: Koa.Middleware<Koa.ParameterizedContext<any, {}>>): void;
120
+ start(server: http.Server | https.Server): Promise<void>;
121
+ }
122
+ export declare class ServerApp implements IServerApp {
123
+ private injector;
124
+ private config;
125
+ private logger;
126
+ private webSocketHandler;
127
+ private modulesInstances;
128
+ use: (middleware: Koa.Middleware<Koa.ParameterizedContext<any, {}>>) => void;
129
+ protected contributionsProvider: ContributionProvider<ServerAppContribution>;
130
+ /**
131
+ * 启动初始化
132
+ * 1. 绑定 process 报错处理
133
+ * 2. 初始化内置的 Provider
134
+ * 3. 获取 Modules 的实例
135
+ * 4. 设置默认的实例
136
+ * @param opts
137
+ */
138
+ constructor(opts: IServerAppOpts);
139
+ /**
140
+ * 将被依赖但未被加入modules的模块加入到待加载模块最后
141
+ */
142
+ resolveModuleDeps(moduleConstructor: ModuleConstructor, modules: any[]): void;
143
+ private get contributions();
144
+ private initBaseProvider;
145
+ private initializeContribution;
146
+ private startContribution;
147
+ start(server: http.Server | https.Server | net.Server, serviceHandler?: (serviceCenter: RPCServiceCenter) => void): Promise<void>;
148
+ private onStop;
149
+ /**
150
+ * 绑定 process 退出逻辑
151
+ */
152
+ private bindProcessHandler;
153
+ /**
154
+ * 收集 module 实例
155
+ * @param Constructors
156
+ * @param modules
157
+ */
158
+ private createNodeModules;
159
+ }
160
+ export {};
161
+ //# sourceMappingURL=app.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../src/bootstrap/app.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,IAAI,MAAM,MAAM,CAAC;AACxB,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,GAAG,MAAM,KAAK,CAAC;AACtB,OAAO,EAAE,MAAM,eAAe,CAAC;AAG/B,OAAO,EAAE,YAAY,EAAE,oBAAoB,EAAyC,MAAM,2BAA2B,CAAC;AACtH,OAAO,EAAsD,gBAAgB,EAAE,MAAM,eAAe,CAAC;AACrG,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAE,gBAAgB,EAAE,MAAM,mCAAmC,CAAC;AACrE,OAAO,EAAE,QAAQ,EAAsB,WAAW,EAAqC,MAAM,2BAA2B,CAAC;AAGzH,oBAAY,iBAAiB,GAAG,aAAa,CAAC,UAAU,CAAC,CAAC;AAC1D,oBAAY,uBAAuB,GAAG,aAAa,CAAC,qBAAqB,CAAC,CAAC;AAE3E,eAAO,MAAM,SAAS,eAAsB,CAAC;AAE7C,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE;QACR,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,MAAM,EAAE,GAAG,SAAS,CAAC;KACjD,CAAC;CACH;AAED,MAAM,WAAW,iBAAiB;IAEhC,QAAQ,EAAE,MAAM,CAAC;IAEjB,YAAY,EAAE,MAAM,CAAC;IAErB,qBAAqB,EAAE,OAAO,CAAC;IAE/B,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EA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,oBAAoB,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC,KAAK,IAAI,CAAC;IAE7E,SAAS,CAAC,qBAAqB,EAAE,oBAAoB,CAAC,qBAAqB,CAAC,CAAC;IAE7E;;;;;;;OAOG;gBACS,IAAI,EAAE,cAAc;IA0ChC;;OAEG;IACI,iBAAiB,CAAC,iBAAiB,EAAE,iBAAiB,EAAE,OAAO,EAAE,GAAG,EAAE;IAW7E,OAAO,KAAK,aAAa,GAExB;IAED,OAAO,CAAC,gBAAgB;YAWV,sBAAsB;YAYtB,iBAAiB;IAYzB,KAAK,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,EAAE,cAAc,CAAC,EAAE,CAAC,aAAa,EAAE,gBAAgB,KAAK,IAAI;YAyBzG,MAAM;IAYpB;;OAEG;IACH,OAAO,CAAC,kBAAkB;IA6B1B;;;;OAIG;IACH,OAAO,CAAC,iBAAiB;CAyB1B"}
@@ -0,0 +1,206 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServerApp = exports.ServerAppContribution = exports.AppConfig = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@opensumi/di");
6
+ const http_1 = (0, tslib_1.__importDefault)(require("http"));
7
+ const https_1 = (0, tslib_1.__importDefault)(require("https"));
8
+ const net_1 = (0, tslib_1.__importDefault)(require("net"));
9
+ const os_1 = (0, tslib_1.__importDefault)(require("os"));
10
+ const path_1 = (0, tslib_1.__importDefault)(require("path"));
11
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
12
+ const connection_1 = require("../connection");
13
+ const ide_core_common_2 = require("@opensumi/ide-core-common");
14
+ const inner_providers_1 = require("./inner-providers");
15
+ exports.AppConfig = Symbol('AppConfig');
16
+ exports.ServerAppContribution = Symbol('ServerAppContribution');
17
+ class ServerApp {
18
+ /**
19
+ * 启动初始化
20
+ * 1. 绑定 process 报错处理
21
+ * 2. 初始化内置的 Provider
22
+ * 3. 获取 Modules 的实例
23
+ * 4. 设置默认的实例
24
+ * @param opts
25
+ */
26
+ constructor(opts) {
27
+ this.injector = opts.injector || new di_1.Injector();
28
+ this.webSocketHandler = opts.webSocketHandler || [];
29
+ // 使用外部传入的中间件
30
+ this.use = opts.use || ((middleware) => null);
31
+ this.config = {
32
+ injector: this.injector,
33
+ logDir: opts.logDir,
34
+ logLevel: opts.logLevel,
35
+ LogServiceClass: opts.LogServiceClass,
36
+ marketplace: Object.assign({
37
+ endpoint: 'https://marketplace.antfin-inc.com',
38
+ extensionDir: path_1.default.join(os_1.default.homedir(), ...(ide_core_common_1.isWindows ? [ide_core_common_2.StoragePaths.WINDOWS_APP_DATA_DIR, ide_core_common_2.StoragePaths.WINDOWS_ROAMING_DIR] : ['']), ide_core_common_2.StoragePaths.DEFAULT_STORAGE_DIR_NAME, ide_core_common_2.StoragePaths.MARKETPLACE_DIR),
39
+ showBuiltinExtensions: false,
40
+ accountId: '',
41
+ masterKey: '',
42
+ ignoreId: [],
43
+ }, opts.marketplace),
44
+ processCloseExitThreshold: opts.processCloseExitThreshold,
45
+ terminalPtyCloseThreshold: opts.terminalPtyCloseThreshold,
46
+ staticAllowOrigin: opts.staticAllowOrigin,
47
+ staticAllowPath: opts.staticAllowPath,
48
+ extLogServiceClassPath: opts.extLogServiceClassPath,
49
+ maxExtProcessCount: opts.maxExtProcessCount,
50
+ onDidCreateExtensionHostProcess: opts.onDidCreateExtensionHostProcess,
51
+ extHost: process.env.EXTENSION_HOST_ENTRY || opts.extHost,
52
+ blockPatterns: opts.blockPatterns,
53
+ extHostIPCSockPath: opts.extHostIPCSockPath,
54
+ extHostForkOptions: opts.extHostForkOptions,
55
+ };
56
+ this.bindProcessHandler();
57
+ this.initBaseProvider(opts);
58
+ this.createNodeModules(opts.modules, opts.modulesInstances);
59
+ this.logger = this.injector.get(ide_core_common_2.ILogServiceManager).getLogger(ide_core_common_2.SupportLogNamespace.App);
60
+ this.contributionsProvider = this.injector.get(exports.ServerAppContribution);
61
+ }
62
+ /**
63
+ * 将被依赖但未被加入modules的模块加入到待加载模块最后
64
+ */
65
+ resolveModuleDeps(moduleConstructor, modules) {
66
+ const dependencies = Reflect.getMetadata('dependencies', moduleConstructor);
67
+ if (dependencies) {
68
+ dependencies.forEach((dep) => {
69
+ if (modules.indexOf(dep) === -1) {
70
+ modules.push(dep);
71
+ }
72
+ });
73
+ }
74
+ }
75
+ get contributions() {
76
+ return this.contributionsProvider.getContributions();
77
+ }
78
+ initBaseProvider(opts) {
79
+ // 创建 contributionsProvider
80
+ (0, ide_core_common_1.createContributionProvider)(this.injector, exports.ServerAppContribution);
81
+ this.injector.addProviders({
82
+ token: exports.AppConfig,
83
+ useValue: this.config,
84
+ });
85
+ (0, inner_providers_1.injectInnerProviders)(this.injector);
86
+ }
87
+ async initializeContribution() {
88
+ for (const contribution of this.contributions) {
89
+ if (contribution.initialize) {
90
+ try {
91
+ await contribution.initialize(this);
92
+ }
93
+ catch (error) {
94
+ this.logger.error('Could not initialize contribution', error);
95
+ }
96
+ }
97
+ }
98
+ }
99
+ async startContribution() {
100
+ for (const contrib of this.contributions) {
101
+ if (contrib.onStart) {
102
+ try {
103
+ await contrib.onStart(this);
104
+ }
105
+ catch (error) {
106
+ this.logger.error('Could not start contribution', error);
107
+ }
108
+ }
109
+ }
110
+ }
111
+ async start(server, serviceHandler) {
112
+ await this.initializeContribution();
113
+ let serviceCenter;
114
+ if (serviceHandler) {
115
+ serviceCenter = new connection_1.RPCServiceCenter();
116
+ serviceHandler(serviceCenter);
117
+ }
118
+ else {
119
+ if (server instanceof http_1.default.Server || server instanceof https_1.default.Server) {
120
+ // 创建 websocket 通道
121
+ serviceCenter = (0, connection_1.createServerConnection2)(server, this.injector, this.modulesInstances, this.webSocketHandler);
122
+ }
123
+ else if (server instanceof net_1.default.Server) {
124
+ serviceCenter = (0, connection_1.createNetServerConnection)(server, this.injector, this.modulesInstances);
125
+ }
126
+ }
127
+ // TODO: 每次链接来的时候绑定一次,或者是服务获取的时候多实例化出来
128
+ // bindModuleBackService(this.injector, this.modulesInstances, serviceCenter);
129
+ await this.startContribution();
130
+ }
131
+ async onStop() {
132
+ for (const contrib of this.contributions) {
133
+ if (contrib.onStop) {
134
+ try {
135
+ await contrib.onStop(this);
136
+ }
137
+ catch (error) {
138
+ this.logger.error('Could not stop contribution', error);
139
+ }
140
+ }
141
+ }
142
+ }
143
+ /**
144
+ * 绑定 process 退出逻辑
145
+ */
146
+ bindProcessHandler() {
147
+ process.on('uncaughtException', (error) => {
148
+ if (error) {
149
+ this.logger.error('Uncaught Exception: ', error.toString());
150
+ if (error.stack) {
151
+ this.logger.error(error.stack);
152
+ }
153
+ }
154
+ });
155
+ // Handles normal process termination.
156
+ process.on('exit', () => {
157
+ this.logger.log('process exit');
158
+ });
159
+ // Handles `Ctrl+C`.
160
+ process.on('SIGINT', async () => {
161
+ this.logger.log('process SIGINT');
162
+ await this.onStop();
163
+ this.logger.log('process SIGINT DONE');
164
+ process.exit(0);
165
+ });
166
+ // Handles `kill pid`.
167
+ process.on('SIGTERM', async () => {
168
+ this.logger.log('process SIGTERM');
169
+ await this.onStop();
170
+ this.logger.log('process SIGTERM DONE');
171
+ process.exit(0);
172
+ });
173
+ }
174
+ /**
175
+ * 收集 module 实例
176
+ * @param Constructors
177
+ * @param modules
178
+ */
179
+ createNodeModules(Constructors = [], modules = []) {
180
+ const allModules = [...modules];
181
+ Constructors.forEach((c) => {
182
+ this.resolveModuleDeps(c, Constructors);
183
+ });
184
+ for (const Constructor of Constructors) {
185
+ allModules.push(this.injector.get(Constructor));
186
+ }
187
+ for (const instance of allModules) {
188
+ if (instance.providers) {
189
+ this.injector.addProviders(...instance.providers);
190
+ }
191
+ if (instance.contributionProvider) {
192
+ if (Array.isArray(instance.contributionProvider)) {
193
+ for (const contributionProvider of instance.contributionProvider) {
194
+ (0, ide_core_common_1.createContributionProvider)(this.injector, contributionProvider);
195
+ }
196
+ }
197
+ else {
198
+ (0, ide_core_common_1.createContributionProvider)(this.injector, instance.contributionProvider);
199
+ }
200
+ }
201
+ }
202
+ this.modulesInstances = allModules;
203
+ }
204
+ }
205
+ exports.ServerApp = ServerApp;
206
+ //# sourceMappingURL=app.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"app.js","sourceRoot":"","sources":["../../src/bootstrap/app.ts"],"names":[],"mappings":";;;;AAAA,qCAAuD;AAEvD,6DAAwB;AACxB,+DAA0B;AAC1B,2DAAsB;AAEtB,yDAAoB;AACpB,6DAAwB;AACxB,+DAAsH;AACtH,8CAAqG;AAGrG,+DAAyH;AACzH,uDAAyD;AAK5C,QAAA,SAAS,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC;AA6GhC,QAAA,qBAAqB,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;AAcrE,MAAa,SAAS;IAgBpB;;;;;;;OAOG;IACH,YAAY,IAAoB;QAC9B,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,IAAI,IAAI,aAAQ,EAAE,CAAC;QAChD,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,gBAAgB,IAAI,EAAE,CAAC;QACpD,aAAa;QACb,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,CAAC,MAAM,GAAG;YACZ,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ;YACvB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC;gBACzB,QAAQ,EAAE,oCAAoC;gBAC9C,YAAY,EAAE,cAAI,CAAC,IAAI,CACrB,YAAE,CAAC,OAAO,EAAE,EACZ,GAAG,CAAC,2BAAS,CAAC,CAAC,CAAC,CAAC,8BAAY,CAAC,oBAA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AAC;QAChC,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,EAAE;YACzB,IAAI,CAAC,iBAAiB,CAAC,CAAC,EAAE,YAAY,CAAC,CAAC;QAC1C,CAAC,CAAC,CAAC;QACH,KAAK,MAAM,WAAW,IAAI,YAAY,EAAE;YACtC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC;SACjD;QACD,KAAK,MAAM,QAAQ,IAAI,UAAU,EAAE;YACjC,IAAI,QAAQ,CAAC,SAAS,EAAE;gBACtB,IAAI,CAAC,QAAQ,CAAC,YAAY,CAAC,GAAG,QAAQ,CAAC,SAAS,CAAC,CAAC;aACnD;YAED,IAAI,QAAQ,CAAC,oBAAoB,EAAE;gBACjC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAC,EAAE;oBAChD,KAAK,MAAM,oBAAoB,IAAI,QAAQ,CAAC,oBAAoB,EAAE;wBAChE,IAAA,4CAA0B,EAAC,IAAI,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;qBACjE;iBACF;qBAAM;oBACL,IAAA,4CAA0B,EAAC,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,oBAAoB,CAAC,CAAC;iBAC1E;aACF;SACF;QACD,IAAI,CAAC,gBAAgB,GAAG,UAAU,CAAC;IACrC,CAAC;CACF;AA1ND,8BA0NC"}
@@ -0,0 +1,3 @@
1
+ export * from './app';
2
+ export * from './shell-path';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC;AACtB,cAAc,cAAc,CAAC"}
@@ -0,0 +1,6 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ (0, tslib_1.__exportStar)(require("./app"), exports);
5
+ (0, tslib_1.__exportStar)(require("./shell-path"), exports);
6
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/bootstrap/index.ts"],"names":[],"mappings":";;;AAAA,qDAAsB;AACtB,4DAA6B"}
@@ -0,0 +1,3 @@
1
+ import { Injector } from '@opensumi/di';
2
+ export declare function injectInnerProviders(injector: Injector): void;
3
+ //# sourceMappingURL=inner-providers.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inner-providers.d.ts","sourceRoot":"","sources":["../../src/bootstrap/inner-providers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAKxC,wBAAgB,oBAAoB,CAAC,QAAQ,EAAE,QAAQ,QAyBtD"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.injectInnerProviders = void 0;
4
+ const node_logger_1 = require("../logger/node-logger");
5
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
6
+ const hash_calculate_1 = require("@opensumi/ide-core-common/lib/hash-calculate/hash-calculate");
7
+ function injectInnerProviders(injector) {
8
+ injector.addProviders({
9
+ token: node_logger_1.INodeLogger,
10
+ useClass: node_logger_1.NodeLogger,
11
+ }, {
12
+ token: ide_core_common_1.IReporter,
13
+ useClass: ide_core_common_1.DefaultReporter,
14
+ }, {
15
+ token: ide_core_common_1.IReporterService,
16
+ useClass: ide_core_common_1.ReporterService,
17
+ }, {
18
+ token: ide_core_common_1.ReporterMetadata,
19
+ useValue: {
20
+ host: ide_core_common_1.REPORT_HOST.NODE,
21
+ },
22
+ }, {
23
+ token: hash_calculate_1.IHashCalculateService,
24
+ useClass: hash_calculate_1.HashCalculateServiceImpl,
25
+ });
26
+ }
27
+ exports.injectInnerProviders = injectInnerProviders;
28
+ //# sourceMappingURL=inner-providers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"inner-providers.js","sourceRoot":"","sources":["../../src/bootstrap/inner-providers.ts"],"names":[],"mappings":";;;AACA,uDAAgE;AAChE,+DAAyI;AACzI,gGAA8H;AAE9H,SAAgB,oBAAoB,CAAC,QAAkB;IACrD,QAAQ,CAAC,YAAY,CACnB;QACE,KAAK,EAAE,yBAAW;QAClB,QAAQ,EAAE,wBAAU;KACrB,EACD;QACE,KAAK,EAAE,2BAAS;QAChB,QAAQ,EAAE,iCAAe;KAC1B,EACD;QACE,KAAK,EAAE,kCAAgB;QACvB,QAAQ,EAAE,iCAAe;KAC1B,EACD;QACE,KAAK,EAAE,kCAAgB;QACvB,QAAQ,EAAE;YACR,IAAI,EAAE,6BAAW,CAAC,IAAI;SACvB;KACF,EACD;QACE,KAAK,EAAE,sCAAqB;QAC5B,QAAQ,EAAE,yCAAwB;KACnC,CACF,CAAC;AACJ,CAAC;AAzBD,oDAyBC"}
@@ -0,0 +1,2 @@
1
+ export declare function getShellPath(): Promise<string | undefined>;
2
+ //# sourceMappingURL=shell-path.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-path.d.ts","sourceRoot":"","sources":["../../src/bootstrap/shell-path.ts"],"names":[],"mappings":"AA8FA,wBAAsB,YAAY,IAAI,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAgBhE"}
@@ -0,0 +1,108 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getShellPath = void 0;
4
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
5
+ const child_process_1 = require("child_process");
6
+ // 成功过一次后,取 PATH 的超时时间
7
+ const MAX_WAIT_AFTER_SUCCESS = 3 * 1000;
8
+ // Shell 执行的最大超时时间
9
+ // 即使 getShellPath 已经返回,在这个时间之内执行成功后还是会更新缓存,供下一次调用使用
10
+ const SHELL_TIMEOUT = 30 * 1000;
11
+ let shellPath = process.env.PATH;
12
+ const isJestTest = process.env.IS_JEST_TEST;
13
+ let updating;
14
+ // 至少成功过一次
15
+ let hasSuccess = false;
16
+ // 某些用户的配置初始化时间较长,提前开始
17
+ // 测试环境下不执行,让测试快一点
18
+ if (!isJestTest) {
19
+ updateShellPath();
20
+ }
21
+ function parseEnv(env) {
22
+ env = env.split('_SHELL_ENV_DELIMITER_')[1];
23
+ const ret = {};
24
+ const lines = (0, ide_core_common_1.stripAnsi)(env).split('\n').filter(Boolean);
25
+ for (const line of lines) {
26
+ const [key, ...values] = line.split('=');
27
+ ret[key] = values.join('=');
28
+ }
29
+ return ret;
30
+ }
31
+ async function createUpdateShellPathPromise() {
32
+ let pid;
33
+ const timer = setTimeout(() => {
34
+ if (pid) {
35
+ try {
36
+ process.kill(pid);
37
+ }
38
+ catch (error) {
39
+ // ignore
40
+ }
41
+ }
42
+ }, SHELL_TIMEOUT);
43
+ try {
44
+ shellPath = await new Promise((resolve, reject) => {
45
+ const buf = [];
46
+ const proc = (0, child_process_1.spawn)(process.env.SHELL || '/bin/bash', [
47
+ '-ilc',
48
+ 'echo -n "_SHELL_ENV_DELIMITER_"; env; echo -n "_SHELL_ENV_DELIMITER_"; exit;',
49
+ ], {
50
+ stdio: ['ignore', 'pipe', 'pipe'],
51
+ detached: true, // 在有些场景 zsh 会卡住, detached 后正常
52
+ });
53
+ proc.on('error', (err) => {
54
+ reject(err);
55
+ });
56
+ proc.stdout.on('data', (chunk) => {
57
+ buf.push(chunk);
58
+ });
59
+ proc.stderr.on('data', (chunk) => {
60
+ // reject(chunk.toString());
61
+ });
62
+ proc.on('close', () => {
63
+ clearTimeout(timer);
64
+ if (buf.length) {
65
+ resolve(parseEnv(Buffer.concat(buf).toString()).PATH);
66
+ }
67
+ else {
68
+ reject(new Error('Fail to get env.'));
69
+ }
70
+ });
71
+ proc.unref();
72
+ pid = proc.pid;
73
+ });
74
+ hasSuccess = true;
75
+ }
76
+ catch (err) {
77
+ // console.error('shell path error:', err);
78
+ }
79
+ }
80
+ function updateShellPath() {
81
+ // 确保每次只有一个进程运行
82
+ // macOS 实测多个进程同时运行时,耗时成倍增加 <1s -> 6-10s
83
+ if (!updating) {
84
+ updating = createUpdateShellPathPromise().finally(() => {
85
+ updating = undefined;
86
+ });
87
+ }
88
+ return updating;
89
+ }
90
+ async function getShellPath() {
91
+ if (ide_core_common_1.isWindows) {
92
+ return process.env['PATH'];
93
+ }
94
+ // 触发一次更新
95
+ await Promise.race([
96
+ updateShellPath(),
97
+ new Promise((resolve) => {
98
+ // 第一次等待时间长一些,尽量拿到正确的 PATH
99
+ setTimeout(() => {
100
+ resolve(undefined);
101
+ }, hasSuccess ? MAX_WAIT_AFTER_SUCCESS : SHELL_TIMEOUT);
102
+ }),
103
+ ]);
104
+ // 不管有没有更新成功,都返回当前的最新结果
105
+ return shellPath;
106
+ }
107
+ exports.getShellPath = getShellPath;
108
+ //# sourceMappingURL=shell-path.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"shell-path.js","sourceRoot":"","sources":["../../src/bootstrap/shell-path.ts"],"names":[],"mappings":";;;AAAA,+DAAiE;AACjE,iDAAsC;AAEtC,sBAAsB;AACtB,MAAM,sBAAsB,GAAG,CAAC,GAAG,IAAI,CAAC;AAExC,kBAAkB;AAClB,oDAAoD;AACpD,MAAM,aAAa,GAAG,EAAE,GAAG,IAAI,CAAC;AAEhC,IAAI,SAAS,GAAG,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC;AACjC,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,YAAY,CAAC;AAC5C,IAAI,QAAmC,CAAC;AAExC,UAAU;AACV,IAAI,UAAU,GAAG,KAAK,CAAC;AAEvB,sBAAsB;AACtB,kBAAkB;AAClB,IAAI,CAAC,UAAU,EAAE;IACf,eAAe,EAAE,CAAC;CACnB;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,GAAG,GAAG,GAAG,CAAC,KAAK,CAAC,uBAAuB,CAAC,CAAC,CAAC,CAAC,CAAC;IAC5C,MAAM,GAAG,GAA4B,EAAE,CAAC;IACxC,MAAM,KAAK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AAC,SAAS,CAAC,CAAC;YACrB,CAAC,EAAE,UAAU,CAAC,CAAC,CAAC,sBAAsB,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC;QAC1D,CAAC,CAAC;KACH,CAAC,CAAC;IACH,uBAAuB;IACvB,OAAO,SAAS,CAAC;AACnB,CAAC;AAhBD,oCAgBC"}
@@ -0,0 +1,5 @@
1
+ import { ICommonServer, OS } from '@opensumi/ide-core-common';
2
+ export declare class CommonServer implements ICommonServer {
3
+ getBackendOS(): Promise<OS.Type>;
4
+ }
5
+ //# sourceMappingURL=common.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.server.d.ts","sourceRoot":"","sources":["../../src/common-module/common.server.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,EAAE,EAAE,MAAM,2BAA2B,CAAC;AAE9D,qBACa,YAAa,YAAW,aAAa;IAC1C,YAAY,IAAI,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC;CAGvC"}
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.CommonServer = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const di_1 = require("@opensumi/di");
6
+ const ide_core_common_1 = require("@opensumi/ide-core-common");
7
+ let CommonServer = class CommonServer {
8
+ async getBackendOS() {
9
+ return ide_core_common_1.OS.type();
10
+ }
11
+ };
12
+ CommonServer = (0, tslib_1.__decorate)([
13
+ (0, di_1.Injectable)()
14
+ ], CommonServer);
15
+ exports.CommonServer = CommonServer;
16
+ //# sourceMappingURL=common.server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"common.server.js","sourceRoot":"","sources":["../../src/common-module/common.server.ts"],"names":[],"mappings":";;;;AAAA,qCAA0C;AAC1C,+DAA8D;AAG9D,IAAa,YAAY,GAAzB,MAAa,YAAY;IACvB,KAAK,CAAC,YAAY;QAChB,OAAO,oBAAE,CAAC,IAAI,EAAE,CAAC;IACnB,CAAC;CACF,CAAA;AAJY,YAAY;IADxB,IAAA,eAAU,GAAE;GACA,YAAY,CAIxB;AAJY,oCAAY"}
@@ -0,0 +1,16 @@
1
+ import { INativeCredentialService } from '@opensumi/ide-core-common';
2
+ export declare class CredentialService implements INativeCredentialService {
3
+ private static readonly MAX_PASSWORD_LENGTH;
4
+ private static readonly PASSWORD_CHUNK_SIZE;
5
+ private readonly appConfig;
6
+ setPassword(service: string, account: string, password: string): Promise<void>;
7
+ deletePassword(service: string, account: string): Promise<boolean>;
8
+ getPassword(service: string, account: string): Promise<string | null>;
9
+ findPassword(service: string): Promise<string | null>;
10
+ findCredentials(service: string): Promise<Array<{
11
+ account: string;
12
+ password: string;
13
+ }>>;
14
+ private withKeytar;
15
+ }
16
+ //# sourceMappingURL=credential.server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credential.server.d.ts","sourceRoot":"","sources":["../../src/common-module/credential.server.ts"],"names":[],"mappings":"AAEA,OAAO,EAAoB,wBAAwB,EAAa,MAAM,2BAA2B,CAAC;AAElG,qBACa,iBAAkB,YAAW,wBAAwB;IAChE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAAQ;IACnD,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAA+C;IAG1F,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAY;IAEhC,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB9E,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IAM/C,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;IA0B5C,YAAY,CAAC,OAAO,EAAE,MAAM;IAS5B,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAAC;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC;YAK/E,UAAU;CAMzB"}