@lvce-editor/extension-management-worker 4.49.0 → 4.50.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.
|
@@ -3027,6 +3027,79 @@ const readFile = uri => {
|
|
|
3027
3027
|
return readFile$1(uri);
|
|
3028
3028
|
};
|
|
3029
3029
|
|
|
3030
|
+
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
3031
|
+
|
|
3032
|
+
const protocol = 'extension-output://';
|
|
3033
|
+
const hasOutputChannels = extension => {
|
|
3034
|
+
return !extension.disabled && isExtensionIsolated(extension) && Array.isArray(extension.outputChannels) && extension.outputChannels.length > 0;
|
|
3035
|
+
};
|
|
3036
|
+
const getOutputChannelUri = (extensionId, outputChannelId) => {
|
|
3037
|
+
return `${protocol}${encodeURIComponent(extensionId)}/${encodeURIComponent(outputChannelId)}`;
|
|
3038
|
+
};
|
|
3039
|
+
const getRegisteredOutputChannelIds = snapshot => {
|
|
3040
|
+
if (!snapshot || !Array.isArray(snapshot.outputChannels)) {
|
|
3041
|
+
return new Set();
|
|
3042
|
+
}
|
|
3043
|
+
return new Set(snapshot.outputChannels.map(outputChannel => outputChannel.id).filter(id => typeof id === 'string'));
|
|
3044
|
+
};
|
|
3045
|
+
const getExtensionOutputChannelProviders = async (extension, assetDir, platform) => {
|
|
3046
|
+
const extensionId = getExtensionId$1(extension);
|
|
3047
|
+
const rpc = await getRpc$1(extension, assetDir, platform);
|
|
3048
|
+
const snapshot = await rpc.invoke('ExtensionApi.getOutputChannelRegistrySnapshot');
|
|
3049
|
+
const registeredIds = getRegisteredOutputChannelIds(snapshot);
|
|
3050
|
+
const outputChannels = extension.outputChannels || [];
|
|
3051
|
+
return outputChannels.filter(outputChannel => typeof outputChannel.id === 'string' && typeof outputChannel.label === 'string' && registeredIds.has(outputChannel.id)).map(outputChannel => ({
|
|
3052
|
+
id: outputChannel.id,
|
|
3053
|
+
label: outputChannel.label,
|
|
3054
|
+
uri: getOutputChannelUri(extensionId, outputChannel.id)
|
|
3055
|
+
}));
|
|
3056
|
+
};
|
|
3057
|
+
const getOutputChannelProviders = async extensionsState => {
|
|
3058
|
+
const {
|
|
3059
|
+
assetDir,
|
|
3060
|
+
platform
|
|
3061
|
+
} = await getRuntimeContext('', extensionsState.platform);
|
|
3062
|
+
const extensions = await getAllExtensionsWithState(extensionsState, assetDir, platform);
|
|
3063
|
+
const outputExtensions = extensions.filter(hasOutputChannels);
|
|
3064
|
+
const providers = await Promise.all(outputExtensions.map(extension => getExtensionOutputChannelProviders(extension, assetDir, platform)));
|
|
3065
|
+
return providers.flat();
|
|
3066
|
+
};
|
|
3067
|
+
const parseOutputChannelUri = uri => {
|
|
3068
|
+
if (!uri.startsWith(protocol)) {
|
|
3069
|
+
throw new Error(`Invalid extension output uri ${uri}`);
|
|
3070
|
+
}
|
|
3071
|
+
const value = uri.slice(protocol.length);
|
|
3072
|
+
const separatorIndex = value.indexOf('/');
|
|
3073
|
+
if (separatorIndex === -1) {
|
|
3074
|
+
throw new Error(`Invalid extension output uri ${uri}`);
|
|
3075
|
+
}
|
|
3076
|
+
const extensionId = decodeURIComponent(value.slice(0, separatorIndex));
|
|
3077
|
+
const outputChannelId = decodeURIComponent(value.slice(separatorIndex + 1));
|
|
3078
|
+
if (!extensionId || !outputChannelId) {
|
|
3079
|
+
throw new Error(`Invalid extension output uri ${uri}`);
|
|
3080
|
+
}
|
|
3081
|
+
return [extensionId, outputChannelId];
|
|
3082
|
+
};
|
|
3083
|
+
const readOutputChannel = async (extensionsState, uri) => {
|
|
3084
|
+
const [extensionId, outputChannelId] = parseOutputChannelUri(uri);
|
|
3085
|
+
const {
|
|
3086
|
+
assetDir,
|
|
3087
|
+
platform
|
|
3088
|
+
} = await getRuntimeContext('', extensionsState.platform);
|
|
3089
|
+
const extensions = await getAllExtensionsWithState(extensionsState, assetDir, platform);
|
|
3090
|
+
const extension = extensions.find(candidate => getExtensionId$1(candidate) === extensionId && hasOutputChannels(candidate));
|
|
3091
|
+
const isContributed = extension?.outputChannels?.some(outputChannel => outputChannel.id === outputChannelId);
|
|
3092
|
+
if (!extension || !isContributed) {
|
|
3093
|
+
throw new Error(`Output channel ${outputChannelId} is not contributed by extension ${extensionId}`);
|
|
3094
|
+
}
|
|
3095
|
+
const rpc = await getRpc$1(extension, assetDir, platform);
|
|
3096
|
+
const logs = await rpc.invoke('ExtensionApi.getOutputChannelLogs', outputChannelId);
|
|
3097
|
+
if (typeof logs !== 'string') {
|
|
3098
|
+
throw new TypeError(`Output channel ${outputChannelId} is not registered by extension ${extensionId}`);
|
|
3099
|
+
}
|
|
3100
|
+
return logs;
|
|
3101
|
+
};
|
|
3102
|
+
|
|
3030
3103
|
const instances = Object.create(null);
|
|
3031
3104
|
const set$1 = (uid, instance) => {
|
|
3032
3105
|
instances[uid] = instance;
|
|
@@ -3976,6 +4049,7 @@ const commandMap = {
|
|
|
3976
4049
|
'Extensions.getExtension': getExtension,
|
|
3977
4050
|
'Extensions.getKeyBindings': getKeyBindings,
|
|
3978
4051
|
'Extensions.getLanguages': getLanguages,
|
|
4052
|
+
'Extensions.getOutputChannelProviders': wrapCommand(getOutputChannelProviders),
|
|
3979
4053
|
'Extensions.getPreference': getPreference,
|
|
3980
4054
|
'Extensions.getRemoteUrlForWebView': getRemoteUrlForWebView,
|
|
3981
4055
|
'Extensions.getRpcInfo': getRpcInfo,
|
|
@@ -3994,6 +4068,7 @@ const commandMap = {
|
|
|
3994
4068
|
'Extensions.initialize': initialize,
|
|
3995
4069
|
'Extensions.install': installExtension,
|
|
3996
4070
|
'Extensions.invalidateExtensionsCache': invalidateExtensionsCache,
|
|
4071
|
+
'Extensions.readOutputChannel': wrapCommand(readOutputChannel),
|
|
3997
4072
|
'Extensions.renderViewInstance': renderViewInstance,
|
|
3998
4073
|
'Extensions.requestViewRerender': requestViewRerender,
|
|
3999
4074
|
'Extensions.saveViewInstanceState': saveViewInstanceState,
|