@lvce-editor/main-area-worker 9.60.0 → 9.62.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.
@@ -1430,55 +1430,55 @@ const SetPatches = 'Viewlet.setPatches';
1430
1430
  const FocusEditorText = 12;
1431
1431
 
1432
1432
  const {
1433
- invoke: invoke$6,
1433
+ invoke: invoke$7,
1434
1434
  set: set$7
1435
1435
  } = create$3(ClipBoardWorker);
1436
1436
  const writeText = async text => {
1437
- return invoke$6('ClipBoard.writeText', text);
1437
+ return invoke$7('ClipBoard.writeText', text);
1438
1438
  };
1439
1439
 
1440
1440
  const {
1441
- invoke: invoke$5,
1441
+ invoke: invoke$6,
1442
1442
  set: set$6
1443
1443
  } = create$3(DialogWorker);
1444
1444
 
1445
1445
  const {
1446
- invoke: invoke$4,
1446
+ invoke: invoke$5,
1447
1447
  set: set$5
1448
1448
  } = create$3(DragAndDropWorker);
1449
1449
  const getDroppedUrisByDropId = async (dropId, isElectron) => {
1450
- return invoke$4('DragAndDrop.getDroppedUrisByDropId', dropId, isElectron);
1450
+ return invoke$5('DragAndDrop.getDroppedUrisByDropId', dropId, isElectron);
1451
1451
  };
1452
1452
 
1453
1453
  const {
1454
- invoke: invoke$3,
1454
+ invoke: invoke$4,
1455
1455
  set: set$4
1456
1456
  } = create$3(IconThemeWorker);
1457
1457
  const getIcons = async iconRequests => {
1458
1458
  // @ts-ignore
1459
- return invoke$3('IconTheme.getIcons', iconRequests);
1459
+ return invoke$4('IconTheme.getIcons', iconRequests);
1460
1460
  };
1461
1461
 
1462
1462
  const {
1463
- invoke: invoke$2,
1463
+ invoke: invoke$3,
1464
1464
  invokeAndTransfer: invokeAndTransfer$2,
1465
1465
  set: set$3
1466
1466
  } = create$3(RendererProcess);
1467
1467
 
1468
1468
  const {
1469
- invoke: invoke$1,
1469
+ invoke: invoke$2,
1470
1470
  invokeAndTransfer: invokeAndTransfer$1,
1471
1471
  set: set$2
1472
1472
  } = create$3(RendererWorker);
1473
1473
  const handleModifiedStatusChange$1 = async (uri, modified) => {
1474
- return invoke$1('Main.handleModifiedStatusChange', uri, modified);
1474
+ return invoke$2('Main.handleModifiedStatusChange', uri, modified);
1475
1475
  };
1476
1476
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1477
1477
  number(uid);
1478
1478
  number(menuId);
1479
1479
  number(x);
1480
1480
  number(y);
1481
- await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1481
+ await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
1482
1482
  };
1483
1483
  const sendMessagePortToClipBoardWorker$1 = async (port, rpcId) => {
1484
1484
  const command = 'ClipBoard.handleMessagePort';
@@ -1493,14 +1493,14 @@ const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1493
1493
  await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1494
1494
  };
1495
1495
  const readFile = async uri => {
1496
- return invoke$1('FileSystem.readFile', uri);
1496
+ return invoke$2('FileSystem.readFile', uri);
1497
1497
  };
1498
1498
  const confirm$1 = async (message, options) => {
1499
- const result = await invoke$1('ConfirmPrompt.prompt', message, options);
1499
+ const result = await invoke$2('ConfirmPrompt.prompt', message, options);
1500
1500
  return result;
1501
1501
  };
1502
1502
  const getPreference = async key => {
1503
- return await invoke$1('Preferences.get', key);
1503
+ return await invoke$2('Preferences.get', key);
1504
1504
  };
1505
1505
 
1506
1506
  const maxClosedTabs = 20;
@@ -1536,7 +1536,7 @@ const isClosedTabEntry = value => {
1536
1536
  return Boolean(entry.group && typeof entry.group === 'object' && entry.tab && typeof entry.tab === 'object' && typeof entry.groupIndex === 'number' && typeof entry.tabIndex === 'number');
1537
1537
  };
1538
1538
  const getEntries = async key => {
1539
- const entries = await invoke$1('CacheStorage.getJson', key);
1539
+ const entries = await invoke$2('CacheStorage.getJson', key);
1540
1540
  return Array.isArray(entries) ? entries.filter(isClosedTabEntry) : [];
1541
1541
  };
