@lvce-editor/main-area-worker 9.67.5 → 9.67.7
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 +53 -20
- package/package.json +1 -1
|
@@ -1531,7 +1531,7 @@ const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
|
|
|
1531
1531
|
const readFile = async uri => {
|
|
1532
1532
|
return invoke$2('FileSystem.readFile', uri);
|
|
1533
1533
|
};
|
|
1534
|
-
const confirm
|
|
1534
|
+
const confirm = async (message, options) => {
|
|
1535
1535
|
const result = await invoke$2('ConfirmPrompt.prompt', message, options);
|
|
1536
1536
|
return result;
|
|
1537
1537
|
};
|
|
@@ -2107,11 +2107,20 @@ const findTabById = (state, tabId) => {
|
|
|
2107
2107
|
return undefined;
|
|
2108
2108
|
};
|
|
2109
2109
|
|
|
2110
|
-
const switchViewlet = async (state, fromTabId, toTabId) => {
|
|
2110
|
+
const switchViewlet = async (state, fromTabId, toTabId, waitForBlur = true) => {
|
|
2111
2111
|
const previous = fromTabId === undefined ? undefined : findTabById(state, fromTabId)?.tab;
|
|
2112
2112
|
if (fromTabId !== toTabId && previous && previous.editorUid >= 0 && previous.loadingState === 'loaded' && previous.editorInput?.type === 'editor') {
|
|
2113
2113
|
// Browsers do not consistently emit blur when a focused editor reference is detached.
|
|
2114
|
-
|
|
2114
|
+
const blur = invoke$1(state.applicationId, 'Viewlet.executeViewletCommand', previous.editorUid, 'handleBlur');
|
|
2115
|
+
if (waitForBlur) {
|
|
2116
|
+
await blur;
|
|
2117
|
+
} else {
|
|
2118
|
+
// Opening a new editor can originate inside the outgoing editor's command queue.
|
|
2119
|
+
// Waiting for blur there would deadlock the navigation command.
|
|
2120
|
+
void blur.catch(() => {
|
|
2121
|
+
// The outgoing editor may have been disposed while blur was queued.
|
|
2122
|
+
});
|
|
2123
|
+
}
|
|
2115
2124
|
}
|
|
2116
2125
|
return {
|
|
2117
2126
|
commands: [],
|
|
@@ -2308,19 +2317,8 @@ const saveEditor = async (editorUid, skipFormatting = false) => {
|
|
|
2308
2317
|
return invoke$2('Editor.save', editorUid);
|
|
2309
2318
|
};
|
|
2310
2319
|
|
|
2311
|
-
const
|
|
2312
|
-
|
|
2313
|
-
return await confirm$1(message, options);
|
|
2314
|
-
} catch (error) {
|
|
2315
|
-
const errorMessage = String(error);
|
|
2316
|
-
if (!errorMessage.includes('ConfirmPrompt.prompt') || !errorMessage.includes('not found')) {
|
|
2317
|
-
throw error;
|
|
2318
|
-
}
|
|
2319
|
-
return invoke$6('ConfirmPrompt.prompt', message, options);
|
|
2320
|
-
}
|
|
2321
|
-
};
|
|
2322
|
-
const promptSave = async title => {
|
|
2323
|
-
const shouldSave = await confirm(`Do you want to save the changes you made to ${title}?`, {
|
|
2320
|
+
const promptLegacy = async (message, discardPrompt) => {
|
|
2321
|
+
const shouldSave = await confirm(message, {
|
|
2324
2322
|
cancelMessage: 'More Options',
|
|
2325
2323
|
confirmMessage: 'Save',
|
|
2326
2324
|
title: 'Save Changes'
|
|
@@ -2328,13 +2326,47 @@ const promptSave = async title => {
|
|
|
2328
2326
|
if (shouldSave) {
|
|
2329
2327
|
return 'save';
|
|
2330
2328
|
}
|
|
2331
|
-
const shouldDiscard = await confirm(
|
|
2329
|
+
const shouldDiscard = await confirm(discardPrompt, {
|
|
2332
2330
|
cancelMessage: 'Cancel',
|
|
2333
2331
|
confirmMessage: "Don't Save",
|
|
2334
2332
|
title: 'Save Changes'
|
|
2335
2333
|
});
|
|
2336
2334
|
return shouldDiscard ? 'discard' : 'cancel';
|
|
2337
2335
|
};
|
|
2336
|
+
const promptSave = async title => {
|
|
2337
|
+
const message = `Do you want to save the changes you made to ${title}?`;
|
|
2338
|
+
const discardPrompt = `Discard the changes you made to ${title}?`;
|
|
2339
|
+
const options = {
|
|
2340
|
+
cancelMessage: 'Cancel',
|
|
2341
|
+
confirmMessage: 'Save',
|
|
2342
|
+
discardMessage: "Don't Save",
|
|
2343
|
+
discardPrompt,
|
|
2344
|
+
title: 'Save Changes'
|
|
2345
|
+
};
|
|
2346
|
+
try {
|
|
2347
|
+
const result = await invoke$2('ConfirmPrompt.prompt3', message, options);
|
|
2348
|
+
if (['cancel', 'discard', 'save'].includes(result)) {
|
|
2349
|
+
return result;
|
|
2350
|
+
}
|
|
2351
|
+
} catch (error) {
|
|
2352
|
+
const errorMessage = String(error);
|
|
2353
|
+
if (!errorMessage.includes('ConfirmPrompt.prompt3') || !errorMessage.includes('not found')) {
|
|
2354
|
+
throw error;
|
|
2355
|
+
}
|
|
2356
|
+
}
|
|
2357
|
+
try {
|
|
2358
|
+
const result = await invoke$6('ConfirmPrompt.prompt3', message, options);
|
|
2359
|
+
if (['cancel', 'discard', 'save'].includes(result)) {
|
|
2360
|
+
return result;
|
|
2361
|
+
}
|
|
2362
|
+
} catch (error) {
|
|
2363
|
+
const errorMessage = String(error);
|
|
2364
|
+
if (!errorMessage.includes('ConfirmPrompt.prompt3') || !errorMessage.includes('not found')) {
|
|
2365
|
+
throw error;
|
|
2366
|
+
}
|
|
2367
|
+
}
|
|
2368
|
+
return promptLegacy(message, discardPrompt);
|
|
2369
|
+
};
|
|
2338
2370
|
const canCloseTab = async tab => {
|
|
2339
2371
|
if (tab.editorUid === -1 || !tab.isDirty) {
|
|
2340
2372
|
return true;
|
|
@@ -3374,11 +3406,12 @@ const selectTab = async (state, groupIndex, index) => {
|
|
|
3374
3406
|
} = selectedTabData;
|
|
3375
3407
|
const normalizedTab = normalizeTabEditorInput(tab);
|
|
3376
3408
|
const isAlreadyActive = activeGroupId === groupId && group.activeTabId === tabId;
|
|
3377
|
-
|
|
3409
|
+
const needsLoading = shouldLoadContentForTab(normalizedTab);
|
|
3410
|
+
const needsViewlet = normalizedTab.editorUid === -1 && Boolean(normalizedTab.uri);
|
|
3411
|
+
if (isAlreadyActive && !needsLoading && !needsViewlet) {
|
|
3378
3412
|
return state;
|
|
3379
3413
|
}
|
|
3380
3414
|
const previousTabId = getActiveTabId$1(state);
|
|
3381
|
-
const needsLoading = shouldLoadContentForTab(normalizedTab);
|
|
3382
3415
|
const requestId = needsLoading ? getNextRequestId() : 0;
|
|
3383
3416
|
const updatedGroups = getUpdatedGroups(groups, groupIndex, needsLoading, tabId);
|
|
3384
3417
|
let newState = {
|
|
@@ -5579,7 +5612,7 @@ const openInputWithContext = async (context, options) => {
|
|
|
5579
5612
|
let intermediateState = stateWithViewlet;
|
|
5580
5613
|
const {
|
|
5581
5614
|
newState: switchedState
|
|
5582
|
-
} = await switchViewlet(intermediateState, previousTabId, tabId);
|
|
5615
|
+
} = await switchViewlet(intermediateState, previousTabId, tabId, false);
|
|
5583
5616
|
intermediateState = switchedState;
|
|
5584
5617
|
await context.updateState(() => intermediateState);
|
|
5585
5618
|
const tabWithViewlet = findTabById(intermediateState, tabId);
|