@lvce-editor/explorer-view 1.11.0 → 1.12.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.
@@ -107,27 +107,6 @@ const string = value => {
107
107
  }
108
108
  };
109
109
 
110
- const walkValue = (value, transferrables, isTransferrable) => {
111
- if (!value) {
112
- return;
113
- }
114
- if (isTransferrable(value)) {
115
- transferrables.push(value);
116
- return;
117
- }
118
- if (Array.isArray(value)) {
119
- for (const item of value) {
120
- walkValue(item, transferrables, isTransferrable);
121
- }
122
- return;
123
- }
124
- if (typeof value === 'object') {
125
- for (const property of Object.values(value)) {
126
- walkValue(property, transferrables, isTransferrable);
127
- }
128
- return;
129
- }
130
- };
131
110
  const isMessagePort = value => {
132
111
  return value && value instanceof MessagePort;
133
112
  };
@@ -152,6 +131,27 @@ const isTransferrable = value => {
152
131
  }
153
132
  return false;
154
133
  };
134
+ const walkValue = (value, transferrables, isTransferrable) => {
135
+ if (!value) {
136
+ return;
137
+ }
138
+ if (isTransferrable(value)) {
139
+ transferrables.push(value);
140
+ return;
141
+ }
142
+ if (Array.isArray(value)) {
143
+ for (const item of value) {
144
+ walkValue(item, transferrables, isTransferrable);
145
+ }
146
+ return;
147
+ }
148
+ if (typeof value === 'object') {
149
+ for (const property of Object.values(value)) {
150
+ walkValue(property, transferrables, isTransferrable);
151
+ }
152
+ return;
153
+ }
154
+ };
155
155
  const getTransferrables = value => {
156
156
  const transferrables = [];
157
157
  walkValue(value, transferrables, isTransferrable);
@@ -184,30 +184,35 @@ const NewLine$1 = '\n';
184
184
  const joinLines$1 = lines => {
185
185
  return lines.join(NewLine$1);
186
186
  };
187
- const splitLines$1 = lines => {
188
- return lines.split(NewLine$1);
189
- };
190
- const isModuleNotFoundMessage = line => {
191
- return line.includes('[ERR_MODULE_NOT_FOUND]');
187
+ const RE_AT = /^\s+at/;
188
+ const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
189
+ const isNormalStackLine = line => {
190
+ return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
192
191
  };
193
- const getModuleNotFoundError = stderr => {
194
- const lines = splitLines$1(stderr);
195
- const messageIndex = lines.findIndex(isModuleNotFoundMessage);
196
- const message = lines[messageIndex];
192
+ const getDetails = lines => {
193
+ const index = lines.findIndex(isNormalStackLine);
194
+ if (index === -1) {
195
+ return {
196
+ actualMessage: joinLines$1(lines),
197
+ rest: []
198
+ };
199
+ }
200
+ let lastIndex = index - 1;
201
+ while (++lastIndex < lines.length) {
202
+ if (!isNormalStackLine(lines[lastIndex])) {
203
+ break;
204
+ }
205
+ }
197
206
  return {
198
- message,
199
- code: ERR_MODULE_NOT_FOUND
207
+ actualMessage: lines[index - 1],
208
+ rest: lines.slice(index, lastIndex)
200
209
  };
201
210
  };
202
- const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
203
- const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
211
+ const splitLines$1 = lines => {
212
+ return lines.split(NewLine$1);
213
+ };
204
214
  const RE_MESSAGE_CODE_BLOCK_START = /^Error: The module '.*'$/;
205
215
  const RE_MESSAGE_CODE_BLOCK_END = /^\s* at/;
206
- const RE_AT = /^\s+at/;
207
- const RE_AT_PROMISE_INDEX = /^\s*at async Promise.all \(index \d+\)$/;
208
- const isUnhelpfulNativeModuleError = stderr => {
209
- return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
210
- };
211
216
  const isMessageCodeBlockStartIndex = line => {
212
217
  return RE_MESSAGE_CODE_BLOCK_START.test(line);
213
218
  };
@@ -222,51 +227,46 @@ const getMessageCodeBlock = stderr => {
222
227
  const relevantMessage = relevantLines.join(' ').slice('Error: '.length);
223
228
  return relevantMessage;
224
229
  };
225
- const getNativeModuleErrorMessage = stderr => {
226
- const message = getMessageCodeBlock(stderr);
230
+ const isModuleNotFoundMessage = line => {
231
+ return line.includes('[ERR_MODULE_NOT_FOUND]');
232
+ };
233
+ const getModuleNotFoundError = stderr => {
234
+ const lines = splitLines$1(stderr);
235
+ const messageIndex = lines.findIndex(isModuleNotFoundMessage);
236
+ const message = lines[messageIndex];
227
237
  return {
228
- message: `Incompatible native node module: ${message}`,
229
- code: E_INCOMPATIBLE_NATIVE_MODULE
238
+ message,
239
+ code: ERR_MODULE_NOT_FOUND
230
240
  };
231
241
  };
232
- const isModulesSyntaxError = stderr => {
242
+ const isModuleNotFoundError = stderr => {
233
243
  if (!stderr) {
234
244
  return false;
235
245
  }
236
- return stderr.includes('SyntaxError: Cannot use import statement outside a module');
237
- };
238
- const getModuleSyntaxError = () => {
239
- return {
240
- message: `ES Modules are not supported in electron`,
241
- code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
242
- };
246
+ return stderr.includes('ERR_MODULE_NOT_FOUND');
243
247
  };
244
- const isModuleNotFoundError = stderr => {
248
+ const isModulesSyntaxError = stderr => {
245
249
  if (!stderr) {
246
250
  return false;
247
251
  }
248
- return stderr.includes('ERR_MODULE_NOT_FOUND');
252
+ return stderr.includes('SyntaxError: Cannot use import statement outside a module');
249
253
  };
250
- const isNormalStackLine = line => {
251
- return RE_AT.test(line) && !RE_AT_PROMISE_INDEX.test(line);
254
+ const RE_NATIVE_MODULE_ERROR = /^innerError Error: Cannot find module '.*.node'/;
255
+ const RE_NATIVE_MODULE_ERROR_2 = /was compiled against a different Node.js version/;
256
+ const isUnhelpfulNativeModuleError = stderr => {
257
+ return RE_NATIVE_MODULE_ERROR.test(stderr) && RE_NATIVE_MODULE_ERROR_2.test(stderr);
252
258
  };
253
- const getDetails = lines => {
254
- const index = lines.findIndex(isNormalStackLine);
255
- if (index === -1) {
256
- return {
257
- actualMessage: joinLines$1(lines),
258
- rest: []
259
- };
260
- }
261
- let lastIndex = index - 1;
262
- while (++lastIndex < lines.length) {
263
- if (!isNormalStackLine(lines[lastIndex])) {
264
- break;
265
- }
266
- }
259
+ const getNativeModuleErrorMessage = stderr => {
260
+ const message = getMessageCodeBlock(stderr);
267
261
  return {
268
- actualMessage: lines[index - 1],
269
- rest: lines.slice(index, lastIndex)
262
+ message: `Incompatible native node module: ${message}`,
263
+ code: E_INCOMPATIBLE_NATIVE_MODULE
264
+ };
265
+ };
266
+ const getModuleSyntaxError = () => {
267
+ return {
268
+ message: `ES Modules are not supported in electron`,
269
+ code: E_MODULES_NOT_SUPPORTED_IN_ELECTRON
270
270
  };
271
271
  };
272
272
  const getHelpfulChildProcessError = (stdout, stderr) => {
@@ -285,7 +285,7 @@ const getHelpfulChildProcessError = (stdout, stderr) => {
285
285
  rest
286
286
  } = getDetails(lines);
287
287
  return {
288
- message: `${actualMessage}`,
288
+ message: actualMessage,
289
289
  code: '',
290
290
  stack: rest
291
291
  };
@@ -327,7 +327,7 @@ const listen$7 = () => {
327
327
  }
328
328
  return globalThis;
329
329
  };
330
- const signal$7 = global => {
330
+ const signal$8 = global => {
331
331
  global.postMessage(readyMessage);
332
332
  };
333
333
  class IpcChildWithModuleWorker extends Ipc {
@@ -353,7 +353,7 @@ class IpcChildWithModuleWorker extends Ipc {
353
353
  this._rawIpc.addEventListener('message', callback);
354
354
  }
355
355
  }
356
- const wrap$e = global => {
356
+ const wrap$f = global => {
357
357
  return new IpcChildWithModuleWorker(global);
358
358
  };
359
359
  const withResolvers = () => {
@@ -362,6 +362,7 @@ const withResolvers = () => {
362
362
  _resolve = resolve;
363
363
  });
364
364
  return {
365
+ // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
365
366
  resolve: _resolve,
366
367
  promise
367
368
  };
@@ -380,8 +381,8 @@ const waitForFirstMessage = async port => {
380
381
  };
381
382
  const listen$6 = async () => {
382
383
  const parentIpcRaw = listen$7();
383
- signal$7(parentIpcRaw);
384
- const parentIpc = wrap$e(parentIpcRaw);
384
+ signal$8(parentIpcRaw);
385
+ const parentIpc = wrap$f(parentIpcRaw);
385
386
  const firstMessage = await waitForFirstMessage(parentIpc);
386
387
  if (firstMessage.method !== 'initialize') {
387
388
  throw new IpcError('unexpected first message');
@@ -400,9 +401,6 @@ const listen$6 = async () => {
400
401
  return globalThis;
401
402
  };
402
403
  class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
403
- constructor(port) {
404
- super(port);
405
- }
406
404
  getData(event) {
407
405
  return getData$2(event);
408
406
  }
@@ -426,13 +424,13 @@ class IpcChildWithModuleWorkerAndMessagePort extends Ipc {
426
424
  this._rawIpc.start();
427
425
  }
428
426
  }
429
- const wrap$d = port => {
427
+ const wrap$e = port => {
430
428
  return new IpcChildWithModuleWorkerAndMessagePort(port);
431
429
  };
432
430
  const IpcChildWithModuleWorkerAndMessagePort$1 = {
433
431
  __proto__: null,
434
432
  listen: listen$6,
435
- wrap: wrap$d
433
+ wrap: wrap$e
436
434
  };
437
435
 
438
436
  const Two = '2.0';
@@ -457,9 +455,6 @@ let id = 0;
457
455
  const create$3 = () => {
458
456
  return ++id;
459
457
  };
460
- const warn = (...args) => {
461
- console.warn(...args);
462
- };
463
458
  const registerPromise = () => {
464
459
  const id = create$3();
465
460
  const {
@@ -472,16 +467,6 @@ const registerPromise = () => {
472
467
  promise
473
468
  };
474
469
  };
475
- const resolve = (id, response) => {
476
- const fn = get(id);
477
- if (!fn) {
478
- console.log(response);
479
- warn(`callback ${id} may already be disposed`);
480
- return;
481
- }
482
- fn(response);
483
- remove$1(id);
484
- };
485
470
  const create$2 = (method, params) => {
486
471
  const {
487
472
  id,
@@ -629,6 +614,19 @@ const unwrapJsonRpcResult = responseMessage => {
629
614
  }
630
615
  throw new JsonRpcError('unexpected response message');
631
616
  };
617
+ const warn = (...args) => {
618
+ console.warn(...args);
619
+ };
620
+ const resolve = (id, response) => {
621
+ const fn = get(id);
622
+ if (!fn) {
623
+ console.log(response);
624
+ warn(`callback ${id} may already be disposed`);
625
+ return;
626
+ }
627
+ fn(response);
628
+ remove$1(id);
629
+ };
632
630
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
633
631
  const getErrorType = prettyError => {
634
632
  if (prettyError && prettyError.type) {
@@ -798,6 +796,8 @@ const execute = (command, ...args) => {
798
796
 
799
797
  const createRpc = ipc => {
800
798
  const rpc = {
799
+ // @ts-ignore
800
+ ipc,
801
801
  /**
802
802
  * @deprecated
803
803
  */
@@ -824,7 +824,8 @@ const logError = () => {
824
824
  };
825
825
  const handleMessage = event => {
826
826
  const actualRequiresSocket = event?.target?.requiresSocket || requiresSocket;
827
- return handleJsonRpcMessage(event.target, event.data, execute, resolve, preparePrettyError, logError, actualRequiresSocket);
827
+ const actualExecute = event?.target?.execute || execute;
828
+ return handleJsonRpcMessage(event.target, event.data, actualExecute, resolve, preparePrettyError, logError, actualRequiresSocket);
828
829
  };
829
830
  const handleIpc = ipc => {
830
831
  if ('addEventListener' in ipc) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/explorer-view",
3
- "version": "1.11.0",
3
+ "version": "1.12.0",
4
4
  "description": "Explorer Worker",
5
5
  "main": "dist/explorerViewWorkerMain.js",
6
6
  "type": "module",