@lvce-editor/text-search-worker 2.11.0 → 2.12.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/textSearchWorkerMain.js +53 -86
- package/package.json +1 -1
|
@@ -24,51 +24,17 @@ const clearSearchResults$1 = state => {
|
|
|
24
24
|
};
|
|
25
25
|
};
|
|
26
26
|
|
|
27
|
-
const state$
|
|
27
|
+
const state$2 = {
|
|
28
28
|
ipc: undefined
|
|
29
29
|
};
|
|
30
30
|
const get$2 = () => {
|
|
31
|
-
return state$
|
|
31
|
+
return state$2.ipc;
|
|
32
32
|
};
|
|
33
33
|
const set$2 = ipc => {
|
|
34
|
-
state$
|
|
34
|
+
state$2.ipc = ipc;
|
|
35
35
|
};
|
|
36
36
|
|
|
37
37
|
const Two = '2.0';
|
|
38
|
-
let AssertionError$1 = class AssertionError extends Error {
|
|
39
|
-
constructor(message) {
|
|
40
|
-
super(message);
|
|
41
|
-
this.name = 'AssertionError';
|
|
42
|
-
}
|
|
43
|
-
};
|
|
44
|
-
const getType$1 = value => {
|
|
45
|
-
switch (typeof value) {
|
|
46
|
-
case 'number':
|
|
47
|
-
return 'number';
|
|
48
|
-
case 'function':
|
|
49
|
-
return 'function';
|
|
50
|
-
case 'string':
|
|
51
|
-
return 'string';
|
|
52
|
-
case 'object':
|
|
53
|
-
if (value === null) {
|
|
54
|
-
return 'null';
|
|
55
|
-
}
|
|
56
|
-
if (Array.isArray(value)) {
|
|
57
|
-
return 'array';
|
|
58
|
-
}
|
|
59
|
-
return 'object';
|
|
60
|
-
case 'boolean':
|
|
61
|
-
return 'boolean';
|
|
62
|
-
default:
|
|
63
|
-
return 'unknown';
|
|
64
|
-
}
|
|
65
|
-
};
|
|
66
|
-
const number$1 = value => {
|
|
67
|
-
const type = getType$1(value);
|
|
68
|
-
if (type !== 'number') {
|
|
69
|
-
throw new AssertionError$1('expected value to be of type number');
|
|
70
|
-
}
|
|
71
|
-
};
|
|
72
38
|
const state$1 = {
|
|
73
39
|
callbacks: Object.create(null)
|
|
74
40
|
};
|
|
@@ -81,11 +47,9 @@ const get$1 = id => {
|
|
|
81
47
|
const remove$1 = id => {
|
|
82
48
|
delete state$1.callbacks[id];
|
|
83
49
|
};
|
|
84
|
-
|
|
85
|
-
id: 0
|
|
86
|
-
};
|
|
50
|
+
let id = 0;
|
|
87
51
|
const create$3 = () => {
|
|
88
|
-
return ++
|
|
52
|
+
return ++id;
|
|
89
53
|
};
|
|
90
54
|
const warn = (...args) => {
|
|
91
55
|
console.warn(...args);
|
|
@@ -102,15 +66,14 @@ const registerPromise = () => {
|
|
|
102
66
|
promise
|
|
103
67
|
};
|
|
104
68
|
};
|
|
105
|
-
const resolve = (id,
|
|
106
|
-
number$1(id);
|
|
69
|
+
const resolve = (id, response) => {
|
|
107
70
|
const fn = get$1(id);
|
|
108
71
|
if (!fn) {
|
|
109
|
-
console.log(
|
|
72
|
+
console.log(response);
|
|
110
73
|
warn(`callback ${id} may already be disposed`);
|
|
111
74
|
return;
|
|
112
75
|
}
|
|
113
|
-
fn(
|
|
76
|
+
fn(response);
|
|
114
77
|
remove$1(id);
|
|
115
78
|
};
|
|
116
79
|
const create$2 = (method, params) => {
|
|
@@ -332,32 +295,42 @@ const defaultRequiresSocket = () => {
|
|
|
332
295
|
return false;
|
|
333
296
|
};
|
|
334
297
|
const defaultResolve = resolve;
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
let execute;
|
|
339
|
-
let preparePrettyError;
|
|
340
|
-
let logError;
|
|
341
|
-
let resolve;
|
|
342
|
-
let requiresSocket;
|
|
298
|
+
|
|
299
|
+
// TODO maybe remove this in v6 or v7, only accept options object to simplify the code
|
|
300
|
+
const normalizeParams = args => {
|
|
343
301
|
if (args.length === 1) {
|
|
344
|
-
const
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
message = args[1];
|
|
355
|
-
execute = args[2];
|
|
356
|
-
resolve = args[3];
|
|
357
|
-
preparePrettyError = args[4];
|
|
358
|
-
logError = args[5];
|
|
359
|
-
requiresSocket = args[6];
|
|
302
|
+
const options = args[0];
|
|
303
|
+
return {
|
|
304
|
+
ipc: options.ipc,
|
|
305
|
+
message: options.message,
|
|
306
|
+
execute: options.execute,
|
|
307
|
+
resolve: options.resolve || defaultResolve,
|
|
308
|
+
preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
|
|
309
|
+
logError: options.logError || defaultLogError,
|
|
310
|
+
requiresSocket: options.requiresSocket || defaultRequiresSocket
|
|
311
|
+
};
|
|
360
312
|
}
|
|
313
|
+
return {
|
|
314
|
+
ipc: args[0],
|
|
315
|
+
message: args[1],
|
|
316
|
+
execute: args[2],
|
|
317
|
+
resolve: args[3],
|
|
318
|
+
preparePrettyError: args[4],
|
|
319
|
+
logError: args[5],
|
|
320
|
+
requiresSocket: args[6]
|
|
321
|
+
};
|
|
322
|
+
};
|
|
323
|
+
const handleJsonRpcMessage = async (...args) => {
|
|
324
|
+
const options = normalizeParams(args);
|
|
325
|
+
const {
|
|
326
|
+
message,
|
|
327
|
+
ipc,
|
|
328
|
+
execute,
|
|
329
|
+
resolve,
|
|
330
|
+
preparePrettyError,
|
|
331
|
+
logError,
|
|
332
|
+
requiresSocket
|
|
333
|
+
} = options;
|
|
361
334
|
if ('id' in message) {
|
|
362
335
|
if ('method' in message) {
|
|
363
336
|
const response = await getResponse(message, ipc, execute, preparePrettyError, logError, requiresSocket);
|
|
@@ -378,15 +351,19 @@ const handleJsonRpcMessage = async (...args) => {
|
|
|
378
351
|
}
|
|
379
352
|
throw new JsonRpcError('unexpected message');
|
|
380
353
|
};
|
|
381
|
-
const
|
|
354
|
+
const invokeHelper = async (ipc, method, params, useSendAndTransfer) => {
|
|
382
355
|
const {
|
|
383
356
|
message,
|
|
384
357
|
promise
|
|
385
358
|
} = create$2(method, params);
|
|
386
|
-
|
|
359
|
+
{
|
|
360
|
+
ipc.send(message);
|
|
361
|
+
}
|
|
387
362
|
const responseMessage = await promise;
|
|
388
|
-
|
|
389
|
-
|
|
363
|
+
return unwrapJsonRpcResult(responseMessage);
|
|
364
|
+
};
|
|
365
|
+
const invoke$2 = (ipc, method, ...params) => {
|
|
366
|
+
return invokeHelper(ipc, method, params);
|
|
390
367
|
};
|
|
391
368
|
|
|
392
369
|
const invoke$1 = (method, ...params) => {
|
|
@@ -615,18 +592,12 @@ const UiStrings = {
|
|
|
615
592
|
ManyResultsInManyFiles: '{PH1} results in {PH2} files',
|
|
616
593
|
ReplaceAll: 'Replace All',
|
|
617
594
|
Replace: 'Replace',
|
|
618
|
-
ConfirmReplaceAll: 'Replace All?',
|
|
619
595
|
ConfirmReplaceOneOccurrenceInOneFile: "Replace 1 occurrence across 1 file with '{PH1}'",
|
|
620
596
|
ConfirmReplaceOneOccurrenceInOneFileNoValue: 'Replace 1 occurrence across 1 file',
|
|
621
597
|
ConfirmReplaceManyOccurrencesInOneFile: "Replace {PH1} occurrences across 1 file with '{PH2}'",
|
|
622
598
|
ConfirmReplaceManyOccurrencesInOneFileNoValue: 'Replace {PH1} occurrences across 1 file',
|
|
623
599
|
ConfirmReplaceManyOccurrencesInManyFiles: "Replace {PH1} occurrences across {PH2} files with '{PH3}'",
|
|
624
600
|
ConfirmReplaceManyOccurrencesInManyFilesNoValue: 'Replace {PH1} occurrences across {PH2} files',
|
|
625
|
-
ReplacedOneOccurrenceInOneFile: "Replaced 1 occurrence across 1 file with '{PH1}'",
|
|
626
|
-
ReplacedManyOccurrencesInOneFile: "Replaced {PH1} occurrences across 1 file with '{PH2}'",
|
|
627
|
-
ReplacedManyOccurrencesInManyFiles: "Replaced {PH1} occurrences across {PH2} files with '{PH3}'",
|
|
628
|
-
CopyPath: 'Copy Path',
|
|
629
|
-
Dismiss: 'Dismiss',
|
|
630
601
|
Refresh: 'Refresh',
|
|
631
602
|
ClearSearchResults: 'Clear Search Results',
|
|
632
603
|
OpenNewSearchEditor: 'Open New Search Editor',
|
|
@@ -1546,10 +1517,10 @@ const textSearch$5 = async (scheme, root, query) => {
|
|
|
1546
1517
|
|
|
1547
1518
|
const normalizeLine$1 = line => {
|
|
1548
1519
|
if (line.startsWith('Error: ')) {
|
|
1549
|
-
return line.slice(
|
|
1520
|
+
return line.slice('Error: '.length);
|
|
1550
1521
|
}
|
|
1551
1522
|
if (line.startsWith('VError: ')) {
|
|
1552
|
-
return line.slice(
|
|
1523
|
+
return line.slice('VError: '.length);
|
|
1553
1524
|
}
|
|
1554
1525
|
return line;
|
|
1555
1526
|
};
|
|
@@ -1941,11 +1912,7 @@ replaceTraps(oldTraps => ({
|
|
|
1941
1912
|
}));
|
|
1942
1913
|
|
|
1943
1914
|
const state = {
|
|
1944
|
-
|
|
1945
|
-
eventId: 0,
|
|
1946
|
-
dbVersion: 1,
|
|
1947
|
-
cachedDb: undefined
|
|
1948
|
-
};
|
|
1915
|
+
dbVersion: 1};
|
|
1949
1916
|
|
|
1950
1917
|
// TODO high memory usage in idb because of transactionDoneMap
|
|
1951
1918
|
|