@lvce-editor/text-search-worker 1.2.0 → 1.4.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.
@@ -18,50 +18,6 @@ const execute = (command, ...args) => {
18
18
  return fn(...args);
19
19
  };
20
20
 
21
- let AssertionError$1 = class AssertionError extends Error {
22
- constructor(message) {
23
- super(message);
24
- this.name = 'AssertionError';
25
- }
26
- };
27
- const getType$2 = value => {
28
- switch (typeof value) {
29
- case 'number':
30
- return 'number';
31
- case 'function':
32
- return 'function';
33
- case 'string':
34
- return 'string';
35
- case 'object':
36
- if (value === null) {
37
- return 'null';
38
- }
39
- if (Array.isArray(value)) {
40
- return 'array';
41
- }
42
- return 'object';
43
- case 'boolean':
44
- return 'boolean';
45
- default:
46
- return 'unknown';
47
- }
48
- };
49
- const string = value => {
50
- const type = getType$2(value);
51
- if (type !== 'string') {
52
- throw new AssertionError$1('expected value to be of type string');
53
- }
54
- };
55
-
56
- const RE_PROTOCOL = /^([a-z\-]+):\/\//;
57
- const getProtocol = uri => {
58
- const protocolMatch = uri.match(RE_PROTOCOL);
59
- if (protocolMatch) {
60
- return protocolMatch[1];
61
- }
62
- return '';
63
- };
64
-
65
21
  const state$3 = {
66
22
  /**
67
23
  * @type {any}
@@ -76,12 +32,12 @@ const set$1 = ipc => {
76
32
  };
77
33
 
78
34
  const Two = '2.0';
79
- class AssertionError extends Error {
35
+ let AssertionError$1 = class AssertionError extends Error {
80
36
  constructor(message) {
81
37
  super(message);
82
38
  this.name = 'AssertionError';
83
39
  }
84
- }
40
+ };
85
41
  const getType$1 = value => {
86
42
  switch (typeof value) {
87
43
  case 'number':
@@ -107,7 +63,7 @@ const getType$1 = value => {
107
63
  const number = value => {
108
64
  const type = getType$1(value);
109
65
  if (type !== 'number') {
110
- throw new AssertionError('expected value to be of type number');
66
+ throw new AssertionError$1('expected value to be of type number');
111
67
  }
112
68
  };
113
69
  const state$1 = {
@@ -131,25 +87,12 @@ const create$3 = () => {
131
87
  const warn = (...args) => {
132
88
  console.warn(...args);
133
89
  };
134
- const withResolvers$1 = () => {
135
- /**
136
- * @type {any}
137
- */
138
- let _resolve;
139
- const promise = new Promise(resolve => {
140
- _resolve = resolve;
141
- });
142
- return {
143
- resolve: _resolve,
144
- promise
145
- };
146
- };
147
90
  const registerPromise = () => {
148
91
  const id = create$3();
149
92
  const {
150
93
  resolve,
151
94
  promise
152
- } = withResolvers$1();
95
+ } = Promise.withResolvers();
153
96
  set(id, resolve);
