@lvce-editor/main-area-worker 9.29.1 → 9.30.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 +68 -23
- package/package.json +1 -1
|
@@ -1786,6 +1786,10 @@ const sendMessagePortToExtensionHostWorker$1 = async (port, rpcId = 0) => {
|
|
|
1786
1786
|
const command = 'HandleMessagePort.handleMessagePort2';
|
|
1787
1787
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionHostWorker', port, command, rpcId);
|
|
1788
1788
|
};
|
|
1789
|
+
const confirm = async (message, options) => {
|
|
1790
|
+
const result = await invoke('ConfirmPrompt.prompt', message, options);
|
|
1791
|
+
return result;
|
|
1792
|
+
};
|
|
1789
1793
|
const writeClipBoardText = async text => {
|
|
1790
1794
|
await invoke('ClipBoard.writeText', /* text */text);
|
|
1791
1795
|
};
|
|
@@ -2254,18 +2258,42 @@ const saveEditor = async editorUid => {
|
|
|
2254
2258
|
return invoke('Editor.save', editorUid);
|
|
2255
2259
|
};
|
|
2256
2260
|
|
|
2261
|
+
const promptSave = async title => {
|
|
2262
|
+
const shouldSave = await confirm(`Do you want to save the changes you made to ${title}?`, {
|
|
2263
|
+
cancelMessage: 'More Options',
|
|
2264
|
+
confirmMessage: 'Save',
|
|
2265
|
+
title: 'Save Changes'
|
|
2266
|
+
});
|
|
2267
|
+
if (shouldSave) {
|
|
2268
|
+
return 'save';
|
|
2269
|
+
}
|
|
2270
|
+
const shouldDiscard = await confirm(`Discard the changes you made to ${title}?`, {
|
|
2271
|
+
cancelMessage: 'Cancel',
|
|
2272
|
+
confirmMessage: "Don't Save",
|
|
2273
|
+
title: 'Save Changes'
|
|
2274
|
+
});
|
|
2275
|
+
return shouldDiscard ? 'discard' : 'cancel';
|
|
2276
|
+
};
|
|
2257
2277
|
const closeTabAndSave = async (state, groupId, tabId) => {
|
|
2258
2278
|
const tab = findTabInState(state, groupId, tabId);
|
|
2259
2279
|
if (!tab) {
|
|
2260
2280
|
return state;
|
|
2261
2281
|
}
|
|
2262
2282
|
if (tab.editorUid !== -1 && tab.isDirty) {
|
|
2263
|
-
const
|
|
2264
|
-
if (
|
|
2283
|
+
const savePromptResult = await promptSave(tab.title);
|
|
2284
|
+
if (savePromptResult === 'cancel') {
|
|
2265
2285
|
return state;
|
|
2266
2286
|
}
|
|
2267
|
-
if (
|
|
2268
|
-
await
|
|
2287
|
+
if (savePromptResult === 'save') {
|
|
2288
|
+
const editorState = await saveEditor(tab.editorUid);
|
|
2289
|
+
if (editorState?.modified !== false) {
|
|
2290
|
+
return state;
|
|
2291
|
+
}
|
|
2292
|
+
if (tab.uri) {
|
|
2293
|
+
await handleModifiedStatusChange$1(tab.uri, false);
|
|
2294
|
+
}
|
|
2295
|
+
} else if (savePromptResult !== 'discard') {
|
|
2296
|
+
return state;
|
|
2269
2297
|
}
|
|
2270
2298
|
}
|
|
2271
2299
|
if (tab.uri?.startsWith('simple-browser://')) {
|
|
@@ -4839,32 +4867,39 @@ const handleUriChange = async (state, oldUri, newUri) => {
|
|
|
4839
4867
|
const {
|
|
4840
4868
|
groups
|
|
4841
4869
|
} = layout;
|
|
4842
|
-
const newTitle = getLabel(newUri);
|
|
4843
4870
|
const editorUriUpdates = [];
|
|
4844
|
-
for (const group of groups) {
|
|
4845
|
-
for (const tab of group.tabs) {
|
|
4846
|
-
if (tab.uri === oldUri && tab.editorType === 'text' && tab.editorUid !== -1) {
|
|
4847
|
-
editorUriUpdates.push(invoke('Editor.handleUriChange', tab.editorUid, newUri));
|
|
4848
|
-
}
|
|
4849
|
-
}
|
|
4850
|
-
}
|
|
4851
|
-
await Promise.all(editorUriUpdates);
|
|
4852
4871
|
const updatedGroups = groups.map(group => {
|
|
4853
4872
|
return {
|
|
4854
4873
|
...group,
|
|
4855
4874
|
tabs: group.tabs.map(tab => {
|
|
4856
|
-
|
|
4875
|
+
const uri = tab.uri || '';
|
|
4876
|
+
let renamedUri = '';
|
|
4877
|
+
if (uri === oldUri) {
|
|
4878
|
+
renamedUri = newUri;
|
|
4879
|
+
} else if (uri.startsWith(`${oldUri}/`) || uri.startsWith(`${oldUri}\\`)) {
|
|
4880
|
+
renamedUri = `${newUri}${uri.slice(oldUri.length)}`;
|
|
4881
|
+
}
|
|
4882
|
+
if (renamedUri) {
|
|
4883
|
+
if (tab.editorType === 'text' && tab.editorUid !== -1) {
|
|
4884
|
+
editorUriUpdates.push(invoke('Editor.handleUriChange', tab.editorUid, renamedUri));
|
|
4885
|
+
}
|
|
4886
|
+
const editorInput = tab.editorInput && 'uri' in tab.editorInput ? {
|
|
4887
|
+
...tab.editorInput,
|
|
4888
|
+
uri: renamedUri
|
|
4889
|
+
} : tab.editorInput;
|
|
4857
4890
|
return {
|
|
4858
4891
|
...tab,
|
|
4859
|
-
|
|
4860
|
-
|
|
4861
|
-
|
|
4892
|
+
editorInput,
|
|
4893
|
+
title: getLabel(renamedUri),
|
|
4894
|
+
uri: renamedUri,
|
|
4895
|
+
uriTitle: getUriTitle(renamedUri, state.homeDirUri || '')
|
|
4862
4896
|
};
|
|
4863
4897
|
}
|
|
4864
4898
|
return tab;
|
|
4865
4899
|
})
|
|
4866
4900
|
};
|
|
4867
4901
|
});
|
|
4902
|
+
await Promise.all(editorUriUpdates);
|
|
4868
4903
|
const stateWithUpdatedUri = {
|
|
4869
4904
|
...state,
|
|
4870
4905
|
layout: {
|
|
@@ -5144,21 +5179,31 @@ const handleWorkspaceChange = async (state, _workspacePath, savedState) => {
|
|
|
5144
5179
|
return loadContent(state, savedState);
|
|
5145
5180
|
};
|
|
5146
5181
|
|
|
5147
|
-
const handleWorkspaceRefresh = async (state,
|
|
5148
|
-
const
|
|
5182
|
+
const handleWorkspaceRefresh = async (state, refresh = {}) => {
|
|
5183
|
+
const changes = Array.isArray(refresh) ? {
|
|
5184
|
+
deleted: refresh
|
|
5185
|
+
} : refresh;
|
|
5186
|
+
const {
|
|
5187
|
+
deleted = [],
|
|
5188
|
+
renamed = []
|
|
5189
|
+
} = changes;
|
|
5149
5190
|
let newState = state;
|
|
5150
|
-
for (const
|
|
5191
|
+
for (const [oldUri, newUri] of renamed) {
|
|
5192
|
+
newState = await handleUriChange(newState, oldUri, newUri);
|
|
5193
|
+
}
|
|
5194
|
+
const deletedUris = new Set(deleted);
|
|
5195
|
+
for (const group of newState.layout.groups) {
|
|
5151
5196
|
for (const tab of group.tabs) {
|
|
5152
|
-
if (tab.editorInput?.type === 'editor' &&
|
|
5197
|
+
if (tab.editorInput?.type === 'editor' && deletedUris.has(tab.editorInput.uri)) {
|
|
5153
5198
|
newState = await closeTabWithViewlet(newState, group.id, tab.id);
|
|
5154
5199
|
}
|
|
5155
5200
|
}
|
|
5156
5201
|
}
|
|
5157
5202
|
return newState;
|
|
5158
5203
|
};
|
|
5159
|
-
const handleWorkspaceRefreshWithContext = async (context,
|
|
5204
|
+
const handleWorkspaceRefreshWithContext = async (context, refresh = {}) => {
|
|
5160
5205
|
const state = context.getState();
|
|
5161
|
-
const newState = await handleWorkspaceRefresh(state,
|
|
5206
|
+
const newState = await handleWorkspaceRefresh(state, refresh);
|
|
5162
5207
|
await context.updateState(() => newState);
|
|
5163
5208
|
};
|
|
5164
5209
|
|