@lvce-editor/text-search-view 1.6.5 → 1.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1135,7 +1135,7 @@ const createMockRpc = ({
1135
1135
  };
1136
1136
 
1137
1137
  const rpcs = Object.create(null);
1138
- const set$4 = (id, rpc) => {
1138
+ const set$7 = (id, rpc) => {
1139
1139
  rpcs[id] = rpc;
1140
1140
  };
1141
1141
  const get$1 = id => {
@@ -1168,7 +1168,7 @@ const create$3 = rpcId => {
1168
1168
  const mockRpc = createMockRpc({
1169
1169
  commandMap
1170
1170
  });
1171
- set$4(rpcId, mockRpc);
1171
+ set$7(rpcId, mockRpc);
1172
1172
  // @ts-ignore
1173
1173
  mockRpc[Symbol.dispose] = () => {
1174
1174
  remove$2(rpcId);
@@ -1177,7 +1177,7 @@ const create$3 = rpcId => {
1177
1177
  return mockRpc;
1178
1178
  },
1179
1179
  set(rpc) {
1180
- set$4(rpcId, rpc);
1180
+ set$7(rpcId, rpc);
1181
1181
  }
1182
1182
  };
1183
1183
  };
@@ -1443,7 +1443,9 @@ const None$1 = 0;
1443
1443
 
1444
1444
  const LeftClick = 0;
1445
1445
 
1446
+ const DialogWorker = 7014;
1446
1447
  const IconThemeWorker = 7009;
1448
+ const RendererProcess = 1670;
1447
1449
  const RendererWorker = 1;
1448
1450
  const TextSearchWorker = 7010;
1449
1451
 
@@ -1474,59 +1476,73 @@ const FocusToggleDetails = 1010;
1474
1476
  const FocusToggleReplace = 1020;
1475
1477
 
1476
1478
  const {
1477
- invoke: invoke$2,
1478
- set: set$3
1479
+ invoke: invoke$5,
1480
+ set: set$6
1481
+ } = create$3(DialogWorker);
1482
+
1483
+ const {
1484
+ invoke: invoke$4,
1485
+ set: set$5
1479
1486
  } = create$3(IconThemeWorker);
1480
1487
  const getIcons = async iconRequests => {
1481
1488
  // @ts-ignore
1482
- return invoke$2('IconTheme.getIcons', iconRequests);
1489
+ return invoke$4('IconTheme.getIcons', iconRequests);
1483
1490
  };
1484
1491
 
1485
1492
  const {
1486
- invoke: invoke$1,
1493
+ invoke: invoke$3,
1494
+ set: set$4
1495
+ } = create$3(RendererProcess);
1496
+
1497
+ const {
1498
+ invoke: invoke$2,
1487
1499
  invokeAndTransfer,
1488
- set: set$2
1500
+ set: set$3
1489
1501
  } = create$3(RendererWorker);
1490
1502
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1491
1503
  number(uid);
1492
1504
  number(menuId);
1493
1505
  number(x);
1494
1506
  number(y);
1495
- await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1507
+ await invoke$2('ContextMenu.show2', uid, menuId, x, y, args);
1496
1508
  };
1497
1509
  const sendMessagePortToTextSearchWorker = async (port, rpcId) => {
1498
1510
  const command = 'HandleMessagePort.handleMessagePort';
1499
1511
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToTextSearchWorker', port, command, rpcId);
1500
1512
  };
1513
+ const sendMessagePortToDialogWorker = async port => {
1514
+ const command = 'HandleMessagePort.handleMessagePort';
1515
+ await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1516
+ };
1501
1517
  const sendMessagePortToIconThemeWorker = async (port, rpcId) => {
1502
1518
  const command = 'IconTheme.handleMessagePort';
1503
1519
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToIconThemeWorker', port, command, rpcId);
1504
1520
  };
1505
1521
  const handleWorkspaceRefresh = async () => {
1506
- return invoke$1('Layout.handleWorkspaceRefresh');
1522
+ return invoke$2('Layout.handleWorkspaceRefresh');
1507
1523
  };
1508
1524
  const writeClipBoardText = async text => {
1509
- await invoke$1('ClipBoard.writeText', /* text */text);
1525
+ await invoke$2('ClipBoard.writeText', /* text */text);
1510
1526
  };
1511
1527
  const getPreference = async key => {
1512
- return await invoke$1('Preferences.get', key);
1528
+ return await invoke$2('Preferences.get', key);
1513
1529
  };
1514
1530
  const openUri$1 = async (uri, focus, options) => {
1515
- await invoke$1('Main.openUri', uri, focus, options);
1531
+ await invoke$2('Main.openUri', uri, focus, options);
1516
1532
  };
1517
1533
 
1518
1534
  const {
1519
- invoke,
1520
- set: set$1
1535
+ invoke: invoke$1,
1536
+ set: set$2
1521
1537
  } = create$3(TextSearchWorker);
1522
1538
  const getIncrementalResults = async (searchId, minLineY, maxLineY) => {
1523
- return invoke('TextSearch.getIncrementalResults', searchId, minLineY, maxLineY);
1539
+ return invoke$1('TextSearch.getIncrementalResults', searchId, minLineY, maxLineY);
1524
1540
  };
1525
1541
  const search$1 = async (...args) => {
1526
- return invoke('TextSearch.search', ...args);
1542
+ return invoke$1('TextSearch.search', ...args);
1527
1543
  };
1528
1544
  const searchIncremental = async (...args) => {
1529
- return invoke('TextSearch.searchIncremental', ...args);
1545
+ return invoke$1('TextSearch.searchIncremental', ...args);
1530
1546
  };
1531
1547
 
1532
1548
  const toCommandId = key => {
@@ -2351,7 +2367,7 @@ const writeText = async text => {
2351
2367
  await writeClipBoardText(text);
2352
2368
  };
2353
2369
  const readText = async () => {
2354
- return await invoke$1('ClipBoard.readText');
2370
+ return await invoke$2('ClipBoard.readText');
2355
2371
  };
2356
2372
 
2357
2373
  const getActualIndex$1 = state => {
@@ -2429,7 +2445,7 @@ const {
2429
2445
  get,
2430
2446
  getCommandIds,
2431
2447
  registerCommands,
2432
- set,
2448
+ set: set$1,
2433
2449
  wrapAsyncCommand,
2434
2450
  wrapCommand,
2435
2451
  wrapGetter
@@ -2542,7 +2558,7 @@ const create = (uid, x, y, width, height, workspacePath, assetDir, itemHeight, v
2542
2558
  viewMode: List,
2543
2559
  workspacePath: workspacePath
2544
2560
  };
2545
- set(uid, state, state);
2561
+ set$1(uid, state, state);
2546
2562
  return state;
2547
2563
  };
2548
2564
 
@@ -3506,7 +3522,7 @@ const openSearchEditor = async state => {
3506
3522
 
3507
3523
  const getSearchExcludes = async (fallback = []) => {
3508
3524
  try {
3509
- const value = await invoke$1('Preferences.get', 'search.exclude');
3525
+ const value = await invoke$2('Preferences.get', 'search.exclude');
3510
3526
  if (!value || typeof value !== 'object' || Array.isArray(value)) {
3511
3527
  return [];
3512
3528
  }
@@ -3583,7 +3599,7 @@ const getProtocol = uri => {
3583
3599
  };
3584
3600
 
3585
3601
  const measureTextHeight = (text, fontFamily, fontSize, lineHeight, width) => {
3586
- return invoke$1('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, `${lineHeight}px`, width);
3602
+ return invoke$2('MeasureTextHeight.measureTextBlockHeight', text, fontFamily, fontSize, `${lineHeight}px`, width);
3587
3603
  };
3588
3604
 
3589
3605
  const SearchWarningFontFamily = 'system-ui';
@@ -3623,7 +3639,7 @@ const textSearch = async (root, query, options, assetDir, platform, searchId, ui
3623
3639
  if (!hasOpenEditors(options.flags)) {
3624
3640
  return search$1(root, query, options, assetDir, platform, searchId, uid);
3625
3641
  }
3626
- const openEditorUris = await invoke$1('GetActiveEditor.getOpenEditorUris');
3642
+ const openEditorUris = await invoke$2('GetActiveEditor.getOpenEditorUris');
3627
3643
  return search$1(root, query, {
3628
3644
  ...options,
3629
3645
  openEditorUris
@@ -3768,9 +3784,9 @@ const textSearchIncremental = async (root, query, options, assetDir, platform, s
3768
3784
  maxLineY: visible.length,
3769
3785
  minLineY: 0
3770
3786
  };
3771
- set(uid, latest2.oldState, updatedState2);
3787
+ set$1(uid, latest2.oldState, updatedState2);
3772
3788
  // @ts-ignore
3773
- await invoke$1('Search.rerender');
3789
+ await invoke$2('Search.rerender');
3774
3790
  await waitForNextFrame();
3775
3791
  }
3776
3792
  await resultPromise;
@@ -3807,7 +3823,7 @@ const handleUpdateIncremental = async (state, update) => {
3807
3823
  ...partialNewState,
3808
3824
  searchId
3809
3825
  };
3810
- set(uid, latest1.oldState, updatedState1);
3826
+ set$1(uid, latest1.oldState, updatedState1);
3811
3827
 
3812
3828
  // TODO await promise?
3813
3829
  void textSearchIncremental(root, value, {
@@ -3849,7 +3865,7 @@ const handleUpdatePullBased = async (state, update) => {
3849
3865
  searchId,
3850
3866
  searchResults: []
3851
3867
  };
3852
- set(previousUid, state, partialNewState);
3868
+ set$1(previousUid, state, partialNewState);
3853
3869
  const {
3854
3870
  assetDir,
3855
3871
  contextLines,
@@ -4024,7 +4040,7 @@ const noop = state => {
4024
4040
  };
4025
4041
 
4026
4042
  const applyBulkReplacement = async bulkEdits => {
4027
- await invoke$1('BulkReplacement.applyBulkReplacement', bulkEdits);
4043
+ await invoke$2('BulkReplacement.applyBulkReplacement', bulkEdits);
4028
4044
  };
4029
4045
 
4030
4046
  const getReplacedMessage = (fileCount, replaceCount, replacement) => {
@@ -4082,8 +4098,16 @@ const getReplacingMessage = (fileCount, replaceCount) => {
4082
4098
  return replacingManyOccurrencesInManyFiles(replaceCount, fileCount);
4083
4099
  };
4084
4100
 
4085
- const prompt = (text, options) => {
4086
- return invoke$1('ConfirmPrompt.prompt', text, options);
4101
+ const missingDialogWorkerRelay = 'Command "SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker" not found';
4102
+ const prompt = async (text, options) => {
4103
+ try {
4104
+ return await invoke$5('ConfirmPrompt.prompt', text, options);
4105
+ } catch (error) {
4106
+ if (!String(error).includes(missingDialogWorkerRelay)) {
4107
+ throw error;
4108
+ }
4109
+ return invoke$2('ConfirmPrompt.prompt', text, options);
4110
+ }
4087
4111
  };
4088
4112
 
4089
4113
  const getReplaceAllConfirmText = (matchCount, fileCount, replacement) => {
@@ -4283,7 +4307,7 @@ const replaceAllWithProgress = async context => {
4283
4307
  ...latestState,
4284
4308
  message
4285
4309
  }));
4286
- await invoke$1('Search.rerender');
4310
+ await invoke$2('Search.rerender');
4287
4311
  const updatedState = await replaceAllConfirmed(context.getState(), fileIndex);
4288
4312
  await context.updateState(() => updatedState);
4289
4313
  };
@@ -4782,6 +4806,31 @@ const handleListFocus = async state => {
4782
4806
  };
4783
4807
  };
4784
4808
 
4809
+ const state = {
4810
+ connected: false
4811
+ };
4812
+ const isConnected = () => {
4813
+ const {
4814
+ connected
4815
+ } = state;
4816
+ return connected;
4817
+ };
4818
+ const invoke = (method, ...params) => {
4819
+ return invoke$3(method, ...params);
4820
+ };
4821
+ const set = rpc => {
4822
+ set$4(rpc);
4823
+ state.connected = true;
4824
+ };
4825
+
4826
+ const handleMessagePort = async port => {
4827
+ const rpc = await create$7({
4828
+ commandMap: {},
4829
+ messagePort: port
4830
+ });
4831
+ set(rpc);
4832
+ };
4833
+
4785
4834
  const handlePullResultsFound = async (state, resultSearchId, newResults) => {
4786
4835
  const {
4787
4836
  fileIconCache,
@@ -4831,8 +4880,8 @@ const handlePullResultsFound = async (state, resultSearchId, newResults) => {
4831
4880
  scrollBarHeight
4832
4881
  };
4833
4882
  const oldState = latest ? latest.oldState : state;
4834
- set(uid, oldState, updatedState);
4835
- await invoke$1('Search.rerender');
4883
+ set$1(uid, oldState, updatedState);
4884
+ await invoke$2('Search.rerender');
4836
4885
  return state;
4837
4886
  };
4838
4887
 
@@ -4915,7 +4964,7 @@ const launchIconThemeWorker = async () => {
4915
4964
 
4916
4965
  const initializeIconThemeWorker = async () => {
4917
4966
  const rpc = await launchIconThemeWorker();
4918
- set$3(rpc);
4967
+ set$5(rpc);
4919
4968
  };
4920
4969
 
4921
4970
  const commandMap$1 = {
@@ -4934,7 +4983,7 @@ const launchTextSearchWorker = async () => {
4934
4983
 
4935
4984
  const initializeTextSearchWorker = async () => {
4936
4985
  const rpc = await launchTextSearchWorker();
4937
- set$1(rpc);
4986
+ set$2(rpc);
4938
4987
  };
4939
4988
 
4940
4989
  const initialize = async () => {
@@ -6615,14 +6664,23 @@ const applyRender = (oldState, newState, diffResult) => {
6615
6664
  return commands;
6616
6665
  };
6617
6666
 
6667
+ const renderDirect = async (uid, commands) => {
6668
+ const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
6669
+ const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
6670
+ const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
6671
+ return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
6672
+ };
6618
6673
  const render2 = (uid, diffResult) => {
6619
6674
  const {
6620
6675
  newState,
6621
6676
  oldState
6622
6677
  } = get(uid);
6623
- set(uid, newState, newState);
6678
+ set$1(uid, newState, newState);
6624
6679
  const commands = applyRender(oldState, newState, diffResult);
6625
- return commands;
6680
+ if (!isConnected()) {
6681
+ return commands;
6682
+ }
6683
+ return renderDirect(uid, commands);
6626
6684
  };
6627
6685
 
6628
6686
  const Button = 1;
@@ -6965,7 +7023,7 @@ const handleContextMenuMouseAt = async (state, eventX, eventY) => {
6965
7023
  newState,
6966
7024
  oldState
6967
7025
  } = get(uid);
6968
- set(uid, oldState, {
7026
+ set$1(uid, oldState, {
6969
7027
  ...newState,
6970
7028
  focusedIndex: index,
6971
7029
  listFocusedIndex: index
@@ -7058,6 +7116,7 @@ const commandMap = {
7058
7116
  'TextSearch.handleListBlur': wrapCommand(handleListBlur),
7059
7117
  'TextSearch.handleListFocus': wrapCommand(handleListFocus),
7060
7118
  'TextSearch.handleListPointerDown': wrapCommand(handleListPointerDown),
7119
+ 'TextSearch.handleMessagePort': handleMessagePort,
7061
7120
  'TextSearch.handlePullResultsFound': wrapCommand(handlePullResultsFound),
7062
7121
  'TextSearch.handleReplaceInput': wrapCommand(handleReplaceInput),
7063
7122
  'TextSearch.handleResize': wrapCommand(handleResize),
@@ -7108,7 +7167,12 @@ const listen = async () => {
7108
7167
  const rpc = await create$4({
7109
7168
  commandMap: commandMap
7110
7169
  });
7111
- set$2(rpc);
7170
+ set$3(rpc);
7171
+ const dialogRpc = await create$5({
7172
+ commandMap: {},
7173
+ send: sendMessagePortToDialogWorker
7174
+ });
7175
+ set$6(dialogRpc);
7112
7176
  };
7113
7177
 
7114
7178
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/text-search-view",
3
- "version": "1.6.5",
3
+ "version": "1.8.0",
4
4
  "description": "Text Search View",
5
5
  "keywords": [
6
6
  "text-search"