@lvce-editor/extension-management-worker 4.2.0 → 4.3.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.
|
@@ -1448,7 +1448,7 @@ const baseName = path => {
|
|
|
1448
1448
|
const slashIndex = path.lastIndexOf('/');
|
|
1449
1449
|
return path.slice(slashIndex + 1);
|
|
1450
1450
|
};
|
|
1451
|
-
const getExtensionId$
|
|
1451
|
+
const getExtensionId$4 = extension => {
|
|
1452
1452
|
if (extension && extension.id) {
|
|
1453
1453
|
return extension.id;
|
|
1454
1454
|
}
|
|
@@ -1536,7 +1536,7 @@ const activateExtension2 = async (extensionId, extension, absolutePath, extensio
|
|
|
1536
1536
|
status: Activated
|
|
1537
1537
|
});
|
|
1538
1538
|
} catch (error) {
|
|
1539
|
-
const id = getExtensionId$
|
|
1539
|
+
const id = getExtensionId$4(extension);
|
|
1540
1540
|
if (isImportError(error)) {
|
|
1541
1541
|
const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
|
|
1542
1542
|
throw new Error(`Failed to activate extension ${id}: ${actualErrorMessage}`, {
|
|
@@ -1772,19 +1772,19 @@ const runningExtensions = Object.create(null);
|
|
|
1772
1772
|
const matchesEvent = (extension, event) => {
|
|
1773
1773
|
return isExtensionIsolated(extension) && Array.isArray(extension.activation) && extension.activation.includes(event);
|
|
1774
1774
|
};
|
|
1775
|
-
const getExtensionId$
|
|
1775
|
+
const getExtensionId$3 = extension => {
|
|
1776
1776
|
return extension.id;
|
|
1777
1777
|
};
|
|
1778
|
-
const getAbsolutePath = (extension, assetDir, platform) => {
|
|
1778
|
+
const getAbsolutePath$2 = (extension, assetDir, platform) => {
|
|
1779
1779
|
return getExtensionAbsolutePath(extension.id, extension.isWeb, extension.builtin, extension.uri || extension.path, extension.browser, globalThis.location.origin, platform, assetDir);
|
|
1780
1780
|
};
|
|
1781
1781
|
const activateExtension = async (extension, event, assetDir, platform) => {
|
|
1782
|
-
const extensionId = getExtensionId$
|
|
1782
|
+
const extensionId = getExtensionId$3(extension);
|
|
1783
1783
|
if (runningExtensions[extensionId]) {
|
|
1784
1784
|
return;
|
|
1785
1785
|
}
|
|
1786
1786
|
if (!Object.hasOwn(activatingExtensions, extensionId)) {
|
|
1787
|
-
const absolutePath = getAbsolutePath(extension, assetDir, platform);
|
|
1787
|
+
const absolutePath = getAbsolutePath$2(extension, assetDir, platform);
|
|
1788
1788
|
activatingExtensions[extensionId] = activateExtension3(extension, absolutePath, event, platform).then(() => {
|
|
1789
1789
|
runningExtensions[extensionId] = true;
|
|
1790
1790
|
}).finally(() => {
|
|
@@ -2035,7 +2035,7 @@ const enableExtension = async (id, isTest) => {
|
|
|
2035
2035
|
return enableExtension2(id, oldState.platform);
|
|
2036
2036
|
};
|
|
2037
2037
|
|
|
2038
|
-
const getExtensionId = extension => {
|
|
2038
|
+
const getExtensionId$2 = extension => {
|
|
2039
2039
|
return extension.id || interExtensionId(extension.uri || extension.path || '');
|
|
2040
2040
|
};
|
|
2041
2041
|
const contributesCommand = (extension, id) => {
|
|
@@ -2050,7 +2050,7 @@ const getRpcForCommand = async (id, platform) => {
|
|
|
2050
2050
|
if (!extension) {
|
|
2051
2051
|
return undefined;
|
|
2052
2052
|
}
|
|
2053
|
-
const extensionId = getExtensionId(extension);
|
|
2053
|
+
const extensionId = getExtensionId$2(extension);
|
|
2054
2054
|
const existingRpc = get$2(extensionId);
|
|
2055
2055
|
if (existingRpc) {
|
|
2056
2056
|
return existingRpc;
|
|
@@ -2072,6 +2072,97 @@ const executeCommand = async (id, ...args) => {
|
|
|
2072
2072
|
return executeRendererCommand(id, args);
|
|
2073
2073
|
};
|
|
2074
2074
|
|
|
2075
|
+
const getExtensionId$1 = extension => {
|
|
2076
|
+
return extension.id || interExtensionId(extension.uri || extension.path || '');
|
|
2077
|
+
};
|
|
2078
|
+
const contributesCompletionProvider = (extension, languageId) => {
|
|
2079
|
+
return Array.isArray(extension.completionProviders) && extension.completionProviders.some(provider => provider.languageId === languageId);
|
|
2080
|
+
};
|
|
2081
|
+
const getOrigin$1 = () => {
|
|
2082
|
+
return globalThis.location?.origin || 'http://localhost';
|
|
2083
|
+
};
|
|
2084
|
+
const getAbsolutePath$1 = (extension, assetDir, platform) => {
|
|
2085
|
+
return getExtensionAbsolutePath(getExtensionId$1(extension), extension.isWeb === true, extension.builtin === true, extension.uri || extension.path || '', extension.browser || '', getOrigin$1(), platform, assetDir);
|
|
2086
|
+
};
|
|
2087
|
+
const getMatchingExtensions$1 = async (textDocument, assetDir, platform) => {
|
|
2088
|
+
const extensions = await getAllExtensions(assetDir, platform);
|
|
2089
|
+
return extensions.filter(extension => isExtensionIsolated(extension) && contributesCompletionProvider(extension, textDocument.languageId));
|
|
2090
|
+
};
|
|
2091
|
+
const getRpc$2 = async (extension, assetDir, platform) => {
|
|
2092
|
+
const extensionId = getExtensionId$1(extension);
|
|
2093
|
+
const existingRpc = get$2(extensionId);
|
|
2094
|
+
if (existingRpc) {
|
|
2095
|
+
return existingRpc;
|
|
2096
|
+
}
|
|
2097
|
+
const absolutePath = getAbsolutePath$1(extension, assetDir, platform);
|
|
2098
|
+
return getOrCreateIsolatedExtensionHostWorker(extensionId, absolutePath);
|
|
2099
|
+
};
|
|
2100
|
+
const executeRpcCompletionProvider = async (rpc, textDocument, args) => {
|
|
2101
|
+
return rpc.invoke('ExtensionApi.executeCompletionProvider', textDocument, ...args);
|
|
2102
|
+
};
|
|
2103
|
+
const executeRpcResolveCompletionItemProvider = async (rpc, textDocument, args) => {
|
|
2104
|
+
return rpc.invoke('ExtensionApi.executeResolveCompletionItemProvider', textDocument, ...args);
|
|
2105
|
+
};
|
|
2106
|
+
const executeCompletionProvider = async (textDocument, ...args) => {
|
|
2107
|
+
const {
|
|
2108
|
+
platform
|
|
2109
|
+
} = get$3();
|
|
2110
|
+
const assetDir = '';
|
|
2111
|
+
const extensions = await getMatchingExtensions$1(textDocument, assetDir, platform);
|
|
2112
|
+
const rpcs = await Promise.all(extensions.map(extension => getRpc$2(extension, assetDir, platform)));
|
|
2113
|
+
const results = await Promise.all(rpcs.map(rpc => executeRpcCompletionProvider(rpc, textDocument, args)));
|
|
2114
|
+
return results[0] || [];
|
|
2115
|
+
};
|
|
2116
|
+
const executeResolveCompletionItemProvider = async (textDocument, ...args) => {
|
|
2117
|
+
const {
|
|
2118
|
+
platform
|
|
2119
|
+
} = get$3();
|
|
2120
|
+
const assetDir = '';
|
|
2121
|
+
const extensions = await getMatchingExtensions$1(textDocument, assetDir, platform);
|
|
2122
|
+
const rpcs = await Promise.all(extensions.map(extension => getRpc$2(extension, assetDir, platform)));
|
|
2123
|
+
const results = await Promise.all(rpcs.map(rpc => executeRpcResolveCompletionItemProvider(rpc, textDocument, args)));
|
|
2124
|
+
return results[0];
|
|
2125
|
+
};
|
|
2126
|
+
|
|
2127
|
+
const getExtensionId = extension => {
|
|
2128
|
+
return extension.id || interExtensionId(extension.uri || extension.path || '');
|
|
2129
|
+
};
|
|
2130
|
+
const contributesFormattingProvider = (extension, languageId) => {
|
|
2131
|
+
return Array.isArray(extension.formattingProviders) && extension.formattingProviders.some(provider => provider.languageId === languageId);
|
|
2132
|
+
};
|
|
2133
|
+
const getOrigin = () => {
|
|
2134
|
+
return globalThis.location?.origin || 'http://localhost';
|
|
2135
|
+
};
|
|
2136
|
+
const getAbsolutePath = (extension, assetDir, platform) => {
|
|
2137
|
+
return getExtensionAbsolutePath(getExtensionId(extension), extension.isWeb === true, extension.builtin === true, extension.uri || extension.path || '', extension.browser || '', getOrigin(), platform, assetDir);
|
|
2138
|
+
};
|
|
2139
|
+
const getMatchingExtensions = async (textDocument, assetDir, platform) => {
|
|
2140
|
+
const extensions = await getAllExtensions(assetDir, platform);
|
|
2141
|
+
return extensions.filter(extension => isExtensionIsolated(extension) && contributesFormattingProvider(extension, textDocument.languageId));
|
|
2142
|
+
};
|
|
2143
|
+
const getRpc$1 = async (extension, assetDir, platform) => {
|
|
2144
|
+
const extensionId = getExtensionId(extension);
|
|
2145
|
+
const existingRpc = get$2(extensionId);
|
|
2146
|
+
if (existingRpc) {
|
|
2147
|
+
return existingRpc;
|
|
2148
|
+
}
|
|
2149
|
+
const absolutePath = getAbsolutePath(extension, assetDir, platform);
|
|
2150
|
+
return getOrCreateIsolatedExtensionHostWorker(extensionId, absolutePath);
|
|
2151
|
+
};
|
|
2152
|
+
const executeRpcFormattingProvider = async (rpc, textDocument, args) => {
|
|
2153
|
+
return rpc.invoke('ExtensionApi.executeFormattingProvider', textDocument, ...args);
|
|
2154
|
+
};
|
|
2155
|
+
const executeFormattingProvider = async (textDocument, ...args) => {
|
|
2156
|
+
const {
|
|
2157
|
+
platform
|
|
2158
|
+
} = get$3();
|
|
2159
|
+
const assetDir = '';
|
|
2160
|
+
const extensions = await getMatchingExtensions(textDocument, assetDir, platform);
|
|
2161
|
+
const rpcs = await Promise.all(extensions.map(extension => getRpc$1(extension, assetDir, platform)));
|
|
2162
|
+
const results = await Promise.all(rpcs.map(rpc => executeRpcFormattingProvider(rpc, textDocument, args)));
|
|
2163
|
+
return results[0] || [];
|
|
2164
|
+
};
|
|
2165
|
+
|
|
2075
2166
|
/* eslint-disable @typescript-eslint/prefer-readonly-parameter-types */
|
|
2076
2167
|
const warn = (...args) => {
|
|
2077
2168
|
console.warn(...args);
|
|
@@ -2519,6 +2610,9 @@ const commandMap = {
|
|
|
2519
2610
|
'Extensions.enable': enableExtension,
|
|
2520
2611
|
'Extensions.enable2': enableExtension2,
|
|
2521
2612
|
'Extensions.executeCommand': executeCommand,
|
|
2613
|
+
'Extensions.executeCompletionProvider': executeCompletionProvider,
|
|
2614
|
+
'Extensions.executeFormattingProvider': executeFormattingProvider,
|
|
2615
|
+
'Extensions.executeResolveCompletionItemProvider': executeResolveCompletionItemProvider,
|
|
2522
2616
|
'Extensions.getAllExtensions': getAllExtensions,
|
|
2523
2617
|
'Extensions.getColorThemeCss': getColorThemeCss,
|
|
2524
2618
|
'Extensions.getColorThemeCssFromJson': getColorThemeCssFromJson,
|