@lvce-editor/activity-bar-worker 7.2.0 → 7.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.
@@ -160,49 +160,6 @@ const create$9 = (id, uri, x, y, width, height, args, parentUid, platform = 0) =
160
160
  return state;
161
161
  };
162
162
 
163
- const hashString = value => {
164
- let hash = 2_166_136_261;
165
- for (const character of value) {
166
- hash ^= character.codePointAt(0) || 0;
167
- hash = Math.imul(hash, 16_777_619);
168
- }
169
- return (hash >>> 0).toString(36);
170
- };
171
- const isCustomIconUrl = icon => {
172
- return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('/');
173
- };
174
- const getCustomIconClass = (id, iconUrl) => {
175
- const hashInput = id + '\n' + iconUrl;
176
- return `MaskIconCustomView${hashString(hashInput)}`;
177
- };
178
- const getIconClass = (item, builtinPrefix) => {
179
- if (item.customIconClass) {
180
- return item.customIconClass;
181
- }
182
- return `${builtinPrefix}${item.icon}`;
183
- };
184
- const escapeCssUrl = url => {
185
- return url.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', '\\a ').replaceAll('\r', '\\d ').replaceAll('\f', '\\c ');
186
- };
187
- const getCustomIconCss = items => {
188
- const seen = new Set();
189
- let css = '';
190
- for (const item of items) {
191
- const {
192
- customIconClass,
193
- customIconUrl
194
- } = item;
195
- if (!customIconClass || !customIconUrl || seen.has(customIconClass)) {
196
- continue;
197
- }
198
- seen.add(customIconClass);
199
- css += `.${customIconClass} {
200
- mask-image: url("${escapeCssUrl(customIconUrl)}");
201
- }
202
- `;
203
- }
204
- return css;
205
- };
206
163
  const getCustomIconSignature = items => {
207
164
  return items.map(item => {
208
165
  if (!item.customIconClass || !item.customIconUrl) {
@@ -315,7 +272,7 @@ const Unchecked = 3;
315
272
 
316
273
  const LeftClick = 0;
317
274
 
318
- const Web = 1;
275
+ const Electron = 2;
319
276
 
320
277
  const ExtensionManagementWorker = 9006;
321
278
  const RendererWorker = 1;
@@ -605,7 +562,7 @@ const getMenuEntriesSettings = state => {
605
562
  id: 'colorTheme',
606
563
  label: colorTheme()
607
564
  }];
608
- if (platform !== Web) {
565
+ if (platform === Electron) {
609
566
  items.push(menuEntrySeparator, {
610
567
  command: 'AutoUpdater.checkForUpdates',
611
568
  flags: None,
@@ -1215,8 +1172,10 @@ const getCurrentStack = () => {
1215
1172
  const currentStack = joinLines(splitLines(new Error().stack || '').slice(stackLinesToSkip));
1216
1173
  return currentStack;
1217
1174
  };
1218
- const getNewLineIndex = (string, startIndex = undefined) => {
1219
- return string.indexOf(NewLine, startIndex);
1175
+ const getNewLineIndex = (string, startIndex) => {
1176
+ {
1177
+ return string.indexOf(NewLine);
1178
+ }
1220
1179
  };
1221
1180
  const getParentStack = error => {
1222
1181
  let parentStack = error.stack || error.data || error.message || '';
@@ -1227,55 +1186,77 @@ const getParentStack = error => {
1227
1186
  };
1228
1187
  const MethodNotFound = -32601;
1229
1188
  const Custom = -32001;
1189
+ const restoreExistingError = (error, currentStack) => {
1190
+ if (typeof error.stack === 'string') {
1191
+ error.stack = error.stack + NewLine + currentStack;
1192
+ }
1193
+ return error;
1194
+ };
1195
+ const restoreMethodNotFoundError = (error, currentStack) => {
1196
+ const restoredError = new JsonRpcError(error.message);
1197
+ const parentStack = getParentStack(error);
1198
+ restoredError.stack = parentStack + NewLine + currentStack;
1199
+ return restoredError;
1200
+ };
1201
+ const restoreStackFromData = (restoredError, error, currentStack) => {
1202
+ if (error.data.stack && error.data.type && error.message) {
1203
+ restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
1204
+ return;
1205
+ }
1206
+ if (error.data.stack) {
1207
+ restoredError.stack = error.data.stack;
1208
+ }
1209
+ };
1210
+ const applyDataProperties = (restoredError, error) => {
1211
+ if (!error.data) {
1212
+ return;
1213
+ }
1214
+ restoreStackFromData(restoredError, error, getCurrentStack());
1215
+ if (error.data.codeFrame) {
1216
+ // @ts-ignore
1217
+ restoredError.codeFrame = error.data.codeFrame;
1218
+ }
1219
+ if (error.data.code) {
1220
+ // @ts-ignore
1221
+ restoredError.code = error.data.code;
1222
+ }
1223
+ if (error.data.type) {
1224
+ // @ts-ignore
1225
+ restoredError.name = error.data.type;
1226
+ }
1227
+ };
1228
+ const applyDirectProperties = (restoredError, error) => {
1229
+ if (error.stack) {
1230
+ const lowerStack = restoredError.stack || '';
1231
+ const indexNewLine = getNewLineIndex(lowerStack);
1232
+ const parentStack = getParentStack(error);
1233
+ // @ts-ignore
1234
+ restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1235
+ }
1236
+ if (error.codeFrame) {
1237
+ // @ts-ignore
1238
+ restoredError.codeFrame = error.codeFrame;
1239
+ }
1240
+ };
1241
+ const restoreMessageError = (error, _currentStack) => {
1242
+ const restoredError = constructError(error.message, error.type, error.name);
1243
+ if (error.data) {
1244
+ applyDataProperties(restoredError, error);
1245
+ } else {
1246
+ applyDirectProperties(restoredError, error);
1247
+ }
1248
+ return restoredError;
1249
+ };
1230
1250
  const restoreJsonRpcError = error => {
1231
1251
  const currentStack = getCurrentStack();
1232
1252
  if (error && error instanceof Error) {
1233
- if (typeof error.stack === 'string') {
1234
- error.stack = error.stack + NewLine + currentStack;
1235
- }
1236
- return error;
1253
+ return restoreExistingError(error, currentStack);
1237
1254
  }
1238
1255
  if (error && error.code && error.code === MethodNotFound) {
1239
- const restoredError = new JsonRpcError(error.message);
1240
- const parentStack = getParentStack(error);
1241
- restoredError.stack = parentStack + NewLine + currentStack;
1242
- return restoredError;
1256
+ return restoreMethodNotFoundError(error, currentStack);
1243
1257
  }
1244
1258
  if (error && error.message) {
1245
- const restoredError = constructError(error.message, error.type, error.name);
1246
- if (error.data) {
1247
- if (error.data.stack && error.data.type && error.message) {
1248
- restoredError.stack = error.data.type + ': ' + error.message + NewLine + error.data.stack + NewLine + currentStack;
1249
- } else if (error.data.stack) {
1250
- restoredError.stack = error.data.stack;
1251
- }
1252
- if (error.data.codeFrame) {
1253
- // @ts-ignore
1254
- restoredError.codeFrame = error.data.codeFrame;
1255
- }
1256
- if (error.data.code) {
1257
- // @ts-ignore
1258
- restoredError.code = error.data.code;
1259
- }
1260
- if (error.data.type) {
1261
- // @ts-ignore
1262
- restoredError.name = error.data.type;
1263
- }
1264
- } else {
1265
- if (error.stack) {
1266
- const lowerStack = restoredError.stack || '';
1267
- // @ts-ignore
1268
- const indexNewLine = getNewLineIndex(lowerStack);
1269
- const parentStack = getParentStack(error);
1270
- // @ts-ignore
1271
- restoredError.stack = parentStack + lowerStack.slice(indexNewLine);
1272
- }
1273
- if (error.codeFrame) {
1274
- // @ts-ignore
1275
- restoredError.codeFrame = error.codeFrame;
1276
- }
1277
- }
1278
- return restoredError;
1259
+ return restoreMessageError(error);
1279
1260
  }
1280
1261
  if (typeof error === 'string') {
1281
1262
  return new Error(`JsonRpc Error: ${error}`);
@@ -2075,6 +2056,23 @@ const handleExtensionManagementMessagePort = async port => {
2075
2056
  set$1(rpc);
2076
2057
  };
2077
2058
 
2059
+ const hashString = value => {
2060
+ let hash = 2_166_136_261;
2061
+ for (const character of value) {
2062
+ hash ^= character.codePointAt(0) || 0;
2063
+ hash = Math.imul(hash, 16_777_619);
2064
+ }
2065
+ return (hash >>> 0).toString(36);
2066
+ };
2067
+ const getCustomIconClass = (id, iconUrl) => {
2068
+ const hashInput = id + '\n' + iconUrl;
2069
+ return `MaskIconCustomView${hashString(hashInput)}`;
2070
+ };
2071
+
2072
+ const isCustomIconUrl = icon => {
2073
+ return icon.startsWith('http://') || icon.startsWith('https://') || icon.startsWith('file://') || icon.startsWith('/');
2074
+ };
2075
+
2078
2076
  const Explorer = 'Explorer';
2079
2077
  const Extensions = 'Extensions';
2080
2078
  const RunAndDebug = 'Run And Debug';
@@ -2338,6 +2336,16 @@ const handleUpdateStateChange = async (state, config) => {
2338
2336
  };
2339
2337
  };
2340
2338
 
2339
+ const getUserState = userInfo => {
2340
+ if (!userInfo || typeof userInfo !== 'object') {
2341
+ return undefined;
2342
+ }
2343
+ if (!('userState' in userInfo)) {
2344
+ return undefined;
2345
+ }
2346
+ return userInfo.userState;
2347
+ };
2348
+
2341
2349
  const getActiveView = async () => {
2342
2350
  try {
2343
2351
  const activeView = await invoke('Layout.getActiveSideBarView');
@@ -2355,14 +2363,16 @@ const getUserInfo = async () => {
2355
2363
  }
2356
2364
  };
2357
2365
 
2358
- const getUserState = userInfo => {
2359
- if (!userInfo || typeof userInfo !== 'object') {
2360
- return undefined;
2361
- }
2362
- if (!('userState' in userInfo)) {
2363
- return undefined;
2364
- }
2365
- return userInfo.userState;
2366
+ const loadPreferences = async (accountEnabled, platform) => {
2367
+ const [accountEnabledNew, activeView, contributedViews, sidebarLocation, sideBarVisible, userInfo] = await Promise.all([getAccountEnabled(accountEnabled), getActiveView(), getContributedViews(platform), getSideBarPosition(), getSideBarVisible(), getUserInfo()]);
2368
+ return {
2369
+ accountEnabled: accountEnabledNew,
2370
+ activeView,
2371
+ contributedViews,
2372
+ sidebarLocation,
2373
+ sideBarVisible,
2374
+ userInfo
2375
+ };
2366
2376
  };
2367
2377
 
2368
2378
  const toUserLoginState = userState => {
@@ -2385,7 +2395,14 @@ const loadContent = async state => {
2385
2395
  itemHeight,
2386
2396
  platform
2387
2397
  } = state;
2388
- const [accountEnabledNew, activeView, contributedViews, sideBarVisible, sidebarLocation, userInfo] = await Promise.all([getAccountEnabled(accountEnabled), getActiveView(), getContributedViews(platform), getSideBarVisible(), getSideBarPosition(), getUserInfo()]);
2398
+ const {
2399
+ accountEnabled: accountEnabledNew,
2400
+ activeView,
2401
+ contributedViews,
2402
+ sidebarLocation,
2403
+ sideBarVisible,
2404
+ userInfo
2405
+ } = await loadPreferences(accountEnabled, platform);
2389
2406
  const newState = {
2390
2407
  ...state,
2391
2408
  accountEnabled: accountEnabledNew,
@@ -2409,6 +2426,30 @@ const loadContent = async state => {
2409
2426
  };
2410
2427
  };
2411
2428
 
2429
+ const escapeCssUrl = url => {
2430
+ return url.replaceAll('\\', '\\\\').replaceAll('"', '\\"').replaceAll('\n', '\\a ').replaceAll('\r', '\\d ').replaceAll('\f', '\\c ');
2431
+ };
2432
+
2433
+ const getCustomIconCss = items => {
2434
+ const seen = new Set();
2435
+ let css = '';
2436
+ for (const item of items) {
2437
+ const {
2438
+ customIconClass,
2439
+ customIconUrl
2440
+ } = item;
2441
+ if (!customIconClass || !customIconUrl || seen.has(customIconClass)) {
2442
+ continue;
2443
+ }
2444
+ seen.add(customIconClass);
2445
+ css += `.${customIconClass} {
2446
+ mask-image: url("${escapeCssUrl(customIconUrl)}");
2447
+ }
2448
+ `;
2449
+ }
2450
+ return css;
2451
+ };
2452
+
2412
2453
  const getCss = (itemHeight, items = []) => {
2413
2454
  return `:root {
2414
2455
  --ActivityBarItemHeight: var(--${itemHeight}px);
@@ -2769,6 +2810,13 @@ const getClassName = (isFocused, marginTop, isSelected) => {
2769
2810
  return mergeClassNames(...classNames);
2770
2811
  };
2771
2812
 
2813
+ const getIconClass = (item, builtinPrefix) => {
2814
+ if (item.customIconClass) {
2815
+ return item.customIconClass;
2816
+ }
2817
+ return `${builtinPrefix}${item.icon}`;
2818
+ };
2819
+
2772
2820
  const getActivityBarItemInProgressDom = item => {
2773
2821
  const {
2774
2822
  flags,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lvce-editor/activity-bar-worker",
3
- "version": "7.2.0",
3
+ "version": "7.4.0",
4
4
  "description": "Explorer Worker",
5
5
  "repository": {
6
6
  "type": "git",