@opensumi/ide-core-common 2.21.13 → 2.22.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/command.d.ts +15 -5
- package/lib/command.d.ts.map +1 -1
- package/lib/command.js +11 -1
- package/lib/command.js.map +1 -1
- package/lib/const/application.d.ts +6 -1
- package/lib/const/application.d.ts.map +1 -1
- package/lib/const/application.js +8 -3
- package/lib/const/application.js.map +1 -1
- package/lib/declare.d.ts +2 -2
- package/lib/declare.d.ts.map +1 -1
- package/lib/editor.d.ts +4 -0
- package/lib/editor.d.ts.map +1 -1
- package/lib/electron.d.ts +1 -1
- package/lib/electron.d.ts.map +1 -1
- package/lib/event-bus/event-bus-types.d.ts +1 -1
- package/lib/event-bus/event-bus-types.d.ts.map +1 -1
- package/lib/event-bus/event-bus.js.map +1 -1
- package/lib/event-bus/event-decorator.js.map +1 -1
- package/lib/extension.schema.d.ts +1 -1
- package/lib/extension.schema.d.ts.map +1 -1
- package/lib/hash-calculate/WASMInterface.d.ts +2 -2
- package/lib/hash-calculate/WASMInterface.d.ts.map +1 -1
- package/lib/hash-calculate/hash-calculate.js.map +1 -1
- package/lib/hash-calculate/util.d.ts +2 -2
- package/lib/hash-calculate/util.d.ts.map +1 -1
- package/lib/json-schema.d.ts +9 -0
- package/lib/json-schema.d.ts.map +1 -1
- package/lib/keyboard/keymap.d.ts +1 -1
- package/lib/keyboard/keymap.d.ts.map +1 -1
- package/lib/localize.d.ts +1 -1
- package/lib/localize.d.ts.map +1 -1
- package/lib/log.d.ts +2 -2
- package/lib/log.d.ts.map +1 -1
- package/lib/mime.d.ts +6 -6
- package/lib/module.js.map +1 -1
- package/lib/preferences/preference-schema.d.ts +13 -3
- package/lib/preferences/preference-schema.d.ts.map +1 -1
- package/lib/preferences/preference-schema.js +11 -1
- package/lib/preferences/preference-schema.js.map +1 -1
- package/lib/preferences/preference-scope.d.ts +8 -1
- package/lib/preferences/preference-scope.d.ts.map +1 -1
- package/lib/preferences/preference-scope.js +11 -2
- package/lib/preferences/preference-scope.js.map +1 -1
- package/lib/problem-matcher.d.ts +1 -1
- package/lib/problem-matcher.d.ts.map +1 -1
- package/lib/problem-matcher.js.map +1 -1
- package/lib/problem-pattern.d.ts +4 -2
- package/lib/problem-pattern.d.ts.map +1 -1
- package/lib/problem-pattern.js +24 -1
- package/lib/problem-pattern.js.map +1 -1
- package/lib/reference.d.ts +2 -1
- package/lib/reference.d.ts.map +1 -1
- package/lib/reference.js +11 -6
- package/lib/reference.js.map +1 -1
- package/lib/reporter.js.map +1 -1
- package/lib/storage.d.ts +1 -1
- package/lib/storage.d.ts.map +1 -1
- package/lib/storage.js.map +1 -1
- package/lib/task-definition.js.map +1 -1
- package/lib/types/common.d.ts +1 -1
- package/lib/types/common.d.ts.map +1 -1
- package/lib/types/editor.d.ts +2 -2
- package/lib/types/editor.d.ts.map +1 -1
- package/lib/types/file-watch.d.ts +1 -1
- package/lib/types/file-watch.d.ts.map +1 -1
- package/lib/types/markers/markers-manager.d.ts.map +1 -1
- package/lib/types/markers/markers-manager.js +4 -10
- package/lib/types/markers/markers-manager.js.map +1 -1
- package/lib/types/markers/markers.d.ts +2 -0
- package/lib/types/markers/markers.d.ts.map +1 -1
- package/lib/types/markers/markers.js.map +1 -1
- package/package.json +7 -6
- package/src/LifeCyclePhase.ts +6 -0
- package/src/application-error.ts +77 -0
- package/src/application-props.ts +28 -0
- package/src/application.lifecycle.ts +15 -0
- package/src/browser-fs/ensure-dir.ts +46 -0
- package/src/browser-fs/util.ts +52 -0
- package/src/clipboard.ts +31 -0
- package/src/command.ts +726 -0
- package/src/commands/terminal.ts +0 -0
- package/src/comparers.ts +152 -0
- package/src/connection.ts +7 -0
- package/src/const/application.ts +11 -0
- package/src/const/index.ts +1 -0
- package/src/contribution-provider.ts +47 -0
- package/src/credential.ts +21 -0
- package/src/crypto.ts +8 -0
- package/src/declare.ts +3 -0
- package/src/di-helper/domain-helper.ts +48 -0
- package/src/di-helper/index.ts +1 -0
- package/src/editor.ts +6 -0
- package/src/electron.ts +168 -0
- package/src/env.ts +1 -0
- package/src/event-bus/basic-event.ts +3 -0
- package/src/event-bus/event-bus-types.ts +68 -0
- package/src/event-bus/event-bus.ts +57 -0
- package/src/event-bus/event-decorator.ts +32 -0
- package/src/event-bus/index.ts +4 -0
- package/src/extension.schema.ts +16 -0
- package/src/hash-calculate/WASMInterface.ts +266 -0
- package/src/hash-calculate/hash-calculate.ts +53 -0
- package/src/hash-calculate/lockedCreate.ts +17 -0
- package/src/hash-calculate/md5.wasm.json +1 -0
- package/src/hash-calculate/mutex.ts +30 -0
- package/src/hash-calculate/util.ts +190 -0
- package/src/id-generator.ts +15 -0
- package/src/index.ts +39 -0
- package/src/json-schema.ts +80 -0
- package/src/keyboard/index.ts +2 -0
- package/src/keyboard/keyboard-layout-provider.ts +46 -0
- package/src/keyboard/keymap.ts +224 -0
- package/src/line-text.ts +93 -0
- package/src/localize.ts +203 -0
- package/src/log.ts +338 -0
- package/src/markdown.ts +8 -0
- package/src/menu.ts +31 -0
- package/src/mime.ts +8 -0
- package/src/mocks/electron/browserMock.ts +10 -0
- package/src/mocks/electron/ipcRenderer.ts +30 -0
- package/src/module.ts +31 -0
- package/src/network.ts +47 -0
- package/src/node/cli.ts +5 -0
- package/src/node/port.ts +134 -0
- package/src/preferences/index.ts +2 -0
- package/src/preferences/preference-schema.ts +122 -0
- package/src/preferences/preference-scope.ts +65 -0
- package/src/problem-matcher.ts +389 -0
- package/src/problem-pattern.ts +574 -0
- package/src/range.ts +24 -0
- package/src/reference.ts +141 -0
- package/src/reporter.ts +64 -0
- package/src/settings/general.ts +5 -0
- package/src/settings/index.ts +3 -0
- package/src/settings/search.ts +7 -0
- package/src/settings/terminal.ts +9 -0
- package/src/storage.ts +99 -0
- package/src/task-definition.ts +172 -0
- package/src/theme.ts +7 -0
- package/src/types/accessibility.ts +4 -0
- package/src/types/application.ts +14 -0
- package/src/types/authentication.ts +120 -0
- package/src/types/common.ts +14 -0
- package/src/types/dnd.ts +8 -0
- package/src/types/editor.ts +246 -0
- package/src/types/extension.ts +96 -0
- package/src/types/file-watch.ts +100 -0
- package/src/types/file.ts +262 -0
- package/src/types/index.ts +15 -0
- package/src/types/markdown.ts +10 -0
- package/src/types/markers/index.ts +2 -0
- package/src/types/markers/markers-manager.ts +392 -0
- package/src/types/markers/markers.ts +125 -0
- package/src/types/message.ts +6 -0
- package/src/types/reporter.ts +96 -0
- package/src/types/statusbar.ts +6 -0
- package/src/types/string.ts +3 -0
- package/src/utils/index.ts +1 -0
- package/src/utils/ipc.ts +28 -0
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { URI } from '@opensumi/ide-utils';
|
|
1
2
|
export interface MapMap<V> {
|
|
2
3
|
[key: string]: {
|
|
3
4
|
[key: string]: V;
|
|
@@ -50,6 +51,7 @@ export interface IRelatedInformation {
|
|
|
50
51
|
*/
|
|
51
52
|
export interface IMarkerData {
|
|
52
53
|
code?: string;
|
|
54
|
+
codeHref?: URI;
|
|
53
55
|
severity: MarkerSeverity;
|
|
54
56
|
message: string;
|
|
55
57
|
source?: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../src/types/markers/markers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"markers.d.ts","sourceRoot":"","sources":["../../../src/types/markers/markers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAEzD,MAAM,WAAW,MAAM,CAAC,CAAC;IACvB,CAAC,GAAG,EAAE,MAAM,GAAG;QAAE,CAAC,GAAG,EAAE,MAAM,GAAG,CAAC,CAAA;KAAE,CAAC;CACrC;AAED,yBAAiB,MAAM,CAAC;IACtB,SAAgB,GAAG,CAAC,CAAC,EAAE,GAAG,EAAE,MAAM,CAAC,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GA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;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC,QAAQ,EAAE,MAAM,CAAC;IACjB,OAAO,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,GAAG,CAAC;IACf,QAAQ,EAAE,cAAc,CAAC;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,mBAAmB,EAAE,CAAC;IAC3C,IAAI,CAAC,EAAE,SAAS,EAAE,CAAC;CACpB;AAED,MAAM,WAAW,OAAQ,SAAQ,WAAW;IAC1C,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,gBAAgB;IAC/B,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"markers.js","sourceRoot":"","sources":["../../../src/types/markers/markers.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"markers.js","sourceRoot":"","sources":["../../../src/types/markers/markers.ts"],"names":[],"mappings":";;;AAAA,mDAAyD;AAMzD,IAAiB,MAAM,CAqDtB;AArDD,WAAiB,MAAM;IACrB,SAAgB,GAAG,CAAI,GAAc,EAAE,IAAY,EAAE,IAAY;QAC/D,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AAG,GAAG,CAAC,GAAG,CAAC,CAAC;YACxB,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC;YAChB,OAAO,MAAM,CAAC;SACf;QACD,OAAO,SAAS,CAAC;IACnB,CAAC;IAPe,gBAAS,YAOxB,CAAA;IAED,SAAgB,IAAI,CAAC,GAAgB;QACnC,MAAM,MAAM,GAAa,EAAE,CAAC;QAC5B,IAAI,GAAG,EAAE;YACP,wCAAwC;YACxC,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE;gBACrB,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAClB;SACF;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;IATe,WAAI,OASnB,CAAA;AACH,CAAC,EArDgB,MAAM,GAAN,cAAM,KAAN,cAAM,QAqDtB;AAED;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,mDAAQ,CAAA;IACR,mDAAQ,CAAA;IACR,yDAAW,CAAA;IACX,qDAAS,CAAA;AACX,CAAC,EALW,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAKzB;AAED,WAAiB,cAAc;IAC7B,SAAgB,OAAO,CAAC,CAAiB,EAAE,CAAiB;QAC1D,OAAO,CAAC,GAAG,CAAC,CAAC;IACf,CAAC;IAFe,sBAAO,UAEtB,CAAA;AACH,CAAC,EAJgB,cAAc,GAAd,sBAAc,KAAd,sBAAc,QAI9B"}
|
package/package.json
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-core-common",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.22.0",
|
|
4
4
|
"description": "@opensumi/ide-core-common",
|
|
5
5
|
"files": [
|
|
6
|
-
"lib"
|
|
6
|
+
"lib",
|
|
7
|
+
"src"
|
|
7
8
|
],
|
|
8
9
|
"license": "MIT",
|
|
9
10
|
"main": "lib/index.js",
|
|
@@ -13,16 +14,16 @@
|
|
|
13
14
|
"url": "git@github.com:opensumi/core.git"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
|
-
"prepublishOnly": "
|
|
17
|
+
"prepublishOnly": "yarn run build",
|
|
17
18
|
"build": "tsc --build ../../configs/ts/references/tsconfig.core-common.json"
|
|
18
19
|
},
|
|
19
20
|
"dependencies": {
|
|
20
21
|
"@opensumi/di": "^1.4.0",
|
|
21
|
-
"@opensumi/ide-utils": "2.
|
|
22
|
+
"@opensumi/ide-utils": "2.22.0",
|
|
22
23
|
"jschardet": "3.0.0"
|
|
23
24
|
},
|
|
24
25
|
"devDependencies": {
|
|
25
|
-
"@opensumi/ide-dev-tool": "
|
|
26
|
+
"@opensumi/ide-dev-tool": "1.3.1"
|
|
26
27
|
},
|
|
27
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "927717e1c60f9cf5f01622fd51085b318a175eeb"
|
|
28
29
|
}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/** ******************************************************************************
|
|
2
|
+
* Copyright (C) 2018 Red Hat, Inc. and others.
|
|
3
|
+
*
|
|
4
|
+
* This program and the accompanying materials are made available under the
|
|
5
|
+
* terms of the Eclipse Public License v. 2.0 which is available at
|
|
6
|
+
* http://www.eclipse.org/legal/epl-2.0.
|
|
7
|
+
*
|
|
8
|
+
* This Source Code may also be made available under the following Secondary
|
|
9
|
+
* Licenses when the conditions for such availability set forth in the Eclipse
|
|
10
|
+
* Public License v. 2.0 are satisfied: GNU General Public License, version 2
|
|
11
|
+
* with the GNU Classpath Exception which is available at
|
|
12
|
+
* https://www.gnu.org/software/classpath/license.html.
|
|
13
|
+
*
|
|
14
|
+
* SPDX-License-Identifier: EPL-2.0 OR GPL-2.0 WITH Classpath-exception-2.0
|
|
15
|
+
********************************************************************************/
|
|
16
|
+
// Some code copied and modified from https://github.com/eclipse-theia/theia/tree/v1.14.0/packages/core/src/common/application-error.ts
|
|
17
|
+
|
|
18
|
+
export interface ApplicationError<C extends number, D> extends Error {
|
|
19
|
+
readonly code: C;
|
|
20
|
+
readonly data: D;
|
|
21
|
+
toJson(): ApplicationError.Literal<D>;
|
|
22
|
+
}
|
|
23
|
+
export namespace ApplicationError {
|
|
24
|
+
export interface Literal<D> {
|
|
25
|
+
message: string;
|
|
26
|
+
data: D;
|
|
27
|
+
stack?: string;
|
|
28
|
+
}
|
|
29
|
+
export interface Constructor<C extends number, D> {
|
|
30
|
+
(...args: any[]): ApplicationError<C, D>;
|
|
31
|
+
code: C;
|
|
32
|
+
is(arg: object | undefined): arg is ApplicationError<C, D>;
|
|
33
|
+
}
|
|
34
|
+
const codes: number[] = [];
|
|
35
|
+
// 用于定义应用错误码
|
|
36
|
+
export function declare<C extends number, D>(code: C, factory: (...args: any[]) => Literal<D>): Constructor<C, D> {
|
|
37
|
+
if (codes.indexOf(code) !== -1) {
|
|
38
|
+
throw new Error(`An application error for '${code}' code is already declared`);
|
|
39
|
+
}
|
|
40
|
+
const constructorOpt = Object.assign((...args: any[]) => new Impl(code, factory(...args), constructorOpt), {
|
|
41
|
+
code,
|
|
42
|
+
is(arg: object | undefined): arg is ApplicationError<C, D> {
|
|
43
|
+
// JSON RPC通信后,错误的构造信息丢失,通过 Error 类的 cause 属性保存 ApplicationError 实例来修复。
|
|
44
|
+
// 需要加上第一个判断,否则过不了语法检查。
|
|
45
|
+
if (arg instanceof Error && arg.cause) {
|
|
46
|
+
const cause = arg.cause;
|
|
47
|
+
return cause instanceof Impl && cause.code === code;
|
|
48
|
+
}
|
|
49
|
+
return arg instanceof Impl && arg.code === code;
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
return constructorOpt;
|
|
53
|
+
}
|
|
54
|
+
export function is<C extends number, D>(arg: object | undefined): arg is ApplicationError<C, D> {
|
|
55
|
+
return arg instanceof Impl;
|
|
56
|
+
}
|
|
57
|
+
export function fromJson<C extends number, D>(code: C, raw: Literal<D>): ApplicationError<C, D> {
|
|
58
|
+
return new Impl(code, raw);
|
|
59
|
+
}
|
|
60
|
+
class Impl<C extends number, D> extends Error implements ApplicationError<C, D> {
|
|
61
|
+
readonly data: D;
|
|
62
|
+
constructor(readonly code: C, raw: ApplicationError.Literal<D>, constructorOpt?: Function) {
|
|
63
|
+
super(raw.message);
|
|
64
|
+
this.data = raw.data;
|
|
65
|
+
Object.setPrototypeOf(this, Impl.prototype);
|
|
66
|
+
if (raw.stack) {
|
|
67
|
+
this.stack = raw.stack;
|
|
68
|
+
} else if (Error.captureStackTrace && constructorOpt) {
|
|
69
|
+
Error.captureStackTrace(this, constructorOpt);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
toJson(): ApplicationError.Literal<D> {
|
|
73
|
+
const { message, data, stack } = this;
|
|
74
|
+
return { message, data, stack };
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 应用基础配置类型.
|
|
3
|
+
*/
|
|
4
|
+
export interface ApplicationConfig {
|
|
5
|
+
readonly [key: string]: any;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* 前端应用配置
|
|
10
|
+
* 下列的属性在页面启动时会注入到`index.html`中的window对象中
|
|
11
|
+
*/
|
|
12
|
+
export interface ClientAppConfig extends ApplicationConfig {
|
|
13
|
+
/**
|
|
14
|
+
* 默认主题
|
|
15
|
+
*/
|
|
16
|
+
readonly defaultTheme?: string;
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* 应用名称
|
|
20
|
+
*/
|
|
21
|
+
readonly applicationName: string;
|
|
22
|
+
|
|
23
|
+
/**
|
|
24
|
+
* 默认内部的 uriScheme,用于桌面版 app 的唤起
|
|
25
|
+
* 也默认为 vscode.env.uriScheme 的值
|
|
26
|
+
*/
|
|
27
|
+
readonly uriScheme: string;
|
|
28
|
+
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { Event } from '@opensumi/ide-utils';
|
|
2
|
+
|
|
3
|
+
export const enum LifeCyclePhase {
|
|
4
|
+
Prepare = 1,
|
|
5
|
+
Initialize = 2,
|
|
6
|
+
Starting = 3,
|
|
7
|
+
Ready = 4,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export const AppLifeCycleServiceToken = Symbol('AppLifeCycleService');
|
|
11
|
+
|
|
12
|
+
export interface IAppLifeCycleService {
|
|
13
|
+
phase: LifeCyclePhase;
|
|
14
|
+
onDidLifeCyclePhaseChange: Event<LifeCyclePhase>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import fs from 'fs';
|
|
2
|
+
|
|
3
|
+
import { promisify } from './util';
|
|
4
|
+
|
|
5
|
+
const PATH_SEPARATOR = '/';
|
|
6
|
+
|
|
7
|
+
function fsExistsAsync(path: string): Promise<boolean> {
|
|
8
|
+
return new Promise((resolve) => {
|
|
9
|
+
fs.exists(path, (exists: boolean) => {
|
|
10
|
+
resolve(exists);
|
|
11
|
+
});
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
interface FsLike {
|
|
16
|
+
access: (path: string) => Promise<boolean>;
|
|
17
|
+
mkdir: (path: string) => Promise<void>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
class DefaultFsImpl implements FsLike {
|
|
21
|
+
access(path: string): Promise<boolean> {
|
|
22
|
+
return new Promise((resolve) => {
|
|
23
|
+
fs.exists(path, (exists: boolean) => {
|
|
24
|
+
resolve(exists);
|
|
25
|
+
});
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
mkdir(path: string): Promise<void> {
|
|
30
|
+
return promisify(fs.mkdir)(path);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
const defaultFsImpl = new DefaultFsImpl();
|
|
35
|
+
|
|
36
|
+
export async function ensureDir(path: string, fsLikeImpl: FsLike = defaultFsImpl) {
|
|
37
|
+
const pathList = (path.startsWith(PATH_SEPARATOR) ? path.slice(0) : path).split(PATH_SEPARATOR);
|
|
38
|
+
let i = 0;
|
|
39
|
+
while (i < pathList.length) {
|
|
40
|
+
const targetPath = PATH_SEPARATOR + pathList.slice(0, i + 1).join(PATH_SEPARATOR);
|
|
41
|
+
if (!(await fsLikeImpl.access(targetPath))) {
|
|
42
|
+
await fsLikeImpl.mkdir(PATH_SEPARATOR + targetPath);
|
|
43
|
+
}
|
|
44
|
+
i = i + 1;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
/* eslint-disable @typescript-eslint/ban-types */
|
|
2
|
+
interface CustomPromisify<TCustom extends Function> extends Function {
|
|
3
|
+
__promisify__: TCustom;
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
export function promisify<TCustom extends Function>(fn: CustomPromisify<TCustom>): TCustom;
|
|
7
|
+
export function promisify<TResult>(fn: (callback: (err: any, result: TResult) => void) => void): () => Promise<TResult>;
|
|
8
|
+
export function promisify(fn: (callback: (err?: any) => void) => void): () => Promise<void>;
|
|
9
|
+
export function promisify<T1, TResult>(
|
|
10
|
+
fn: (arg1: T1, callback: (err: any, result: TResult) => void) => void,
|
|
11
|
+
): (arg1: T1) => Promise<TResult>;
|
|
12
|
+
export function promisify<T1>(fn: (arg1: T1, callback: (err?: any) => void) => void): (arg1: T1) => Promise<void>;
|
|
13
|
+
export function promisify<T1, T2, TResult>(
|
|
14
|
+
fn: (arg1: T1, arg2: T2, callback: (err: any, result: TResult) => void) => void,
|
|
15
|
+
): (arg1: T1, arg2: T2) => Promise<TResult>;
|
|
16
|
+
export function promisify<T1, T2>(
|
|
17
|
+
fn: (arg1: T1, arg2: T2, callback: (err?: any) => void) => void,
|
|
18
|
+
): (arg1: T1, arg2: T2) => Promise<void>;
|
|
19
|
+
export function promisify<T1, T2, T3, TResult>(
|
|
20
|
+
fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err: any, result: TResult) => void) => void,
|
|
21
|
+
): (arg1: T1, arg2: T2, arg3: T3) => Promise<TResult>;
|
|
22
|
+
export function promisify<T1, T2, T3>(
|
|
23
|
+
fn: (arg1: T1, arg2: T2, arg3: T3, callback: (err?: any) => void) => void,
|
|
24
|
+
): (arg1: T1, arg2: T2, arg3: T3) => Promise<void>;
|
|
25
|
+
export function promisify<T1, T2, T3, T4, TResult>(
|
|
26
|
+
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err: any, result: TResult) => void) => void,
|
|
27
|
+
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<TResult>;
|
|
28
|
+
export function promisify<T1, T2, T3, T4>(
|
|
29
|
+
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, callback: (err?: any) => void) => void,
|
|
30
|
+
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4) => Promise<void>;
|
|
31
|
+
export function promisify<T1, T2, T3, T4, T5, TResult>(
|
|
32
|
+
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err: any, result: TResult) => void) => void,
|
|
33
|
+
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<TResult>;
|
|
34
|
+
export function promisify<T1, T2, T3, T4, T5>(
|
|
35
|
+
fn: (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5, callback: (err?: any) => void) => void,
|
|
36
|
+
): (arg1: T1, arg2: T2, arg3: T3, arg4: T4, arg5: T5) => Promise<void>;
|
|
37
|
+
export function promisify(fn: Function): Function {
|
|
38
|
+
// https://www.typescriptlang.org/docs/handbook/release-notes/typescript-2-0.html#this-parameters-in-callbacks
|
|
39
|
+
return function (this: void, ...args: any[]) {
|
|
40
|
+
const that = this;
|
|
41
|
+
return new Promise((resolve, reject) => {
|
|
42
|
+
const callback = (err: Error, result: any) => {
|
|
43
|
+
if (err) {
|
|
44
|
+
reject(err);
|
|
45
|
+
}
|
|
46
|
+
resolve(result);
|
|
47
|
+
};
|
|
48
|
+
const newArgs = args.concat(callback);
|
|
49
|
+
fn.apply(that, newArgs);
|
|
50
|
+
});
|
|
51
|
+
};
|
|
52
|
+
}
|
package/src/clipboard.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { URI } from '@opensumi/ide-utils';
|
|
2
|
+
|
|
3
|
+
export const IClipboardService = Symbol('IClipboardService');
|
|
4
|
+
export const CLIPBOARD_FILE_TOKEN = 'clipboard/file-list';
|
|
5
|
+
|
|
6
|
+
export interface IClipboardService {
|
|
7
|
+
/**
|
|
8
|
+
* 写入文本
|
|
9
|
+
*/
|
|
10
|
+
writeText(text: string): Promise<void>;
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* 读取文本
|
|
14
|
+
*/
|
|
15
|
+
readText(): Promise<string>;
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* 写入资源
|
|
19
|
+
*/
|
|
20
|
+
writeResources(resources: URI[], field?: string): Promise<void>;
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* 读取资源
|
|
24
|
+
*/
|
|
25
|
+
readResources(field?: string): Promise<URI[]>;
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* 是否存在资源
|
|
29
|
+
*/
|
|
30
|
+
hasResources(field?: string): Promise<boolean>;
|
|
31
|
+
}
|