@lvce-editor/extension-management-worker 1.9.0 → 1.10.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.
|
@@ -1353,6 +1353,50 @@ const activateExtension2 = async (extensionId, extension, absolutePath) => {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
};
|
|
1355
1355
|
|
|
1356
|
+
const importExtension = async (extensionId, absolutePath, activationEvent) => {
|
|
1357
|
+
try {
|
|
1358
|
+
string(absolutePath);
|
|
1359
|
+
const startTime = performance.now();
|
|
1360
|
+
set$2({
|
|
1361
|
+
activationEndTime: 0,
|
|
1362
|
+
activationEvent: activationEvent,
|
|
1363
|
+
activationStartTime: performance.now(),
|
|
1364
|
+
activationTime: 0,
|
|
1365
|
+
id: extensionId,
|
|
1366
|
+
importEndTime: 0,
|
|
1367
|
+
importStartTime: startTime,
|
|
1368
|
+
importTime: 0,
|
|
1369
|
+
status: Importing
|
|
1370
|
+
});
|
|
1371
|
+
try {
|
|
1372
|
+
await invoke$3('ExtensionHost.importExtension2', extensionId, absolutePath);
|
|
1373
|
+
const endTime = performance.now();
|
|
1374
|
+
const time = endTime - startTime;
|
|
1375
|
+
update$1(extensionId, {
|
|
1376
|
+
importEndTime: endTime,
|
|
1377
|
+
importTime: time
|
|
1378
|
+
});
|
|
1379
|
+
} catch (error) {
|
|
1380
|
+
update$1(extensionId, {
|
|
1381
|
+
status: Error$1 // TODO maybe store error also in runtime status state
|
|
1382
|
+
});
|
|
1383
|
+
if (isImportError(error)) {
|
|
1384
|
+
const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
|
|
1385
|
+
throw new Error(actualErrorMessage);
|
|
1386
|
+
}
|
|
1387
|
+
throw error;
|
|
1388
|
+
}
|
|
1389
|
+
} catch (error) {
|
|
1390
|
+
throw new VError(error, `Failed to import extension ${extensionId}`);
|
|
1391
|
+
}
|
|
1392
|
+
};
|
|
1393
|
+
|
|
1394
|
+
const activateExtension3 = async (extension, absolutePath, activationEvent) => {
|
|
1395
|
+
const extensionId = extension.id;
|
|
1396
|
+
await importExtension(extensionId, absolutePath, activationEvent);
|
|
1397
|
+
await activateExtension2(extensionId, extension, absolutePath);
|
|
1398
|
+
};
|
|
1399
|
+
|
|
1356
1400
|
const cache = Object.create(null);
|
|
1357
1401
|
const id = 1;
|
|
1358
1402
|
const clear = () => {
|
|
@@ -1746,44 +1790,6 @@ const handleMessagePort = async port => {
|
|
|
1746
1790
|
});
|
|
1747
1791
|
};
|
|
1748
1792
|
|
|
1749
|
-
const importExtension = async (extensionId, absolutePath, activationEvent) => {
|
|
1750
|
-
try {
|
|
1751
|
-
string(absolutePath);
|
|
1752
|
-
const startTime = performance.now();
|
|
1753
|
-
set$2({
|
|
1754
|
-
activationEndTime: 0,
|
|
1755
|
-
activationEvent: activationEvent,
|
|
1756
|
-
activationStartTime: performance.now(),
|
|
1757
|
-
activationTime: 0,
|
|
1758
|
-
id: extensionId,
|
|
1759
|
-
importEndTime: 0,
|
|
1760
|
-
importStartTime: startTime,
|
|
1761
|
-
importTime: 0,
|
|
1762
|
-
status: Importing
|
|
1763
|
-
});
|
|
1764
|
-
try {
|
|
1765
|
-
await invoke$3('ExtneionHost.importExtension2', extensionId, absolutePath);
|
|
1766
|
-
const endTime = performance.now();
|
|
1767
|
-
const time = endTime - startTime;
|
|
1768
|
-
update$1(extensionId, {
|
|
1769
|
-
importEndTime: endTime,
|
|
1770
|
-
importTime: time
|
|
1771
|
-
});
|
|
1772
|
-
} catch (error) {
|
|
1773
|
-
update$1(extensionId, {
|
|
1774
|
-
status: Error$1 // TODO maybe store error also in runtime status state
|
|
1775
|
-
});
|
|
1776
|
-
if (isImportError(error)) {
|
|
1777
|
-
const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
|
|
1778
|
-
throw new Error(actualErrorMessage);
|
|
1779
|
-
}
|
|
1780
|
-
throw error;
|
|
1781
|
-
}
|
|
1782
|
-
} catch (error) {
|
|
1783
|
-
throw new VError(error, `Failed to import extension ${extensionId}`);
|
|
1784
|
-
}
|
|
1785
|
-
};
|
|
1786
|
-
|
|
1787
1793
|
const initializeExtensionHostWorker = async () => {
|
|
1788
1794
|
const rpc = await TransferMessagePortRpcParent.create({
|
|
1789
1795
|
commandMap: commandMapRef,
|
|
@@ -1892,6 +1898,7 @@ const uninstallExtension = async () => {
|
|
|
1892
1898
|
|
|
1893
1899
|
const commandMap = {
|
|
1894
1900
|
'Extensions.activate2': activateExtension2,
|
|
1901
|
+
'Extensions.activate3': activateExtension3,
|
|
1895
1902
|
'Extensions.addWebExtension': addWebExtension,
|
|
1896
1903
|
'Extensions.disable': disableExtension,
|
|
1897
1904
|
'Extensions.enable': enableExtension,
|