@opensumi/ide-connection 3.3.4-next-1727343192.0 → 3.4.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/README.md CHANGED
@@ -1,21 +1,16 @@
1
- # 通信模块(connection)
1
+ # 通信模块
2
2
 
3
3
  基于 sumi rpc 完成多端远程调用场景,兼容 lsp 等通信方式
4
4
 
5
- ### opensumi 中使用
5
+ ### 后端服务: backService
6
6
 
7
- **准备**
8
-
9
- 1. 框架中服务分为运行在浏览器环境的 前端服务(frontService) 与运行在 node 环境的 后端服务(backService),服务在两端的实现方式是一致的
10
- 2. 目前在 `tools/dev-tool` 中的启动逻辑中完成了服务的注册和获取逻辑,在具体功能模块中无需关心具体的通信注册获取逻辑
11
-
12
- **后端服务(backService)** 后端服务(backService) 即在 Web Server 暴露的能力,类似 web 应用框架中 controller 提供的请求响应逻辑
7
+ backService 即在 Web Server 暴露的能力,类似 web 应用框架中 controller 提供的请求响应逻辑
13
8
 
14
9
  1. 注册服务
15
10
 
16
11
  `packages/file-service/src/node/index.ts`
17
12
 
18
- ```javascript
13
+ ```ts
19
14
  import { FileSystemNodeOptions, FileService } from './file-service';
20
15
  import { servicePath } from '../common/index';
21
16
 
