@lvce-editor/extension-host-worker 5.17.0 → 5.18.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 +189 -112
- package/package.json +1 -1
|
@@ -1749,11 +1749,11 @@ const remove$3 = id => {
|
|
|
1749
1749
|
delete callbacks[id];
|
|
1750
1750
|
};
|
|
1751
1751
|
let id$1 = 0;
|
|
1752
|
-
const create$3$
|
|
1752
|
+
const create$3$2 = () => {
|
|
1753
1753
|
return ++id$1;
|
|
1754
1754
|
};
|
|
1755
1755
|
const registerPromise = () => {
|
|
1756
|
-
const id = create$3$
|
|
1756
|
+
const id = create$3$2();
|
|
1757
1757
|
const {
|
|
1758
1758
|
resolve,
|
|
1759
1759
|
promise
|
|
@@ -1838,7 +1838,8 @@ const splitLines$1 = lines => {
|
|
|
1838
1838
|
return lines.split(NewLine$1);
|
|
1839
1839
|
};
|
|
1840
1840
|
const getCurrentStack = () => {
|
|
1841
|
-
const
|
|
1841
|
+
const stackLinesToSkip = 3;
|
|
1842
|
+
const currentStack = joinLines(splitLines$1(new Error().stack || '').slice(stackLinesToSkip));
|
|
1842
1843
|
return currentStack;
|
|
1843
1844
|
};
|
|
1844
1845
|
const getNewLineIndex = (string, startIndex = undefined) => {
|
|
@@ -2098,7 +2099,7 @@ const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
|
2098
2099
|
const responseMessage = await promise;
|
|
2099
2100
|
return unwrapJsonRpcResult(responseMessage);
|
|
2100
2101
|
};
|
|
2101
|
-
const send = (transport, method, ...params) => {
|
|
2102
|
+
const send$1 = (transport, method, ...params) => {
|
|
2102
2103
|
const message = create$4$2(method, params);
|
|
2103
2104
|
transport.send(message);
|
|
2104
2105
|
};
|
|
@@ -2109,6 +2110,12 @@ const invokeAndTransfer$1 = (ipc, method, ...params) => {
|
|
|
2109
2110
|
return invokeHelper(ipc, method, params, true);
|
|
2110
2111
|
};
|
|
2111
2112
|
|
|
2113
|
+
class CommandNotFoundError extends Error {
|
|
2114
|
+
constructor(command) {
|
|
2115
|
+
super(`Command not found ${command}`);
|
|
2116
|
+
this.name = 'CommandNotFoundError';
|
|
2117
|
+
}
|
|
2118
|
+
}
|
|
2112
2119
|
const commands = Object.create(null);
|
|
2113
2120
|
const register$1 = commandMap => {
|
|
2114
2121
|
Object.assign(commands, commandMap);
|
|
@@ -2119,7 +2126,7 @@ const getCommand = key => {
|
|
|
2119
2126
|
const execute = (command, ...args) => {
|
|
2120
2127
|
const fn = getCommand(command);
|
|
2121
2128
|
if (!fn) {
|
|
2122
|
-
throw new
|
|
2129
|
+
throw new CommandNotFoundError(command);
|
|
2123
2130
|
}
|
|
2124
2131
|
return fn(...args);
|
|
2125
2132
|
};
|
|
@@ -2132,7 +2139,7 @@ const createRpc$1 = ipc => {
|
|
|
2132
2139
|
* @deprecated
|
|
2133
2140
|
*/
|
|
2134
2141
|
send(method, ...params) {
|
|
2135
|
-
send(ipc, method, ...params);
|
|
2142
|
+
send$1(ipc, method, ...params);
|
|
2136
2143
|
},
|
|
2137
2144
|
invoke(method, ...params) {
|
|
2138
2145
|
return invoke$1(ipc, method, ...params);
|
|
@@ -2176,7 +2183,7 @@ const listen$1 = async (module, options) => {
|
|
|
2176
2183
|
const ipc = module.wrap(rawIpc);
|
|
2177
2184
|
return ipc;
|
|
2178
2185
|
};
|
|
2179
|
-
const create$
|
|
2186
|
+
const create$f = async ({
|
|
2180
2187
|
commandMap,
|
|
2181
2188
|
messagePort
|
|
2182
2189
|
}) => {
|
|
@@ -2191,9 +2198,9 @@ const create$e = async ({
|
|
|
2191
2198
|
};
|
|
2192
2199
|
const MessagePortRpcClient = {
|
|
2193
2200
|
__proto__: null,
|
|
2194
|
-
create: create$
|
|
2201
|
+
create: create$f
|
|
2195
2202
|
};
|
|
2196
|
-
const create$
|
|
2203
|
+
const create$e = async ({
|
|
2197
2204
|
commandMap,
|
|
2198
2205
|
messagePort,
|
|
2199
2206
|
isMessagePortOpen
|
|
@@ -2211,7 +2218,7 @@ const create$d = async ({
|
|
|
2211
2218
|
};
|
|
2212
2219
|
const MessagePortRpcParent = {
|
|
2213
2220
|
__proto__: null,
|
|
2214
|
-
create: create$
|
|
2221
|
+
create: create$e
|
|
2215
2222
|
};
|
|
2216
2223
|
const create$5$1 = async ({
|
|
2217
2224
|
commandMap,
|
|
@@ -2242,6 +2249,24 @@ const PlainMessagePortRpcParent = {
|
|
|
2242
2249
|
__proto__: null,
|
|
2243
2250
|
create: create$4$1
|
|
2244
2251
|
};
|
|
2252
|
+
const create$3$1 = async ({
|
|
2253
|
+
commandMap,
|
|
2254
|
+
send
|
|
2255
|
+
}) => {
|
|
2256
|
+
const {
|
|
2257
|
+
port1,
|
|
2258
|
+
port2
|
|
2259
|
+
} = new MessageChannel();
|
|
2260
|
+
await send(port1);
|
|
2261
|
+
return create$5$1({
|
|
2262
|
+
commandMap,
|
|
2263
|
+
messagePort: port2
|
|
2264
|
+
});
|
|
2265
|
+
};
|
|
2266
|
+
const TransferMessagePortRpcParent = {
|
|
2267
|
+
__proto__: null,
|
|
2268
|
+
create: create$3$1
|
|
2269
|
+
};
|
|
2245
2270
|
const create$2$1 = async ({
|
|
2246
2271
|
commandMap,
|
|
2247
2272
|
webSocket
|
|
@@ -2492,6 +2517,54 @@ const createNodeRpc = async ({
|
|
|
2492
2517
|
}
|
|
2493
2518
|
};
|
|
2494
2519
|
|
|
2520
|
+
const send = async port => {
|
|
2521
|
+
await invokeAndTransfer$2('SendMessagePortToExtensionHostWorker.SendMessagePortToFileSystemWorker', port);
|
|
2522
|
+
};
|
|
2523
|
+
const launchFileSystemProcess = async () => {
|
|
2524
|
+
const rpc = await TransferMessagePortRpcParent.create({
|
|
2525
|
+
commandMap: {},
|
|
2526
|
+
send
|
|
2527
|
+
});
|
|
2528
|
+
return rpc;
|
|
2529
|
+
};
|
|
2530
|
+
|
|
2531
|
+
let fileSystemWorkerPromise;
|
|
2532
|
+
const getOrCreateRpc$1 = async () => {
|
|
2533
|
+
if (!fileSystemWorkerPromise) {
|
|
2534
|
+
fileSystemWorkerPromise = launchFileSystemProcess();
|
|
2535
|
+
}
|
|
2536
|
+
return fileSystemWorkerPromise;
|
|
2537
|
+
};
|
|
2538
|
+
const append = async (uri, content) => {
|
|
2539
|
+
const rpc = await getOrCreateRpc$1();
|
|
2540
|
+
await rpc.invoke('FileSystem.appendFile', uri, content);
|
|
2541
|
+
};
|
|
2542
|
+
|
|
2543
|
+
const providers = Object.create(null);
|
|
2544
|
+
const registerOutputChannel = provider => {
|
|
2545
|
+
providers[provider.id] = provider;
|
|
2546
|
+
const uri = `output://${provider.id}`;
|
|
2547
|
+
return {
|
|
2548
|
+
async append(text) {
|
|
2549
|
+
await append(uri, text);
|
|
2550
|
+
},
|
|
2551
|
+
getUri() {
|
|
2552
|
+
return uri;
|
|
2553
|
+
}
|
|
2554
|
+
};
|
|
2555
|
+
};
|
|
2556
|
+
const getEnabledProviders = () => {
|
|
2557
|
+
const values = Object.values(providers);
|
|
2558
|
+
const enabledProviders = [];
|
|
2559
|
+
for (const provider of values) {
|
|
2560
|
+
enabledProviders.push({
|
|
2561
|
+
id: provider.id,
|
|
2562
|
+
label: provider.label
|
|
2563
|
+
});
|
|
2564
|
+
}
|
|
2565
|
+
return enabledProviders;
|
|
2566
|
+
};
|
|
2567
|
+
|
|
2495
2568
|
const confirm = message => {
|
|
2496
2569
|
string(message);
|
|
2497
2570
|
const result = invoke$2('ConfirmPrompt.prompt', message);
|
|
@@ -3124,6 +3197,8 @@ const api = {
|
|
|
3124
3197
|
// Implementation
|
|
3125
3198
|
registerImplementationProvider: registerImplementationProvider,
|
|
3126
3199
|
executeImplementationProvider: executeImplementationProvider,
|
|
3200
|
+
// Output
|
|
3201
|
+
registerOutputChannel: registerOutputChannel,
|
|
3127
3202
|
// Prompt
|
|
3128
3203
|
confirm: confirm,
|
|
3129
3204
|
// QuickPick
|
|
@@ -3283,6 +3358,22 @@ const getExtensionId = extension => {
|
|
|
3283
3358
|
return '<unknown>';
|
|
3284
3359
|
};
|
|
3285
3360
|
|
|
3361
|
+
const isImportErrorChrome = error => {
|
|
3362
|
+
return error && error instanceof Error && error.message.startsWith('Failed to fetch dynamically imported module');
|
|
3363
|
+
};
|
|
3364
|
+
|
|
3365
|
+
const isImportErrorFirefox = error => {
|
|
3366
|
+
return error && error instanceof TypeError && error.message === 'error loading dynamically imported module';
|
|
3367
|
+
};
|
|
3368
|
+
|
|
3369
|
+
const isSyntaxError = error => {
|
|
3370
|
+
return error instanceof SyntaxError;
|
|
3371
|
+
};
|
|
3372
|
+
|
|
3373
|
+
const isImportError = error => {
|
|
3374
|
+
return isImportErrorChrome(error) || isImportErrorFirefox(error) || isSyntaxError(error);
|
|
3375
|
+
};
|
|
3376
|
+
|
|
3286
3377
|
const states = Object.create(null);
|
|
3287
3378
|
const set$5 = status => {
|
|
3288
3379
|
states[status.id] = status;
|
|
@@ -3312,108 +3403,6 @@ const sleep = duration => {
|
|
|
3312
3403
|
return promise;
|
|
3313
3404
|
};
|
|
3314
3405
|
|
|
3315
|
-
// TODO make activation timeout configurable or remove it.
|
|
3316
|
-
// some extension might do workspace indexing which could take some time
|
|
3317
|
-
const activationTimeout$1 = 10_000;
|
|
3318
|
-
const rejectAfterTimeout$1 = async (timeout, token) => {
|
|
3319
|
-
await sleep(timeout);
|
|
3320
|
-
if (isCanceled(token)) {
|
|
3321
|
-
return;
|
|
3322
|
-
}
|
|
3323
|
-
throw new Error(`Activation timeout of ${timeout}ms exceeded`);
|
|
3324
|
-
};
|
|
3325
|
-
|
|
3326
|
-
// TODO separate importing extension and activating extension for smaller functions
|
|
3327
|
-
// and better error handling
|
|
3328
|
-
const activateExtension2 = async (extensionId, extension) => {
|
|
3329
|
-
const token = create$1();
|
|
3330
|
-
try {
|
|
3331
|
-
const startTime = performance.now();
|
|
3332
|
-
update(extensionId, {
|
|
3333
|
-
status: Activating,
|
|
3334
|
-
activationStartTime: startTime
|
|
3335
|
-
});
|
|
3336
|
-
const module = acquire(extensionId);
|
|
3337
|
-
await Promise.race([module.activate(extension), rejectAfterTimeout$1(activationTimeout$1, token)]);
|
|
3338
|
-
const endTime = performance.now();
|
|
3339
|
-
const time = endTime - startTime;
|
|
3340
|
-
update(extensionId, {
|
|
3341
|
-
status: Activated,
|
|
3342
|
-
activationTime: time,
|
|
3343
|
-
activationEndTime: endTime
|
|
3344
|
-
});
|
|
3345
|
-
} catch (error) {
|
|
3346
|
-
update(extensionId, {
|
|
3347
|
-
status: Error$1 // TODO maybe store error also in runtime status state
|
|
3348
|
-
});
|
|
3349
|
-
const id = getExtensionId(extension);
|
|
3350
|
-
throw new VError(error, `Failed to activate extension ${id}`);
|
|
3351
|
-
} finally {
|
|
3352
|
-
cancel(token);
|
|
3353
|
-
}
|
|
3354
|
-
};
|
|
3355
|
-
|
|
3356
|
-
const getUrlPrefix = (platform, extensionPath) => {
|
|
3357
|
-
if (extensionPath.startsWith('http://') || extensionPath.startsWith('https://')) {
|
|
3358
|
-
return extensionPath;
|
|
3359
|
-
}
|
|
3360
|
-
if (platform === Web) {
|
|
3361
|
-
return extensionPath;
|
|
3362
|
-
}
|
|
3363
|
-
if (extensionPath.startsWith('/')) {
|
|
3364
|
-
return `/remote${extensionPath}`;
|
|
3365
|
-
}
|
|
3366
|
-
return `/remote/${extensionPath}`;
|
|
3367
|
-
};
|
|
3368
|
-
|
|
3369
|
-
const handleRpcInfos = (extension, platform) => {
|
|
3370
|
-
try {
|
|
3371
|
-
if (!extension) {
|
|
3372
|
-
return;
|
|
3373
|
-
}
|
|
3374
|
-
const rpcs = extension.rpc;
|
|
3375
|
-
const urlPrefix = getUrlPrefix(platform, extension.path);
|
|
3376
|
-
if (!rpcs) {
|
|
3377
|
-
return;
|
|
3378
|
-
}
|
|
3379
|
-
if (!Array.isArray(rpcs)) {
|
|
3380
|
-
return;
|
|
3381
|
-
}
|
|
3382
|
-
for (const rpc of rpcs) {
|
|
3383
|
-
rpc.url = `${urlPrefix}/${rpc.url}`;
|
|
3384
|
-
add$1(rpc.id, rpc);
|
|
3385
|
-
}
|
|
3386
|
-
} catch (error) {
|
|
3387
|
-
console.warn(`Failed to handle extension rpcs: ${error}`);
|
|
3388
|
-
}
|
|
3389
|
-
};
|
|
3390
|
-
|
|
3391
|
-
class ContentSecurityPolicyError extends Error {
|
|
3392
|
-
constructor(violatedDirective, sourceFile, lineNumber, columnNumber) {
|
|
3393
|
-
super(`Content Security Policy Violation: ${violatedDirective}`);
|
|
3394
|
-
this.name = 'ContentSecurityPolicyError';
|
|
3395
|
-
this.stack = sourceFile ? `Content Security Policy Violation
|
|
3396
|
-
at ${sourceFile}:${lineNumber}:${columnNumber}` : `Content Security Policy Violation
|
|
3397
|
-
at <unknown>`;
|
|
3398
|
-
}
|
|
3399
|
-
}
|
|
3400
|
-
|
|
3401
|
-
const isImportErrorChrome = error => {
|
|
3402
|
-
return error && error instanceof Error && error.message.startsWith('Failed to fetch dynamically imported module');
|
|
3403
|
-
};
|
|
3404
|
-
|
|
3405
|
-
const isImportErrorFirefox = error => {
|
|
3406
|
-
return error && error instanceof TypeError && error.message === 'error loading dynamically imported module';
|
|
3407
|
-
};
|
|
3408
|
-
|
|
3409
|
-
const isSyntaxError = error => {
|
|
3410
|
-
return error instanceof SyntaxError;
|
|
3411
|
-
};
|
|
3412
|
-
|
|
3413
|
-
const isImportError = error => {
|
|
3414
|
-
return isImportErrorChrome(error) || isImportErrorFirefox(error) || isSyntaxError(error);
|
|
3415
|
-
};
|
|
3416
|
-
|
|
3417
3406
|
const NotFound = 404;
|
|
3418
3407
|
|
|
3419
3408
|
const RE_LINE_COLUMN = /(.*)(?:\(\d+:\d+\))/;
|
|
@@ -3465,6 +3454,16 @@ const parse = async (code, options) => {
|
|
|
3465
3454
|
|
|
3466
3455
|
const Module = 'module';
|
|
3467
3456
|
|
|
3457
|
+
class ContentSecurityPolicyError extends Error {
|
|
3458
|
+
constructor(violatedDirective, sourceFile, lineNumber, columnNumber) {
|
|
3459
|
+
super(`Content Security Policy Violation: ${violatedDirective}`);
|
|
3460
|
+
this.name = 'ContentSecurityPolicyError';
|
|
3461
|
+
this.stack = sourceFile ? `Content Security Policy Violation
|
|
3462
|
+
at ${sourceFile}:${lineNumber}:${columnNumber}` : `Content Security Policy Violation
|
|
3463
|
+
at <unknown>`;
|
|
3464
|
+
}
|
|
3465
|
+
}
|
|
3466
|
+
|
|
3468
3467
|
const getLineAndColumn = (text, start, end) => {
|
|
3469
3468
|
let index = -1;
|
|
3470
3469
|
let line = 0;
|
|
@@ -3722,6 +3721,83 @@ const tryToGetActualImportErrorMessage = async (url, error) => {
|
|
|
3722
3721
|
}
|
|
3723
3722
|
};
|
|
3724
3723
|
|
|
3724
|
+
// TODO make activation timeout configurable or remove it.
|
|
3725
|
+
// some extension might do workspace indexing which could take some time
|
|
3726
|
+
const activationTimeout$1 = 10_000;
|
|
3727
|
+
const rejectAfterTimeout$1 = async (timeout, token) => {
|
|
3728
|
+
await sleep(timeout);
|
|
3729
|
+
if (isCanceled(token)) {
|
|
3730
|
+
return;
|
|
3731
|
+
}
|
|
3732
|
+
throw new Error(`Activation timeout of ${timeout}ms exceeded`);
|
|
3733
|
+
};
|
|
3734
|
+
const activateExtension2 = async (extensionId, extension, absolutePath) => {
|
|
3735
|
+
const token = create$1();
|
|
3736
|
+
try {
|
|
3737
|
+
const startTime = performance.now();
|
|
3738
|
+
update(extensionId, {
|
|
3739
|
+
status: Activating,
|
|
3740
|
+
activationStartTime: startTime
|
|
3741
|
+
});
|
|
3742
|
+
const module = acquire(extensionId);
|
|
3743
|
+
await Promise.race([module.activate(extension), rejectAfterTimeout$1(activationTimeout$1, token)]);
|
|
3744
|
+
const endTime = performance.now();
|
|
3745
|
+
const time = endTime - startTime;
|
|
3746
|
+
update(extensionId, {
|
|
3747
|
+
status: Activated,
|
|
3748
|
+
activationTime: time,
|
|
3749
|
+
activationEndTime: endTime
|
|
3750
|
+
});
|
|
3751
|
+
} catch (error) {
|
|
3752
|
+
const id = getExtensionId(extension);
|
|
3753
|
+
if (isImportError(error)) {
|
|
3754
|
+
const actualErrorMessage = await tryToGetActualImportErrorMessage(absolutePath, error);
|
|
3755
|
+
throw new Error(`Failed to activate extension ${id}: ${actualErrorMessage}`);
|
|
3756
|
+
}
|
|
3757
|
+
update(extensionId, {
|
|
3758
|
+
status: Error$1 // TODO maybe store error also in runtime status state
|
|
3759
|
+
});
|
|
3760
|
+
throw new VError(error, `Failed to activate extension ${id}`);
|
|
3761
|
+
} finally {
|
|
3762
|
+
cancel(token);
|
|
3763
|
+
}
|
|
3764
|
+
};
|
|
3765
|
+
|
|
3766
|
+
const getUrlPrefix = (platform, extensionPath) => {
|
|
3767
|
+
if (extensionPath.startsWith('http://') || extensionPath.startsWith('https://')) {
|
|
3768
|
+
return extensionPath;
|
|
3769
|
+
}
|
|
3770
|
+
if (platform === Web) {
|
|
3771
|
+
return extensionPath;
|
|
3772
|
+
}
|
|
3773
|
+
if (extensionPath.startsWith('/')) {
|
|
3774
|
+
return `/remote${extensionPath}`;
|
|
3775
|
+
}
|
|
3776
|
+
return `/remote/${extensionPath}`;
|
|
3777
|
+
};
|
|
3778
|
+
|
|
3779
|
+
const handleRpcInfos = (extension, platform) => {
|
|
3780
|
+
try {
|
|
3781
|
+
if (!extension) {
|
|
3782
|
+
return;
|
|
3783
|
+
}
|
|
3784
|
+
const rpcs = extension.rpc;
|
|
3785
|
+
const urlPrefix = getUrlPrefix(platform, extension.path);
|
|
3786
|
+
if (!rpcs) {
|
|
3787
|
+
return;
|
|
3788
|
+
}
|
|
3789
|
+
if (!Array.isArray(rpcs)) {
|
|
3790
|
+
return;
|
|
3791
|
+
}
|
|
3792
|
+
for (const rpc of rpcs) {
|
|
3793
|
+
rpc.url = `${urlPrefix}/${rpc.url}`;
|
|
3794
|
+
add$1(rpc.id, rpc);
|
|
3795
|
+
}
|
|
3796
|
+
} catch (error) {
|
|
3797
|
+
console.warn(`Failed to handle extension rpcs: ${error}`);
|
|
3798
|
+
}
|
|
3799
|
+
};
|
|
3800
|
+
|
|
3725
3801
|
const importScript = async url => {
|
|
3726
3802
|
try {
|
|
3727
3803
|
return await import(url);
|
|
@@ -5948,6 +6024,7 @@ const commandMap = {
|
|
|
5948
6024
|
'IndexedDb.saveValue': saveValue,
|
|
5949
6025
|
'IndexedDb.set': set$3,
|
|
5950
6026
|
'Languages.getLanguages': getLanguages,
|
|
6027
|
+
'Output.getEnabledProviders': getEnabledProviders,
|
|
5951
6028
|
'SaveState.saveState': saveState,
|
|
5952
6029
|
'SearchFileWithFetch.searchFileWithFetch': searchFile$2,
|
|
5953
6030
|
'SearchFileWithHtml.searchFileWithHtml': searchFile$1,
|