@lvce-editor/quick-pick-worker 4.29.2 → 4.31.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 +275 -71
- 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,18 +1260,18 @@ 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
1276
|
const sendMessagePortToEditorWorker = async (port, rpcId) => {
|
|
1277
1277
|
const command = 'HandleMessagePort.handleMessagePort';
|
|
@@ -1656,10 +1656,10 @@ const create$2 = () => {
|
|
|
1656
1656
|
|
|
1657
1657
|
const {
|
|
1658
1658
|
dispose: dispose$1,
|
|
1659
|
-
get: get$
|
|
1659
|
+
get: get$3,
|
|
1660
1660
|
getCommandIds,
|
|
1661
1661
|
registerCommands,
|
|
1662
|
-
set: set$
|
|
1662
|
+
set: set$5,
|
|
1663
1663
|
wrapAsyncCommand,
|
|
1664
1664
|
wrapCommand
|
|
1665
1665
|
} = create$2();
|
|
@@ -1956,7 +1956,7 @@ const create = (uid, uri, listItemHeight, x, y, width, height, platform, args, _
|
|
|
1956
1956
|
platform,
|
|
1957
1957
|
value: ''
|
|
1958
1958
|
};
|
|
1959
|
-
set$
|
|
1959
|
+
set$5(uid, state, state);
|
|
1960
1960
|
};
|
|
1961
1961
|
|
|
1962
1962
|
const isEqual$4 = (oldState, newState) => {
|
|
@@ -2007,7 +2007,7 @@ const diff2 = uid => {
|
|
|
2007
2007
|
const {
|
|
2008
2008
|
newState,
|
|
2009
2009
|
oldState
|
|
2010
|
-
} = get$
|
|
2010
|
+
} = get$3(uid);
|
|
2011
2011
|
return diff(oldState, newState);
|
|
2012
2012
|
};
|
|
2013
2013
|
|
|
@@ -2723,6 +2723,120 @@ const collectWarnings = items => {
|
|
|
2723
2723
|
return warnings;
|
|
2724
2724
|
};
|
|
2725
2725
|
|
|
2726
|
+
const state$4 = {};
|
|
2727
|
+
const set$4 = value => {
|
|
2728
|
+
state$4.rpc = value;
|
|
2729
|
+
};
|
|
2730
|
+
const invoke$3 = (method, ...args) => {
|
|
2731
|
+
if (!state$4.rpc) {
|
|
2732
|
+
throw new Error('Cache worker is not initialized');
|
|
2733
|
+
}
|
|
2734
|
+
return state$4.rpc.invoke(method, ...args);
|
|
2735
|
+
};
|
|
2736
|
+
|
|
2737
|
+
const cacheName$1 = 'quick-pick-commands-v1';
|
|
2738
|
+
const version = 1;
|
|
2739
|
+
const isJsonValue = value => {
|
|
2740
|
+
if (value === null || typeof value === 'string' || typeof value === 'boolean') {
|
|
2741
|
+
return true;
|
|
2742
|
+
}
|
|
2743
|
+
if (typeof value === 'number') {
|
|
2744
|
+
return Number.isFinite(value);
|
|
2745
|
+
}
|
|
2746
|
+
if (Array.isArray(value)) {
|
|
2747
|
+
return value.every(isJsonValue);
|
|
2748
|
+
}
|
|
2749
|
+
if (typeof value !== 'object') {
|
|
2750
|
+
return false;
|
|
2751
|
+
}
|
|
2752
|
+
const prototype = Object.getPrototypeOf(value);
|
|
2753
|
+
return (prototype === Object.prototype || prototype === null) && Object.values(value).every(isJsonValue);
|
|
2754
|
+
};
|
|
2755
|
+
const canSerialize = value => {
|
|
2756
|
+
try {
|
|
2757
|
+
JSON.stringify(value);
|
|
2758
|
+
return true;
|
|
2759
|
+
} catch {
|
|
2760
|
+
return false;
|
|
2761
|
+
}
|
|
2762
|
+
};
|
|
2763
|
+
const isCommand = value => {
|
|
2764
|
+
if (!value || typeof value !== 'object') {
|
|
2765
|
+
return false;
|
|
2766
|
+
}
|
|
2767
|
+
const command = value;
|
|
2768
|
+
if (typeof command.id !== 'string' || typeof command.label !== 'string') {
|
|
2769
|
+
return false;
|
|
2770
|
+
}
|
|
2771
|
+
if (command.args === undefined) {
|
|
2772
|
+
return true;
|
|
2773
|
+
}
|
|
2774
|
+
return canSerialize(command.args) && isJsonValue(command.args);
|
|
2775
|
+
};
|
|
2776
|
+
const isContribution = value => {
|
|
2777
|
+
if (!value || typeof value !== 'object') {
|
|
2778
|
+
return false;
|
|
2779
|
+
}
|
|
2780
|
+
const contribution = value;
|
|
2781
|
+
if (typeof contribution.hash !== 'string' || !/^[\da-f]{64}$/.test(contribution.hash) || !Array.isArray(contribution.commands)) {
|
|
2782
|
+
return false;
|
|
2783
|
+
}
|
|
2784
|
+
return contribution.commands.every(isCommand);
|
|
2785
|
+
};
|
|
2786
|
+
const isCacheableCommands = commands => {
|
|
2787
|
+
try {
|
|
2788
|
+
return commands.every(isCommand);
|
|
2789
|
+
} catch {
|
|
2790
|
+
return false;
|
|
2791
|
+
}
|
|
2792
|
+
};
|
|
2793
|
+
const isEntry$1 = value => {
|
|
2794
|
+
if (!value || typeof value !== 'object') {
|
|
2795
|
+
return false;
|
|
2796
|
+
}
|
|
2797
|
+
const entry = value;
|
|
2798
|
+
return entry.version === version && isContribution(entry.builtin) && isContribution(entry.extensions);
|
|
2799
|
+
};
|
|
2800
|
+
const getCacheUrl = (applicationId, assetDir, platform) => {
|
|
2801
|
+
const context = JSON.stringify({
|
|
2802
|
+
applicationId: applicationId ?? null,
|
|
2803
|
+
assetDir,
|
|
2804
|
+
platform
|
|
2805
|
+
});
|
|
2806
|
+
return `https://quick-pick-cache.invalid/cache/v1/commands/${encodeURIComponent(context)}`;
|
|
2807
|
+
};
|
|
2808
|
+
const get$2 = async (applicationId, assetDir, platform) => {
|
|
2809
|
+
try {
|
|
2810
|
+
const cached = await invoke$3('Cache.getCacheStorageItem', getCacheUrl(applicationId, assetDir, platform), cacheName$1);
|
|
2811
|
+
if (!cached) {
|
|
2812
|
+
return undefined;
|
|
2813
|
+
}
|
|
2814
|
+
const expires = Date.parse(cached.headers.expires || '');
|
|
2815
|
+
if (!Number.isFinite(expires) || expires <= Date.now()) {
|
|
2816
|
+
return undefined;
|
|
2817
|
+
}
|
|
2818
|
+
const entry = JSON.parse(new TextDecoder().decode(cached.body));
|
|
2819
|
+
return isEntry$1(entry) ? entry : undefined;
|
|
2820
|
+
} catch {
|
|
2821
|
+
return undefined;
|
|
2822
|
+
}
|
|
2823
|
+
};
|
|
2824
|
+
const set$3 = async (applicationId, assetDir, platform, entry) => {
|
|
2825
|
+
const expires = new Date(Date.now() + 90 * 24 * 60 * 60 * 1000).toUTCString();
|
|
2826
|
+
const body = JSON.stringify(entry);
|
|
2827
|
+
const headers = {
|
|
2828
|
+
'cache-control': 'private, max-age=7776000',
|
|
2829
|
+
'content-length': String(new TextEncoder().encode(body).byteLength),
|
|
2830
|
+
'content-type': 'application/json',
|
|
2831
|
+
expires
|
|
2832
|
+
};
|
|
2833
|
+
try {
|
|
2834
|
+
await invoke$3('Cache.setCacheStorageItem', getCacheUrl(applicationId, assetDir, platform), body, cacheName$1, headers);
|
|
2835
|
+
} catch {
|
|
2836
|
+
// Caching is optional; storage failures must not break command selection.
|
|
2837
|
+
}
|
|
2838
|
+
};
|
|
2839
|
+
|
|
2726
2840
|
const handleError = async (error, notify = true, prefix = '') => {
|
|
2727
2841
|
console.error(error);
|
|
2728
2842
|
};
|
|
@@ -2751,7 +2865,7 @@ const warn = (...args) => {
|
|
|
2751
2865
|
console.warn(...args);
|
|
2752
2866
|
};
|
|
2753
2867
|
|
|
2754
|
-
const state$
|
|
2868
|
+
const state$3 = {
|
|
2755
2869
|
menuEntries: []
|
|
2756
2870
|
};
|
|
2757
2871
|
const getAll = async () => {
|
|
@@ -2762,22 +2876,46 @@ const getAll = async () => {
|
|
|
2762
2876
|
} catch {
|
|
2763
2877
|
// ignore
|
|
2764
2878
|
}
|
|
2765
|
-
return state$
|
|
2879
|
+
return state$3.menuEntries;
|
|
2766
2880
|
};
|
|
2767
2881
|
const add$1 = menuEntries => {
|
|
2768
|
-
state$
|
|
2882
|
+
state$3.menuEntries = [...state$3.menuEntries, ...menuEntries];
|
|
2769
2883
|
};
|
|
2770
2884
|
|
|
2771
2885
|
const changeLanguageModePick = {
|
|
2772
2886
|
id: 'QuickPick.changeLanguageMode',
|
|
2773
2887
|
label: 'Change Language Mode'
|
|
2774
2888
|
};
|
|
2775
|
-
|
|
2776
|
-
|
|
2777
|
-
|
|
2889
|
+
const isCommandProviderResponse = value => {
|
|
2890
|
+
return !!value && typeof value === 'object' && !Array.isArray(value) && 'matchesCache' in value && 'hash' in value;
|
|
2891
|
+
};
|
|
2892
|
+
const getBuiltinPicks = async ifNonMatch => {
|
|
2893
|
+
const result = await invoke$4('Layout.getAllQuickPickMenuEntries', ifNonMatch);
|
|
2894
|
+
if (isCommandProviderResponse(result)) {
|
|
2895
|
+
const response = result;
|
|
2896
|
+
return response.commands ? {
|
|
2897
|
+
...response,
|
|
2898
|
+
commands: [...response.commands, changeLanguageModePick]
|
|
2899
|
+
} : response;
|
|
2900
|
+
}
|
|
2901
|
+
return Array.isArray(result) ? [...result, changeLanguageModePick] : [...(await getAll()), changeLanguageModePick];
|
|
2902
|
+
};
|
|
2903
|
+
const getBuiltinFallback = async () => {
|
|
2778
2904
|
const builtinPicks = await getAll();
|
|
2779
2905
|
return [...builtinPicks, changeLanguageModePick];
|
|
2780
2906
|
};
|
|
2907
|
+
const getBuiltinCommands = async (response, cached) => {
|
|
2908
|
+
if (isCommandProviderResponse(response)) {
|
|
2909
|
+
if (response.matchesCache) {
|
|
2910
|
+
return cached?.builtin.commands ?? [];
|
|
2911
|
+
}
|
|
2912
|
+
return response.commands ?? getBuiltinFallback();
|
|
2913
|
+
}
|
|
2914
|
+
if (Array.isArray(response)) {
|
|
2915
|
+
return response;
|
|
2916
|
+
}
|
|
2917
|
+
return getBuiltinFallback();
|
|
2918
|
+
};
|
|
2781
2919
|
const prefixIdWithExt = item => {
|
|
2782
2920
|
return {
|
|
2783
2921
|
...item,
|
|
@@ -2785,16 +2923,24 @@ const prefixIdWithExt = item => {
|
|
|
2785
2923
|
label: item.label || item.id
|
|
2786
2924
|
};
|
|
2787
2925
|
};
|
|
2788
|
-
const getExtensionPicks = async (assetDir, platform, applicationId) => {
|
|
2926
|
+
const getExtensionPicks = async (assetDir, platform, applicationId, ifNonMatch) => {
|
|
2789
2927
|
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);
|
|
2928
|
+
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
2929
|
if (!extensionPicks) {
|
|
2797
|
-
return
|
|
2930
|
+
return undefined;
|
|
2931
|
+
}
|
|
2932
|
+
if (isCommandProviderResponse(extensionPicks)) {
|
|
2933
|
+
if (extensionPicks.matchesCache || !extensionPicks.commands) {
|
|
2934
|
+
return extensionPicks;
|
|
2935
|
+
}
|
|
2936
|
+
const warnings = collectWarnings(extensionPicks.commands);
|
|
2937
|
+
for (const warning of warnings) {
|
|
2938
|
+
warn(`[QuickPick] ${warning}`);
|
|
2939
|
+
}
|
|
2940
|
+
return {
|
|
2941
|
+
...extensionPicks,
|
|
2942
|
+
commands: extensionPicks.commands.map(prefixIdWithExt)
|
|
2943
|
+
};
|
|
2798
2944
|
}
|
|
2799
2945
|
const warnings = collectWarnings(extensionPicks);
|
|
2800
2946
|
for (const warning of warnings) {
|
|
@@ -2804,7 +2950,59 @@ const getExtensionPicks = async (assetDir, platform, applicationId) => {
|
|
|
2804
2950
|
return mappedPicks;
|
|
2805
2951
|
} catch (error) {
|
|
2806
2952
|
console.error(`Failed to get extension picks: ${error}`);
|
|
2807
|
-
return
|
|
2953
|
+
return undefined;
|
|
2954
|
+
}
|
|
2955
|
+
};
|
|
2956
|
+
const getExtensionCommands = (response, cached) => {
|
|
2957
|
+
if (isCommandProviderResponse(response)) {
|
|
2958
|
+
if (response.matchesCache) {
|
|
2959
|
+
return cached?.extensions.commands ?? [];
|
|
2960
|
+
}
|
|
2961
|
+
return response.commands ?? [];
|
|
2962
|
+
}
|
|
2963
|
+
if (Array.isArray(response)) {
|
|
2964
|
+
return response;
|
|
2965
|
+
}
|
|
2966
|
+
return cached?.extensions.commands ?? [];
|
|
2967
|
+
};
|
|
2968
|
+
const toCachedCommands = items => {
|
|
2969
|
+
const commands = items.map(item => ({
|
|
2970
|
+
...(item.args !== undefined && {
|
|
2971
|
+
args: item.args
|
|
2972
|
+
}),
|
|
2973
|
+
id: String(item.id),
|
|
2974
|
+
label: typeof item.label === 'string' ? item.label : String(item.id)
|
|
2975
|
+
}));
|
|
2976
|
+
return isCacheableCommands(commands) ? commands : undefined;
|
|
2977
|
+
};
|
|
2978
|
+
const saveCommandCache = async (applicationId, assetDir, platform, cached, builtinResponse, extensionResponse, builtinPicks, extensionPicks) => {
|
|
2979
|
+
const builtinCommands = toCachedCommands(builtinPicks);
|
|
2980
|
+
const extensionCommands = toCachedCommands(extensionPicks);
|
|
2981
|
+
if (!builtinCommands || !extensionCommands) {
|
|
2982
|
+
return;
|
|
2983
|
+
}
|
|
2984
|
+
const builtinHash = isCommandProviderResponse(builtinResponse) ? builtinResponse.hash : cached?.builtin.hash;
|
|
2985
|
+
const extensionHash = isCommandProviderResponse(extensionResponse) ? extensionResponse.hash : cached?.extensions.hash;
|
|
2986
|
+
if (!builtinHash || !extensionHash) {
|
|
2987
|
+
return;
|
|
2988
|
+
}
|
|
2989
|
+
await set$3(applicationId, assetDir, platform, {
|
|
2990
|
+
builtin: {
|
|
2991
|
+
commands: builtinCommands,
|
|
2992
|
+
hash: builtinHash
|
|
2993
|
+
},
|
|
2994
|
+
extensions: {
|
|
2995
|
+
commands: extensionCommands,
|
|
2996
|
+
hash: extensionHash
|
|
2997
|
+
},
|
|
2998
|
+
version: 1
|
|
2999
|
+
});
|
|
3000
|
+
};
|
|
3001
|
+
const getOptional = async callback => {
|
|
3002
|
+
try {
|
|
3003
|
+
return await callback();
|
|
3004
|
+
} catch {
|
|
3005
|
+
return undefined;
|
|
2808
3006
|
}
|
|
2809
3007
|
};
|
|
2810
3008
|
const toProtoVisibleItem$3 = item => {
|
|
@@ -2829,15 +3027,25 @@ const getPicks$e = async (value, args, {
|
|
|
2829
3027
|
assetDir = '',
|
|
2830
3028
|
platform = 0
|
|
2831
3029
|
} = {}) => {
|
|
2832
|
-
|
|
2833
|
-
|
|
2834
|
-
|
|
3030
|
+
let cacheEnabled = false;
|
|
3031
|
+
try {
|
|
3032
|
+
cacheEnabled = (await invoke$4('Preferences.get', 'quickPick.cache')) !== false;
|
|
3033
|
+
} catch {
|
|
3034
|
+
// If preferences are unavailable, preserve the existing uncached command behavior.
|
|
3035
|
+
}
|
|
3036
|
+
const cached = cacheEnabled ? await get$2(applicationId, assetDir, platform) : undefined;
|
|
3037
|
+
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))]);
|
|
3038
|
+
const builtinPicks = await getBuiltinCommands(builtinResponse, cached);
|
|
3039
|
+
const extensionPicks = getExtensionCommands(extensionResponse, cached);
|
|
3040
|
+
if (cacheEnabled) {
|
|
3041
|
+
await saveCommandCache(applicationId, assetDir, platform, cached, builtinResponse, extensionResponse, builtinPicks, extensionPicks);
|
|
3042
|
+
}
|
|
2835
3043
|
const allPicks = [...builtinPicks, ...extensionPicks];
|
|
2836
3044
|
const converted = allPicks.map(toProtoVisibleItem$3);
|
|
2837
3045
|
return value === '>' ? converted.toSorted((a, b) => a.label.localeCompare(b.label)) : converted;
|
|
2838
3046
|
};
|
|
2839
3047
|
|
|
2840
|
-
const state$
|
|
3048
|
+
const state$2 = {
|
|
2841
3049
|
args: [],
|
|
2842
3050
|
items: Object.create(null)
|
|
2843
3051
|
};
|
|
@@ -2847,24 +3055,24 @@ const idState = {
|
|
|
2847
3055
|
};
|
|
2848
3056
|
const add = items => {
|
|
2849
3057
|
const nextId = ++idState.value;
|
|
2850
|
-
state$
|
|
3058
|
+
state$2.items[nextId] = items;
|
|
2851
3059
|
return nextId;
|
|
2852
3060
|
};
|
|
2853
3061
|
const get$1 = id => {
|
|
2854
|
-
return state$
|
|
3062
|
+
return state$2.items[id] || [];
|
|
2855
3063
|
};
|
|
2856
3064
|
const remove = id => {
|
|
2857
|
-
delete state$
|
|
3065
|
+
delete state$2.items[id];
|
|
2858
3066
|
};
|
|
2859
3067
|
|
|
2860
|
-
const state$
|
|
3068
|
+
const state$1 = {
|
|
2861
3069
|
rpc: undefined
|
|
2862
3070
|
};
|
|
2863
|
-
const set$
|
|
2864
|
-
state$
|
|
3071
|
+
const set$2 = newRpc => {
|
|
3072
|
+
state$1.rpc = newRpc;
|
|
2865
3073
|
};
|
|
2866
|
-
const invoke$
|
|
2867
|
-
return state$
|
|
3074
|
+
const invoke$2 = (method, ...args) => {
|
|
3075
|
+
return state$1.rpc.invoke(method, ...args);
|
|
2868
3076
|
};
|
|
2869
3077
|
|
|
2870
3078
|
const isTextInput = args => {
|
|
@@ -2895,14 +3103,14 @@ const toProtoVisibleItem$2 = item => {
|
|
|
2895
3103
|
};
|
|
2896
3104
|
};
|
|
2897
3105
|
const getPicks$d = async (searchValue, args) => {
|
|
2898
|
-
state$
|
|
3106
|
+
state$2.args = args;
|
|
2899
3107
|
if (isTextInput(args)) {
|
|
2900
3108
|
return [];
|
|
2901
3109
|
}
|
|
2902
3110
|
const options = args.at(-1);
|
|
2903
3111
|
let items;
|
|
2904
3112
|
if (options?.mode === 'quickInput') {
|
|
2905
|
-
items = searchValue === '' && options?.customItemsId ? get$1(options.customItemsId) : await invoke$
|
|
3113
|
+
items = searchValue === '' && options?.customItemsId ? get$1(options.customItemsId) : await invoke$2('ExtensionHostQuickPick.renderQuickInput', options.quickInputId, searchValue);
|
|
2906
3114
|
} else {
|
|
2907
3115
|
items = options?.customItemsId ? get$1(options.customItemsId) : args[1] || [];
|
|
2908
3116
|
}
|
|
@@ -2930,20 +3138,16 @@ const getWorkspacePath = async () => {
|
|
|
2930
3138
|
return invoke$4('Workspace.getUri');
|
|
2931
3139
|
};
|
|
2932
3140
|
|
|
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
3141
|
const cacheName = 'quick-pick-files-v1';
|
|
3142
|
+
const encodePathSegment = segment => encodeURIComponent(segment).replaceAll('+', '%2B').replaceAll(/%25([\da-f]{2})/gi, '%$1');
|
|
2945
3143
|
const cacheUrl = workspace => {
|
|
2946
|
-
const
|
|
3144
|
+
const uriMatch = workspace.match(/^([a-z][\da-z+.-]*):\/\/([^/]*)(\/.*)?$/i);
|
|
3145
|
+
if (uriMatch) {
|
|
3146
|
+
const [, scheme, authority, uriPath = ''] = uriMatch;
|
|
3147
|
+
const path = [scheme.toLowerCase(), encodePathSegment(authority), ...uriPath.split('/').filter(Boolean).map(encodePathSegment)].filter(Boolean).join('/');
|
|
3148
|
+
return `https://quick-pick-cache.invalid/cache/v1/${path}`;
|
|
3149
|
+
}
|
|
3150
|
+
const path = workspace.replaceAll('\\', '/').replace(/^\/+/, '').split('/').filter(Boolean).map(encodePathSegment).join('/');
|
|
2947
3151
|
return `https://quick-pick-cache.invalid/cache/v1/file/${path}`;
|
|
2948
3152
|
};
|
|
2949
3153
|
const isEntry = value => {
|
|
@@ -2955,7 +3159,7 @@ const isEntry = value => {
|
|
|
2955
3159
|
};
|
|
2956
3160
|
const get = async workspace => {
|
|
2957
3161
|
try {
|
|
2958
|
-
const cached = await invoke$
|
|
3162
|
+
const cached = await invoke$3('Cache.getCacheStorageItem', cacheUrl(workspace), cacheName);
|
|
2959
3163
|
if (!cached) {
|
|
2960
3164
|
return undefined;
|
|
2961
3165
|
}
|
|
@@ -2979,7 +3183,7 @@ const set$1 = async (workspace, entry) => {
|
|
|
2979
3183
|
expires
|
|
2980
3184
|
};
|
|
2981
3185
|
try {
|
|
2982
|
-
await invoke$
|
|
3186
|
+
await invoke$3('Cache.setCacheStorageItem', cacheUrl(workspace), body, cacheName, headers);
|
|
2983
3187
|
} catch {
|
|
2984
3188
|
// Caching is optional; a storage failure must not break file search.
|
|
2985
3189
|
}
|
|
@@ -3655,7 +3859,7 @@ const getOptions = args => {
|
|
|
3655
3859
|
const selectPick$a = async (_pick, value) => {
|
|
3656
3860
|
const {
|
|
3657
3861
|
args
|
|
3658
|
-
} = state$
|
|
3862
|
+
} = state$2;
|
|
3659
3863
|
const options = getOptions(args);
|
|
3660
3864
|
if (options.executeItemCommand && _pick.command) {
|
|
3661
3865
|
return {
|
|
@@ -4364,7 +4568,7 @@ const handleMessagePort = async port => {
|
|
|
4364
4568
|
isMessagePortOpen: true,
|
|
4365
4569
|
messagePort: port
|
|
4366
4570
|
});
|
|
4367
|
-
set$
|
|
4571
|
+
set$2(rpc);
|
|
4368
4572
|
};
|
|
4369
4573
|
|
|
4370
4574
|
const state = {
|
|
@@ -4380,7 +4584,7 @@ const invoke$1 = (method, ...params) => {
|
|
|
4380
4584
|
return invoke$5(method, ...params);
|
|
4381
4585
|
};
|
|
4382
4586
|
const set = rpc => {
|
|
4383
|
-
set$
|
|
4587
|
+
set$7(rpc);
|
|
4384
4588
|
state.connected = true;
|
|
4385
4589
|
};
|
|
4386
4590
|
|
|
@@ -5321,11 +5525,11 @@ const render2 = (uid, diffResult) => {
|
|
|
5321
5525
|
const {
|
|
5322
5526
|
newState,
|
|
5323
5527
|
oldState
|
|
5324
|
-
} = get$
|
|
5528
|
+
} = get$3(uid);
|
|
5325
5529
|
if (oldState === newState) {
|
|
5326
5530
|
return [];
|
|
5327
5531
|
}
|
|
5328
|
-
set$
|
|
5532
|
+
set$5(uid, newState, newState);
|
|
5329
5533
|
const commands = applyRender(oldState, newState, diffResult);
|
|
5330
5534
|
if (!isConnected()) {
|
|
5331
5535
|
return commands;
|
|
@@ -5529,7 +5733,7 @@ const initializeCacheWorker = async () => {
|
|
|
5529
5733
|
await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToCacheWorker', port);
|
|
5530
5734
|
}
|
|
5531
5735
|
});
|
|
5532
|
-
set$
|
|
5736
|
+
set$4(rpc);
|
|
5533
5737
|
};
|
|
5534
5738
|
|
|
5535
5739
|
const initializeEditorWorker = async () => {
|
|
@@ -5539,7 +5743,7 @@ const initializeEditorWorker = async () => {
|
|
|
5539
5743
|
await sendMessagePortToEditorWorker(port, 0);
|
|
5540
5744
|
}
|
|
5541
5745
|
});
|
|
5542
|
-
set$
|
|
5746
|
+
set$a(rpc);
|
|
5543
5747
|
};
|
|
5544
5748
|
|
|
5545
5749
|
const initializeExtensionManagementWorker = async () => {
|
|
@@ -5549,7 +5753,7 @@ const initializeExtensionManagementWorker = async () => {
|
|
|
5549
5753
|
await sendMessagePortToExtensionManagementWorker(port, 0);
|
|
5550
5754
|
}
|
|
5551
5755
|
});
|
|
5552
|
-
set$
|
|
5756
|
+
set$9(rpc);
|
|
5553
5757
|
};
|
|
5554
5758
|
|
|
5555
5759
|
const initializeFileSearchWorker = async () => {
|
|
@@ -5559,14 +5763,14 @@ const initializeFileSearchWorker = async () => {
|
|
|
5559
5763
|
await sendMessagePortToFileSearchWorker2(port, 0);
|
|
5560
5764
|
}
|
|
5561
5765
|
});
|
|
5562
|
-
set$
|
|
5766
|
+
set$8(rpc);
|
|
5563
5767
|
};
|
|
5564
5768
|
|
|
5565
5769
|
const initializeRendererWorker = async () => {
|
|
5566
5770
|
const rpc = await create$5({
|
|
5567
5771
|
commandMap: commandMap
|
|
5568
5772
|
});
|
|
5569
|
-
set$
|
|
5773
|
+
set$6(rpc);
|
|
5570
5774
|
};
|
|
5571
5775
|
|
|
5572
5776
|
const listen = async () => {
|