154
97
  return {
155
98
  id,
@@ -315,7 +258,7 @@ const unwrapJsonRpcResult = responseMessage => {
315
258
  throw new JsonRpcError('unexpected response message');
316
259
  };
317
260
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
318
- const getType = prettyError => {
261
+ const getErrorType = prettyError => {
319
262
  if (prettyError && prettyError.type) {
320
263
  return prettyError.type;
321
264
  }
@@ -338,7 +281,7 @@ const getErrorProperty = (error, prettyError) => {
338
281
  data: {
339
282
  stack: prettyError.stack,
340
283
  codeFrame: prettyError.codeFrame,
341
- type: getType(prettyError),
284
+ type: getErrorType(prettyError),
342
285
  code: prettyError.code,
343
286
  name: prettyError.name
344
287
  }
@@ -451,6 +394,156 @@ const listen$2 = ipc => {
451
394
  set$1(ipc);
452
395
  };
453
396
 
397
+ const FocusSearchInput = 21;
398
+ const FocusSearchReplaceInput = 31;
399
+ const FocusSearchMatchCase = 32;
400
+ const FocusSearchRegex = 33;
401
+ const FocusSearchWholeWord = 34;
402
+ const FocusSearchReplaceAll = 35;
403
+ const FocusSearchPreserveCase = 36;
404
+
405
+ const focusSearchValue$1 = state => {
406
+ return {
407
+ ...state,
408
+ focus: FocusSearchInput
409
+ };
410
+ };
411
+ const focusSearchValueNext$1 = state => {
412
+ const {
413
+ replaceExpanded
414
+ } = state;
415
+ if (replaceExpanded) {
416
+ return focusReplaceValue$1(state);
417
+ }
418
+ return focusMatchCase$1(state);
419
+ };
420
+ const focusMatchCasePrevious = state => {
421
+ const {
422
+ replaceExpanded
423
+ } = state;
424
+ if (replaceExpanded) {
425
+ return focusReplaceValue$1(state);
426
+ }
427
+ return focusSearchValue$1(state);
428
+ };
429
+ const focusReplaceValueNext = state => {
430
+ return focusMatchCase$1(state);
431
+ };
432
+ const focusRegexNext = state => {
433
+ return focusPreserveCase(state);
434
+ };
435
+ const focusReplaceValue$1 = state => {
436
+ return {
437
+ ...state,
438
+ focus: FocusSearchReplaceInput
439
+ };
440
+ };
441
+ const focusMatchCase$1 = state => {
442
+ return {
443
+ ...state,
444
+ focus: FocusSearchMatchCase
445
+ };
446
+ };
447
+ const focusPreserveCase = state => {
448
+ return {
449
+ ...state,
450
+ focus: FocusSearchPreserveCase
451
+ };
452
+ };
453
+ const focusMatchWholeWord = state => {
454
+ return {
455
+ ...state,
456
+ focus: FocusSearchWholeWord
457
+ };
458
+ };
459
+ const focusRegex = state => {
460
+ return {
461
+ ...state,
462
+ focus: FocusSearchRegex
463
+ };
464
+ };
465
+ const focusReplaceAll = state => {
466
+ return {
467
+ ...state,
468
+ focus: FocusSearchReplaceAll
469
+ };
470
+ };
471
+
472
+ const focusMatchCase = state => {
473
+ return {
474
+ ...state,
475
+ focus: FocusSearchMatchCase
476
+ };
477
+ };
478
+
479
+ const focusReplaceValue = state => {
480
+ return {
481
+ ...state,
482
+ focus: FocusSearchReplaceInput
483
+ };
484
+ };
485
+
486
+ const focusSearchValue = state => {
487
+ return {
488
+ ...state,
489
+ focus: FocusSearchInput
490
+ };
491
+ };
492
+
493
+ const focusSearchValueNext = state => {
494
+ const {
495
+ replaceExpanded
496
+ } = state;
497
+ if (replaceExpanded) {
498
+ return focusReplaceValue(state);
499
+ }
500
+ return focusMatchCase(state);
501
+ };
502
+
503
+ class AssertionError extends Error {
504
+ constructor(message) {
505
+ super(message);
506
+ this.name = 'AssertionError';
507
+ }
508
+ }
509
+ const getType = value => {
510
+ switch (typeof value) {
511
+ case 'number':
512
+ return 'number';
513
+ case 'function':
514
+ return 'function';
515
+ case 'string':
516
+ return 'string';
517
+ case 'object':
518
+ if (value === null) {
519
+ return 'null';
520
+ }
521
+ if (Array.isArray(value)) {
522
+ return 'array';
523
+ }
524
+ return 'object';
525
+ case 'boolean':
526
+ return 'boolean';
527
+ default:
528
+ return 'unknown';
529
+ }
530
+ };
531
+ const string = value => {
532
+ const type = getType(value);
533
+ if (type !== 'string') {
534
+ throw new AssertionError('expected value to be of type string');
535
+ }
536
+ };
537
+
538
+ const RE_PROTOCOL = /^([a-z\-]+):\/\//;
539
+ const getProtocol = uri => {
540
+ const protocolMatch = uri.match(RE_PROTOCOL);
541
+ if (protocolMatch) {
542
+ return protocolMatch[1];
543
+ }
544
+ return '';
545
+ };
546
+
454
547
  const textSearch$5 = async (scheme, root, query) => {
455
548
  string(scheme);
456
549
  string(query);
@@ -592,42 +685,9 @@ const textSearch$4 = async (scheme, root, query, options, assetDir) => {
592
685
  return allResults;
593
686
  };
594
687
 
595
- // based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
596
-
597
- const insertInto = (array, start, newItems) => {
598
- const originalLength = array.length;
599
- const newItemsLength = newItems.length;
600
- array.length = originalLength + newItemsLength;
601
- // Move the items after the start index, start from the end so that we don't overwrite any value.
602
- for (let i = originalLength - 1; i >= start; i--) {
603
- array[i + newItemsLength] = array[i];
604
- }
605
- for (let i = 0; i < newItemsLength; i++) {
606
- array[i + start] = newItems[i];
607
- }
608
- };
609
- const push = (array, newItems) => {
610
- insertInto(array, array.length, newItems);
611
- };
612
-
613
- const NotReadableError = 'NotReadableError';
614
-
615
- const isNotReadableError = error => {
616
- return error && error.name === NotReadableError;
617
- };
618
-
619
688
  const Directory = 'directory';
620
689
  const File = 'file';
621
690
 
622
- /**
623
- *
624
- * @param {FileSystemFileHandle} handle
625
- * @returns
626
- */
627
- const getFile = handle => {
628
- return handle.getFile();
629
- };
630
-
631
691
  const dirname = (pathSeparator, path) => {
632
692
  const index = path.lastIndexOf(pathSeparator);
633
693
  if (index === -1) {
@@ -939,6 +999,40 @@ const getDirectoryHandle = async uri => {
939
999
  }
940
1000
  return getDirectoryHandle(dirname$1);
941
1001
  };
1002
+
1003
+ // based on https://github.com/microsoft/vscode/blob/c0769274fa136b45799edeccc0d0a2f645b75caf/src/vs/base/common/arrays.ts#L625 (License MIT)
1004
+
1005
+ const insertInto = (array, start, newItems) => {
1006
+ const originalLength = array.length;
1007
+ const newItemsLength = newItems.length;
1008
+ array.length = originalLength + newItemsLength;
1009
+ // Move the items after the start index, start from the end so that we don't overwrite any value.
1010
+ for (let i = originalLength - 1; i >= start; i--) {
1011
+ array[i + newItemsLength] = array[i];
1012
+ }
1013
+ for (let i = 0; i < newItemsLength; i++) {
1014
+ array[i + start] = newItems[i];
1015
+ }
1016
+ };
1017
+ const push = (array, newItems) => {
1018
+ insertInto(array, array.length, newItems);
1019
+ };
1020
+
1021
+ const NotReadableError = 'NotReadableError';
1022
+
1023
+ const isNotReadableError = error => {
1024
+ return error && error.name === NotReadableError;
1025
+ };
1026
+
1027
+ /**
1028
+ *
1029
+ * @param {FileSystemFileHandle} handle
1030
+ * @returns
1031
+ */
1032
+ const getFile = handle => {
1033
+ return handle.getFile();
1034
+ };
1035
+
942
1036
  const textSearchInText = (file, content, query) => {
943
1037
  const results = [];
944
1038
  const lines = splitLines$1(content);
@@ -966,6 +1060,7 @@ const textSearchInText = (file, content, query) => {
966
1060
  }
967
1061
  return results;
968
1062
  };
1063
+
969
1064
  const textSearchInFile = async (all, handle, absolutePath, query) => {
970
1065
  try {
971
1066
  const file = await getFile(handle);
@@ -980,6 +1075,7 @@ const textSearchInFile = async (all, handle, absolutePath, query) => {
980
1075
  throw error;
981
1076
  }
982
1077
  };
1078
+
983
1079
  const textSearchRecursively = async (all, parent, handle, query) => {
984
1080
  const childHandles = [];
985
1081
  // TODO
@@ -1096,7 +1192,22 @@ const textSearch = async (root, query, options, assetDir) => {
1096
1192
  };
1097
1193
 
1098
1194
  const commandMap = {
1099
- 'TextSearch.textSearch': textSearch
1195
+ 'TextSearch.focusMatchCase': focusMatchCase$1,
1196
+ 'TextSearch.focusMatchCasePrevious': focusMatchCasePrevious,
1197
+ 'TextSearch.focusMatchWholeWord': focusMatchWholeWord,
1198
+ 'TextSearch.focusPreserveCase': focusPreserveCase,
1199
+ 'TextSearch.focusRegex': focusRegex,
1200
+ 'TextSearch.focusRegexNext': focusRegexNext,
1201
+ 'TextSearch.focusReplaceAll': focusReplaceAll,
1202
+ 'TextSearch.focusReplaceValue': focusReplaceValue$1,
1203
+ 'TextSearch.focusReplaceValueNext': focusReplaceValueNext,
1204
+ 'TextSearch.focusSearchValue': focusSearchValue$1,
1205
+ 'TextSearch.focusSearchValueNext': focusSearchValueNext$1,
1206
+ 'TextSearch.textSearch': textSearch,
1207
+ 'SearchView.focusReplaceValue': focusReplaceValue,
1208
+ 'SearchView.focusMatchCase': focusMatchCase,
1209
+ 'SearchView.focusSearchValue': focusSearchValue,
1210
+ 'SearchView.focusSearchValueNext': focusSearchValueNext
1100
1211
  };
1101
1212
 
1102
1213
  const requiresSocket = () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "1.2.0",
3
+ "version": "1.4.0",
4
4
  "description": "",
5
5
  "main": "dist/textSearchWorkerMain.js",
6
6
  "type": "module",