提交 2cc98f3a 编写于 作者: A Alex Dima

Load uri transformer via common js

上级 adee318d
......@@ -5,6 +5,4 @@
import { startExtensionHostProcess } from 'vs/workbench/services/extensions/node/extensionHostProcessSetup';
startExtensionHostProcess(
_ => null
).catch((err) => console.log(err));
startExtensionHostProcess().catch((err) => console.log(err));
......@@ -5,6 +5,7 @@
import * as nativeWatchdog from 'native-watchdog';
import * as net from 'net';
import * as minimist from 'minimist';
import { onUnexpectedError } from 'vs/base/common/errors';
import { Event } from 'vs/base/common/event';
import { IMessagePassingProtocol } from 'vs/base/parts/ipc/common/ipc';
......@@ -17,11 +18,21 @@ import { ExtensionHostMain, IExitFn, ILogServiceFn } from 'vs/workbench/services
import { VSBuffer } from 'vs/base/common/buffer';
import { createBufferSpdLogService } from 'vs/platform/log/node/spdlogService';
import { ExtensionHostLogFileName } from 'vs/workbench/services/extensions/common/extensions';
import { IURITransformer } from 'vs/base/common/uriIpc';
import { IURITransformer, URITransformer, IRawURITransformer } from 'vs/base/common/uriIpc';
import { exists } from 'vs/base/node/pfs';
import { realpath } from 'vs/base/node/extpath';
import { IHostUtils } from 'vs/workbench/api/node/extHostExtensionService';
interface ParsedExtHostArgs {
uriTransformerPath?: string;
}
const args = minimist(process.argv.slice(2), {
string: [
'uriTransformerPath'
]
}) as ParsedExtHostArgs;
// With Electron 2.x and node.js 8.x the "natives" module
// can cause a native crash (see https://github.com/nodejs/node/issues/19891 and
// https://github.com/electron/electron/issues/10905). To prevent this from
......@@ -271,9 +282,7 @@ function connectToRenderer(protocol: IMessagePassingProtocol): Promise<IRenderer
}
})();
export async function startExtensionHostProcess(
uriTransformerFn: (initData: IInitData) => IURITransformer | null
): Promise<void> {
export async function startExtensionHostProcess(): Promise<void> {
const protocol = await createExtHostProtocol();
const renderer = await connectToRenderer(protocol);
......@@ -288,6 +297,17 @@ export async function startExtensionHostProcess(
realpath(path: string) { return realpath(path); }
};
// Attempt to load uri transformer
let uriTransformer: IURITransformer | null = null;
if (initData.remoteAuthority && args.uriTransformerPath) {
try {
const rawURITransformerFactory = <any>require.__$__nodeRequire(args.uriTransformerPath);
const rawURITransformer = <IRawURITransformer>rawURITransformerFactory(initData.remoteAuthority);
uriTransformer = new URITransformer(rawURITransformer);
} catch (e) {
console.error(e);
}
}
const extensionHostMain = new ExtensionHostMain(
renderer.protocol,
......@@ -295,7 +315,7 @@ export async function startExtensionHostProcess(
hostUtils,
patchPatchedConsole,
createLogService,
uriTransformerFn(initData)
uriTransformer
);
// rewrite onTerminate-function to be a proper shutdown
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册