@lvce-editor/quick-pick-worker 4.30.0 → 4.32.0
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/quickPickWorkerMain.js +281 -78
- package/package.json +1 -1
|
@@ -553,7 +553,7 @@ const execute = (command, ...args) => {
|
|
|
553
553
|
|
|
554
554
|
const Two$1 = '2.0';
|
|
555
555
|
const callbacks$2 = Object.create(null);
|
|
556
|
-
const get$
|
|
556
|
+
const get$5 = id => {
|
|
557
557
|
return callbacks$2[id];
|
|
558
558
|
};
|
|
559
559
|
const remove$2 = id => {
|
|
@@ -774,7 +774,7 @@ const warn$1 = (...args) => {
|
|
|
774
774
|
console.warn(...args);
|
|
775
775
|
};
|
|
776
776
|
const resolve = (id, response) => {
|
|
777
|
-
const fn = get$
|
|
777
|
+
const fn = get$5(id);
|
|
778
778
|
if (!fn) {
|
|
779
779
|
console.log(response);
|
|
780
780
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -1174,10 +1174,10 @@ const createMockRpc = ({
|
|
|
1174
1174
|
};
|
|
1175
1175
|
|
|
1176
1176
|
const rpcs = Object.create(null);
|
|
1177
|
-
const set$
|
|
1177
|
+
const set$b = (id, rpc) => {
|
|
1178
1178
|
rpcs[id] = rpc;
|
|
1179
1179
|
};
|
|
1180
|
-
const get$
|
|
1180
|
+
const get$4 = id => {
|
|
1181
1181
|
return rpcs[id];
|
|
1182
1182
|
};
|
|
1183
1183
|
const remove$1 = id => {
|
|
@@ -1188,18 +1188,18 @@ const remove$1 = id => {
|
|
|
1188
1188
|
const create$4 = rpcId => {
|
|
1189
1189
|
return {
|
|
1190
1190
|
async dispose() {
|
|
1191
|
-
const rpc = get$
|
|
1191
|
+
const rpc = get$4(rpcId);
|
|
1192
1192
|
await rpc.dispose();
|
|
1193
1193
|
},
|
|
1194
1194
|
// @ts-ignore
|
|
1195
1195
|
invoke(method, ...params) {
|
|
1196
|
-
const rpc = get$
|
|
1196
|
+
const rpc = get$4(rpcId);
|
|
1197
1197
|
// @ts-ignore
|
|
1198
1198
|
return rpc.invoke(method, ...params);
|
|
1199
1199
|
},
|
|
1200
1200
|
// @ts-ignore
|
|
1201
1201
|
invokeAndTransfer(method, ...params) {
|
|
1202
|
-
const rpc = get$
|
|
1202
|
+
const rpc = get$4(rpcId);
|
|
1203
1203
|
// @ts-ignore
|
|
1204
1204
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1205
1205
|
},
|
|
@@ -1207,7 +1207,7 @@ const create$4 = rpcId => {
|
|
|
1207
1207
|
const mockRpc = createMockRpc({
|
|
1208
1208
|
commandMap
|
|
1209
1209
|
});
|
|
1210
|
-
set$
|
|
1210
|
+
set$b(rpcId, mockRpc);
|
|
1211
1211
|
// @ts-ignore
|
|
1212
1212
|
mockRpc[Symbol.dispose] = () => {
|
|
1213
1213
|
remove$1(rpcId);
|
|
@@ -1216,7 +1216,7 @@ const create$4 = rpcId => {
|
|
|
1216
1216
|
return mockRpc;
|
|
1217
1217
|
},
|
|
1218
1218
|
set(rpc) {
|
|
1219
|
-
set$
|
|
1219
|
+
set$b(rpcId, rpc);
|
|
1220
1220
|
}
|
|
1221
1221
|
};
|
|
1222
1222
|
};
|
|
@@ -1243,7 +1243,7 @@ const FocusQuickPickInput = 20;
|
|
|
1243
1243
|
|
|
1244
1244
|
const {
|
|
1245
1245
|
invoke: invoke$8,
|
|
1246
|
-
set: set$
|
|
1246
|
+
set: set$a
|
|
1247
1247
|
} = create$4(EditorWorker);
|
|
1248
1248
|
const getLines = async editorUid => {
|
|
1249
1249
|
const lines = await invoke$8('Editor.getLines2', editorUid);
|
|
@@ -1252,7 +1252,7 @@ const getLines = async editorUid => {
|
|
|
1252
1252
|
|
|
1253
1253
|
const {
|
|
1254
1254
|
invoke: invoke$7,
|
|
1255
|
-
set: set$
|
|
1255
|
+
set: set$9
|
|
1256
1256
|
} = create$4(ExtensionManagementWorker);
|
|
1257
1257
|
const getLanguages = (platform, assetDir) => {
|
|
1258
1258
|
return invoke$7('Extensions.getLanguages', platform, assetDir);
|
|
@@ -1260,19 +1260,25 @@ const getLanguages = (platform, assetDir) => {
|
|
|
1260
1260
|
|
|
1261
1261
|
const {
|
|
1262
1262
|
invoke: invoke$6,
|
|
1263
|
-
set: set$
|
|
1263
|
+
set: set$8
|
|
1264
1264
|
} = create$4(7013);
|
|
1265
1265
|
|
|
1266
1266
|
const {
|
|
1267
1267
|
invoke: invoke$5,
|
|
1268
|
-
set: set$
|
|
1268
|
+
set: set$7
|
|
1269
1269
|
} = create$4(RendererProcess);
|
|
1270
1270
|
|
|
1271
1271
|
const {
|
|
1272
1272
|
invoke: invoke$4,
|
|
1273
1273
|
invokeAndTransfer,
|
|
1274
|
-
set: set$
|
|
1274
|
+
set: set$6
|
|
1275
1275
|
} = create$4(RendererWorker);
|
|
1276
|
+
const initializeRendererWorkerForWorker = async commandMap => {
|
|
1277
|
+
const rpc = await create$5({
|
|
1278
|
+
commandMap
|
|
1279
|
+
});
|
|
1280
|
+
set$6(rpc);
|
|
1281
|
+
};
|
|
1276
1282
|
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
1277
1283
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
1278
1284
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToEditorWorker', port, command, rpcId);
|
|
@@ -1656,10 +1662,10 @@ const create$2 = () => {
|
|
|
1656
1662
|
|
|
1657
1663
|
const {
|
|
1658
1664
|
dispose: dispose$1,
|
|
1659
|
-
get: get$
|
|
1665
|
+
get: get$3,
|
|
1660
1666
|
getCommandIds,
|
|
1661
1667
|
registerCommands,
|
|
1662
|
-
set: set$
|
|
1668
|
+
set: set$5,
|
|
1663
1669
|
wrapAsyncCommand,
|
|
1664
1670
|
wrapCommand
|
|
1665
1671
|
} = create$2();
|
|
@@ -1956,7 +1962,7 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, _
|
|
|
1956
1962
|
platform,
|
|
1957
1963
|
value: ''
|
|
1958
1964
|
};
|
|
1959
|
-
set$
|
|
1965
|
+
set$5(uid, state, state);
|
|
1960
1966
|
};
|
|
1961
1967
|
|
|
1962
1968
|
const isEqual$4 = (oldState, newState) => {
|
|
@@ -2007,7 +2013,7 @@ const diff2 = uid => {
|
|
|
2007
2013
|
const {
|
|
2008
2014
|
newState,
|
|
2009
2015
|
oldState
|
|
2010
|
-
} = get$
|
|
2016
|
+
} = get$3(uid);
|
|
2011
2017
|
return diff(oldState, newState);
|
|
2012
2018
|
};
|
|
2013
2019
|
|
|
@@ -2723,6 +2729,120 @@ const collectWarnings = items => {
|
|
|
2723
2729
|
return warnings;
|
|
2724
2730
|
};
|
|
2725
2731
|
|
|
2732
|
+
const state$4 = {};
|
|
2733
|
+
const set$4 = value => {
|
|
2734
|
+
state$4.rpc = value;
|
|
2735
|
+
};
|
|
2736
|
+
const invoke$3 = (method, ...args) => {
|
|
2737
|
+
if (!state$4.rpc) {
|
|
2738
|
+
throw new Error('Cache worker is not initialized');
|
|
2739
|
+
}
|
|
2740
|
+
return state$4.rpc.invoke(method, ...args);
|
|
2741
|
+
};
|
|
2742
|
+
|
|
2743
|
+
const cacheName$1 = 'quick-pick-commands-v1';
|
|
2744
|
+
const version = 1;
|
|
2745
|
+
const isJsonValue = value => {
|
|
2746
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean') {
|
|
2747
|
+
return true;
|
|
2748
|
+
}
|
|
2749
|
+
if (typeof value === 'number') {
|
|
2750
|
+
return Number.isFinite(value);
|
|
2751
|
+
}
|
|
2752
|
+
if (Array.isArray(value)) {
|
|
2753
|
+
return value.every(isJsonValue);
|
|
2754
|
+
}
|
|
2755
|
+
if (typeof value !== 'object') {
|
|
2756
|
+
return false;
|
|
2757
|
+
}
|
|
2758
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2759
|
+
return (prototype === Object.prototype || prototype === null) && Object.values(value).every(isJsonValue);
|
|
2760
|
+
};
|
|
2761
|
+
const canSerialize = value => {
|
|
2762
|
+
try {
|
|
2763
|
+
JSON.stringify(value);
|
|
2764
|
+
return true;
|
|
2765
|
+
} catch {
|
|
2766
|
+
return false;
|
|
2767
|
+
}
|
|
2768
|
+
};
|
|
2769
|
+
const isCommand = value => {
|
|
2770
|
+
if (!value || typeof value !== 'object') {
|
|
2771
|
+
return false;
|
|
2772
|
+
}
|
|
2773
|
+
const command = value;
|
|
2774
|
+
if (typeof command.id !== 'string' || typeof command.label !== 'string') {
|
|
2775
|
+
return false;
|
|
2776
|
+
}
|
|
2777
|
+
if (command.args === undefined) {
|
|
2778
|
+
return true;
|
|
2779
|
+
}
|
|
2780
|
+
return canSerialize(command.args) && isJsonValue(command.args);
|
|
2781
|
+
};
|
|
2782
|
+
const isContribution = value => {
|
|
2783
|
+
if (!value || typeof value !== 'object') {
|
|
2784
|
+
return false;
|
|
2785
|
+
}
|
|
2786
|
+
const contribution = value;
|
|
2787
|
+
if (typeof contribution.hash !== 'string' || !/^[\da-f]{64}$/.test(contribution.hash) || !Array.isArray(contribution.commands)) {
|
|
2788
|
+
return false;
|
|
2789
|
+
}
|
|
2790
|
+
return contribution.commands.every(isCommand);
|
|
2791
|
+
};
|
|
2792
|
+
const isCacheableCommands = commands => {
|
|
2793
|
+
try {
|
|
2794
|
+
return commands.every(isCommand);
|
|
2795
|
+
} catch {
|
|
2796
|
+
return false;
|
|
2797
|
+
}
|
|
2798
|
+
};
|
|
2799
|
+
const isEntry$1 = value => {
|
|
2800
|
+
if (!value || typeof value !== 'object') {
|
|
2801
|
+
return false;
|
|
2802
|
+
}
|
|
2803
|
+
const entry = value;
|
|
2804
|
+
return entry.version === version && isContribution(entry.builtin) && isContribution(entry.extensions);
|
|
2805
|
+
};
|
|
2806
|
+
const getCacheUrl = (applicationId, assetDir, platform) => {
|
|
2807
|
+
const context = JSON.stringify({
|
|
2808
|
+
applicationId: applicationId ?? null,
|
|
2809
|
+
assetDir,
|
|
2810
|
+
platform
|
|
2811
|
+
});
|
|
2812
|
+
return `https://quick-pick-cache.invalid/cache/v1/commands/${encodeURIComponent(context)}`;
|
|
2813
|
+
};
|
|
2814
|
+
const get$2 = async (applicationId, assetDir, platform) => {
|
|
2815
|
+
try {
|
|
2816
|
+
const cached = await invoke$3('Cache.getCacheStorageItem', getCacheUrl(applicationId, assetDir, platform), cacheName$1);
|
|
2817
|
+
if (!cached) {
|
|
2818
|
+
return undefined;
|
|
2819
|
+
}
|
|
2820
|
+
const expires = Date.parse(cached.headers.expires || '');
|
|
2821
|
+
if (!Number.isFinite(expires) || expires <= Date.now()) {
|
|
2822
|
+
return undefined;
|
|
2823
|
+
}
|
|
2824
|
+
const entry = JSON.parse(new TextDecoder().decode(cached.body));
|
|
2825
|
+
return isEntry$1(entry) ? entry : undefined;
|
|
2826
|
+
} catch {
|
|
2827
|
+
return undefined;
|
|
2828
|
+
}
|
|
2829
|
+
};
|
|
2830
|
+
const set$3 = async (applicationId, assetDir, platform, entry) => {
|
|
2831
|
+
const expires = new Date(Date.now() + 90 * 24 * 60 * 60 * 1000).toUTCString();
|
|
2832
|
+
const body = JSON.stringify(entry);
|
|
2833
|
+
const headers = {
|
|
2834
|
+
'cache-control': 'private, max-age=7776000',
|
|
2835
|
+
'content-length': String(new TextEncoder().encode(body).byteLength),
|
|
2836
|
+
'content-type': 'application/json',
|
|
2837
|
+
expires
|
|
2838
|
+
};
|
|
2839
|
+
try {
|
|
2840
|
+
await invoke$3('Cache.setCacheStorageItem', getCacheUrl(applicationId, assetDir, platform), body, cacheName$1, headers);
|
|
2841
|
+
} catch {
|
|
2842
|
+
// Caching is optional; storage failures must not break command selection.
|
|
2843
|
+
}
|
|
2844
|
+
};
|
|
2845
|
+
|
|
2726
2846
|
const handleError = async (error, notify = true, prefix = '') => {
|
|
2727
2847
|
console.error(error);
|
|
2728
2848
|
};
|
|
@@ -2751,7 +2871,7 @@ const warn = (...args) => {
|
|
|
2751
2871
|
console.warn(...args);
|
|
2752
2872
|
};
|
|
2753
2873
|
|
|
2754
|
-
const state$
|
|
2874
|
+
const state$3 = {
|
|
2755
2875
|
menuEntries: []
|
|
2756
2876
|
};
|
|
2757
2877
|
const getAll = async () => {
|
|
@@ -2762,22 +2882,46 @@ const getAll = async () => {
|
|
|
2762
2882
|
} catch {
|
|
2763
2883
|
// ignore
|
|
2764
2884
|
}
|
|
2765
|
-
return state$
|
|
2885
|
+
return state$3.menuEntries;
|
|
2766
2886
|
};
|
|
2767
2887
|
const add$1 = menuEntries => {
|
|
2768
|
-
state$
|
|
2888
|
+
state$3.menuEntries = [...state$3.menuEntries, ...menuEntries];
|
|
2769
2889
|
};
|
|
2770
2890
|
|
|
2771
2891
|
const changeLanguageModePick = {
|
|
2772
2892
|
id: 'QuickPick.changeLanguageMode',
|
|
2773
2893
|
label: 'Change Language Mode'
|
|
2774
2894
|
};
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2895
|
+
const isCommandProviderResponse = value => {
|
|
2896
|
+
return !!value && typeof value === 'object' && !Array.isArray(value) && 'matchesCache' in value && 'hash' in value;
|
|
2897
|
+
};
|
|
2898
|
+
const getBuiltinPicks = async ifNonMatch => {
|
|
2899
|
+
const result = await invoke$4('Layout.getAllQuickPickMenuEntries', ifNonMatch);
|
|
2900
|
+
if (isCommandProviderResponse(result)) {
|
|
2901
|
+
const response = result;
|
|
2902
|
+
return response.commands ? {
|
|
2903
|
+
...response,
|
|
2904
|
+
commands: [...response.commands, changeLanguageModePick]
|
|
2905
|
+
} : response;
|
|
2906
|
+
}
|
|
2907
|
+
return Array.isArray(result) ? [...result, changeLanguageModePick] : [...(await getAll()), changeLanguageModePick];
|
|
2908
|
+
};
|
|
2909
|
+
const getBuiltinFallback = async () => {
|
|
2778
2910
|
const builtinPicks = await getAll();
|
|
2779
2911
|
return [...builtinPicks, changeLanguageModePick];
|
|
2780
2912
|
};
|
|
2913
|
+
const getBuiltinCommands = async (response, cached) => {
|
|
2914
|
+
if (isCommandProviderResponse(response)) {
|
|
2915
|
+
if (response.matchesCache) {
|
|
2916
|
+
return cached?.builtin.commands ?? [];
|
|
2917
|
+
}
|
|
2918
|
+
return response.commands ?? getBuiltinFallback();
|
|
2919
|
+
}
|
|
2920
|
+
if (Array.isArray(response)) {
|
|
2921
|
+
return response;
|
|
2922
|
+
}
|
|
2923
|
+
return getBuiltinFallback();
|
|
2924
|
+
};
|
|
2781
2925
|
const prefixIdWithExt = item => {
|
|
2782
2926
|
return {
|
|
2783
2927
|
...item,
|
|
@@ -2785,16 +2929,24 @@ const prefixIdWithExt = item => {
|
|
|
2785
2929
|
label: item.label || item.id
|
|
2786
2930
|
};
|
|
2787
2931
|
};
|
|
2788
|
-
const getExtensionPicks = async (assetDir, platform, applicationId) => {
|
|
2932
|
+
const getExtensionPicks = async (assetDir, platform, applicationId, ifNonMatch) => {
|
|
2789
2933
|
try {
|
|
2790
|
-
|
|
2791
|
-
// Assert.string(assetDir)
|
|
2792
|
-
// Assert.number(platform)
|
|
2793
|
-
// TODO ask extension management worker directly
|
|
2794
|
-
// TODO don't call this every time, cache the results
|
|
2795
|
-
const extensionPicks = applicationId === undefined ? await invoke$4('ExtensionHost.getCommands', assetDir, platform) : await invoke$4('Application.execute', applicationId, 'ExtensionHost.getCommands', assetDir, platform);
|
|
2934
|
+
const extensionPicks = applicationId === undefined ? await invoke$4('ExtensionHost.getCommands', assetDir, platform, undefined, ifNonMatch) : await invoke$4('Application.execute', applicationId, 'ExtensionHost.getCommands', assetDir, platform, ifNonMatch);
|
|
2796
2935
|
if (!extensionPicks) {
|
|
2797
|
-
return
|
|
2936
|
+
return undefined;
|
|
2937
|
+
}
|
|
2938
|
+
if (isCommandProviderResponse(extensionPicks)) {
|
|
2939
|
+
if (extensionPicks.matchesCache || !extensionPicks.commands) {
|
|
2940
|
+
return extensionPicks;
|
|
2941
|
+
}
|
|
2942
|
+
const warnings = collectWarnings(extensionPicks.commands);
|
|
2943
|
+
for (const warning of warnings) {
|
|
2944
|
+
warn(`[QuickPick] ${warning}`);
|
|
2945
|
+
}
|
|
2946
|
+
return {
|
|
2947
|
+
...extensionPicks,
|
|
2948
|
+
commands: extensionPicks.commands.map(prefixIdWithExt)
|
|
2949
|
+
};
|
|
2798
2950
|
}
|
|
2799
2951
|
const warnings = collectWarnings(extensionPicks);
|
|
2800
2952
|
for (const warning of warnings) {
|
|
@@ -2804,7 +2956,59 @@ const getExtensionPicks = async (assetDir, platform, applicationId) => {
|
|
|
2804
2956
|
return mappedPicks;
|
|
2805
2957
|
} catch (error) {
|
|
2806
2958
|
console.error(`Failed to get extension picks: ${error}`);
|
|
2807
|
-
return
|
|
2959
|
+
return undefined;
|
|
2960
|
+
}
|
|
2961
|
+
};
|
|
2962
|
+
const getExtensionCommands = (response, cached) => {
|
|
2963
|
+
if (isCommandProviderResponse(response)) {
|
|
2964
|
+
if (response.matchesCache) {
|
|
2965
|
+
return cached?.extensions.commands ?? [];
|
|
2966
|
+
}
|
|
2967
|
+
return response.commands ?? [];
|
|
2968
|
+
}
|
|
2969
|
+
if (Array.isArray(response)) {
|
|
2970
|
+
return response;
|
|
2971
|
+
}
|
|
2972
|
+
return cached?.extensions.commands ?? [];
|
|
2973
|
+
};
|
|
2974
|
+
const toCachedCommands = items => {
|
|
2975
|
+
const commands = items.map(item => ({
|
|
2976
|
+
...(item.args !== undefined && {
|
|
2977
|
+
args: item.args
|
|
2978
|
+
}),
|
|
2979
|
+
id: String(item.id),
|
|
2980
|
+
label: typeof item.label === 'string' ? item.label : String(item.id)
|
|
2981
|
+
}));
|
|
2982
|
+
return isCacheableCommands(commands) ? commands : undefined;
|
|
2983
|
+
};
|
|
2984
|
+
const saveCommandCache = async (applicationId, assetDir, platform, cached, builtinResponse, extensionResponse, builtinPicks, extensionPicks) => {
|
|
2985
|
+
const builtinCommands = toCachedCommands(builtinPicks);
|
|
2986
|
+
const extensionCommands = toCachedCommands(extensionPicks);
|
|
2987
|
+
if (!builtinCommands || !extensionCommands) {
|
|
2988
|
+
return;
|
|
2989
|
+
}
|
|
2990
|
+
const builtinHash = isCommandProviderResponse(builtinResponse) ? builtinResponse.hash : cached?.builtin.hash;
|
|
2991
|
+
const extensionHash = isCommandProviderResponse(extensionResponse) ? extensionResponse.hash : cached?.extensions.hash;
|
|
2992
|
+
if (!builtinHash || !extensionHash) {
|
|
2993
|
+
return;
|
|
2994
|
+
}
|
|
2995
|
+
await set$3(applicationId, assetDir, platform, {
|
|
2996
|
+
builtin: {
|
|
2997
|
+
commands: builtinCommands,
|
|
2998
|
+
hash: builtinHash
|
|
2999
|
+
},
|
|
3000
|
+
extensions: {
|
|
3001
|
+
commands: extensionCommands,
|
|
3002
|
+
hash: extensionHash
|
|
3003
|
+
},
|
|
3004
|
+
version: 1
|
|
3005
|
+
});
|
|
3006
|
+
};
|
|
3007
|
+
const getOptional = async callback => {
|
|
3008
|
+
try {
|
|
3009
|
+
return await callback();
|
|
3010
|
+
} catch {
|
|
3011
|
+
return undefined;
|
|
2808
3012
|
}
|
|
2809
3013
|
};
|
|
2810
3014
|
const toProtoVisibleItem$3 = item => {
|
|
@@ -2829,15 +3033,25 @@ const getPicks$e = async (value, args, {
|
|
|
2829
3033
|
assetDir = '',
|
|
2830
3034
|
platform = 0
|
|
2831
3035
|
} = {}) => {
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
3036
|
+
let cacheEnabled = false;
|
|
3037
|
+
try {
|
|
3038
|
+
cacheEnabled = (await invoke$4('Preferences.get', 'quickPick.cache')) !== false;
|
|
3039
|
+
} catch {
|
|
3040
|
+
// If preferences are unavailable, preserve the existing uncached command behavior.
|
|
3041
|
+
}
|
|
3042
|
+
const cached = cacheEnabled ? await get$2(applicationId, assetDir, platform) : undefined;
|
|
3043
|
+
const [builtinResponse, extensionResponse] = await Promise.all([getOptional(() => getBuiltinPicks(cacheEnabled ? cached?.builtin.hash ?? null : undefined)), getOptional(() => getExtensionPicks(assetDir, platform, applicationId, cacheEnabled ? cached?.extensions.hash ?? null : undefined))]);
|
|
3044
|
+
const builtinPicks = await getBuiltinCommands(builtinResponse, cached);
|
|
3045
|
+
const extensionPicks = getExtensionCommands(extensionResponse, cached);
|
|
3046
|
+
if (cacheEnabled) {
|
|
3047
|
+
await saveCommandCache(applicationId, assetDir, platform, cached, builtinResponse, extensionResponse, builtinPicks, extensionPicks);
|
|
3048
|
+
}
|
|
2835
3049
|
const allPicks = [...builtinPicks, ...extensionPicks];
|
|
2836
3050
|
const converted = allPicks.map(toProtoVisibleItem$3);
|
|
2837
3051
|
return value === '>' ? converted.toSorted((a, b) => a.label.localeCompare(b.label)) : converted;
|
|
2838
3052
|
};
|
|
2839
3053
|
|
|
2840
|
-
const state$
|
|
3054
|
+
const state$2 = {
|
|
2841
3055
|
args: [],
|
|
2842
3056
|
items: Object.create(null)
|
|
2843
3057
|
};
|
|
@@ -2847,24 +3061,24 @@ const idState = {
|
|
|
2847
3061
|
};
|
|
2848
3062
|
const add = items => {
|
|
2849
3063
|
const nextId = ++idState.value;
|
|
2850
|
-
state$
|
|
3064
|
+
state$2.items[nextId] = items;
|
|
2851
3065
|
return nextId;
|
|
2852
3066
|
};
|
|
2853
3067
|
const get$1 = id => {
|
|
2854
|
-
return state$
|
|
3068
|
+
return state$2.items[id] || [];
|
|
2855
3069
|
};
|
|
2856
3070
|
const remove = id => {
|
|
2857
|
-
delete state$
|
|
3071
|
+
delete state$2.items[id];
|
|
2858
3072
|
};
|
|
2859
3073
|
|
|
2860
|
-
const state$
|
|
3074
|
+
const state$1 = {
|
|
2861
3075
|
rpc: undefined
|
|
2862
3076
|
};
|
|
2863
|
-
const set$
|
|
2864
|
-
state$
|
|
3077
|
+
const set$2 = newRpc => {
|
|
3078
|
+
state$1.rpc = newRpc;
|
|
2865
3079
|
};
|
|
2866
|
-
const invoke$
|
|
2867
|
-
return state$
|
|
3080
|
+
const invoke$2 = (method, ...args) => {
|
|
3081
|
+
return state$1.rpc.invoke(method, ...args);
|
|
2868
3082
|
};
|
|
2869
3083
|
|
|
2870
3084
|
const isTextInput = args => {
|
|
@@ -2895,14 +3109,14 @@ const toProtoVisibleItem$2 = item => {
|
|
|
2895
3109
|
};
|
|
2896
3110
|
};
|
|
2897
3111
|
const getPicks$d = async (searchValue, args) => {
|
|
2898
|
-
state$
|
|
3112
|
+
state$2.args = args;
|
|
2899
3113
|
if (isTextInput(args)) {
|
|
2900
3114
|
return [];
|
|
2901
3115
|
}
|
|
2902
3116
|
const options = args.at(-1);
|
|
2903
3117
|
let items;
|
|
2904
3118
|
if (options?.mode === 'quickInput') {
|
|
2905
|
-
items = searchValue === '' && options?.customItemsId ? get$1(options.customItemsId) : await invoke$
|
|
3119
|
+
items = searchValue === '' && options?.customItemsId ? get$1(options.customItemsId) : await invoke$2('ExtensionHostQuickPick.renderQuickInput', options.quickInputId, searchValue);
|
|
2906
3120
|
} else {
|
|
2907
3121
|
items = options?.customItemsId ? get$1(options.customItemsId) : args[1] || [];
|
|
2908
3122
|
}
|
|
@@ -2930,20 +3144,16 @@ const getWorkspacePath = async () => {
|
|
|
2930
3144
|
return invoke$4('Workspace.getUri');
|
|
2931
3145
|
};
|
|
2932
3146
|
|
|
2933
|
-
const state$1 = {};
|
|
2934
|
-
const set$2 = value => {
|
|
2935
|
-
state$1.rpc = value;
|
|
2936
|
-
};
|
|
2937
|
-
const invoke$2 = (method, ...args) => {
|
|
2938
|
-
if (!state$1.rpc) {
|
|
2939
|
-
throw new Error('Cache worker is not initialized');
|
|
2940
|
-
}
|
|
2941
|
-
return state$1.rpc.invoke(method, ...args);
|
|
2942
|
-
};
|
|
2943
|
-
|
|
2944
3147
|
const cacheName = 'quick-pick-files-v1';
|
|
3148
|
+
const encodePathSegment = segment => encodeURIComponent(segment).replaceAll('+', '%2B').replaceAll(/%25([\da-f]{2})/gi, '%$1');
|
|
2945
3149
|
const cacheUrl = workspace => {
|
|
2946
|
-
const
|
|
3150
|
+
const uriMatch = workspace.match(/^([a-z][\da-z+.-]*):\/\/([^/]*)(\/.*)?$/i);
|
|
3151
|
+
if (uriMatch) {
|
|
3152
|
+
const [, scheme, authority, uriPath = ''] = uriMatch;
|
|
3153
|
+
const path = [scheme.toLowerCase(), encodePathSegment(authority), ...uriPath.split('/').filter(Boolean).map(encodePathSegment)].filter(Boolean).join('/');
|
|
3154
|
+
return `https://quick-pick-cache.invalid/cache/v1/${path}`;
|
|
3155
|
+
}
|
|
3156
|
+
const path = workspace.replaceAll('\\', '/').replace(/^\/+/, '').split('/').filter(Boolean).map(encodePathSegment).join('/');
|
|
2947
3157
|
return `https://quick-pick-cache.invalid/cache/v1/file/${path}`;
|
|
2948
3158
|
};
|
|
2949
3159
|
const isEntry = value => {
|
|
@@ -2955,7 +3165,7 @@ const isEntry = value => {
|
|
|
2955
3165
|
};
|
|
2956
3166
|
const get = async workspace => {
|
|
2957
3167
|
try {
|
|
2958
|
-
const cached = await invoke$
|
|
3168
|
+
const cached = await invoke$3('Cache.getCacheStorageItem', cacheUrl(workspace), cacheName);
|
|
2959
3169
|
if (!cached) {
|
|
2960
3170
|
return undefined;
|
|
2961
3171
|
}
|
|
@@ -2979,7 +3189,7 @@ const set$1 = async (workspace, entry) => {
|
|
|
2979
3189
|
expires
|
|
2980
3190
|
};
|
|
2981
3191
|
try {
|
|
2982
|
-
await invoke$
|
|
3192
|
+
await invoke$3('Cache.setCacheStorageItem', cacheUrl(workspace), body, cacheName, headers);
|
|
2983
3193
|
} catch {
|
|
2984
3194
|
// Caching is optional; a storage failure must not break file search.
|
|
2985
3195
|
}
|
|
@@ -3655,7 +3865,7 @@ const getOptions = args => {
|
|
|
3655
3865
|
const selectPick$a = async (_pick, value) => {
|
|
3656
3866
|
const {
|
|
3657
3867
|
args
|
|
3658
|
-
} = state$
|
|
3868
|
+
} = state$2;
|
|
3659
3869
|
const options = getOptions(args);
|
|
3660
3870
|
if (options.executeItemCommand && _pick.command) {
|
|
3661
3871
|
return {
|
|
@@ -4364,7 +4574,7 @@ const handleMessagePort = async port => {
|
|
|
4364
4574
|
isMessagePortOpen: true,
|
|
4365
4575
|
messagePort: port
|
|
4366
4576
|
});
|
|
4367
|
-
set$
|
|
4577
|
+
set$2(rpc);
|
|
4368
4578
|
};
|
|
4369
4579
|
|
|
4370
4580
|
const state = {
|
|
@@ -4380,7 +4590,7 @@ const invoke$1 = (method, ...params) => {
|
|
|
4380
4590
|
return invoke$5(method, ...params);
|
|
4381
4591
|
};
|
|
4382
4592
|
const set = rpc => {
|
|
4383
|
-
set$
|
|
4593
|
+
set$7(rpc);
|
|
4384
4594
|
state.connected = true;
|
|
4385
4595
|
};
|
|
4386
4596
|
|
|
@@ -5321,11 +5531,11 @@ const render2 = (uid, diffResult) => {
|
|
|
5321
5531
|
const {
|
|
5322
5532
|
newState,
|
|
5323
5533
|
oldState
|
|
5324
|
-
} = get$
|
|
5534
|
+
} = get$3(uid);
|
|
5325
5535
|
if (oldState === newState) {
|
|
5326
5536
|
return [];
|
|
5327
5537
|
}
|
|
5328
|
-
set$
|
|
5538
|
+
set$5(uid, newState, newState);
|
|
5329
5539
|
const commands = applyRender(oldState, newState, diffResult);
|
|
5330
5540
|
if (!isConnected()) {
|
|
5331
5541
|
return commands;
|
|
@@ -5529,7 +5739,7 @@ const initializeCacheWorker = async () => {
|
|
|
5529
5739
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToCacheWorker', port);
|
|
5530
5740
|
}
|
|
5531
5741
|
});
|
|
5532
|
-
set$
|
|
5742
|
+
set$4(rpc);
|
|
5533
5743
|
};
|
|
5534
5744
|
|
|
5535
5745
|
const initializeEditorWorker = async () => {
|
|
@@ -5539,7 +5749,7 @@ const initializeEditorWorker = async () => {
|
|
|
5539
5749
|
await sendMessagePortToEditorWorker(port, 0);
|
|
5540
5750
|
}
|
|
5541
5751
|
});
|
|
5542
|
-
set$
|
|
5752
|
+
set$a(rpc);
|
|
5543
5753
|
};
|
|
5544
5754
|
|
|
5545
5755
|
const initializeExtensionManagementWorker = async () => {
|
|
@@ -5549,7 +5759,7 @@ const initializeExtensionManagementWorker = async () => {
|
|
|
5549
5759
|
await sendMessagePortToExtensionManagementWorker(port, 0);
|
|
5550
5760
|
}
|
|
5551
5761
|
});
|
|
5552
|
-
set$
|
|
5762
|
+
set$9(rpc);
|
|
5553
5763
|
};
|
|
5554
5764
|
|
|
5555
5765
|
const initializeFileSearchWorker = async () => {
|
|
@@ -5559,20 +5769,13 @@ const initializeFileSearchWorker = async () => {
|
|
|
5559
5769
|
await sendMessagePortToFileSearchWorker2(port, 0);
|
|
5560
5770
|
}
|
|
5561
5771
|
});
|
|
5562
|
-
set$
|
|
5563
|
-
};
|
|
5564
|
-
|
|
5565
|
-
const initializeRendererWorker = async () => {
|
|
5566
|
-
const rpc = await create$5({
|
|
5567
|
-
commandMap: commandMap
|
|
5568
|
-
});
|
|
5569
|
-
set$5(rpc);
|
|
5772
|
+
set$8(rpc);
|
|
5570
5773
|
};
|
|
5571
5774
|
|
|
5572
5775
|
const listen = async () => {
|
|
5573
5776
|
Object.assign(commandMapRef, commandMap);
|
|
5574
5777
|
registerCommands(commandMap);
|
|
5575
|
-
await Promise.all([
|
|
5778
|
+
await Promise.all([initializeRendererWorkerForWorker(commandMap), initializeEditorWorker(), initializeExtensionManagementWorker(), initializeFileSearchWorker(), initializeCacheWorker()]);
|
|
5576
5779
|
};
|
|
5577
5780
|
|
|
5578
5781
|
const main = async () => {
|