@lvce-editor/text-search-worker 5.34.0 → 6.1.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.
@@ -592,7 +592,7 @@ const callbacks = Object.create(null);
592
592
  const get$3 = id => {
593
593
  return callbacks[id];
594
594
  };
595
- const remove$2 = id => {
595
+ const remove$3 = id => {
596
596
  delete callbacks[id];
597
597
  };
598
598
  class JsonRpcError extends Error {
@@ -745,7 +745,7 @@ const resolve = (id, response) => {
745
745
  return;
746
746
  }
747
747
  fn(response);
748
- remove$2(id);
748
+ remove$3(id);
749
749
  };
750
750
  const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
751
751
  const getErrorType = prettyError => {
@@ -788,7 +788,7 @@ const getErrorProperty = (error, prettyError) => {
788
788
  }
789
789
  };
790
790
  };
791
- const create$1$2 = (id, error) => {
791
+ const create$1$1 = (id, error) => {
792
792
  return {
793
793
  jsonrpc: Two$1,
794
794
  id,
@@ -799,9 +799,9 @@ const getErrorResponse = (id, error, preparePrettyError, logError) => {
799
799
  const prettyError = preparePrettyError(error);
800
800
  logError(error, prettyError);
801
801
  const errorProperty = getErrorProperty(error, prettyError);
802
- return create$1$2(id, errorProperty);
802
+ return create$1$1(id, errorProperty);
803
803
  };
804
- const create$5 = (message, result) => {
804
+ const create$4 = (message, result) => {
805
805
  return {
806
806
  jsonrpc: Two$1,
807
807
  id: message.id,
@@ -810,7 +810,7 @@ const create$5 = (message, result) => {
810
810
  };
811
811
  const getSuccessResponse = (message, result) => {
812
812
  const resultProperty = result ?? null;
813
- return create$5(message, resultProperty);
813
+ return create$4(message, resultProperty);
814
814
  };
815
815
  const getErrorResponseSimple = (id, error) => {
816
816
  return {
@@ -924,14 +924,14 @@ const execute = (command, ...args) => {
924
924
  };
925
925
 
926
926
  const Two = '2.0';
927
- const create$s = (method, params) => {
927
+ const create$t = (method, params) => {
928
928
  return {
929
929
  jsonrpc: Two,
930
930
  method,
931
931
  params
932
932
  };
933
933
  };
934
- const create$r = (id, method, params) => {
934
+ const create$s = (id, method, params) => {
935
935
  const message = {
936
936
  id,
937
937
  jsonrpc: Two,
@@ -941,14 +941,14 @@ const create$r = (id, method, params) => {
941
941
  return message;
942
942
  };
943
943
  let id = 0;
944
- const create$q = () => {
944
+ const create$r = () => {
945
945
  return ++id;
946
946
  };
947
947
 
948
948
  /* eslint-disable n/no-unsupported-features/es-syntax */
949
949
 
950
950
  const registerPromise = map => {
951
- const id = create$q();
951
+ const id = create$r();
952
952
  const {
953
953
  promise,
954
954
  resolve
@@ -966,7 +966,7 @@ const invokeHelper = async (callbacks, ipc, method, params, useSendAndTransfer)
966
966
  id,
967
967
  promise
968
968
  } = registerPromise(callbacks);
969
- const message = create$r(id, method, params);
969
+ const message = create$s(id, method, params);
970
970
  if (useSendAndTransfer && ipc.sendAndTransfer) {
971
971
  ipc.sendAndTransfer(message);
972
972
  } else {
@@ -1002,7 +1002,7 @@ const createRpc = ipc => {
1002
1002
  * @deprecated
1003
1003
  */
1004
1004
  send(method, ...params) {
1005
- const message = create$s(method, params);
1005
+ const message = create$t(method, params);
1006
1006
  ipc.send(message);
1007
1007
  }
1008
1008
  };
@@ -1068,13 +1068,13 @@ const createSharedLazyRpc = factory => {
1068
1068
  }
1069
1069
  };
1070
1070
  };
1071
- const create$i = async ({
1071
+ const create$j = async ({
1072
1072
  commandMap,
1073
1073
  isMessagePortOpen,
1074
1074
  send
1075
1075
  }) => {
1076
1076
  return createSharedLazyRpc(() => {
1077
- return create$2$1({
1077
+ return create$3$1({
1078
1078
  commandMap,
1079
1079
  isMessagePortOpen,
1080
1080
  send
@@ -1083,7 +1083,7 @@ const create$i = async ({
1083
1083
  };
1084
1084
  const LazyTransferMessagePortRpcParent = {
1085
1085
  __proto__: null,
1086
- create: create$i
1086
+ create: create$j
1087
1087
  };
1088
1088
  const Https = 'https:';
1089
1089
  const Ws = 'ws:';
@@ -1101,7 +1101,7 @@ const getHost = () => {
1101
1101
  const getProtocol$1 = () => {
1102
1102
  return location.protocol;
1103
1103
  };
1104
- const create$h = async ({
1104
+ const create$i = async ({
1105
1105
  commandMap,
1106
1106
  webSocket
1107
1107
  }) => {
@@ -1115,7 +1115,7 @@ const create$h = async ({
1115
1115
  const rpc = createRpc(ipc);
1116
1116
  return rpc;
1117
1117
  };
1118
- const create$g = async ({
1118
+ const create$h = async ({
1119
1119
  commandMap,
1120
1120
  type
1121
1121
  }) => {
@@ -1123,18 +1123,18 @@ const create$g = async ({
1123
1123
  const protocol = getProtocol$1();
1124
1124
  const wsUrl = getWebSocketUrl(type, host, protocol);
1125
1125
  const webSocket = new WebSocket(wsUrl);
1126
- const rpc = await create$h({
1126
+ const rpc = await create$i({
1127
1127
  commandMap,
1128
1128
  webSocket
1129
1129
  });
1130
1130
  return rpc;
1131
1131
  };
1132
- const create$f = async ({
1132
+ const create$g = async ({
1133
1133
  commandMap,
1134
1134
  type
1135
1135
  }) => {
1136
1136
  return createSharedLazyRpc(() => {
1137
- return create$g({
1137
+ return create$h({
1138
1138
  commandMap,
1139
1139
  type
1140
1140
  });
@@ -1142,9 +1142,9 @@ const create$f = async ({
1142
1142
  };
1143
1143
  const LazyWebSocketRpcParent2 = {
1144
1144
  __proto__: null,
1145
- create: create$f
1145
+ create: create$g
1146
1146
  };
1147
- const create$4 = async ({
1147
+ const create$5 = async ({
1148
1148
  commandMap,
1149
1149
  isMessagePortOpen = true,
1150
1150
  messagePort
@@ -1161,7 +1161,7 @@ const create$4 = async ({
1161
1161
  messagePort.start();
1162
1162
  return rpc;
1163
1163
  };
1164
- const create$2$1 = async ({
1164
+ const create$3$1 = async ({
1165
1165
  commandMap,
1166
1166
  isMessagePortOpen,
1167
1167
  send
@@ -1171,7 +1171,7 @@ const create$2$1 = async ({
1171
1171
  port2
1172
1172
  } = new MessageChannel();
1173
1173
  await send(port1);
1174
- return create$4({
1174
+ return create$5({
1175
1175
  commandMap,
1176
1176
  isMessagePortOpen,
1177
1177
  messagePort: port2
@@ -1179,9 +1179,9 @@ const create$2$1 = async ({
1179
1179
  };
1180
1180
  const TransferMessagePortRpcParent = {
1181
1181
  __proto__: null,
1182
- create: create$2$1
1182
+ create: create$3$1
1183
1183
  };
1184
- const create$1$1 = async ({
1184
+ const create$2$1 = async ({
1185
1185
  commandMap
1186
1186
  }) => {
1187
1187
  // TODO create a commandMap per rpc instance
@@ -1193,7 +1193,26 @@ const create$1$1 = async ({
1193
1193
  };
1194
1194
  const WebWorkerRpcClient = {
1195
1195
  __proto__: null,
1196
- create: create$1$1
1196
+ create: create$2$1
1197
+ };
1198
+ const createMockRpc = ({
1199
+ commandMap
1200
+ }) => {
1201
+ const invocations = [];
1202
+ const invoke = (method, ...params) => {
1203
+ invocations.push([method, ...params]);
1204
+ const command = commandMap[method];
1205
+ if (!command) {
1206
+ throw new Error(`command ${method} not found`);
1207
+ }
1208
+ return command(...params);
1209
+ };
1210
+ const mockRpc = {
1211
+ invocations,
1212
+ invoke,
1213
+ invokeAndTransfer: invoke
1214
+ };
1215
+ return mockRpc;
1197
1216
  };
1198
1217
 
1199
1218
  const Alert = 'alert';
@@ -1206,9 +1225,79 @@ const ToolBar = 'toolbar';
1206
1225
  const Tree$1 = 'tree';
1207
1226
  const TreeItem$1 = 'treeitem';
1208
1227
 
1228
+ const Actions = 'Actions';
1229
+ const Badge = 'Badge';
1230
+ const Chevron = 'Chevron';
1231
+ const CloseMaskIcon = 'MaskIcon MaskIconClose';
1232
+ const Empty$1 = '';
1233
+ const FileIcon = 'FileIcon';
1234
+ const FocusOutline = 'FocusOutline';
1235
+ const Grow = 'Grow';
1236
+ const Highlight = 'Highlight';
1237
+ const HighlightDeleted = 'HighlightDeleted';
1238
+ const HighlightInserted = 'HighlightInserted';
1239
+ const IconButton = 'IconButton';
1240
+ const IconButtonDisabled = 'IconButtonDisabled';
1241
+ const Label = 'Label';
1242
+ const List$1 = 'List';
1243
+ const MaskIcon = 'MaskIcon';
1244
+ const MaskIconBook = 'MaskIconBook';
1245
+ const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1246
+ const MaskIconChevronDown = 'MaskIconChevronDown';
1247
+ const MaskIconChevronRight = 'MaskIconChevronRight';
1248
+ const MaskIconEllipsis = 'MaskIconEllipsis';
1249
+ const MaskIconExclude = 'MaskIconExclude';
1250
+ const MaskIconPreserveCase = 'MaskIconPreserveCase';
1251
+ const MaskIconRegex = 'MaskIconRegex';
1252
+ const MaskIconReplaceAll = 'MaskIconReplaceAll';
1253
+ const MaskIconWholeWord = 'MaskIconWholeWord';
1254
+ const MultilineInputBox = 'MultilineInputBox';
1255
+ const ScrollBar = 'ScrollBar';
1256
+ const ScrollBarThumb = 'ScrollBarThumb';
1257
+ const ScrollBarVertical = 'ScrollBarVertical';
1258
+ const Search$2 = 'Search';
1259
+ const SearchField = 'SearchField';
1260
+ const SearchFieldButton = 'SearchFieldButton';
1261
+ const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
1262
+ const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
1263
+ const SearchFieldButtons = 'SearchFieldButtons';
1264
+ const SearchFieldContainer = 'SearchFieldContainer';
1265
+ const SearchFieldError = 'SearchFieldError';
1266
+ const SearchHeader = 'SearchHeader';
1267
+ const SearchHeaderDetails = 'SearchHeaderDetails';
1268
+ const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1269
+ const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
1270
+ const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
1271
+ const SearchHeaderTop = 'SearchHeaderTop';
1272
+ const SearchHeaderTopRight = 'SearchHeaderTopRight';
1273
+ const SearchInputError = 'SearchInputError';
1274
+ const SearchRemove = 'SearchRemove';
1275
+ const SearchToggleButton = 'SearchToggleButton';
1276
+ const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1277
+ const SourceControlBadge = 'SourceControlBadge';
1278
+ const ToggleDetails = 'ToggleDetails';
1279
+ const Tree = 'Tree';
1280
+ const TreeItem = 'TreeItem';
1281
+ const TreeItemActive = 'TreeItemActive';
1282
+ const TreeItems$1 = 'TreeItems';
1283
+ const Viewlet = 'Viewlet';
1284
+ const ViewletSearchMessage = 'ViewletSearchMessage';
1285
+ const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1286
+
1209
1287
  const File$2 = 7;
1210
1288
 
1211
- const Button$2 = 'event.button';
1289
+ const Button$2 = 1;
1290
+ const Div = 4;
1291
+ const Span = 8;
1292
+ const Text = 12;
1293
+ const Img = 17;
1294
+ const Ins = 20;
1295
+ const Del = 21;
1296
+ const H4 = 24;
1297
+ const TextArea = 62;
1298
+ const Reference = 100;
1299
+
1300
+ const Button$1 = 'event.button';
1212
1301
  const ClientX = 'event.clientX';
1213
1302
  const ClientY = 'event.clientY';
1214
1303
  const DeltaMode = 'event.deltaMode';
@@ -1220,7 +1309,7 @@ const TargetValue = 'event.target.value';
1220
1309
 
1221
1310
  const Script$1 = 2;
1222
1311
 
1223
- const Search$2 = 18;
1312
+ const Search$1 = 18;
1224
1313
  const InputContextMenu = 91;
1225
1314
 
1226
1315
  const Separator = 1;
@@ -1243,7 +1332,22 @@ const SetDom2 = 'Viewlet.setDom2';
1243
1332
  const SetFocusContext = 'Viewlet.setFocusContext';
1244
1333
  const SetValueByName = 'Viewlet.setValueByName';
1245
1334
 
1246
- const FocusSearch$1 = 1013;
1335
+ const Empty = 0;
1336
+ const FocusIgnoreFiles = 1012;
1337
+ const FocusSearch = 1013;
1338
+ const FocusSearchExcludeInput = 1008;
1339
+ const FocusSearchIncludeInput = 1007;
1340
+ const FocusSearchInput = 21;
1341
+ const FocusSearchMatchCase = 32;
1342
+ const FocusSearchOpenEditors = 1011;
1343
+ const FocusSearchPreserveCase = 36;
1344
+ const FocusSearchRegex = 33;
1345
+ const FocusSearchReplaceAll = 35;
1346
+ const FocusSearchReplaceInput = 31;
1347
+ const FocusSearchResults = 22;
1348
+ const FocusSearchWholeWord = 34;
1349
+ const FocusToggleDetails = 1010;
1350
+ const FocusToggleReplace = 1020;
1247
1351
 
1248
1352
  const rpcs = Object.create(null);
1249
1353
  const set$4 = (id, rpc) => {
@@ -1252,7 +1356,11 @@ const set$4 = (id, rpc) => {
1252
1356
  const get$2 = id => {
1253
1357
  return rpcs[id];
1254
1358
  };
1359
+ const remove$2 = id => {
1360
+ delete rpcs[id];
1361
+ };
1255
1362
 
1363
+ /* eslint-disable @typescript-eslint/explicit-function-return-type */
1256
1364
  const create$3 = rpcId => {
1257
1365
  return {
1258
1366
  async dispose() {
@@ -1271,6 +1379,18 @@ const create$3 = rpcId => {
1271
1379
  // @ts-ignore
1272
1380
  return rpc.invokeAndTransfer(method, ...params);
1273
1381
  },
1382
+ registerMockRpc(commandMap) {
1383
+ const mockRpc = createMockRpc({
1384
+ commandMap
1385
+ });
1386
+ set$4(rpcId, mockRpc);
1387
+ // @ts-ignore
1388
+ mockRpc[Symbol.dispose] = () => {
1389
+ remove$2(rpcId);
1390
+ };
1391
+ // @ts-ignore
1392
+ return mockRpc;
1393
+ },
1274
1394
  set(rpc) {
1275
1395
  set$4(rpcId, rpc);
1276
1396
  }
@@ -1296,12 +1416,10 @@ const showContextMenu2 = async (uid, menuId, x, y, args) => {
1296
1416
  number(menuId);
1297
1417
  number(x);
1298
1418
  number(y);
1299
- // @ts-ignore
1300
1419
  await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1301
1420
  };
1302
1421
  const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1303
1422
  const command = 'IconTheme.handleMessagePort';
1304
- // @ts-ignore
1305
1423
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1306
1424
  };
1307
1425
  const handleWorkspaceRefresh = async () => {
@@ -1330,42 +1448,68 @@ const create$2 = () => {
1330
1448
  const states = Object.create(null);
1331
1449
  const commandMapRef = {};
1332
1450
  return {
1333
- get(uid) {
1334
- return states[uid];
1451
+ clear() {
1452
+ for (const key of Object.keys(states)) {
1453
+ delete states[key];
1454
+ }
1335
1455
  },
1336
- set(uid, oldState, newState) {
1337
- states[uid] = {
1338
- oldState,
1339
- newState
1340
- };
1456
+ diff(uid, modules, numbers) {
1457
+ const {
1458
+ newState,
1459
+ oldState
1460
+ } = states[uid];
1461
+ const diffResult = [];
1462
+ for (let i = 0; i < modules.length; i++) {
1463
+ const fn = modules[i];
1464
+ if (!fn(oldState, newState)) {
1465
+ diffResult.push(numbers[i]);
1466
+ }
1467
+ }
1468
+ return diffResult;
1341
1469
  },
1342
1470
  dispose(uid) {
1343
1471
  delete states[uid];
1344
1472
  },
1473
+ get(uid) {
1474
+ return states[uid];
1475
+ },
1476
+ getCommandIds() {
1477
+ const keys = Object.keys(commandMapRef);
1478
+ const ids = keys.map(toCommandId);
1479
+ return ids;
1480
+ },
1345
1481
  getKeys() {
1346
1482
  return Object.keys(states).map(key => {
1347
1483
  return Number.parseInt(key);
1348
1484
  });
1349
1485
  },
1350
- clear() {
1351
- for (const key of Object.keys(states)) {
1352
- delete states[key];
1353
- }
1486
+ registerCommands(commandMap) {
1487
+ Object.assign(commandMapRef, commandMap);
1488
+ },
1489
+ set(uid, oldState, newState) {
1490
+ states[uid] = {
1491
+ newState,
1492
+ oldState
1493
+ };
1354
1494
  },
1355
1495
  wrapCommand(fn) {
1356
1496
  const wrapped = async (uid, ...args) => {
1357
1497
  const {
1358
- oldState,
1359
- newState
1498
+ newState,
1499
+ oldState
1360
1500
  } = states[uid];
1361
1501
  const newerState = await fn(newState, ...args);
1362
1502
  if (oldState === newerState || newState === newerState) {
1363
1503
  return;
1364
1504
  }
1365
- const latest = states[uid];
1505
+ const latestOld = states[uid];
1506
+ const latestNew = {
1507
+ ...latestOld.newState,
1508
+ ...newerState
1509
+ };
1366
1510
  states[uid] = {
1367
- oldState: latest.oldState,
1368
- newState: newerState
1511
+ newState: latestNew,
1512
+ oldState: latestOld.oldState
1369
1513
  };
1370
1514
  };
1371
1515
  return wrapped;
@@ -1378,28 +1522,6 @@ const create$2 = () => {
1378
1522
  return fn(newState, ...args);
1379
1523
  };
1380
1524
  return wrapped;
1381
- },
1382
- diff(uid, modules, numbers) {
1383
- const {
1384
- oldState,
1385
- newState
1386
- } = states[uid];
1387
- const diffResult = [];
1388
- for (let i = 0; i < modules.length; i++) {
1389
- const fn = modules[i];
1390
- if (!fn(oldState, newState)) {
1391
- diffResult.push(numbers[i]);
1392
- }
1393
- }
1394
- return diffResult;
1395
- },
1396
- getCommandIds() {
1397
- const keys = Object.keys(commandMapRef);
1398
- const ids = keys.map(toCommandId);
1399
- return ids;
1400
- },
1401
- registerCommands(commandMap) {
1402
- Object.assign(commandMapRef, commandMap);
1403
1525
  }
1404
1526
  };
1405
1527
  };
@@ -1407,105 +1529,20 @@ const terminate = () => {
1407
1529
  globalThis.close();
1408
1530
  };
1409
1531
 
1410
- const Actions = 'Actions';
1411
- const Badge = 'Badge';
1412
- const Chevron = 'Chevron';
1413
- const CloseMaskIcon = 'MaskIcon MaskIconClose';
1414
- const Empty$1 = '';
1415
- const FileIcon = 'FileIcon';
1416
- const FocusOutline = 'FocusOutline';
1417
- const Grow = 'Grow';
1418
- const Highlight = 'Highlight';
1419
- const HighlightDeleted = 'HighlightDeleted';
1420
- const HighlightInserted = 'HighlightInserted';
1421
- const IconButton = 'IconButton';
1422
- const IconButtonDisabled = 'IconButtonDisabled';
1423
- const Label = 'Label';
1424
- const List$1 = 'List';
1425
- const MaskIcon = 'MaskIcon';
1426
- const MaskIconBook = 'MaskIconBook';
1427
- const MaskIconCaseSensitive = 'MaskIconCaseSensitive';
1428
- const MaskIconChevronDown = 'MaskIconChevronDown';
1429
- const MaskIconChevronRight = 'MaskIconChevronRight';
1430
- const MaskIconEllipsis = 'MaskIconEllipsis';
1431
- const MaskIconExclude = 'MaskIconExclude';
1432
- const MaskIconPreserveCase = 'MaskIconPreserveCase';
1433
- const MaskIconRegex = 'MaskIconRegex';
1434
- const MaskIconReplaceAll = 'MaskIconReplaceAll';
1435
- const MaskIconWholeWord = 'MaskIconWholeWord';
1436
- const MultilineInputBox = 'MultilineInputBox';
1437
- const ScrollBar = 'ScrollBar';
1438
- const ScrollBarThumb = 'ScrollBarThumb';
1439
- const ScrollBarVertical = 'ScrollBarVertical';
1440
- const Search$1 = 'Search';
1441
- const SearchField = 'SearchField';
1442
- const SearchFieldButton = 'SearchFieldButton';
1443
- const SearchFieldButtonChecked = 'SearchFieldButtonChecked';
1444
- const SearchFieldButtonDisabled = 'SearchFieldButtonDisabled';
1445
- const SearchFieldButtons = 'SearchFieldButtons';
1446
- const SearchFieldContainer = 'SearchFieldContainer';
1447
- const SearchFieldError = 'SearchFieldError';
1448
- const SearchHeader = 'SearchHeader';
1449
- const SearchHeaderDetails = 'SearchHeaderDetails';
1450
- const SearchHeaderDetailsExpanded = 'SearchHeaderDetailsExpanded';
1451
- const SearchHeaderDetailsExpandedTop = 'SearchHeaderDetailsExpandedTop';
1452
- const SearchHeaderDetailsHeading = 'SearchHeaderDetailsHeading';
1453
- const SearchHeaderTop = 'SearchHeaderTop';
1454
- const SearchHeaderTopRight = 'SearchHeaderTopRight';
1455
- const SearchInputError = 'SearchInputError';
1456
- const SearchRemove = 'SearchRemove';
1457
- const SearchToggleButton = 'SearchToggleButton';
1458
- const SearchToggleButtonExpanded = 'SearchToggleButtonExpanded';
1459
- const SourceControlBadge = 'SourceControlBadge';
1460
- const ToggleDetails = 'ToggleDetails';
1461
- const Tree = 'Tree';
1462
- const TreeItem = 'TreeItem';
1463
- const TreeItemActive = 'TreeItemActive';
1464
- const TreeItems$1 = 'TreeItems';
1465
- const Viewlet = 'Viewlet';
1466
- const ViewletSearchMessage = 'ViewletSearchMessage';
1467
- const ViewletSearchMessageIndented = 'ViewletSearchMessageIndented';
1468
-
1469
- const Button$1 = 1;
1470
- const Div = 4;
1471
- const Span = 8;
1472
- const Text = 12;
1473
- const Img = 17;
1474
- const Ins = 20;
1475
- const Del = 21;
1476
- const H4 = 24;
1477
- const TextArea = 62;
1478
-
1479
- const Empty = 0;
1480
- const FocusIgnoreFiles = 1012;
1481
- const FocusSearch = 1013;
1482
- const FocusSearchExcludeInput = 1008;
1483
- const FocusSearchIncludeInput = 1007;
1484
- const FocusSearchInput = 21;
1485
- const FocusSearchMatchCase = 32;
1486
- const FocusSearchOpenEditors = 1011;
1487
- const FocusSearchPreserveCase = 36;
1488
- const FocusSearchRegex = 33;
1489
- const FocusSearchReplaceAll = 35;
1490
- const FocusSearchReplaceInput = 31;
1491
- const FocusSearchResults = 22;
1492
- const FocusSearchWholeWord = 34;
1493
- const FocusToggleDetails = 1010;
1494
- const FocusToggleReplace = 1020;
1495
-
1496
1532
  const mergeClassNames = (...classNames) => {
1497
1533
  return classNames.filter(Boolean).join(' ');
1498
1534
  };
1499
1535
 
1500
1536
  const text = data => {
1501
1537
  return {
1502
- type: Text,
1538
+ childCount: 0,
1503
1539
  text: data,
1504
- childCount: 0
1540
+ type: Text
1505
1541
  };
1506
1542
  };
1507
1543
 
1508
1544
  const SetText = 1;
1545
+ const Replace$1 = 2;
1509
1546
  const SetAttribute = 3;
1510
1547
  const RemoveAttribute = 4;
1511
1548
  const Add = 6;
@@ -1513,24 +1550,7 @@ const NavigateChild = 7;
1513
1550
  const NavigateParent = 8;
1514
1551
  const RemoveChild = 9;
1515
1552
  const NavigateSibling = 10;
1516
-
1517
- const applyPendingPatches = (patches, pendingPatches, skip) => {
1518
- for (let k = 0; k < pendingPatches.length - skip; k += 2) {
1519
- const type = pendingPatches[k];
1520
- const index = pendingPatches[k + 1];
1521
- if (type === NavigateParent) {
1522
- patches.push({
1523
- type
1524
- });
1525
- } else {
1526
- patches.push({
1527
- type,
1528
- index
1529
- });
1530
- }
1531
- }
1532
- pendingPatches.length = 0;
1533
- };
1553
+ const SetReferenceNodeUid = 11;
1534
1554
 
1535
1555
  const isKey = key => {
1536
1556
  return key !== 'type' && key !== 'childCount';
@@ -1541,183 +1561,272 @@ const getKeys = node => {
1541
1561
  return keys;
1542
1562
  };
1543
1563
 
1544
- const getTotalChildCount = (nodes, index) => {
1545
- let i = index;
1546
- let pending = 1;
1547
- while (pending) {
1564
+ const arrayToTree = nodes => {
1565
+ const result = [];
1566
+ let i = 0;
1567
+ while (i < nodes.length) {
1548
1568
  const node = nodes[i];
1549
- pending += node.childCount;
1550
- pending--;
1551
- i++;
1569
+ const {
1570
+ children,
1571
+ nodesConsumed
1572
+ } = getChildrenWithCount(nodes, i + 1, node.childCount || 0);
1573
+ result.push({
1574
+ node,
1575
+ children
1576
+ });
1577
+ i += 1 + nodesConsumed;
1552
1578
  }
1553
- return i - index;
1579
+ return result;
1580
+ };
1581
+ const getChildrenWithCount = (nodes, startIndex, childCount) => {
1582
+ if (childCount === 0) {
1583
+ return {
1584
+ children: [],
1585
+ nodesConsumed: 0
1586
+ };
1587
+ }
1588
+ const children = [];
1589
+ let i = startIndex;
1590
+ let remaining = childCount;
1591
+ let totalConsumed = 0;
1592
+ while (remaining > 0 && i < nodes.length) {
1593
+ const node = nodes[i];
1594
+ const nodeChildCount = node.childCount || 0;
1595
+ const {
1596
+ children: nodeChildren,
1597
+ nodesConsumed
1598
+ } = getChildrenWithCount(nodes, i + 1, nodeChildCount);
1599
+ children.push({
1600
+ node,
1601
+ children: nodeChildren
1602
+ });
1603
+ const nodeSize = 1 + nodesConsumed;
1604
+ i += nodeSize;
1605
+ totalConsumed += nodeSize;
1606
+ remaining--;
1607
+ }
1608
+ return {
1609
+ children,
1610
+ nodesConsumed: totalConsumed
1611
+ };
1554
1612
  };
1555
1613
 
1556
- const diff$1 = (oldNodes, newNodes) => {
1614
+ const compareNodes = (oldNode, newNode) => {
1557
1615
  const patches = [];
1558
- const pendingPatches = [];
1559
- let i = 0;
1560
- let j = 0;
1561
- let siblingOffset = 0;
1562
- let maxSiblingOffset = 1;
1563
- const indexStack = [0, 1];
1564
- while (i < oldNodes.length && j < newNodes.length) {
1565
- const oldNode = oldNodes[i];
1566
- const newNode = newNodes[j];
1567
- // TODO maybe don't have the current element in indexstack
1568
- if (siblingOffset === maxSiblingOffset) {
1569
- indexStack.pop();
1570
- indexStack.pop();
1571
- pendingPatches.push(NavigateParent, 0);
1572
- maxSiblingOffset = indexStack.pop();
1573
- siblingOffset = indexStack.pop() + 1;
1616
+ // Check if node type changed - return null to signal incompatible nodes
1617
+ // (caller should handle this with a Replace operation)
1618
+ if (oldNode.type !== newNode.type) {
1619
+ return null;
1620
+ }
1621
+ // Handle reference nodes - special handling for uid changes
1622
+ if (oldNode.type === Reference) {
1623
+ if (oldNode.uid !== newNode.uid) {
1624
+ patches.push({
1625
+ type: SetReferenceNodeUid,
1626
+ uid: newNode.uid
1627
+ });
1574
1628
  }
1575
- while (siblingOffset === maxSiblingOffset) {
1576
- pendingPatches.push(NavigateParent, 0);
1577
- maxSiblingOffset = indexStack.pop();
1578
- siblingOffset = indexStack.pop() + 1;
1629
+ return patches;
1630
+ }
1631
+ // Handle text nodes
1632
+ if (oldNode.type === Text && newNode.type === Text) {
1633
+ if (oldNode.text !== newNode.text) {
1634
+ patches.push({
1635
+ type: SetText,
1636
+ value: newNode.text
1637
+ });
1579
1638
  }
1580
- if (oldNode.type !== newNode.type) {
1581
- let skip = 0;
1582
- if (pendingPatches.length > 0 && pendingPatches.at(-2) === NavigateChild) {
1583
- skip = 2;
1584
- }
1585
- applyPendingPatches(patches, pendingPatches, skip);
1586
- const oldTotal = getTotalChildCount(oldNodes, i);
1587
- const newTotal = getTotalChildCount(newNodes, j);
1639
+ return patches;
1640
+ }
1641
+ // Compare attributes
1642
+ const oldKeys = getKeys(oldNode);
1643
+ const newKeys = getKeys(newNode);
1644
+ // Check for attribute changes
1645
+ for (const key of newKeys) {
1646
+ if (oldNode[key] !== newNode[key]) {
1588
1647
  patches.push({
1589
- type: RemoveChild,
1590
- index: siblingOffset
1648
+ type: SetAttribute,
1649
+ key,
1650
+ value: newNode[key]
1591
1651
  });
1652
+ }
1653
+ }
1654
+ // Check for removed attributes
1655
+ for (const key of oldKeys) {
1656
+ if (!(key in newNode)) {
1592
1657
  patches.push({
1593
- type: Add,
1594
- nodes: newNodes.slice(j, j + newTotal)
1658
+ type: RemoveAttribute,
1659
+ key
1595
1660
  });
1596
- siblingOffset++;
1597
- i += oldTotal;
1598
- j += newTotal;
1661
+ }
1662
+ }
1663
+ return patches;
1664
+ };
1665
+
1666
+ const treeToArray = node => {
1667
+ const result = [node.node];
1668
+ for (const child of node.children) {
1669
+ result.push(...treeToArray(child));
1670
+ }
1671
+ return result;
1672
+ };
1673
+
1674
+ const diffChildren = (oldChildren, newChildren, patches) => {
1675
+ const maxLength = Math.max(oldChildren.length, newChildren.length);
1676
+ // Track where we are: -1 means at parent, >= 0 means at child index
1677
+ let currentChildIndex = -1;
1678
+ // Collect indices of children to remove (we'll add these patches at the end in reverse order)
1679
+ const indicesToRemove = [];
1680
+ for (let i = 0; i < maxLength; i++) {
1681
+ const oldNode = oldChildren[i];
1682
+ const newNode = newChildren[i];
1683
+ if (!oldNode && !newNode) {
1599
1684
  continue;
1600
1685
  }
1601
- if (oldNode.type === Text && newNode.type === Text) {
1602
- if (oldNode.text !== newNode.text) {
1603
- if (siblingOffset !== 0) {
1604
- pendingPatches.push(NavigateSibling, siblingOffset);
1605
- }
1606
- applyPendingPatches(patches, pendingPatches, 0);
1686
+ if (!oldNode) {
1687
+ // Add new node - we should be at the parent
1688
+ if (currentChildIndex >= 0) {
1689
+ // Navigate back to parent
1607
1690
  patches.push({
1608
- type: SetText,
1609
- value: newNode.text
1691
+ type: NavigateParent
1610
1692
  });
1693
+ currentChildIndex = -1;
1611
1694
  }
1612
- i++;
1613
- j++;
1614
- siblingOffset++;
1615
- continue;
1616
- }
1617
- const oldKeys = getKeys(oldNode);
1618
- const newKeys = getKeys(newNode);
1619
- let hasAttributeChanges = false;
1620
- for (const key of newKeys) {
1621
- if (oldNode[key] !== newNode[key]) {
1622
- hasAttributeChanges = true;
1623
- break;
1624
- }
1625
- }
1626
- for (const key of oldKeys) {
1627
- if (!(key in newNode)) {
1628
- hasAttributeChanges = true;
1629
- break;
1630
- }
1631
- }
1632
- if (hasAttributeChanges) {
1633
- if (siblingOffset > 0) {
1634
- pendingPatches.push(NavigateSibling, siblingOffset);
1635
- }
1636
- applyPendingPatches(patches, pendingPatches, 0);
1637
- for (const key of newKeys) {
1638
- if (oldNode[key] !== newNode[key]) {
1695
+ // Flatten the entire subtree so renderInternal can handle it
1696
+ const flatNodes = treeToArray(newNode);
1697
+ patches.push({
1698
+ type: Add,
1699
+ nodes: flatNodes
1700
+ });
1701
+ } else if (newNode) {
1702
+ // Compare nodes to see if we need any patches
1703
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
1704
+ // If nodePatches is null, the node types are incompatible - need to replace
1705
+ if (nodePatches === null) {
1706
+ // Navigate to this child
1707
+ if (currentChildIndex === -1) {
1639
1708
  patches.push({
1640
- type: SetAttribute,
1641
- key,
1642
- value: newNode[key]
1709
+ type: NavigateChild,
1710
+ index: i
1643
1711
  });
1644
- }
1645
- }
1646
- for (const key of oldKeys) {
1647
- if (!(key in newNode)) {
1712
+ currentChildIndex = i;
1713
+ } else if (currentChildIndex !== i) {
1648
1714
  patches.push({
1649
- type: RemoveAttribute,
1650
- key
1715
+ type: NavigateSibling,
1716
+ index: i
1651
1717
  });
1718
+ currentChildIndex = i;
1652
1719
  }
1653
- }
1654
- }
1655
- if (oldNode.childCount && newNode.childCount) {
1656
- maxSiblingOffset = oldNode.childCount;
1657
- indexStack.push(0, maxSiblingOffset);
1658
- pendingPatches.push(NavigateChild, 0);
1659
- i++;
1660
- j++;
1661
- continue;
1662
- }
1663
- if (oldNode.childCount) {
1664
- applyPendingPatches(patches, pendingPatches, 0);
1665
- for (let k = 0; k < oldNode.childCount; k++) {
1720
+ // Replace the entire subtree
1721
+ const flatNodes = treeToArray(newNode);
1666
1722
  patches.push({
1667
- type: RemoveChild,
1668
- index: 0
1723
+ type: Replace$1,
1724
+ nodes: flatNodes
1669
1725
  });
1726
+ // After replace, we're at the new element (same position)
1727
+ continue;
1670
1728
  }
1671
- i += getTotalChildCount(oldNodes, i);
1672
- j++;
1673
- siblingOffset++;
1674
- continue;
1675
- }
1676
- if (newNode.childCount) {
1677
- applyPendingPatches(patches, pendingPatches, 0);
1678
- const total = getTotalChildCount(newNodes, j);
1679
- patches.push({
1680
- type: Add,
1681
- nodes: newNodes.slice(j + 1, j + total)
1682
- });
1683
- i++;
1684
- j += total;
1685
- continue;
1729
+ // Check if we need to recurse into children
1730
+ const hasChildrenToCompare = oldNode.children.length > 0 || newNode.children.length > 0;
1731
+ // Only navigate to this element if we need to do something
1732
+ if (nodePatches.length > 0 || hasChildrenToCompare) {
1733
+ // Navigate to this child if not already there
1734
+ if (currentChildIndex === -1) {
1735
+ patches.push({
1736
+ type: NavigateChild,
1737
+ index: i
1738
+ });
1739
+ currentChildIndex = i;
1740
+ } else if (currentChildIndex !== i) {
1741
+ patches.push({
1742
+ type: NavigateSibling,
1743
+ index: i
1744
+ });
1745
+ currentChildIndex = i;
1746
+ }
1747
+ // Apply node patches (these apply to the current element, not children)
1748
+ if (nodePatches.length > 0) {
1749
+ patches.push(...nodePatches);
1750
+ }
1751
+ // Compare children recursively
1752
+ if (hasChildrenToCompare) {
1753
+ diffChildren(oldNode.children, newNode.children, patches);
1754
+ }
1755
+ }
1756
+ } else {
1757
+ // Remove old node - collect the index for later removal
1758
+ indicesToRemove.push(i);
1686
1759
  }
1687
- i++;
1688
- j++;
1689
- siblingOffset++;
1690
1760
  }
1691
- while (i < oldNodes.length) {
1692
- if (indexStack.length !== 2) {
1693
- patches.push({
1694
- type: NavigateParent
1695
- });
1696
- }
1761
+ // Navigate back to parent if we ended at a child
1762
+ if (currentChildIndex >= 0) {
1763
+ patches.push({
1764
+ type: NavigateParent
1765
+ });
1766
+ currentChildIndex = -1;
1767
+ }
1768
+ // Add remove patches in reverse order (highest index first)
1769
+ // This ensures indices remain valid as we remove
1770
+ for (let j = indicesToRemove.length - 1; j >= 0; j--) {
1697
1771
  patches.push({
1698
1772
  type: RemoveChild,
1699
- index: siblingOffset
1773
+ index: indicesToRemove[j]
1700
1774
  });
1701
- i += getTotalChildCount(oldNodes, i);
1702
- indexStack.pop();
1703
- indexStack.pop();
1704
1775
  }
1705
- while (j < newNodes.length) {
1706
- if (siblingOffset > 0) {
1776
+ };
1777
+ const diffTrees = (oldTree, newTree, patches, path) => {
1778
+ // At the root level (path.length === 0), we're already AT the element
1779
+ // So we compare the root node directly, then compare its children
1780
+ if (path.length === 0 && oldTree.length === 1 && newTree.length === 1) {
1781
+ const oldNode = oldTree[0];
1782
+ const newNode = newTree[0];
1783
+ // Compare root nodes
1784
+ const nodePatches = compareNodes(oldNode.node, newNode.node);
1785
+ // If nodePatches is null, the root node types are incompatible - need to replace
1786
+ if (nodePatches === null) {
1787
+ const flatNodes = treeToArray(newNode);
1707
1788
  patches.push({
1708
- type: NavigateSibling,
1709
- index: siblingOffset
1789
+ type: Replace$1,
1790
+ nodes: flatNodes
1710
1791
  });
1711
- siblingOffset = 0;
1792
+ return;
1712
1793
  }
1713
- const count = getTotalChildCount(newNodes, j);
1714
- patches.push({
1715
- type: Add,
1716
- nodes: newNodes.slice(j, j + count)
1717
- });
1718
- j += count;
1794
+ if (nodePatches.length > 0) {
1795
+ patches.push(...nodePatches);
1796
+ }
1797
+ // Compare children
1798
+ if (oldNode.children.length > 0 || newNode.children.length > 0) {
1799
+ diffChildren(oldNode.children, newNode.children, patches);
1800
+ }
1801
+ } else {
1802
+ // Non-root level or multiple root elements - use the regular comparison
1803
+ diffChildren(oldTree, newTree, patches);
1719
1804
  }
1720
- return patches;
1805
+ };
1806
+
1807
+ const removeTrailingNavigationPatches = patches => {
1808
+ // Find the last non-navigation patch
1809
+ let lastNonNavigationIndex = -1;
1810
+ for (let i = patches.length - 1; i >= 0; i--) {
1811
+ const patch = patches[i];
1812
+ if (patch.type !== NavigateChild && patch.type !== NavigateParent && patch.type !== NavigateSibling) {
1813
+ lastNonNavigationIndex = i;
1814
+ break;
1815
+ }
1816
+ }
1817
+ // Return patches up to and including the last non-navigation patch
1818
+ return lastNonNavigationIndex === -1 ? [] : patches.slice(0, lastNonNavigationIndex + 1);
1819
+ };
1820
+
1821
+ const diffTree = (oldNodes, newNodes) => {
1822
+ // Step 1: Convert flat arrays to tree structures
1823
+ const oldTree = arrayToTree(oldNodes);
1824
+ const newTree = arrayToTree(newNodes);
1825
+ // Step 3: Compare the trees
1826
+ const patches = [];
1827
+ diffTrees(oldTree, newTree, patches, []);
1828
+ // Remove trailing navigation patches since they serve no purpose
1829
+ return removeTrailingNavigationPatches(patches);
1721
1830
  };
1722
1831
 
1723
1832
  const User = 1;
@@ -1911,6 +2020,9 @@ const hasReplaceExpanded = flags => {
1911
2020
  const hasDetailsExpanded = flags => {
1912
2021
  return (flags & DetailsExpanded) === DetailsExpanded;
1913
2022
  };
2023
+ const hasUseIgnoreFiles = flags => {
2024
+ return (flags & UseIgnoreFiles) === UseIgnoreFiles;
2025
+ };
1914
2026
 
1915
2027
  const collapseDetails = state => {
1916
2028
  const {
@@ -1952,6 +2064,9 @@ const copyPath$1 = async state => {
1952
2064
  return state;
1953
2065
  };
1954
2066
 
2067
+ const defaultExcludes = ['.git', 'node_modules'];
2068
+ defaultExcludes.join(',');
2069
+
1955
2070
  const minimumSliderSize = 20;
1956
2071
 
1957
2072
  const {
@@ -1994,6 +2109,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
1994
2109
  disposed: false,
1995
2110
  fileCount: 0,
1996
2111
  height,
2112
+ initial: true,
1997
2113
  searchResults: [],
1998
2114
  stats: {},
1999
2115
  uid,
@@ -2009,11 +2125,12 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
2009
2125
  }),
2010
2126
  assetDir,
2011
2127
  collapsedPaths: [],
2128
+ defaultExcludes: defaultExcludes,
2012
2129
  deltaY: 0,
2013
2130
  excludeValue: '',
2014
2131
  fileIconCache: {},
2015
2132
  finalDeltaY: 0,
2016
- flags: 0,
2133
+ flags: UseIgnoreFiles,
2017
2134
  focus: Empty,
2018
2135
  focused: false,
2019
2136
  focusedIndex: -1,
@@ -2106,7 +2223,7 @@ const isEqual = (oldState, newState) => {
2106
2223
  };
2107
2224
 
2108
2225
  const modules = [isEqual$2, isEqual$5, isEqual$3, isEqual$6, isEqual$1, isEqual, isEqual$4];
2109
- const numbers = [RenderItems, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext];
2226
+ const numbers = [RenderIncremental, RenderFocus, RenderIncludeValue, RenderExcludeValue, RenderReplaceValue, RenderValue, RenderFocusContext];
2110
2227
 
2111
2228
  const diff = (oldState, newState) => {
2112
2229
  const diffResult = [];
@@ -2867,7 +2984,7 @@ const getMenuEntriesList = (state, props) => {
2867
2984
  };
2868
2985
 
2869
2986
  const getMenuEntries = (state, props) => {
2870
- if (props.menuId === Search$2) {
2987
+ if (props.menuId === Search$1) {
2871
2988
  return getMenuEntriesList(state, props);
2872
2989
  }
2873
2990
  if (props.menuId === InputContextMenu) {
@@ -2877,7 +2994,7 @@ const getMenuEntries = (state, props) => {
2877
2994
  };
2878
2995
 
2879
2996
  const getMenuEntryIds = () => {
2880
- return [Search$2, InputContextMenu];
2997
+ return [Search$1, InputContextMenu];
2881
2998
  };
2882
2999
 
2883
3000
  const ClearAll$1 = 'ClearAll';
@@ -3023,6 +3140,7 @@ const handleUpdateFull = async (state, update) => {
3023
3140
  results
3024
3141
  } = await textSearch$6(root, value, {
3025
3142
  assetDir,
3143
+ defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
3026
3144
  exclude: excludeValue,
3027
3145
  flags,
3028
3146
  include: includeValue,
@@ -3081,12 +3199,20 @@ const handleUpdateFull = async (state, update) => {
3081
3199
  };
3082
3200
 
3083
3201
  const getRipGrepArgs = ({
3202
+ defaultExcludes,
3203
+ exclude,
3084
3204
  isCaseSensitive,
3085
3205
  searchString,
3086
3206
  threads,
3087
3207
  useRegularExpression
3088
3208
  }) => {
3089
3209
  const ripGrepArgs = ['--hidden', '--no-require-git', '--smart-case', '--stats', '--json', '--threads', `${threads}`];
3210
+ const excludePatternsFromValue = exclude ? exclude.split(',').map(part => part.trim()).filter(Boolean) : [];
3211
+ const excludePatternsFromDefaults = defaultExcludes?.filter(Boolean) || [];
3212
+ const uniqueExcludePatterns = [...new Set([...excludePatternsFromDefaults, ...excludePatternsFromValue])];
3213
+ for (const excludePattern of uniqueExcludePatterns) {
3214
+ ripGrepArgs.push('--glob', `!**/${excludePattern}/**`);
3215
+ }
3090
3216
  if (isCaseSensitive) {
3091
3217
  ripGrepArgs.push('--case-sensitive');
3092
3218
  } else {
@@ -3188,6 +3314,7 @@ const handleUpdateIncremental = async (state, update) => {
3188
3314
  // TODO await promise?
3189
3315
  void textSearchIncremental(root, value, {
3190
3316
  assetDir: assetDir,
3317
+ defaultExcludes: hasUseIgnoreFiles(flags) ? partialNewState.defaultExcludes : [],
3191
3318
  exclude: excludeValue,
3192
3319
  flags,
3193
3320
  include: includeValue,
@@ -3446,6 +3573,7 @@ const toggleUseRegularExpression = state => {
3446
3573
  };
3447
3574
 
3448
3575
  const getClickHandler = name => {
3576
+ // TODO maybe add a click handler to each button instead
3449
3577
  switch (name) {
3450
3578
  case MatchCase:
3451
3579
  return toggleMatchCase;
@@ -4414,7 +4542,7 @@ const getSavedFlags = savedState => {
4414
4542
  if (savedState && typeof savedState === 'object' && 'flags' in savedState && typeof savedState.flags === 'number') {
4415
4543
  return savedState.flags;
4416
4544
  }
4417
- return 0;
4545
+ return UseIgnoreFiles;
4418
4546
  };
4419
4547
  const getSavedIncludeValue = savedState => {
4420
4548
  if (savedState && typeof savedState === 'object' && 'includeValue' in savedState && typeof savedState.includeValue === 'string') {
@@ -4476,6 +4604,7 @@ const loadContent = async (state, savedState) => {
4476
4604
  const result = await handleUpdate(state, update);
4477
4605
  return {
4478
4606
  ...result,
4607
+ initial: false,
4479
4608
  loaded: true
4480
4609
  };
4481
4610
  }
@@ -4483,6 +4612,7 @@ const loadContent = async (state, savedState) => {
4483
4612
  ...state,
4484
4613
  ...update,
4485
4614
  flags,
4615
+ initial: false,
4486
4616
  loaded: true,
4487
4617
  threads
4488
4618
  };
@@ -4581,7 +4711,7 @@ const renderFocus = (oldState, newState) => {
4581
4711
  };
4582
4712
 
4583
4713
  const renderFocusContext = (oldState, newState) => {
4584
- return [SetFocusContext, newState.uid, FocusSearch$1, newState.focus];
4714
+ return [SetFocusContext, newState.uid, FocusSearch, newState.focus];
4585
4715
  };
4586
4716
 
4587
4717
  const None = 0;
@@ -4751,7 +4881,7 @@ const getSearchDetailsToggleVirtualDom = () => {
4751
4881
  role: Button$3,
4752
4882
  tabIndex: 0,
4753
4883
  title: toggleSearchDetails(),
4754
- type: Button$1
4884
+ type: Button$2
4755
4885
  }, {
4756
4886
  childCount: 0,
4757
4887
  className: mergeClassNames(MaskIcon, MaskIconEllipsis),
@@ -4871,7 +5001,7 @@ const getSearchFieldButtonVirtualDom = button => {
4871
5001
  role,
4872
5002
  tabIndex: 0,
4873
5003
  title,
4874
- type: Button$1
5004
+ type: Button$2
4875
5005
  }, {
4876
5006
  childCount: 0,
4877
5007
  className: mergeClassNames(MaskIcon, icon),
@@ -5048,7 +5178,7 @@ const getSearchToggleVirtualDom = replaceExpanded => {
5048
5178
  name: ToggleReplace,
5049
5179
  onClick: HandleButtonClick,
5050
5180
  title: toggleReplace$1(),
5051
- type: Button$1
5181
+ type: Button$2
5052
5182
  }, {
5053
5183
  childCount: 0,
5054
5184
  className: mergeClassNames(MaskIcon, replaceExpanded ? MaskIconChevronDown : MaskIconChevronRight),
@@ -5263,7 +5393,7 @@ const getSearchRemoveVirtualDom = () => {
5263
5393
  className: SearchRemove,
5264
5394
  name: Remove,
5265
5395
  title,
5266
- type: Button$1
5396
+ type: Button$2
5267
5397
  }, closeIcon];
5268
5398
  return dom;
5269
5399
  };
@@ -5342,8 +5472,11 @@ const getSearchResultsVirtualDom = (visibleItems, focusOutline, scrollbarHeight,
5342
5472
  }, ...getTreeItemsVirtualDom(visibleItems, deltaY, itemHeight), ...getScrollBarVirtualDom(scrollbarHeight, scrollBarY, scrollBarValue)];
5343
5473
  };
5344
5474
 
5345
- const className = mergeClassNames(Viewlet, Search$1);
5346
- const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0) => {
5475
+ const className = mergeClassNames(Viewlet, Search$2);
5476
+ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchInputErrorMessage, scrollBarHeight, scrollBarY, scrollBarValue, deltaY, itemHeight, matchCount, limitHitWarning, focus = 0, initial = false) => {
5477
+ if (initial) {
5478
+ return [];
5479
+ }
5347
5480
  const errorDom = getSearchInputErrorVirtualDom(searchInputErrorMessage);
5348
5481
  const childCount = 2 + (errorDom.length > 0 ? 1 : 0);
5349
5482
  return [{
@@ -5355,16 +5488,16 @@ const getSearchVirtualDom = (visibleItems, flags, message, focusOutline, searchI
5355
5488
 
5356
5489
  const renderItems = (oldState, newState) => {
5357
5490
  const viewModel = createViewModel(newState);
5358
- const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount, newState.limitHitWarning, viewModel.focus);
5491
+ const dom = getSearchVirtualDom(viewModel.displayResults, viewModel.flags, viewModel.message, viewModel.focusOutline, viewModel.searchInputErrorMessage, viewModel.scrollBarHeight, viewModel.scrollBarY, viewModel.scrollBarValue, viewModel.deltaY, viewModel.itemHeight, viewModel.matchCount, newState.limitHitWarning, viewModel.focus, newState.initial);
5359
5492
  return [SetDom2, newState.uid, dom];
5360
5493
  };
5361
5494
 
5362
5495
  // TODO cache rendered dom so that it can be used for dom diffing
5363
5496
  const renderIncremental = (oldState, newState) => {
5364
- const oldDom = renderItems(oldState, oldState);
5365
- const newDom = renderItems(newState, newState);
5366
- const patches = diff$1(oldDom, newDom);
5367
- return patches;
5497
+ const oldDom = renderItems(oldState, oldState)[2];
5498
+ const newDom = renderItems(newState, newState)[2];
5499
+ const patches = diffTree(oldDom, newDom);
5500
+ return ['Viewlet.setPatches', newState.uid, patches];
5368
5501
  };
5369
5502
 
5370
5503
  const renderSelections = (oldState, newState) => {
@@ -5461,7 +5594,7 @@ const getActionButtonVirtualDom = action => {
5461
5594
  className,
5462
5595
  name: id,
5463
5596
  title: label,
5464
- type: Button$1
5597
+ type: Button$2
5465
5598
  }, getIconVirtualDom(icon)];
5466
5599
  };
5467
5600
 
@@ -5558,7 +5691,7 @@ const renderEventListeners = () => {
5558
5691
  params: ['handleClickAt', ClientX, ClientY, TargetName]
5559
5692
  }, {
5560
5693
  name: HandleListPointerDown,
5561
- params: ['handleListPointerDown', Button$2, TargetName]
5694
+ params: ['handleListPointerDown', Button$1, TargetName]
5562
5695
  }, {
5563
5696
  name: HandleToggleButtonClick,
5564
5697
  params: ['handleToggleButtonClick']
@@ -5570,11 +5703,11 @@ const renderEventListeners = () => {
5570
5703
  params: ['handleListBlur']
5571
5704
  }, {
5572
5705
  name: HandleListContextMenu,
5573
- params: ['handleContextMenu', Button$2, ClientX, ClientY],
5706
+ params: ['handleContextMenu', Button$1, ClientX, ClientY],
5574
5707
  preventDefault: true
5575
5708
  }, {
5576
5709
  name: HandleInputContextMenu,
5577
- params: ['handleInputContextMenu', TargetName, Button$2, ClientX, ClientY],
5710
+ params: ['handleInputContextMenu', TargetName, Button$1, ClientX, ClientY],
5578
5711
  preventDefault: true
5579
5712
  }, {
5580
5713
  name: HandleActionClick,
@@ -5702,8 +5835,11 @@ const focusElement = (state, focusKey) => {
5702
5835
  };
5703
5836
 
5704
5837
  const handleFocusIn = async (state, key) => {
5838
+ const {
5839
+ focus
5840
+ } = state;
5705
5841
  const focusKey = getSearchFocusKey(key);
5706
- if (state.focus === focusKey) {
5842
+ if (focus === focusKey) {
5707
5843
  return state;
5708
5844
  }
5709
5845
  return {
@@ -5782,10 +5918,10 @@ const handleContextMenuKeyboard = async state => {
5782
5918
  x,
5783
5919
  y
5784
5920
  } = state; // TODO
5785
- await show2(uid, Search$2, x, y, {
5921
+ await show2(uid, Search$1, x, y, {
5786
5922
  index: 0,
5787
5923
  // TODO pass proper index
5788
- menuId: Search$2
5924
+ menuId: Search$1
5789
5925
  });
5790
5926
  return state;
5791
5927
  };
@@ -5811,9 +5947,9 @@ const handleContextMenuMouseAt = async (state, eventX, eventY) => {
5811
5947
  focusedIndex: index,
5812
5948
  listFocusedIndex: index
5813
5949
  });
5814
- await show2(uid, Search$2, x, y, {
5950
+ await show2(uid, Search$1, x, y, {
5815
5951
  index,
5816
- menuId: Search$2
5952
+ menuId: Search$1
5817
5953
  });
5818
5954
  return state;
5819
5955
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-worker",
3
- "version": "5.34.0",
3
+ "version": "6.1.0",
4
4
  "description": "Text Search Worker",
5
5
  "keywords": [
6
6
  "text-search"