@lvce-editor/status-bar-worker 3.26.1 → 3.27.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.
@@ -267,7 +267,8 @@ const {
267
267
  registerCommands,
268
268
  set: set$7,
269
269
  wrapCommand,
270
- wrapGetter
270
+ wrapGetter,
271
+ wrapSerialCommand
271
272
  } = create$8();
272
273
 
273
274
  const create$7 = (uid, uri, x, y, width, height, platform, assetDir) => {
@@ -314,6 +315,10 @@ const diff2 = uid => {
314
315
  return result;
315
316
  };
316
317
 
318
+ const getComponentState = uid => {
319
+ return get$5(uid).newState;
320
+ };
321
+
317
322
  const getMatchingItemInternal = (items, name) => {
318
323
  for (const item of items) {
319
324
  if (item.name === name) {
@@ -1946,13 +1951,17 @@ const getStatusBarItems = async ({
1946
1951
  return [...uiStatusBarItems.map(toStatusBarItem), ...extraItems];
1947
1952
  };
1948
1953
 
1954
+ const refreshVersions = Object.create(null);
1949
1955
  const handleExtensionsChanged = async state => {
1950
1956
  const {
1951
1957
  assetDir,
1952
1958
  errorCount,
1953
1959
  platform,
1960
+ uid,
1954
1961
  warningCount
1955
1962
  } = state;
1963
+ const refreshVersion = (refreshVersions[uid] || 0) + 1;
1964
+ refreshVersions[uid] = refreshVersion;
1956
1965
  // TODO requery status bar items
1957
1966
  const statusBarItems = await getStatusBarItems({
1958
1967
  assetDir,
@@ -1963,6 +1972,9 @@ const handleExtensionsChanged = async state => {
1963
1972
  showItems: true,
1964
1973
  warningCount
1965
1974
  });
1975
+ if (refreshVersions[uid] !== refreshVersion) {
1976
+ return state;
1977
+ }
1966
1978
  return {
1967
1979
  ...state,
1968
1980
  statusBarItemsLeft: [...statusBarItems]
@@ -2340,6 +2352,15 @@ const handleProblemsSummaryChange = (state, summary) => {
2340
2352
  };
2341
2353
  };
2342
2354
 
2355
+ const handleWorkspaceChange = async state => {
2356
+ const {
2357
+ assetDir,
2358
+ platform
2359
+ } = state;
2360
+ await invoke$3('Extensions.activateByEvent', 'onStatusBarItem', assetDir, platform);
2361
+ return state;
2362
+ };
2363
+
2343
2364
  const initialize = async () => {};
2344
2365
 
2345
2366
  const getIndex = (items, item) => {
@@ -2472,21 +2493,45 @@ const saveState = state => {
2472
2493
  };
2473
2494
  };
2474
2495
 
2496
+ const applyComponentState = (currentState, state) => {
2497
+ if (!state || typeof state !== 'object' || Array.isArray(state)) {
2498
+ throw new TypeError('Status Bar state must be an object');
2499
+ }
2500
+ const {
2501
+ uid
2502
+ } = state;
2503
+ const {
2504
+ uid: currentUid
2505
+ } = currentState;
2506
+ if (uid !== currentUid) {
2507
+ throw new Error(`Status Bar state uid must remain ${currentUid}`);
2508
+ }
2509
+ return state;
2510
+ };
2511
+ const setComponentState = wrapCommand(applyComponentState);
2512
+
2475
2513
  const handleDirectMessagePort = (port, setAsRendererProcess = true) => handleMessagePort(port, commandMap, setAsRendererProcess);
2514
+ const activateOnWorkspaceChange = wrapCommand(handleWorkspaceChange);
2515
+ const refreshExtensionItems = wrapSerialCommand(handleItemsChanged);
2516
+ const handleWorkspaceChangeAndRefresh = async (uid, workspacePath) => {
2517
+ await activateOnWorkspaceChange(uid, workspacePath);
2518
+ await refreshExtensionItems(uid);
2519
+ };
2476
2520
  const commandMap = {
2477
2521
  'StatusBar.create': create$7,
2478
2522
  'StatusBar.diff2': diff2,
2479
2523
  'StatusBar.getCommandIds': getCommandIds,
2480
- 'StatusBar.handleChange': wrapCommand(handleItemsChanged),
2524
+ 'StatusBar.getComponentState': getComponentState,
2525
+ 'StatusBar.handleChange': wrapSerialCommand(handleItemsChanged),
2481
2526
  'StatusBar.handleClick': wrapCommand(handleClick),
2482
2527
  'StatusBar.handleContextMenu': wrapCommand(handleContextMenu),
2483
2528
  'StatusBar.handleExtensionManagementMessagePort': handleExtensionManagementMessagePort,
2484
2529
  'StatusBar.handleExtensionsChanged': wrapCommand(handleExtensionsChanged),
2485
- 'StatusBar.handleItemsChanged': wrapCommand(handleItemsChanged),
2530
+ 'StatusBar.handleItemsChanged': wrapSerialCommand(handleItemsChanged),
2486
2531
  'StatusBar.handleMessagePort': handleDirectMessagePort,
2487
2532
  'StatusBar.handleNotificationCountChanged': wrapCommand(handleNotificationCountChanged),
2488
2533
  'StatusBar.handleProblemsSummaryChange': wrapCommand(handleProblemsSummaryChange),
2489
- 'StatusBar.handleWorkspaceChange': wrapCommand(handleExtensionsChanged),
2534
+ 'StatusBar.handleWorkspaceChange': handleWorkspaceChangeAndRefresh,
2490
2535
  'StatusBar.initialize': initialize,
2491
2536
  'StatusBar.itemLeftUpdate': wrapCommand(itemLeftUpdate),
2492
2537
  'StatusBar.itemRightCreate': wrapCommand(itemRightCreate),
@@ -2496,6 +2541,7 @@ const commandMap = {
2496
2541
  'StatusBar.renderEventListeners': renderEventListeners,
2497
2542
  'StatusBar.resize': wrapCommand(resize),
2498
2543
  'StatusBar.saveState': wrapGetter(saveState),
2544
+ 'StatusBar.setComponentState': setComponentState,
2499
2545
  'StatusBar.terminate': terminate
2500
2546
  };
2501
2547
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/status-bar-worker",
3
- "version": "3.26.1",
3
+ "version": "3.27.0",
4
4
  "description": "Status Bar Worker",
5
5
  "repository": {
6
6
  "type": "git",