@lvce-editor/extension-search-view 7.16.1 → 7.18.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.
@@ -1123,7 +1123,7 @@ const createMockRpc = ({
1123
1123
  };
1124
1124
 
1125
1125
  const rpcs = Object.create(null);
1126
- const set$4 = (id, rpc) => {
1126
+ const set$6 = (id, rpc) => {
1127
1127
  rpcs[id] = rpc;
1128
1128
  };
1129
1129
  const get$1 = id => {
@@ -1156,7 +1156,7 @@ const create$3 = rpcId => {
1156
1156
  const mockRpc = createMockRpc({
1157
1157
  commandMap
1158
1158
  });
1159
- set$4(rpcId, mockRpc);
1159
+ set$6(rpcId, mockRpc);
1160
1160
  // @ts-ignore
1161
1161
  mockRpc[Symbol.dispose] = () => {
1162
1162
  remove(rpcId);
@@ -1165,7 +1165,7 @@ const create$3 = rpcId => {
1165
1165
  return mockRpc;
1166
1166
  },
1167
1167
  set(rpc) {
1168
- set$4(rpcId, rpc);
1168
+ set$6(rpcId, rpc);
1169
1169
  }
1170
1170
  };
1171
1171
  };
@@ -1359,70 +1359,77 @@ const LeftClick = 0;
1359
1359
 
1360
1360
  const DialogWorker = 7014;
1361
1361
  const ExtensionManagementWorker = 9006;
1362
+ const RendererProcess = 1670;
1362
1363
  const RendererWorker = 1;
1363
1364
 
1364
1365
  const FocusSelector = 'Viewlet.focusSelector';
1365
1366
  const SetCss = 'Viewlet.setCss';
1366
1367
  const SetDom2 = 'Viewlet.setDom2';
1368
+ const SetFocusContext = 'Viewlet.setFocusContext';
1367
1369
  const SetPatches = 'Viewlet.setPatches';
1368
1370
 
1369
1371
  const {
1370
- invoke: invoke$2,
1371
- set: set$3
1372
+ invoke: invoke$4,
1373
+ set: set$5
1372
1374
  } = create$3(DialogWorker);
1373
1375
 
1374
1376
  const {
1375
- invoke: invoke$1,
1376
- set: set$2
1377
+ invoke: invoke$3,
1378
+ set: set$4
1377
1379
  } = create$3(ExtensionManagementWorker);
1378
1380
  const disableWorkspace$2 = id => {
1379
- return invoke$1('Extensions.disableWorkspace', id);
1381
+ return invoke$3('Extensions.disableWorkspace', id);
1380
1382
  };
1381
1383
  const uninstall$2 = id => {
1382
- return invoke$1(`Extensions.uninstall`, id);
1384
+ return invoke$3(`Extensions.uninstall`, id);
1383
1385
  };
1384
1386
 
1385
1387
  const {
1386
- invoke,
1388
+ invoke: invoke$2,
1389
+ set: set$3
1390
+ } = create$3(RendererProcess);
1391
+
1392
+ const {
1393
+ invoke: invoke$1,
1387
1394
  invokeAndTransfer,
1388
- set: set$1
1395
+ set: set$2
1389
1396
  } = create$3(RendererWorker);
1390
1397
  const showContextMenu2 = async (uid, menuId, x, y, args) => {
1391
1398
  number(uid);
1392
1399
  number(menuId);
1393
1400
  number(x);
1394
1401
  number(y);
1395
- await invoke('ContextMenu.show2', uid, menuId, x, y, args);
1402
+ await invoke$1('ContextMenu.show2', uid, menuId, x, y, args);
1396
1403
  };
1397
1404
  const sendMessagePortToDialogWorker = async port => {
1398
1405
  const command = 'HandleMessagePort.handleMessagePort';
1399
1406
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToDialogWorker', port, command);
1400
1407
  };
1401
1408
  const disableExtension = async id => {
1402
- return invoke('ExtensionManagement.disable', id);
1409
+ return invoke$1('ExtensionManagement.disable', id);
1403
1410
  };
1404
1411
  const enableExtension = async id => {
1405
- return invoke('ExtensionManagement.enable', id);
1412
+ return invoke$1('ExtensionManagement.enable', id);
1406
1413
  };
1407
1414
  const writeClipBoardText = async text => {
1408
- await invoke('ClipBoard.writeText', /* text */text);
1415
+ await invoke$1('ClipBoard.writeText', /* text */text);
1409
1416
  };
1410
1417
  const sendMessagePortToExtensionManagementWorker = async (port, rpcId) => {
1411
1418
  const command = 'Extensions.handleMessagePort';
1412
1419
  await invokeAndTransfer('SendMessagePortToExtensionHostWorker.sendMessagePortToExtensionManagementWorker', port, command, rpcId);
1413
1420
  };
1414
1421
  const openUri$1 = async (uri, focus, options) => {
1415
- await invoke('Main.openUri', {
1422
+ await invoke$1('Main.openUri', {
1416
1423
  ...options,
1417
1424
  focus,
1418
1425
  uri
1419
1426
  });
1420
1427
  };
1421
1428
  const showErrorDialog = async errorInfo => {
1422
- await invoke('ErrorHandling.showErrorDialog', errorInfo);
1429
+ await invoke$1('ErrorHandling.showErrorDialog', errorInfo);
1423
1430
  };
1424
1431
  const installExtension = async id => {
1425
- return invoke('ExtensionManagement.install', id);
1432
+ return invoke$1('ExtensionManagement.install', id);
1426
1433
  };
1427
1434
 
1428
1435
  const toCommandId = key => {
@@ -2467,7 +2474,7 @@ const {
2467
2474
  get,
2468
2475
  getCommandIds,
2469
2476
  registerCommands,
2470
- set,
2477
+ set: set$1,
2471
2478
  wrapAsyncCommand,
2472
2479
  wrapCommand,
2473
2480
  wrapGetter
@@ -2514,7 +2521,7 @@ const create = (id, uri, x, y, width, height, platform, assetDir, parentUid) =>
2514
2521
  y
2515
2522
  };
2516
2523
  create$1(id);
2517
- set(id, state, state);
2524
+ set$1(id, state, state);
2518
2525
  };
2519
2526
 
2520
2527
  const isEqual$4 = (oldState, newState) => {
@@ -2619,7 +2626,7 @@ const enableWorkspace = async state => {
2619
2626
  if (!item) {
2620
2627
  return state;
2621
2628
  }
2622
- await invoke$1('Extensions.enableWorkspace', item.id);
2629
+ await invoke$3('Extensions.enableWorkspace', item.id);
2623
2630
  return setExtensionStatus(state, item.id, Enabled);
2624
2631
  };
2625
2632
 
@@ -3562,7 +3569,7 @@ const Remote = 3;
3562
3569
 
3563
3570
  const getAllExtensions$1 = async (assetDir, platform) => {
3564
3571
  try {
3565
- return await invoke$1('Extensions.getAllExtensions', assetDir, platform);
3572
+ return await invoke$3('Extensions.getAllExtensions', assetDir, platform);
3566
3573
  } catch (error) {
3567
3574
  if (platform === Web) {
3568
3575
  return [];
@@ -3803,6 +3810,41 @@ const handleInstall = async (state, id) => {
3803
3810
  return setExtensionStatus(state, id, Enabled);
3804
3811
  };
3805
3812
 
3813
+ const state = {
3814
+ connected: false
3815
+ };
3816
+ const isConnected = () => {
3817
+ const {
3818
+ connected
3819
+ } = state;
3820
+ return connected;
3821
+ };
3822
+ const invoke = (method, ...params) => {
3823
+ return invoke$2(method, ...params);
3824
+ };
3825
+ const set = rpc => {
3826
+ set$3(rpc);
3827
+ state.connected = true;
3828
+ };
3829
+
3830
+ const handleMessagePort = async (port, viewletCommandMap) => {
3831
+ const executeViewletCommand = async (uid, command, ...args) => {
3832
+ const fn = viewletCommandMap[`SearchExtensions.${command}`];
3833
+ if (typeof fn !== 'function') {
3834
+ throw new TypeError(`Viewlet command not found: ${command}`);
3835
+ }
3836
+ await fn(uid, ...args);
3837
+ await invoke$1('Viewlet.requestRender', uid);
3838
+ };
3839
+ const rpc = await create$7({
3840
+ commandMap: {
3841
+ 'Viewlet.executeViewletCommand': executeViewletCommand
3842
+ },
3843
+ messagePort: port
3844
+ });
3845
+ set(rpc);
3846
+ };
3847
+
3806
3848
  const handleScrollBarCaptureLost = state => {
3807
3849
  return {
3808
3850
  ...state,
@@ -3995,7 +4037,7 @@ const createExtensionManagementWorkerRpc = async () => {
3995
4037
  const initializeExtensionManagementWorker = async () => {
3996
4038
  try {
3997
4039
  const rpc = await createExtensionManagementWorkerRpc();
3998
- set$2(rpc);
4040
+ set$4(rpc);
3999
4041
  } catch {
4000
4042
  // ignore
4001
4043
  }
@@ -4006,7 +4048,7 @@ const initialize = async () => {
4006
4048
  };
4007
4049
 
4008
4050
  const installAnotherVersion = async state => {
4009
- await invoke$2('ConfirmPrompt.prompt', 'not implemented', undefined);
4051
+ await invoke$4('ConfirmPrompt.prompt', 'not implemented', undefined);
4010
4052
  return state;
4011
4053
  };
4012
4054
 
@@ -4957,14 +4999,20 @@ const applyRender = (oldState, newState, diffResult) => {
4957
4999
  return commands;
4958
5000
  };
4959
5001
 
4960
- const render3 = (uid, diffResult) => {
5002
+ const render3 = async (uid, diffResult) => {
4961
5003
  const {
4962
5004
  newState,
4963
5005
  oldState
4964
5006
  } = get(uid);
4965
- set(uid, newState, newState);
5007
+ set$1(uid, newState, newState);
4966
5008
  const commands = applyRender(oldState, newState, diffResult);
4967
- return commands;
5009
+ if (!isConnected()) {
5010
+ return commands;
5011
+ }
5012
+ const rendererWorkerCommands = commands.filter(command => command[0] === SetFocusContext);
5013
+ const rendererProcessCommands = commands.filter(command => command[0] !== SetFocusContext);
5014
+ const transactionId = await invoke('Viewlet.queueCommands', uid, rendererProcessCommands);
5015
+ return [...rendererWorkerCommands, ['Viewlet.commitPending', uid, transactionId]];
4968
5016
  };
4969
5017
 
4970
5018
  const getIconVirtualDom = (icon, type = Div) => {
@@ -5168,6 +5216,7 @@ const toggleSuggest = state => {
5168
5216
  return state.suggestOpen ? closeSuggest(state) : openSuggest(state);
5169
5217
  };
5170
5218
 
5219
+ const handleDirectMessagePort = port => handleMessagePort(port, commandMap);
5171
5220
  const commandMap = {
5172
5221
  'Extensions.copyExtensionId': wrapCommand(copyExtensionId),
5173
5222
  'Extensions.copyExtensionInfo': wrapCommand(copyExtensionInfo),
@@ -5225,6 +5274,7 @@ const commandMap = {
5225
5274
  'SearchExtensions.handleInput': wrapAsyncCommand(handleInputWithContext),
5226
5275
  'SearchExtensions.handleInputFocus': wrapCommand(handleInputFocus),
5227
5276
  'SearchExtensions.handleInstall': wrapCommand(handleInstall),
5277
+ 'SearchExtensions.handleMessagePort': handleDirectMessagePort,
5228
5278
  'SearchExtensions.handleScrollBarCaptureLost': wrapCommand(handleScrollBarCaptureLost),
5229
5279
  'SearchExtensions.handleScrollBarClick': wrapCommand(handleScrollBarClick),
5230
5280
  'SearchExtensions.handleScrollBarMove': wrapCommand(handleScrollBarMove),
@@ -5258,12 +5308,12 @@ const listen = async () => {
5258
5308
  const rpc = await create$4({
5259
5309
  commandMap: commandMap
5260
5310
  });
5261
- set$1(rpc);
5311
+ set$2(rpc);
5262
5312
  const dialogRpc = await create$5({
5263
5313
  commandMap: {},
5264
5314
  send: sendMessagePortToDialogWorker
5265
5315
  });
5266
- set$3(dialogRpc);
5316
+ set$5(dialogRpc);
5267
5317
  };
5268
5318
 
5269
5319
  const main = async () => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/extension-search-view",
3
- "version": "7.16.1",
3
+ "version": "7.18.0",
4
4
  "description": "Extension Search View Worker",
5
5
  "repository": {
6
6
  "type": "git",