@lvce-editor/extension-management-worker 4.83.3 → 4.85.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.
|
@@ -79,7 +79,7 @@ const get$7 = applicationId => {
|
|
|
79
79
|
}
|
|
80
80
|
return state$4.extensionsState;
|
|
81
81
|
};
|
|
82
|
-
const set$
|
|
82
|
+
const set$e = newState => {
|
|
83
83
|
if (newState.applicationId !== undefined) {
|
|
84
84
|
const currentState = get$7(newState.applicationId);
|
|
85
85
|
if (newState.applicationGeneration !== currentState.applicationGeneration) {
|
|
@@ -97,7 +97,7 @@ const update = (newState, applicationId) => {
|
|
|
97
97
|
throw new Error('Cannot change extension application identity');
|
|
98
98
|
}
|
|
99
99
|
const current = get$7(applicationId);
|
|
100
|
-
set$
|
|
100
|
+
set$e({
|
|
101
101
|
...current,
|
|
102
102
|
...newState
|
|
103
103
|
});
|
|
@@ -921,6 +921,9 @@ const restoreExistingError = (error, currentStack) => {
|
|
|
921
921
|
};
|
|
922
922
|
const restoreMethodNotFoundError = (error, currentStack) => {
|
|
923
923
|
const restoredError = new JsonRpcError(error.message);
|
|
924
|
+
Object.assign(restoredError, {
|
|
925
|
+
code: error.code
|
|
926
|
+
});
|
|
924
927
|
const parentStack = getParentStack(error);
|
|
925
928
|
setStack(restoredError, `${parentStack}${NewLine$1}${currentStack}`);
|
|
926
929
|
return restoredError;
|
|
@@ -940,9 +943,13 @@ const applyDataProperties = (restoredError, error) => {
|
|
|
940
943
|
// @ts-ignore
|
|
941
944
|
restoredError.codeFrame = error.data.codeFrame;
|
|
942
945
|
}
|
|
943
|
-
if (error.data.code) {
|
|
946
|
+
if (typeof error.data.code === 'string' || typeof error.data.code === 'number') {
|
|
944
947
|
// @ts-ignore
|
|
945
|
-
restoredError
|
|
948
|
+
Object.defineProperty(restoredError, 'code', {
|
|
949
|
+
configurable: true,
|
|
950
|
+
value: error.data.code,
|
|
951
|
+
writable: true
|
|
952
|
+
});
|
|
946
953
|
}
|
|
947
954
|
if (error.data.type) {
|
|
948
955
|
// @ts-ignore
|
|
@@ -963,7 +970,14 @@ const applyDirectProperties = (restoredError, error) => {
|
|
|
963
970
|
}
|
|
964
971
|
};
|
|
965
972
|
const restoreMessageError = (error, _currentStack) => {
|
|
966
|
-
const restoredError = constructError(error.message, error.type, error.name);
|
|
973
|
+
const restoredError = constructError(error.message, error.type || error.data?.type, error.name);
|
|
974
|
+
if (typeof error.code === 'string' || typeof error.code === 'number') {
|
|
975
|
+
Object.defineProperty(restoredError, 'code', {
|
|
976
|
+
configurable: true,
|
|
977
|
+
value: error.code,
|
|
978
|
+
writable: true
|
|
979
|
+
});
|
|
980
|
+
}
|
|
967
981
|
if (error.data) {
|
|
968
982
|
applyDataProperties(restoredError, error);
|
|
969
983
|
} else {
|
|
@@ -971,6 +985,23 @@ const restoreMessageError = (error, _currentStack) => {
|
|
|
971
985
|
}
|
|
972
986
|
return restoredError;
|
|
973
987
|
};
|
|
988
|
+
const getFallbackMessage = error => {
|
|
989
|
+
if (error && typeof error.message === 'string' && error.message) {
|
|
990
|
+
return error.message;
|
|
991
|
+
}
|
|
992
|
+
if (error && error.data) {
|
|
993
|
+
return getFallbackMessage(error.data);
|
|
994
|
+
}
|
|
995
|
+
const stringified = String(error);
|
|
996
|
+
if (stringified !== '[object Object]') {
|
|
997
|
+
return stringified;
|
|
998
|
+
}
|
|
999
|
+
try {
|
|
1000
|
+
return JSON.stringify(error);
|
|
1001
|
+
} catch {
|
|
1002
|
+
return stringified;
|
|
1003
|
+
}
|
|
1004
|
+
};
|
|
974
1005
|
const restoreJsonRpcError = error => {
|
|
975
1006
|
const currentStack = getCurrentStack();
|
|
976
1007
|
if (error && error instanceof Error) {
|
|
@@ -979,13 +1010,13 @@ const restoreJsonRpcError = error => {
|
|
|
979
1010
|
if (error && error.code && error.code === MethodNotFound) {
|
|
980
1011
|
return restoreMethodNotFoundError(error, currentStack);
|
|
981
1012
|
}
|
|
1013
|
+
if (error && error.error) {
|
|
1014
|
+
return restoreJsonRpcError(error.error);
|
|
1015
|
+
}
|
|
982
1016
|
if (error && error.message) {
|
|
983
1017
|
return restoreMessageError(error);
|
|
984
1018
|
}
|
|
985
|
-
|
|
986
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
987
|
-
}
|
|
988
|
-
return new Error(`JsonRpc Error: ${error}`);
|
|
1019
|
+
return new Error(`JsonRpc Error: ${getFallbackMessage(error)}`);
|
|
989
1020
|
};
|
|
990
1021
|
const unwrapJsonRpcResult = responseMessage => {
|
|
991
1022
|
if ('error' in responseMessage) {
|
|
@@ -1042,9 +1073,9 @@ const getErrorProperty = (error, prettyError) => {
|
|
|
1042
1073
|
return {
|
|
1043
1074
|
code: Custom,
|
|
1044
1075
|
data: {
|
|
1045
|
-
code: prettyError.code,
|
|
1076
|
+
code: prettyError.code ?? error?.code,
|
|
1046
1077
|
codeFrame: prettyError.codeFrame,
|
|
1047
|
-
name: prettyError.name,
|
|
1078
|
+
name: prettyError.name ?? error?.name,
|
|
1048
1079
|
stack: getStack(prettyError),
|
|
1049
1080
|
type: getErrorType(prettyError)
|
|
1050
1081
|
},
|
|
@@ -1079,7 +1110,12 @@ const getErrorResponseSimple = (id, error) => {
|
|
|
1079
1110
|
return {
|
|
1080
1111
|
error: {
|
|
1081
1112
|
code: Custom,
|
|
1082
|
-
data: error
|
|
1113
|
+
data: error instanceof Error ? {
|
|
1114
|
+
...error,
|
|
1115
|
+
code: 'code' in error ? error.code : undefined,
|
|
1116
|
+
stack: error.stack,
|
|
1117
|
+
type: error.name
|
|
1118
|
+
} : error,
|
|
1083
1119
|
// @ts-ignore
|
|
1084
1120
|
message: error.message
|
|
1085
1121
|
},
|
|
@@ -1518,7 +1554,7 @@ const RendererWorker = 1;
|
|
|
1518
1554
|
const SharedProcess = 1492;
|
|
1519
1555
|
|
|
1520
1556
|
const rpcs$2 = Object.create(null);
|
|
1521
|
-
const set$
|
|
1557
|
+
const set$d = (id, rpc) => {
|
|
1522
1558
|
rpcs$2[id] = rpc;
|
|
1523
1559
|
};
|
|
1524
1560
|
const get$5 = id => {
|
|
@@ -1551,7 +1587,7 @@ const create = rpcId => {
|
|
|
1551
1587
|
const mockRpc = createMockRpc({
|
|
1552
1588
|
commandMap
|
|
1553
1589
|
});
|
|
1554
|
-
set$
|
|
1590
|
+
set$d(rpcId, mockRpc);
|
|
1555
1591
|
// @ts-ignore
|
|
1556
1592
|
mockRpc[Symbol.dispose] = () => {
|
|
1557
1593
|
remove$2(rpcId);
|
|
@@ -1560,15 +1596,29 @@ const create = rpcId => {
|
|
|
1560
1596
|
return mockRpc;
|
|
1561
1597
|
},
|
|
1562
1598
|
set(rpc) {
|
|
1563
|
-
set$
|
|
1599
|
+
set$d(rpcId, rpc);
|
|
1564
1600
|
}
|
|
1565
1601
|
};
|
|
1566
1602
|
};
|
|
1567
1603
|
|
|
1604
|
+
const {
|
|
1605
|
+
invoke: invoke$9,
|
|
1606
|
+
set: set$c
|
|
1607
|
+
} = create(6010);
|
|
1608
|
+
|
|
1568
1609
|
const {
|
|
1569
1610
|
invoke: invoke$8,
|
|
1570
1611
|
set: set$b
|
|
1571
|
-
} = create(
|
|
1612
|
+
} = create(19_001);
|
|
1613
|
+
const getCacheStorageItem = async (request, cacheName, bucketName, bucketOptions) => {
|
|
1614
|
+
return invoke$8('Cache.getCacheStorageItem', request, cacheName, bucketName, bucketOptions);
|
|
1615
|
+
};
|
|
1616
|
+
const removeCacheStorageItem = async (request, cacheName, bucketName, bucketOptions) => {
|
|
1617
|
+
return invoke$8('Cache.removeCacheStorageItem', request, cacheName, bucketName, bucketOptions);
|
|
1618
|
+
};
|
|
1619
|
+
const setCacheStorageItem = async (request, value, cacheName, headers, bucketName, bucketOptions) => {
|
|
1620
|
+
return invoke$8('Cache.setCacheStorageItem', request, value, cacheName, headers, bucketName, bucketOptions);
|
|
1621
|
+
};
|
|
1572
1622
|
|
|
1573
1623
|
const {
|
|
1574
1624
|
invoke: invoke$7,
|
|
@@ -1668,20 +1718,22 @@ const createResponseFromData = data => {
|
|
|
1668
1718
|
const cacheName$1 = 'Extensions'; // TODO
|
|
1669
1719
|
|
|
1670
1720
|
const getJson$1 = async cacheKey => {
|
|
1671
|
-
const
|
|
1672
|
-
|
|
1673
|
-
});
|
|
1674
|
-
if (!response) {
|
|
1721
|
+
const item = await getCacheStorageItem(cacheKey, cacheName$1);
|
|
1722
|
+
if (!item) {
|
|
1675
1723
|
return undefined;
|
|
1676
1724
|
}
|
|
1677
|
-
const
|
|
1678
|
-
|
|
1725
|
+
const body = item.body;
|
|
1726
|
+
const json = typeof body === 'string' ? body : new TextDecoder().decode(body);
|
|
1727
|
+
return JSON.parse(json);
|
|
1679
1728
|
};
|
|
1680
1729
|
const setJson = async (cacheKey, data) => {
|
|
1681
1730
|
try {
|
|
1682
|
-
const cache = await caches.open(cacheName$1);
|
|
1683
1731
|
const response = createResponseFromData(data);
|
|
1684
|
-
|
|
1732
|
+
const headers = Object.fromEntries(response.headers.entries());
|
|
1733
|
+
const result = await setCacheStorageItem(cacheKey, await response.arrayBuffer(), cacheName$1, headers);
|
|
1734
|
+
if (!result.success) {
|
|
1735
|
+
throw new Error(result.errorMessage);
|
|
1736
|
+
}
|
|
1685
1737
|
} catch (error) {
|
|
1686
1738
|
throw new VError(error, `Failed to add to cache`);
|
|
1687
1739
|
}
|
|
@@ -2918,8 +2970,7 @@ const deleteSecret = async (extensionId, key) => {
|
|
|
2918
2970
|
await invoke$5('SecretStorage.delete', extensionId, key);
|
|
2919
2971
|
return;
|
|
2920
2972
|
}
|
|
2921
|
-
|
|
2922
|
-
await cache.delete(getRequestUrl(extensionId, key));
|
|
2973
|
+
await removeCacheStorageItem(getRequestUrl(extensionId, key), cacheName);
|
|
2923
2974
|
};
|
|
2924
2975
|
const getSecret = async (extensionId, key) => {
|
|
2925
2976
|
string(extensionId);
|
|
@@ -2927,9 +2978,12 @@ const getSecret = async (extensionId, key) => {
|
|
|
2927
2978
|
if (isElectron()) {
|
|
2928
2979
|
return invoke$5('SecretStorage.get', extensionId, key);
|
|
2929
2980
|
}
|
|
2930
|
-
const
|
|
2931
|
-
|
|
2932
|
-
|
|
2981
|
+
const item = await getCacheStorageItem(getRequestUrl(extensionId, key), cacheName);
|
|
2982
|
+
if (!item) {
|
|
2983
|
+
return undefined;
|
|
2984
|
+
}
|
|
2985
|
+
const body = item.body;
|
|
2986
|
+
return typeof body === 'string' ? body : new TextDecoder().decode(body);
|
|
2933
2987
|
};
|
|
2934
2988
|
const storeSecret = async (extensionId, key, value) => {
|
|
2935
2989
|
string(extensionId);
|
|
@@ -2939,8 +2993,10 @@ const storeSecret = async (extensionId, key, value) => {
|
|
|
2939
2993
|
await invoke$5('SecretStorage.store', extensionId, key, value);
|
|
2940
2994
|
return;
|
|
2941
2995
|
}
|
|
2942
|
-
const
|
|
2943
|
-
|
|
2996
|
+
const result = await setCacheStorageItem(getRequestUrl(extensionId, key), value, cacheName);
|
|
2997
|
+
if (!result.success) {
|
|
2998
|
+
throw new Error(result.errorMessage);
|
|
2999
|
+
}
|
|
2944
3000
|
};
|
|
2945
3001
|
|
|
2946
3002
|
class CommandNotFoundError extends Error {
|
|
@@ -3491,7 +3547,7 @@ const disableExtension2$1 = async (id, platform) => {
|
|
|
3491
3547
|
...oldState,
|
|
3492
3548
|
disabledIds: [...oldState.disabledIds, id]
|
|
3493
3549
|
};
|
|
3494
|
-
set$
|
|
3550
|
+
set$e(newState);
|
|
3495
3551
|
} else if (isWeb) {
|
|
3496
3552
|
const cached = await getJson$1(disabledExtensionsCacheKey);
|
|
3497
3553
|
const oldDisabled = getStringArray(cached?.disabledExtensions);
|
|
@@ -3516,7 +3572,7 @@ const enableExtension2$1 = async (id, platform) => {
|
|
|
3516
3572
|
...oldState,
|
|
3517
3573
|
disabledIds: oldState.disabledIds.filter(existing => existing !== id)
|
|
3518
3574
|
};
|
|
3519
|
-
set$
|
|
3575
|
+
set$e(newState);
|
|
3520
3576
|
} else if (isWeb) {
|
|
3521
3577
|
const cached = await getJson$1(disabledExtensionsCacheKey);
|
|
3522
3578
|
const oldDisabled = getStringArray(cached?.disabledExtensions);
|
|
@@ -3943,14 +3999,20 @@ const executeExtensionDiagnosticProvider = async (rpc, extension, textDocument,
|
|
|
3943
3999
|
const executeMatchingDiagnosticProvider = async (extension, textDocument, args, assetDir, platform, resultPort, providerIndex) => {
|
|
3944
4000
|
const providerId = extension.id ?? extension.uri ?? extension.path ?? String(providerIndex);
|
|
3945
4001
|
let diagnostics = [];
|
|
4002
|
+
let providerError;
|
|
3946
4003
|
try {
|
|
3947
4004
|
const rpc = await getRpc$1(extension, assetDir, platform, `onDiagnostic:${textDocument.languageId}`);
|
|
3948
4005
|
diagnostics = await executeExtensionDiagnosticProvider(rpc, extension, textDocument, args);
|
|
3949
|
-
} catch {
|
|
3950
|
-
//
|
|
4006
|
+
} catch (error) {
|
|
4007
|
+
// Preserve failure information for callers waiting for a successful diagnostics pass.
|
|
4008
|
+
// Other providers still deliver their results.
|
|
4009
|
+
providerError = error instanceof Error ? error.message : String(error);
|
|
3951
4010
|
}
|
|
3952
4011
|
resultPort?.postMessage({
|
|
3953
4012
|
diagnostics,
|
|
4013
|
+
...(providerError !== undefined && {
|
|
4014
|
+
error: providerError
|
|
4015
|
+
}),
|
|
3954
4016
|
providerId,
|
|
3955
4017
|
providerIndex,
|
|
3956
4018
|
type: 'result'
|
|
@@ -5155,7 +5217,7 @@ const saveViewInstanceState = async (viewId, uid, assetDir, platform) => {
|
|
|
5155
5217
|
};
|
|
5156
5218
|
|
|
5157
5219
|
const getAccessToken = (options = {}) => {
|
|
5158
|
-
return invoke$
|
|
5220
|
+
return invoke$9('Auth.getAccessToken', options);
|
|
5159
5221
|
};
|
|
5160
5222
|
|
|
5161
5223
|
const transparent = (color, factor) => {
|
|
@@ -6470,6 +6532,16 @@ const initializeAuthWorker = async () => {
|
|
|
6470
6532
|
await sendMessagePortToAuthWorker(port, 0);
|
|
6471
6533
|
}
|
|
6472
6534
|
});
|
|
6535
|
+
set$c(rpc);
|
|
6536
|
+
};
|
|
6537
|
+
|
|
6538
|
+
const initializeCacheWorker = async () => {
|
|
6539
|
+
const rpc = await create$5({
|
|
6540
|
+
commandMap: commandMapRef,
|
|
6541
|
+
async send(port) {
|
|
6542
|
+
await invokeAndTransfer$1('SendMessagePortToExtensionHostWorker.sendMessagePortToCacheWorker', port);
|
|
6543
|
+
}
|
|
6544
|
+
});
|
|
6473
6545
|
set$b(rpc);
|
|
6474
6546
|
};
|
|
6475
6547
|
|
|
@@ -6512,7 +6584,7 @@ const initializeRendererWorker = async () => {
|
|
|
6512
6584
|
|
|
6513
6585
|
const listen = async () => {
|
|
6514
6586
|
Object.assign(commandMapRef, commandMap);
|
|
6515
|
-
await Promise.all([initializeRendererWorker(), initializeAuthWorker(), initializeErrorWorker(), initializeFileSystemWorker(), initializeIframeWorker()]);
|
|
6587
|
+
await Promise.all([initializeRendererWorker(), initializeAuthWorker(), initializeCacheWorker(), initializeErrorWorker(), initializeFileSystemWorker(), initializeIframeWorker()]);
|
|
6516
6588
|
};
|
|
6517
6589
|
|
|
6518
6590
|
const main = async () => {
|