@lvce-editor/extension-host-worker 3.1.0 → 3.3.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 +121 -74
- package/package.json +1 -1
|
@@ -761,7 +761,7 @@ const setConfigurations = preferences => {
|
|
|
761
761
|
const state$8 = {
|
|
762
762
|
rpc: undefined
|
|
763
763
|
};
|
|
764
|
-
const invoke$
|
|
764
|
+
const invoke$2 = (method, ...params) => {
|
|
765
765
|
const rpc = state$8.rpc;
|
|
766
766
|
return rpc.invoke(method, ...params);
|
|
767
767
|
};
|
|
@@ -937,7 +937,7 @@ const {
|
|
|
937
937
|
|
|
938
938
|
const showInformationMessage = message => {
|
|
939
939
|
string(message);
|
|
940
|
-
const result = invoke$
|
|
940
|
+
const result = invoke$2('ExtensionHostDialog.showInformationMessage', message);
|
|
941
941
|
return result;
|
|
942
942
|
};
|
|
943
943
|
|
|
@@ -992,7 +992,7 @@ const readFileExternal = async path => {
|
|
|
992
992
|
// this avoid parsing the potentially large message
|
|
993
993
|
// and improve performance by not blocking the renderer worker
|
|
994
994
|
// when reading / writing large files
|
|
995
|
-
const content = await invoke$
|
|
995
|
+
const content = await invoke$2('FileSystem.readFile', path);
|
|
996
996
|
return content;
|
|
997
997
|
};
|
|
998
998
|
const readDirWithFileTypesExternal = async path => {
|
|
@@ -1002,7 +1002,7 @@ const readDirWithFileTypesExternal = async path => {
|
|
|
1002
1002
|
// this avoid parsing the potentially large message
|
|
1003
1003
|
// and improve performance by not blocking the renderer worker
|
|
1004
1004
|
// when reading / writing large files
|
|
1005
|
-
const content = await invoke$
|
|
1005
|
+
const content = await invoke$2('FileSystem.readDirWithFileTypes', path);
|
|
1006
1006
|
return content;
|
|
1007
1007
|
};
|
|
1008
1008
|
const writeFile = async (protocol, uri, content) => {
|
|
@@ -1975,7 +1975,7 @@ const send = (transport, method, ...params) => {
|
|
|
1975
1975
|
const message = create$4$1(method, params);
|
|
1976
1976
|
transport.send(message);
|
|
1977
1977
|
};
|
|
1978
|
-
const invoke = (ipc, method, ...params) => {
|
|
1978
|
+
const invoke$1 = (ipc, method, ...params) => {
|
|
1979
1979
|
return invokeHelper(ipc, method, params, false);
|
|
1980
1980
|
};
|
|
1981
1981
|
const invokeAndTransfer = (ipc, method, ...params) => {
|
|
@@ -2008,7 +2008,7 @@ const createRpc$1 = ipc => {
|
|
|
2008
2008
|
send(ipc, method, ...params);
|
|
2009
2009
|
},
|
|
2010
2010
|
invoke(method, ...params) {
|
|
2011
|
-
return invoke(ipc, method, ...params);
|
|
2011
|
+
return invoke$1(ipc, method, ...params);
|
|
2012
2012
|
},
|
|
2013
2013
|
invokeAndTransfer(method, ...params) {
|
|
2014
2014
|
return invokeAndTransfer(ipc, method, ...params);
|
|
@@ -2332,7 +2332,7 @@ const createNodeRpc = async ({
|
|
|
2332
2332
|
|
|
2333
2333
|
const confirm = message => {
|
|
2334
2334
|
string(message);
|
|
2335
|
-
const result = invoke$
|
|
2335
|
+
const result = invoke$2('ConfirmPrompt.prompt', message);
|
|
2336
2336
|
return result;
|
|
2337
2337
|
};
|
|
2338
2338
|
|
|
@@ -2344,7 +2344,7 @@ const showQuickPick = async ({
|
|
|
2344
2344
|
}) => {
|
|
2345
2345
|
const rawPicks = await getPicks();
|
|
2346
2346
|
const picks = rawPicks.map(toPick);
|
|
2347
|
-
return invoke$
|
|
2347
|
+
return invoke$2(ExtensionHostQuickPickShow, picks);
|
|
2348
2348
|
};
|
|
2349
2349
|
|
|
2350
2350
|
const {
|
|
@@ -2404,7 +2404,7 @@ const extensionHostSubWorkerUrl = getExtensionHostSubWorkerUrl();
|
|
|
2404
2404
|
|
|
2405
2405
|
const set$2 = async (url, contentSecurityPolicy) => {
|
|
2406
2406
|
const pathName = new URL(url).pathname;
|
|
2407
|
-
await invoke$
|
|
2407
|
+
await invoke$2('ExtensionHostWorkerContentSecurityPolicy.set', pathName, contentSecurityPolicy);
|
|
2408
2408
|
};
|
|
2409
2409
|
|
|
2410
2410
|
/**
|
|
@@ -2769,7 +2769,7 @@ const getRemoteUrlForWebView = async (uri, options = {}) => {
|
|
|
2769
2769
|
if (!webView) {
|
|
2770
2770
|
throw new Error(`webview ${options.webViewId} not found`);
|
|
2771
2771
|
}
|
|
2772
|
-
const [rpc, blob] = await Promise.all([createWebViewIpc(webView), invoke$
|
|
2772
|
+
const [rpc, blob] = await Promise.all([createWebViewIpc(webView), invoke$2('FileSystem.getBlob', uri)]);
|
|
2773
2773
|
const objectUrl = await rpc.invoke('createObjectUrl', blob);
|
|
2774
2774
|
return objectUrl;
|
|
2775
2775
|
};
|
|
@@ -2794,7 +2794,7 @@ const getRemoteUrl = async (uri, options = {}) => {
|
|
|
2794
2794
|
return getRemoteUrlForWebView(uri, options);
|
|
2795
2795
|
}
|
|
2796
2796
|
if (uri.startsWith('html://')) {
|
|
2797
|
-
const url = await invoke$
|
|
2797
|
+
const url = await invoke$2('Blob.getSrc', uri);
|
|
2798
2798
|
return url;
|
|
2799
2799
|
}
|
|
2800
2800
|
throw new Error(`unsupported platform for remote url`);
|
|
@@ -2837,6 +2837,9 @@ const registerWebViewProvider = provider => {
|
|
|
2837
2837
|
};
|
|
2838
2838
|
const getWebViewInfo = providerId => {
|
|
2839
2839
|
const webView = getWebView(providerId);
|
|
2840
|
+
if (!webView) {
|
|
2841
|
+
throw new Error(`Webview not found: ${providerId}`);
|
|
2842
|
+
}
|
|
2840
2843
|
return {
|
|
2841
2844
|
uid: webView.uid,
|
|
2842
2845
|
origin: webView.origin,
|
|
@@ -3071,6 +3074,97 @@ const setup = ({
|
|
|
3071
3074
|
global.vscode = api;
|
|
3072
3075
|
};
|
|
3073
3076
|
|
|
3077
|
+
const getAssetDir = () => {
|
|
3078
|
+
// @ts-ignore
|
|
3079
|
+
if (typeof ASSET_DIR !== 'undefined') {
|
|
3080
|
+
// @ts-ignore
|
|
3081
|
+
return ASSET_DIR;
|
|
3082
|
+
}
|
|
3083
|
+
if (platform === Electron) {
|
|
3084
|
+
return '../../../../..';
|
|
3085
|
+
}
|
|
3086
|
+
return '';
|
|
3087
|
+
};
|
|
3088
|
+
const assetDir = getAssetDir();
|
|
3089
|
+
|
|
3090
|
+
const iframeWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/iframe-worker/dist/iframeWorkerMain.js`;
|
|
3091
|
+
|
|
3092
|
+
const get$1 = key => {
|
|
3093
|
+
return invoke$2('Preferences.get', key);
|
|
3094
|
+
};
|
|
3095
|
+
|
|
3096
|
+
const getConfiguredIframeWorkerUrl = async () => {
|
|
3097
|
+
let configuredWorkerUrl = (await get$1('develop.iframeWorkerPath')) || '';
|
|
3098
|
+
if (configuredWorkerUrl) {
|
|
3099
|
+
configuredWorkerUrl = '/remote' + configuredWorkerUrl;
|
|
3100
|
+
}
|
|
3101
|
+
configuredWorkerUrl = configuredWorkerUrl || iframeWorkerUrl;
|
|
3102
|
+
return configuredWorkerUrl;
|
|
3103
|
+
};
|
|
3104
|
+
|
|
3105
|
+
const state$2 = {
|
|
3106
|
+
id: 0
|
|
3107
|
+
};
|
|
3108
|
+
const create$1 = () => {
|
|
3109
|
+
return ++state$2.id;
|
|
3110
|
+
};
|
|
3111
|
+
|
|
3112
|
+
const commandMap$1 = {
|
|
3113
|
+
'WebView.compatExtensionHostWorkerInvoke': (...args) => invoke$2('WebView.compatExtensionHostWorkerInvoke', ...args),
|
|
3114
|
+
'WebView.compatExtensionHostWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatExtensionHostWorkerInvokeAndTransfer', ...args),
|
|
3115
|
+
'WebView.compatRendererProcessInvoke': (...args) => invoke$2('WebView.compatRendererProcessInvoke', ...args),
|
|
3116
|
+
'WebView.compatRendererProcessInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatRendererProcessInvokeAndTransfer', ...args),
|
|
3117
|
+
'WebView.compatSharedProcessInvoke': (...args) => invoke$2('WebView.compatSharedProcessInvoke', ...args),
|
|
3118
|
+
'WebView.getSavedState': (...args) => invoke$2('WebView.getSavedState', ...args),
|
|
3119
|
+
'WebView.getWebViewInfo': (...args) => invoke$2('WebView.getWebViewInfo', ...args),
|
|
3120
|
+
'WebView.getWebViews': (...args) => invoke$2('WebView.getWebViews', ...args),
|
|
3121
|
+
'WebView.setPort': (...args) => invoke$2('WebView.setPort', ...args),
|
|
3122
|
+
'ExtensionHostManagement.activateByEvent': (...args) => invoke$2('ExtensionHostManagement.activateByEvent', ...args)
|
|
3123
|
+
};
|
|
3124
|
+
const launchIframeWorker = async () => {
|
|
3125
|
+
const configuredWorkerUrl = await getConfiguredIframeWorkerUrl();
|
|
3126
|
+
const name = 'Iframe Worker';
|
|
3127
|
+
const id = create$1();
|
|
3128
|
+
const rpc = await create$2({
|
|
3129
|
+
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
3130
|
+
name,
|
|
3131
|
+
url: configuredWorkerUrl,
|
|
3132
|
+
id,
|
|
3133
|
+
commandMap: commandMap$1
|
|
3134
|
+
});
|
|
3135
|
+
return rpc;
|
|
3136
|
+
};
|
|
3137
|
+
|
|
3138
|
+
let workerPromise;
|
|
3139
|
+
const ensureWorker = () => {
|
|
3140
|
+
if (!workerPromise) {
|
|
3141
|
+
workerPromise = launchIframeWorker();
|
|
3142
|
+
}
|
|
3143
|
+
return workerPromise;
|
|
3144
|
+
};
|
|
3145
|
+
const invoke = async (method, ...params) => {
|
|
3146
|
+
const rpc = await ensureWorker();
|
|
3147
|
+
return rpc.invoke(method, ...params);
|
|
3148
|
+
};
|
|
3149
|
+
|
|
3150
|
+
const createWebView3 = async ({
|
|
3151
|
+
id,
|
|
3152
|
+
uri,
|
|
3153
|
+
isGitpod,
|
|
3154
|
+
platform,
|
|
3155
|
+
assetDir,
|
|
3156
|
+
webViewScheme
|
|
3157
|
+
}) => {
|
|
3158
|
+
await invoke('WebView.create3', {
|
|
3159
|
+
id,
|
|
3160
|
+
uri,
|
|
3161
|
+
isGitpod,
|
|
3162
|
+
platform,
|
|
3163
|
+
assetDir,
|
|
3164
|
+
webViewScheme
|
|
3165
|
+
});
|
|
3166
|
+
};
|
|
3167
|
+
|
|
3074
3168
|
const BraceCompletionExecuteBraceCompletionProvider = 'ExtensionHostBraceCompletion.executeBraceCompletionProvider';
|
|
3075
3169
|
const ClosingTagExecuteClosingTagProvider = 'ExtensionHostClosingTag.executeClosingTagProvider';
|
|
3076
3170
|
const CommandExecute = 'ExtensionHostCommand.executeCommand';
|
|
@@ -3110,7 +3204,7 @@ const WorkspaceSetPath = 'Workspace.setWorkspacePath';
|
|
|
3110
3204
|
const SelectionExecuteSelectionProvider = 'ExtensionHostSelection.executeSelectionProvider';
|
|
3111
3205
|
const ConfigurationSetConfiguration = 'ExtensionHostConfiguration.setConfiguration';
|
|
3112
3206
|
|
|
3113
|
-
const create
|
|
3207
|
+
const create = () => {
|
|
3114
3208
|
return {
|
|
3115
3209
|
finished: false
|
|
3116
3210
|
};
|
|
@@ -3232,19 +3326,6 @@ class BabelParseError extends SyntaxError {
|
|
|
3232
3326
|
}
|
|
3233
3327
|
}
|
|
3234
3328
|
|
|
3235
|
-
const getAssetDir = () => {
|
|
3236
|
-
// @ts-ignore
|
|
3237
|
-
if (typeof ASSET_DIR !== 'undefined') {
|
|
3238
|
-
// @ts-ignore
|
|
3239
|
-
return ASSET_DIR;
|
|
3240
|
-
}
|
|
3241
|
-
if (platform === Electron) {
|
|
3242
|
-
return '../../../../..';
|
|
3243
|
-
}
|
|
3244
|
-
return '';
|
|
3245
|
-
};
|
|
3246
|
-
const assetDir = getAssetDir();
|
|
3247
|
-
|
|
3248
3329
|
const loadBabelParser = () => {
|
|
3249
3330
|
const url = `${assetDir}/js/babel-parser.js`;
|
|
3250
3331
|
return import(url);
|
|
@@ -3535,7 +3616,7 @@ const activate = async (extension, absolutePath) => {
|
|
|
3535
3616
|
string(absolutePath);
|
|
3536
3617
|
const module = await importScript(absolutePath);
|
|
3537
3618
|
handleRpcInfos(extension);
|
|
3538
|
-
const token = create
|
|
3619
|
+
const token = create();
|
|
3539
3620
|
try {
|
|
3540
3621
|
await Promise.race([module.activate(extension), rejectAfterTimeout(activationTimeout, token)]);
|
|
3541
3622
|
} catch (error) {
|
|
@@ -3571,7 +3652,7 @@ const mockExec = () => {
|
|
|
3571
3652
|
try {
|
|
3572
3653
|
// @ts-ignore
|
|
3573
3654
|
api.exec = async (command, args, options) => {
|
|
3574
|
-
const result = await invoke$
|
|
3655
|
+
const result = await invoke$2('Test.executeMockExecFunction', command, args, options);
|
|
3575
3656
|
const {
|
|
3576
3657
|
stdout,
|
|
3577
3658
|
stderr,
|
|
@@ -3597,7 +3678,7 @@ const mockRpc = () => {
|
|
|
3597
3678
|
try {
|
|
3598
3679
|
return {
|
|
3599
3680
|
async invoke(method, ...params) {
|
|
3600
|
-
const result = await invoke$
|
|
3681
|
+
const result = await invoke$2('Test.executeMockRpcFunction', options.name, method, ...params);
|
|
3601
3682
|
return result;
|
|
3602
3683
|
}
|
|
3603
3684
|
};
|
|
@@ -3890,7 +3971,7 @@ replaceTraps(oldTraps => ({
|
|
|
3890
3971
|
}
|
|
3891
3972
|
}));
|
|
3892
3973
|
|
|
3893
|
-
const state$
|
|
3974
|
+
const state$1 = {
|
|
3894
3975
|
databases: Object.create(null),
|
|
3895
3976
|
eventId: 0,
|
|
3896
3977
|
dbVersion: 1,
|
|
@@ -3908,7 +3989,7 @@ const isDataCloneError = error => {
|
|
|
3908
3989
|
|
|
3909
3990
|
const getDb$1 = async () => {
|
|
3910
3991
|
// @ts-ignore
|
|
3911
|
-
const db = await openDB('session', state$
|
|
3992
|
+
const db = await openDB('session', state$1.dbVersion, {
|
|
3912
3993
|
async upgrade(db, oldVersion) {
|
|
3913
3994
|
if (!db.objectStoreNames.contains('session')) {
|
|
3914
3995
|
const objectStore = await db.createObjectStore('session', {
|
|
@@ -3923,8 +4004,8 @@ const getDb$1 = async () => {
|
|
|
3923
4004
|
return db;
|
|
3924
4005
|
};
|
|
3925
4006
|
const getDbMemoized$1 = async () => {
|
|
3926
|
-
state$
|
|
3927
|
-
return state$
|
|
4007
|
+
state$1.cachedDb ||= await getDb$1();
|
|
4008
|
+
return state$1.cachedDb;
|
|
3928
4009
|
};
|
|
3929
4010
|
const saveValue = async (storeId, value) => {
|
|
3930
4011
|
try {
|
|
@@ -3963,7 +4044,7 @@ const getValuesByIndexName = async (storeId, indexName, only) => {
|
|
|
3963
4044
|
return objects;
|
|
3964
4045
|
};
|
|
3965
4046
|
const getHandleDb = async () => {
|
|
3966
|
-
const db = await openDB('handle', state$
|
|
4047
|
+
const db = await openDB('handle', state$1.dbVersion, {
|
|
3967
4048
|
async upgrade(db, oldVersion) {
|
|
3968
4049
|
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
3969
4050
|
// @ts-ignore
|
|
@@ -3987,13 +4068,13 @@ const storeId = 'lvce-keyvalue';
|
|
|
3987
4068
|
|
|
3988
4069
|
// TODO high memory usage in idb because of transactionDoneMap
|
|
3989
4070
|
|
|
3990
|
-
const state
|
|
4071
|
+
const state = {
|
|
3991
4072
|
databases: Object.create(null),
|
|
3992
4073
|
dbVersion: 2,
|
|
3993
4074
|
cachedDb: undefined
|
|
3994
4075
|
};
|
|
3995
4076
|
const getDb = async () => {
|
|
3996
|
-
const db = await openDB(storeId, state
|
|
4077
|
+
const db = await openDB(storeId, state.dbVersion, {
|
|
3997
4078
|
async upgrade(db, oldVersion) {
|
|
3998
4079
|
if (!db.objectStoreNames.contains(storeId)) {
|
|
3999
4080
|
await db.createObjectStore(storeId, {
|
|
@@ -4005,8 +4086,8 @@ const getDb = async () => {
|
|
|
4005
4086
|
return db;
|
|
4006
4087
|
};
|
|
4007
4088
|
const getDbMemoized = async () => {
|
|
4008
|
-
state
|
|
4009
|
-
return state
|
|
4089
|
+
state.cachedDb ||= await getDb();
|
|
4090
|
+
return state.cachedDb;
|
|
4010
4091
|
};
|
|
4011
4092
|
|
|
4012
4093
|
// TODO high memory usage in idb because of transactionDoneMap
|
|
@@ -4019,7 +4100,7 @@ const set = async (key, value) => {
|
|
|
4019
4100
|
throw new VError(error, 'Failed to save value to indexed db');
|
|
4020
4101
|
}
|
|
4021
4102
|
};
|
|
4022
|
-
const get
|
|
4103
|
+
const get = async key => {
|
|
4023
4104
|
try {
|
|
4024
4105
|
const db = await getDbMemoized();
|
|
4025
4106
|
const value = await db.get(storeId, key);
|
|
@@ -4029,41 +4110,6 @@ const get$1 = async key => {
|
|
|
4029
4110
|
}
|
|
4030
4111
|
};
|
|
4031
4112
|
|
|
4032
|
-
const iframeWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/iframe-worker/dist/iframeWorkerMain.js`;
|
|
4033
|
-
|
|
4034
|
-
const get = key => {
|
|
4035
|
-
return invoke$1('Preferences.get', key);
|
|
4036
|
-
};
|
|
4037
|
-
|
|
4038
|
-
const getConfiguredIframeWorkerUrl = async () => {
|
|
4039
|
-
let configuredWorkerUrl = (await get('develop.iframeWorkerPath')) || '';
|
|
4040
|
-
if (configuredWorkerUrl) {
|
|
4041
|
-
configuredWorkerUrl = '/remote' + configuredWorkerUrl;
|
|
4042
|
-
}
|
|
4043
|
-
configuredWorkerUrl = configuredWorkerUrl || iframeWorkerUrl;
|
|
4044
|
-
return configuredWorkerUrl;
|
|
4045
|
-
};
|
|
4046
|
-
|
|
4047
|
-
const state = {
|
|
4048
|
-
id: 0
|
|
4049
|
-
};
|
|
4050
|
-
const create = () => {
|
|
4051
|
-
return ++state.id;
|
|
4052
|
-
};
|
|
4053
|
-
|
|
4054
|
-
const launchIframeWorker = async () => {
|
|
4055
|
-
const configuredWorkerUrl = getConfiguredIframeWorkerUrl();
|
|
4056
|
-
const name = 'Iframe Worker';
|
|
4057
|
-
const id = create();
|
|
4058
|
-
const rpc = await create$2({
|
|
4059
|
-
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
4060
|
-
name,
|
|
4061
|
-
url: configuredWorkerUrl,
|
|
4062
|
-
id
|
|
4063
|
-
});
|
|
4064
|
-
return rpc;
|
|
4065
|
-
};
|
|
4066
|
-
|
|
4067
4113
|
const loadWebView = async (providerId, savedState) => {
|
|
4068
4114
|
const rpc = getWebView(providerId);
|
|
4069
4115
|
await rpc.provider.create(rpc, rpc.uri, savedState);
|
|
@@ -4379,11 +4425,12 @@ const textSearch = async (scheme, root, query) => {
|
|
|
4379
4425
|
};
|
|
4380
4426
|
|
|
4381
4427
|
const commandMap = {
|
|
4428
|
+
'WebView.create3': createWebView3,
|
|
4382
4429
|
'ExtensionHost.launchIframeWorker': launchIframeWorker,
|
|
4383
4430
|
'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
|
|
4384
4431
|
'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
|
|
4385
4432
|
'IndexedDb.addHandle': addHandle,
|
|
4386
|
-
'IndexedDb.get': get
|
|
4433
|
+
'IndexedDb.get': get,
|
|
4387
4434
|
'IndexedDb.getHandle': getHandle$1,
|
|
4388
4435
|
'IndexedDb.getValues': getValues,
|
|
4389
4436
|
'IndexedDb.getValuesByIndexName': getValuesByIndexName,
|
package/package.json
CHANGED