@lvce-editor/extension-management-worker 4.85.0 → 4.87.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.
|
@@ -1608,6 +1608,7 @@ const {
|
|
|
1608
1608
|
|
|
1609
1609
|
const {
|
|
1610
1610
|
invoke: invoke$8,
|
|
1611
|
+
invokeAndTransfer: invokeAndTransfer$2,
|
|
1611
1612
|
set: set$b
|
|
1612
1613
|
} = create(19_001);
|
|
1613
1614
|
const getCacheStorageItem = async (request, cacheName, bucketName, bucketOptions) => {
|
|
@@ -2832,6 +2833,12 @@ const reset = applicationId => {
|
|
|
2832
2833
|
}
|
|
2833
2834
|
};
|
|
2834
2835
|
|
|
2836
|
+
const getCacheFileHandle = async (extensionId, name) => {
|
|
2837
|
+
const digest = await crypto.subtle.digest('SHA-256', new TextEncoder().encode(extensionId));
|
|
2838
|
+
const hash = Array.from(new Uint8Array(digest), byte => byte.toString(16).padStart(2, '0')).join('');
|
|
2839
|
+
return invoke$8('Opfs.getCacheFileHandle', `extension-${hash}`, name);
|
|
2840
|
+
};
|
|
2841
|
+
|
|
2835
2842
|
const prefix = '[Extension] Uncaught Error: ';
|
|
2836
2843
|
const handleUncaughtExtensionError = async error => {
|
|
2837
2844
|
const prettyError = await invoke$7('Errors.prepare', error);
|
|
@@ -2999,6 +3006,10 @@ const storeSecret = async (extensionId, key, value) => {
|
|
|
2999
3006
|
}
|
|
3000
3007
|
};
|
|
3001
3008
|
|
|
3009
|
+
const sendMessagePortToCacheWorker = async (extensionId, port) => {
|
|
3010
|
+
await invokeAndTransfer$2('CacheWorker.handleExtensionMessagePort', port, extensionId);
|
|
3011
|
+
};
|
|
3012
|
+
|
|
3002
3013
|
class CommandNotFoundError extends Error {
|
|
3003
3014
|
constructor(command) {
|
|
3004
3015
|
super(`Command not found ${command}`);
|
|
@@ -3044,7 +3055,9 @@ const createExtensionCommandMap = (extensionId, invokeCommand = invokeGlobalComm
|
|
|
3044
3055
|
return {
|
|
3045
3056
|
...inheritedCommands,
|
|
3046
3057
|
'Extensions.executeCommand': (id, ...args) => executeCommand$1(invokeCommand, id, ...args),
|
|
3058
|
+
'Extensions.getCacheFileHandle': name => invokeCommand('Extensions.getCacheFileHandle', name),
|
|
3047
3059
|
'Extensions.registerFileChangeHandler': () => invokeCommand('Extensions.registerFileChangeHandler'),
|
|
3060
|
+
'Extensions.sendMessagePortToCacheWorker': port => invokeCommand('Extensions.sendMessagePortToCacheWorker', port),
|
|
3048
3061
|
'Extensions.unregisterFileChangeHandler': () => invokeCommand('Extensions.unregisterFileChangeHandler')
|
|
3049
3062
|
};
|
|
3050
3063
|
}
|
|
@@ -3062,12 +3075,18 @@ const createExtensionCommandMap = (extensionId, invokeCommand = invokeGlobalComm
|
|
|
3062
3075
|
'Extensions.executeCommand'(id, ...args) {
|
|
3063
3076
|
return executeCommand$1(invokeCommand, id, ...args);
|
|
3064
3077
|
},
|
|
3078
|
+
'Extensions.getCacheFileHandle'(name) {
|
|
3079
|
+
return getCacheFileHandle(extensionId, name);
|
|
3080
|
+
},
|
|
3065
3081
|
'Extensions.getSecret'(key) {
|
|
3066
3082
|
return getSecret(extensionId, key);
|
|
3067
3083
|
},
|
|
3068
3084
|
'Extensions.registerFileChangeHandler'() {
|
|
3069
3085
|
register(extensionId);
|
|
3070
3086
|
},
|
|
3087
|
+
'Extensions.sendMessagePortToCacheWorker'(port) {
|
|
3088
|
+
return sendMessagePortToCacheWorker(extensionId, port);
|
|
3089
|
+
},
|
|
3071
3090
|
'Extensions.sendMessagePortToElectron'(port, initialCommand) {
|
|
3072
3091
|
if (initialCommand !== allowedElectronPortCommand) {
|
|
3073
3092
|
throw new Error(`Isolated extensions cannot send a port using ${initialCommand}`);
|
|
@@ -3117,6 +3136,9 @@ const createIsolatedExtensionHostWorker = async (extensionId, absolutePath, work
|
|
|
3117
3136
|
const runtimeId = getRuntimeId(extensionId, application);
|
|
3118
3137
|
const invokeCommand = application === undefined ? undefined : (method, ...args) => {
|
|
3119
3138
|
assertCurrentApplication(application);
|
|
3139
|
+
if (method === 'Extensions.getCacheFileHandle') {
|
|
3140
|
+
return getCacheFileHandle(extensionId, args[0]);
|
|
3141
|
+
}
|
|
3120
3142
|
if (method === 'Extensions.registerFileChangeHandler') {
|
|
3121
3143
|
return register(extensionId, application.applicationId);
|
|
3122
3144
|
}
|
|
@@ -3126,6 +3148,9 @@ const createIsolatedExtensionHostWorker = async (extensionId, absolutePath, work
|
|
|
3126
3148
|
if (method === 'Extensions.sendMessagePortToFileSystemWorker') {
|
|
3127
3149
|
return createFileSystemPort(application, args[0], extensionId);
|
|
3128
3150
|
}
|
|
3151
|
+
if (method === 'Extensions.sendMessagePortToCacheWorker') {
|
|
3152
|
+
return sendMessagePortToCacheWorker(extensionId, args[0]);
|
|
3153
|
+
}
|
|
3129
3154
|
if (method === 'Extensions.createWebViewWorkerRpc' || method === 'Extensions.createWebViewWorkerRpc2') {
|
|
3130
3155
|
return createWorker$1(application, args[0], args[1], method === 'Extensions.createWebViewWorkerRpc', extensionId);
|
|
3131
3156
|
}
|