@lvce-editor/main-area-worker 9.70.0 → 9.71.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 +176 -5
- package/package.json +1 -1
|
@@ -1934,6 +1934,7 @@ const withActiveEditorChangeAsync = fn => {
|
|
|
1934
1934
|
|
|
1935
1935
|
const registry = create$4();
|
|
1936
1936
|
const {
|
|
1937
|
+
dispose: dispose$1,
|
|
1937
1938
|
get: get$1,
|
|
1938
1939
|
getCommandIds,
|
|
1939
1940
|
getKeys: getKeys$1,
|
|
@@ -2911,6 +2912,16 @@ const diff2 = uid => {
|
|
|
2911
2912
|
return result;
|
|
2912
2913
|
};
|
|
2913
2914
|
|
|
2915
|
+
const dispose = async uid => {
|
|
2916
|
+
const instance = get$1(uid);
|
|
2917
|
+
if (!instance) {
|
|
2918
|
+
return;
|
|
2919
|
+
}
|
|
2920
|
+
const editorUids = instance.newState.layout.groups.flatMap(group => group.tabs.map(tab => tab.editorUid).filter(id => id !== -1));
|
|
2921
|
+
dispose$1(uid);
|
|
2922
|
+
await disposeEditors(editorUids);
|
|
2923
|
+
};
|
|
2924
|
+
|
|
2914
2925
|
const state = {
|
|
2915
2926
|
connected: false
|
|
2916
2927
|
};
|
|
@@ -4783,18 +4794,15 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropInd
|
|
|
4783
4794
|
const nestedDirection = segment.direction;
|
|
4784
4795
|
const nestedChildCount = segment.groups.length + segment.groups.length - 1;
|
|
4785
4796
|
const nestedChildren = [];
|
|
4786
|
-
let nestedCount = 0;
|
|
4787
4797
|
for (let j = 0; j < segment.groups.length; j++) {
|
|
4788
4798
|
if (j > 0) {
|
|
4789
4799
|
const beforeGroupId = segment.groups[j - 1].id;
|
|
4790
4800
|
const afterGroupId = segment.groups[j].id;
|
|
4791
4801
|
const sashId = create(beforeGroupId, afterGroupId);
|
|
4792
4802
|
nestedChildren.push(...renderSash(nestedDirection, sashId));
|
|
4793
|
-
nestedCount++;
|
|
4794
4803
|
}
|
|
4795
4804
|
const group = segment.groups[j];
|
|
4796
4805
|
nestedChildren.push(...renderEditorGroup(group, segment.startIndex + j, splitButtonEnabled, true, tabDropIndicator));
|
|
4797
|
-
nestedCount++;
|
|
4798
4806
|
}
|
|
4799
4807
|
children.push({
|
|
4800
4808
|
childCount: nestedChildCount,
|
|
@@ -4804,7 +4812,6 @@ const renderSegmentChildren = (direction, groups, splitButtonEnabled, tabDropInd
|
|
|
4804
4812
|
});
|
|
4805
4813
|
children.push(...nestedChildren);
|
|
4806
4814
|
childCount++;
|
|
4807
|
-
childCount += nestedCount;
|
|
4808
4815
|
}
|
|
4809
4816
|
return {
|
|
4810
4817
|
childCount,
|
|
@@ -8091,6 +8098,163 @@ const initialize$1 = async () => {
|
|
|
8091
8098
|
// Kept as a compatibility command for existing renderer startup code.
|
|
8092
8099
|
};
|
|
8093
8100
|
|
|
8101
|
+
const isCurrent = context => {
|
|
8102
|
+
const state = context.getState();
|
|
8103
|
+
return !state.disposed && get$1(state.uid)?.newState === state;
|
|
8104
|
+
};
|
|
8105
|
+
const renderPending = async context => {
|
|
8106
|
+
if (!isCurrent(context)) {
|
|
8107
|
+
return;
|
|
8108
|
+
}
|
|
8109
|
+
const {
|
|
8110
|
+
applicationId,
|
|
8111
|
+
uid
|
|
8112
|
+
} = context.getState();
|
|
8113
|
+
await invoke$1(applicationId, 'Layout.renderMainAreaPending', uid);
|
|
8114
|
+
};
|
|
8115
|
+
const loadRestoredTab = async (context, tab) => {
|
|
8116
|
+
const isPending = () => {
|
|
8117
|
+
const latestTab = findTabById(context.getState(), tab.id)?.tab;
|
|
8118
|
+
return isCurrent(context) && latestTab?.editorUid === tab.editorUid && latestTab.loadingState === 'loading';
|
|
8119
|
+
};
|
|
8120
|
+
try {
|
|
8121
|
+
const state = context.getState();
|
|
8122
|
+
const moduleId = await getViewletModuleIdForEditorInput(tab.editorInput, state.applicationId);
|
|
8123
|
+
if (!isPending()) {
|
|
8124
|
+
return;
|
|
8125
|
+
}
|
|
8126
|
+
if (!moduleId) {
|
|
8127
|
+
throw new Error('Could not determine editor type for this URI');
|
|
8128
|
+
}
|
|
8129
|
+
const latestState = context.getState();
|
|
8130
|
+
const location = findTabById(latestState, tab.id);
|
|
8131
|
+
const bounds = getSelectedTabBounds(latestState, location.groupId);
|
|
8132
|
+
await createViewletContent(moduleId, tab.editorUid, tab.id, bounds, tab.uri, [{
|
|
8133
|
+
focus: false
|
|
8134
|
+
}], state.applicationId);
|
|
8135
|
+
if (!isPending()) {
|
|
8136
|
+
await disposeEditors([tab.editorUid]);
|
|
8137
|
+
return;
|
|
8138
|
+
}
|
|
8139
|
+
const beforeReady = context.getState();
|
|
8140
|
+
const readyState = await context.updateState(current => handleViewletReady(current, tab.editorUid));
|
|
8141
|
+
await notifyActiveEditorChange(beforeReady, readyState);
|
|
8142
|
+
await notifyMountedViewlets(beforeReady, readyState);
|
|
8143
|
+
await renderPending(context);
|
|
8144
|
+
// Optional metadata must never hold up editor readiness or another group.
|
|
8145
|
+
const title = await getViewletTitle(tab.editorUid);
|
|
8146
|
+
if (!isCurrent(context) || findTabById(context.getState(), tab.id)?.tab.editorUid !== tab.editorUid) {
|
|
8147
|
+
return;
|
|
8148
|
+
}
|
|
8149
|
+
if (title) {
|
|
8150
|
+
await context.updateState(current => handleViewletReady(current, tab.editorUid, title));
|
|
8151
|
+
}
|
|
8152
|
+
await renderPending(context);
|
|
8153
|
+
} catch (error) {
|
|
8154
|
+
if (!isPending()) {
|
|
8155
|
+
return;
|
|
8156
|
+
}
|
|
8157
|
+
await disposeEditors([tab.editorUid]);
|
|
8158
|
+
await context.updateState(current => updateTab(current, tab.id, {
|
|
8159
|
+
editorUid: -1,
|
|
8160
|
+
errorMessage: error instanceof Error ? error.message : 'Failed to restore editor',
|
|
8161
|
+
loadingState: 'error'
|
|
8162
|
+
}));
|
|
8163
|
+
await renderPending(context);
|
|
8164
|
+
}
|
|
8165
|
+
};
|
|
8166
|
+
const loadHomeDir = async context => {
|
|
8167
|
+
const homeDirUri = await loadHomeDirUri(context.getState().applicationId);
|
|
8168
|
+
if (!isCurrent(context)) {
|
|
8169
|
+
return;
|
|
8170
|
+
}
|
|
8171
|
+
await context.updateState(state => updateTabUriTitles({
|
|
8172
|
+
...state,
|
|
8173
|
+
homeDirUri
|
|
8174
|
+
}));
|
|
8175
|
+
await renderPending(context);
|
|
8176
|
+
};
|
|
8177
|
+
const loadIcons = async context => {
|
|
8178
|
+
const {
|
|
8179
|
+
fileIconCache,
|
|
8180
|
+
updatedLayout
|
|
8181
|
+
} = await loadFileIcons(context.getState());
|
|
8182
|
+
if (!isCurrent(context)) {
|
|
8183
|
+
return;
|
|
8184
|
+
}
|
|
8185
|
+
const icons = new Map(updatedLayout.groups.flatMap(group => group.tabs.map(tab => [tab.id, tab])));
|
|
8186
|
+
// Metadata completion must not restore an obsolete layout or tab selection.
|
|
8187
|
+
await context.updateState(state => ({
|
|
8188
|
+
...state,
|
|
8189
|
+
fileIconCache: {
|
|
8190
|
+
...state.fileIconCache,
|
|
8191
|
+
...fileIconCache
|
|
8192
|
+
},
|
|
8193
|
+
layout: {
|
|
8194
|
+
...state.layout,
|
|
8195
|
+
groups: state.layout.groups.map(group => ({
|
|
8196
|
+
...group,
|
|
8197
|
+
tabs: group.tabs.map(tab => {
|
|
8198
|
+
const restored = icons.get(tab.id);
|
|
8199
|
+
return restored && restored.uri === tab.uri ? {
|
|
8200
|
+
...tab,
|
|
8201
|
+
icon: restored.icon
|
|
8202
|
+
} : tab;
|
|
8203
|
+
})
|
|
8204
|
+
}))
|
|
8205
|
+
}
|
|
8206
|
+
}));
|
|
8207
|
+
await renderPending(context);
|
|
8208
|
+
};
|
|
8209
|
+
const loadContentLater = async context => {
|
|
8210
|
+
const state = context.getState();
|
|
8211
|
+
// Older renderers discover this lifecycle hook but still use loadContent.
|
|
8212
|
+
if (state.pendingRestoreTabIds === undefined) {
|
|
8213
|
+
return;
|
|
8214
|
+
}
|
|
8215
|
+
const pendingIds = new Set(state.pendingRestoreTabIds);
|
|
8216
|
+
const tabs = state.layout.groups.flatMap(group => group.tabs.filter(tab => pendingIds.has(tab.id) && tab.loadingState === 'loading'));
|
|
8217
|
+
await context.updateState(current => ({
|
|
8218
|
+
...current,
|
|
8219
|
+
pendingRestoreTabIds: []
|
|
8220
|
+
}));
|
|
8221
|
+
await Promise.all([loadHomeDir(context), loadIcons(context), ...tabs.map(tab => loadRestoredTab(context, tab))]);
|
|
8222
|
+
};
|
|
8223
|
+
|
|
8224
|
+
// Restore the shell without depending on any editor, workspace, or icon RPC.
|
|
8225
|
+
const loadContentShell = (state, savedState) => {
|
|
8226
|
+
const layout = tryRestoreLayout(savedState) ?? {
|
|
8227
|
+
activeGroupId: -1,
|
|
8228
|
+
direction: Horizontal,
|
|
8229
|
+
groups: []
|
|
8230
|
+
};
|
|
8231
|
+
const {
|
|
8232
|
+
groups
|
|
8233
|
+
} = layout;
|
|
8234
|
+
reserve(groups.flatMap(group => [group.id, ...group.tabs.map(tab => tab.id)]));
|
|
8235
|
+
return updateTabUriTitles({
|
|
8236
|
+
...state,
|
|
8237
|
+
initial: false,
|
|
8238
|
+
layout: {
|
|
8239
|
+
...layout,
|
|
8240
|
+
groups: groups.map(group => ({
|
|
8241
|
+
...group,
|
|
8242
|
+
tabs: group.tabs.map(tab => {
|
|
8243
|
+
if (tab.id !== group.activeTabId || !tab.uri || tab.loadingState === 'binary') {
|
|
8244
|
+
return tab;
|
|
8245
|
+
}
|
|
8246
|
+
return {
|
|
8247
|
+
...tab,
|
|
8248
|
+
editorUid: create$2(),
|
|
8249
|
+
loadingState: 'loading'
|
|
8250
|
+
};
|
|
8251
|
+
})
|
|
8252
|
+
}))
|
|
8253
|
+
},
|
|
8254
|
+
pendingRestoreTabIds: groups.flatMap(group => group.tabs.filter(tab => tab.id === group.activeTabId && tab.uri && tab.loadingState !== 'binary').map(tab => tab.id))
|
|
8255
|
+
});
|
|
8256
|
+
};
|
|
8257
|
+
|
|
8094
8258
|
const hasTargetGroup = groupId => {
|
|
8095
8259
|
return groupId !== undefined && groupId >= 0;
|
|
8096
8260
|
};
|
|
@@ -9305,6 +9469,7 @@ const commandMap = {
|
|
|
9305
9469
|
'MainArea.copyRelativePath': wrapSerialCommand(copyRelativePath$1),
|
|
9306
9470
|
'MainArea.create': create$1,
|
|
9307
9471
|
'MainArea.diff2': diff2,
|
|
9472
|
+
'MainArea.dispose': dispose,
|
|
9308
9473
|
'MainArea.flipEditorLayout': wrapSerialCommand(flipLayout),
|
|
9309
9474
|
'MainArea.focus': wrapSerialCommand(focus),
|
|
9310
9475
|
'MainArea.focusNext': wrapSerialCommand(focusNextTab),
|
|
@@ -9312,7 +9477,8 @@ const commandMap = {
|
|
|
9312
9477
|
'MainArea.focusPrevious': wrapSerialCommand(focusPreviousTab),
|
|
9313
9478
|
'MainArea.focusPreviousTab': wrapSerialCommand(focusPreviousTab),
|
|
9314
9479
|
'MainArea.getActiveEditorUid': wrapGetter(getActiveEditorUid),
|
|
9315
|
-
|
|
9480
|
+
// Lifecycle hooks require an explicit renderer adapter, not command discovery.
|
|
9481
|
+
'MainArea.getCommandIds': () => getCommandIds().filter(id => id !== 'loadContentLater'),
|
|
9316
9482
|
'MainArea.getComponentDom': getComponentDom,
|
|
9317
9483
|
'MainArea.getComponentState': getComponentState,
|
|
9318
9484
|
'MainArea.getMenuEntries': wrapGetter(getMenuEntries),
|
|
@@ -9356,6 +9522,11 @@ const commandMap = {
|
|
|
9356
9522
|
'MainArea.hasDirtyTabs': wrapGetter(hasDirtyTabs),
|
|
9357
9523
|
'MainArea.initialize': initialize$1,
|
|
9358
9524
|
'MainArea.loadContent': loadContentTracked,
|
|
9525
|
+
'MainArea.loadContentLater': wrapAsyncCommand(loadContentLater),
|
|
9526
|
+
'MainArea.loadContentShell': (uid, savedState) => {
|
|
9527
|
+
const instance = get$1(uid);
|
|
9528
|
+
set$1(uid, instance.oldState, loadContentShell(instance.newState, savedState));
|
|
9529
|
+
},
|
|
9359
9530
|
'MainArea.moveIntoNewWindow': wrapSerialCommand(moveIntoNewWindow),
|
|
9360
9531
|
'MainArea.newFile': wrapSerialCommand(newFile),
|
|
9361
9532
|
'MainArea.newWindow': wrapSerialCommand(newWindow),
|