@lvce-editor/about-view 1.3.0 → 1.5.0
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/aboutWorkerMain.js +51 -41
- package/package.json +5 -3
package/dist/aboutWorkerMain.js
CHANGED
@@ -225,109 +225,114 @@ const inSomeYears = years => {
|
|
225
225
|
});
|
226
226
|
};
|
227
227
|
|
228
|
-
// based on https://github.com/microsoft/vscode/blob/bd782eb059e133d3a20fdb446b8feb0010a278ad/src/vs/base/common/date.ts (License MIT)
|
229
228
|
const minute = 60;
|
230
229
|
const hour = minute * 60;
|
231
230
|
const day = hour * 24;
|
232
231
|
const week = day * 7;
|
233
232
|
const month = day * 30;
|
234
233
|
const year = day * 365;
|
235
|
-
|
234
|
+
|
235
|
+
// based on https://github.com/microsoft/vscode/blob/bd782eb059e133d3a20fdb446b8feb0010a278ad/src/vs/base/common/date.ts (License MIT)
|
236
|
+
const formatDateFuture = seconds => {
|
236
237
|
if (seconds < minute) {
|
237
238
|
if (seconds === 1) {
|
238
|
-
return
|
239
|
+
return inOneSecond();
|
239
240
|
}
|
240
|
-
return
|
241
|
+
return inSomeSeconds(seconds);
|
241
242
|
}
|
242
243
|
if (seconds < hour) {
|
243
244
|
const minutes = Math.floor(seconds / minute);
|
244
245
|
if (minutes === 1) {
|
245
|
-
return
|
246
|
+
return inOneMinute();
|
246
247
|
}
|
247
|
-
return
|
248
|
+
return inSomeMinutes(minutes);
|
248
249
|
}
|
249
250
|
if (seconds < day) {
|
250
251
|
const days = Math.floor(seconds / hour);
|
251
252
|
if (days === 1) {
|
252
|
-
return
|
253
|
+
return inOneHour();
|
253
254
|
}
|
254
|
-
return
|
255
|
+
return inSomeHours(days);
|
255
256
|
}
|
256
257
|
if (seconds < week) {
|
257
258
|
const days = Math.floor(seconds / day);
|
258
259
|
if (days === 1) {
|
259
|
-
return
|
260
|
+
return inOneDay();
|
260
261
|
}
|
261
|
-
return
|
262
|
+
return inSomeDays(days);
|
262
263
|
}
|
263
264
|
if (seconds < month) {
|
264
265
|
const weeks = Math.floor(seconds / week);
|
265
266
|
if (weeks === 1) {
|
266
|
-
return
|
267
|
+
return inOneWeek();
|
267
268
|
}
|
268
|
-
return
|
269
|
+
return inSomeWeeks(weeks);
|
269
270
|
}
|
270
271
|
if (seconds < year) {
|
271
272
|
const months = Math.floor(seconds / month);
|
272
273
|
if (months === 1) {
|
273
|
-
return
|
274
|
+
return inOneMonth();
|
274
275
|
}
|
275
|
-
return
|
276
|
+
return inSomeMonths(months);
|
276
277
|
}
|
277
278
|
const years = Math.floor(seconds / year);
|
278
279
|
if (years === 1) {
|
279
|
-
return
|
280
|
+
return inOneYear();
|
280
281
|
}
|
281
|
-
return
|
282
|
+
return inSomeYears(years);
|
282
283
|
};
|
283
|
-
|
284
|
+
|
285
|
+
// based on https://github.com/microsoft/vscode/blob/bd782eb059e133d3a20fdb446b8feb0010a278ad/src/vs/base/common/date.ts (License MIT)
|
286
|
+
const formatDatePast = seconds => {
|
284
287
|
if (seconds < minute) {
|
285
288
|
if (seconds === 1) {
|
286
|
-
return
|
289
|
+
return oneSecondAgo();
|
287
290
|
}
|
288
|
-
return
|
291
|
+
return someSecondsAgo(seconds);
|
289
292
|
}
|
290
293
|
if (seconds < hour) {
|
291
294
|
const minutes = Math.floor(seconds / minute);
|
292
295
|
if (minutes === 1) {
|
293
|
-
return
|
296
|
+
return oneMinuteAgo();
|
294
297
|
}
|
295
|
-
return
|
298
|
+
return someMinutesAgo(minutes);
|
296
299
|
}
|
297
300
|
if (seconds < day) {
|
298
301
|
const days = Math.floor(seconds / hour);
|
299
302
|
if (days === 1) {
|
300
|
-
return
|
303
|
+
return oneHourAgo();
|
301
304
|
}
|
302
|
-
return
|
305
|
+
return someHoursAgo(days);
|
303
306
|
}
|
304
307
|
if (seconds < week) {
|
305
308
|
const days = Math.floor(seconds / day);
|
306
309
|
if (days === 1) {
|
307
|
-
return
|
310
|
+
return oneDayAgo();
|
308
311
|
}
|
309
|
-
return
|
312
|
+
return someDaysAgo(days);
|
310
313
|
}
|
311
314
|
if (seconds < month) {
|
312
315
|
const weeks = Math.floor(seconds / week);
|
313
316
|
if (weeks === 1) {
|
314
|
-
return
|
317
|
+
return oneWeekAgo();
|
315
318
|
}
|
316
|
-
return
|
319
|
+
return someWeeksAgo(weeks);
|
317
320
|
}
|
318
321
|
if (seconds < year) {
|
319
322
|
const months = Math.floor(seconds / month);
|
320
323
|
if (months === 1) {
|
321
|
-
return
|
324
|
+
return oneMonthAgo();
|
322
325
|
}
|
323
|
-
return
|
326
|
+
return someMonthsAgo(months);
|
324
327
|
}
|
325
328
|
const years = Math.floor(seconds / year);
|
326
329
|
if (years === 1) {
|
327
|
-
return
|
330
|
+
return oneYearAgo();
|
328
331
|
}
|
329
|
-
return
|
332
|
+
return someYearsAgo(years);
|
330
333
|
};
|
334
|
+
|
335
|
+
// based on https://github.com/microsoft/vscode/blob/bd782eb059e133d3a20fdb446b8feb0010a278ad/src/vs/base/common/date.ts (License MIT)
|
331
336
|
const formatDate = (date, now) => {
|
332
337
|
const difference = now - date;
|
333
338
|
const seconds = Math.round(difference / 1000);
|
@@ -337,7 +342,7 @@ const formatDate = (date, now) => {
|
|
337
342
|
return formatDateFuture(-seconds);
|
338
343
|
};
|
339
344
|
|
340
|
-
const formatAboutDate = isoDate => {
|
345
|
+
const formatAboutDate = (isoDate, now) => {
|
341
346
|
if (!isoDate) {
|
342
347
|
return 'unknown';
|
343
348
|
}
|
@@ -345,7 +350,6 @@ const formatAboutDate = isoDate => {
|
|
345
350
|
if (isNaN(date)) {
|
346
351
|
return `Invalid Date: ${isoDate}`;
|
347
352
|
}
|
348
|
-
const now = Date.now();
|
349
353
|
const ago = formatDate(date, now);
|
350
354
|
return `${isoDate} (${ago})`;
|
351
355
|
};
|
@@ -384,7 +388,8 @@ const productNameLong = 'Lvce Editor - OSS';
|
|
384
388
|
|
385
389
|
const getDetailString = async () => {
|
386
390
|
const [electronVersion, nodeVersion, chromeVersion, version, commit, v8Version, date] = await Promise.all([getElectronVersion(), getNodeVersion(), getChromeVersion(), getVersion(), getCommit(), getV8Version(), getDate()]);
|
387
|
-
const
|
391
|
+
const now = Date.now();
|
392
|
+
const formattedDate = formatAboutDate(date, now);
|
388
393
|
const lines = [`Version: ${version}`, `Commit: ${commit}`, `Date: ${formattedDate}`, `Electron: ${electronVersion}`, `Chromium: ${chromeVersion}`, `Node: ${nodeVersion}`, `V8: ${v8Version}`];
|
389
394
|
return joinLines$1(lines);
|
390
395
|
};
|
@@ -397,7 +402,8 @@ const getDetailStringWeb = () => {
|
|
397
402
|
const version$1 = version;
|
398
403
|
const commit$1 = commit;
|
399
404
|
const date$1 = date;
|
400
|
-
const
|
405
|
+
const now = Date.now();
|
406
|
+
const formattedDate = formatAboutDate(date$1, now);
|
401
407
|
const browser = getBrowser();
|
402
408
|
const lines = [`Version: ${version$1}`, `Commit: ${commit$1}`, `Date: ${formattedDate}`, `Browser: ${browser}`];
|
403
409
|
return lines;
|
@@ -456,10 +462,14 @@ const getAboutContentVirtualDom = lines => {
|
|
456
462
|
const Button = 'button';
|
457
463
|
const Dialog = 'dialog';
|
458
464
|
|
465
|
+
const mergeClassNames = (...classNames) => {
|
466
|
+
return classNames.filter(Boolean).join(' ');
|
467
|
+
};
|
468
|
+
|
459
469
|
const getPrimaryButtonVirtualDom = (message, onClick) => {
|
460
470
|
return [{
|
461
471
|
type: Button$2,
|
462
|
-
className:
|
472
|
+
className: mergeClassNames(Button$1, ButtonPrimary),
|
463
473
|
onClick,
|
464
474
|
childCount: 1
|
465
475
|
}, text(message)];
|
@@ -467,7 +477,7 @@ const getPrimaryButtonVirtualDom = (message, onClick) => {
|
|
467
477
|
const getSecondaryButtonVirtualDom = (message, onClick) => {
|
468
478
|
return [{
|
469
479
|
type: Button$2,
|
470
|
-
className:
|
480
|
+
className: mergeClassNames(Button$1, ButtonSecondary),
|
471
481
|
onClick,
|
472
482
|
childCount: 1
|
473
483
|
}, text(message)];
|
@@ -634,7 +644,7 @@ class AssertionError extends Error {
|
|
634
644
|
this.name = 'AssertionError';
|
635
645
|
}
|
636
646
|
}
|
637
|
-
const getType
|
647
|
+
const getType = value => {
|
638
648
|
switch (typeof value) {
|
639
649
|
case 'number':
|
640
650
|
return 'number';
|
@@ -657,7 +667,7 @@ const getType$1 = value => {
|
|
657
667
|
}
|
658
668
|
};
|
659
669
|
const number = value => {
|
660
|
-
const type = getType
|
670
|
+
const type = getType(value);
|
661
671
|
if (type !== 'number') {
|
662
672
|
throw new AssertionError('expected value to be of type number');
|
663
673
|
}
|
@@ -694,7 +704,7 @@ class JsonRpcError extends Error {
|
|
694
704
|
const MethodNotFound = -32601;
|
695
705
|
const Custom = -32001;
|
696
706
|
const E_COMMAND_NOT_FOUND = 'E_COMMAND_NOT_FOUND';
|
697
|
-
const
|
707
|
+
const getErrorType = prettyError => {
|
698
708
|
if (prettyError && prettyError.type) {
|
699
709
|
return prettyError.type;
|
700
710
|
}
|
@@ -717,7 +727,7 @@ const getErrorProperty = (error, prettyError) => {
|
|
717
727
|
data: {
|
718
728
|
stack: prettyError.stack,
|
719
729
|
codeFrame: prettyError.codeFrame,
|
720
|
-
type:
|
730
|
+
type: getErrorType(prettyError),
|
721
731
|
code: prettyError.code,
|
722
732
|
name: prettyError.name
|
723
733
|
}
|
package/package.json
CHANGED
@@ -1,10 +1,12 @@
|
|
1
1
|
{
|
2
2
|
"name": "@lvce-editor/about-view",
|
3
|
-
"version": "1.
|
3
|
+
"version": "1.5.0",
|
4
4
|
"description": "",
|
5
5
|
"main": "dist/aboutWorkerMain.js",
|
6
6
|
"type": "module",
|
7
|
-
"keywords": [
|
8
|
-
|
7
|
+
"keywords": [
|
8
|
+
"about"
|
9
|
+
],
|
10
|
+
"author": "Lvce Editor",
|
9
11
|
"license": "MIT"
|
10
12
|
}
|