@lvce-editor/main-area-worker 9.33.3 → 9.34.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.
@@ -2016,10 +2016,38 @@ const notifyActiveEditorChange = async (oldState, newState) => {
2016
2016
  }
2017
2017
  };
2018
2018
 
2019
+ const getMountedViewletUids = state => {
2020
+ const mountedViewletUids = [];
2021
+ for (const group of state.layout.groups) {
2022
+ const activeTab = group.tabs.find(tab => tab.id === group.activeTabId);
2023
+ if (activeTab?.loadingState === 'loaded' && activeTab.editorUid !== -1) {
2024
+ mountedViewletUids.push(activeTab.editorUid);
2025
+ }
2026
+ }
2027
+ return mountedViewletUids;
2028
+ };
2029
+
2030
+ const arraysEqual = (a, b) => {
2031
+ return a.length === b.length && a.every((value, index) => value === b[index]);
2032
+ };
2033
+ const notifyMountedViewlets = async (oldState, newState) => {
2034
+ const oldViewletUids = getMountedViewletUids(oldState);
2035
+ const newViewletUids = getMountedViewletUids(newState);
2036
+ if (oldState.uid === newState.uid && arraysEqual(oldViewletUids, newViewletUids)) {
2037
+ return;
2038
+ }
2039
+ try {
2040
+ await invoke('Layout.setMountedViewlets', newState.uid, newViewletUids);
2041
+ } catch (error) {
2042
+ console.warn('Failed to publish mounted viewlets', error);
2043
+ }
2044
+ };
2045
+
2019
2046
  const withActiveEditorChange = fn => {
2020
2047
  return async (state, ...args) => {
2021
2048
  const newState = await fn(state, ...args);
2022
2049
  await notifyActiveEditorChange(state, newState);
2050
+ await notifyMountedViewlets(state, newState);
2023
2051
  return newState;
2024
2052
  };
2025
2053
  };
@@ -2029,6 +2057,7 @@ const withActiveEditorChangeAsync = fn => {
2029
2057
  await fn(context, ...args);
2030
2058
  const newState = context.getState();
2031
2059
  await notifyActiveEditorChange(oldState, newState);
2060
+ await notifyMountedViewlets(oldState, newState);
2032
2061
  };
2033
2062
  };
2034
2063
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/main-area-worker",
3
- "version": "9.33.3",
3
+ "version": "9.34.0",
4
4
  "description": "Main Area Worker",
5
5
  "repository": {
6
6
  "type": "git",