@lvce-editor/extension-management-worker 4.90.1 → 4.90.3
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.
|
@@ -1729,10 +1729,9 @@ const createResponseFromData = data => {
|
|
|
1729
1729
|
return response;
|
|
1730
1730
|
};
|
|
1731
1731
|
|
|
1732
|
-
const
|
|
1733
|
-
|
|
1734
|
-
const
|
|
1735
|
-
const item = await getCacheStorageItem(cacheKey, cacheName$1);
|
|
1732
|
+
const defaultCacheName = 'Extensions';
|
|
1733
|
+
const getJson$1 = async (cacheKey, cacheName = defaultCacheName) => {
|
|
1734
|
+
const item = await getCacheStorageItem(cacheKey, cacheName);
|
|
1736
1735
|
if (!item) {
|
|
1737
1736
|
return undefined;
|
|
1738
1737
|
}
|
|
@@ -1740,11 +1739,11 @@ const getJson$1 = async cacheKey => {
|
|
|
1740
1739
|
const json = typeof body === 'string' ? body : new TextDecoder().decode(body);
|
|
1741
1740
|
return JSON.parse(json);
|
|
1742
1741
|
};
|
|
1743
|
-
const setJson = async (cacheKey, data) => {
|
|
1742
|
+
const setJson = async (cacheKey, data, cacheName = defaultCacheName) => {
|
|
1744
1743
|
try {
|
|
1745
1744
|
const response = createResponseFromData(data);
|
|
1746
1745
|
const headers = Object.fromEntries(response.headers.entries());
|
|
1747
|
-
const result = await setCacheStorageItem(cacheKey, await response.arrayBuffer(), cacheName
|
|
1746
|
+
const result = await setCacheStorageItem(cacheKey, await response.arrayBuffer(), cacheName, headers);
|
|
1748
1747
|
if (!result.success) {
|
|
1749
1748
|
throw new Error(result.errorMessage);
|
|
1750
1749
|
}
|
|
@@ -1818,10 +1817,11 @@ const isStaticHttpAssetDir = assetDir => {
|
|
|
1818
1817
|
const isHttpLocation = () => {
|
|
1819
1818
|
return Reflect.has(globalThis, 'location') && globalThis.location.protocol.startsWith('http');
|
|
1820
1819
|
};
|
|
1821
|
-
const getRuntimeContext = async (assetDir, platform) => {
|
|
1820
|
+
const getRuntimeContext = async (assetDir, platform, applicationId) => {
|
|
1822
1821
|
const shouldInferPlatform = isMissingPlatform(platform);
|
|
1823
|
-
const
|
|
1824
|
-
const
|
|
1822
|
+
const invoke = command => applicationId === undefined ? invoke$4(command) : invoke$4('Application.execute', applicationId, command);
|
|
1823
|
+
const resolvedAssetDir = isMissingAssetDir(assetDir) ? await invoke('Layout.getAssetDir') : assetDir;
|
|
1824
|
+
const resolvedPlatform = shouldInferPlatform ? await invoke('Layout.getPlatform') : platform;
|
|
1825
1825
|
if (shouldInferPlatform && isHttpLocation() && isStaticHttpAssetDir(resolvedAssetDir)) {
|
|
1826
1826
|
return {
|
|
1827
1827
|
assetDir: resolvedAssetDir,
|
|
@@ -3071,7 +3071,7 @@ const hideNotificationsFromExtension = async extensionId => {
|
|
|
3071
3071
|
await notifyNotificationsChanged();
|
|
3072
3072
|
};
|
|
3073
3073
|
|
|
3074
|
-
const cacheName = 'ExtensionSecrets';
|
|
3074
|
+
const cacheName$1 = 'ExtensionSecrets';
|
|
3075
3075
|
const getRequestUrl = (extensionId, key) => {
|
|
3076
3076
|
return `https://secret-storage.invalid/${encodeURIComponent(extensionId)}/${encodeURIComponent(key)}`;
|
|
3077
3077
|
};
|
|
@@ -3085,7 +3085,7 @@ const deleteSecret = async (extensionId, key) => {
|
|
|
3085
3085
|
await invoke$5('SecretStorage.delete', extensionId, key);
|
|
3086
3086
|
return;
|
|
3087
3087
|
}
|
|
3088
|
-
await removeCacheStorageItem(getRequestUrl(extensionId, key), cacheName);
|
|
3088
|
+
await removeCacheStorageItem(getRequestUrl(extensionId, key), cacheName$1);
|
|
3089
3089
|
};
|
|
3090
3090
|
const getSecret = async (extensionId, key) => {
|
|
3091
3091
|
string(extensionId);
|
|
@@ -3093,7 +3093,7 @@ const getSecret = async (extensionId, key) => {
|
|
|
3093
3093
|
if (isElectron()) {
|
|
3094
3094
|
return invoke$5('SecretStorage.get', extensionId, key);
|
|
3095
3095
|
}
|
|
3096
|
-
const item = await getCacheStorageItem(getRequestUrl(extensionId, key), cacheName);
|
|
3096
|
+
const item = await getCacheStorageItem(getRequestUrl(extensionId, key), cacheName$1);
|
|
3097
3097
|
if (!item) {
|
|
3098
3098
|
return undefined;
|
|
3099
3099
|
}
|
|
@@ -3108,7 +3108,7 @@ const storeSecret = async (extensionId, key, value) => {
|
|
|
3108
3108
|
await invoke$5('SecretStorage.store', extensionId, key, value);
|
|
3109
3109
|
return;
|
|
3110
3110
|
}
|
|
3111
|
-
const result = await setCacheStorageItem(getRequestUrl(extensionId, key), value, cacheName);
|
|
3111
|
+
const result = await setCacheStorageItem(getRequestUrl(extensionId, key), value, cacheName$1);
|
|
3112
3112
|
if (!result.success) {
|
|
3113
3113
|
throw new Error(result.errorMessage);
|
|
3114
3114
|
}
|
|
@@ -3547,7 +3547,14 @@ const deferInvalidateExtensionsCache = (extensionId, disabled) => {
|
|
|
3547
3547
|
}, 0);
|
|
3548
3548
|
};
|
|
3549
3549
|
|
|
3550
|
-
const handleChange$1 = async _id => {
|
|
3550
|
+
const handleChange$1 = async (_id, applicationId) => {
|
|
3551
|
+
if (applicationId !== undefined) {
|
|
3552
|
+
const visible = await invoke$4('Application.execute', applicationId, 'Layout.getStatusBarVisible');
|
|
3553
|
+
if (visible) {
|
|
3554
|
+
await invoke$4('Application.execute', applicationId, 'StatusBar.handleChange');
|
|
3555
|
+
}
|
|
3556
|
+
return;
|
|
3557
|
+
}
|
|
3551
3558
|
const statusBarVisible = await invoke$4('Layout.getStatusBarVisible');
|
|
3552
3559
|
if (!statusBarVisible) {
|
|
3553
3560
|
return;
|
|
@@ -5036,7 +5043,7 @@ const getOutputChannelProviders = async extensionsState => {
|
|
|
5036
5043
|
const {
|
|
5037
5044
|
assetDir,
|
|
5038
5045
|
platform
|
|
5039
|
-
} = await getRuntimeContext('', extensionsState.platform);
|
|
5046
|
+
} = await getRuntimeContext('', extensionsState.platform, extensionsState.applicationId);
|
|
5040
5047
|
const extensions = await getAllExtensionsWithState(extensionsState, assetDir, platform);
|
|
5041
5048
|
const outputExtensions = extensions.filter(hasOutputChannels);
|
|
5042
5049
|
const providers = await Promise.all(outputExtensions.map(extension => getExtensionOutputChannelProviders(extension, assetDir, platform)));
|
|
@@ -5063,7 +5070,7 @@ const resolveOutputChannel = async (extensionsState, uri) => {
|
|
|
5063
5070
|
const {
|
|
5064
5071
|
assetDir,
|
|
5065
5072
|
platform
|
|
5066
|
-
} = await getRuntimeContext('', extensionsState.platform);
|
|
5073
|
+
} = await getRuntimeContext('', extensionsState.platform, extensionsState.applicationId);
|
|
5067
5074
|
const extensions = await getAllExtensionsWithState(extensionsState, assetDir, platform);
|
|
5068
5075
|
const extension = extensions.find(candidate => getExtensionId$3(candidate) === extensionId && hasOutputChannels(candidate));
|
|
5069
5076
|
const isContributed = extension?.outputChannels?.some(outputChannel => outputChannel.id === outputChannelId);
|
|
@@ -5521,6 +5528,38 @@ const getColorThemeCssCached = async (colorThemeId, platform, getData) => {
|
|
|
5521
5528
|
const readJson = url => {
|
|
5522
5529
|
return invoke$4('FileSystem.readJson', url);
|
|
5523
5530
|
};
|
|
5531
|
+
const statWithMetadata = url => {
|
|
5532
|
+
return invoke$4('FileSystem.statWithMetadata', url);
|
|
5533
|
+
};
|
|
5534
|
+
|
|
5535
|
+
const getColorThemeJsonCacheKey = source => {
|
|
5536
|
+
return `https://color-theme.cache/${encodeURIComponent(source)}`;
|
|
5537
|
+
};
|
|
5538
|
+
|
|
5539
|
+
const cacheName = 'ColorThemes';
|
|
5540
|
+
const getColorThemeJsonCached = async (source, validator, getJson, forceReload = false) => {
|
|
5541
|
+
const cacheKey = getColorThemeJsonCacheKey(source);
|
|
5542
|
+
if (!forceReload) {
|
|
5543
|
+
try {
|
|
5544
|
+
const cached = await getJson$1(cacheKey, cacheName);
|
|
5545
|
+
if (cached?.validator === validator) {
|
|
5546
|
+
return cached.json;
|
|
5547
|
+
}
|
|
5548
|
+
} catch {
|
|
5549
|
+
// Persistent cache errors must not prevent loading the theme.
|
|
5550
|
+
}
|
|
5551
|
+
}
|
|
5552
|
+
const json = await getJson();
|
|
5553
|
+
try {
|
|
5554
|
+
await setJson(cacheKey, {
|
|
5555
|
+
json,
|
|
5556
|
+
validator
|
|
5557
|
+
}, cacheName);
|
|
5558
|
+
} catch {
|
|
5559
|
+
// Persistent cache errors must not prevent loading the theme.
|
|
5560
|
+
}
|
|
5561
|
+
return json;
|
|
5562
|
+
};
|
|
5524
5563
|
|
|
5525
5564
|
const join = (pathSeparator, ...parts) => {
|
|
5526
5565
|
return parts.join(pathSeparator);
|
|
@@ -5547,30 +5586,57 @@ const getColorThemeUri = (extensions, colorThemeId) => {
|
|
|
5547
5586
|
return '';
|
|
5548
5587
|
};
|
|
5549
5588
|
|
|
5550
|
-
const getColorThemeJson$2 = async (colorThemeId, assetDir, platform) => {
|
|
5589
|
+
const getColorThemeJson$2 = async (colorThemeId, assetDir, platform, forceReload = false) => {
|
|
5551
5590
|
const extensions = await getAllExtensions(assetDir, platform);
|
|
5552
5591
|
const colorThemeUri = getColorThemeUri(extensions, colorThemeId);
|
|
5553
5592
|
if (!colorThemeUri) {
|
|
5554
5593
|
return {};
|
|
5555
5594
|
}
|
|
5556
|
-
|
|
5557
|
-
|
|
5595
|
+
try {
|
|
5596
|
+
const stat = await statWithMetadata(colorThemeUri);
|
|
5597
|
+
if (typeof stat?.mtimeMs !== 'number' || typeof stat?.size !== 'number') {
|
|
5598
|
+
return await readJson(colorThemeUri);
|
|
5599
|
+
}
|
|
5600
|
+
const validator = JSON.stringify({
|
|
5601
|
+
mtimeMs: stat.mtimeMs,
|
|
5602
|
+
size: stat.size
|
|
5603
|
+
});
|
|
5604
|
+
return getColorThemeJsonCached(colorThemeUri, validator, () => readJson(colorThemeUri), forceReload);
|
|
5605
|
+
} catch {
|
|
5606
|
+
return readJson(colorThemeUri);
|
|
5607
|
+
}
|
|
5558
5608
|
};
|
|
5559
5609
|
|
|
5560
5610
|
const getColorThemeUrlWeb = (assetDir, colorThemeId) => {
|
|
5561
5611
|
return `${assetDir}/extensions/builtin.theme-${colorThemeId}/color-theme.json`;
|
|
5562
5612
|
};
|
|
5563
|
-
const getColorThemeJson$1 = (colorThemeId, assetDir) => {
|
|
5613
|
+
const getColorThemeJson$1 = (colorThemeId, assetDir, forceReload = false) => {
|
|
5564
5614
|
const url = getColorThemeUrlWeb(assetDir, colorThemeId);
|
|
5565
|
-
|
|
5566
|
-
|
|
5615
|
+
return getJsonCached(url, forceReload);
|
|
5616
|
+
};
|
|
5617
|
+
const getJsonCached = async (url, forceReload) => {
|
|
5618
|
+
try {
|
|
5619
|
+
const response = await fetch(url, {
|
|
5620
|
+
method: 'HEAD'
|
|
5621
|
+
});
|
|
5622
|
+
if (!response.ok) {
|
|
5623
|
+
return getJson(url);
|
|
5624
|
+
}
|
|
5625
|
+
const etag = response.headers.get('etag');
|
|
5626
|
+
if (!etag) {
|
|
5627
|
+
return getJson(url);
|
|
5628
|
+
}
|
|
5629
|
+
return getColorThemeJsonCached(url, etag, () => getJson(url), forceReload);
|
|
5630
|
+
} catch {
|
|
5631
|
+
return getJson(url);
|
|
5632
|
+
}
|
|
5567
5633
|
};
|
|
5568
5634
|
|
|
5569
|
-
const getColorThemeJson = (colorThemeId, platform, assetDir) => {
|
|
5635
|
+
const getColorThemeJson = (colorThemeId, platform, assetDir, forceReload = false) => {
|
|
5570
5636
|
if (platform === Web) {
|
|
5571
|
-
return getColorThemeJson$1(colorThemeId, assetDir);
|
|
5637
|
+
return getColorThemeJson$1(colorThemeId, assetDir, forceReload);
|
|
5572
5638
|
}
|
|
5573
|
-
return getColorThemeJson$2(colorThemeId, assetDir, platform);
|
|
5639
|
+
return getColorThemeJson$2(colorThemeId, assetDir, platform, forceReload);
|
|
5574
5640
|
};
|
|
5575
5641
|
|
|
5576
5642
|
const getColorThemeCssFromJson = async (colorThemeId, colorThemeJson) => {
|
|
@@ -6562,7 +6628,7 @@ const wrapSourceControlProviderCommand = methodName => {
|
|
|
6562
6628
|
return executeRequiredSourceControlProvider(extensionsState, providerId, methodName, ...args);
|
|
6563
6629
|
});
|
|
6564
6630
|
};
|
|
6565
|
-
const sharedApplicationCommands = new Set(['Extensions.getColorThemeCss', 'Extensions.getColorThemeCssFromJson', 'Extensions.getColorThemeJson', 'Extensions.getColorThemeNames'
|
|
6631
|
+
const sharedApplicationCommands = new Set(['Extensions.getColorThemeCss', 'Extensions.getColorThemeCssFromJson', 'Extensions.getColorThemeJson', 'Extensions.getColorThemeNames']);
|
|
6566
6632
|
const invokeForApplication = async (applicationId, method, ...args) => {
|
|
6567
6633
|
const application = get$7(applicationId);
|
|
6568
6634
|
const command = commandMap[method];
|
|
@@ -6588,6 +6654,8 @@ const invokeForApplication = async (applicationId, method, ...args) => {
|
|
|
6588
6654
|
return getAllExtensionsWithState(application, args[0] || '', args[1] ?? application.platform, args[2]);
|
|
6589
6655
|
case 'Extensions.getDynamicWebExtensions':
|
|
6590
6656
|
return application.webExtensions;
|
|
6657
|
+
case 'Extensions.getPreference':
|
|
6658
|
+
return invoke$2('Application.execute', applicationId, 'Preferences.get', ...args);
|
|
6591
6659
|
case 'Extensions.getRpcInfo':
|
|
6592
6660
|
return getRpcInfo$1(application, args[0]);
|
|
6593
6661
|
case 'Extensions.getRuntimeStatus':
|
|
@@ -6607,8 +6675,14 @@ const invokeForApplication = async (applicationId, method, ...args) => {
|
|
|
6607
6675
|
return requestViewRerender(args[0], applicationId);
|
|
6608
6676
|
case 'Extensions.sendMessagePortToFileSystemWorker':
|
|
6609
6677
|
return createFileSystemPort(application, args[0]);
|
|
6678
|
+
case 'Extensions.setPreference':
|
|
6679
|
+
return invoke$2('Application.execute', applicationId, 'Preferences.update', {
|
|
6680
|
+
[args[0]]: args[1]
|
|
6681
|
+
});
|
|
6610
6682
|
case 'Extensions.showNotification':
|
|
6611
6683
|
return invoke$2('Application.execute', applicationId, 'Notification.create', ...args);
|
|
6684
|
+
case 'StatusBar.handleChange':
|
|
6685
|
+
return handleChange$1(args[0], applicationId);
|
|
6612
6686
|
default:
|
|
6613
6687
|
throw new Error(`Extension command does not support application context: ${method}`);
|
|
6614
6688
|
}
|