@@ -37,7 +32,7 @@ export class FileServiceModule extends NodeModule {
37
32
 
38
33
  `packages/file-tree/src/browser/index.ts`
39
34
 
40
- ```javascript
35
+ ```ts
41
36
  import { servicePath as FileServicePath } from '@opensumi/ide-file-service';
42
37
 
43
38
  @Injectable()
@@ -55,12 +50,11 @@ export class FileTreeModule extends BrowserModule {
55
50
 
56
51
  `packages/file-tree/src/browser/file-tree.service.ts`
57
52
 
58
- ```javascript
59
- import {servicePath as FileServicePath} from '@opensumi/ide-file-service';
53
+ ```ts
54
+ import { servicePath as FileServicePath } from '@opensumi/ide-file-service';
60
55
 
61
56
  @Injectable()
62
57
  export default class FileTreeService extends Disposable {
63
-
64
58
  @observable.shallow
65
59
  files: CloudFile[] = [];
66
60
 
@@ -75,8 +69,8 @@ export default class FileTreeService extends Disposable {
75
69
 
76
70
  this.getFiles();
77
71
  }
78
- createFile = async () => {
79
- const {content} = await this.fileService.resolveContent('{file_path}');
72
+ createFile = async () => {
73
+ const { content } = await this.fileService.resolveContent('{file_path}');
80
74
  const file = await this.fileAPI.createFile({
81
75
  name: 'name' + Date.now() + '\n' + content,
82
76
  path: 'path' + Date.now(),
@@ -90,13 +84,13 @@ export default class FileTreeService extends Disposable {
90
84
  } else {
91
85
  this.files = [file];
92
86
  }
93
- }
87
+ };
94
88
  }
95
89
  ```
96
90
 
97
91
  在 file-tree.service.ts 中通过 `servicePath` 进行注入,并直接调用在服务类上的方法
98
92
 
99
- ```javascript
93
+ ```ts
100
94
  constructor(@Inject(FileServicePath) protected readonly fileService) {
101
95
  super();
102
96
 
@@ -106,97 +100,34 @@ constructor(@Inject(FileServicePath) protected readonly fileService) {
106
100
 
107
101
  方法调用会转换成一个远程调用进行响应,返回结果
108
102
 
109
- ```javascript
103
+ ```ts
110
104
  const { content } = await this.fileService.resolveContent('{file_path}');
111
105
  ```
112
106
 
113
- **前端服务(frontService)** 后端服务(backService) 即在 Browser 环境下运行的代码暴露的能力
114
-
115
- 1. 注册服务
107
+ ### 后端服务: remoteService
116
108
 
117
- `packages/file-ree/src/browser/index.ts`
109
+ remoteService 提供了一种更简单,显式的 API 声明,我们将上面的 fileService 使用 remoteService 重写一遍:
118
110
 
119
- ```javascript
120
- @Injectable()
121
- export class FileTreeModule extends BrowserModule {
122
- providers: Provider[] = [createFileTreeAPIProvider(FileTreeAPIImpl)];
123
- backServices = [
124
- {
125
- servicePath: FileServicePath,
126
- },
127
- ];
128
- frontServices = [
129
- {
130
- servicePath: FileTreeServicePath,
131
- token: FileTreeService,
132
- },
133
- ];
134
- }
135
- ```
136
-
137
- 与后端服务注册类似,例如在 file-tree 模块中声明 `frontServices` 字段,传入对应的服务地址 `servicePath` 和对应服务的注入 `token`
138
-
139
- 2. 服务使用
111
+ 1. 注册服务
140
112
 
141
113
  `packages/file-service/src/node/index.ts`
142
114
 
143
- ```javascript
144
- import { servicePath as FileTreeServicePath } from '@opensumi/ide-file-tree';
115
+ ```ts
116
+ import { FileSystemNodeOptions, FileService } from './file-service';
145
117
 
146
- @Injectable()
147
118
  export class FileServiceModule extends NodeModule {
148
119
  providers = [{ token: 'FileServiceOptions', useValue: FileSystemNodeOptions.DEFAULT }];
149
-
150
- backServices = [
151
- {
152
- servicePath,
153
- token: FileService,
154
- },
155
- ];
156
- frontServices = [
157
- {
158
- servicePath: FileTreeServicePath,
159
- },
160
- ];
120
+ remoteServices = [FileService];
161
121
  }
162
122
  ```
163
123
 
164
- 与使用后端服务一致,在模块定义中声明需要使用的前端服务 `frontServices`,传入前端服务注册时用的 `servicePath` 一致
165
-
166
124
  `packages/file-service/src/node/file-service.ts`
167
125
 
168
- ```javascript
169
- @Injectable()
170
- export class FileService implements IFileService {
171
-
172
- constructor(
173
- @Inject('FileServiceOptions') protected readonly options: FileSystemNodeOptions,
174
- @Inject(FileTreeServicePath) protected readonly fileTreeService
175
- ) { }
176
-
177
- async resolveContent(uri: string, options?: { encoding?: string }): Promise<{ stat: FileStat, content: string }> {
178
- const fileTree = await this.fileTreeService
179
- fileTree.fileName(uri.substr(-5))
180
-
181
- ...
182
- return { stat, content };
183
- }
184
- ```
185
-
186
- 与使用后端服务使用方式一致,在 file-service.ts 中通过 `servicePath` 进行注入,通过调用注入服务的对应方法
187
-
188
- ```javascript
189
- constructor(
190
- @Inject('FileServiceOptions') protected readonly options: FileSystemNodeOptions,
191
- @Inject(FileTreeServicePath) protected readonly fileTreeService
192
- ) { }
193
- ```
194
-
195
- 方法调用会转换成一个远程调用进行响应,返回结果
126
+ ```ts
127
+ import { servicePath } from '../common/index';
196
128
 
197
- ```javascript
198
- const fileTree = await this.fileTreeService;
199
- fileTree.fileName(uri.substr(-5));
129
+ export class FileService extends RemoteService {
130
+ servicePath = servicePath;
131
+ // write your own logic here
132
+ }
200
133
  ```
201
-
202
- 与后端服务调用区别的是,目前因前端代码后置执行,所以首先需要获取服务 `await this.fileTreeService` 后进行调用
@@ -3,8 +3,6 @@ export * from './center';
3
3
  export * from './registry';
4
4
  export declare abstract class RPCService<T = any> {
5
5
  rpcClient?: T[];
6
- rpcRegistered?: boolean;
7
- register?(): () => Promise<T>;
8
6
  get client(): T | undefined;
9
7
  }
10
8
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/rpc-service/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,8BAAsB,UAAU,CAAC,CAAC,GAAG,GAAG;IACtC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;IAChB,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB,QAAQ,CAAC,IAAI,MAAM,OAAO,CAAC,CAAC,CAAC;IAC7B,IAAI,MAAM,IAAI,CAAC,GAAG,SAAS,CAE1B;CACF"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/common/rpc-service/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,UAAU,CAAC;AACzB,cAAc,YAAY,CAAC;AAE3B,8BAAsB,UAAU,CAAC,CAAC,GAAG,GAAG;IACtC,SAAS,CAAC,EAAE,CAAC,EAAE,CAAC;IAChB,IAAI,MAAM,IAAI,CAAC,GAAG,SAAS,CAE1B;CACF"}
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/rpc-service/index.ts"],"names":[],"mappings":";;;;AAAA,iDAAuB;AACvB,mDAAyB;AACzB,qDAA2B;AAE3B,MAAsB,UAAU;IAI9B,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxD,CAAC;CACF;AAPD,gCAOC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/common/rpc-service/index.ts"],"names":[],"mappings":";;;;AAAA,iDAAuB;AACvB,mDAAyB;AACzB,qDAA2B;AAE3B,MAAsB,UAAU;IAE9B,IAAI,MAAM;QACR,OAAO,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;IACxD,CAAC;CACF;AALD,gCAKC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opensumi/ide-connection",
3
- "version": "3.3.4-next-1727343192.0",
3
+ "version": "3.4.0",
4
4
  "files": [
5
5
  "lib",
6
6
  "src"
@@ -19,17 +19,17 @@
19
19
  "dependencies": {
20
20
  "@furyjs/fury": "0.5.9-beta",
21
21
  "@opensumi/events": "^1.0.0",
22
- "@opensumi/ide-core-common": "3.3.4-next-1727343192.0",
23
- "@opensumi/ide-utils": "3.3.4-next-1727343192.0",
22
+ "@opensumi/ide-core-common": "3.4.0",
23
+ "@opensumi/ide-utils": "3.4.0",
24
24
  "@opensumi/reconnecting-websocket": "^4.4.0",
25
25
  "@opensumi/vscode-jsonrpc": "^8.0.0-next.2",
26
26
  "path-to-regexp": "^6.2.1",
27
27
  "ws": "^8.16.0"
28
28
  },
29
29
  "devDependencies": {
30
- "@opensumi/ide-components": "3.3.4-next-1727343192.0",
31
- "@opensumi/ide-dev-tool": "3.3.4-next-1727343192.0",
30
+ "@opensumi/ide-components": "3.4.0",
31
+ "@opensumi/ide-dev-tool": "3.4.0",
32
32
  "@opensumi/mock-socket": "^9.3.1"
33
33
  },
34
- "gitHead": "04d38de8ac21b1791a0c518c4edb59e21059b665"
34
+ "gitHead": "1596a2b1b547d2b99c880afe14f91f16f76bb9d5"
35
35
  }
@@ -4,8 +4,6 @@ export * from './registry';
4
4
 
5
5
  export abstract class RPCService<T = any> {
6
6
  rpcClient?: T[];
7
- rpcRegistered?: boolean;
8
- register?(): () => Promise<T>;
9
7
  get client(): T | undefined {
10
8
  return this.rpcClient ? this.rpcClient[0] : undefined;
11
9
  }