@lvce-editor/main-area-worker 9.62.0 → 9.63.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 +30 -9
- package/package.json +1 -1
|
@@ -1503,6 +1503,8 @@ const getPreference = async key => {
|
|
|
1503
1503
|
return await invoke$2('Preferences.get', key);
|
|
1504
1504
|
};
|
|
1505
1505
|
|
|
1506
|
+
const cacheName = 'lvce0main-area-tabs';
|
|
1507
|
+
const cacheDuration = 90 * 24 * 60 * 60 * 1000;
|
|
1506
1508
|
const maxClosedTabs = 20;
|
|
1507
1509
|
const pendingOperations = new Map();
|
|
1508
1510
|
const sessionId = encodeURIComponent(`session-${new Date().toISOString()}`);
|
|
@@ -1536,9 +1538,23 @@ const isClosedTabEntry = value => {
|
|
|
1536
1538
|
return Boolean(entry.group && typeof entry.group === 'object' && entry.tab && typeof entry.tab === 'object' && typeof entry.groupIndex === 'number' && typeof entry.tabIndex === 'number');
|
|
1537
1539
|
};
|
|
1538
1540
|
const getEntries = async key => {
|
|
1539
|
-
const
|
|
1541
|
+
const cache = await caches.open(cacheName);
|
|
1542
|
+
const response = await cache.match(key);
|
|
1543
|
+
const entries = response ? await response.json() : [];
|
|
1540
1544
|
return Array.isArray(entries) ? entries.filter(isClosedTabEntry) : [];
|
|
1541
1545
|
};
|
|
1546
|
+
const setEntries = async (key, entries) => {
|
|
1547
|
+
const cache = await caches.open(cacheName);
|
|
1548
|
+
const value = JSON.stringify(entries);
|
|
1549
|
+
const expires = new Date(Date.now() + cacheDuration).toUTCString();
|
|
1550
|
+
await cache.put(key, new Response(value, {
|
|
1551
|
+
headers: {
|
|
1552
|
+
'Content-Length': String(value.length),
|
|
1553
|
+
'Content-Type': 'application/json',
|
|
1554
|
+
Expires: expires
|
|
1555
|
+
}
|
|
1556
|
+
}));
|
|
1557
|
+
};
|
|
1542
1558
|
const compact = entry => {
|
|
1543
1559
|
return {
|
|
1544
1560
|
...entry,
|
|
@@ -1557,7 +1573,7 @@ const add = (uid, entries) => {
|
|
|
1557
1573
|
const key = getKey(uid);
|
|
1558
1574
|
const existing = await getEntries(key);
|
|
1559
1575
|
const compactEntries = entries.map(compact);
|
|
1560
|
-
await
|
|
1576
|
+
await setEntries(key, [...existing, ...compactEntries].slice(-maxClosedTabs));
|
|
1561
1577
|
} catch {
|
|
1562
1578
|
// Closed tab history is optional and must never break editor commands.
|
|
1563
1579
|
}
|
|
@@ -1566,7 +1582,7 @@ const add = (uid, entries) => {
|
|
|
1566
1582
|
const clear = uid => {
|
|
1567
1583
|
return run(uid, async () => {
|
|
1568
1584
|
try {
|
|
1569
|
-
await
|
|
1585
|
+
await setEntries(getKey(uid), []);
|
|
1570
1586
|
} catch {
|
|
1571
1587
|
// Closed tab history is optional and must never break workspace changes.
|
|
1572
1588
|
}
|
|
@@ -1581,7 +1597,7 @@ const takeLast = uid => {
|
|
|
1581
1597
|
if (!isClosedTabEntry(entry)) {
|
|
1582
1598
|
return undefined;
|
|
1583
1599
|
}
|
|
1584
|
-
await
|
|
1600
|
+
await setEntries(key, entries.slice(0, -1));
|
|
1585
1601
|
return entry;
|
|
1586
1602
|
} catch {
|
|
1587
1603
|
return undefined;
|
|
@@ -2804,7 +2820,7 @@ const getEditorInputUri = editorInput => {
|
|
|
2804
2820
|
case 'webview':
|
|
2805
2821
|
return editorInput.uri;
|
|
2806
2822
|
case 'extension-detail-view':
|
|
2807
|
-
return `extension-detail
|
|
2823
|
+
return `extension-detail:///${encodeURIComponent(editorInput.extensionId)}`;
|
|
2808
2824
|
case 'process-explorer':
|
|
2809
2825
|
return 'process-explorer://';
|
|
2810
2826
|
case 'running-extensions':
|
|
@@ -2849,6 +2865,12 @@ const hasBinaryFileSuffix = uri => {
|
|
|
2849
2865
|
const cleanPath = pathName.slice(0, endIndex).toLowerCase();
|
|
2850
2866
|
return binaryFileSuffixes.some(suffix => cleanPath.endsWith(suffix));
|
|
2851
2867
|
};
|
|
2868
|
+
const getExtensionId = uri => {
|
|
2869
|
+
if (uri.startsWith('extension-detail:///')) {
|
|
2870
|
+
return decodeURIComponent(uri.slice('extension-detail:///'.length).split('/', 1)[0]);
|
|
2871
|
+
}
|
|
2872
|
+
return uri.slice('extension-detail://'.length).split('/', 1)[0];
|
|
2873
|
+
};
|
|
2852
2874
|
const getEditorInputFromUri = uri => {
|
|
2853
2875
|
if (uri.startsWith('diff://?') && URL.canParse(uri)) {
|
|
2854
2876
|
const parsed = new URL(uri);
|
|
@@ -2863,8 +2885,7 @@ const getEditorInputFromUri = uri => {
|
|
|
2863
2885
|
}
|
|
2864
2886
|
}
|
|
2865
2887
|
if (uri.startsWith('extension-detail://')) {
|
|
2866
|
-
const
|
|
2867
|
-
const extensionId = extensionIdWithPath.split('/', 1)[0];
|
|
2888
|
+
const extensionId = getExtensionId(uri);
|
|
2868
2889
|
if (extensionId) {
|
|
2869
2890
|
return {
|
|
2870
2891
|
extensionId,
|
|
@@ -2943,7 +2964,7 @@ const normalizeTabEditorInput = tab => {
|
|
|
2943
2964
|
if (!editorInput) {
|
|
2944
2965
|
return Object.hasOwn(tab, 'editorType') ? rest : tab;
|
|
2945
2966
|
}
|
|
2946
|
-
const uri = typeof tab.uri === 'string' ? tab.uri : getEditorInputUri(editorInput);
|
|
2967
|
+
const uri = editorInput.type !== 'extension-detail-view' && typeof tab.uri === 'string' ? tab.uri : getEditorInputUri(editorInput);
|
|
2947
2968
|
return {
|
|
2948
2969
|
...rest,
|
|
2949
2970
|
editorInput,
|
|
@@ -4754,7 +4775,7 @@ const applyInitialCursorPosition = async (state, tabId, position) => {
|
|
|
4754
4775
|
if (!tab || tab.editorUid < 0 || tab.loadingState !== 'loaded' || tab.editorInput?.type !== 'editor') {
|
|
4755
4776
|
return;
|
|
4756
4777
|
}
|
|
4757
|
-
await invoke$1(state.applicationId, 'Viewlet.executeViewletCommand', tab.editorUid, 'cursorSet', position.rowIndex, position.columnIndex);
|
|
4778
|
+
await invoke$1(state.applicationId, 'Viewlet.executeViewletCommand', tab.editorUid, position.highlightProblem ? 'revealProblem' : 'cursorSet', position.rowIndex, position.columnIndex);
|
|
4758
4779
|
};
|
|
4759
4780
|
|
|
4760
4781
|
const findTabByUri = (state, uri) => {
|