@lvce-editor/panel-worker 2.6.1 → 2.7.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.
@@ -1583,10 +1583,34 @@ const getUid = () => {
1583
1583
  return Math.random();
1584
1584
  };
1585
1585
 
1586
+ const command = 'SaveState.saveViewletStateWithStorageId';
1587
+ const isCommandNotFoundError = error => {
1588
+ if (!(error instanceof Error)) {
1589
+ return false;
1590
+ }
1591
+ const message = error.message.toLowerCase();
1592
+ return message.includes(command.toLowerCase()) && message.includes('not found');
1593
+ };
1594
+ const saveViewletState = async (childUid, viewletId) => {
1595
+ if (childUid <= 0 || !viewletId) {
1596
+ return;
1597
+ }
1598
+ try {
1599
+ await invoke(command, childUid, viewletId);
1600
+ } catch (error) {
1601
+ if (!isCommandNotFoundError(error)) {
1602
+ throw error;
1603
+ }
1604
+ }
1605
+ };
1606
+
1586
1607
  const openViewlet = async (state, id, focus = false, uri = '') => {
1587
1608
  const {
1609
+ childUid: currentChildUid,
1610
+ currentViewletId,
1588
1611
  views
1589
1612
  } = state;
1613
+ await saveViewletState(currentChildUid, currentViewletId);
1590
1614
  const childDimensions = getContentDimensions(state);
1591
1615
  const childUid = getUid();
1592
1616
  const tabId = getUid();
@@ -2212,10 +2236,12 @@ const resize = async (state, dimensions) => {
2212
2236
  };
2213
2237
  };
2214
2238
 
2215
- const saveState = state => {
2239
+ const saveState = async state => {
2216
2240
  const {
2241
+ childUid,
2217
2242
  currentViewletId
2218
2243
  } = state;
2244
+ await saveViewletState(childUid, currentViewletId);
2219
2245
  return {
2220
2246
  currentViewletId
2221
2247
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/panel-worker",
3
- "version": "2.6.1",
3
+ "version": "2.7.0",
4
4
  "description": "Panel Worker",
5
5
  "repository": {
6
6
  "type": "git",