@blocklet/launcher-util 2.1.12 → 2.1.13
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.
- package/lib/constant.js +1 -0
- package/lib/locale/en.js +8 -1
- package/lib/locale/zh.js +8 -1
- package/lib/util.js +15 -3
- package/package.json +2 -2
package/lib/constant.js
CHANGED
package/lib/locale/en.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const flat = require('flat');
|
|
2
|
-
const { SERVERLESS_INSTANCE_STATUS, INSTANCE_STATUS } = require('../constant');
|
|
2
|
+
const { SERVERLESS_INSTANCE_STATUS, INSTANCE_STATUS, CURRENCY_TYPE, PAYMENT_METHODS } = require('../constant');
|
|
3
3
|
|
|
4
4
|
module.exports = flat({
|
|
5
5
|
common: {
|
|
6
|
+
spaceName: 'Space Name',
|
|
6
7
|
duration: 'Duration',
|
|
7
8
|
},
|
|
8
9
|
serverlessInstance: {
|
|
@@ -28,4 +29,10 @@ module.exports = flat({
|
|
|
28
29
|
[INSTANCE_STATUS.underMaintenance]: 'Under-Maintenance',
|
|
29
30
|
},
|
|
30
31
|
},
|
|
32
|
+
paymentMethod: {
|
|
33
|
+
[PAYMENT_METHODS.crypto]: 'Crypto',
|
|
34
|
+
[PAYMENT_METHODS.stripe]: 'Credit',
|
|
35
|
+
[CURRENCY_TYPE.fiat]: 'Credit',
|
|
36
|
+
[CURRENCY_TYPE.crypto]: 'Crypto',
|
|
37
|
+
},
|
|
31
38
|
});
|
package/lib/locale/zh.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
const flat = require('flat');
|
|
2
|
-
const { SERVERLESS_INSTANCE_STATUS, INSTANCE_STATUS } = require('../constant');
|
|
2
|
+
const { SERVERLESS_INSTANCE_STATUS, INSTANCE_STATUS, PAYMENT_METHODS, CURRENCY_TYPE } = require('../constant');
|
|
3
3
|
|
|
4
4
|
module.exports = flat({
|
|
5
5
|
common: {
|
|
6
|
+
spaceName: '应用空间',
|
|
6
7
|
duration: '时长',
|
|
7
8
|
},
|
|
8
9
|
serverlessInstance: {
|
|
@@ -28,4 +29,10 @@ module.exports = flat({
|
|
|
28
29
|
[INSTANCE_STATUS.underMaintenance]: '维护中',
|
|
29
30
|
},
|
|
30
31
|
},
|
|
32
|
+
paymentMethod: {
|
|
33
|
+
[PAYMENT_METHODS.crypto]: '加密货币',
|
|
34
|
+
[PAYMENT_METHODS.stripe]: '信用卡',
|
|
35
|
+
[CURRENCY_TYPE.fiat]: '信用卡', // TODO: 统一管理支付方式和货币类型
|
|
36
|
+
[CURRENCY_TYPE.crypto]: '加密货币', // TODO: 统一管理支付方式和货币类型
|
|
37
|
+
},
|
|
31
38
|
});
|
package/lib/util.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
require('moment-timezone');
|
|
2
2
|
const moment = require('moment');
|
|
3
|
+
const joinURL = require('url-join');
|
|
3
4
|
const get = require('lodash.get');
|
|
4
5
|
const { BN, fromUnitToToken, fromTokenToUnit } = require('@ocap/util');
|
|
5
6
|
|
|
@@ -56,7 +57,7 @@ const prettyDuration = ({ value, unit }, locale) => {
|
|
|
56
57
|
return `${value}${prettyDurationUnit({ value, unit }, locale)}`;
|
|
57
58
|
};
|
|
58
59
|
|
|
59
|
-
const
|
|
60
|
+
const formatDatetime = (time, locale = 'en-us', timezone = Intl.DateTimeFormat().resolvedOptions().timeZone) => {
|
|
60
61
|
/* eslint-disable no-param-reassign */
|
|
61
62
|
if (!time) {
|
|
62
63
|
return '';
|
|
@@ -67,9 +68,16 @@ const formatExpirationTime = (time, locale) => {
|
|
|
67
68
|
locale = 'zh-cn';
|
|
68
69
|
}
|
|
69
70
|
|
|
70
|
-
|
|
71
|
+
try {
|
|
72
|
+
return moment(time).locale(locale).tz(timezone).format('LLL zz');
|
|
73
|
+
} catch (error) {
|
|
74
|
+
console.error(`formate date time "${time}" error`, error);
|
|
75
|
+
return '';
|
|
76
|
+
}
|
|
71
77
|
};
|
|
72
78
|
|
|
79
|
+
const formatUtcDatetime = (time, locale = 'en-us') => formatDatetime(time, locale, 'UTC');
|
|
80
|
+
|
|
73
81
|
const sortArrayByDate = (array, asc = true, field = undefined) =>
|
|
74
82
|
(array || []).sort((x, y) => {
|
|
75
83
|
let v1 = x;
|
|
@@ -105,14 +113,18 @@ const getExplorerUrl = ({ address, type = 'txs', chainHost }) => {
|
|
|
105
113
|
|
|
106
114
|
const getBlockletDisplayName = (blocklet) => get(blocklet, 'title') || get(blocklet, 'name') || '';
|
|
107
115
|
|
|
116
|
+
const getBlockletAdminURL = (appURL) => joinURL(appURL, '/.well-known/service/admin/overview');
|
|
117
|
+
|
|
108
118
|
module.exports = {
|
|
109
119
|
formatPeriod,
|
|
110
120
|
calculatePrice,
|
|
111
121
|
prettyDurationUnit,
|
|
112
122
|
prettyDuration,
|
|
113
|
-
|
|
123
|
+
formatDatetime,
|
|
124
|
+
formatUtcDatetime,
|
|
114
125
|
getSort,
|
|
115
126
|
sortArrayByDate,
|
|
116
127
|
getExplorerUrl,
|
|
117
128
|
getBlockletDisplayName,
|
|
129
|
+
getBlockletAdminURL,
|
|
118
130
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/launcher-util",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.13",
|
|
4
4
|
"description": "Common constants",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"constant"
|
|
@@ -46,5 +46,5 @@
|
|
|
46
46
|
"devDependencies": {
|
|
47
47
|
"jest": "^27.5.1"
|
|
48
48
|
},
|
|
49
|
-
"gitHead": "
|
|
49
|
+
"gitHead": "4d577c7b97c258952fdd3c44415db2d03c476a7c"
|
|
50
50
|
}
|