1542
1542
  const compact = entry => {
@@ -1557,7 +1557,7 @@ const add = (uid, entries) => {
1557
1557
  const key = getKey(uid);
1558
1558
  const existing = await getEntries(key);
1559
1559
  const compactEntries = entries.map(compact);
1560
- await invoke$1('CacheStorage.setJson', key, [...existing, ...compactEntries].slice(-maxClosedTabs));
1560
+ await invoke$2('CacheStorage.setJson', key, [...existing, ...compactEntries].slice(-maxClosedTabs));
1561
1561
  } catch {
1562
1562
  // Closed tab history is optional and must never break editor commands.
1563
1563
  }
@@ -1566,7 +1566,7 @@ const add = (uid, entries) => {
1566
1566
  const clear = uid => {
1567
1567
  return run(uid, async () => {
1568
1568
  try {
1569
- await invoke$1('CacheStorage.setJson', getKey(uid), []);
1569
+ await invoke$2('CacheStorage.setJson', getKey(uid), []);
1570
1570
  } catch {
1571
1571
  // Closed tab history is optional and must never break workspace changes.
1572
1572
  }
@@ -1581,7 +1581,7 @@ const takeLast = uid => {
1581
1581
  if (!isClosedTabEntry(entry)) {
1582
1582
  return undefined;
1583
1583
  }
1584
- await invoke$1('CacheStorage.setJson', key, entries.slice(0, -1));
1584
+ await invoke$2('CacheStorage.setJson', key, entries.slice(0, -1));
1585
1585
  return entry;
1586
1586
  } catch {
1587
1587
  return undefined;
@@ -1714,26 +1714,30 @@ const closeTab = (state, groupId, tabId) => {
1714
1714
  const handleAttach = async command => {
1715
1715
  // TODO find a better way to append editors
1716
1716
  const parentNodeSelector = '.editor-groups-container, .EditorGroup';
1717
- await invoke$1('Layout.attachViewlet', parentNodeSelector, command.instanceId);
1717
+ await invoke$2('Layout.attachViewlet', parentNodeSelector, command.instanceId);
1718
+ };
1719
+
1720
+ const invoke$1 = async (applicationId, method, ...args) => {
1721
+ return applicationId === undefined ? invoke$2(method, ...args) : invoke$2('Application.execute', applicationId, method, ...args);
1718
1722
  };
1719
1723
 
1720
1724
  const getViewletTitle = async editorUid => {
1721
1725
  try {
1722
- const title = await invoke$1('Viewlet.getTitle', editorUid);
1726
+ const title = await invoke$2('Viewlet.getTitle', editorUid);
1723
1727
  return typeof title === 'string' && title ? title : undefined;
1724
1728
  } catch {
1725
1729
  return undefined;
1726
1730
  }
1727
1731
  };
1728
- const createViewletContent = async (viewletModuleId, editorUid, tabId, bounds, uri, args) => {
1732
+ const createViewletContent = async (viewletModuleId, editorUid, tabId, bounds, uri, args, applicationId) => {
1729
1733
  if (args === undefined) {
1730
- await invoke$1('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
1734
+ await invoke$1(applicationId, 'Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
1731
1735
  } else {
1732
- await invoke$1('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri, args);
1736
+ await invoke$1(applicationId, 'Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri, args);
1733
1737
  }
1734
1738
  };
1735
- const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri, args) => {
1736
- await createViewletContent(viewletModuleId, editorUid, tabId, bounds, uri, args);
1739
+ const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri, args, applicationId) => {
1740
+ await createViewletContent(viewletModuleId, editorUid, tabId, bounds, uri, args, applicationId);
1737
1741
  return getViewletTitle(editorUid);
1738
1742
  };
1739
1743
 
@@ -1766,7 +1770,7 @@ const notifyActiveEditorChange = async (oldState, newState) => {
1766
1770
  return;
1767
1771
  }
1768
1772
  try {
1769
- await invoke$1('Layout.handleActiveEditorChange', newUri);
1773
+ await invoke$1(newState.applicationId, 'Layout.handleActiveEditorChange', newUri);
1770
1774
  } catch (error) {
1771
1775
  console.warn('Failed to notify viewlets about active editor change', error);
1772
1776
  }
@@ -1793,7 +1797,7 @@ const notifyMountedViewlets = async (oldState, newState) => {
1793
1797
  return;
1794
1798
  }
1795
1799
  try {
1796
- await invoke$1('Layout.setMountedViewlets', newState.uid, newViewletUids);
1800
+ await invoke$1(newState.applicationId, 'Layout.setMountedViewlets', newState.uid, newViewletUids);
1797
1801
  } catch (error) {
1798
1802
  console.warn('Failed to publish mounted viewlets', error);
1799
1803
  }
@@ -2092,7 +2096,10 @@ const disposeViewletForTab = (state, tabId) => {
2092
2096
  const handleCreate = async command => {
2093
2097
  // Safe to call - no visible side effects
2094
2098
 
2095
- const title = await createViewlet(command.viewletModuleId, command.editorUid, command.tabId, command.bounds, command.uri || '');
2099
+ const {
2100
+ applicationId
2101
+ } = get$1(command.uid).newState;
2102
+ const title = await createViewlet(command.viewletModuleId, command.editorUid, command.tabId, command.bounds, command.uri || '', undefined, applicationId);
2096
2103
 
2097
2104
  // After viewlet is created, mark it as ready
2098
2105
  // Attachment is handled automatically by virtual DOM reference nodes
@@ -2108,17 +2115,17 @@ const handleCreate = async command => {
2108
2115
  const handleDetach = async command => {
2109
2116
  // Hides viewlet but keeps it alive
2110
2117
 
2111
- await invoke$1('Viewlet.detach', command.instanceId);
2118
+ await invoke$2('Viewlet.detach', command.instanceId);
2112
2119
  };
2113
2120
 
2114
2121
  const handleDispose = async command => {
2115
2122
  // Fully destroys viewlet
2116
2123
 
2117
- await invoke$1('Viewlet.dispose', command.instanceId);
2124
+ await invoke$2('Viewlet.dispose', command.instanceId);
2118
2125
  };
2119
2126
 
2120
2127
  const handleSetBounds = async command => {
2121
- await invoke$1('Viewlet.setBounds', command.instanceId, command.bounds);
2128
+ await invoke$2('Viewlet.setBounds', command.instanceId, command.bounds);
2122
2129
  };
2123
2130
 
2124
2131
  const executeViewletCommand = async command => {
@@ -2202,7 +2209,7 @@ const closeTabWithViewlet = async (state, groupId, tabId) => {
2202
2209
  };
2203
2210
 
2204
2211
  const saveEditor = async editorUid => {
2205
- return invoke$1('Editor.save', editorUid);
2212
+ return invoke$2('Editor.save', editorUid);
2206
2213
  };
2207
2214
 
2208
2215
  const confirm = async (message, options) => {
@@ -2213,7 +2220,7 @@ const confirm = async (message, options) => {
2213
2220
  if (!errorMessage.includes('ConfirmPrompt.prompt') || !errorMessage.includes('not found')) {
2214
2221
  throw error;
2215
2222
  }
2216
- return invoke$5('ConfirmPrompt.prompt', message, options);
2223
+ return invoke$6('ConfirmPrompt.prompt', message, options);
2217
2224
  }
2218
2225
  };
2219
2226
  const promptSave = async title => {
@@ -2293,7 +2300,7 @@ const disposeEditors = async editorUids => {
2293
2300
  // Dispose all child viewlets in the renderer worker
2294
2301
  for (const editorUid of editorUids) {
2295
2302
  try {
2296
- await invoke$1('Viewlet.dispose', editorUid);
2303
+ await invoke$2('Viewlet.dispose', editorUid);
2297
2304
  } catch {
2298
2305
  // Silently ignore errors during disposal
2299
2306
  // Viewlet may already be disposed or renderer worker may not be available
@@ -2604,7 +2611,7 @@ const copyIntoNewWindow$1 = async state => {
2604
2611
  if (!tab?.uri) {
2605
2612
  return state;
2606
2613
  }
2607
- await invoke$1('ElectronWindow.openNewWithUri', tab.uri);
2614
+ await invoke$2('ElectronWindow.openNewWithUri', tab.uri);
2608
2615
  return state;
2609
2616
  };
2610
2617
 
@@ -2616,7 +2623,7 @@ const copyPath$1 = async (state, path) => {
2616
2623
 
2617
2624
  const copyRelativePath$1 = async (state, path) => {
2618
2625
  string(path);
2619
- const relativePath = await invoke$1('Workspace.pathBaseName', path);
2626
+ const relativePath = await invoke$1(state.applicationId, 'Workspace.pathBaseName', path);
2620
2627
  await writeText(relativePath);
2621
2628
  return state;
2622
2629
  };
@@ -2639,8 +2646,11 @@ const normalizeLayoutDirection = direction => {
2639
2646
  return undefined;
2640
2647
  };
2641
2648
 
2642
- const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight = 35) => {
2649
+ const create$1 = (uid, uri, x, y, width, height, platform, assetDir, tabHeight = 35, applicationId) => {
2643
2650
  const state = {
2651
+ ...(applicationId !== undefined && {
2652
+ applicationId
2653
+ }),
2644
2654
  assetDir,
2645
2655
  fileIconCache: {},
2646
2656
  height,
@@ -2750,7 +2760,7 @@ const isConnected = () => {
2750
2760
  return connected;
2751
2761
  };
2752
2762
  const invoke = (method, ...params) => {
2753
- return invoke$2(method, ...params);
2763
+ return invoke$3(method, ...params);
2754
2764
  };
2755
2765
  const invokeAndTransfer = (method, ...params) => {
2756
2766
  return invokeAndTransfer$2(method, ...params);
@@ -2770,7 +2780,7 @@ const focus = async state => {
2770
2780
  await invoke('Viewlet.focusSelector', editorUid, '[name="editor"]');
2771
2781
  await invoke('Viewlet.focusSelectorAfterRender', editorUid, '[name="editor"]');
2772
2782
  } else {
2773
- await invoke$1('Viewlet.focusSelector', editorUid, '[name="editor"]');
2783
+ await invoke$2('Viewlet.focusSelector', editorUid, '[name="editor"]');
2774
2784
  }
2775
2785
  return state;
2776
2786
  };
@@ -3176,11 +3186,11 @@ const getSelectedTabBounds = (state, groupId = state.layout.activeGroupId) => {
3176
3186
  };
3177
3187
  };
3178
3188
 
3179
- const getViewletModuleId$1 = async (uri, opener) => {
3189
+ const getViewletModuleId$1 = async (uri, opener, applicationId) => {
3180
3190
  // Query RendererWorker for viewlet module ID (optional, may fail in tests)
3181
3191
  let viewletModuleId;
3182
3192
  try {
3183
- viewletModuleId = opener === undefined ? await invoke$1('Layout.getModuleId', uri) : await invoke$1('Layout.getModuleId', uri, opener);
3193
+ viewletModuleId = opener === undefined ? await invoke$1(applicationId, 'Layout.getModuleId', uri) : await invoke$1(applicationId, 'Layout.getModuleId', uri, opener);
3184
3194
  } catch {
3185
3195
  // Viewlet creation is optional - silently ignore if RendererWorker isn't available
3186
3196
  }
@@ -3194,31 +3204,31 @@ const ProcessExplorer = 'ProcessExplorer';
3194
3204
  const RunningExtensions = 'RunningExtensions';
3195
3205
  const QuickPick = 'QuickPick';
3196
3206
 
3197
- const getViewletModuleIdForEditorInput = async editorInput => {
3207
+ const getViewletModuleIdForEditorInput = async (editorInput, applicationId) => {
3198
3208
  switch (editorInput.type) {
3199
3209
  case 'binary':
3200
3210
  return undefined;
3201
3211
  case 'diff-editor':
3202
3212
  return DiffEditor;
3203
3213
  case 'editor':
3204
- return editorInput.forceText ? EditorText : getViewletModuleId$1(editorInput.uri);
3214
+ return editorInput.forceText ? EditorText : getViewletModuleId$1(editorInput.uri, undefined, applicationId);
3205
3215
  case 'extension-detail-view':
3206
3216
  return ExtensionDetail;
3207
3217
  case 'image':
3208
3218
  case 'video':
3209
- return getViewletModuleId$1(editorInput.uri);
3219
+ return getViewletModuleId$1(editorInput.uri, undefined, applicationId);
3210
3220
  case 'process-explorer':
3211
3221
  return ProcessExplorer;
3212
3222
  case 'running-extensions':
3213
3223
  return RunningExtensions;
3214
3224
  case 'webview':
3215
- return getViewletModuleId$1(editorInput.uri, editorInput.providerId);
3225
+ return getViewletModuleId$1(editorInput.uri, editorInput.providerId, applicationId);
3216
3226
  }
3217
3227
  };
3218
3228
 
3219
- const getViewletModuleId = async tab => {
3229
+ const getViewletModuleId = async (tab, applicationId) => {
3220
3230
  const normalizedTab = normalizeTabEditorInput(tab);
3221
- return normalizedTab.editorInput ? getViewletModuleIdForEditorInput(normalizedTab.editorInput) : invoke$1('Layout.getModuleId', normalizedTab.uri);
3231
+ return normalizedTab.editorInput ? getViewletModuleIdForEditorInput(normalizedTab.editorInput, applicationId) : invoke$1(applicationId, 'Layout.getModuleId', normalizedTab.uri);
3222
3232
  };
3223
3233
 
3224
3234
  const startContentLoading = async (oldState, state, tabId, path, requestId) => {
@@ -3254,7 +3264,7 @@ const maybeCreateViewletForSelectedTab = async (state, newState, groupIndex, ind
3254
3264
  if (!shouldCreateViewletForSelectedTab(selectedTab)) {
3255
3265
  return undefined;
3256
3266
  }
3257
- const viewletModuleId = await getViewletModuleId(selectedTab);
3267
+ const viewletModuleId = await getViewletModuleId(selectedTab, state.applicationId);
3258
3268
  if (!viewletModuleId) {
3259
3269
  return undefined;
3260
3270
  }
@@ -3270,7 +3280,7 @@ const maybeCreateViewletForSelectedTab = async (state, newState, groupIndex, ind
3270
3280
  editorUid
3271
3281
  } = tabWithViewlet.tab;
3272
3282
  if (editorUid !== -1 && selectedTab.uri) {
3273
- const title = await createViewlet(viewletModuleId, editorUid, tabId, bounds, selectedTab.uri);
3283
+ const title = await createViewlet(viewletModuleId, editorUid, tabId, bounds, selectedTab.uri, undefined, state.applicationId);
3274
3284
  stateWithViewlet = handleViewletReady(stateWithViewlet, editorUid, title);
3275
3285
  set$1(uid, state, stateWithViewlet);
3276
3286
  }
@@ -4732,10 +4742,21 @@ const handleClickTogglePreview = async state => {
4732
4742
  if (!activeTabInfo || !activeTabInfo.tab.uri) {
4733
4743
  return state;
4734
4744
  }
4735
- await invoke$1('Layout.showPreview', activeTabInfo.tab.uri);
4745
+ await invoke$1(state.applicationId, 'Layout.showPreview', activeTabInfo.tab.uri);
4736
4746
  return state;
4737
4747
  };
4738
4748
 
4749
+ const applyInitialCursorPosition = async (state, tabId, position) => {
4750
+ if (!position) {
4751
+ return;
4752
+ }
4753
+ const tab = findTabById(state, tabId)?.tab;
4754
+ if (!tab || tab.editorUid < 0 || tab.loadingState !== 'loaded' || tab.editorInput?.type !== 'editor') {
4755
+ return;
4756
+ }
4757
+ await invoke$1(state.applicationId, 'Viewlet.executeViewletCommand', tab.editorUid, 'cursorSet', position.rowIndex, position.columnIndex);
4758
+ };
4759
+
4739
4760
  const findTabByUri = (state, uri) => {
4740
4761
  const {
4741
4762
  layout
@@ -4939,12 +4960,12 @@ const getMaxFileSize = async () => {
4939
4960
  }
4940
4961
  return defaultMaxFileSizeMb * bytesPerMegabyte;
4941
4962
  };
4942
- const getLargeFileSize = async (editorInput, forceOpen = false) => {
4963
+ const getLargeFileSize = async (editorInput, forceOpen = false, applicationId) => {
4943
4964
  if (editorInput.type !== 'editor' || forceOpen || !editorInput.uri.startsWith('file://')) {
4944
4965
  return undefined;
4945
4966
  }
4946
4967
  try {
4947
- const [fileSize, maxFileSize] = await Promise.all([invoke$1('FileSystem.getFileSize', editorInput.uri), getMaxFileSize()]);
4968
+ const [fileSize, maxFileSize] = await Promise.all([invoke$1(applicationId, 'FileSystem.getFileSize', editorInput.uri), getMaxFileSize()]);
4948
4969
  return typeof fileSize === 'number' && fileSize > maxFileSize ? fileSize : undefined;
4949
4970
  } catch {
4950
4971
  // File systems without stat support should retain the existing open behavior.
@@ -5199,12 +5220,12 @@ const shouldCheckDirectoryEditorInput = editorInput => {
5199
5220
  return baseName.endsWith('/') || baseName !== '' && !baseName.includes('.');
5200
5221
  };
5201
5222
 
5202
- const isDirectoryEditorInput = async editorInput => {
5223
+ const isDirectoryEditorInput = async (editorInput, applicationId) => {
5203
5224
  if (!shouldCheckDirectoryEditorInput(editorInput)) {
5204
5225
  return false;
5205
5226
  }
5206
5227
  try {
5207
- const type = await invoke$1('FileSystem.stat', editorInput.uri);
5228
+ const type = await invoke$1(applicationId, 'FileSystem.stat', editorInput.uri);
5208
5229
  return type === Directory;
5209
5230
  } catch {
5210
5231
  return false;
@@ -5366,9 +5387,9 @@ const updateTabIcon = async (context, readyState, tabId) => {
5366
5387
  }
5367
5388
  };
5368
5389
 
5369
- const renderMainAreaPending = async uid => {
5390
+ const renderMainAreaPending = async (uid, applicationId) => {
5370
5391
  try {
5371
- await invoke$1('Layout.renderMainAreaPending', uid);
5392
+ await invoke$1(applicationId, 'Layout.renderMainAreaPending', uid);
5372
5393
  } catch {
5373
5394
  // Older renderer workers render the final state when openInput completes.
5374
5395
  }
@@ -5419,7 +5440,8 @@ const openInputWithContext = async (context, options) => {
5419
5440
  if (existingTab && !shouldRetry) {
5420
5441
  const switchedState = getExistingTabState(currentState, existingTab, preview);
5421
5442
  await context.updateState(() => switchedState);
5422
- await focusIfRequested(switchedState, options.focus);
5443
+ await applyInitialCursorPosition(switchedState, existingTab.tab.id, options.initialCursorPosition);
5444
+ await focusIfRequested(context.getState(), options.focus);
5423
5445
  return;
5424
5446
  }
5425
5447
  const replacedEditorUid = getActivePreviewEditorUid(currentState);
@@ -5432,7 +5454,7 @@ const openInputWithContext = async (context, options) => {
5432
5454
  if (replacedEditorUid !== -1) {
5433
5455
  await disposeEditors([replacedEditorUid]);
5434
5456
  }
5435
- if (await isDirectoryEditorInput(editorInput)) {
5457
+ if (await isDirectoryEditorInput(editorInput, state.applicationId)) {
5436
5458
  const latestState = context.getState();
5437
5459
  const errorState = updateTab(latestState, tabId, {
5438
5460
  errorMessage: 'Expected a file but received a folder',
@@ -5450,7 +5472,7 @@ const openInputWithContext = async (context, options) => {
5450
5472
  await context.updateState(() => binaryState);
5451
5473
  return;
5452
5474
  }
5453
- const fileSize = await getLargeFileSize(editorInput, options.forceOpen === true);
5475
+ const fileSize = await getLargeFileSize(editorInput, options.forceOpen === true, state.applicationId);
5454
5476
  if (fileSize !== undefined) {
5455
5477
  const latestState = context.getState();
5456
5478
  const largeFileState = updateTab(latestState, tabId, {
@@ -5462,7 +5484,7 @@ const openInputWithContext = async (context, options) => {
5462
5484
  return;
5463
5485
  }
5464
5486
  try {
5465
- const viewletModuleId = await getViewletModuleIdForEditorInput(editorInput);
5487
+ const viewletModuleId = await getViewletModuleIdForEditorInput(editorInput, state.applicationId);
5466
5488
  const stateAfterModuleId = context.getState();
5467
5489
  if (!viewletModuleId) {
5468
5490
  const unsupportedState = updateTab(stateAfterModuleId, tabId, {
@@ -5491,11 +5513,12 @@ const openInputWithContext = async (context, options) => {
5491
5513
  if (editorUid === -1) {
5492
5514
  throw new Error('invalid editorUid');
5493
5515
  }
5494
- await createViewletContent(viewletModuleId, editorUid, tabId, bounds, uri, options.args);
5516
+ await createViewletContent(viewletModuleId, editorUid, tabId, bounds, uri, options.args, state.applicationId);
5495
5517
  const latestState = context.getState();
5496
5518
  let readyState = handleViewletReady(latestState, editorUid);
5497
5519
  await context.updateState(() => readyState);
5498
- await renderMainAreaPending(state.uid);
5520
+ await renderMainAreaPending(state.uid, state.applicationId);
5521
+ await applyInitialCursorPosition(context.getState(), tabId, options.initialCursorPosition);
5499
5522
  await focusIfRequested(context.getState(), options.focus);
5500
5523
  const renderedTitle = await getViewletTitle(editorUid);
5501
5524
  if (renderedTitle) {
@@ -5580,7 +5603,7 @@ const getViewletContext = (options, viewletContext) => {
5580
5603
  if (viewletContext !== undefined || typeof options === 'string') {
5581
5604
  return viewletContext;
5582
5605
  }
5583
- const context = Object.fromEntries(Object.entries(options).filter(([key]) => key !== 'focus' && key !== 'preview' && key !== 'reuseExisting' && key !== 'uri'));
5606
+ const context = Object.fromEntries(Object.entries(options).filter(([key]) => key !== 'focus' && key !== 'initialCursorPosition' && key !== 'shouldFocus' && key !== 'preview' && key !== 'reuseExisting' && key !== 'uri'));
5584
5607
  return Object.keys(context).length === 0 ? undefined : context;
5585
5608
  };
5586
5609
  const getOpenInputOptions = (options, focus = true, viewletContext) => {
@@ -5593,7 +5616,10 @@ const getOpenInputOptions = (options, focus = true, viewletContext) => {
5593
5616
  args: [context]
5594
5617
  }),
5595
5618
  editorInput: getNormalizedOpenEditorInput(uri),
5596
- focus: typeof options === 'string' ? focus : options.focus,
5619
+ focus: typeof options === 'string' ? focus : options.shouldFocus ?? options.focus ?? true,
5620
+ ...(typeof options !== 'string' && options.initialCursorPosition && {
5621
+ initialCursorPosition: options.initialCursorPosition
5622
+ }),
5597
5623
  preview,
5598
5624
  reuseExisting
5599
5625
  };
@@ -6521,10 +6547,10 @@ const applyDropAction = async (context, action, splitDirection, targetGroupId) =
6521
6547
  break;
6522
6548
  }
6523
6549
  case 'setPath':
6524
- void invoke$1('Workspace.setPath', action.value).catch(() => {});
6550
+ void invoke$1(context.getState().applicationId, 'Workspace.setPath', action.value).catch(() => {});
6525
6551
  break;
6526
6552
  case 'setUri':
6527
- void invoke$1('Workspace.setUri', action.value).catch(() => {});
6553
+ void invoke$1(context.getState().applicationId, 'Workspace.setUri', action.value).catch(() => {});
6528
6554
  break;
6529
6555
  }
6530
6556
  };
@@ -6628,12 +6654,12 @@ const applyTabDrop = (state, sourceGroupId, tabId, splitDirection, targetGroupId
6628
6654
  return moveTabToGroup(splitState, sourceGroupId, splitState.layout.activeGroupId, tabId);
6629
6655
  };
6630
6656
 
6631
- const getDropAction = async uris => {
6657
+ const getDropAction = async (uris, applicationId) => {
6632
6658
  for (const uri of uris) {
6633
6659
  if (uri.endsWith('/') || (await isDirectoryEditorInput({
6634
6660
  type: 'editor',
6635
6661
  uri
6636
- }))) {
6662
+ }, applicationId))) {
6637
6663
  if (uri.includes('://')) {
6638
6664
  return {
6639
6665
  command: 'setUri',
@@ -6682,7 +6708,7 @@ const handleDrop = async (context, dropId) => {
6682
6708
  await context.updateState(state => resetPointerDown(applyTabDrop(state, sourceGroup.id, draggedTab.id, splitDirection, tabTargetGroupId, tabTargetIndex)));
6683
6709
  return;
6684
6710
  }
6685
- const actions = await getDropAction(uris);
6711
+ const actions = await getDropAction(uris, initialState.applicationId);
6686
6712
  await applyDropAction(context, actions, splitDirection, targetGroupId);
6687
6713
  };
6688
6714
 
@@ -6779,7 +6805,7 @@ const newFile = async state => {
6779
6805
  if (actualEditorUid === -1) {
6780
6806
  throw new Error(`invalid editorUid`);
6781
6807
  }
6782
- const title = await createViewlet(viewletModuleId, actualEditorUid, tabId, bounds, newTab.uri || '');
6808
+ const title = await createViewlet(viewletModuleId, actualEditorUid, tabId, bounds, newTab.uri || '', undefined, state.applicationId);
6783
6809
 
6784
6810
  // After viewlet is created, get the latest state and mark it as ready
6785
6811
  const {
@@ -6881,7 +6907,7 @@ const handleMessagePort = async (port, viewletCommandMap, setAsRendererProcessFa
6881
6907
  throw new TypeError(`Viewlet command not found: ${command}`);
6882
6908
  }
6883
6909
  await fn(uid, ...args);
6884
- await invoke$1('Viewlet.requestRender', uid);
6910
+ await invoke$2('Viewlet.requestRender', uid);
6885
6911
  };
6886
6912
  const rpc = await create$8({
6887
6913
  commandMap: {
@@ -6930,7 +6956,7 @@ const handleModifiedStatusChangeWithContext = async (context, uri, newStatus) =>
6930
6956
 
6931
6957
  const resizeChild = async (editorUid, dimensions) => {
6932
6958
  try {
6933
- return await invoke$1('Viewlet.resize', editorUid, dimensions);
6959
+ return await invoke$2('Viewlet.resize', editorUid, dimensions);
6934
6960
  } catch {
6935
6961
  return [];
6936
6962
  }
@@ -7272,7 +7298,7 @@ const focusTab = async (state, groupIndex, index) => {
7272
7298
  if (isConnected()) {
7273
7299
  await invoke('Viewlet.focusSelector', state.uid, selector);
7274
7300
  } else {
7275
- await invoke$1('Viewlet.focusSelector', state.uid, selector);
7301
+ await invoke$2('Viewlet.focusSelector', state.uid, selector);
7276
7302
  }
7277
7303
  };
7278
7304
  const handleTabKeyDown = async (state, groupIndexRaw, indexRaw, key) => {
@@ -7319,7 +7345,7 @@ const handleTabsWheel = async (state, groupIndexRaw, deltaMode, deltaY) => {
7319
7345
  if (isConnected()) {
7320
7346
  await invoke('Viewlet.scrollSelectorBy', state.uid, selector, pixelDelta);
7321
7347
  } else {
7322
- await invoke$1('Viewlet.scrollSelectorBy', state.uid, selector, pixelDelta);
7348
+ await invoke$2('Viewlet.scrollSelectorBy', state.uid, selector, pixelDelta);
7323
7349
  }
7324
7350
  return state;
7325
7351
  };
@@ -7346,7 +7372,7 @@ const handleUriChange = async (state, oldUri, newUri) => {
7346
7372
  }
7347
7373
  if (renamedUri) {
7348
7374
  if (tab.editorInput?.type === 'editor' && tab.editorUid !== -1) {
7349
- editorUriUpdates.push(invoke$1('Editor.handleUriChange', tab.editorUid, renamedUri));
7375
+ editorUriUpdates.push(invoke$2('Editor.handleUriChange', tab.editorUid, renamedUri));
7350
7376
  }
7351
7377
  const editorInput = tab.editorInput && 'uri' in tab.editorInput ? {
7352
7378
  ...tab.editorInput,
@@ -7401,9 +7427,9 @@ const toFileUri = path => {
7401
7427
  }
7402
7428
  return path;
7403
7429
  };
7404
- const loadHomeDirUri = async () => {
7430
+ const loadHomeDirUri = async applicationId => {
7405
7431
  try {
7406
- const homeDir = await invoke$1('Workspace.getHomeDir');
7432
+ const homeDir = await invoke$1(applicationId, 'Workspace.getHomeDir');
7407
7433
  return typeof homeDir === 'string' ? toFileUri(homeDir) : '';
7408
7434
  } catch {
7409
7435
  return '';
@@ -7517,7 +7543,7 @@ const createViewlets = async (state, viewletModuleIds) => {
7517
7543
  const editorUid = activeTab.editorUid === -1 ? create$2() : activeTab.editorUid;
7518
7544
  editorUids[activeTab.id] = editorUid;
7519
7545
  const bounds = getSelectedTabBounds(state, group.id);
7520
- const title = await createViewlet(viewletModuleIds[activeTab.id], editorUid, activeTab.id, bounds, activeTab.uri || '');
7546
+ const title = await createViewlet(viewletModuleIds[activeTab.id], editorUid, activeTab.id, bounds, activeTab.uri || '', undefined, state.applicationId);
7521
7547
  if (title) {
7522
7548
  titles[activeTab.id] = title;
7523
7549
  }
@@ -7529,7 +7555,7 @@ const createViewlets = async (state, viewletModuleIds) => {
7529
7555
  };
7530
7556
  };
7531
7557
 
7532
- const getViewletModuleIds = async layout => {
7558
+ const getViewletModuleIds = async (layout, applicationId) => {
7533
7559
  const {
7534
7560
  groups
7535
7561
  } = layout;
@@ -7545,7 +7571,7 @@ const getViewletModuleIds = async layout => {
7545
7571
  editorInput,
7546
7572
  uri
7547
7573
  } = normalizedTab;
7548
- const viewletModuleId = normalizedTab.editorInput ? await getViewletModuleIdForEditorInput(editorInput) : await getViewletModuleId$1(uri);
7574
+ const viewletModuleId = normalizedTab.editorInput ? await getViewletModuleIdForEditorInput(editorInput, applicationId) : await getViewletModuleId$1(uri, undefined, applicationId);
7549
7575
  if (viewletModuleId) {
7550
7576
  viewletModuleIds[activeTab.id] = viewletModuleId;
7551
7577
  }
@@ -7597,7 +7623,7 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
7597
7623
  };
7598
7624
 
7599
7625
  // Get viewlet module IDs for all active tabs
7600
- const viewletModuleIds = await getViewletModuleIds(newState.layout);
7626
+ const viewletModuleIds = await getViewletModuleIds(newState.layout, state.applicationId);
7601
7627
 
7602
7628
  // Create viewlets and get editor UIDs
7603
7629
  const {
@@ -7622,7 +7648,7 @@ const restoreAndCreateEditors = async (state, restoredLayout) => {
7622
7648
  };
7623
7649
 
7624
7650
  const loadContent$1 = async (state, savedState) => {
7625
- const homeDirUri = await loadHomeDirUri();
7651
+ const homeDirUri = await loadHomeDirUri(state.applicationId);
7626
7652
  const stateWithHomeDir = {
7627
7653
  ...state,
7628
7654
  homeDirUri
@@ -7700,7 +7726,7 @@ const reloadChangedEditors = async (state, changed) => {
7700
7726
  }
7701
7727
  }
7702
7728
  }
7703
- await Promise.allSettled(Array.from(editorUids, editorUid => invoke$1('Viewlet.reload', editorUid)));
7729
+ await Promise.allSettled(Array.from(editorUids, editorUid => invoke$2('Viewlet.reload', editorUid)));
7704
7730
  };
7705
7731
  const handleWorkspaceRefresh = async (state, refresh = {}) => {
7706
7732
  const changes = Array.isArray(refresh) ? {
@@ -8007,12 +8033,12 @@ const moveIntoNewWindow = async state => {
8007
8033
  if (!tab?.uri) {
8008
8034
  return state;
8009
8035
  }
8010
- await invoke$1('ElectronWindow.openNewWithUri', tab.uri);
8036
+ await invoke$2('ElectronWindow.openNewWithUri', tab.uri);
8011
8037
  return closeTabAndSave(state, group.id, activeTabId);
8012
8038
  };
8013
8039
 
8014
8040
  const newWindow = async state => {
8015
- await invoke$1('ElectronWindow.openNew');
8041
+ await invoke$2('ElectronWindow.openNew');
8016
8042
  return state;
8017
8043
  };
8018
8044
 
@@ -8237,7 +8263,7 @@ const renderPendingViewletUpdate = (oldState, newState) => {
8237
8263
  const update = newState.pendingViewletUpdate;
8238
8264
  newState.pendingViewletUpdate = undefined;
8239
8265
  setTimeout(() => {
8240
- void invoke$1('Viewlet.dispose', update.disposal).catch(() => {});
8266
+ void invoke$2('Viewlet.dispose', update.disposal).catch(() => {});
8241
8267
  }, 50);
8242
8268
  return update.focus === undefined ? [] : ['Viewlet.setFocusContext', update.focus, FocusEditorText, 0, update.focus, 'Editor'];
8243
8269
  };
@@ -8387,9 +8413,9 @@ const textEditorEntry = {
8387
8413
  label: 'Text Editor',
8388
8414
  type: 'editor'
8389
8415
  };
8390
- const getViewProviderEntries = async uri => {
8416
+ const getViewProviderEntries = async (uri, applicationId) => {
8391
8417
  try {
8392
- const providers = await invoke$1('WebView.getEditorProviders');
8418
+ const providers = await invoke$1(applicationId, 'WebView.getEditorProviders');
8393
8419
  const matchingProviders = providers.filter(provider => provider?.id && provider.selector?.some(selector => uri.endsWith(selector)));
8394
8420
  return [textEditorEntry, ...matchingProviders.map(provider => {
8395
8421
  const titleElement = provider.elements?.find(element => element.type === 'title');
@@ -8418,13 +8444,13 @@ const reopenEditorWith = async (context, preferredEditorId) => {
8418
8444
  if (preferredEditorId === textEditorEntry.id) {
8419
8445
  selected = textEditorEntry;
8420
8446
  } else {
8421
- const entries = await getViewProviderEntries(initialTab.uri);
8447
+ const entries = await getViewProviderEntries(initialTab.uri, initialState.applicationId);
8422
8448
  const items = entries.map(entry => ({
8423
8449
  description: '',
8424
8450
  label: entry.label,
8425
8451
  value: entry
8426
8452
  }));
8427
- selected = await invoke$1('ExtensionHostQuickPick.showQuickPick', {
8453
+ selected = await invoke$1(initialState.applicationId, 'ExtensionHostQuickPick.showQuickPick', {
8428
8454
  items,
8429
8455
  placeholder: 'Select Editor'
8430
8456
  });
@@ -8441,7 +8467,7 @@ const reopenEditorWith = async (context, preferredEditorId) => {
8441
8467
  type: 'webview',
8442
8468
  uri: initialTab.uri
8443
8469
  };
8444
- const viewletModuleId = await getViewletModuleIdForEditorInput(editorInput);
8470
+ const viewletModuleId = await getViewletModuleIdForEditorInput(editorInput, context.getState().applicationId);
8445
8471
  if (!viewletModuleId) {
8446
8472
  return;
8447
8473
  }
@@ -8464,12 +8490,12 @@ const reopenEditorWith = async (context, preferredEditorId) => {
8464
8490
  if (!tabWithViewlet || tabWithViewlet.tab.editorUid === -1) {
8465
8491
  return;
8466
8492
  }
8467
- const renderedTitle = await createViewlet(viewletModuleId, tabWithViewlet.tab.editorUid, initialTab.id, bounds, initialTab.uri);
8493
+ const renderedTitle = await createViewlet(viewletModuleId, tabWithViewlet.tab.editorUid, initialTab.id, bounds, initialTab.uri, undefined, latestState.applicationId);
8468
8494
  const readyState = handleViewletReady(context.getState(), tabWithViewlet.tab.editorUid, renderedTitle);
8469
8495
  await context.updateState(() => readyState);
8470
8496
  if (oldEditorUid !== -1) {
8471
8497
  try {
8472
- await invoke$1('Viewlet.dispose', oldEditorUid);
8498
+ await invoke$2('Viewlet.dispose', oldEditorUid);
8473
8499
  } catch {
8474
8500
  // Reopening should still proceed if the previous viewlet was already disposed.
8475
8501
  }
@@ -8484,10 +8510,10 @@ const resize$1 = (state, dimensions) => {
8484
8510
  };
8485
8511
 
8486
8512
  const settingsUri = 'app://settings.json';
8487
- const saveEditorAndHandleSettingsChange = async tab => {
8513
+ const saveEditorAndHandleSettingsChange = async (tab, applicationId) => {
8488
8514
  const editorState = await saveEditor(tab.editorUid);
8489
8515
  if (!editorState?.modified && tab.uri === settingsUri) {
8490
- await invoke$1('Layout.handleSettingsChanged');
8516
+ await invoke$1(applicationId, 'Layout.handleSettingsChanged');
8491
8517
  }
8492
8518
  return editorState;
8493
8519
  };
@@ -8529,16 +8555,16 @@ const save = async state => {
8529
8555
  return currentState;
8530
8556
  }
8531
8557
  if (!tab.isDirty) {
8532
- await saveEditorAndHandleSettingsChange(tab);
8558
+ await saveEditorAndHandleSettingsChange(tab, state.applicationId);
8533
8559
  return getLatestStoredState(uid, currentState, tab.id, tab.uri);
8534
8560
  }
8535
- const editorState = await saveEditorAndHandleSettingsChange(tab);
8561
+ const editorState = await saveEditorAndHandleSettingsChange(tab, state.applicationId);
8536
8562
  const latestState = getLatestStoredState(uid, currentState, tab.id, tab.uri);
8537
8563
  if (editorState?.modified) {
8538
8564
  return latestState;
8539
8565
  }
8540
8566
  if (tab.uri) {
8541
- await handleModifiedStatusChange$1(tab.uri, false);
8567
+ await invoke$1(state.applicationId, 'Main.handleModifiedStatusChange', tab.uri, false);
8542
8568
  }
8543
8569
  const stateAfterModifiedStatusChange = getLatestStoredState(uid, latestState, tab.id, tab.uri);
8544
8570
  return updateTab(stateAfterModifiedStatusChange, tab.id, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.60.0",
3
+ "version": "9.62.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",