@opensumi/ide-connection 2.18.3 → 2.18.4-rc-1655088231.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.
Files changed (2) hide show
  1. package/README.md +36 -42
  2. package/package.json +4 -4
package/README.md CHANGED
@@ -2,22 +2,22 @@
2
2
 
3
3
  基于 jsonrpc 完成多端远程调用场景,兼容 lsp 等通信方式
4
4
 
5
-
6
5
  ### opensumi 中使用
7
6
 
8
7
  **准备**
8
+
9
9
  1. 框架中服务分为运行在浏览器环境的 前端服务(frontService) 与运行在 node 环境的 后端服务(backService),服务在两端的实现方式是一致的
10
10
  2. 目前在 `tools/dev-tool` 中的启动逻辑中完成了服务的注册和获取逻辑,在具体功能模块中无需关心具体的通信注册获取逻辑
11
11
 
12
- **后端服务(backService)**
13
- 后端服务(backService) 即在 Web Server 暴露的能力,类似 web 应用框架中 controller提供的请求响应逻辑
12
+ **后端服务(backService)** 后端服务(backService) 即在 Web Server 暴露的能力,类似 web 应用框架中 controller 提供的请求响应逻辑
14
13
 
15
14
  1. 注册服务
16
15
 
17
16
  `packages/file-service/src/node/index.ts`
17
+
18
18
  ```javascript
19
19
  import { FileSystemNodeOptions, FileService } from './file-service';
20
- import {servicePath} from '../common/index';
20
+ import { servicePath } from '../common/index';
21
21
 
22
22
  export class FileServiceModule extends NodeModule {
23
23
  providers = [{ token: 'FileServiceOptions', useValue: FileSystemNodeOptions.DEFAULT }];
@@ -36,26 +36,25 @@ export class FileServiceModule extends NodeModule {
36
36
  2. 服务调用
37
37
 
38
38
  `packages/file-tree/src/browser/index.ts`
39
- ```javascript
40
39
 
41
- import {servicePath as FileServicePath} from '@opensumi/ide-file-service';
40
+ ```javascript
41
+ import { servicePath as FileServicePath } from '@opensumi/ide-file-service';
42
42
 
43
43
  @Injectable()
44
44
  export class FileTreeModule extends BrowserModule {
45
-
46
- providers: Provider[] = [
47
- createFileTreeAPIProvider(FileTreeAPIImpl),
45
+ providers: Provider[] = [createFileTreeAPIProvider(FileTreeAPIImpl)];
46
+ backServices = [
47
+ {
48
+ servicePath: FileServicePath,
49
+ },
48
50
  ];
49
- backServices = [{
50
- servicePath: FileServicePath,
51
- }];
52
51
  }
53
-
54
52
  ```
55
53
 
56
54
  例如在 file-tree 模块中,首先在模块入口位置声明需要用到的 `backServices`,传入引用的服务 `servicePath`,与服务注册时的 `servicePath` 一致
57
55
 
58
56
  `packages/file-tree/src/browser/file-tree.service.ts`
57
+
59
58
  ```javascript
60
59
  import {servicePath as FileServicePath} from '@opensumi/ide-file-service';
61
60
 
@@ -71,13 +70,13 @@ export default class FileTreeService extends Disposable {
71
70
  @Autowired(CommandService)
72
71
  private commandService: CommandService;
73
72
 
74
- constructor(@Inject(FileServicePath) protected readonly fileSevice) {
73
+ constructor(@Inject(FileServicePath) protected readonly fileService) {
75
74
  super();
76
75
 
77
76
  this.getFiles();
78
77
  }
79
78
  createFile = async () => {
80
- const {content} = await this.fileSevice.resolveContent('/Users/franklife/work/ide/ac/ide-framework/tsconfig.json');
79
+ const {content} = await this.fileService.resolveContent('/Users/franklife/work/ide/ac/ide-framework/tsconfig.json');
81
80
  const file = await this.fileAPI.createFile({
82
81
  name: 'name' + Date.now() + '\n' + content,
83
82
  path: 'path' + Date.now(),
@@ -98,7 +97,7 @@ export default class FileTreeService extends Disposable {
98
97
  在 file-tree.service.ts 中通过 `servicePath` 进行注入,并直接调用在服务类上的方法
99
98
 
100
99
  ```javascript
