@lvce-editor/extension-host-worker 5.2.0 → 5.4.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.
- package/dist/extensionHostWorkerMain.js +88 -27
- package/package.json +1 -1
|
@@ -756,7 +756,7 @@ const setConfigurations = preferences => {
|
|
|
756
756
|
};
|
|
757
757
|
|
|
758
758
|
const rpcs$2 = Object.create(null);
|
|
759
|
-
const set$
|
|
759
|
+
const set$5$1 = (id, rpc) => {
|
|
760
760
|
rpcs$2[id] = rpc;
|
|
761
761
|
};
|
|
762
762
|
const get$a = id => {
|
|
@@ -1400,22 +1400,11 @@ class IpcChildWithModuleWorker extends Ipc {
|
|
|
1400
1400
|
const wrap$f = global => {
|
|
1401
1401
|
return new IpcChildWithModuleWorker(global);
|
|
1402
1402
|
};
|
|
1403
|
-
const withResolvers = () => {
|
|
1404
|
-
let _resolve;
|
|
1405
|
-
const promise = new Promise(resolve => {
|
|
1406
|
-
_resolve = resolve;
|
|
1407
|
-
});
|
|
1408
|
-
return {
|
|
1409
|
-
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
1410
|
-
resolve: _resolve,
|
|
1411
|
-
promise
|
|
1412
|
-
};
|
|
1413
|
-
};
|
|
1414
1403
|
const waitForFirstMessage = async port => {
|
|
1415
1404
|
const {
|
|
1416
1405
|
resolve,
|
|
1417
1406
|
promise
|
|
1418
|
-
} = withResolvers();
|
|
1407
|
+
} = Promise.withResolvers();
|
|
1419
1408
|
port.addEventListener('message', resolve, {
|
|
1420
1409
|
once: true
|
|
1421
1410
|
});
|
|
@@ -1497,7 +1486,7 @@ const getFirstEvent = (eventEmitter, eventMap) => {
|
|
|
1497
1486
|
const {
|
|
1498
1487
|
resolve,
|
|
1499
1488
|
promise
|
|
1500
|
-
} = withResolvers();
|
|
1489
|
+
} = Promise.withResolvers();
|
|
1501
1490
|
const listenerMap = Object.create(null);
|
|
1502
1491
|
const cleanup = value => {
|
|
1503
1492
|
for (const event of Object.keys(eventMap)) {
|
|
@@ -1653,11 +1642,11 @@ const remove$3 = id => {
|
|
|
1653
1642
|
delete callbacks[id];
|
|
1654
1643
|
};
|
|
1655
1644
|
let id$1 = 0;
|
|
1656
|
-
const create$3$
|
|
1645
|
+
const create$3$2 = () => {
|
|
1657
1646
|
return ++id$1;
|
|
1658
1647
|
};
|
|
1659
1648
|
const registerPromise = () => {
|
|
1660
|
-
const id = create$3$
|
|
1649
|
+
const id = create$3$2();
|
|
1661
1650
|
const {
|
|
1662
1651
|
resolve,
|
|
1663
1652
|
promise
|
|
@@ -1668,7 +1657,7 @@ const registerPromise = () => {
|
|
|
1668
1657
|
promise
|
|
1669
1658
|
};
|
|
1670
1659
|
};
|
|
1671
|
-
const create$2$
|
|
1660
|
+
const create$2$2 = (method, params) => {
|
|
1672
1661
|
const {
|
|
1673
1662
|
id,
|
|
1674
1663
|
promise
|
|
@@ -1871,7 +1860,7 @@ const getErrorResponse = (message, error, preparePrettyError, logError) => {
|
|
|
1871
1860
|
const errorProperty = getErrorProperty(error, prettyError);
|
|
1872
1861
|
return create$1$2(message, errorProperty);
|
|
1873
1862
|
};
|
|
1874
|
-
const create$
|
|
1863
|
+
const create$8 = (message, result) => {
|
|
1875
1864
|
return {
|
|
1876
1865
|
jsonrpc: Two,
|
|
1877
1866
|
id: message.id,
|
|
@@ -1880,7 +1869,7 @@ const create$a = (message, result) => {
|
|
|
1880
1869
|
};
|
|
1881
1870
|
const getSuccessResponse = (message, result) => {
|
|
1882
1871
|
const resultProperty = result ?? null;
|
|
1883
|
-
return create$
|
|
1872
|
+
return create$8(message, resultProperty);
|
|
1884
1873
|
};
|
|
1885
1874
|
const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
|
|
1886
1875
|
try {
|
|
@@ -1960,7 +1949,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
1960
1949
|
const {
|
|
1961
1950
|
message,
|
|
1962
1951
|
promise
|
|
1963
|
-
} = create$2$
|
|
1952
|
+
} = create$2$2(method, params);
|
|
1964
1953
|
if (useSendAndTransfer && ipc.sendAndTransfer) {
|
|
1965
1954
|
ipc.sendAndTransfer(message);
|
|
1966
1955
|
} else {
|
|
@@ -2047,7 +2036,7 @@ const listen$1 = async (module, options) => {
|
|
|
2047
2036
|
const ipc = module.wrap(rawIpc);
|
|
2048
2037
|
return ipc;
|
|
2049
2038
|
};
|
|
2050
|
-
const create$
|
|
2039
|
+
const create$a = async ({
|
|
2051
2040
|
commandMap,
|
|
2052
2041
|
messagePort
|
|
2053
2042
|
}) => {
|
|
@@ -2062,9 +2051,9 @@ const create$9 = async ({
|
|
|
2062
2051
|
};
|
|
2063
2052
|
const MessagePortRpcClient = {
|
|
2064
2053
|
__proto__: null,
|
|
2065
|
-
create: create$
|
|
2054
|
+
create: create$a
|
|
2066
2055
|
};
|
|
2067
|
-
const create$
|
|
2056
|
+
const create$9 = async ({
|
|
2068
2057
|
commandMap,
|
|
2069
2058
|
messagePort,
|
|
2070
2059
|
isMessagePortOpen
|
|
@@ -2082,7 +2071,36 @@ const create$8 = async ({
|
|
|
2082
2071
|
};
|
|
2083
2072
|
const MessagePortRpcParent = {
|
|
2084
2073
|
__proto__: null,
|
|
2085
|
-
create: create$
|
|
2074
|
+
create: create$9
|
|
2075
|
+
};
|
|
2076
|
+
const create$3$1 = async ({
|
|
2077
|
+
commandMap,
|
|
2078
|
+
messagePort
|
|
2079
|
+
}) => {
|
|
2080
|
+
// TODO create a commandMap per rpc instance
|
|
2081
|
+
register$1(commandMap);
|
|
2082
|
+
const rawIpc = await IpcParentWithMessagePort$1.create({
|
|
2083
|
+
messagePort,
|
|
2084
|
+
isMessagePortOpen: true
|
|
2085
|
+
});
|
|
2086
|
+
const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
|
|
2087
|
+
handleIpc(ipc);
|
|
2088
|
+
const rpc = createRpc$1(ipc);
|
|
2089
|
+
messagePort.start();
|
|
2090
|
+
return rpc;
|
|
2091
|
+
};
|
|
2092
|
+
const create$2$1 = async ({
|
|
2093
|
+
commandMap,
|
|
2094
|
+
messagePort
|
|
2095
|
+
}) => {
|
|
2096
|
+
return create$3$1({
|
|
2097
|
+
commandMap,
|
|
2098
|
+
messagePort
|
|
2099
|
+
});
|
|
2100
|
+
};
|
|
2101
|
+
const PlainMessagePortRpcParent = {
|
|
2102
|
+
__proto__: null,
|
|
2103
|
+
create: create$2$1
|
|
2086
2104
|
};
|
|
2087
2105
|
const create$1$1 = async ({
|
|
2088
2106
|
commandMap,
|
|
@@ -4734,11 +4752,43 @@ const remove = uri => {
|
|
|
4734
4752
|
remove$1(key);
|
|
4735
4753
|
}
|
|
4736
4754
|
};
|
|
4737
|
-
const
|
|
4755
|
+
const renameFile = (oldUri, newUri) => {
|
|
4738
4756
|
const content = readFile(oldUri);
|
|
4739
4757
|
writeFile(newUri, content);
|
|
4740
4758
|
remove(oldUri);
|
|
4741
4759
|
};
|
|
4760
|
+
const renameDirectory = (oldUri, newUri) => {
|
|
4761
|
+
if (!oldUri.endsWith(Slash)) {
|
|
4762
|
+
oldUri += Slash;
|
|
4763
|
+
}
|
|
4764
|
+
if (!newUri.endsWith(Slash)) {
|
|
4765
|
+
newUri += Slash;
|
|
4766
|
+
}
|
|
4767
|
+
ensureParentDir(newUri);
|
|
4768
|
+
setDirent(newUri, {
|
|
4769
|
+
type: Directory$1,
|
|
4770
|
+
content: ''
|
|
4771
|
+
});
|
|
4772
|
+
const allFiles = getAll();
|
|
4773
|
+
for (const [key, value] of Object.entries(allFiles)) {
|
|
4774
|
+
if (key.startsWith(oldUri)) {
|
|
4775
|
+
const newPath = key.replace(oldUri, newUri);
|
|
4776
|
+
setDirent(newPath, value);
|
|
4777
|
+
}
|
|
4778
|
+
}
|
|
4779
|
+
remove(oldUri);
|
|
4780
|
+
};
|
|
4781
|
+
const rename = (oldUri, newUri) => {
|
|
4782
|
+
const item = getDirent(oldUri);
|
|
4783
|
+
if (!item) {
|
|
4784
|
+
throw new FileNotFoundError(oldUri);
|
|
4785
|
+
}
|
|
4786
|
+
if (item.type === Directory$1) {
|
|
4787
|
+
renameDirectory(oldUri, newUri);
|
|
4788
|
+
return;
|
|
4789
|
+
}
|
|
4790
|
+
renameFile(oldUri, newUri);
|
|
4791
|
+
};
|
|
4742
4792
|
const readDirWithFileTypes = uri => {
|
|
4743
4793
|
if (!uri.endsWith(Slash)) {
|
|
4744
4794
|
uri += Slash;
|
|
@@ -4933,13 +4983,23 @@ const handleBeforeUnload = () => {
|
|
|
4933
4983
|
// console.log('before unload')
|
|
4934
4984
|
};
|
|
4935
4985
|
|
|
4986
|
+
const handleMessagePort2 = async (port, rpcId) => {
|
|
4987
|
+
const rpc = await PlainMessagePortRpcParent.create({
|
|
4988
|
+
messagePort: port,
|
|
4989
|
+
commandMap: {}
|
|
4990
|
+
});
|
|
4991
|
+
if (rpcId) {
|
|
4992
|
+
set$5$1(rpcId, rpc);
|
|
4993
|
+
}
|
|
4994
|
+
};
|
|
4995
|
+
|
|
4936
4996
|
const handleMessagePort = async (port, rpcId) => {
|
|
4937
4997
|
const rpc = await MessagePortRpcClient.create({
|
|
4938
4998
|
messagePort: port,
|
|
4939
4999
|
commandMap: {}
|
|
4940
5000
|
});
|
|
4941
5001
|
if (rpcId) {
|
|
4942
|
-
set$
|
|
5002
|
+
set$5$1(rpcId, rpc);
|
|
4943
5003
|
}
|
|
4944
5004
|
};
|
|
4945
5005
|
|
|
@@ -5542,6 +5602,7 @@ const commandMap = {
|
|
|
5542
5602
|
'FileSystemMemory.writeFile': writeFile,
|
|
5543
5603
|
'HandleBeforeUnload.handleBeforeUnload': handleBeforeUnload,
|
|
5544
5604
|
'HandleMessagePort.handleMessagePort': handleMessagePort,
|
|
5605
|
+
'HandleMessagePort.handleMessagePort2': handleMessagePort2,
|
|
5545
5606
|
'IconTheme.getJson': getIconThemeJson,
|
|
5546
5607
|
'IconTheme.getState': getState,
|
|
5547
5608
|
'IconTheme.hydrate': hydrate,
|
|
@@ -5612,7 +5673,7 @@ const listen = async () => {
|
|
|
5612
5673
|
const rpc = await WebWorkerRpcClient.create({
|
|
5613
5674
|
commandMap: commandMap
|
|
5614
5675
|
});
|
|
5615
|
-
set$
|
|
5676
|
+
set$5$1(RendererWorker, rpc);
|
|
5616
5677
|
};
|
|
5617
5678
|
|
|
5618
5679
|
const main = async () => {
|