@lvce-editor/extension-host-worker 3.1.0 → 3.2.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 +118 -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`);
|
|
@@ -3071,6 +3071,97 @@ const setup = ({
|
|
|
3071
3071
|
global.vscode = api;
|
|
3072
3072
|
};
|
|
3073
3073
|
|
|
3074
|
+
const getAssetDir = () => {
|
|
3075
|
+
// @ts-ignore
|
|
3076
|
+
if (typeof ASSET_DIR !== 'undefined') {
|
|
3077
|
+
// @ts-ignore
|
|
3078
|
+
return ASSET_DIR;
|
|
3079
|
+
}
|
|
3080
|
+
if (platform === Electron) {
|
|
3081
|
+
return '../../../../..';
|
|
3082
|
+
}
|
|
3083
|
+
return '';
|
|
3084
|
+
};
|
|
3085
|
+
const assetDir = getAssetDir();
|
|
3086
|
+
|
|
3087
|
+
const iframeWorkerUrl = `${assetDir}/packages/renderer-worker/node_modules/@lvce-editor/iframe-worker/dist/iframeWorkerMain.js`;
|
|
3088
|
+
|
|
3089
|
+
const get$1 = key => {
|
|
3090
|
+
return invoke$2('Preferences.get', key);
|
|
3091
|
+
};
|
|
3092
|
+
|
|
3093
|
+
const getConfiguredIframeWorkerUrl = async () => {
|
|
3094
|
+
let configuredWorkerUrl = (await get$1('develop.iframeWorkerPath')) || '';
|
|
3095
|
+
if (configuredWorkerUrl) {
|
|
3096
|
+
configuredWorkerUrl = '/remote' + configuredWorkerUrl;
|
|
3097
|
+
}
|
|
3098
|
+
configuredWorkerUrl = configuredWorkerUrl || iframeWorkerUrl;
|
|
3099
|
+
return configuredWorkerUrl;
|
|
3100
|
+
};
|
|
3101
|
+
|
|
3102
|
+
const state$2 = {
|
|
3103
|
+
id: 0
|
|
3104
|
+
};
|
|
3105
|
+
const create$1 = () => {
|
|
3106
|
+
return ++state$2.id;
|
|
3107
|
+
};
|
|
3108
|
+
|
|
3109
|
+
const commandMap$1 = {
|
|
3110
|
+
'WebView.compatExtensionHostWorkerInvoke': (...args) => invoke$2('WebView.compatExtensionHostWorkerInvoke', ...args),
|
|
3111
|
+
'WebView.compatExtensionHostWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatExtensionHostWorkerInvokeAndTransfer', ...args),
|
|
3112
|
+
'WebView.compatRendererProcessInvoke': (...args) => invoke$2('WebView.compatRendererProcessInvoke', ...args),
|
|
3113
|
+
'WebView.compatRendererProcessInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatRendererProcessInvokeAndTransfer', ...args),
|
|
3114
|
+
'WebView.compatSharedProcessInvoke': (...args) => invoke$2('WebView.compatSharedProcessInvoke', ...args),
|
|
3115
|
+
'WebView.getSavedState': (...args) => invoke$2('WebView.getSavedState', ...args),
|
|
3116
|
+
'WebView.getWebViewInfo': (...args) => invoke$2('WebView.getWebViewInfo', ...args),
|
|
3117
|
+
'WebView.getWebViews': (...args) => invoke$2('WebView.getWebViews', ...args),
|
|
3118
|
+
'WebView.setPort': (...args) => invoke$2('WebView.setPort', ...args),
|
|
3119
|
+
'ExtensionHostManagement.activateByEvent': (...args) => invoke$2('ExtensionHostManagement.activateByEvent', ...args)
|
|
3120
|
+
};
|
|
3121
|
+
const launchIframeWorker = async () => {
|
|
3122
|
+
const configuredWorkerUrl = await getConfiguredIframeWorkerUrl();
|
|
3123
|
+
const name = 'Iframe Worker';
|
|
3124
|
+
const id = create$1();
|
|
3125
|
+
const rpc = await create$2({
|
|
3126
|
+
method: ModuleWorkerAndWorkaroundForChromeDevtoolsBug$1,
|
|
3127
|
+
name,
|
|
3128
|
+
url: configuredWorkerUrl,
|
|
3129
|
+
id,
|
|
3130
|
+
commandMap: commandMap$1
|
|
3131
|
+
});
|
|
3132
|
+
return rpc;
|
|
3133
|
+
};
|
|
3134
|
+
|
|
3135
|
+
let workerPromise;
|
|
3136
|
+
const ensureWorker = () => {
|
|
3137
|
+
if (!workerPromise) {
|
|
3138
|
+
workerPromise = launchIframeWorker();
|
|
3139
|
+
}
|
|
3140
|
+
return workerPromise;
|
|
3141
|
+
};
|
|
3142
|
+
const invoke = async (method, ...params) => {
|
|
3143
|
+
const rpc = await ensureWorker();
|
|
3144
|
+
return rpc.invoke(method, ...params);
|
|
3145
|
+
};
|
|
3146
|
+
|
|
3147
|
+
const createWebView3 = async ({
|
|
3148
|
+
id,
|
|
3149
|
+
uri,
|
|
3150
|
+
isGitpod,
|
|
3151
|
+
platform,
|
|
3152
|
+
assetDir,
|
|
3153
|
+
webViewScheme
|
|
3154
|
+
}) => {
|
|
3155
|
+
await invoke('WebView.create3', {
|
|
3156
|
+
id,
|
|
3157
|
+
uri,
|
|
3158
|
+
isGitpod,
|
|
3159
|
+
platform,
|
|
3160
|
+
assetDir,
|
|
3161
|
+
webViewScheme
|
|
3162
|
+
});
|
|
3163
|
+
};
|
|
3164
|
+
|
|
3074
3165
|
const BraceCompletionExecuteBraceCompletionProvider = 'ExtensionHostBraceCompletion.executeBraceCompletionProvider';
|
|
3075
3166
|
const ClosingTagExecuteClosingTagProvider = 'ExtensionHostClosingTag.executeClosingTagProvider';
|
|
3076
3167
|
const CommandExecute = 'ExtensionHostCommand.executeCommand';
|
|
@@ -3110,7 +3201,7 @@ const WorkspaceSetPath = 'Workspace.setWorkspacePath';
|
|
|
3110
3201
|
const SelectionExecuteSelectionProvider = 'ExtensionHostSelection.executeSelectionProvider';
|
|
3111
3202
|
const ConfigurationSetConfiguration = 'ExtensionHostConfiguration.setConfiguration';
|
|
3112
3203
|
|
|
3113
|
-
const create
|
|
3204
|
+
const create = () => {
|
|
3114
3205
|
return {
|
|
3115
3206
|
finished: false
|
|
3116
3207
|
};
|
|
@@ -3232,19 +3323,6 @@ class BabelParseError extends SyntaxError {
|
|
|
3232
3323
|
}
|
|
3233
3324
|
}
|
|
3234
3325
|
|
|
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
3326
|
const loadBabelParser = () => {
|
|
3249
3327
|
const url = `${assetDir}/js/babel-parser.js`;
|
|
3250
3328
|
return import(url);
|
|
@@ -3535,7 +3613,7 @@ const activate = async (extension, absolutePath) => {
|
|
|
3535
3613
|
string(absolutePath);
|
|
3536
3614
|
const module = await importScript(absolutePath);
|
|
3537
3615
|
handleRpcInfos(extension);
|
|
3538
|
-
const token = create
|
|
3616
|
+
const token = create();
|
|
3539
3617
|
try {
|
|
3540
3618
|
await Promise.race([module.activate(extension), rejectAfterTimeout(activationTimeout, token)]);
|
|
3541
3619
|
} catch (error) {
|
|
@@ -3571,7 +3649,7 @@ const mockExec = () => {
|
|
|
3571
3649
|
try {
|
|
3572
3650
|
// @ts-ignore
|
|
3573
3651
|
api.exec = async (command, args, options) => {
|
|
3574
|
-
const result = await invoke$
|
|
3652
|
+
const result = await invoke$2('Test.executeMockExecFunction', command, args, options);
|
|
3575
3653
|
const {
|
|
3576
3654
|
stdout,
|
|
3577
3655
|
stderr,
|
|
@@ -3597,7 +3675,7 @@ const mockRpc = () => {
|
|
|
3597
3675
|
try {
|
|
3598
3676
|
return {
|
|
3599
3677
|
async invoke(method, ...params) {
|
|
3600
|
-
const result = await invoke$
|
|
3678
|
+
const result = await invoke$2('Test.executeMockRpcFunction', options.name, method, ...params);
|
|
3601
3679
|
return result;
|
|
3602
3680
|
}
|
|
3603
3681
|
};
|
|
@@ -3890,7 +3968,7 @@ replaceTraps(oldTraps => ({
|
|
|
3890
3968
|
}
|
|
3891
3969
|
}));
|
|
3892
3970
|
|
|
3893
|
-
const state$
|
|
3971
|
+
const state$1 = {
|
|
3894
3972
|
databases: Object.create(null),
|
|
3895
3973
|
eventId: 0,
|
|
3896
3974
|
dbVersion: 1,
|
|
@@ -3908,7 +3986,7 @@ const isDataCloneError = error => {
|
|
|
3908
3986
|
|
|
3909
3987
|
const getDb$1 = async () => {
|
|
3910
3988
|
// @ts-ignore
|
|
3911
|
-
const db = await openDB('session', state$
|
|
3989
|
+
const db = await openDB('session', state$1.dbVersion, {
|
|
3912
3990
|
async upgrade(db, oldVersion) {
|
|
3913
3991
|
if (!db.objectStoreNames.contains('session')) {
|
|
3914
3992
|
const objectStore = await db.createObjectStore('session', {
|
|
@@ -3923,8 +4001,8 @@ const getDb$1 = async () => {
|
|
|
3923
4001
|
return db;
|
|
3924
4002
|
};
|
|
3925
4003
|
const getDbMemoized$1 = async () => {
|
|
3926
|
-
state$
|
|
3927
|
-
return state$
|
|
4004
|
+
state$1.cachedDb ||= await getDb$1();
|
|
4005
|
+
return state$1.cachedDb;
|
|
3928
4006
|
};
|
|
3929
4007
|
const saveValue = async (storeId, value) => {
|
|
3930
4008
|
try {
|
|
@@ -3963,7 +4041,7 @@ const getValuesByIndexName = async (storeId, indexName, only) => {
|
|
|
3963
4041
|
return objects;
|
|
3964
4042
|
};
|
|
3965
4043
|
const getHandleDb = async () => {
|
|
3966
|
-
const db = await openDB('handle', state$
|
|
4044
|
+
const db = await openDB('handle', state$1.dbVersion, {
|
|
3967
4045
|
async upgrade(db, oldVersion) {
|
|
3968
4046
|
if (!db.objectStoreNames.contains('file-handles-store')) {
|
|
3969
4047
|
// @ts-ignore
|
|
@@ -3987,13 +4065,13 @@ const storeId = 'lvce-keyvalue';
|
|
|
3987
4065
|
|
|
3988
4066
|
// TODO high memory usage in idb because of transactionDoneMap
|
|
3989
4067
|
|
|
3990
|
-
const state
|
|
4068
|
+
const state = {
|
|
3991
4069
|
databases: Object.create(null),
|
|
3992
4070
|
dbVersion: 2,
|
|
3993
4071
|
cachedDb: undefined
|
|
3994
4072
|
};
|
|
3995
4073
|
const getDb = async () => {
|
|
3996
|
-
const db = await openDB(storeId, state
|
|
4074
|
+
const db = await openDB(storeId, state.dbVersion, {
|
|
3997
4075
|
async upgrade(db, oldVersion) {
|
|
3998
4076
|
if (!db.objectStoreNames.contains(storeId)) {
|
|
3999
4077
|
await db.createObjectStore(storeId, {
|
|
@@ -4005,8 +4083,8 @@ const getDb = async () => {
|
|
|
4005
4083
|
return db;
|
|
4006
4084
|
};
|
|
4007
4085
|
const getDbMemoized = async () => {
|
|
4008
|
-
state
|
|
4009
|
-
return state
|
|
4086
|
+
state.cachedDb ||= await getDb();
|
|
4087
|
+
return state.cachedDb;
|
|
4010
4088
|
};
|
|
4011
4089
|
|
|
4012
4090
|
// TODO high memory usage in idb because of transactionDoneMap
|
|
@@ -4019,7 +4097,7 @@ const set = async (key, value) => {
|
|
|
4019
4097
|
throw new VError(error, 'Failed to save value to indexed db');
|
|
4020
4098
|
}
|
|
4021
4099
|
};
|
|
4022
|
-
const get
|
|
4100
|
+
const get = async key => {
|
|
4023
4101
|
try {
|
|
4024
4102
|
const db = await getDbMemoized();
|
|
4025
4103
|
const value = await db.get(storeId, key);
|
|
@@ -4029,41 +4107,6 @@ const get$1 = async key => {
|
|
|
4029
4107
|
}
|
|
4030
4108
|
};
|
|
4031
4109
|
|
|
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
4110
|
const loadWebView = async (providerId, savedState) => {
|
|
4068
4111
|
const rpc = getWebView(providerId);
|
|
4069
4112
|
await rpc.provider.create(rpc, rpc.uri, savedState);
|
|
@@ -4379,11 +4422,12 @@ const textSearch = async (scheme, root, query) => {
|
|
|
4379
4422
|
};
|
|
4380
4423
|
|
|
4381
4424
|
const commandMap = {
|
|
4425
|
+
'WebView.create3': createWebView3,
|
|
4382
4426
|
'ExtensionHost.launchIframeWorker': launchIframeWorker,
|
|
4383
4427
|
'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
|
|
4384
4428
|
'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
|
|
4385
4429
|
'IndexedDb.addHandle': addHandle,
|
|
4386
|
-
'IndexedDb.get': get
|
|
4430
|
+
'IndexedDb.get': get,
|
|
4387
4431
|
'IndexedDb.getHandle': getHandle$1,
|
|
4388
4432
|
'IndexedDb.getValues': getValues,
|
|
4389
4433
|
'IndexedDb.getValuesByIndexName': getValuesByIndexName,
|
package/package.json
CHANGED