@lvce-editor/extension-host-worker 4.6.0 → 4.8.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 +94 -43
- package/package.json +4 -4
|
@@ -614,7 +614,7 @@ const create$a = ({
|
|
|
614
614
|
};
|
|
615
615
|
|
|
616
616
|
const Array$1 = 'array';
|
|
617
|
-
const Boolean = 'boolean';
|
|
617
|
+
const Boolean$1 = 'boolean';
|
|
618
618
|
const Number = 'number';
|
|
619
619
|
const Object$1 = 'object';
|
|
620
620
|
const String$1 = 'string';
|
|
@@ -626,7 +626,7 @@ const {
|
|
|
626
626
|
} = create$a({
|
|
627
627
|
name: 'BraceCompletion',
|
|
628
628
|
resultShape: {
|
|
629
|
-
type: Boolean
|
|
629
|
+
type: Boolean$1
|
|
630
630
|
}
|
|
631
631
|
});
|
|
632
632
|
|
|
@@ -1068,7 +1068,9 @@ const getPosition = (textDocument, offset) => {
|
|
|
1068
1068
|
let index = 0;
|
|
1069
1069
|
let rowIndex = 0;
|
|
1070
1070
|
let newLineIndex = 0;
|
|
1071
|
-
const
|
|
1071
|
+
const {
|
|
1072
|
+
text
|
|
1073
|
+
} = textDocument;
|
|
1072
1074
|
while (index < offset) {
|
|
1073
1075
|
newLineIndex = text.indexOf('\n', index);
|
|
1074
1076
|
if (newLineIndex === -1) {
|
|
@@ -2713,7 +2715,7 @@ const {
|
|
|
2713
2715
|
}
|
|
2714
2716
|
});
|
|
2715
2717
|
|
|
2716
|
-
const RE_PROTOCOL = /^([a-z
|
|
2718
|
+
const RE_PROTOCOL = /^([a-z-]+):\/\//;
|
|
2717
2719
|
const getProtocol = uri => {
|
|
2718
2720
|
const protocolMatch = uri.match(RE_PROTOCOL);
|
|
2719
2721
|
if (protocolMatch) {
|
|
@@ -3073,7 +3075,7 @@ const setup = ({
|
|
|
3073
3075
|
setStackTraceLimit(errorConstructor, 20);
|
|
3074
3076
|
global.onerror ||= handleUnhandledError;
|
|
3075
3077
|
global.onunhandledrejection ||= handleUnhandledRejection;
|
|
3076
|
-
if ('SecurityPolicyViolationEvent' in
|
|
3078
|
+
if ('SecurityPolicyViolationEvent' in globalThis) {
|
|
3077
3079
|
global.addEventListener('securitypolicyviolation', handleContentSecurityPolicyViolation);
|
|
3078
3080
|
}
|
|
3079
3081
|
// @ts-ignore
|
|
@@ -3197,7 +3199,9 @@ const createColorThemeFromJson = (colorThemeId, colorThemeJson) => {
|
|
|
3197
3199
|
warn(`color theme json for "${colorThemeId}" cannot be converted to css, it must be of type object but was of type array`);
|
|
3198
3200
|
return '';
|
|
3199
3201
|
}
|
|
3200
|
-
const
|
|
3202
|
+
const {
|
|
3203
|
+
colors
|
|
3204
|
+
} = colorThemeJson;
|
|
3201
3205
|
if (!colors) {
|
|
3202
3206
|
return '';
|
|
3203
3207
|
}
|
|
@@ -3849,7 +3853,7 @@ const create$1 = () => {
|
|
|
3849
3853
|
return ++state$3.id;
|
|
3850
3854
|
};
|
|
3851
3855
|
|
|
3852
|
-
const
|
|
3856
|
+
const iframeWorkerCommandMap = {
|
|
3853
3857
|
'WebView.compatExtensionHostWorkerInvoke': (...args) => invoke$2('WebView.compatExtensionHostWorkerInvoke', ...args),
|
|
3854
3858
|
'WebView.compatExtensionHostWorkerInvokeAndTransfer': (...args) => invokeAndTransfer$1('WebView.compatExtensionHostWorkerInvokeAndTransfer', ...args),
|
|
3855
3859
|
'WebView.compatRendererProcessInvoke': (...args) => invoke$2('WebView.compatRendererProcessInvoke', ...args),
|
|
@@ -3866,6 +3870,7 @@ const commandMap$1 = {
|
|
|
3866
3870
|
'ExtensionHostManagement.activateByEvent': (...args) => invoke$2('ExtensionHostManagement.activateByEvent', ...args),
|
|
3867
3871
|
'WebView.getRemoteUrl': options => getRemoteUrlForWebView(options.uri, options)
|
|
3868
3872
|
};
|
|
3873
|
+
|
|
3869
3874
|
const launchIframeWorker = async () => {
|
|
3870
3875
|
const configuredWorkerUrl = await getConfiguredIframeWorkerUrl();
|
|
3871
3876
|
const name = 'Iframe Worker';
|
|
@@ -3875,7 +3880,7 @@ const launchIframeWorker = async () => {
|
|
|
3875
3880
|
name,
|
|
3876
3881
|
url: configuredWorkerUrl,
|
|
3877
3882
|
id,
|
|
3878
|
-
commandMap:
|
|
3883
|
+
commandMap: iframeWorkerCommandMap
|
|
3879
3884
|
});
|
|
3880
3885
|
return rpc;
|
|
3881
3886
|
};
|
|
@@ -3887,6 +3892,9 @@ const ensureWorker = () => {
|
|
|
3887
3892
|
}
|
|
3888
3893
|
return workerPromise;
|
|
3889
3894
|
};
|
|
3895
|
+
const isActive = () => {
|
|
3896
|
+
return Boolean(workerPromise);
|
|
3897
|
+
};
|
|
3890
3898
|
const invoke = async (method, ...params) => {
|
|
3891
3899
|
const rpc = await ensureWorker();
|
|
3892
3900
|
return rpc.invoke(method, ...params);
|
|
@@ -4034,13 +4042,9 @@ class ContentSecurityPolicyError extends Error {
|
|
|
4034
4042
|
constructor(violatedDirective, sourceFile, lineNumber, columnNumber) {
|
|
4035
4043
|
super(`Content Security Policy Violation: ${violatedDirective}`);
|
|
4036
4044
|
this.name = 'ContentSecurityPolicyError';
|
|
4037
|
-
|
|
4038
|
-
|
|
4039
|
-
at ${sourceFile}:${lineNumber}:${columnNumber}`;
|
|
4040
|
-
} else {
|
|
4041
|
-
this.stack = `Content Security Policy Violation
|
|
4045
|
+
this.stack = sourceFile ? `Content Security Policy Violation
|
|
4046
|
+
at ${sourceFile}:${lineNumber}:${columnNumber}` : `Content Security Policy Violation
|
|
4042
4047
|
at <unknown>`;
|
|
4043
|
-
}
|
|
4044
4048
|
}
|
|
4045
4049
|
}
|
|
4046
4050
|
|
|
@@ -4061,15 +4065,17 @@ const isImportError = error => {
|
|
|
4061
4065
|
};
|
|
4062
4066
|
|
|
4063
4067
|
const sleep = duration => {
|
|
4064
|
-
const
|
|
4065
|
-
|
|
4066
|
-
|
|
4067
|
-
|
|
4068
|
+
const {
|
|
4069
|
+
resolve,
|
|
4070
|
+
promise
|
|
4071
|
+
} = Promise.withResolvers();
|
|
4072
|
+
setTimeout(resolve, duration);
|
|
4073
|
+
return promise;
|
|
4068
4074
|
};
|
|
4069
4075
|
|
|
4070
4076
|
const NotFound = 404;
|
|
4071
4077
|
|
|
4072
|
-
const RE_LINE_COLUMN = /(.*)(?:\(\d
|
|
4078
|
+
const RE_LINE_COLUMN = /(.*)(?:\(\d+:\d+\))/;
|
|
4073
4079
|
const getBabelErrorMessage = message => {
|
|
4074
4080
|
const match = message.match(RE_LINE_COLUMN);
|
|
4075
4081
|
if (match) {
|
|
@@ -4083,7 +4089,9 @@ class BabelParseError extends SyntaxError {
|
|
|
4083
4089
|
super(message);
|
|
4084
4090
|
this.name = 'BabelParseError';
|
|
4085
4091
|
// @ts-ignore
|
|
4086
|
-
const
|
|
4092
|
+
const {
|
|
4093
|
+
line
|
|
4094
|
+
} = error.loc;
|
|
4087
4095
|
// @ts-ignore
|
|
4088
4096
|
const column = error.loc.column + 1;
|
|
4089
4097
|
this.stack = `${message}
|
|
@@ -4201,8 +4209,12 @@ const getBabelAstDependencies = (code, ast) => {
|
|
|
4201
4209
|
for (const node of body) {
|
|
4202
4210
|
if (node.type === ImportDeclaration || node.type === ExportAllDeclaration) {
|
|
4203
4211
|
const relativePath = node.source.extra.rawValue;
|
|
4204
|
-
const
|
|
4205
|
-
|
|
4212
|
+
const {
|
|
4213
|
+
start
|
|
4214
|
+
} = node.source;
|
|
4215
|
+
const {
|
|
4216
|
+
end
|
|
4217
|
+
} = node.source;
|
|
4206
4218
|
// @ts-ignore
|
|
4207
4219
|
dependencies.push({
|
|
4208
4220
|
relativePath,
|
|
@@ -4212,8 +4224,12 @@ const getBabelAstDependencies = (code, ast) => {
|
|
|
4212
4224
|
});
|
|
4213
4225
|
} else if (node.type === VariableDeclaration && node.declarations && node.declarations[0] && node.declarations[0].type === VariableDeclarator && node.declarations[0].init && node.declarations[0].init.type === AwaitExpression && node.declarations[0].init.argument && node.declarations[0].init.argument.type === CallExpression && node.declarations[0].init.argument.callee && node.declarations[0].init.argument.callee.type === Import && node.declarations[0].init.argument.arguments && node.declarations[0].init.argument.arguments[0] && node.declarations[0].init.argument.arguments[0].type === StringLiteral) {
|
|
4214
4226
|
const relativePath = node.declarations[0].init.argument.arguments[0].extra.rawValue;
|
|
4215
|
-
const
|
|
4216
|
-
|
|
4227
|
+
const {
|
|
4228
|
+
start
|
|
4229
|
+
} = node.declarations[0].init.argument.arguments[0];
|
|
4230
|
+
const {
|
|
4231
|
+
end
|
|
4232
|
+
} = node.declarations[0].init.argument.arguments[0];
|
|
4217
4233
|
// @ts-ignore
|
|
4218
4234
|
dependencies.push({
|
|
4219
4235
|
relativePath,
|
|
@@ -4226,8 +4242,12 @@ const getBabelAstDependencies = (code, ast) => {
|
|
|
4226
4242
|
const visitor = node => {
|
|
4227
4243
|
if (node && node.type === CallExpression && node.callee && node.callee.type === Import && node.arguments && node.arguments[0] && node.arguments[0].type === StringLiteral) {
|
|
4228
4244
|
const relativePath = node.arguments[0].extra.rawValue;
|
|
4229
|
-
const
|
|
4230
|
-
|
|
4245
|
+
const {
|
|
4246
|
+
start
|
|
4247
|
+
} = node.arguments[0];
|
|
4248
|
+
const {
|
|
4249
|
+
end
|
|
4250
|
+
} = node.arguments[0];
|
|
4231
4251
|
// @ts-ignore
|
|
4232
4252
|
dependencies.push({
|
|
4233
4253
|
relativePath,
|
|
@@ -4301,7 +4321,7 @@ const tryToGetActualErrorMessage = async (error, url, response, seenUrls = []) =
|
|
|
4301
4321
|
let text;
|
|
4302
4322
|
try {
|
|
4303
4323
|
text = await response.text();
|
|
4304
|
-
} catch
|
|
4324
|
+
} catch {
|
|
4305
4325
|
return `Failed to import ${url}: Unknown Network Error`;
|
|
4306
4326
|
}
|
|
4307
4327
|
let ast;
|
|
@@ -4743,6 +4763,16 @@ const getColorThemeNames = async () => {
|
|
|
4743
4763
|
return colorThemeNames;
|
|
4744
4764
|
};
|
|
4745
4765
|
|
|
4766
|
+
const getExtension = async id => {
|
|
4767
|
+
const allExtensions = await getExtensions();
|
|
4768
|
+
for (const extension of allExtensions) {
|
|
4769
|
+
if (extension.id === id) {
|
|
4770
|
+
return extension;
|
|
4771
|
+
}
|
|
4772
|
+
}
|
|
4773
|
+
return undefined;
|
|
4774
|
+
};
|
|
4775
|
+
|
|
4746
4776
|
const findMatchingIconThemeExtension = (extensions, iconThemeId) => {
|
|
4747
4777
|
for (const extension of extensions) {
|
|
4748
4778
|
if (extension && extension.iconThemes) {
|
|
@@ -4819,7 +4849,9 @@ const getWebViewsFromExtensions = extensions => {
|
|
|
4819
4849
|
for (const extension of extensions) {
|
|
4820
4850
|
if (extension && extension.webViews) {
|
|
4821
4851
|
for (const webView of extension.webViews) {
|
|
4822
|
-
let
|
|
4852
|
+
let {
|
|
4853
|
+
path
|
|
4854
|
+
} = extension;
|
|
4823
4855
|
if (webView && webView.path) {
|
|
4824
4856
|
path = `${extension.path}/${webView.path}`;
|
|
4825
4857
|
}
|
|
@@ -5069,9 +5101,12 @@ const serializeWebViews = async webViews => {
|
|
|
5069
5101
|
}
|
|
5070
5102
|
return serialized;
|
|
5071
5103
|
};
|
|
5072
|
-
const getAdditional = () => {
|
|
5104
|
+
const getAdditional = async () => {
|
|
5105
|
+
if (!isActive()) {
|
|
5106
|
+
return [];
|
|
5107
|
+
}
|
|
5073
5108
|
try {
|
|
5074
|
-
return invoke('WebView.saveState');
|
|
5109
|
+
return await invoke('WebView.saveState');
|
|
5075
5110
|
} catch {
|
|
5076
5111
|
return [];
|
|
5077
5112
|
}
|
|
@@ -5216,30 +5251,43 @@ const getLineMatchRegex = (line, lineNumber, query, matchCase) => {
|
|
|
5216
5251
|
return [];
|
|
5217
5252
|
};
|
|
5218
5253
|
|
|
5219
|
-
const
|
|
5254
|
+
const doesMatchWord = (line, index, wordBoundaries) => {
|
|
5255
|
+
if (index === 0) {
|
|
5256
|
+
return true;
|
|
5257
|
+
}
|
|
5258
|
+
const char = line.charAt(index - 1);
|
|
5259
|
+
return wordBoundaries.includes(char);
|
|
5260
|
+
};
|
|
5261
|
+
const getLineMatchText = (line, lineNumber, query, queryLower, matchCase, matchWholeWord) => {
|
|
5262
|
+
// TODO support multiple matches per line
|
|
5220
5263
|
const lineToQuery = matchCase ? line : line.toLowerCase();
|
|
5221
5264
|
const actualQuery = matchCase ? query : queryLower;
|
|
5222
5265
|
const index = lineToQuery.indexOf(actualQuery);
|
|
5223
|
-
if (index
|
|
5224
|
-
return [
|
|
5225
|
-
type: Match,
|
|
5226
|
-
text: line,
|
|
5227
|
-
start: index,
|
|
5228
|
-
end: index + query.length,
|
|
5229
|
-
lineNumber
|
|
5230
|
-
}];
|
|
5266
|
+
if (index === -1) {
|
|
5267
|
+
return [];
|
|
5231
5268
|
}
|
|
5232
|
-
|
|
5269
|
+
const wordBoundaries = [' ', '\t', '-'];
|
|
5270
|
+
if (matchWholeWord && !doesMatchWord(line, index, wordBoundaries)) {
|
|
5271
|
+
return [];
|
|
5272
|
+
}
|
|
5273
|
+
return [{
|
|
5274
|
+
type: Match,
|
|
5275
|
+
text: line,
|
|
5276
|
+
start: index,
|
|
5277
|
+
end: index + query.length,
|
|
5278
|
+
lineNumber
|
|
5279
|
+
}];
|
|
5233
5280
|
};
|
|
5234
5281
|
|
|
5235
|
-
const getLineMatch = (line, lineNumber, query, queryLower, useRegularExpression, matchCase) => {
|
|
5282
|
+
const getLineMatch = (line, lineNumber, query, queryLower, useRegularExpression, matchCase, matchWholeWord) => {
|
|
5236
5283
|
if (useRegularExpression) {
|
|
5237
5284
|
return getLineMatchRegex(line, lineNumber, query, matchCase);
|
|
5238
5285
|
}
|
|
5239
|
-
return getLineMatchText(line, lineNumber, query, queryLower, matchCase);
|
|
5286
|
+
return getLineMatchText(line, lineNumber, query, queryLower, matchCase, matchWholeWord);
|
|
5240
5287
|
};
|
|
5241
5288
|
|
|
5242
5289
|
const UseRegularExpression = 1 << 1; // 2
|
|
5290
|
+
const MatchWholeWord = 1 << 3; // 8
|
|
5243
5291
|
const MatchCase = 1 << 4; // 16
|
|
5244
5292
|
// 128
|
|
5245
5293
|
|
|
@@ -5250,9 +5298,10 @@ const splitLines = lines => {
|
|
|
5250
5298
|
const textSearchInText = (file, content, query, flags = 0) => {
|
|
5251
5299
|
const matchCase = flags & MatchCase;
|
|
5252
5300
|
const useRegularExpression = flags & UseRegularExpression;
|
|
5301
|
+
const matchWholeWord = flags & MatchWholeWord;
|
|
5253
5302
|
const lines = splitLines(content);
|
|
5254
5303
|
const queryLower = query.toLowerCase();
|
|
5255
|
-
const results = lines.flatMap((line, i) => getLineMatch(line, i, query, queryLower, useRegularExpression, matchCase));
|
|
5304
|
+
const results = lines.flatMap((line, i) => getLineMatch(line, i, query, queryLower, useRegularExpression, matchCase, matchWholeWord));
|
|
5256
5305
|
if (results.length > 0) {
|
|
5257
5306
|
return [{
|
|
5258
5307
|
type: File$3,
|
|
@@ -5371,6 +5420,7 @@ const matchesUri = (uri, relativeRoot, include, exclude) => {
|
|
|
5371
5420
|
}
|
|
5372
5421
|
return true;
|
|
5373
5422
|
};
|
|
5423
|
+
|
|
5374
5424
|
const textSearch = async (scheme, root, query, options, assetDir) => {
|
|
5375
5425
|
string(scheme);
|
|
5376
5426
|
string(root);
|
|
@@ -5402,6 +5452,7 @@ const commandMap = {
|
|
|
5402
5452
|
'ExtensionHostRename.executeprepareRenameProvider': executeprepareRenameProvider,
|
|
5403
5453
|
'ExtensionHostRename.executeRenameProvider': executeRenameProvider,
|
|
5404
5454
|
'Extensions.getExtensions': getExtensions,
|
|
5455
|
+
'Extensions.getExtension': getExtension,
|
|
5405
5456
|
'Extensions.addWebExtension': addWebExtension,
|
|
5406
5457
|
'FileSystemFetch.chmod': chmod$1,
|
|
5407
5458
|
'FileSystemFetch.getBlob': getBlob$1,
|
package/package.json
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lvce-editor/extension-host-worker",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.8.0",
|
|
4
4
|
"description": "Webworker for the extension host functionality in Lvce Editor.",
|
|
5
|
-
"main": "dist/extensionHostWorkerMain.js",
|
|
6
|
-
"type": "module",
|
|
7
5
|
"keywords": [
|
|
8
6
|
"web-worker"
|
|
9
7
|
],
|
|
8
|
+
"license": "MIT",
|
|
10
9
|
"author": "Lvce Editor",
|
|
11
|
-
"
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "dist/extensionHostWorkerMain.js"
|
|
12
12
|
}
|