@lvce-editor/text-search-worker 6.4.0 → 6.5.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.
@@ -632,12 +632,12 @@ const getErrorConstructor = (message, type) => {
632
632
  switch (type) {
633
633
  case DomException:
634
634
  return DOMException;
635
- case TypeError$1:
636
- return TypeError;
637
- case SyntaxError$1:
638
- return SyntaxError;
639
635
  case ReferenceError$1:
640
636
  return ReferenceError;
637
+ case SyntaxError$1:
638
+ return SyntaxError;
639
+ case TypeError$1:
640
+ return TypeError;
641
641
  default:
642
642
  return Error;
643
643
  }
@@ -793,27 +793,27 @@ const getErrorProperty = (error, prettyError) => {
793
793
  if (error && error.code === E_COMMAND_NOT_FOUND) {
794
794
  return {
795
795
  code: MethodNotFound,
796
- message: error.message,
797
- data: error.stack
796
+ data: error.stack,
797
+ message: error.message
798
798
  };
799
799
  }
800
800
  return {
801
801
  code: Custom,
802
- message: prettyError.message,
803
802
  data: {
804
- stack: getStack(prettyError),
805
- codeFrame: prettyError.codeFrame,
806
- type: getErrorType(prettyError),
807
803
  code: prettyError.code,
808
- name: prettyError.name
809
- }
804
+ codeFrame: prettyError.codeFrame,
805
+ name: prettyError.name,
806
+ stack: getStack(prettyError),
807
+ type: getErrorType(prettyError)
808
+ },
809
+ message: prettyError.message
810
810
  };
811
811
  };
812
812
  const create$1$1 = (id, error) => {
813
813
  return {
814
- jsonrpc: Two$1,
814
+ error,
815
815
  id,
816
- error
816
+ jsonrpc: Two$1
817
817
  };
818
818
  };
819
819
  const getErrorResponse = (id, error, preparePrettyError, logError) => {
@@ -824,8 +824,8 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
824
824
  };
825
825
  const create$e = (message, result) => {
826
826
  return {
827
- jsonrpc: Two$1,
828
827
  id: message.id,
828
+ jsonrpc: Two$1,
829
829
  result: result ?? null
830
830
  };
831
831
  };
@@ -835,14 +835,14 @@ const getSuccessResponse = (message, result) => {
835
835
  };
836
836
  const getErrorResponseSimple = (id, error) => {
837
837
  return {
838
- jsonrpc: Two$1,
839
- id,
840
838
  error: {
841
839
  code: Custom,
840
+ data: error,
842
841
  // @ts-ignore
843
- message: error.message,
844
- data: error
845
- }
842
+ message: error.message
843
+ },
844
+ id,
845
+ jsonrpc: Two$1
846
846
  };
847
847
  };
