Skip to content

Commit

Permalink
fix: 移除 connection 模块中对 browser/connect 的定义
Browse files Browse the repository at this point in the history
  • Loading branch information
erha19 committed Apr 15, 2022
1 parent 8db02ca commit d4b5a5c
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 26 deletions.
17 changes: 0 additions & 17 deletions packages/connection/src/browser/connect.ts

This file was deleted.

1 change: 0 additions & 1 deletion packages/connection/src/browser/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
export * from './ws-channel-handler';
export * from './connect';
6 changes: 6 additions & 0 deletions packages/connection/src/common/message.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,12 @@ import {
import { Disposable } from '@opensumi/vscode-jsonrpc/lib/common/disposable';
import { MessageReader, DataCallback } from '@opensumi/vscode-jsonrpc/lib/common/messageReader';
import { MessageWriter } from '@opensumi/vscode-jsonrpc/lib/common/messageWriter';
/**
* 由于 `createMessageConnection` 方法隐式依赖了 `@opensumi/vscode-jsonrpc/lib/browser/main` 或 `@opensumi/vscode-jsonrpc/lib/node/main`
* 的初始化 `RIL.install()` 初始化代码,而 `browser/main` 中仅支持浏览器使用
* 故需要保证提前引入或执行一次 `@opensumi/vscode-jsonrpc/lib/node/main` 代码才能保证逻辑正常执行
*/
import '@opensumi/vscode-jsonrpc/lib/node/main';

export class WebSocketMessageReader extends AbstractMessageReader implements MessageReader {
protected state: 'initial' | 'listening' | 'closed' = 'initial';
Expand Down
9 changes: 1 addition & 8 deletions packages/core-browser/src/bootstrap/connection.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Injector, Provider } from '@opensumi/di';
import { RPCServiceCenter, initRPCService, RPCMessageConnection } from '@opensumi/ide-connection';
import { createSocketConnection, WSChannelHandler } from '@opensumi/ide-connection/lib/browser';
import { WSChannelHandler } from '@opensumi/ide-connection/lib/browser';
import { createWebSocketConnection } from '@opensumi/ide-connection/lib/common/message';
import {
getDebugLogger,
Expand Down Expand Up @@ -63,13 +63,6 @@ export async function createClientConnection2(
bindConnectionService(injector, modules, createWebSocketConnection(channel));
}

/**
* electron 环境下不要调用这个函数,该函数的 createSocketConnection 是 browser 环境下的
*/
export async function createNetClientConnection(injector: Injector, modules: ModuleConstructor[], connection: any) {
bindConnectionService(injector, modules, createSocketConnection(connection));
}

export async function bindConnectionService(
injector: Injector,
modules: ModuleConstructor[],
Expand Down

0 comments on commit d4b5a5c

Please sign in to comment.