@lvce-editor/main-area-worker 9.28.0 → 9.28.1
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.
- package/dist/mainAreaWorkerMain.js +127 -8
- package/package.json +1 -1
|
@@ -2295,7 +2295,21 @@ const closeActiveEditor = async state => {
|
|
|
2295
2295
|
return closeTabAndSave(state, focusedGroup.id, activeTabId);
|
|
2296
2296
|
};
|
|
2297
2297
|
|
|
2298
|
-
const
|
|
2298
|
+
const disposeEditors = async editorUids => {
|
|
2299
|
+
// Dispose all child viewlets in the renderer worker
|
|
2300
|
+
for (const editorUid of editorUids) {
|
|
2301
|
+
try {
|
|
2302
|
+
await invoke('Viewlet.dispose', editorUid);
|
|
2303
|
+
} catch {
|
|
2304
|
+
// Silently ignore errors during disposal
|
|
2305
|
+
// Viewlet may already be disposed or renderer worker may not be available
|
|
2306
|
+
}
|
|
2307
|
+
}
|
|
2308
|
+
};
|
|
2309
|
+
|
|
2310
|
+
const closeAll$1 = async state => {
|
|
2311
|
+
const editorUids = state.layout.groups.flatMap(group => group.tabs.map(tab => tab.editorUid)).filter(editorUid => editorUid !== -1);
|
|
2312
|
+
await disposeEditors(editorUids);
|
|
2299
2313
|
const entries = state.layout.groups.flatMap((group, groupIndex) => {
|
|
2300
2314
|
return group.tabs.map((tab, tabIndex) => ({
|
|
2301
2315
|
group,
|
|
@@ -2671,6 +2685,7 @@ const getEditorInputEditorType = editorInput => {
|
|
|
2671
2685
|
case 'process-explorer':
|
|
2672
2686
|
case 'running-extensions':
|
|
2673
2687
|
case 'video':
|
|
2688
|
+
case 'webview':
|
|
2674
2689
|
return 'custom';
|
|
2675
2690
|
case 'editor':
|
|
2676
2691
|
return 'text';
|
|
@@ -2684,6 +2699,7 @@ const getEditorInputUri = editorInput => {
|
|
|
2684
2699
|
case 'editor':
|
|
2685
2700
|
case 'image':
|
|
2686
2701
|
case 'video':
|
|
2702
|
+
case 'webview':
|
|
2687
2703
|
return editorInput.uri;
|
|
2688
2704
|
case 'extension-detail-view':
|
|
2689
2705
|
return `extension-detail://${editorInput.extensionId}`;
|
|
@@ -2788,6 +2804,9 @@ const getNormalizedEditorInput = tab => {
|
|
|
2788
2804
|
editorInput: tabEditorInput,
|
|
2789
2805
|
uri: tabUri
|
|
2790
2806
|
} = tab ?? {};
|
|
2807
|
+
if (tabEditorInput?.type === 'editor' && tabEditorInput.forceText || tabEditorInput?.type === 'webview') {
|
|
2808
|
+
return tabEditorInput;
|
|
2809
|
+
}
|
|
2791
2810
|
let uri;
|
|
2792
2811
|
if (typeof tabUri === 'string') {
|
|
2793
2812
|
uri = tabUri;
|
|
@@ -2916,11 +2935,11 @@ const getSelectedTabBounds = state => {
|
|
|
2916
2935
|
};
|
|
2917
2936
|
};
|
|
2918
2937
|
|
|
2919
|
-
const getViewletModuleId$1 = async uri => {
|
|
2938
|
+
const getViewletModuleId$1 = async (uri, opener) => {
|
|
2920
2939
|
// Query RendererWorker for viewlet module ID (optional, may fail in tests)
|
|
2921
2940
|
let viewletModuleId;
|
|
2922
2941
|
try {
|
|
2923
|
-
viewletModuleId = await invoke('Layout.getModuleId', uri);
|
|
2942
|
+
viewletModuleId = opener === undefined ? await invoke('Layout.getModuleId', uri) : await invoke('Layout.getModuleId', uri, opener);
|
|
2924
2943
|
} catch {
|
|
2925
2944
|
// Viewlet creation is optional - silently ignore if RendererWorker isn't available
|
|
2926
2945
|
}
|
|
@@ -2939,15 +2958,18 @@ const getViewletModuleIdForEditorInput = async editorInput => {
|
|
|
2939
2958
|
case 'diff-editor':
|
|
2940
2959
|
return DiffEditor;
|
|
2941
2960
|
case 'editor':
|
|
2961
|
+
return editorInput.forceText ? EditorText : getViewletModuleId$1(editorInput.uri);
|
|
2962
|
+
case 'extension-detail-view':
|
|
2963
|
+
return ExtensionDetail;
|
|
2942
2964
|
case 'image':
|
|
2943
2965
|
case 'video':
|
|
2944
2966
|
return getViewletModuleId$1(editorInput.uri);
|
|
2945
|
-
case 'extension-detail-view':
|
|
2946
|
-
return ExtensionDetail;
|
|
2947
2967
|
case 'process-explorer':
|
|
2948
2968
|
return ProcessExplorer;
|
|
2949
2969
|
case 'running-extensions':
|
|
2950
2970
|
return RunningExtensions;
|
|
2971
|
+
case 'webview':
|
|
2972
|
+
return getViewletModuleId$1(editorInput.uri, editorInput.providerId);
|
|
2951
2973
|
}
|
|
2952
2974
|
};
|
|
2953
2975
|
|
|
@@ -3496,6 +3518,7 @@ const getEditorInputTitle = editorInput => {
|
|
|
3496
3518
|
case 'editor':
|
|
3497
3519
|
case 'image':
|
|
3498
3520
|
case 'video':
|
|
3521
|
+
case 'webview':
|
|
3499
3522
|
return getLabel(editorInput.uri);
|
|
3500
3523
|
case 'extension-detail-view':
|
|
3501
3524
|
return editorInput.extensionId;
|
|
@@ -5203,7 +5226,7 @@ const copyPath = () => {
|
|
|
5203
5226
|
const copyRelativePath = () => {
|
|
5204
5227
|
return i18nString(CopyRelativePath);
|
|
5205
5228
|
};
|
|
5206
|
-
const reopenEditorWith = () => {
|
|
5229
|
+
const reopenEditorWith$1 = () => {
|
|
5207
5230
|
return i18nString(ReopenEditorWith);
|
|
5208
5231
|
};
|
|
5209
5232
|
const share = () => {
|
|
@@ -5370,10 +5393,10 @@ const getMenuEntries$1 = state => {
|
|
|
5370
5393
|
id: 'copyRelativePath',
|
|
5371
5394
|
label: copyRelativePath()
|
|
5372
5395
|
}, menuEntrySeparator, {
|
|
5373
|
-
command: '',
|
|
5396
|
+
command: 'Main.reopenEditorWith',
|
|
5374
5397
|
flags: None,
|
|
5375
5398
|
id: 'reopenEditorWith',
|
|
5376
|
-
label: reopenEditorWith()
|
|
5399
|
+
label: reopenEditorWith$1()
|
|
5377
5400
|
}, menuEntrySeparator, {
|
|
5378
5401
|
command: '',
|
|
5379
5402
|
flags: None,
|
|
@@ -6458,6 +6481,101 @@ const renderEventListeners = () => {
|
|
|
6458
6481
|
}];
|
|
6459
6482
|
};
|
|
6460
6483
|
|
|
6484
|
+
const getViewProviderEntries = async uri => {
|
|
6485
|
+
const textEditorEntry = {
|
|
6486
|
+
id: 'editor',
|
|
6487
|
+
label: 'Text Editor',
|
|
6488
|
+
type: 'editor'
|
|
6489
|
+
};
|
|
6490
|
+
try {
|
|
6491
|
+
const providers = await invoke('WebView.getWebViews');
|
|
6492
|
+
const matchingProviders = providers.filter(provider => provider?.id && provider.selector?.some(selector => uri.endsWith(selector)));
|
|
6493
|
+
return [textEditorEntry, ...matchingProviders.map(provider => {
|
|
6494
|
+
const titleElement = provider.elements?.find(element => element.type === 'title');
|
|
6495
|
+
return {
|
|
6496
|
+
id: provider.id,
|
|
6497
|
+
label: provider.name || provider.title || titleElement?.value || provider.id,
|
|
6498
|
+
type: 'webview'
|
|
6499
|
+
};
|
|
6500
|
+
})];
|
|
6501
|
+
} catch {
|
|
6502
|
+
return [textEditorEntry];
|
|
6503
|
+
}
|
|
6504
|
+
};
|
|
6505
|
+
const reopenEditorWith = async context => {
|
|
6506
|
+
const initialState = context.getState();
|
|
6507
|
+
const {
|
|
6508
|
+
activeGroupId,
|
|
6509
|
+
groups
|
|
6510
|
+
} = initialState.layout;
|
|
6511
|
+
const activeGroup = groups.find(group => group.id === activeGroupId);
|
|
6512
|
+
const initialTab = activeGroup?.tabs.find(tab => tab.id === activeGroup.activeTabId);
|
|
6513
|
+
if (!initialTab?.uri) {
|
|
6514
|
+
return;
|
|
6515
|
+
}
|
|
6516
|
+
const entries = await getViewProviderEntries(initialTab.uri);
|
|
6517
|
+
const items = entries.map(entry => ({
|
|
6518
|
+
description: '',
|
|
6519
|
+
label: entry.label,
|
|
6520
|
+
value: entry
|
|
6521
|
+
}));
|
|
6522
|
+
const selected = await invoke('ExtensionHostQuickPick.showQuickPick', {
|
|
6523
|
+
items,
|
|
6524
|
+
placeholder: 'Select Editor'
|
|
6525
|
+
});
|
|
6526
|
+
if (!selected) {
|
|
6527
|
+
return;
|
|
6528
|
+
}
|
|
6529
|
+
const editorInput = selected.type === 'editor' ? {
|
|
6530
|
+
forceText: true,
|
|
6531
|
+
type: 'editor',
|
|
6532
|
+
uri: initialTab.uri
|
|
6533
|
+
} : {
|
|
6534
|
+
providerId: selected.id,
|
|
6535
|
+
type: 'webview',
|
|
6536
|
+
uri: initialTab.uri
|
|
6537
|
+
};
|
|
6538
|
+
const viewletModuleId = await getViewletModuleIdForEditorInput(editorInput);
|
|
6539
|
+
if (!viewletModuleId) {
|
|
6540
|
+
return;
|
|
6541
|
+
}
|
|
6542
|
+
const latestState = context.getState();
|
|
6543
|
+
const latestTab = findTabById(latestState, initialTab.id);
|
|
6544
|
+
if (!latestTab) {
|
|
6545
|
+
return;
|
|
6546
|
+
}
|
|
6547
|
+
const oldEditorUid = latestTab.tab.editorUid;
|
|
6548
|
+
const resetState = updateTab(latestState, initialTab.id, {
|
|
6549
|
+
editorInput,
|
|
6550
|
+
editorType: getEditorInputEditorType(editorInput),
|
|
6551
|
+
editorUid: -1,
|
|
6552
|
+
errorMessage: undefined,
|
|
6553
|
+
loadingState: undefined
|
|
6554
|
+
});
|
|
6555
|
+
const bounds = {
|
|
6556
|
+
height: resetState.height - resetState.tabHeight,
|
|
6557
|
+
width: resetState.width,
|
|
6558
|
+
x: resetState.x,
|
|
6559
|
+
y: resetState.y + resetState.tabHeight
|
|
6560
|
+
};
|
|
6561
|
+
const stateWithViewlet = createViewletForTab(resetState, initialTab.id);
|
|
6562
|
+
await context.updateState(() => stateWithViewlet);
|
|
6563
|
+
const tabWithViewlet = findTabById(stateWithViewlet, initialTab.id);
|
|
6564
|
+
if (!tabWithViewlet || tabWithViewlet.tab.editorUid === -1) {
|
|
6565
|
+
return;
|
|
6566
|
+
}
|
|
6567
|
+
const renderedTitle = await createViewlet(viewletModuleId, tabWithViewlet.tab.editorUid, initialTab.id, bounds, initialTab.uri);
|
|
6568
|
+
const readyState = handleViewletReady(context.getState(), tabWithViewlet.tab.editorUid, renderedTitle);
|
|
6569
|
+
await context.updateState(() => readyState);
|
|
6570
|
+
if (oldEditorUid !== -1) {
|
|
6571
|
+
try {
|
|
6572
|
+
await invoke('Viewlet.dispose', oldEditorUid);
|
|
6573
|
+
} catch {
|
|
6574
|
+
// Reopening should still proceed if the previous viewlet was already disposed.
|
|
6575
|
+
}
|
|
6576
|
+
}
|
|
6577
|
+
};
|
|
6578
|
+
|
|
6461
6579
|
const getLatestStoredState = (uid, fallbackState, referenceTabId, referenceTabUri, allowMissingReference = false) => {
|
|
6462
6580
|
const stateFromStore = get(uid);
|
|
6463
6581
|
if (!stateFromStore) {
|
|
@@ -6940,6 +7058,7 @@ const commandMap = {
|
|
|
6940
7058
|
'MainArea.refresh': wrapSerialCommand(refresh),
|
|
6941
7059
|
'MainArea.render2': render2,
|
|
6942
7060
|
'MainArea.renderEventListeners': renderEventListeners,
|
|
7061
|
+
'MainArea.reopenEditorWith': wrapSerialAsyncCommand(reopenEditorWith),
|
|
6943
7062
|
'MainArea.resize': wrapGetter(handleResize),
|
|
6944
7063
|
'MainArea.restoreClosedTab': wrapSerialCommand(restoreClosedTab),
|
|
6945
7064
|
'MainArea.save': wrapSerialCommand(save),
|