@lvce-editor/main-area-worker 9.53.1 → 9.54.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 +81 -34
- package/package.json +1 -1
|
@@ -1217,7 +1217,8 @@ const create$4 = () => {
|
|
|
1217
1217
|
const commandQueues = new Map();
|
|
1218
1218
|
const generations = Object.create(null);
|
|
1219
1219
|
const states = Object.create(null);
|
|
1220
|
-
const commandMapRef =
|
|
1220
|
+
const commandMapRef = Object.create(null);
|
|
1221
|
+
const commandsById = Object.create(null);
|
|
1221
1222
|
const getGeneration = uid => generations[uid] || 0;
|
|
1222
1223
|
const isCurrentGeneration = (uid, generation) => {
|
|
1223
1224
|
return states[uid] !== undefined && getGeneration(uid) === generation;
|
|
@@ -1279,6 +1280,18 @@ const create$4 = () => {
|
|
|
1279
1280
|
delete states[key];
|
|
1280
1281
|
}
|
|
1281
1282
|
},
|
|
1283
|
+
createDirectEventCommandMap(requestRender) {
|
|
1284
|
+
return {
|
|
1285
|
+
async 'Viewlet.executeViewletCommand'(uid, command, ...args) {
|
|
1286
|
+
const fn = commandsById[command];
|
|
1287
|
+
if (!fn) {
|
|
1288
|
+
throw new Error(`Viewlet command not found: ${command}`);
|
|
1289
|
+
}
|
|
1290
|
+
await fn(uid, ...args);
|
|
1291
|
+
await requestRender(uid);
|
|
1292
|
+
}
|
|
1293
|
+
};
|
|
1294
|
+
},
|
|
1282
1295
|
diff(uid, modules, numbers) {
|
|
1283
1296
|
const {
|
|
1284
1297
|
oldState,
|
|
@@ -1310,6 +1323,9 @@ const create$4 = () => {
|
|
|
1310
1323
|
},
|
|
1311
1324
|
registerCommands(commandMap) {
|
|
1312
1325
|
Object.assign(commandMapRef, commandMap);
|
|
1326
|
+
for (const [key, fn] of Object.entries(commandMap)) {
|
|
1327
|
+
commandsById[toCommandId(key)] = fn;
|
|
1328
|
+
}
|
|
1313
1329
|
},
|
|
1314
1330
|
set(uid, oldState, newState, scheduledState) {
|
|
1315
1331
|
const current = states[uid];
|
|
@@ -3002,12 +3018,8 @@ const getPathEndIndex = pathName => {
|
|
|
3002
3018
|
return Math.min(queryIndex, hashIndex);
|
|
3003
3019
|
};
|
|
3004
3020
|
const getPathName = uri => {
|
|
3005
|
-
if (uri.startsWith('file://')) {
|
|
3006
|
-
|
|
3007
|
-
return new URL(uri).pathname;
|
|
3008
|
-
} catch {
|
|
3009
|
-
return uri;
|
|
3010
|
-
}
|
|
3021
|
+
if (uri.startsWith('file://') && URL.canParse(uri)) {
|
|
3022
|
+
return new URL(uri).pathname;
|
|
3011
3023
|
}
|
|
3012
3024
|
return uri;
|
|
3013
3025
|
};
|
|
@@ -3029,20 +3041,16 @@ const hasBinaryFileSuffix = uri => {
|
|
|
3029
3041
|
return binaryFileSuffixes.some(suffix => cleanPath.endsWith(suffix));
|
|
3030
3042
|
};
|
|
3031
3043
|
const getEditorInputFromUri = uri => {
|
|
3032
|
-
if (uri.startsWith('diff://?')) {
|
|
3033
|
-
|
|
3034
|
-
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
|
|
3038
|
-
|
|
3039
|
-
|
|
3040
|
-
|
|
3041
|
-
|
|
3042
|
-
};
|
|
3043
|
-
}
|
|
3044
|
-
} catch {
|
|
3045
|
-
// Ignore malformed legacy URIs and fall back to a text editor input.
|
|
3044
|
+
if (uri.startsWith('diff://?') && URL.canParse(uri)) {
|
|
3045
|
+
const parsed = new URL(uri);
|
|
3046
|
+
const uriLeft = parsed.searchParams.get('left');
|
|
3047
|
+
const uriRight = parsed.searchParams.get('right');
|
|
3048
|
+
if (uriLeft && uriRight) {
|
|
3049
|
+
return {
|
|
3050
|
+
type: 'diff-editor',
|
|
3051
|
+
uriLeft,
|
|
3052
|
+
uriRight
|
|
3053
|
+
};
|
|
3046
3054
|
}
|
|
3047
3055
|
}
|
|
3048
3056
|
if (uri.startsWith('extension-detail://')) {
|
|
@@ -3753,12 +3761,42 @@ const getLabel = uri => {
|
|
|
3753
3761
|
if (uri.startsWith('running-extensions://')) {
|
|
3754
3762
|
return 'Running Extensions';
|
|
3755
3763
|
}
|
|
3764
|
+
if (uri.startsWith('cookie-import-view://')) {
|
|
3765
|
+
return 'Import Firefox Cookies';
|
|
3766
|
+
}
|
|
3756
3767
|
if (uri.startsWith(inlineDiffPrefix)) {
|
|
3757
3768
|
return getInlineDiffLabel(uri);
|
|
3758
3769
|
}
|
|
3759
3770
|
return getBasename$1(uri);
|
|
3760
3771
|
};
|
|
3761
3772
|
|
|
3773
|
+
/**
|
|
3774
|
+
*
|
|
3775
|
+
* @param {string} uri
|
|
3776
|
+
* @returns
|
|
3777
|
+
*/
|
|
3778
|
+
const getFileIcon = uri => {
|
|
3779
|
+
if (uri === 'app://keybindings') {
|
|
3780
|
+
return `MaskIconRecordKey`;
|
|
3781
|
+
}
|
|
3782
|
+
if (uri.startsWith('extension-detail://')) {
|
|
3783
|
+
return `MaskIconExtensions`;
|
|
3784
|
+
}
|
|
3785
|
+
if (uri.startsWith('process-explorer://')) {
|
|
3786
|
+
return `MaskIconDebugAlt2`;
|
|
3787
|
+
}
|
|
3788
|
+
if (uri.startsWith('running-extensions://')) {
|
|
3789
|
+
return `MaskIconExtensions`;
|
|
3790
|
+
}
|
|
3791
|
+
if (uri.startsWith('cookie-import-view://')) {
|
|
3792
|
+
return `MaskIconRecordKey`;
|
|
3793
|
+
}
|
|
3794
|
+
if (uri.startsWith('search-editor://')) {
|
|
3795
|
+
return `MaskIconSearch`;
|
|
3796
|
+
}
|
|
3797
|
+
return '';
|
|
3798
|
+
};
|
|
3799
|
+
|
|
3762
3800
|
const getEditorInputTitle = editorInput => {
|
|
3763
3801
|
switch (editorInput.type) {
|
|
3764
3802
|
case 'binary':
|
|
@@ -4154,31 +4192,40 @@ const getFileIconsForTabs = async (tabs, fileIconCache) => {
|
|
|
4154
4192
|
};
|
|
4155
4193
|
};
|
|
4156
4194
|
|
|
4195
|
+
const updateIcon = (state, tabId, icon) => {
|
|
4196
|
+
return {
|
|
4197
|
+
...state,
|
|
4198
|
+
layout: {
|
|
4199
|
+
...state.layout,
|
|
4200
|
+
groups: state.layout.groups.map(group => ({
|
|
4201
|
+
...group,
|
|
4202
|
+
tabs: group.tabs.map(tab => tab.id === tabId ? {
|
|
4203
|
+
...tab,
|
|
4204
|
+
icon
|
|
4205
|
+
} : tab)
|
|
4206
|
+
}))
|
|
4207
|
+
}
|
|
4208
|
+
};
|
|
4209
|
+
};
|
|
4157
4210
|
const updateTabIcon = async (context, readyState, tabId) => {
|
|
4158
4211
|
const newTab = findTabById(readyState, tabId);
|
|
4159
4212
|
if (!newTab || !newTab.tab.uri) {
|
|
4160
4213
|
return undefined;
|
|
4161
4214
|
}
|
|
4215
|
+
const builtInIcon = getFileIcon(newTab.tab.uri);
|
|
4216
|
+
if (builtInIcon) {
|
|
4217
|
+
return context.updateState(state => updateIcon(state, tabId, builtInIcon));
|
|
4218
|
+
}
|
|
4162
4219
|
try {
|
|
4163
4220
|
const {
|
|
4164
4221
|
newFileIconCache
|
|
4165
4222
|
} = await getFileIconsForTabs([newTab.tab], readyState.fileIconCache);
|
|
4166
4223
|
const stateBeforeIconUpdate = context.getState();
|
|
4167
4224
|
const icon = newFileIconCache[newTab.tab.uri] || '';
|
|
4168
|
-
const stateWithIcon = {
|
|
4225
|
+
const stateWithIcon = updateIcon({
|
|
4169
4226
|
...stateBeforeIconUpdate,
|
|
4170
|
-
fileIconCache: newFileIconCache
|
|
4171
|
-
|
|
4172
|
-
...stateBeforeIconUpdate.layout,
|
|
4173
|
-
groups: stateBeforeIconUpdate.layout.groups.map(group => ({
|
|
4174
|
-
...group,
|
|
4175
|
-
tabs: group.tabs.map(tab => tab.id === tabId ? {
|
|
4176
|
-
...tab,
|
|
4177
|
-
icon
|
|
4178
|
-
} : tab)
|
|
4179
|
-
}))
|
|
4180
|
-
}
|
|
4181
|
-
};
|
|
4227
|
+
fileIconCache: newFileIconCache
|
|
4228
|
+
}, tabId, icon);
|
|
4182
4229
|
return context.updateState(() => stateWithIcon);
|
|
4183
4230
|
} catch {
|
|
4184
4231
|
return undefined;
|