Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make runtime abstraction layer tobe correctly #839

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 0 additions & 4 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
const { JSDOM } = require('jsdom');
// new TextDecoder('ascii') is not supported in node12
// use TextDecoder and TextEncoder from `text-encoding`
const { TextDecoder, TextEncoder } = require('text-encoding');

const jsdom = new JSDOM('<div id="main"></div>', {
// https://github.com/jsdom/jsdom#basic-options
// 禁用掉 resources: usable, 采用 jsdom 默认策略不加载 subresources
Expand Down
1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@
"simple-git": "^3.3.0",
"strip-html-comments": "^1.0.0",
"temp": "^0.9.4",
"text-encoding": "^0.7.0",
"ts-jest": "^27.0.3",
"uuid": "^8.3.2",
"write-pkg": "^4.0.0",
Expand Down
9 changes: 0 additions & 9 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';
/**
* FIXME: 由于 `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';
erha19 marked this conversation as resolved.
Show resolved Hide resolved

export class WebSocketMessageReader extends AbstractMessageReader implements MessageReader {
protected state: 'initial' | 'listening' | 'closed' = 'initial';
Expand Down
2 changes: 1 addition & 1 deletion packages/connection/src/common/proxy.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { MessageConnection } from '@opensumi/vscode-jsonrpc/lib/common/connection';
import type { MessageConnection } from '@opensumi/vscode-jsonrpc/lib/common/connection';

export abstract class RPCService<T = any> {
rpcClient?: T[];
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