@lvce-editor/panel-worker 1.3.0 → 1.4.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.
@@ -1091,7 +1091,7 @@ const create = (uid, uri, x, y, width, height, platform, assetDir) => {
1091
1091
  };
1092
1092
 
1093
1093
  const isEqual = (oldState, newState) => {
1094
- return oldState.assetDir === newState.assetDir;
1094
+ return oldState.assetDir === newState.assetDir && oldState.initial === newState.initial && oldState.currentViewletId === newState.currentViewletId;
1095
1095
  };
1096
1096
 
1097
1097
  const RenderItems = 4;
@@ -1120,8 +1120,24 @@ const diff2 = uid => {
1120
1120
  return result;
1121
1121
  };
1122
1122
 
1123
- const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) => {
1124
- await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
1123
+ const handleClickClose = async state => {
1124
+ await invoke('Layout.hidePanel');
1125
+ return state;
1126
+ };
1127
+
1128
+ const handleClickMaximize = async state => {
1129
+ return state;
1130
+ };
1131
+
1132
+ const handleFilterInput = async (state, value) => {
1133
+ object(state);
1134
+ string(value);
1135
+ const {
1136
+ currentViewletId
1137
+ } = state;
1138
+ const fullCommand = `${currentViewletId}.handleFilterInput`;
1139
+ await invoke(fullCommand, value);
1140
+ return state;
1125
1141
  };
1126
1142
 
1127
1143
  const DebugConsole = 'Debug Console';
@@ -1140,33 +1156,10 @@ const getSavedViewletId = savedState => {
1140
1156
  }
1141
1157
  return Problems;
1142
1158
  };
1143
- const loadContent = (state, savedState) => {
1144
- const savedViewletId = getSavedViewletId(savedState);
1145
- const views = getPanelViews();
1146
- const loaded = {
1147
- ...state,
1148
- currentViewletId: savedViewletId,
1149
- views
1150
- };
1151
- return openViewlet(loaded, savedViewletId);
1152
- };
1153
- const setBadgeCount = (state, id, count) => {
1154
- const {
1155
- badgeCounts
1156
- } = state;
1157
- return {
1158
- ...state,
1159
- badgeCounts: {
1160
- ...badgeCounts,
1161
- [id]: count
1162
- }
1163
- };
1164
- };
1165
1159
 
1166
- // export const contentLoaded = (state) => {
1167
- // const commands = []
1168
- // return commands
1169
- // }
1160
+ const createViewlet = async (viewletModuleId, editorUid, tabId, bounds, uri) => {
1161
+ await invoke('Layout.createViewlet', viewletModuleId, editorUid, tabId, bounds, uri);
1162
+ };
1170
1163
 
1171
1164
  const getContentDimensions = dimensions => {
1172
1165
  return {
@@ -1177,39 +1170,32 @@ const getContentDimensions = dimensions => {
1177
1170
  };
1178
1171
  };
1179
1172
 
1180
- // TODO
1181
- // export const getChildren = (state) => {
1182
- // const { currentViewletId } = state
1183
- // return [
1184
- // {
1185
- // id: currentViewletId,
1186
- // ...getContentDimensions(state),
1187
- // },
1188
- // ]
1189
- // }
1190
-
1191
1173
  const openViewlet = async (state, id, focus = false) => {
1192
1174
  const childDimensions = getContentDimensions(state);
1193
1175
  const childUid = Math.random();
1194
1176
  const tabId = 1234;
1195
- // TODO get the actions uid somehow
1196
1177
  const actionsUid = Math.random();
1197
1178
  await createViewlet(id, childUid, tabId, childDimensions, '');
1198
1179
  return {
1199
1180
  ...state,
1200
1181
  actionsUid,
1201
1182
  childUid,
1202
- currentViewletId: id
1183
+ currentViewletId: id,
1184
+ initial: false
1203
1185
  };
1204
1186
  };
1205
- const handleClickClose = async state => {
1206
- await invoke('Layout.hidePanel');
1207
- return state;
1208
- };
1209
- const handleClickMaximize = async state => {
1210
- // TODO
1211
- return state;
1187
+
1188
+ const loadContent = (state, savedState) => {
1189
+ const savedViewletId = getSavedViewletId(savedState);
1190
+ const views = getPanelViews();
1191
+ const loaded = {
1192
+ ...state,
1193
+ currentViewletId: savedViewletId,
1194
+ views
1195
+ };
1196
+ return openViewlet(loaded, savedViewletId);
1212
1197
  };
1198
+
1213
1199
  const selectIndex = async (state, index) => {
1214
1200
  await openViewlet(state, state.views[index]);
1215
1201
  return {
@@ -1217,30 +1203,34 @@ const selectIndex = async (state, index) => {
1217
1203
  selectedIndex: index
1218
1204
  };
1219
1205
  };
1206
+
1220
1207
  const selectRaw = async (state, rawIndex) => {
1221
1208
  return selectIndex(state, Number.parseInt(rawIndex, 10));
1222
1209
  };
1210
+
1211
+ const setBadgeCount = (state, id, count) => {
1212
+ const {
1213
+ badgeCounts
1214
+ } = state;
1215
+ return {
1216
+ ...state,
1217
+ badgeCounts: {
1218
+ ...badgeCounts,
1219
+ [id]: count
1220
+ }
1221
+ };
1222
+ };
1223
+
1223
1224
  const toggleView = async (state, name) => {
1224
1225
  const index = state.views.indexOf(name);
1225
1226
  if (index === -1) {
1226
1227
  return state;
1227
1228
  }
1228
1229
  if (name === state.currentViewletId) {
1229
- // await Command.execute('Layout.hidePanel') // TODO
1230
1230
  return state;
1231
1231
  }
1232
1232
  return selectIndex(state, index);
1233
1233
  };
1234
- const handleFilterInput = async (state, value) => {
1235
- object(state);
1236
- string(value);
1237
- const {
1238
- currentViewletId
1239
- } = state;
1240
- const fullCommand = `${currentViewletId}.handleFilterInput`;
1241
- await invoke(fullCommand, value);
1242
- return state;
1243
- };
1244
1234
 
1245
1235
  const text = data => {
1246
1236
  return {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/panel-worker",
3
- "version": "1.3.0",
3
+ "version": "1.4.0",
4
4
  "description": "Panel Worker",
5
5
  "repository": {
6
6
  "type": "git",