@lvce-editor/test-worker 1.6.0 → 1.8.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,23 @@
1
+ const commands = Object.create(null);
2
+ const registerCommand = (key, fn) => {
3
+ commands[key] = fn;
4
+ };
5
+ const register = commandMap => {
6
+ for (const [key, value] of Object.entries(commandMap)) {
7
+ registerCommand(key, value);
8
+ }
9
+ };
10
+ const getCommand = key => {
11
+ return commands[key];
12
+ };
13
+ const execute$3 = (command, ...args) => {
14
+ const fn = getCommand(command);
15
+ if (!fn) {
16
+ throw new Error(`command not found ${command}`);
17
+ }
18
+ return fn(...args);
19
+ };
20
+
1
21
  const state$3 = {
2
22
  /**
3
23
  * @type {any}
@@ -46,17 +66,17 @@ const number = value => {
46
66
  throw new AssertionError$1('expected value to be of type number');
47
67
  }
48
68
  };
49
- const state$1$1 = {
69
+ const state$1 = {
50
70
  callbacks: Object.create(null)
51
71
  };
52
72
  const set = (id, fn) => {
53
- state$1$1.callbacks[id] = fn;
73
+ state$1.callbacks[id] = fn;
54
74
  };
55
75
  const get = id => {
56
- return state$1$1.callbacks[id];
76
+ return state$1.callbacks[id];
57
77
  };
58
78
  const remove = id => {
59
- delete state$1$1.callbacks[id];
79
+ delete state$1.callbacks[id];
60
80
  };
61
81
  const state$2 = {
62
82
  id: 0
@@ -250,14 +270,16 @@ const unwrapJsonRpcResult = responseMessage => {
250
270
  }
251
271
  throw new JsonRpcError('unexpected response message');
252
272
  };
253
- const create$1 = (message, error) => {
254
- return {
255
- jsonrpc: Two,
256
- id: message.id,
257
- error
258
- };
259
- };
260
273
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
274
+ const getType$2 = prettyError => {
275
+ if (prettyError && prettyError.type) {
276
+ return prettyError.type;
277
+ }
278
+ if (prettyError && prettyError.constructor && prettyError.constructor.name) {
279
+ return prettyError.constructor.name;
280
+ }
281
+ return undefined;
282
+ };
261
283
  const getErrorProperty = (error, prettyError) => {
262
284
  if (error && error.code === E_COMMAND_NOT_FOUND) {
263
285
  return {
@@ -272,11 +294,19 @@ const getErrorProperty = (error, prettyError) => {
272
294
  data: {
273
295
  stack: prettyError.stack,
274
296
  codeFrame: prettyError.codeFrame,
275
- type: prettyError.type,
276
- code: prettyError.code
297
+ type: getType$2(prettyError),
298
+ code: prettyError.code,
299
+ name: prettyError.name
277
300
  }
278
301
  };
279
302
  };
303
+ const create$1 = (message, error) => {
304
+ return {
305
+ jsonrpc: Two,
306
+ id: message.id,
307
+ error
308
+ };
309
+ };
280
310
  const getErrorResponse = (message, error, preparePrettyError, logError) => {
281
311
  const prettyError = preparePrettyError(error);
282
312
  logError(error, prettyError);
@@ -368,14 +398,7 @@ const invoke$1 = async (ipc, method, ...params) => {
368
398
  const result = unwrapJsonRpcResult(responseMessage);
369
399
  return result;
370
400
  };
371
-
372
- // TODO deprecated old typings,
373
- // always use automatic transferrable detection
374
- const invokeAndTransfer$1 = async (ipc, handle, method, ...params) => {
375
- if (typeof handle === 'string') {
376
- params = [method, ...params];
377
- method = handle;
378
- }
401
+ const invokeAndTransfer$1 = async (ipc, method, ...params) => {
379
402
  const {
380
403
  message,
381
404
  promise
@@ -688,7 +711,7 @@ const string = value => {
688
711
 
689
712
  // @ts-nocheck
690
713
 
691
- const state$1 = {
714
+ const state = {
692
715
  /**
693
716
  * @type {any[]}
694
717
  */
@@ -696,20 +719,20 @@ const state$1 = {
696
719
  mockRpcs: Object.create(null)
697
720
  };
698
721
  const addTest = (name, fn) => {
699
- state$1.pendingTests.push({
722
+ state.pendingTests.push({
700
723
  name,
701
724
  fn
702
725
  });
703
726
  };
704
727
  const getTests = () => {
705
- const tests = state$1.pendingTests;
706
- state$1.pendingTests = [];
728
+ const tests = state.pendingTests;
729
+ state.pendingTests = [];
707
730
  return tests;
708
731
  };
709
732
  const setMockRpc = mockRpc => {
710
733
  object(mockRpc);
711
734
  string(mockRpc.name);
712
- state$1.mockRpcs[mockRpc.name] = mockRpc;
735
+ state.mockRpcs[mockRpc.name] = mockRpc;
713
736
  };
714
737
 
715
738
  // @ts-nocheck
@@ -894,13 +917,13 @@ const TestFrameWorkComponentBaseUrl = {
894
917
  getBaseUrl
895
918
  };
896
919
 
897
- const execute$3 = async (id, ...args) => {
920
+ const execute$2 = async (id, ...args) => {
898
921
  return invoke(id, ...args);
899
922
  };
900
923
 
901
924
  const TestFrameWorkComponentCommand = {
902
925
  __proto__: null,
903
- execute: execute$3
926
+ execute: execute$2
904
927
  };
905
928
 
906
929
  const selectItem$1 = async text => {
@@ -990,9 +1013,19 @@ const openSourceActions = async () => {
990
1013
  const sourceActionsSelectCurrent = async () => {
991
1014
  await invoke('EditorSourceActions.selectCurrent');
992
1015
  };
1016
+ const openCompletionDetails = async () => {
1017
+ await invoke('EditorCompletion.openDetails');
1018
+ };
1019
+ const closeCompletionDetails = async () => {
1020
+ await invoke('EditorCompletion.closeDetails');
1021
+ };
1022
+ const toggleCompletionDetails = async () => {
1023
+ await invoke('EditorCompletion.toggleDetails');
1024
+ };
993
1025
 
994
1026
  const TestFrameWorkComponentEditor = {
995
1027
  __proto__: null,
1028
+ closeCompletionDetails,
996
1029
  copyLineDown,
997
1030
  cursorCharacterLeft,
998
1031
  cursorCharacterRight,
@@ -1010,6 +1043,7 @@ const TestFrameWorkComponentEditor = {
1010
1043
  invokeBraceCompletion,
1011
1044
  invokeTabCompletion,
1012
1045
  openCompletion,
1046
+ openCompletionDetails,
1013
1047
  openEditorContextMenu,
1014
1048
  openFindWidget,
1015
1049
  openHover,
@@ -1018,6 +1052,7 @@ const TestFrameWorkComponentEditor = {
1018
1052
  setDeltaY,
1019
1053
  setSelections,
1020
1054
  sourceActionsSelectCurrent,
1055
+ toggleCompletionDetails,
1021
1056
  type
1022
1057
  };
1023
1058
 
@@ -1482,7 +1517,7 @@ const preparePrettyError$1 = error => {
1482
1517
  const logError$1 = () => {
1483
1518
  // ignore
1484
1519
  };
1485
- const execute$2 = () => {};
1520
+ const execute$1 = () => {};
1486
1521
  const requiresSocket$1 = () => {
1487
1522
  return false;
1488
1523
  };
@@ -1502,7 +1537,7 @@ const createPortIpc = async webViewId => {
1502
1537
  }
1503
1538
  const handleOtherMessage = async event => {
1504
1539
  // @ts-ignore
1505
- await handleJsonRpcMessage(ipc, event.data, resolve, preparePrettyError$1, execute$2, logError$1, requiresSocket$1);
1540
+ await handleJsonRpcMessage(ipc, event.data, resolve, preparePrettyError$1, execute$1, logError$1, requiresSocket$1);
1506
1541
  };
1507
1542
  port1.onmessage = handleOtherMessage;
1508
1543
  const ipc = {
@@ -1577,7 +1612,7 @@ const TestFrameWorkComponent = {
1577
1612
  Workspace: TestFrameWorkComponentWorkspace
1578
1613
  };
1579
1614
 
1580
- const execute$1 = async href => {
1615
+ const execute = async href => {
1581
1616
  const globals = {
1582
1617
  ...TestFrameWorkComponent,
1583
1618
  ...TestFrameWork
@@ -1612,32 +1647,7 @@ const execute$1 = async href => {
1612
1647
  };
1613
1648
 
1614
1649
  const commandMap = {
1615
- 'Test.execute': execute$1
1616
- };
1617
-
1618
- const state = {
1619
- commands: Object.create(null)
1620
- };
1621
- const registerCommand = (key, fn) => {
1622
- state.commands[key] = fn;
1623
- };
1624
- const registerCommands = commandMap => {
1625
- for (const [key, value] of Object.entries(commandMap)) {
1626
- registerCommand(key, value);
1627
- }
1628
- };
1629
- const getCommand = key => {
1630
- return state.commands[key];
1631
- };
1632
-
1633
- const processName = 'embeds-worker';
1634
-
1635
- const execute = (command, ...args) => {
1636
- const fn = getCommand(command);
1637
- if (!fn) {
1638
- throw new Error(`[${processName}] command not found ${command}`);
1639
- }
1640
- return fn(...args);
1650
+ 'Test.execute': execute
1641
1651
  };
1642
1652
 
1643
1653
  const requiresSocket = () => {
@@ -1650,7 +1660,7 @@ const logError = error => {
1650
1660
  console.error(error);
1651
1661
  };
1652
1662
  const handleMessage = event => {
1653
- return handleJsonRpcMessage(event.target, event.data, execute, resolve, preparePrettyError, logError, requiresSocket);
1663
+ return handleJsonRpcMessage(event.target, event.data, execute$3, resolve, preparePrettyError, logError, requiresSocket);
1654
1664
  };
1655
1665
 
1656
1666
  const handleIpc = ipc => {
@@ -2086,7 +2096,7 @@ const listen$1 = async ({
2086
2096
  };
2087
2097
 
2088
2098
  const listen = async () => {
2089
- registerCommands(commandMap);
2099
+ register(commandMap);
2090
2100
  const ipc = await listen$1({
2091
2101
  method: Auto()
2092
2102
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/test-worker",
3
- "version": "1.6.0",
3
+ "version": "1.8.0",
4
4
  "description": "",
5
5
  "main": "dist/testWorkerMain.js",
6
6
  "type": "module",
@@ -66,5 +66,12 @@
66
66
  "ignores": [
67
67
  "distmin"
68
68
  ]
69
+ },
70
+ "nodemonConfig": {
71
+ "watch": [
72
+ "src"
73
+ ],
74
+ "ext": "ts,js",
75
+ "exec": "node scripts/build.js"
69
76
  }
70
77
  }