@lvce-editor/panel-worker 1.7.0 → 1.9.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.
@@ -463,12 +463,12 @@ const getErrorConstructor = (message, type) => {
463
463
  switch (type) {
464
464
  case DomException:
465
465
  return DOMException;
466
- case TypeError$1:
467
- return TypeError;
468
- case SyntaxError$1:
469
- return SyntaxError;
470
466
  case ReferenceError$1:
471
467
  return ReferenceError;
468
+ case SyntaxError$1:
469
+ return SyntaxError;
470
+ case TypeError$1:
471
+ return TypeError;
472
472
  default:
473
473
  return Error;
474
474
  }
@@ -624,27 +624,27 @@ const getErrorProperty = (error, prettyError) => {
624
624
  if (error && error.code === E_COMMAND_NOT_FOUND) {
625
625
  return {
626
626
  code: MethodNotFound,
627
- message: error.message,
628
- data: error.stack
627
+ data: error.stack,
628
+ message: error.message
629
629
  };
630
630
  }
631
631
  return {
632
632
  code: Custom,
633
- message: prettyError.message,
634
633
  data: {
635
- stack: getStack(prettyError),
636
- codeFrame: prettyError.codeFrame,
637
- type: getErrorType(prettyError),
638
634
  code: prettyError.code,
639
- name: prettyError.name
640
- }
635
+ codeFrame: prettyError.codeFrame,
636
+ name: prettyError.name,
637
+ stack: getStack(prettyError),
638
+ type: getErrorType(prettyError)
639
+ },
640
+ message: prettyError.message
641
641
  };
642
642
  };
643
643
  const create$1$1 = (id, error) => {
644
644
  return {
645
- jsonrpc: Two$1,
645
+ error,
646
646
  id,
647
- error
647
+ jsonrpc: Two$1
648
648
  };
649
649
  };
650
650
  const getErrorResponse = (id, error, preparePrettyError, logError) => {
@@ -655,8 +655,8 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
655
655
  };
656
656
  const create$7 = (message, result) => {
657
657
  return {
658
- jsonrpc: Two$1,
659
658
  id: message.id,
659
+ jsonrpc: Two$1,
660
660
  result: result ?? null
661
661
  };
662
662
  };
@@ -666,14 +666,14 @@ const getSuccessResponse = (message, result) => {
666
666
  };
667
667
  const getErrorResponseSimple = (id, error) => {
668
668
  return {
669
- jsonrpc: Two$1,
670
- id,
671
669
  error: {
672
670
  code: Custom,
671
+ data: error,
673
672
  // @ts-ignore
674
- message: error.message,
675
- data: error
676
- }
673
+ message: error.message
674
+ },
675
+ id,
676
+ jsonrpc: Two$1
677
677
  };
678
678
  };
679
679
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
@@ -703,35 +703,35 @@ const normalizeParams = args => {
703
703
  if (args.length === 1) {
704
704
  const options = args[0];
705
705
  return {
706
+ execute: options.execute,
706
707
  ipc: options.ipc,
708
+ logError: options.logError || defaultLogError,
707
709
  message: options.message,
708
- execute: options.execute,
709
- resolve: options.resolve || defaultResolve,
710
710
  preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
711
- logError: options.logError || defaultLogError,
712
- requiresSocket: options.requiresSocket || defaultRequiresSocket
711
+ requiresSocket: options.requiresSocket || defaultRequiresSocket,
712
+ resolve: options.resolve || defaultResolve
713
713
  };
714
714
  }
715
715
  return {
716
+ execute: args[2],
716
717
  ipc: args[0],
718
+ logError: args[5],
717
719
  message: args[1],
718
- execute: args[2],
719
- resolve: args[3],
720
720
  preparePrettyError: args[4],
721
- logError: args[5],
722
- requiresSocket: args[6]
721
+ requiresSocket: args[6],
722
+ resolve: args[3]
723
723
  };
724
724
  };
725
725
  const handleJsonRpcMessage = async (...args) => {
726
726
  const options = normalizeParams(args);
727
727
  const {
728
- message,
729
- ipc,
730
728
  execute,
731
- resolve,
732
- preparePrettyError,
729
+ ipc,
733
730
  logError,
734
- requiresSocket
731
+ message,
732
+ preparePrettyError,
733
+ requiresSocket,
734
+ resolve
735
735
  } = options;
736
736
  if ('id' in message) {
737
737
  if ('method' in message) {
@@ -792,7 +792,6 @@ const registerPromise = map => {
792
792
  };
793
793
  };
794
794
 
795
- // @ts-ignore
796
795
  const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
797
796
  const {
798
797
  id,
@@ -886,6 +885,7 @@ const create$3 = async ({
886
885
  };
887
886
 
888
887
  const Tab = 'tab';
888
+ const TabList = 'tablist';
889
889
  const ToolBar = 'toolbar';
890
890
 
891
891
  const Button = 1;
@@ -1181,15 +1181,17 @@ const getContentDimensions = dimensions => {
1181
1181
  const openViewlet = async (state, id, focus = false) => {
1182
1182
  const childDimensions = getContentDimensions(state);
1183
1183
  const childUid = Math.random();
1184
- const tabId = 1234;
1184
+ const tabId = Math.random();
1185
1185
  const actionsUid = Math.random();
1186
+ const index = state.views.indexOf(id);
1186
1187
  await createViewlet(id, childUid, tabId, childDimensions, '');
1187
1188
  return {
1188
1189
  ...state,
1189
1190
  actionsUid,
1190
1191
  childUid,
1191
1192
  currentViewletId: id,
1192
- initial: false
1193
+ initial: false,
1194
+ selectedIndex: index
1193
1195
  };
1194
1196
  };
1195
1197
 
@@ -1208,11 +1210,7 @@ const selectIndex = async (state, index) => {
1208
1210
  const {
1209
1211
  views
1210
1212
  } = state;
1211
- await openViewlet(state, views[index]);
1212
- return {
1213
- ...state,
1214
- selectedIndex: index
1215
- };
1213
+ return openViewlet(state, views[index]);
1216
1214
  };
1217
1215
 
1218
1216
  const selectRaw = async (state, rawIndex) => {
@@ -1659,7 +1657,7 @@ const createPanelTab = (tab, badgeCount, isSelected, index) => {
1659
1657
  className,
1660
1658
  'data-index': index,
1661
1659
  name: tab,
1662
- onClick: HandleClickSelectTab,
1660
+ onClick: HandleClickTab,
1663
1661
  role: Tab,
1664
1662
  type: Button
1665
1663
  };
@@ -1694,7 +1692,7 @@ const getPanelHeaderDom = newState => {
1694
1692
  }, {
1695
1693
  childCount: newState.views.length,
1696
1694
  className: PanelTabs,
1697
- role: 'tablist',
1695
+ role: TabList,
1698
1696
  type: Div
1699
1697
  }, ...tabsDom, ...getActionsDom(newState), ...getGlobalActionsDom()];
1700
1698
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/panel-worker",
3
- "version": "1.7.0",
3
+ "version": "1.9.0",
4
4
  "description": "Panel Worker",
5
5
  "repository": {
6
6
  "type": "git",