@@ -929,11 +929,13 @@ index 0000000000000000000000000000000000000000..3c0703b7174ad792a4b42841e96ee937
929
929
+ };
930
930
diff --git a/src/vs/server/browser/extHostNodeProxy.ts b/src/vs/server/browser/extHostNodeProxy.ts
931
931
new file mode 100644
932
- index 0000000000000000000000000000000000000000..ed7c078077b0c375758529959b280e091436113a
932
+ index 0000000000000000000000000000000000000000..6c6b87a05610417d73635c5a151845000f216d28
933
933
--- /dev/null
934
934
+++ b/src/vs/server/browser/extHostNodeProxy.ts
935
- @@ -0,0 +1,46 @@
935
+ @@ -0,0 +1,52 @@
936
+ + import { VSBuffer } from 'vs/base/common/buffer';
936
937
+ import { Emitter } from 'vs/base/common/event';
938
+ + import { UriComponents } from 'vs/base/common/uri';
937
939
+ import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
938
940
+ import { ExtHostNodeProxyShape, MainContext, MainThreadNodeProxyShape } from 'vs/workbench/api/common/extHost.protocol';
939
941
+ import { IExtHostRpcService } from 'vs/workbench/api/common/extHostRpcService';
@@ -975,17 +977,24 @@ index 0000000000000000000000000000000000000000..ed7c078077b0c375758529959b280e09
975
977
+ public send(message: string): void {
976
978
+ this.proxy.$send(message);
977
979
+ }
980
+ +
981
+ + public async fetchExtension(extensionUri: UriComponents): Promise<Uint8Array> {
982
+ + return this.proxy.$fetchExtension(extensionUri).then(b => b.buffer);
983
+ + }
978
984
+ }
979
985
+
980
986
+ export interface IExtHostNodeProxy extends ExtHostNodeProxy { }
981
987
+ export const IExtHostNodeProxy = createDecorator<IExtHostNodeProxy>('IExtHostNodeProxy');
982
988
diff --git a/src/vs/server/browser/mainThreadNodeProxy.ts b/src/vs/server/browser/mainThreadNodeProxy.ts
983
989
new file mode 100644
984
- index 0000000000000000000000000000000000000000..0d2e93edae2baf34d27b7b52be0bf4960f244531
990
+ index 0000000000000000000000000000000000000000..21a139288e5b8f56016491879d69d01da929decb
985
991
--- /dev/null
986
992
+++ b/src/vs/server/browser/mainThreadNodeProxy.ts
987
- @@ -0,0 +1,37 @@
993
+ @@ -0,0 +1,55 @@
994
+ + import { VSBuffer } from 'vs/base/common/buffer';
988
995
+ import { IDisposable } from 'vs/base/common/lifecycle';
996
+ + import { FileAccess } from 'vs/base/common/network';
997
+ + import { URI, UriComponents } from 'vs/base/common/uri';
989
998
+ import { INodeProxyService } from 'vs/server/common/nodeProxy';
990
999
+ import { ExtHostContext, IExtHostContext, MainContext, MainThreadNodeProxyShape } from 'vs/workbench/api/common/extHost.protocol';
991
1000
+ import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
@@ -1016,6 +1025,21 @@ index 0000000000000000000000000000000000000000..0d2e93edae2baf34d27b7b52be0bf496
1016
1025
+ }
1017
1026
+ }
1018
1027
+
1028
+ + async $fetchExtension(extensionUri: UriComponents): Promise<VSBuffer> {
1029
+ + const fetchUri = URI.from({
1030
+ + scheme: window.location.protocol.replace(':', ''),
1031
+ + authority: window.location.host,
1032
+ + // Use FileAccess to get the static base path.
1033
+ + path: FileAccess.asBrowserUri("", require).path,
1034
+ + query: `tar=${encodeURIComponent(extensionUri.path)}`,
1035
+ + });
1036
+ + const response = await fetch(fetchUri.toString(true));
1037
+ + if (response.status !== 200) {
1038
+ + throw new Error(`Failed to download extension "${module}"`);
1039
+ + }
1040
+ + return VSBuffer.wrap(new Uint8Array(await response.arrayBuffer()));
1041
+ + }
1042
+ +
1019
1043
+ dispose(): void {
1020
1044
+ this.disposables.forEach((d) => d.dispose());
1021
1045
+ this.disposables = [];
@@ -1024,10 +1048,10 @@ index 0000000000000000000000000000000000000000..0d2e93edae2baf34d27b7b52be0bf496
1024
1048
+ }
1025
1049
diff --git a/src/vs/server/browser/worker.ts b/src/vs/server/browser/worker.ts
1026
1050
new file mode 100644
1027
- index 0000000000000000000000000000000000000000..5ae44cdc856bf81326a4c516b8be9afb2c746a67
1051
+ index 0000000000000000000000000000000000000000..1d47ede49b76b1774329269ab5c86fedb5712c19
1028
1052
--- /dev/null
1029
1053
+++ b/src/vs/server/browser/worker.ts
1030
- @@ -0,0 +1,56 @@
1054
+ @@ -0,0 +1,48 @@
1031
1055
+ import { Client } from '@coder/node-browser';
1032
1056
+ import { fromTar } from '@coder/requirefs';
1033
1057
+ import { URI } from 'vs/base/common/uri';
@@ -1042,19 +1066,11 @@ index 0000000000000000000000000000000000000000..5ae44cdc856bf81326a4c516b8be9afb
1042
1066
+ logService: ILogService,
1043
1067
+ vscode: any,
1044
1068
+ ): Promise<T> => {
1045
- + const fetchUri = URI.from({
1046
- + scheme: self.location.protocol.replace(':', ''),
1047
- + authority: self.location.host,
1048
- + path: self.location.pathname.replace(/\/static\/([^\/]+)\/.*$/, '/static/$1\/'),
1049
- + query: `tar=${encodeURIComponent(module.path)}`,
1050
- + });
1051
- + const response = await fetch(fetchUri.toString(true));
1052
- + if (response.status !== 200) {
1053
- + throw new Error(`Failed to download extension "${module}"`);
1054
- + }
1055
1069
+ const client = new Client(nodeProxy, { logger: logService });
1056
- + const init = await client.handshake();
1057
- + const buffer = new Uint8Array(await response.arrayBuffer());
1070
+ + const [buffer, init] = await Promise.all([
1071
+ + nodeProxy.fetchExtension(module),
1072
+ + client.handshake(),
1073
+ + ]);
1058
1074
+ const rfs = fromTar(buffer);
1059
1075
+ (<any>self).global = self;
1060
1076
+ rfs.provide('vscode', vscode);
@@ -2895,15 +2911,16 @@ index 2a0576b68f943f63c010dd496e094311bdc149f0..357c63f0fec08ddfb06b3579460fe156
2895
2911
rpcProtocol.set(ExtHostContext.ExtHostWindow, extHostWindow);
2896
2912
2897
2913
diff --git a/src/vs/workbench/api/common/extHost.protocol.ts b/src/vs/workbench/api/common/extHost.protocol.ts
2898
- index 3728f5602dffd0fd4b0cf326c5fa7d6d7c49c53e..233fbbce328094d014a375b1e9c11231ac9fafd9 100644
2914
+ index 3728f5602dffd0fd4b0cf326c5fa7d6d7c49c53e..2521acff0e692e97b72deef758ce41b4cd54a724 100644
2899
2915
--- a/src/vs/workbench/api/common/extHost.protocol.ts
2900
2916
+++ b/src/vs/workbench/api/common/extHost.protocol.ts
2901
- @@ -807,6 +807,16 @@ export interface MainThreadLabelServiceShape extends IDisposable {
2917
+ @@ -807,6 +807,17 @@ export interface MainThreadLabelServiceShape extends IDisposable {
2902
2918
$unregisterResourceLabelFormatter(handle: number): void;
2903
2919
}
2904
2920
2905
2921
+ export interface MainThreadNodeProxyShape extends IDisposable {
2906
2922
+ $send(message: string): void;
2923
+ + $fetchExtension(extensionUri: UriComponents): Promise<VSBuffer>;
2907
2924
+ }
2908
2925
+ export interface ExtHostNodeProxyShape {
2909
2926
+ $onMessage(message: string): void;
@@ -2915,15 +2932,15 @@ index 3728f5602dffd0fd4b0cf326c5fa7d6d7c49c53e..233fbbce328094d014a375b1e9c11231
2915
2932
export interface MainThreadSearchShape extends IDisposable {
2916
2933
$registerFileSearchProvider(handle: number, scheme: string): void;
2917
2934
$registerTextSearchProvider(handle: number, scheme: string): void;
2918
- @@ -1784,6 +1794 ,7 @@ export const MainContext = {
2935
+ @@ -1784,6 +1795 ,7 @@ export const MainContext = {
2919
2936
MainThreadWindow: createMainId<MainThreadWindowShape>('MainThreadWindow'),
2920
2937
MainThreadLabelService: createMainId<MainThreadLabelServiceShape>('MainThreadLabelService'),
2921
2938
MainThreadNotebook: createMainId<MainThreadNotebookShape>('MainThreadNotebook'),
2922
2939
+ MainThreadNodeProxy: createMainId<MainThreadNodeProxyShape>('MainThreadNodeProxy'),
2923
2940
MainThreadTheming: createMainId<MainThreadThemingShape>('MainThreadTheming'),
2924
2941
MainThreadTunnelService: createMainId<MainThreadTunnelServiceShape>('MainThreadTunnelService'),
2925
2942
MainThreadTimeline: createMainId<MainThreadTimelineShape>('MainThreadTimeline')
2926
- @@ -1826,6 +1837 ,7 @@ export const ExtHostContext = {
2943
+ @@ -1826,6 +1838 ,7 @@ export const ExtHostContext = {
2927
2944
ExtHostOutputService: createMainId<ExtHostOutputServiceShape>('ExtHostOutputService'),
2928
2945
ExtHosLabelService: createMainId<ExtHostLabelServiceShape>('ExtHostLabelService'),
2929
2946
ExtHostNotebook: createMainId<ExtHostNotebookShape>('ExtHostNotebook'),
0 commit comments