@lvce-editor/file-system-worker 4.2.0 → 5.1.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.
@@ -1,3 +1,170 @@
1
+ // TODO: including these in blob-util.ts causes typedoc to generate docs for them,
2
+ // even with --excludePrivate ¯\_(ツ)_/¯
3
+ /** @private */
4
+
5
+ /* global Promise, Image, Blob, FileReader, atob, btoa,
6
+ BlobBuilder, MSBlobBuilder, MozBlobBuilder, WebKitBlobBuilder, webkitURL */
7
+ /**
8
+ * Shim for
9
+ * [`new Blob()`](https://developer.mozilla.org/en-US/docs/Web/API/Blob.Blob)
10
+ * to support
11
+ * [older browsers that use the deprecated `BlobBuilder` API](http://caniuse.com/blob).
12
+ *
13
+ * Example:
14
+ *
15
+ * ```js
16
+ * var myBlob = blobUtil.createBlob(['hello world'], {type: 'text/plain'});
17
+ * ```
18
+ *
19
+ * @param parts - content of the Blob
20
+ * @param properties - usually `{type: myContentType}`,
21
+ * you can also pass a string for the content type
22
+ * @returns Blob
23
+ */
24
+ function createBlob(parts, properties) {
25
+ parts = parts || [];
26
+ properties = properties || {};
27
+ if (typeof properties === 'string') {
28
+ properties = {
29
+ type: properties
30
+ }; // infer content type
31
+ }
32
+ try {
33
+ return new Blob(parts, properties);
34
+ } catch (e) {
35
+ if (e.name !== 'TypeError') {
36
+ throw e;
37
+ }
38
+ var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : WebKitBlobBuilder;
39
+ var builder = new Builder();
40
+ for (var i = 0; i < parts.length; i += 1) {
41
+ builder.append(parts[i]);
42
+ }
43
+ return builder.getBlob(properties.type);
44
+ }
45
+ }
46
+ /**
47
+ * Convert a `Blob` to a binary string.
48
+ *
49
+ * Example:
50
+ *
51
+ * ```js
52
+ * blobUtil.blobToBinaryString(blob).then(function (binaryString) {
53
+ * // success
54
+ * }).catch(function (err) {
55
+ * // error
56
+ * });
57
+ * ```
58
+ *
59
+ * @param blob
60
+ * @returns Promise that resolves with the binary string
61
+ */
62
+ function blobToBinaryString$1(blob) {
63
+ return new Promise(function (resolve, reject) {
64
+ var reader = new FileReader();
65
+ var hasBinaryString = typeof reader.readAsBinaryString === 'function';
66
+ reader.onloadend = function () {
67
+ var result = reader.result || '';
68
+ if (hasBinaryString) {
69
+ return resolve(result);
70
+ }
71
+ resolve(arrayBufferToBinaryString(result));
72
+ };
73
+ reader.onerror = reject;
74
+ if (hasBinaryString) {
75
+ reader.readAsBinaryString(blob);
76
+ } else {
77
+ reader.readAsArrayBuffer(blob);
78
+ }
79
+ });
80
+ }
81
+ /**
82
+ * Convert a base64-encoded string to a `Blob`.
83
+ *
84
+ * Example:
85
+ *
86
+ * ```js
87
+ * var blob = blobUtil.base64StringToBlob(base64String);
88
+ * ```
89
+ * @param base64 - base64-encoded string
90
+ * @param type - the content type (optional)
91
+ * @returns Blob
92
+ */
93
+ function base64StringToBlob(base64, type) {
94
+ var parts = [binaryStringToArrayBuffer(atob(base64))];
95
+ return type ? createBlob(parts, {
96
+ type: type
97
+ }) : createBlob(parts);
98
+ }
99
+ /**
100
+ * Convert a binary string to a `Blob`.
101
+ *
102
+ * Example:
103
+ *
104
+ * ```js
105
+ * var blob = blobUtil.binaryStringToBlob(binaryString);
106
+ * ```
107
+ *
108
+ * @param binary - binary string
109
+ * @param type - the content type (optional)
110
+ * @returns Blob
111
+ */
112
+ function binaryStringToBlob$1(binary, type) {
113
+ return base64StringToBlob(btoa(binary), type);
114
+ }
115
+ /**
116
+ * Convert an `ArrayBuffer` to a binary string.
117
+ *
118
+ * Example:
119
+ *
120
+ * ```js
121
+ * var myString = blobUtil.arrayBufferToBinaryString(arrayBuff)
122
+ * ```
123
+ *
124
+ * @param buffer - array buffer
125
+ * @returns binary string
126
+ */
127
+ function arrayBufferToBinaryString(buffer) {
128
+ var binary = '';
129
+ var bytes = new Uint8Array(buffer);
130
+ var length = bytes.byteLength;
131
+ var i = -1;
132
+ while (++i < length) {
133
+ binary += String.fromCharCode(bytes[i]);
134
+ }
135
+ return binary;
136
+ }
137
+ /**
138
+ * Convert a binary string to an `ArrayBuffer`.
139
+ *
140
+ * ```js
141
+ * var myBuffer = blobUtil.binaryStringToArrayBuffer(binaryString)
142
+ * ```
143
+ *
144
+ * @param binary - binary string
145
+ * @returns array buffer
146
+ */
147
+ function binaryStringToArrayBuffer(binary) {
148
+ var length = binary.length;
149
+ var buf = new ArrayBuffer(length);
150
+ var arr = new Uint8Array(buf);
151
+ var i = -1;
152
+ while (++i < length) {
153
+ arr[i] = binary.charCodeAt(i);
154
+ }
155
+ return buf;
156
+ }
157
+
158
+ const normalizeBlobError = error => {
159
+ if (error && error instanceof ProgressEvent && error.target &&
160
+ // @ts-expect-error - target.error may not be in the type definition
161
+ error.target.error) {
162
+ // @ts-expect-error - target.error may not be in the type definition
163
+ return error.target.error;
164
+ }
165
+ return error;
166
+ };
167
+
1
168
  const normalizeLine = line => {
2
169
  if (line.startsWith('Error: ')) {
3
170
  return line.slice('Error: '.length);
@@ -54,6 +221,94 @@ class VError extends Error {
54
221
  }
55
222
  }
56
223
 
224
+ const binaryStringToBlob = async (string, type) => {
225
+ try {
226
+ return binaryStringToBlob$1(string, type);
227
+ } catch (error) {
228
+ const normalizedError = normalizeBlobError(error);
229
+ throw new VError(normalizedError, 'Failed to convert binary string to blob');
230
+ }
231
+ };
232
+ const blobToBinaryString = async blob => {
233
+ try {
234
+ return await blobToBinaryString$1(blob);
235
+ } catch (error) {
236
+ const normalizedError = normalizeBlobError(error);
237
+ throw new VError(normalizedError, 'Failed to convert blob to binary string');
238
+ }
239
+ };
240
+
241
+ const readFile$4 = async uri => {
242
+ const response = await fetch(uri);
243
+ if (!response.ok) {
244
+ throw new Error(response.statusText);
245
+ }
246
+ const result = await response.text();
247
+ return result;
248
+ };
249
+ const readFileAsBlob$1 = async uri => {
250
+ const response = await fetch(uri);
251
+ if (!response.ok) {
252
+ throw new Error(response.statusText);
253
+ }
254
+ const result = await response.blob();
255
+ return result;
256
+ };
257
+ const exists$3 = async uri => {
258
+ const response = await fetch(uri);
259
+ if (response.ok) {
260
+ return true;
261
+ }
262
+ return false;
263
+ };
264
+ const readJson$4 = async uri => {
265
+ const response = await fetch(uri);
266
+ if (!response.ok) {
267
+ throw new Error(`${response.statusText}`);
268
+ }
269
+ const json = await response.json();
270
+ return json;
271
+ };
272
+
273
+ const DebugWorker = 55;
274
+ const ExtensionHostWorker = 44;
275
+ const FileSystemProcess$1 = 210;
276
+ const FileSystemWorker = 209;
277
+ const RendererProcess = 1670;
278
+ const RendererWorker = 1;
279
+
280
+ const rpcs = Object.create(null);
281
+ const set$5 = (id, rpc) => {
282
+ rpcs[id] = rpc;
283
+ };
284
+ const get$1 = id => {
285
+ return rpcs[id];
286
+ };
287
+
288
+ const create$6 = rpcId => {
289
+ return {
290
+ async dispose() {
291
+ const rpc = get$1(rpcId);
292
+ await rpc.dispose();
293
+ },
294
+ // @ts-ignore
295
+ invoke(method, ...params) {
296
+ const rpc = get$1(rpcId);
297
+ // @ts-ignore
298
+ return rpc.invoke(method, ...params);
299
+ },
300
+ // @ts-ignore
301
+ invokeAndTransfer(method, ...params) {
302
+ const rpc = get$1(rpcId);
303
+ // @ts-ignore
304
+ return rpc.invokeAndTransfer(method, ...params);
305
+ },
306
+ set(rpc) {
307
+ set$5(rpcId, rpc);
308
+ }
309
+ };
310
+ };
311
+
57
312
  class AssertionError extends Error {
58
313
  constructor(message) {
59
314
  super(message);
@@ -225,8 +480,8 @@ const getModuleNotFoundError = stderr => {
225
480
  const messageIndex = lines.findIndex(isModuleNotFoundMessage);
226
481
  const message = lines[messageIndex];
227
482
  return {
228
- message,
229
- code: ERR_MODULE_NOT_FOUND
483
+ code: ERR_MODULE_NOT_FOUND,
484
+ message
230
485
  };
231
486
  };
232
487
  const isModuleNotFoundError = stderr => {
@@ -249,14 +504,14 @@ const isUnhelpfulNativeModuleError = stderr => {
249
504
  const getNativeModuleErrorMessage = stderr => {
250
505
  const message = getMessageCodeBlock(stderr);
251
506
  return {
252
- message: `Incompatible native node module: ${message}`,
253
- code: E_INCOMPATIBLE_NATIVE_MODULE
507
+ code: E_INCOMPATIBLE_NATIVE_MODULE,
508
+ message: `Incompatible native node module: ${message}`
254
509
  };
255
510
  };
256
511
  const getModuleSyntaxError = () => {
257
512
  return {
258
- message: `ES Modules are not supported in electron`,
259
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
513
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON,
514
+ message: `ES Modules are not supported in electron`
260
515
  };
261
516
  };
262
517
  const getHelpfulChildProcessError = (stdout, stderr) => {
@@ -275,8 +530,8 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
275
530
  rest
276
531
  } = getDetails(lines);
277
532
  return {
278
- message: actualMessage,
279
533
  code: '',
534
+ message: actualMessage,
280
535
  stack: rest
281
536
  };
282
537
  };
@@ -286,8 +541,8 @@ class IpcError extends VError {
286
541
  if (stdout || stderr) {
287
542
  // @ts-ignore
288
543
  const {
289
- message,
290
544
  code,
545
+ message,
291
546
  stack
292
547
  } = getHelpfulChildProcessError(stdout, stderr);
293
548
  const cause = new Error(message);
@@ -348,8 +603,8 @@ const wrap$f = global => {
348
603
  };
349
604
  const waitForFirstMessage = async port => {
350
605
  const {
351
- resolve,
352
- promise
606
+ promise,
607
+ resolve
353
608
  } = Promise.withResolvers();
354
609
  port.addEventListener('message', resolve, {
355
610
  once: true
@@ -369,8 +624,8 @@ const listen$6 = async () => {
369
624
  const type = firstMessage.params[0];
370
625
  if (type === 'message-port') {
371
626
  parentIpc.send({
372
- jsonrpc: '2.0',
373
627
  id: firstMessage.id,
628
+ jsonrpc: '2.0',
374
629
  result: null
375
630
  });
376
631
  parentIpc.dispose();
@@ -430,8 +685,8 @@ const removeListener = (emitter, type, callback) => {
430
685
  };
431
686
  const getFirstEvent = (eventEmitter, eventMap) => {
432
687
  const {
433
- resolve,
434
- promise
688
+ promise,
689
+ resolve
435
690
  } = Promise.withResolvers();
436
691
  const listenerMap = Object.create(null);
437
692
  const cleanup = value => {
@@ -443,8 +698,8 @@ const getFirstEvent = (eventEmitter, eventMap) => {
443
698
  for (const [event, type] of Object.entries(eventMap)) {
444
699
  const listener = event => {
445
700
  cleanup({
446
- type,
447
- event
701
+ event,
702
+ type
448
703
  });
449
704
  };
450
705
  addListener(eventEmitter, event, listener);
@@ -453,9 +708,9 @@ const getFirstEvent = (eventEmitter, eventMap) => {
453
708
  return promise;
454
709
  };
455
710
  const Message$1 = 3;
456
- const create$5$1 = async ({
457
- messagePort,
458
- isMessagePortOpen
711
+ const create$5 = async ({
712
+ isMessagePortOpen,
713
+ messagePort
459
714
  }) => {
460
715
  if (!isMessagePort(messagePort)) {
461
716
  throw new IpcError('port must be of type MessagePort');
@@ -468,8 +723,8 @@ const create$5$1 = async ({
468
723
  });
469
724
  messagePort.start();
470
725
  const {
471
- type,
472
- event
726
+ event,
727
+ type
473
728
  } = await eventPromise;
474
729
  if (type !== Message$1) {
475
730
  throw new IpcError('Failed to wait for ipc message');
@@ -504,7 +759,7 @@ const wrap$5 = messagePort => {
504
759
  };
505
760
  const IpcParentWithMessagePort$1 = {
506
761
  __proto__: null,
507
- create: create$5$1,
762
+ create: create$5,
508
763
  signal: signal$1,
509
764
  wrap: wrap$5
510
765
  };
@@ -523,12 +778,12 @@ const parse = content => {
523
778
  };
524
779
  const waitForWebSocketToBeOpen = webSocket => {
525
780
  return getFirstEvent(webSocket, {
526
- open: Open,
527
781
  close: Close,
528
- error: Error$3
782
+ error: Error$3,
783
+ open: Open
529
784
  });
530
785
  };
531
- const create$7 = async ({
786
+ const create$3 = async ({
532
787
  webSocket
533
788
  }) => {
534
789
  const firstWebSocketEvent = await waitForWebSocketToBeOpen(webSocket);
@@ -565,60 +820,18 @@ const wrap = webSocket => {
565
820
  };
566
821
  const IpcParentWithWebSocket$1 = {
567
822
  __proto__: null,
568
- create: create$7,
823
+ create: create$3,
569
824
  wrap
570
825
  };
571
826
 
572
- const Two = '2.0';
573
- const create$4$1 = (method, params) => {
574
- return {
575
- jsonrpc: Two,
576
- method,
577
- params
578
- };
579
- };
827
+ const Two$1 = '2.0';
580
828
  const callbacks = Object.create(null);
581
- const set$4 = (id, fn) => {
582
- callbacks[id] = fn;
583
- };
584
- const get$1 = id => {
829
+ const get = id => {
585
830
  return callbacks[id];
586
831
  };
587
832
  const remove$4 = id => {
588
833
  delete callbacks[id];
589
834
  };
590
- let id = 0;
591
- const create$3$1 = () => {
592
- return ++id;
593
- };
594
- const registerPromise = () => {
595
- const id = create$3$1();
596
- const {
597
- resolve,
598
- promise
599
- } = Promise.withResolvers();
600
- set$4(id, resolve);
601
- return {
602
- id,
603
- promise
604
- };
605
- };
606
- const create$2$1 = (method, params) => {
607
- const {
608
- id,
609
- promise
610
- } = registerPromise();
611
- const message = {
612
- jsonrpc: Two,
613
- method,
614
- params,
615
- id
616
- };
617
- return {
618
- message,
619
- promise
620
- };
621
- };
622
835
  class JsonRpcError extends Error {
623
836
  constructor(message) {
624
837
  super(message);
@@ -762,7 +975,7 @@ const warn = (...args) => {
762
975
  console.warn(...args);
763
976
  };
764
977
  const resolve = (id, response) => {
765
- const fn = get$1(id);
978
+ const fn = get(id);
766
979
  if (!fn) {
767
980
  console.log(response);
768
981
  warn(`callback ${id} may already be disposed`);
@@ -814,7 +1027,7 @@ const getErrorProperty = (error, prettyError) => {
814
1027
  };
815
1028
  const create$1$1 = (id, error) => {
816
1029
  return {
817
- jsonrpc: Two,
1030
+ jsonrpc: Two$1,
818
1031
  id,
819
1032
  error
820
1033
  };
@@ -825,20 +1038,20 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
825
1038
  const errorProperty = getErrorProperty(error, prettyError);
826
1039
  return create$1$1(id, errorProperty);
827
1040
  };
828
- const create$6 = (message, result) => {
1041
+ const create = (message, result) => {
829
1042
  return {
830
- jsonrpc: Two,
1043
+ jsonrpc: Two$1,
831
1044
  id: message.id,
832
1045
  result: result ?? null
833
1046
  };
834
1047
  };
835
1048
  const getSuccessResponse = (message, result) => {
836
1049
  const resultProperty = result ?? null;
837
- return create$6(message, resultProperty);
1050
+ return create(message, resultProperty);
838
1051
  };
839
1052
  const getErrorResponseSimple = (id, error) => {
840
1053
  return {
841
- jsonrpc: Two,
1054
+ jsonrpc: Two$1,
842
1055
  id,
843
1056
  error: {
844
1057
  code: Custom,
@@ -925,29 +1138,6 @@ const handleJsonRpcMessage = async (...args) => {
925
1138
  }
926
1139
  throw new JsonRpcError('unexpected message');
927
1140
  };
928
- const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
929
- const {
930
- message,
931
- promise
932
- } = create$2$1(method, params);
933
- if (useSendAndTransfer && ipc.sendAndTransfer) {
934
- ipc.sendAndTransfer(message);
935
- } else {
936
- ipc.send(message);
937
- }
938
- const responseMessage = await promise;
939
- return unwrapJsonRpcResult(responseMessage);
940
- };
941
- const send = (transport, method, ...params) => {
942
- const message = create$4$1(method, params);
943
- transport.send(message);
944
- };
945
- const invoke$4 = (ipc, method, ...params) => {
946
- return invokeHelper(ipc, method, params, false);
947
- };
948
- const invokeAndTransfer$2 = (ipc, method, ...params) => {
949
- return invokeHelper(ipc, method, params, true);
950
- };
951
1141
 
952
1142
  class CommandNotFoundError extends Error {
953
1143
  constructor(command) {
@@ -970,24 +1160,87 @@ const execute = (command, ...args) => {
970
1160
  return fn(...args);
971
1161
  };
972
1162
 
1163
+ const Two = '2.0';
1164
+ const create$s = (method, params) => {
1165
+ return {
1166
+ jsonrpc: Two,
1167
+ method,
1168
+ params
1169
+ };
1170
+ };
1171
+ const create$r = (id, method, params) => {
1172
+ const message = {
1173
+ id,
1174
+ jsonrpc: Two,
1175
+ method,
1176
+ params
1177
+ };
1178
+ return message;
1179
+ };
1180
+ let id = 0;
1181
+ const create$q = () => {
1182
+ return ++id;
1183
+ };
1184
+
1185
+ /* eslint-disable n/no-unsupported-features/es-syntax */
1186
+
1187
+ const registerPromise = map => {
1188
+ const id = create$q();
1189
+ const {
1190
+ promise,
1191
+ resolve
1192
+ } = Promise.withResolvers();
1193
+ map[id] = resolve;
1194
+ return {
1195
+ id,
1196
+ promise
1197
+ };
1198
+ };
1199
+
1200
+ // @ts-ignore
1201
+ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
1202
+ const {
1203
+ id,
1204
+ promise
1205
+ } = registerPromise(callbacks);
1206
+ const message = create$r(id, method, params);
1207
+ if (useSendAndTransfer && ipc.sendAndTransfer) {
1208
+ ipc.sendAndTransfer(message);
1209
+ } else {
1210
+ ipc.send(message);
1211
+ }
1212
+ const responseMessage = await promise;
1213
+ return unwrapJsonRpcResult(responseMessage);
1214
+ };
973
1215
  const createRpc = ipc => {
1216
+ const callbacks = Object.create(null);
1217
+ ipc._resolve = (id, response) => {
1218
+ const fn = callbacks[id];
1219
+ if (!fn) {
1220
+ console.warn(`callback ${id} may already be disposed`);
1221
+ return;
1222
+ }
1223
+ fn(response);
1224
+ delete callbacks[id];
1225
+ };
974
1226
  const rpc = {
1227
+ async dispose() {
1228
+ await ipc?.dispose();
1229
+ },
1230
+ invoke(method, ...params) {
1231
+ return invokeHelper(callbacks, ipc, method, params, false);
1232
+ },
1233
+ invokeAndTransfer(method, ...params) {
1234
+ return invokeHelper(callbacks, ipc, method, params, true);
1235
+ },
975
1236
  // @ts-ignore
976
1237
  ipc,
977
1238
  /**
978
1239
  * @deprecated
979
1240
  */
980
1241
  send(method, ...params) {
981
- send(ipc, method, ...params);
982
- },
983
- invoke(method, ...params) {
984
- return invoke$4(ipc, method, ...params);
985
- },
986
- invokeAndTransfer(method, ...params) {
987
- return invokeAndTransfer$2(ipc, method, ...params);
988
- },
989
- async dispose() {
990
- await ipc?.dispose();
1242
+ const message = create$s(method, params);
1243
+ ipc.send(message);
991
1244
  }
992
1245
  };
993
1246
  return rpc;
@@ -1004,7 +1257,7 @@ const logError = () => {
1004
1257
  const handleMessage = event => {
1005
1258
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
1006
1259
  const actualExecute = event?.target?.execute || execute;
1007
- return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
1260
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, event.target._resolve, preparePrettyError, logError, actualRequiresSocket);
1008
1261
  };
1009
1262
  const handleIpc = ipc => {
1010
1263
  if ('addEventListener' in ipc) {
@@ -1022,57 +1275,52 @@ const listen$1 = async (module, options) => {
1022
1275
  const ipc = module.wrap(rawIpc);
1023
1276
  return ipc;
1024
1277
  };
1025
- const create$5 = async ({
1026
- commandMap,
1027
- messagePort
1028
- }) => {
1029
- // TODO create a commandMap per rpc instance
1030
- register(commandMap);
1031
- const rawIpc = await IpcParentWithMessagePort$1.create({
1032
- messagePort,
1033
- isMessagePortOpen: true
1034
- });
1035
- const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1036
- handleIpc(ipc);
1037
- const rpc = createRpc(ipc);
1038
- messagePort.start();
1039
- return rpc;
1040
- };
1041
- const PlainMessagePortRpc = {
1042
- __proto__: null,
1043
- create: create$5
1278
+
1279
+ /* eslint-disable @typescript-eslint/no-misused-promises */
1280
+
1281
+ const createSharedLazyRpc = factory => {
1282
+ let rpcPromise;
1283
+ const getOrCreate = () => {
1284
+ if (!rpcPromise) {
1285
+ rpcPromise = factory();
1286
+ }
1287
+ return rpcPromise;
1288
+ };
1289
+ return {
1290
+ async dispose() {
1291
+ const rpc = await getOrCreate();
1292
+ await rpc.dispose();
1293
+ },
1294
+ async invoke(method, ...params) {
1295
+ const rpc = await getOrCreate();
1296
+ return rpc.invoke(method, ...params);
1297
+ },
1298
+ async invokeAndTransfer(method, ...params) {
1299
+ const rpc = await getOrCreate();
1300
+ return rpc.invokeAndTransfer(method, ...params);
1301
+ },
1302
+ async send(method, ...params) {
1303
+ const rpc = await getOrCreate();
1304
+ rpc.send(method, ...params);
1305
+ }
1306
+ };
1044
1307
  };
1045
- const create$3 = async ({
1308
+ const create$i = async ({
1046
1309
  commandMap,
1310
+ isMessagePortOpen,
1047
1311
  send
1048
1312
  }) => {
1049
- const {
1050
- port1,
1051
- port2
1052
- } = new MessageChannel();
1053
- await send(port1);
1054
- return create$5({
1055
- commandMap,
1056
- messagePort: port2
1313
+ return createSharedLazyRpc(() => {
1314
+ return create$2({
1315
+ commandMap,
1316
+ isMessagePortOpen,
1317
+ send
1318
+ });
1057
1319
  });
1058
1320
  };
1059
- const TransferMessagePortRpcParent = {
1321
+ const LazyTransferMessagePortRpcParent = {
1060
1322
  __proto__: null,
1061
- create: create$3
1062
- };
1063
- const create$2 = async ({
1064
- commandMap,
1065
- webSocket
1066
- }) => {
1067
- // TODO create a commandMap per rpc instance
1068
- register(commandMap);
1069
- const rawIpc = await IpcParentWithWebSocket$1.create({
1070
- webSocket
1071
- });
1072
- const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
1073
- handleIpc(ipc);
1074
- const rpc = createRpc(ipc);
1075
- return rpc;
1323
+ create: create$i
1076
1324
  };
1077
1325
  const Https$1 = 'https:';
1078
1326
  const Ws = 'ws:';
@@ -1090,7 +1338,21 @@ const getHost = () => {
1090
1338
  const getProtocol = () => {
1091
1339
  return location.protocol;
1092
1340
  };
1093
- const create$1 = async ({
1341
+ const create$h = async ({
1342
+ commandMap,
1343
+ webSocket
1344
+ }) => {
1345
+ // TODO create a commandMap per rpc instance
1346
+ register(commandMap);
1347
+ const rawIpc = await IpcParentWithWebSocket$1.create({
1348
+ webSocket
1349
+ });
1350
+ const ipc = IpcParentWithWebSocket$1.wrap(rawIpc);
1351
+ handleIpc(ipc);
1352
+ const rpc = createRpc(ipc);
1353
+ return rpc;
1354
+ };
1355
+ const create$g = async ({
1094
1356
  commandMap,
1095
1357
  type
1096
1358
  }) => {
@@ -1098,17 +1360,58 @@ const create$1 = async ({
1098
1360
  const protocol = getProtocol();
1099
1361
  const wsUrl = getWebSocketUrl(type, host, protocol);
1100
1362
  const webSocket = new WebSocket(wsUrl);
1101
- const rpc = await create$2({
1102
- webSocket,
1103
- commandMap
1363
+ const rpc = await create$h({
1364
+ commandMap,
1365
+ webSocket
1104
1366
  });
1105
1367
  return rpc;
1106
1368
  };
1107
1369
  const WebSocketRpcParent2 = {
1108
1370
  __proto__: null,
1109
- create: create$1
1371
+ create: create$g
1110
1372
  };
1111
1373
  const create$4 = async ({
1374
+ commandMap,
1375
+ isMessagePortOpen = true,
1376
+ messagePort
1377
+ }) => {
1378
+ // TODO create a commandMap per rpc instance
1379
+ register(commandMap);
1380
+ const rawIpc = await IpcParentWithMessagePort$1.create({
1381
+ isMessagePortOpen,
1382
+ messagePort
1383
+ });
1384
+ const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1385
+ handleIpc(ipc);
1386
+ const rpc = createRpc(ipc);
1387
+ messagePort.start();
1388
+ return rpc;
1389
+ };
1390
+ const PlainMessagePortRpc = {
1391
+ __proto__: null,
1392
+ create: create$4
1393
+ };
1394
+ const create$2 = async ({
1395
+ commandMap,
1396
+ isMessagePortOpen,
1397
+ send
1398
+ }) => {
1399
+ const {
1400
+ port1,
1401
+ port2
1402
+ } = new MessageChannel();
1403
+ await send(port1);
1404
+ return create$4({
1405
+ commandMap,
1406
+ isMessagePortOpen,
1407
+ messagePort: port2
1408
+ });
1409
+ };
1410
+ const TransferMessagePortRpcParent = {
1411
+ __proto__: null,
1412
+ create: create$2
1413
+ };
1414
+ const create$1 = async ({
1112
1415
  commandMap
1113
1416
  }) => {
1114
1417
  // TODO create a commandMap per rpc instance
@@ -1120,7 +1423,7 @@ const create$4 = async ({
1120
1423
  };
1121
1424
  const WebWorkerRpcClient = {
1122
1425
  __proto__: null,
1123
- create: create$4
1426
+ create: create$1
1124
1427
  };
1125
1428
  const createMockRpc = ({
1126
1429
  commandMap
@@ -1132,148 +1435,119 @@ const createMockRpc = ({
1132
1435
  if (!command) {
1133
1436
  throw new Error(`command ${method} not found`);
1134
1437
  }
1135
- return command(...params);
1136
- };
1137
- const mockRpc = {
1138
- invoke,
1139
- invokeAndTransfer: invoke,
1140
- invocations
1141
- };
1142
- return mockRpc;
1143
- };
1144
-
1145
- const DebugWorker = 55;
1146
- const ExtensionHostWorker = 44;
1147
- const FileSystemProcess$1 = 210;
1148
- const FileSystemWorker = 209;
1149
- const RendererProcess = 1670;
1150
- const RendererWorker = 1;
1151
-
1152
- const rpcs = Object.create(null);
1153
- const set$3 = (id, rpc) => {
1154
- rpcs[id] = rpc;
1155
- };
1156
- const get = id => {
1157
- return rpcs[id];
1158
- };
1159
-
1160
- const create = rpcId => {
1161
- return {
1162
- // @ts-ignore
1163
- invoke(method, ...params) {
1164
- const rpc = get(rpcId);
1165
- // @ts-ignore
1166
- return rpc.invoke(method, ...params);
1167
- },
1168
- // @ts-ignore
1169
- invokeAndTransfer(method, ...params) {
1170
- const rpc = get(rpcId);
1171
- // @ts-ignore
1172
- return rpc.invokeAndTransfer(method, ...params);
1173
- },
1174
- set(rpc) {
1175
- set$3(rpcId, rpc);
1176
- },
1177
- async dispose() {
1178
- const rpc = get(rpcId);
1179
- await rpc.dispose();
1180
- }
1438
+ return command(...params);
1439
+ };
1440
+ const mockRpc = {
1441
+ invocations,
1442
+ invoke,
1443
+ invokeAndTransfer: invoke
1181
1444
  };
1445
+ return mockRpc;
1182
1446
  };
1183
1447
 
1184
1448
  const {
1185
1449
  invoke: invoke$3,
1450
+ set: set$4
1451
+ } = create$6(ExtensionHostWorker);
1452
+
1453
+ const {
1454
+ dispose,
1455
+ invoke: invoke$2,
1186
1456
  invokeAndTransfer: invokeAndTransfer$1,
1187
- set: set$2,
1188
- dispose
1189
- } = create(FileSystemProcess$1);
1457
+ set: set$3
1458
+ } = create$6(FileSystemProcess$1);
1190
1459
  const remove$3 = async uri => {
1191
- return invoke$3('FileSystem.remove', uri);
1460
+ return invoke$2('FileSystem.remove', uri);
1192
1461
  };
1193
- const readFile$4 = async uri => {
1194
- return invoke$3('FileSystem.readFile', uri);
1462
+ const readFile$3 = async uri => {
1463
+ return invoke$2('FileSystem.readFile', uri);
1195
1464
  };
1196
1465
  const appendFile$2 = async (uri, text) => {
1197
1466
  // @ts-ignore
1198
- return invoke$3('FileSystem.appendFile', uri, text);
1467
+ return invoke$2('FileSystem.appendFile', uri, text);
1199
1468
  };
1200
1469
  const readDirWithFileTypes$2 = async uri => {
1201
- return invoke$3('FileSystem.readDirWithFileTypes', uri);
1470
+ return invoke$2('FileSystem.readDirWithFileTypes', uri);
1202
1471
  };
1203
1472
  const getPathSeparator$2 = async root => {
1204
1473
  // @ts-ignore
1205
- return invoke$3('FileSystem.getPathSeparator', root);
1474
+ return invoke$2('FileSystem.getPathSeparator', root);
1206
1475
  };
1207
- const readJson$4 = async root => {
1476
+ const readJson$3 = async root => {
1208
1477
  // @ts-ignore
1209
- return invoke$3('FileSystem.readJson', root);
1478
+ return invoke$2('FileSystem.readJson', root);
1210
1479
  };
1211
1480
  const getRealPath$2 = async path => {
1212
1481
  // @ts-ignore
1213
- return invoke$3('FileSystem.getRealPath', path);
1482
+ return invoke$2('FileSystem.getRealPath', path);
1214
1483
  };
1215
1484
  const stat$2 = async path => {
1216
1485
  // @ts-ignore
1217
- return invoke$3('FileSystem.stat', path);
1486
+ return invoke$2('FileSystem.stat', path);
1218
1487
  };
1219
1488
  const writeFile$3 = async (path, content) => {
1220
1489
  // @ts-ignore
1221
- return invoke$3('FileSystem.writeFile', path, content);
1490
+ return invoke$2('FileSystem.writeFile', path, content);
1222
1491
  };
1223
1492
  const mkdir$2 = async path => {
1224
1493
  // @ts-ignore
1225
- return invoke$3('FileSystem.mkdir', path);
1494
+ return invoke$2('FileSystem.mkdir', path);
1226
1495
  };
1227
1496
  const rename$3 = async (oldUri, newUri) => {
1228
1497
  // @ts-ignore
1229
- return invoke$3('FileSystem.rename', oldUri, newUri);
1498
+ return invoke$2('FileSystem.rename', oldUri, newUri);
1230
1499
  };
1231
1500
  const copy$2 = async (oldUri, newUri) => {
1232
1501
  // @ts-ignore
1233
- return invoke$3('FileSystem.copy', oldUri, newUri);
1502
+ return invoke$2('FileSystem.copy', oldUri, newUri);
1234
1503
  };
1235
1504
  const getFolderSize$2 = async uri => {
1236
1505
  // @ts-ignore
1237
- return invoke$3('FileSystem.getFolderSize', uri);
1506
+ return invoke$2('FileSystem.getFolderSize', uri);
1238
1507
  };
1239
- const exists$3 = async uri => {
1508
+ const exists$2 = async uri => {
1240
1509
  // @ts-ignore
1241
- return invoke$3('FileSystem.exists', uri);
1510
+ return invoke$2('FileSystem.exists', uri);
1242
1511
  };
1243
1512
  const registerMockRpc = commandMap => {
1244
1513
  const mockRpc = createMockRpc({
1245
1514
  commandMap
1246
1515
  });
1247
- set$2(mockRpc);
1516
+ set$3(mockRpc);
1248
1517
  return mockRpc;
1249
1518
  };
1250
1519
 
1251
1520
  const FileSystemProcess = {
1252
- __proto__: null,
1253
- appendFile: appendFile$2,
1254
- copy: copy$2,
1255
- dispose,
1256
- exists: exists$3,
1257
- getFolderSize: getFolderSize$2,
1258
- getPathSeparator: getPathSeparator$2,
1259
- getRealPath: getRealPath$2,
1260
- invoke: invoke$3,
1261
- invokeAndTransfer: invokeAndTransfer$1,
1262
- mkdir: mkdir$2,
1263
- readDirWithFileTypes: readDirWithFileTypes$2,
1264
- readFile: readFile$4,
1265
- readJson: readJson$4,
1266
- registerMockRpc,
1267
- remove: remove$3,
1268
- rename: rename$3,
1269
- set: set$2,
1270
- stat: stat$2,
1271
- writeFile: writeFile$3
1521
+ __proto__: null,
1522
+ appendFile: appendFile$2,
1523
+ copy: copy$2,
1524
+ dispose,
1525
+ exists: exists$2,
1526
+ getFolderSize: getFolderSize$2,
1527
+ getPathSeparator: getPathSeparator$2,
1528
+ getRealPath: getRealPath$2,
1529
+ invoke: invoke$2,
1530
+ invokeAndTransfer: invokeAndTransfer$1,
1531
+ mkdir: mkdir$2,
1532
+ readDirWithFileTypes: readDirWithFileTypes$2,
1533
+ readFile: readFile$3,
1534
+ readJson: readJson$3,
1535
+ registerMockRpc,
1536
+ remove: remove$3,
1537
+ rename: rename$3,
1538
+ set: set$3,
1539
+ stat: stat$2,
1540
+ writeFile: writeFile$3
1272
1541
  };
1273
1542
 
1543
+ const {
1544
+ set: set$2
1545
+ } = create$6(RendererProcess);
1546
+
1274
1547
  const {
1275
1548
  invokeAndTransfer,
1276
- set: set$1} = create(RendererWorker);
1549
+ set: set$1
1550
+ } = create$6(RendererWorker);
1277
1551
  const sendMessagePortToExtensionHostWorker = async (port, rpcId = 0) => {
1278
1552
  const command = 'HandleMessagePort.handleMessagePort2';
1279
1553
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
@@ -1289,7 +1563,7 @@ const createLazyRpc = rpcId => {
1289
1563
  let factory;
1290
1564
  const createRpc = async () => {
1291
1565
  const rpc = await factory();
1292
- set$3(rpcId, rpc);
1566
+ set$5(rpcId, rpc);
1293
1567
  };
1294
1568
  const ensureRpc = async () => {
1295
1569
  if (!rpcPromise) {
@@ -1298,238 +1572,22 @@ const createLazyRpc = rpcId => {
1298
1572
  await rpcPromise;
1299
1573
  };
1300
1574
  return {
1301
- setFactory(value) {
1302
- factory = value;
1303
- },
1304
1575
  async invoke(method, ...params) {
1305
1576
  await ensureRpc();
1306
- const rpc = get(rpcId);
1577
+ const rpc = get$1(rpcId);
1307
1578
  return rpc.invoke(method, ...params);
1579
+ },
1580
+ async invokeAndTransfer(method, ...params) {
1581
+ await ensureRpc();
1582
+ const rpc = get$1(rpcId);
1583
+ return rpc.invokeAndTransfer(method, ...params);
1584
+ },
1585
+ setFactory(value) {
1586
+ factory = value;
1308
1587
  }
1309
1588
  };
1310
1589
  };
1311
1590
 
1312
- // TODO: including these in blob-util.ts causes typedoc to generate docs for them,
1313
- // even with --excludePrivate ¯\_(ツ)_/¯
1314
- /** @private */
1315
-
1316
- /* global Promise, Image, Blob, FileReader, atob, btoa,
1317
- BlobBuilder, MSBlobBuilder, MozBlobBuilder, WebKitBlobBuilder, webkitURL */
1318
- /**
1319
- * Shim for
1320
- * [`new Blob()`](https://developer.mozilla.org/en-US/docs/Web/API/Blob.Blob)
1321
- * to support
1322
- * [older browsers that use the deprecated `BlobBuilder` API](http://caniuse.com/blob).
1323
- *
1324
- * Example:
1325
- *
1326
- * ```js
1327
- * var myBlob = blobUtil.createBlob(['hello world'], {type: 'text/plain'});
1328
- * ```
1329
- *
1330
- * @param parts - content of the Blob
1331
- * @param properties - usually `{type: myContentType}`,
1332
- * you can also pass a string for the content type
1333
- * @returns Blob
1334
- */
1335
- function createBlob(parts, properties) {
1336
- parts = parts || [];
1337
- properties = properties || {};
1338
- if (typeof properties === 'string') {
1339
- properties = {
1340
- type: properties
1341
- }; // infer content type
1342
- }
1343
- try {
1344
- return new Blob(parts, properties);
1345
- } catch (e) {
1346
- if (e.name !== 'TypeError') {
1347
- throw e;
1348
- }
1349
- var Builder = typeof BlobBuilder !== 'undefined' ? BlobBuilder : typeof MSBlobBuilder !== 'undefined' ? MSBlobBuilder : typeof MozBlobBuilder !== 'undefined' ? MozBlobBuilder : WebKitBlobBuilder;
1350
- var builder = new Builder();
1351
- for (var i = 0; i < parts.length; i += 1) {
1352
- builder.append(parts[i]);
1353
- }
1354
- return builder.getBlob(properties.type);
1355
- }
1356
- }
1357
- /**
1358
- * Convert a `Blob` to a binary string.
1359
- *
1360
- * Example:
1361
- *
1362
- * ```js
1363
- * blobUtil.blobToBinaryString(blob).then(function (binaryString) {
1364
- * // success
1365
- * }).catch(function (err) {
1366
- * // error
1367
- * });
1368
- * ```
1369
- *
1370
- * @param blob
1371
- * @returns Promise that resolves with the binary string
1372
- */
1373
- function blobToBinaryString$1(blob) {
1374
- return new Promise(function (resolve, reject) {
1375
- var reader = new FileReader();
1376
- var hasBinaryString = typeof reader.readAsBinaryString === 'function';
1377
- reader.onloadend = function () {
1378
- var result = reader.result || '';
1379
- if (hasBinaryString) {
1380
- return resolve(result);
1381
- }
1382
- resolve(arrayBufferToBinaryString(result));
1383
- };
1384
- reader.onerror = reject;
1385
- if (hasBinaryString) {
1386
- reader.readAsBinaryString(blob);
1387
- } else {
1388
- reader.readAsArrayBuffer(blob);
1389
- }
1390
- });
1391
- }
1392
- /**
1393
- * Convert a base64-encoded string to a `Blob`.
1394
- *
1395
- * Example:
1396
- *
1397
- * ```js
1398
- * var blob = blobUtil.base64StringToBlob(base64String);
1399
- * ```
1400
- * @param base64 - base64-encoded string
1401
- * @param type - the content type (optional)
1402
- * @returns Blob
1403
- */
1404
- function base64StringToBlob(base64, type) {
1405
- var parts = [binaryStringToArrayBuffer(atob(base64))];
1406
- return type ? createBlob(parts, {
1407
- type: type
1408
- }) : createBlob(parts);
1409
- }
1410
- /**
1411
- * Convert a binary string to a `Blob`.
1412
- *
1413
- * Example:
1414
- *
1415
- * ```js
1416
- * var blob = blobUtil.binaryStringToBlob(binaryString);
1417
- * ```
1418
- *
1419
- * @param binary - binary string
1420
- * @param type - the content type (optional)
1421
- * @returns Blob
1422
- */
1423
- function binaryStringToBlob$1(binary, type) {
1424
- return base64StringToBlob(btoa(binary), type);
1425
- }
1426
- /**
1427
- * Convert an `ArrayBuffer` to a binary string.
1428
- *
1429
- * Example:
1430
- *
1431
- * ```js
1432
- * var myString = blobUtil.arrayBufferToBinaryString(arrayBuff)
1433
- * ```
1434
- *
1435
- * @param buffer - array buffer
1436
- * @returns binary string
1437
- */
1438
- function arrayBufferToBinaryString(buffer) {
1439
- var binary = '';
1440
- var bytes = new Uint8Array(buffer);
1441
- var length = bytes.byteLength;
1442
- var i = -1;
1443
- while (++i < length) {
1444
- binary += String.fromCharCode(bytes[i]);
1445
- }
1446
- return binary;
1447
- }
1448
- /**
1449
- * Convert a binary string to an `ArrayBuffer`.
1450
- *
1451
- * ```js
1452
- * var myBuffer = blobUtil.binaryStringToArrayBuffer(binaryString)
1453
- * ```
1454
- *
1455
- * @param binary - binary string
1456
- * @returns array buffer
1457
- */
1458
- function binaryStringToArrayBuffer(binary) {
1459
- var length = binary.length;
1460
- var buf = new ArrayBuffer(length);
1461
- var arr = new Uint8Array(buf);
1462
- var i = -1;
1463
- while (++i < length) {
1464
- arr[i] = binary.charCodeAt(i);
1465
- }
1466
- return buf;
1467
- }
1468
-
1469
- const normalizeBlobError = error => {
1470
- if (error && error instanceof ProgressEvent && error.target &&
1471
- // @ts-expect-error - target.error may not be in the type definition
1472
- error.target.error) {
1473
- // @ts-expect-error - target.error may not be in the type definition
1474
- return error.target.error;
1475
- }
1476
- return error;
1477
- };
1478
-
1479
- const binaryStringToBlob = async (string, type) => {
1480
- try {
1481
- return binaryStringToBlob$1(string, type);
1482
- } catch (error) {
1483
- const normalizedError = normalizeBlobError(error);
1484
- throw new VError(normalizedError, 'Failed to convert binary string to blob');
1485
- }
1486
- };
1487
- const blobToBinaryString = async blob => {
1488
- try {
1489
- return await blobToBinaryString$1(blob);
1490
- } catch (error) {
1491
- const normalizedError = normalizeBlobError(error);
1492
- throw new VError(normalizedError, 'Failed to convert blob to binary string');
1493
- }
1494
- };
1495
-
1496
- const readFile$3 = async uri => {
1497
- const response = await fetch(uri);
1498
- if (!response.ok) {
1499
- throw new Error(response.statusText);
1500
- }
1501
- const result = await response.text();
1502
- return result;
1503
- };
1504
- const readFileAsBlob$1 = async uri => {
1505
- const response = await fetch(uri);
1506
- if (!response.ok) {
1507
- throw new Error(response.statusText);
1508
- }
1509
- const result = await response.blob();
1510
- return result;
1511
- };
1512
- const exists$2 = async uri => {
1513
- const response = await fetch(uri);
1514
- if (response.ok) {
1515
- return true;
1516
- }
1517
- return false;
1518
- };
1519
- const readJson$3 = async uri => {
1520
- const response = await fetch(uri);
1521
- if (!response.ok) {
1522
- throw new Error(`${response.statusText}`);
1523
- }
1524
- const json = await response.json();
1525
- return json;
1526
- };
1527
-
1528
- const {
1529
- invoke: invoke$2,
1530
- setFactory: setFactory$1
1531
- } = createLazyRpc(ExtensionHostWorker);
1532
-
1533
1591
  const RE_PROTOCOL = /^([a-z-]+):\/\//;
1534
1592
  const assertUri = uri => {
1535
1593
  const protocolMatch = uri.match(RE_PROTOCOL);
@@ -1579,7 +1637,7 @@ const executeWatchCallBack = async id => {
1579
1637
  commandId,
1580
1638
  rpcId
1581
1639
  } = entry;
1582
- const rpc = get(rpcId);
1640
+ const rpc = get$1(rpcId);
1583
1641
  await rpc.invoke(commandId, id);
1584
1642
  };
1585
1643
  const unregisterWatchCallback = id => {
@@ -1627,28 +1685,28 @@ const triggerMemfsFileWatcher = async uri => {
1627
1685
  };
1628
1686
 
1629
1687
  const remove$1 = async dirent => {
1630
- await invoke$2('FileSystemMemory.remove', dirent);
1688
+ await invoke$3('FileSystemMemory.remove', dirent);
1631
1689
  // Trigger file watchers for memfs files
1632
1690
  await triggerMemfsFileWatcher(dirent);
1633
1691
  };
1634
1692
  const readFile$1 = async uri => {
1635
- return invoke$2('FileSystemMemory.readFile', uri);
1693
+ return invoke$3('FileSystemMemory.readFile', uri);
1636
1694
  };
1637
1695
  const readJson$1 = async uri => {
1638
1696
  throw new Error('not implemented');
1639
1697
  };
1640
1698
  const createFile$1 = async uri => {
1641
- await invoke$2('FileSystemMemory.createFile', uri);
1699
+ await invoke$3('FileSystemMemory.createFile', uri);
1642
1700
  // Trigger file watchers for memfs files
1643
1701
  await triggerMemfsFileWatcher(uri);
1644
1702
  };
1645
1703
  const writeFile$1 = async (uri, content) => {
1646
- await invoke$2('FileSystemMemory.writeFile', uri, content);
1704
+ await invoke$3('FileSystemMemory.writeFile', uri, content);
1647
1705
  // Trigger file watchers for memfs files
1648
1706
  await triggerMemfsFileWatcher(uri);
1649
1707
  };
1650
1708
  const rename$1 = async (oldUri, newUri) => {
1651
- await invoke$2('FileSystemMemory.rename', oldUri, newUri);
1709
+ await invoke$3('FileSystemMemory.rename', oldUri, newUri);
1652
1710
  // Trigger file watchers for both old and new URIs
1653
1711
  await triggerMemfsFileWatcher(oldUri);
1654
1712
  await triggerMemfsFileWatcher(newUri);
@@ -1670,7 +1728,7 @@ const remove = async dirent => {
1670
1728
  };
1671
1729
  const readFile = async uri => {
1672
1730
  if (isHttp(uri)) {
1673
- return readFile$3(uri);
1731
+ return readFile$4(uri);
1674
1732
  }
1675
1733
  if (isMemory(uri)) {
1676
1734
  return readFile$1(uri);
@@ -1688,7 +1746,7 @@ const getPathSeparator = async root => {
1688
1746
  };
1689
1747
  const readJson = async uri => {
1690
1748
  if (isHttp(uri)) {
1691
- return readJson$3(uri);
1749
+ return readJson$4(uri);
1692
1750
  }
1693
1751
  if (isMemory(uri)) {
1694
1752
  return readJson$1();
@@ -1719,7 +1777,7 @@ const stat = async dirent => {
1719
1777
  };
1720
1778
  const exists = async uri => {
1721
1779
  if (isHttp(uri)) {
1722
- return exists$2(uri);
1780
+ return exists$3(uri);
1723
1781
  }
1724
1782
  return exists$1(uri);
1725
1783
  };
@@ -1770,7 +1828,7 @@ const handleMessagePort = async (port, rpcId) => {
1770
1828
  messagePort: port
1771
1829
  });
1772
1830
  if (rpcId) {
1773
- set$3(rpcId, rpc);
1831
+ set$5(rpcId, rpc);
1774
1832
  }
1775
1833
  };
1776
1834
 
@@ -1841,9 +1899,7 @@ const Directory = 'directory';
1841
1899
  const File = 'file';
1842
1900
 
1843
1901
  const {
1844
- invoke,
1845
- setFactory
1846
- } = createLazyRpc(RendererProcess);
1902
+ invoke} = createLazyRpc(RendererProcess);
1847
1903
 
1848
1904
  /**
1849
1905
  * Do not use directly, use FileSystemHtml.getChildHandles
@@ -1952,40 +2008,42 @@ const commandMap = {
1952
2008
  'Initialize.initialize': initialize
1953
2009
  };
1954
2010
 
1955
- const createExtensionHostRpc = async () => {
2011
+ const initializeExtensionHostWorker = async () => {
1956
2012
  try {
1957
- const rpc = await TransferMessagePortRpcParent.create({
2013
+ const rpc = await LazyTransferMessagePortRpcParent.create({
1958
2014
  commandMap: {},
1959
2015
  send: sendMessagePortToExtensionHostWorker
1960
2016
  });
1961
- return rpc;
2017
+ set$4(rpc);
1962
2018
  } catch (error) {
1963
2019
  throw new VError(error, `Failed to create extension host rpc`);
1964
2020
  }
1965
2021
  };
1966
2022
 
1967
- const createRendererProcessRpc = async () => {
2023
+ const initializeRendererProcess = async () => {
1968
2024
  try {
1969
- const rpc = await TransferMessagePortRpcParent.create({
2025
+ const rpc = await LazyTransferMessagePortRpcParent.create({
1970
2026
  commandMap: {},
1971
2027
  send: sendMessagePortToRendererProcess
1972
2028
  });
1973
- return rpc;
2029
+ set$2(rpc);
1974
2030
  } catch (error) {
1975
2031
  throw new VError(error, `Failed to create renderer process rpc`);
1976
2032
  }
1977
2033
  };
1978
2034
 
1979
- const listen = async () => {
1980
- Object.assign(commandMapRef, commandMap);
1981
- setFactory$1(createExtensionHostRpc);
1982
- setFactory(createRendererProcessRpc);
2035
+ const initializeRendererWorker = async () => {
1983
2036
  const rpc = await WebWorkerRpcClient.create({
1984
2037
  commandMap: commandMap
1985
2038
  });
1986
2039
  set$1(rpc);
1987
2040
  };
1988
2041
 
2042
+ const listen = async () => {
2043
+ Object.assign(commandMapRef, commandMap);
2044
+ await Promise.all([initializeExtensionHostWorker(), initializeRendererProcess(), initializeRendererWorker()]);
2045
+ };
2046
+
1989
2047
  const main = async () => {
1990
2048
  await listen();
1991
2049
  };