848
848
  const getResponse = async (message, ipc, execute, preparePrettyError, logError, requiresSocket) => {
@@ -872,35 +872,35 @@ const normalizeParams = args => {
872
872
  if (args.length === 1) {
873
873
  const options = args[0];
874
874
  return {
875
+ execute: options.execute,
875
876
  ipc: options.ipc,
877
+ logError: options.logError || defaultLogError,
876
878
  message: options.message,
877
- execute: options.execute,
878
- resolve: options.resolve || defaultResolve,
879
879
  preparePrettyError: options.preparePrettyError || defaultPreparePrettyError,
880
- logError: options.logError || defaultLogError,
881
- requiresSocket: options.requiresSocket || defaultRequiresSocket
880
+ requiresSocket: options.requiresSocket || defaultRequiresSocket,
881
+ resolve: options.resolve || defaultResolve
882
882
  };
883
883
  }
884
884
  return {
885
+ execute: args[2],
885
886
  ipc: args[0],
887
+ logError: args[5],
886
888
  message: args[1],
887
- execute: args[2],
888
- resolve: args[3],
889
889
  preparePrettyError: args[4],
890
- logError: args[5],
891
- requiresSocket: args[6]
890
+ requiresSocket: args[6],
891
+ resolve: args[3]
892
892
  };
893
893
  };
894
894
  const handleJsonRpcMessage = async (...args) => {
895
895
  const options = normalizeParams(args);
896
896
  const {
897
- message,
898
- ipc,
899
897
  execute,
900
- resolve,
901
- preparePrettyError,
898
+ ipc,
902
899
  logError,
903
- requiresSocket
900
+ message,
901
+ preparePrettyError,
902
+ requiresSocket,
903
+ resolve
904
904
  } = options;
905
905
  if ('id' in message) {
906
906
  if ('method' in message) {
@@ -961,7 +961,6 @@ const registerPromise = map => {
961
961
  };
962
962
  };
963
963
 
964
- // @ts-ignore
965
964
  const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer) => {
966
965
  const {
967
966
  id,
@@ -1043,6 +1042,41 @@ const listen$1 = async (module, options) => {
1043
1042
  return ipc;
1044
1043
  };
1045
1044
 
1045
+ const create$a = async ({
1046
+ commandMap,
1047
+ isMessagePortOpen = true,
1048
+ messagePort
1049
+ }) => {
1050
+ // TODO create a commandMap per rpc instance
1051
+ register(commandMap);
1052
+ const rawIpc = await IpcParentWithMessagePort$1.create({
1053
+ isMessagePortOpen,
1054
+ messagePort
1055
+ });
1056
+ const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1057
+ handleIpc(ipc);
1058
+ const rpc = createRpc(ipc);
1059
+ messagePort.start();
1060
+ return rpc;
1061
+ };
1062
+
1063
+ const create$9 = async ({
1064
+ commandMap,
1065
+ isMessagePortOpen,
1066
+ send
1067
+ }) => {
1068
+ const {
1069
+ port1,
1070
+ port2
1071
+ } = new MessageChannel();
1072
+ await send(port1);
1073
+ return create$a({
1074
+ commandMap,
1075
+ isMessagePortOpen,
1076
+ messagePort: port2
1077
+ });
1078
+ };
1079
+
1046
1080
  const createSharedLazyRpc = factory => {
1047
1081
  let rpcPromise;
1048
1082
  const getOrCreate = () => {
@@ -1071,13 +1105,13 @@ const createSharedLazyRpc = factory => {
1071
1105
  };
1072
1106
  };
1073
1107
 
1074
- const create$a = async ({
1108
+ const create$8 = async ({
1075
1109
  commandMap,
1076
1110
  isMessagePortOpen,
1077
1111
  send
1078
1112
  }) => {
1079
1113
  return createSharedLazyRpc(() => {
1080
- return create$5({
1114
+ return create$9({
1081
1115
  commandMap,
1082
1116
  isMessagePortOpen,
1083
1117
  send
@@ -1105,7 +1139,7 @@ const getProtocol$1 = () => {
1105
1139
  return location.protocol;
1106
1140
  };
1107
1141
 
1108
- const create$9 = async ({
1142
+ const create$7 = async ({
1109
1143
  commandMap,
1110
1144
  webSocket
1111
1145
  }) => {
@@ -1120,7 +1154,7 @@ const create$9 = async ({
1120
1154
  return rpc;
1121
1155
  };
1122
1156
 
1123
- const create$8 = async ({
1157
+ const create$6 = async ({
1124
1158
  commandMap,
1125
1159
  type
1126
1160
  }) => {
@@ -1128,60 +1162,25 @@ const create$8 = async ({
1128
1162
  const protocol = getProtocol$1();
1129
1163
  const wsUrl = getWebSocketUrl(type, host, protocol);
1130
1164
  const webSocket = new WebSocket(wsUrl);
1131
- const rpc = await create$9({
1165
+ const rpc = await create$7({
1132
1166
  commandMap,
1133
1167
  webSocket
1134
1168
  });
1135
1169
  return rpc;
1136
1170
  };
1137
1171
 
1138
- const create$7 = async ({
1172
+ const create$5 = async ({
1139
1173
  commandMap,
1140
1174
  type
1141
1175
  }) => {
1142
1176
  return createSharedLazyRpc(() => {
1143
- return create$8({
1177
+ return create$6({
1144
1178
  commandMap,
1145
1179
  type
1146
1180
  });
1147
1181
  });
1148
1182
  };
1149
1183
 
1150
- const create$6 = async ({
1151
- commandMap,
1152
- isMessagePortOpen = true,
1153
- messagePort
1154
- }) => {
1155
- // TODO create a commandMap per rpc instance
1156
- register(commandMap);
1157
- const rawIpc = await IpcParentWithMessagePort$1.create({
1158
- isMessagePortOpen,
1159
- messagePort
1160
- });
1161
- const ipc = IpcParentWithMessagePort$1.wrap(rawIpc);
1162
- handleIpc(ipc);
1163
- const rpc = createRpc(ipc);
1164
- messagePort.start();
1165
- return rpc;
1166
- };
1167
-
1168
- const create$5 = async ({
1169
- commandMap,
1170
- isMessagePortOpen,
1171
- send
1172
- }) => {
1173
- const {
1174
- port1,
1175
- port2
1176
- } = new MessageChannel();
1177
- await send(port1);
1178
- return create$6({
1179
- commandMap,
1180
- isMessagePortOpen,
1181
- messagePort: port2
1182
- });
1183
- };
1184
-
1185
1184
  const create$4 = async ({
1186
1185
  commandMap
1187
1186
  }) => {
@@ -1193,141 +1192,6 @@ const create$4 = async ({
1193
1192
  return rpc;
1194
1193
  };
1195
1194
 
1196
- const Alert = 'alert';
1197
- const Button$3 = 'button';
1198
- const CheckBox = 'checkbox';
1199
- const None$2 = 'none';
1200
- const ScrollBar$1 = 'scrollbar';
1201
- const Status = 'status';
1202
- const ToolBar = 'toolbar';
1203
- const Tree$1 = 'tree';
1204
- const TreeItem$1 = 'treeitem';
1205
-
1206
- const Actions = 'Actions';
1207
- const Badge = 'Badge';
1208
- const Chevron = 'Chevron';
1209
- const CloseMaskIcon = 'MaskIcon MaskIconClose';
1210
- const Empty$1 = '';
1211
- const FileIcon = 'FileIcon';
1212
- const FocusOutline = 'FocusOutline';
1213
- const Grow = 'Grow';
1214
- const Highlight = 'Highlight';
1215
- const HighlightDeleted = 'HighlightDeleted';
1216
- const HighlightInserted = 'HighlightInserted';
1217
- const IconButton = 'IconButton';
1218
- const IconButtonDisabled = 'IconButtonDisabled';
1219
- const Label = 'Label';
1220
- const List$1 = 'List';
1221
- const MaskIcon = 'MaskIcon';
1222
- const MaskIconBook = 'MaskIconBook';
1223
- const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1224
- const MaskIconChevronDown = 'MaskIconChevronDown';
1225
- const MaskIconChevronRight = 'MaskIconChevronRight';
1226
- const MaskIconEllipsis = 'MaskIconEllipsis';
1227
- const MaskIconExclude = 'MaskIconExclude';
1228
- const MaskIconPreserveCase = 'MaskIconPreserveCase';
1229
- const MaskIconRegex = 'MaskIconRegex';
1230
- const MaskIconReplaceAll = 'MaskIconReplaceAll';
1231
- const MaskIconWholeWord = 'MaskIconWholeWord';
1232
- const MultilineInputBox = 'MultilineInputBox';
1233
- const ScrollBar = 'ScrollBar';
1234
- const ScrollBarThumb = 'ScrollBarThumb';
1235
- const ScrollBarVertical = 'ScrollBarVertical';
1236
- const Search$2 = 'Search';
1237
- const SearchField = 'SearchField';
1238
- const SearchFieldButton = 'SearchFieldButton';
1239
- const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
1240
- const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
1241
- const SearchFieldButtons = 'SearchFieldButtons';
1242
- const SearchFieldContainer = 'SearchFieldContainer';
1243
- const SearchFieldError = 'SearchFieldError';
1244
- const SearchHeader = 'SearchHeader';
1245
- const SearchHeaderDetails = 'SearchHeaderDetails';
1246
- const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1247
- const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
1248
- const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
1249
- const SearchHeaderTop = 'SearchHeaderTop';
1250
- const SearchHeaderTopRight = 'SearchHeaderTopRight';
1251
- const SearchInputError = 'SearchInputError';
1252
- const SearchRemove = 'SearchRemove';
1253
- const SearchToggleButton = 'SearchToggleButton';
1254
- const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1255
- const SourceControlBadge = 'SourceControlBadge';
1256
- const ToggleDetails = 'ToggleDetails';
1257
- const Tree = 'Tree';
1258
- const TreeItem = 'TreeItem';
1259
- const TreeItemActive = 'TreeItemActive';
1260
- const TreeItems$1 = 'TreeItems';
1261
- const Viewlet = 'Viewlet';
1262
- const ViewletSearchMessage = 'ViewletSearchMessage';
1263
- const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1264
-
1265
- const File$2 = 7;
1266
-
1267
- const Button$2 = 1;
1268
- const Div = 4;
1269
- const Span = 8;
1270
- const Text = 12;
1271
- const Img = 17;
1272
- const Ins = 20;
1273
- const Del = 21;
1274
- const H4 = 24;
1275
- const TextArea = 62;
1276
- const Reference = 100;
1277
-
1278
- const Button$1 = 'event.button';
1279
- const ClientX = 'event.clientX';
1280
- const ClientY = 'event.clientY';
1281
- const DeltaMode = 'event.deltaMode';
1282
- const DeltaY = 'event.deltaY';
1283
- const TargetName = 'event.target.name';
1284
- const TargetSelectionEnd = 'event.target.selectionEnd';
1285
- const TargetSelectionStart = 'event.target.selectionStart';
1286
- const TargetValue = 'event.target.value';
1287
-
1288
- const Script$1 = 2;
1289
-
1290
- const Search$1 = 18;
1291
- const InputContextMenu = 91;
1292
-
1293
- const Separator = 1;
1294
- const None$1 = 0;
1295
-
1296
- const LeftClick = 0;
1297
-
1298
- const Electron = 2;
1299
- const Remote = 3;
1300
-
1301
- const IconThemeWorker = 7009;
1302
- const RendererWorker = 1;
1303
- const SearchProcess = 77;
1304
-
1305
- const File$1 = 1;
1306
- const Match$1 = 2;
1307
-
1308
- const FocusElementByName = 'Viewlet.focusElementByName';
1309
- const SetCss = 'Viewlet.setCss';
1310
- const SetFocusContext = 'Viewlet.setFocusContext';
1311
- const SetValueByName = 'Viewlet.setValueByName';
1312
- const SetPatches = 'Viewlet.setPatches';
1313
-
1314
- const Empty = 0;
1315
- const FocusIgnoreFiles = 1012;
1316
- const FocusSearch = 1013;
1317
- const FocusSearchExcludeInput = 1008;
1318
- const FocusSearchIncludeInput = 1007;
1319
- const FocusSearchInput = 21;
1320
- const FocusSearchMatchCase = 32;
1321
- const FocusSearchOpenEditors = 1011;
1322
- const FocusSearchPreserveCase = 36;
1323
- const FocusSearchRegex = 33;
1324
- const FocusSearchReplaceAll = 35;
1325
- const FocusSearchReplaceInput = 31;
1326
- const FocusSearchResults = 22;
1327
- const FocusSearchWholeWord = 34;
1328
- const FocusToggleDetails = 1010;
1329
- const FocusToggleReplace = 1020;
1330
-
1331
1195
  const createMockRpc = ({
1332
1196
  commandMap
1333
1197
  }) => {
@@ -1396,6 +1260,56 @@ const create$3 = rpcId => {
1396
1260
  };
1397
1261
  };
1398
1262
 
1263
+ const Alert = 'alert';
1264
+ const Button$3 = 'button';
1265
+ const CheckBox = 'checkbox';
1266
+ const None$2 = 'none';
1267
+ const ScrollBar$1 = 'scrollbar';
1268
+ const Status = 'status';
1269
+ const ToolBar = 'toolbar';
1270
+ const Tree$1 = 'tree';
1271
+ const TreeItem$1 = 'treeitem';
1272
+
1273
+ const File$2 = 7;
1274
+
1275
+ const Button$2 = 'event.button';
1276
+ const ClientX = 'event.clientX';
1277
+ const ClientY = 'event.clientY';
1278
+ const DeltaMode = 'event.deltaMode';
1279
+ const DeltaY = 'event.deltaY';
1280
+ const TargetName = 'event.target.name';
1281
+ const TargetSelectionEnd = 'event.target.selectionEnd';
1282
+ const TargetSelectionStart = 'event.target.selectionStart';
1283
+ const TargetValue = 'event.target.value';
1284
+
1285
+ const Script$1 = 2;
1286
+
1287
+ const Search$2 = 18;
1288
+ const InputContextMenu = 91;
1289
+
1290
+ const Separator = 1;
1291
+ const None$1 = 0;
1292
+
1293
+ const LeftClick = 0;
1294
+
1295
+ const Electron = 2;
1296
+ const Remote = 3;
1297
+
1298
+ const IconThemeWorker = 7009;
1299
+ const RendererWorker = 1;
1300
+ const SearchProcess = 77;
1301
+
1302
+ const File$1 = 1;
1303
+ const Match$1 = 2;
1304
+
1305
+ const FocusElementByName = 'Viewlet.focusElementByName';
1306
+ const SetCss = 'Viewlet.setCss';
1307
+ const SetFocusContext = 'Viewlet.setFocusContext';
1308
+ const SetValueByName = 'Viewlet.setValueByName';
1309
+ const SetPatches = 'Viewlet.setPatches';
1310
+
1311
+ const FocusSearch$1 = 1013;
1312
+
1399
1313
  const {
1400
1314
  invoke: invoke$2,
1401
1315
  set: set$3
@@ -1482,7 +1396,7 @@ const create$2 = () => {
1482
1396
  },
1483
1397
  getKeys() {
1484
1398
  return Object.keys(states).map(key => {
1485
- return Number.parseInt(key);
1399
+ return Number.parseFloat(key);
1486
1400
  });
1487
1401
  },
1488
1402
  registerCommands(commandMap) {
@@ -1524,6 +1438,37 @@ const create$2 = () => {
1524
1438
  return fn(newState, ...args);
1525
1439
  };
1526
1440
  return wrapped;
1441
+ },
1442
+ wrapLoadContent(fn) {
1443
+ const wrapped = async (uid, ...args) => {
1444
+ const {
1445
+ newState,
1446
+ oldState
1447
+ } = states[uid];
1448
+ const result = await fn(newState, ...args);
1449
+ const {
1450
+ error,
1451
+ state
1452
+ } = result;
1453
+ if (oldState === state || newState === state) {
1454
+ return {
1455
+ error
1456
+ };
1457
+ }
1458
+ const latestOld = states[uid];
1459
+ const latestNew = {
1460
+ ...latestOld.newState,
1461
+ ...state
1462
+ };
1463
+ states[uid] = {
1464
+ newState: latestNew,
1465
+ oldState: latestOld.oldState
1466
+ };
1467
+ return {
1468
+ error
1469
+ };
1470
+ };
1471
+ return wrapped;
1527
1472
  }
1528
1473
  };
1529
1474
  };
@@ -1531,6 +1476,93 @@ const terminate = () => {
1531
1476
  globalThis.close();
1532
1477
  };
1533
1478
 
1479
+ const Actions = 'Actions';
1480
+ const Badge = 'Badge';
1481
+ const Chevron = 'Chevron';
1482
+ const CloseMaskIcon = 'MaskIcon MaskIconClose';
1483
+ const Empty$1 = '';
1484
+ const FileIcon = 'FileIcon';
1485
+ const FocusOutline = 'FocusOutline';
1486
+ const Grow = 'Grow';
1487
+ const Highlight = 'Highlight';
1488
+ const HighlightDeleted = 'HighlightDeleted';
1489
+ const HighlightInserted = 'HighlightInserted';
1490
+ const IconButton = 'IconButton';
1491
+ const IconButtonDisabled = 'IconButtonDisabled';
1492
+ const Label = 'Label';
1493
+ const List$1 = 'List';
1494
+ const MaskIcon = 'MaskIcon';
1495
+ const MaskIconBook = 'MaskIconBook';
1496
+ const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1497
+ const MaskIconChevronDown = 'MaskIconChevronDown';
1498
+ const MaskIconChevronRight = 'MaskIconChevronRight';
1499
+ const MaskIconEllipsis = 'MaskIconEllipsis';
1500
+ const MaskIconExclude = 'MaskIconExclude';
1501
+ const MaskIconPreserveCase = 'MaskIconPreserveCase';
1502
+ const MaskIconRegex = 'MaskIconRegex';
1503
+ const MaskIconReplaceAll = 'MaskIconReplaceAll';
1504
+ const MaskIconWholeWord = 'MaskIconWholeWord';
1505
+ const MultilineInputBox = 'MultilineInputBox';
1506
+ const ScrollBar = 'ScrollBar';
1507
+ const ScrollBarThumb = 'ScrollBarThumb';
1508
+ const ScrollBarVertical = 'ScrollBarVertical';
1509
+ const Search$1 = 'Search';
1510
+ const SearchField = 'SearchField';
1511
+ const SearchFieldButton = 'SearchFieldButton';
1512
+ const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
1513
+ const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
1514
+ const SearchFieldButtons = 'SearchFieldButtons';
1515
+ const SearchFieldContainer = 'SearchFieldContainer';
1516
+ const SearchFieldError = 'SearchFieldError';
1517
+ const SearchHeader = 'SearchHeader';
1518
+ const SearchHeaderDetails = 'SearchHeaderDetails';
1519
+ const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1520
+ const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
1521
+ const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
1522
+ const SearchHeaderTop = 'SearchHeaderTop';
1523
+ const SearchHeaderTopRight = 'SearchHeaderTopRight';
1524
+ const SearchInputError = 'SearchInputError';
1525
+ const SearchRemove = 'SearchRemove';
1526
+ const SearchToggleButton = 'SearchToggleButton';
1527
+ const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1528
+ const SourceControlBadge = 'SourceControlBadge';
1529
+ const ToggleDetails = 'ToggleDetails';
1530
+ const Tree = 'Tree';
1531
+ const TreeItem = 'TreeItem';
1532
+ const TreeItemActive = 'TreeItemActive';
1533
+ const TreeItems$1 = 'TreeItems';
1534
+ const Viewlet = 'Viewlet';
1535
+ const ViewletSearchMessage = 'ViewletSearchMessage';
1536
+ const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1537
+
1538
+ const Button$1 = 1;
1539
+ const Div = 4;
1540
+ const Span = 8;
1541
+ const Text = 12;
1542
+ const Img = 17;
1543
+ const Ins = 20;
1544
+ const Del = 21;
1545
+ const H4 = 24;
1546
+ const TextArea = 62;
1547
+ const Reference = 100;
1548
+
1549
+ const Empty = 0;
1550
+ const FocusIgnoreFiles = 1012;
1551
+ const FocusSearch = 1013;
1552
+ const FocusSearchExcludeInput = 1008;
1553
+ const FocusSearchIncludeInput = 1007;
1554
+ const FocusSearchInput = 21;
1555
+ const FocusSearchMatchCase = 32;
1556
+ const FocusSearchOpenEditors = 1011;
1557
+ const FocusSearchPreserveCase = 36;
1558
+ const FocusSearchRegex = 33;
1559
+ const FocusSearchReplaceAll = 35;
1560
+ const FocusSearchReplaceInput = 31;
1561
+ const FocusSearchResults = 22;
1562
+ const FocusSearchWholeWord = 34;
1563
+ const FocusToggleDetails = 1010;
1564
+ const FocusToggleReplace = 1020;
1565
+
1534
1566
  const mergeClassNames = (...classNames) => {
1535
1567
  return classNames.filter(Boolean).join(' ');
1536
1568
  };
@@ -2026,15 +2058,38 @@ const hasUseIgnoreFiles = flags => {
2026
2058
  return (flags & UseIgnoreFiles) === UseIgnoreFiles;
2027
2059
  };
2028
2060
 
2061
+ const getTopHeight = flags => {
2062
+ if (flags & ReplaceExpanded && flags & DetailsExpanded) {
2063
+ return 190;
2064
+ }
2065
+ if (flags & DetailsExpanded) {
2066
+ return 158;
2067
+ }
2068
+ if (flags & ReplaceExpanded) {
2069
+ return 93;
2070
+ }
2071
+ return 61;
2072
+ };
2073
+
2074
+ const getHeaderHeightForFlags = (headerHeight, oldFlags, newFlags) => {
2075
+ const oldTopHeight = getTopHeight(oldFlags);
2076
+ const newTopHeight = getTopHeight(newFlags);
2077
+ const warningHeight = Math.max(headerHeight - oldTopHeight, 0);
2078
+ return newTopHeight + warningHeight;
2079
+ };
2080
+
2029
2081
  const collapseDetails = state => {
2030
2082
  const {
2031
- flags
2083
+ flags,
2084
+ headerHeight
2032
2085
  } = state;
2086
+ const newFlags = flags & -33;
2033
2087
  return {
2034
2088
  ...state,
2035
- flags: flags & -33,
2089
+ flags: newFlags,
2036
2090
  focus: FocusSearchInput,
2037
- focusSource: Script
2091
+ focusSource: Script,
2092
+ headerHeight: getHeaderHeightForFlags(headerHeight, flags, newFlags)
2038
2093
  };
2039
2094
  };
2040
2095
 
@@ -2107,6 +2162,7 @@ const create$1 = ({
2107
2162
  };
2108
2163
 
2109
2164
  const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, value = '', replacement = '', platform) => {
2165
+ const headerHeight = getTopHeight(0);
2110
2166
  const state = {
2111
2167
  disposed: false,
2112
2168
  fileCount: 0,
@@ -2120,8 +2176,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
2120
2176
  x,
2121
2177
  y,
2122
2178
  ...create$1({
2123
- headerHeight: 61,
2124
- // TODO
2179
+ headerHeight,
2125
2180
  itemHeight: itemHeight || 22,
2126
2181
  minimumSliderSize: minimumSliderSize
2127
2182
  }),
@@ -2673,13 +2728,16 @@ const enableRenderFolderPaths = state => {
2673
2728
 
2674
2729
  const expandDetails = state => {
2675
2730
  const {
2676
- flags
2731
+ flags,
2732
+ headerHeight
2677
2733
  } = state;
2734
+ const newFlags = flags | DetailsExpanded;
2678
2735
  return {
2679
2736
  ...state,
2680
- flags: flags | DetailsExpanded,
2737
+ flags: newFlags,
2681
2738
  focus: FocusSearchIncludeInput,
2682
- focusSource: Script
2739
+ focusSource: Script,
2740
+ headerHeight: getHeaderHeightForFlags(headerHeight, flags, newFlags)
2683
2741
  };
2684
2742
  };
2685
2743
 
@@ -3006,7 +3064,7 @@ const getMenuEntriesList = (state, props) => {
3006
3064
  };
3007
3065
 
3008
3066
  const getMenuEntries = (state, props) => {
3009
- if (props.menuId === Search$1) {
3067
+ if (props.menuId === Search$2) {
3010
3068
  return getMenuEntriesList(state, props);
3011
3069
  }
3012
3070
  if (props.menuId === InputContextMenu) {
@@ -3016,7 +3074,7 @@ const getMenuEntries = (state, props) => {
3016
3074
  };
3017
3075
 
3018
3076
  const getMenuEntryIds = () => {
3019
- return [Search$1, InputContextMenu];
3077
+ return [Search$2, InputContextMenu];
3020
3078
  };
3021
3079
 
3022
3080
  const ClearAll$1 = 'ClearAll';
@@ -3095,6 +3153,24 @@ const getProtocol = uri => {
3095
3153
  return '';
3096
3154
  };
3097
3155
 
3156
+ const measureTextHeight = (text, fontFamily, fontSize, lineHeight, width) => {
3157
+ return invoke$1('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, `${lineHeight}px`, width);
3158
+ };
3159
+
3160
+ const SearchWarningFontFamily = 'system-ui';
3161
+ const SearchWarningFontSize = 12;
3162
+ const SearchWarningLineHeight = 18;
3163
+ const SearchWarningHorizontalPadding = 10;
3164
+ const SearchWarningVerticalPadding = 8;
3165
+ const getSearchWarningMessageHeight = async (limitHitWarning, width) => {
3166
+ if (!limitHitWarning) {
3167
+ return 0;
3168
+ }
3169
+ const availableWidth = Math.max(width - SearchWarningHorizontalPadding, 1);
3170
+ const textHeight = await measureTextHeight(limitHitWarning, SearchWarningFontFamily, SearchWarningFontSize, SearchWarningLineHeight, availableWidth);
3171
+ return textHeight + SearchWarningVerticalPadding;
3172
+ };
3173
+
3098
3174
  const getTextSearchResultCounts = results => {
3099
3175
  let resultCount = 0;
3100
3176
  let fileCount = 0;
@@ -3145,7 +3221,6 @@ const handleUpdateFull = async (state, update) => {
3145
3221
  excludeValue,
3146
3222
  fileIconCache,
3147
3223
  flags,
3148
- headerHeight,
3149
3224
  height,
3150
3225
  includeValue,
3151
3226
  itemHeight,
@@ -3155,7 +3230,8 @@ const handleUpdateFull = async (state, update) => {
3155
3230
  threads,
3156
3231
  uid,
3157
3232
  usePullBasedSearch,
3158
- value
3233
+ value,
3234
+ width
3159
3235
  } = partialNewState;
3160
3236
  const root = state.workspacePath;
3161
3237
  const scheme = getProtocol(root);
@@ -3189,6 +3265,9 @@ const handleUpdateFull = async (state, update) => {
3189
3265
  resultCount
3190
3266
  } = getTextSearchResultCounts(results);
3191
3267
  const message = getStatusMessage(resultCount, fileCount);
3268
+ const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
3269
+ const warningHeight = await getSearchWarningMessageHeight(limitHitWarning, width);
3270
+ const headerHeight = getTopHeight(flags) + warningHeight;
3192
3271
  const total = results.length;
3193
3272
  const contentHeight = total * itemHeight;
3194
3273
  const listHeight = height - headerHeight;
@@ -3201,7 +3280,6 @@ const handleUpdateFull = async (state, update) => {
3201
3280
  icons,
3202
3281
  newFileIconCache
3203
3282
  } = await getFileIcons(visible, fileIconCache);
3204
- const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
3205
3283
  return {
3206
3284
  ...partialNewState,
3207
3285
  collapsedPaths: [],
@@ -3209,6 +3287,7 @@ const handleUpdateFull = async (state, update) => {
3209
3287
  fileCount,
3210
3288
  fileIconCache: newFileIconCache,
3211
3289
  finalDeltaY,
3290
+ headerHeight,
3212
3291
  icons,
3213
3292
  items: results,
3214
3293
  limitHit,
@@ -3361,8 +3440,11 @@ const handleUpdateIncremental = async (state, update) => {
3361
3440
  return state;
3362
3441
  };
3363
3442
 
3443
+ const getsearchid = () => {
3444
+ return crypto.randomUUID();
3445
+ };
3364
3446
  const handleUpdatePullBased = async (state, update) => {
3365
- const searchId = crypto.randomUUID();
3447
+ const searchId = getsearchid();
3366
3448
  const partialNewState = {
3367
3449
  ...state,
3368
3450
  ...update,
@@ -3383,7 +3465,8 @@ const handleUpdatePullBased = async (state, update) => {
3383
3465
  threads,
3384
3466
  uid,
3385
3467
  usePullBasedSearch,
3386
- value
3468
+ value,
3469
+ width
3387
3470
  } = partialNewState;
3388
3471
  const root = state.workspacePath;
3389
3472
  const scheme = getProtocol(root);
@@ -3412,6 +3495,8 @@ const handleUpdatePullBased = async (state, update) => {
3412
3495
  return state;
3413
3496
  }
3414
3497
  const limitHitWarning = limitHit ? theResultSetOnlyContainsASubSetOfMatches() : '';
3498
+ const warningHeight = await getSearchWarningMessageHeight(limitHitWarning, width);
3499
+ const headerHeight = getTopHeight(flags) + warningHeight;
3415
3500
  const {
3416
3501
  fileCount,
3417
3502
  resultCount
@@ -3419,6 +3504,7 @@ const handleUpdatePullBased = async (state, update) => {
3419
3504
  const message = getStatusMessage(resultCount, fileCount);
3420
3505
  return {
3421
3506
  ...latest.newState,
3507
+ headerHeight,
3422
3508
  limitHit,
3423
3509
  limitHitWarning,
3424
3510
  message
@@ -3638,21 +3724,27 @@ const togglePreserveCase = state => {
3638
3724
 
3639
3725
  const collapseReplace = state => {
3640
3726
  const {
3641
- flags
3727
+ flags,
3728
+ headerHeight
3642
3729
  } = state;
3730
+ const newFlags = flags & -5;
3643
3731
  return {
3644
3732
  ...state,
3645
- flags: flags & -5
3733
+ flags: newFlags,
3734
+ headerHeight: getHeaderHeightForFlags(headerHeight, flags, newFlags)
3646
3735
  };
3647
3736
  };
3648
3737
 
3649
3738
  const expandReplace = state => {
3650
3739
  const {
3651
- flags
3740
+ flags,
3741
+ headerHeight
3652
3742
  } = state;
3743
+ const newFlags = flags | ReplaceExpanded;
3653
3744
  return {
3654
3745
  ...state,
3655
- flags: flags | ReplaceExpanded
3746
+ flags: newFlags,
3747
+ headerHeight: getHeaderHeightForFlags(headerHeight, flags, newFlags)
3656
3748
  };
3657
3749
  };
3658
3750
 
@@ -4184,7 +4276,7 @@ const send = async port => {
4184
4276
  };
4185
4277
  const launchIconThemeWorker = async () => {
4186
4278
  // TODO connect to icon theme worker
4187
- const rpc = await create$5({
4279
+ const rpc = await create$9({
4188
4280
  commandMap: {},
4189
4281
  send
4190
4282
  });
@@ -4197,7 +4289,7 @@ const initializeIconThemeWorker = async () => {
4197
4289
  };
4198
4290
 
4199
4291
  const launchSearchProcessElectron = async () => {
4200
- const rpc = await create$a({
4292
+ const rpc = await create$8({
4201
4293
  commandMap: {},
4202
4294
  send: sendMessagePortToSearchProcess
4203
4295
  });
@@ -4205,7 +4297,7 @@ const launchSearchProcessElectron = async () => {
4205
4297
  };
4206
4298
 
4207
4299
  const launchSearchProcessNode = async () => {
4208
- const rpc = await create$7({
4300
+ const rpc = await create$5({
4209
4301
  commandMap: {},
4210
4302
  // @ts-ignore
4211
4303
  type: 'search-process'
@@ -4536,19 +4628,6 @@ const getListIndex = (eventX, eventY, x, y, deltaY, itemHeight, topHeight, itemC
4536
4628
  return index;
4537
4629
  };
4538
4630
 
4539
- const getTopHeight = flags => {
4540
- if (flags & ReplaceExpanded && flags & DetailsExpanded) {
4541
- return 190;
4542
- }
4543
- if (flags & DetailsExpanded) {
4544
- return 158;
4545
- }
4546
- if (flags & ReplaceExpanded) {
4547
- return 93;
4548
- }
4549
- return 61;
4550
- };
4551
-
4552
4631
  const getFilteredResults = (results, collapsedPaths) => {
4553
4632
  if (collapsedPaths.length === 0) {
4554
4633
  return results;
@@ -4699,14 +4778,13 @@ const selectIndex = async (state, index) => {
4699
4778
  const handleClickAt = async (state, eventX, eventY, name) => {
4700
4779
  const {
4701
4780
  deltaY,
4702
- flags,
4781
+ headerHeight,
4703
4782
  itemHeight,
4704
4783
  listItems,
4705
4784
  x,
4706
4785
  y
4707
4786
  } = state;
4708
- const topHeight = getTopHeight(flags);
4709
- const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
4787
+ const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, headerHeight, listItems.length);
4710
4788
  const isRemoveButton = name === Remove;
4711
4789
  if (isRemoveButton) {
4712
4790
  return removeIndex(state, index);
@@ -4828,12 +4906,15 @@ const loadContent = async (state, savedState) => {
4828
4906
  threads
4829
4907
  } = restoreState(savedState);
4830
4908
  const usePullBasedSearch = await getUsePullBasedSearch();
4909
+ const warningHeight = await getSearchWarningMessageHeight(state.limitHitWarning, state.width);
4910
+ const headerHeight = getTopHeight(flags) + warningHeight;
4831
4911
  const update = {
4832
4912
  collapsedPaths: savedCollapsedPaths,
4833
4913
  excludeValue,
4834
4914
  flags,
4835
4915
  focus: 0,
4836
4916
  // TODO
4917
+ headerHeight,
4837
4918
  includeValue,
4838
4919
  inputSource: Script,
4839
4920
  replacement,
@@ -5174,7 +5255,7 @@ const renderFocus = (oldState, newState) => {
5174
5255
  };
5175
5256
 
5176
5257
  const renderFocusContext = (oldState, newState) => {
5177
- return [SetFocusContext, newState.uid, FocusSearch, newState.focus];
5258
+ return [SetFocusContext, newState.uid, FocusSearch$1, newState.focus];
5178
5259
  };
5179
5260
 
5180
5261
  const HandleClick = 1;
@@ -5209,7 +5290,7 @@ const getSearchDetailsToggleVirtualDom = () => {
5209
5290
  role: Button$3,
5210
5291
  tabIndex: 0,
5211
5292
  title: toggleSearchDetails(),
5212
- type: Button$2
5293
+ type: Button$1
5213
5294
  }, {
5214
5295
  childCount: 0,
5215
5296
  className: mergeClassNames(MaskIcon, MaskIconEllipsis),
@@ -5329,7 +5410,7 @@ const getSearchFieldButtonVirtualDom = button => {
5329
5410
  role,
5330
5411
  tabIndex: 0,
5331
5412
  title,
5332
- type: Button$2
5413
+ type: Button$1
5333
5414
  }, {
5334
5415
  childCount: 0,
5335
5416
  className: mergeClassNames(MaskIcon, icon),
@@ -5506,7 +5587,7 @@ const getSearchToggleVirtualDom = replaceExpanded => {
5506
5587
  name: ToggleReplace,
5507
5588
  onClick: HandleButtonClick,
5508
5589
  title: toggleReplace$1(),
5509
- type: Button$2
5590
+ type: Button$1
5510
5591
  }, {
5511
5592
  childCount: 0,
5512
5593
  className: mergeClassNames(MaskIcon, replaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
@@ -5718,7 +5799,7 @@ const getSearchRemoveVirtualDom = () => {
5718
5799
  className: SearchRemove,
5719
5800
  name: Remove,
5720
5801
  title,
5721
- type: Button$2
5802
+ type: Button$1
5722
5803
  }, closeIcon];
5723
5804
  return dom;
5724
5805
  };
@@ -5794,7 +5875,7 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
5794
5875
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
5795
5876
  };
5796
5877
 
5797
- const className = mergeClassNames(Viewlet, Search$2);
5878
+ const className = mergeClassNames(Viewlet, Search$1);
5798
5879
  const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0, initial = false) => {
5799
5880
  if (initial) {
5800
5881
  return [];
@@ -5916,7 +5997,7 @@ const getActionButtonVirtualDom = action => {
5916
5997
  className,
5917
5998
  name: id,
5918
5999
  title: label,
5919
- type: Button$2
6000
+ type: Button$1
5920
6001
  }, getIconVirtualDom(icon)];
5921
6002
  };
5922
6003
 
@@ -6013,7 +6094,7 @@ const renderEventListeners = () => {
6013
6094
  params: ['handleClickAt', ClientX, ClientY, TargetName]
6014
6095
  }, {
6015
6096
  name: HandleListPointerDown,
6016
- params: ['handleListPointerDown', Button$1, TargetName]
6097
+ params: ['handleListPointerDown', Button$2, TargetName]
6017
6098
  }, {
6018
6099
  name: HandleToggleButtonClick,
6019
6100
  params: ['handleToggleButtonClick']
@@ -6025,11 +6106,11 @@ const renderEventListeners = () => {
6025
6106
  params: ['handleListBlur']
6026
6107
  }, {
6027
6108
  name: HandleListContextMenu,
6028
- params: ['handleContextMenu', Button$1, ClientX, ClientY],
6109
+ params: ['handleContextMenu', Button$2, ClientX, ClientY],
6029
6110
  preventDefault: true
6030
6111
  }, {
6031
6112
  name: HandleInputContextMenu,
6032
- params: ['handleInputContextMenu', TargetName, Button$1, ClientX, ClientY],
6113
+ params: ['handleInputContextMenu', TargetName, Button$2, ClientX, ClientY],
6033
6114
  preventDefault: true
6034
6115
  }, {
6035
6116
  name: HandleActionClick,
@@ -6240,10 +6321,10 @@ const handleContextMenuKeyboard = async state => {
6240
6321
  x,
6241
6322
  y
6242
6323
  } = state; // TODO
6243
- await show2(uid, Search$1, x, y, {
6324
+ await show2(uid, Search$2, x, y, {
6244
6325
  index: 0,
6245
6326
  // TODO pass proper index
6246
- menuId: Search$1
6327
+ menuId: Search$2
6247
6328
  });
6248
6329
  return state;
6249
6330
  };
@@ -6251,15 +6332,14 @@ const handleContextMenuKeyboard = async state => {
6251
6332
  const handleContextMenuMouseAt = async (state, eventX, eventY) => {
6252
6333
  const {
6253
6334
  deltaY,
6254
- flags,
6335
+ headerHeight,
6255
6336
  itemHeight,
6256
6337
  listItems,
6257
6338
  uid,
6258
6339
  x,
6259
6340
  y
6260
6341
  } = state;
6261
- const topHeight = getTopHeight(flags);
6262
- const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, topHeight, listItems.length);
6342
+ const index = getListIndex(eventX, eventY, x, y, deltaY, itemHeight, headerHeight, listItems.length);
6263
6343
  const {
6264
6344
  newState,
6265
6345
  oldState
@@ -6269,9 +6349,9 @@ const handleContextMenuMouseAt = async (state, eventX, eventY) => {
6269
6349
  focusedIndex: index,
6270
6350
  listFocusedIndex: index
6271
6351
  });
6272
- await show2(uid, Search$1, x, y, {
6352
+ await show2(uid, Search$2, x, y, {
6273
6353
  index,
6274
- menuId: Search$1
6354
+ menuId: Search$2
6275
6355
  });
6276
6356
  return state;
6277
6357
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "6.4.0",
3
+ "version": "6.5.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"