@lvce-editor/extension-management-worker 1.11.0 → 1.13.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.
|
@@ -587,7 +587,7 @@ const callbacks = Object.create(null);
|
|
|
587
587
|
const set$8 = (id, fn) => {
|
|
588
588
|
callbacks[id] = fn;
|
|
589
589
|
};
|
|
590
|
-
const get$
|
|
590
|
+
const get$5 = id => {
|
|
591
591
|
return callbacks[id];
|
|
592
592
|
};
|
|
593
593
|
const remove = id => {
|
|
@@ -768,7 +768,7 @@ const warn$1 = (...args) => {
|
|
|
768
768
|
console.warn(...args);
|
|
769
769
|
};
|
|
770
770
|
const resolve = (id, response) => {
|
|
771
|
-
const fn = get$
|
|
771
|
+
const fn = get$5(id);
|
|
772
772
|
if (!fn) {
|
|
773
773
|
console.log(response);
|
|
774
774
|
warn$1(`callback ${id} may already be disposed`);
|
|
@@ -1138,29 +1138,29 @@ const FileSystemWorker = 209;
|
|
|
1138
1138
|
const RendererWorker = 1;
|
|
1139
1139
|
const SharedProcess = 1;
|
|
1140
1140
|
|
|
1141
|
-
const rpcs = Object.create(null);
|
|
1141
|
+
const rpcs$1 = Object.create(null);
|
|
1142
1142
|
const set$7 = (id, rpc) => {
|
|
1143
|
-
rpcs[id] = rpc;
|
|
1143
|
+
rpcs$1[id] = rpc;
|
|
1144
1144
|
};
|
|
1145
|
-
const get$
|
|
1146
|
-
return rpcs[id];
|
|
1145
|
+
const get$4 = id => {
|
|
1146
|
+
return rpcs$1[id];
|
|
1147
1147
|
};
|
|
1148
1148
|
|
|
1149
1149
|
const create$1 = rpcId => {
|
|
1150
1150
|
return {
|
|
1151
1151
|
async dispose() {
|
|
1152
|
-
const rpc = get$
|
|
1152
|
+
const rpc = get$4(rpcId);
|
|
1153
1153
|
await rpc.dispose();
|
|
1154
1154
|
},
|
|
1155
1155
|
// @ts-ignore
|
|
1156
1156
|
invoke(method, ...params) {
|
|
1157
|
-
const rpc = get$
|
|
1157
|
+
const rpc = get$4(rpcId);
|
|
1158
1158
|
// @ts-ignore
|
|
1159
1159
|
return rpc.invoke(method, ...params);
|
|
1160
1160
|
},
|
|
1161
1161
|
// @ts-ignore
|
|
1162
1162
|
invokeAndTransfer(method, ...params) {
|
|
1163
|
-
const rpc = get$
|
|
1163
|
+
const rpc = get$4(rpcId);
|
|
1164
1164
|
// @ts-ignore
|
|
1165
1165
|
return rpc.invokeAndTransfer(method, ...params);
|
|
1166
1166
|
},
|
|
@@ -1261,7 +1261,7 @@ const states = Object.create(null);
|
|
|
1261
1261
|
const set$2 = status => {
|
|
1262
1262
|
states[status.id] = status;
|
|
1263
1263
|
};
|
|
1264
|
-
const get$
|
|
1264
|
+
const get$3 = extensionId => {
|
|
1265
1265
|
return states[extensionId];
|
|
1266
1266
|
};
|
|
1267
1267
|
const update$1 = (id, update) => {
|
|
@@ -1353,6 +1353,49 @@ const activateExtension2 = async (extensionId, extension, absolutePath) => {
|
|
|
1353
1353
|
}
|
|
1354
1354
|
};
|
|
1355
1355
|
|
|
1356
|
+
const rpcs = Object.create(null);
|
|
1357
|
+
const add = (id, rpc) => {
|
|
1358
|
+
rpcs[id] = rpc;
|
|
1359
|
+
};
|
|
1360
|
+
const get$2 = id => {
|
|
1361
|
+
return rpcs[id];
|
|
1362
|
+
};
|
|
1363
|
+
|
|
1364
|
+
const getUrlPrefix = (platform, extensionPath) => {
|
|
1365
|
+
if (extensionPath.startsWith('http://') || extensionPath.startsWith('https://')) {
|
|
1366
|
+
return extensionPath;
|
|
1367
|
+
}
|
|
1368
|
+
if (platform === Web) {
|
|
1369
|
+
return extensionPath;
|
|
1370
|
+
}
|
|
1371
|
+
if (extensionPath.startsWith('/')) {
|
|
1372
|
+
return `/remote${extensionPath}`;
|
|
1373
|
+
}
|
|
1374
|
+
return `/remote/${extensionPath}`;
|
|
1375
|
+
};
|
|
1376
|
+
|
|
1377
|
+
const handleRpcInfos = (extension, platform) => {
|
|
1378
|
+
try {
|
|
1379
|
+
if (!extension) {
|
|
1380
|
+
return;
|
|
1381
|
+
}
|
|
1382
|
+
const rpcs = extension.rpc;
|
|
1383
|
+
const urlPrefix = getUrlPrefix(platform, extension.path);
|
|
1384
|
+
if (!rpcs) {
|
|
1385
|
+
return;
|
|
1386
|
+
}
|
|
1387
|
+
if (!Array.isArray(rpcs)) {
|
|
1388
|
+
return;
|
|
1389
|
+
}
|
|
1390
|
+
for (const rpc of rpcs) {
|
|
1391
|
+
rpc.url = `${urlPrefix}/${rpc.url}`;
|
|
1392
|
+
add(rpc.id, rpc);
|
|
1393
|
+
}
|
|
1394
|
+
} catch (error) {
|
|
1395
|
+
console.warn(`Failed to handle extension rpcs: ${error}`);
|
|
1396
|
+
}
|
|
1397
|
+
};
|
|
1398
|
+
|
|
1356
1399
|
const importExtension = async (extensionId, absolutePath, activationEvent) => {
|
|
1357
1400
|
try {
|
|
1358
1401
|
string(absolutePath);
|
|
@@ -1391,7 +1434,8 @@ const importExtension = async (extensionId, absolutePath, activationEvent) => {
|
|
|
1391
1434
|
}
|
|
1392
1435
|
};
|
|
1393
1436
|
|
|
1394
|
-
const activateExtension3 = async (extension, absolutePath, activationEvent) => {
|
|
1437
|
+
const activateExtension3 = async (extension, absolutePath, activationEvent, platform) => {
|
|
1438
|
+
handleRpcInfos(extension, platform);
|
|
1395
1439
|
const extensionId = extension.id;
|
|
1396
1440
|
await importExtension(extensionId, absolutePath, activationEvent);
|
|
1397
1441
|
await activateExtension2(extensionId, extension, absolutePath);
|
|
@@ -1764,6 +1808,14 @@ const getExtension = async id => {
|
|
|
1764
1808
|
return undefined;
|
|
1765
1809
|
};
|
|
1766
1810
|
|
|
1811
|
+
const getRpcInfo = rpcId => {
|
|
1812
|
+
const info = get$2(rpcId);
|
|
1813
|
+
if (!info) {
|
|
1814
|
+
throw new Error(`Rpc not found ${rpcId}`);
|
|
1815
|
+
}
|
|
1816
|
+
return info;
|
|
1817
|
+
};
|
|
1818
|
+
|
|
1767
1819
|
const emptyStatus = {
|
|
1768
1820
|
activationEndTime: 0,
|
|
1769
1821
|
activationEvent: '',
|
|
@@ -1776,7 +1828,7 @@ const emptyStatus = {
|
|
|
1776
1828
|
status: None
|
|
1777
1829
|
};
|
|
1778
1830
|
const getRuntimeStatus = extensionId => {
|
|
1779
|
-
return get$
|
|
1831
|
+
return get$3(extensionId) || emptyStatus;
|
|
1780
1832
|
};
|
|
1781
1833
|
|
|
1782
1834
|
const commandMapRef = {};
|
|
@@ -1908,11 +1960,13 @@ const commandMap = {
|
|
|
1908
1960
|
'Extensions.disable': disableExtension,
|
|
1909
1961
|
'Extensions.enable': enableExtension,
|
|
1910
1962
|
'Extensions.getAllExtensions': getAllExtensions,
|
|
1911
|
-
'Extensions.
|
|
1963
|
+
'Extensions.getColorThemeCss': getColorThemeCss,
|
|
1964
|
+
'Extensions.getColorThemeCssFromJson': getColorThemeCssFromJson,
|
|
1912
1965
|
'Extensions.getColorThemeJson': getColorThemeJson,
|
|
1913
1966
|
'Extensions.getColorThemeNames': getColorThemeNames,
|
|
1914
1967
|
'Extensions.getExtension': getExtension,
|
|
1915
1968
|
'Extensions.getLanguages': getLanguages,
|
|
1969
|
+
'Extensions.getRpcInfo': getRpcInfo,
|
|
1916
1970
|
'Extensions.getRuntimeStatus': getRuntimeStatus,
|
|
1917
1971
|
'Extensions.handleMessagePort': handleMessagePort,
|
|
1918
1972
|
'Extensions.importExtension': importExtension,
|