101
- constructor(@Inject(FileServicePath) protected readonly fileSevice) {
100
+ constructor(@Inject(FileServicePath) protected readonly fileService) {
102
101
  super();
103
102
 
104
103
  this.getFiles();
@@ -108,30 +107,30 @@ constructor(@Inject(FileServicePath) protected readonly fileSevice) {
108
107
  方法调用会转换成一个远程调用进行响应,返回结果
109
108
 
110
109
  ```javascript
111
- const {content} = await this.fileSevice.resolveContent('/Users/franklife/work/ide/ac/ide-framework/tsconfig.json');
110
+ const { content } = await this.fileService.resolveContent('/Users/franklife/work/ide/ac/ide-framework/tsconfig.json');
112
111
  ```
113
112
 
114
-
115
- **前端服务(frontService)**
116
- 后端服务(backService) 即在 Browser 环境下运行的代码暴露的能力
113
+ **前端服务(frontService)** 后端服务(backService) 即在 Browser 环境下运行的代码暴露的能力
117
114
 
118
115
  1. 注册服务
119
116
 
120
117
  `packages/file-ree/src/browser/index.ts`
118
+
121
119
  ```javascript
122
120
  @Injectable()
123
121
  export class FileTreeModule extends BrowserModule {
124
-
125
- providers: Provider[] = [
126
- createFileTreeAPIProvider(FileTreeAPIImpl),
122
+ providers: Provider[] = [createFileTreeAPIProvider(FileTreeAPIImpl)];
123
+ backServices = [
124
+ {
125
+ servicePath: FileServicePath,
126
+ },
127
+ ];
128
+ frontServices = [
129
+ {
130
+ servicePath: FileTreeServicePath,
131
+ token: FileTreeService,
132
+ },
127
133
  ];
128
- backServices = [{
129
- servicePath: FileServicePath,
130
- }];
131
- frontServices = [{
132
- servicePath: FileTreeServicePath,
133
- token: FileTreeService,
134
- }];
135
134
  }
136
135
  ```
137
136
 
@@ -140,8 +139,9 @@ export class FileTreeModule extends BrowserModule {
140
139
  2. 服务使用
141
140
 
142
141
  `packages/file-service/src/node/index.ts`
142
+
143
143
  ```javascript
144
- import {servicePath as FileTreeServicePath} from '@opensumi/ide-file-tree';
144
+ import { servicePath as FileTreeServicePath } from '@opensumi/ide-file-tree';
145
145
 
146
146
  @Injectable()
147
147
  export class FileServiceModule extends NodeModule {
@@ -164,6 +164,7 @@ export class FileServiceModule extends NodeModule {
164
164
  与使用后端服务一致,在模块定义中声明需要使用的前端服务 `frontServices`,传入前端服务注册时用的 `servicePath` 一致
165
165
 
166
166
  `packages/file-service/src/node/file-service.ts`
167
+
167
168
  ```javascript
168
169
  @Injectable()
169
170
  export class FileService implements IFileService {
@@ -192,17 +193,10 @@ export class FileService implements IFileService {
192
193
  ```
193
194
 
194
195
  方法调用会转换成一个远程调用进行响应,返回结果
196
+
195
197
  ```javascript
196
- const fileTree = await this.fileTreeService
197
- fileTree.fileName(uri.substr(-5))
198
+ const fileTree = await this.fileTreeService;
199
+ fileTree.fileName(uri.substr(-5));
198
200
  ```
199
201
 
200
- 与后端服务调用区别的是,目前因前端代码后置执行,所以首先需要获取服务 `await thie.fileTreeService` 后进行调用
201
-
202
-
203
-
204
-
205
-
206
-
207
-
208
-
202
+ 与后端服务调用区别的是,目前因前端代码后置执行,所以首先需要获取服务 `await this.fileTreeService` 后进行调用
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensumi/ide-connection",
3
- "version": "2.18.3",
3
+ "version": "2.18.4-rc-1655088231.0",
4
4
  "files": [
5
5
  "lib"
6
6
  ],
@@ -16,15 +16,15 @@
16
16
  "url": "git@github.com:opensumi/core.git"
17
17
  },
18
18
  "dependencies": {
19
- "@opensumi/ide-core-common": "2.18.3",
19
+ "@opensumi/ide-core-common": "2.18.4-rc-1655088231.0",
20
20
  "@opensumi/vscode-jsonrpc": "^8.0.0-next.2",
21
21
  "path-match": "^1.2.4",
22
22
  "ws": "^7.2.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@opensumi/ide-components": "2.18.3",
25
+ "@opensumi/ide-components": "2.18.4-rc-1655088231.0",
26
26
  "@opensumi/ide-dev-tool": "^1.3.1",
27
27
  "mock-socket": "^9.0.2"
28
28
  },
29
- "gitHead": "7e10dbebe40ce48e1e1e3defaf96180c461f8888"
29
+ "gitHead": "2e9fd9e91988a30c1834a4b0709f30d23d22e04f"
30
30
  }