@lvce-editor/main-area-worker 9.46.0 → 9.48.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.
@@ -2945,13 +2945,34 @@ const getActiveTab = state => {
2945
2945
  };
2946
2946
  };
2947
2947
 
2948
+ const state = {
2949
+ connected: false
2950
+ };
2951
+ const isConnected = () => {
2952
+ const {
2953
+ connected
2954
+ } = state;
2955
+ return connected;
2956
+ };
2957
+ const invoke = (method, ...params) => {
2958
+ return invoke$2(method, ...params);
2959
+ };
2960
+ const set = rpc => {
2961
+ set$3(rpc);
2962
+ state.connected = true;
2963
+ };
2964
+
2948
2965
  const focus = async state => {
2949
2966
  const activeTab = getActiveTab(state);
2950
2967
  const editorUid = activeTab?.tab.editorUid;
2951
2968
  if (typeof editorUid !== 'number' || editorUid < 0) {
2952
2969
  return state;
2953
2970
  }
2954
- await invoke$1('Viewlet.focusSelector', editorUid, '[name="editor"]');
2971
+ if (isConnected()) {
2972
+ await invoke('Viewlet.focusSelectorAfterRender', editorUid, '[name="editor"]');
2973
+ } else {
2974
+ await invoke$1('Viewlet.focusSelector', editorUid, '[name="editor"]');
2975
+ }
2955
2976
  return state;
2956
2977
  };
2957
2978
 
@@ -3474,6 +3495,15 @@ const focusPreviousTab = async state => {
3474
3495
  return selectTab(state, activeGroupIndex, previousTabIndex);
3475
3496
  };
3476
3497
 
3498
+ const getActiveEditorUid = state => {
3499
+ const activeTab = getActiveTab(state);
3500
+ const editorUid = activeTab?.tab.editorUid;
3501
+ if (editorUid === undefined || editorUid < 0) {
3502
+ throw new Error('no active editor found');
3503
+ }
3504
+ return editorUid;
3505
+ };
3506
+
3477
3507
  const getMenuIds = () => {
3478
3508
  return [Main$1, Tab];
3479
3509
  };
@@ -5410,24 +5440,7 @@ const handleIconThemeChange = async state => {
5410
5440
  };
5411
5441
  };
5412
5442
 
5413
- const state = {
5414
- connected: false
5415
- };
5416
- const isConnected = () => {
5417
- const {
5418
- connected
5419
- } = state;
5420
- return connected;
5421
- };
5422
- const invoke = (method, ...params) => {
5423
- return invoke$2(method, ...params);
5424
- };
5425
- const set = rpc => {
5426
- set$3(rpc);
5427
- state.connected = true;
5428
- };
5429
-
5430
- const handleMessagePort = async (port, viewletCommandMap) => {
5443
+ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcess = true) => {
5431
5444
  const executeViewletCommand = async (uid, command, ...args) => {
5432
5445
  const fn = viewletCommandMap[`MainArea.${command}`];
5433
5446
  if (typeof fn !== 'function') {
@@ -5442,7 +5455,9 @@ const handleMessagePort = async (port, viewletCommandMap) => {
5442
5455
  },
5443
5456
  messagePort: port
5444
5457
  });
5445
- set(rpc);
5458
+ if (setAsRendererProcess) {
5459
+ set(rpc);
5460
+ }
5446
5461
  };
5447
5462
 
5448
5463
  const handleModifiedStatusChange = (state, uri, newStatus) => {
@@ -8302,7 +8317,8 @@ const resize = async (uid, dimensions) => {
8302
8317
  set$1(uid, instance.oldState, resizedState);
8303
8318
  return handleResize(resizedState, dimensions);
8304
8319
  };
8305
- const handleDirectMessagePort = port => handleMessagePort(port, commandMap);
8320
+ const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
8321
+ const handleTestWorkerMessagePort = port => handleMessagePort(port, commandMap, false);
8306
8322
  const commandMap = {
8307
8323
  'Main.closeActiveEditor': wrapSerialCommand(closeActiveEditor),
8308
8324
  'Main.closeAll': wrapSerialCommand(closeAll$1),
@@ -8349,6 +8365,7 @@ const commandMap = {
8349
8365
  'MainArea.focusNextTab': wrapSerialCommand(focusNextTab),
8350
8366
  'MainArea.focusPrevious': wrapSerialCommand(focusPreviousTab),
8351
8367
  'MainArea.focusPreviousTab': wrapSerialCommand(focusPreviousTab),
8368
+ 'MainArea.getActiveEditorUid': wrapGetter(getActiveEditorUid),
8352
8369
  'MainArea.getCommandIds': getCommandIds,
8353
8370
  'MainArea.getMenuEntries': wrapGetter(getMenuEntries),
8354
8371
  'MainArea.getMenuIds': getMenuIds,
@@ -8377,6 +8394,7 @@ const commandMap = {
8377
8394
  'MainArea.handleSashPointerUp': wrapSerialCommand(handleSashPointerUp),
8378
8395
  'MainArea.handleTabContextMenu': wrapSerialCommand(handleTabContextMenu),
8379
8396
  'MainArea.handleTabMouseUp': wrapSerialCommand(resetPointerDown),
8397
+ 'MainArea.handleTestWorkerMessagePort': handleTestWorkerMessagePort,
8380
8398
  'MainArea.handleUriChange': wrapSerialCommand(handleUriChange),
8381
8399
  'MainArea.handleWorkspaceChange': wrapSerialCommand(handleWorkspaceChange),
8382
8400
  'MainArea.handleWorkspaceRefresh': wrapAsyncCommand(handleWorkspaceRefreshWithContext),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.46.0",
3
+ "version": "9.48.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",