@blocklet/launcher-workflow 2.3.24 → 2.3.26
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/es/locales/en.js +1 -0
- package/es/locales/zh.js +1 -0
- package/es/prepare.js +39 -9
- package/lib/locales/en.js +1 -0
- package/lib/locales/zh.js +1 -0
- package/lib/prepare.js +43 -12
- package/package.json +16 -16
package/es/locales/en.js
CHANGED
|
@@ -112,6 +112,7 @@ export default {
|
|
|
112
112
|
serverlessNotSupported: 'This app is not allowed in sigular and on-demand space, please select dedicated space',
|
|
113
113
|
componentCount: '{count} Component Included',
|
|
114
114
|
componentsCount: '{count} Components Included',
|
|
115
|
+
onDemandNotSupport: 'This app does not support installation in on-demand space, please purchase dedicated space or install in your own dedicated space',
|
|
115
116
|
dialog: {
|
|
116
117
|
title: 'Purchase Blocklet Space NFT',
|
|
117
118
|
scan: 'Scan the QR code below with your DID wallet to complete purchase',
|
package/es/locales/zh.js
CHANGED
|
@@ -111,6 +111,7 @@ export default {
|
|
|
111
111
|
serverlessNotSupported: '该应用被禁止能在单应用或者按需空间中运行,请选择专用空间',
|
|
112
112
|
componentCount: '共 {count} 个组件',
|
|
113
113
|
componentsCount: '共 {count} 个组件',
|
|
114
|
+
onDemandNotSupport: '该应用不支持安装在按需空间中,请购买专用空间,或者安装在自己已有的专用空间中',
|
|
114
115
|
dialog: {
|
|
115
116
|
title: '购买 Blocklet Server NFT',
|
|
116
117
|
scan: '用您的 DID 钱包扫描下面的二维码完成购买',
|
package/es/prepare.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import Center from '@arcblock/ux/lib/Center';
|
|
2
|
+
import Toast from '@arcblock/ux/lib/Toast';
|
|
2
3
|
import { LAUNCH_STATUS } from '@blocklet/launcher-util/es/constant';
|
|
3
4
|
import { getBlockletAdminURL, getBlockletLogoUrl, getBlockletMetaUrlFromQuery, getDefaultTrialEnd } from '@blocklet/launcher-util/es/util';
|
|
4
5
|
import CheckoutOnDemand from '@blocklet/launcher-ux/lib/payment/checkout/on-demand';
|
|
@@ -10,7 +11,7 @@ import Stack from '@mui/material/Stack';
|
|
|
10
11
|
import ToggleButton from '@mui/material/ToggleButton';
|
|
11
12
|
import ToggleButtonGroup from '@mui/material/ToggleButtonGroup';
|
|
12
13
|
import PropTypes from 'prop-types';
|
|
13
|
-
import { useCallback, useEffect } from 'react';
|
|
14
|
+
import { useCallback, useEffect, useMemo } from 'react';
|
|
14
15
|
import { Link, useNavigate, useSearchParams } from 'react-router-dom';
|
|
15
16
|
import useAsync from 'react-use/lib/useAsync';
|
|
16
17
|
import useSetState from 'react-use/lib/useSetState';
|
|
@@ -33,6 +34,21 @@ const Root = styled('div')`
|
|
|
33
34
|
width: 100%;
|
|
34
35
|
}
|
|
35
36
|
`;
|
|
37
|
+
const isBlockletSupportOnDemand = (blockletMetaUrl, serverlessTrustedSources) => {
|
|
38
|
+
try {
|
|
39
|
+
if (!serverlessTrustedSources || serverlessTrustedSources?.length === 0 || !blockletMetaUrl) {
|
|
40
|
+
return true;
|
|
41
|
+
}
|
|
42
|
+
return (serverlessTrustedSources || []).some(item => {
|
|
43
|
+
const url = new URL(item.url);
|
|
44
|
+
return url.origin === new URL(blockletMetaUrl).origin;
|
|
45
|
+
});
|
|
46
|
+
} catch (error) {
|
|
47
|
+
// 如果出错,不要阻塞流程
|
|
48
|
+
console.warn('exception in isBlockletSupportOnDemand', error, blockletMetaUrl, serverlessTrustedSources);
|
|
49
|
+
return true;
|
|
50
|
+
}
|
|
51
|
+
};
|
|
36
52
|
function Content({
|
|
37
53
|
blocklet
|
|
38
54
|
}) {
|
|
@@ -59,21 +75,32 @@ function Content({
|
|
|
59
75
|
const blockletMetaUrl = getBlockletMetaUrlFromQuery(params);
|
|
60
76
|
const defaultProductType = params.get('product_type');
|
|
61
77
|
const from = params.get('from');
|
|
62
|
-
const productTypes =
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
78
|
+
const productTypes = useMemo(() => {
|
|
79
|
+
const result = [];
|
|
80
|
+
if (isBlockletSupportOnDemand(blockletMetaUrl, window.blocklet?.preferences?.serverlessTrustedSources) === true) {
|
|
81
|
+
result.push('on-demand');
|
|
82
|
+
} else {
|
|
83
|
+
Toast.info(t('purchase.onDemandNotSupport'), {
|
|
84
|
+
persist: true
|
|
85
|
+
});
|
|
86
|
+
}
|
|
87
|
+
if (window.blocklet?.preferences?.dedicatedPricingTableId) {
|
|
88
|
+
result.push('dedicated');
|
|
89
|
+
}
|
|
90
|
+
return result;
|
|
91
|
+
}, [blockletMetaUrl, t]);
|
|
66
92
|
useEffect(() => {
|
|
67
|
-
|
|
93
|
+
const defaultType = productTypes.includes(defaultProductType) ? defaultProductType : productTypes?.[0];
|
|
94
|
+
if (defaultType) {
|
|
68
95
|
setState({
|
|
69
|
-
productType:
|
|
96
|
+
productType: defaultType
|
|
70
97
|
});
|
|
71
|
-
params.set('product_type',
|
|
98
|
+
params.set('product_type', defaultType);
|
|
72
99
|
setParams(params, {
|
|
73
100
|
replace: true
|
|
74
101
|
});
|
|
75
102
|
}
|
|
76
|
-
}, [defaultProductType, params, setParams, setState]);
|
|
103
|
+
}, [productTypes, defaultProductType, params, setParams, setState]);
|
|
77
104
|
const launchState = useAsync(async () => {
|
|
78
105
|
const createPromiseFn = (fn, ...args) => new Promise((resolve, reject) => {
|
|
79
106
|
fn(...args, (err, value) => {
|
|
@@ -261,6 +288,9 @@ function Content({
|
|
|
261
288
|
'& button': {
|
|
262
289
|
fontSize: '1rem !important'
|
|
263
290
|
}
|
|
291
|
+
},
|
|
292
|
+
'& .btn-row': {
|
|
293
|
+
justifyContent: 'center !important'
|
|
264
294
|
}
|
|
265
295
|
},
|
|
266
296
|
children: /*#__PURE__*/_jsx(PaymentProvider, {
|
package/lib/locales/en.js
CHANGED
|
@@ -118,6 +118,7 @@ var _default = exports.default = {
|
|
|
118
118
|
serverlessNotSupported: 'This app is not allowed in sigular and on-demand space, please select dedicated space',
|
|
119
119
|
componentCount: '{count} Component Included',
|
|
120
120
|
componentsCount: '{count} Components Included',
|
|
121
|
+
onDemandNotSupport: 'This app does not support installation in on-demand space, please purchase dedicated space or install in your own dedicated space',
|
|
121
122
|
dialog: {
|
|
122
123
|
title: 'Purchase Blocklet Space NFT',
|
|
123
124
|
scan: 'Scan the QR code below with your DID wallet to complete purchase',
|
package/lib/locales/zh.js
CHANGED
|
@@ -117,6 +117,7 @@ var _default = exports.default = {
|
|
|
117
117
|
serverlessNotSupported: '该应用被禁止能在单应用或者按需空间中运行,请选择专用空间',
|
|
118
118
|
componentCount: '共 {count} 个组件',
|
|
119
119
|
componentsCount: '共 {count} 个组件',
|
|
120
|
+
onDemandNotSupport: '该应用不支持安装在按需空间中,请购买专用空间,或者安装在自己已有的专用空间中',
|
|
120
121
|
dialog: {
|
|
121
122
|
title: '购买 Blocklet Server NFT',
|
|
122
123
|
scan: '用您的 DID 钱包扫描下面的二维码完成购买',
|
package/lib/prepare.js
CHANGED
|
@@ -5,6 +5,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.default = void 0;
|
|
7
7
|
var _Center = _interopRequireDefault(require("@arcblock/ux/lib/Center"));
|
|
8
|
+
var _Toast = _interopRequireDefault(require("@arcblock/ux/lib/Toast"));
|
|
8
9
|
var _constant = require("@blocklet/launcher-util/es/constant");
|
|
9
10
|
var _util = require("@blocklet/launcher-util/es/util");
|
|
10
11
|
var _onDemand = _interopRequireDefault(require("@blocklet/launcher-ux/lib/payment/checkout/on-demand"));
|
|
@@ -34,8 +35,23 @@ var _templateObject;
|
|
|
34
35
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
35
36
|
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
36
37
|
const Root = (0, _styled.default)('div')(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n width: 100%;\n height: 100%;\n padding-top: 0;\n\n @media (max-width: 960px) {\n width: 100%;\n }\n"])));
|
|
38
|
+
const isBlockletSupportOnDemand = (blockletMetaUrl, serverlessTrustedSources) => {
|
|
39
|
+
try {
|
|
40
|
+
if (!serverlessTrustedSources || (serverlessTrustedSources === null || serverlessTrustedSources === void 0 ? void 0 : serverlessTrustedSources.length) === 0 || !blockletMetaUrl) {
|
|
41
|
+
return true;
|
|
42
|
+
}
|
|
43
|
+
return (serverlessTrustedSources || []).some(item => {
|
|
44
|
+
const url = new URL(item.url);
|
|
45
|
+
return url.origin === new URL(blockletMetaUrl).origin;
|
|
46
|
+
});
|
|
47
|
+
} catch (error) {
|
|
48
|
+
// 如果出错,不要阻塞流程
|
|
49
|
+
console.warn('exception in isBlockletSupportOnDemand', error, blockletMetaUrl, serverlessTrustedSources);
|
|
50
|
+
return true;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
37
53
|
function Content(_ref) {
|
|
38
|
-
var
|
|
54
|
+
var _launchState$value2, _ref2, _window$blocklet3, _window$blocklet4, _window$blocklet5;
|
|
39
55
|
let {
|
|
40
56
|
blocklet
|
|
41
57
|
} = _ref;
|
|
@@ -62,21 +78,33 @@ function Content(_ref) {
|
|
|
62
78
|
const blockletMetaUrl = (0, _util.getBlockletMetaUrlFromQuery)(params);
|
|
63
79
|
const defaultProductType = params.get('product_type');
|
|
64
80
|
const from = params.get('from');
|
|
65
|
-
const productTypes =
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
81
|
+
const productTypes = (0, _react.useMemo)(() => {
|
|
82
|
+
var _window$blocklet, _window$blocklet2;
|
|
83
|
+
const result = [];
|
|
84
|
+
if (isBlockletSupportOnDemand(blockletMetaUrl, (_window$blocklet = window.blocklet) === null || _window$blocklet === void 0 || (_window$blocklet = _window$blocklet.preferences) === null || _window$blocklet === void 0 ? void 0 : _window$blocklet.serverlessTrustedSources) === true) {
|
|
85
|
+
result.push('on-demand');
|
|
86
|
+
} else {
|
|
87
|
+
_Toast.default.info(t('purchase.onDemandNotSupport'), {
|
|
88
|
+
persist: true
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
if ((_window$blocklet2 = window.blocklet) !== null && _window$blocklet2 !== void 0 && (_window$blocklet2 = _window$blocklet2.preferences) !== null && _window$blocklet2 !== void 0 && _window$blocklet2.dedicatedPricingTableId) {
|
|
92
|
+
result.push('dedicated');
|
|
93
|
+
}
|
|
94
|
+
return result;
|
|
95
|
+
}, [blockletMetaUrl, t]);
|
|
69
96
|
(0, _react.useEffect)(() => {
|
|
70
|
-
|
|
97
|
+
const defaultType = productTypes.includes(defaultProductType) ? defaultProductType : productTypes === null || productTypes === void 0 ? void 0 : productTypes[0];
|
|
98
|
+
if (defaultType) {
|
|
71
99
|
setState({
|
|
72
|
-
productType:
|
|
100
|
+
productType: defaultType
|
|
73
101
|
});
|
|
74
|
-
params.set('product_type',
|
|
102
|
+
params.set('product_type', defaultType);
|
|
75
103
|
setParams(params, {
|
|
76
104
|
replace: true
|
|
77
105
|
});
|
|
78
106
|
}
|
|
79
|
-
}, [defaultProductType, params, setParams, setState]);
|
|
107
|
+
}, [productTypes, defaultProductType, params, setParams, setState]);
|
|
80
108
|
const launchState = (0, _useAsync.default)(async () => {
|
|
81
109
|
const createPromiseFn = function createPromiseFn(fn) {
|
|
82
110
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
@@ -243,7 +271,7 @@ function Content(_ref) {
|
|
|
243
271
|
locale: locale,
|
|
244
272
|
api: launchSessionAPI,
|
|
245
273
|
checkoutPath: "/payment/checkout"
|
|
246
|
-
}), state.productType === 'dedicated' && ((_window$
|
|
274
|
+
}), state.productType === 'dedicated' && ((_window$blocklet3 = window.blocklet) === null || _window$blocklet3 === void 0 || (_window$blocklet3 = _window$blocklet3.preferences) === null || _window$blocklet3 === void 0 ? void 0 : _window$blocklet3.dedicatedPricingTableId) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
247
275
|
sx: {
|
|
248
276
|
display: 'flex',
|
|
249
277
|
width: '100%',
|
|
@@ -271,19 +299,22 @@ function Content(_ref) {
|
|
|
271
299
|
'& button': {
|
|
272
300
|
fontSize: '1rem !important'
|
|
273
301
|
}
|
|
302
|
+
},
|
|
303
|
+
'& .btn-row': {
|
|
304
|
+
justifyContent: 'center !important'
|
|
274
305
|
}
|
|
275
306
|
},
|
|
276
307
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_paymentReact.PaymentProvider, {
|
|
277
308
|
session: session,
|
|
278
309
|
connect: connectApi,
|
|
279
310
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_paymentReact.CheckoutTable, {
|
|
280
|
-
id: (_window$
|
|
311
|
+
id: (_window$blocklet4 = window.blocklet) === null || _window$blocklet4 === void 0 || (_window$blocklet4 = _window$blocklet4.preferences) === null || _window$blocklet4 === void 0 ? void 0 : _window$blocklet4.dedicatedPricingTableId,
|
|
281
312
|
mode: "inline",
|
|
282
313
|
extraParams: {
|
|
283
314
|
'metadata.session_id': launch._id,
|
|
284
315
|
'subscription_data.trial_end': (0, _util.getDefaultTrialEnd)(),
|
|
285
316
|
'subscription_data.days_until_due': 0,
|
|
286
|
-
'subscription_data.days_until_cancel': ((_window$
|
|
317
|
+
'subscription_data.days_until_cancel': ((_window$blocklet5 = window.blocklet) === null || _window$blocklet5 === void 0 || (_window$blocklet5 = _window$blocklet5.preferences) === null || _window$blocklet5 === void 0 ? void 0 : _window$blocklet5.daysUntilCancel) || 30
|
|
287
318
|
},
|
|
288
319
|
onPaid: handlePaid
|
|
289
320
|
})
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/launcher-workflow",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.26",
|
|
4
4
|
"description": "Purchase components for Launcher UI",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -41,22 +41,22 @@
|
|
|
41
41
|
"react": ">=18.1.0"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@arcblock/did-connect": "^2.10.
|
|
45
|
-
"@arcblock/icons": "^2.10.
|
|
46
|
-
"@arcblock/license": "^2.10.
|
|
47
|
-
"@arcblock/react-hooks": "^2.10.
|
|
48
|
-
"@arcblock/ux": "^2.10.
|
|
49
|
-
"@blocklet/launcher-layout": "2.3.
|
|
50
|
-
"@blocklet/launcher-util": "2.3.
|
|
51
|
-
"@blocklet/launcher-ux": "2.3.
|
|
52
|
-
"@blocklet/payment": "^1.13.
|
|
53
|
-
"@blocklet/payment-react": "^1.13.
|
|
44
|
+
"@arcblock/did-connect": "^2.10.3",
|
|
45
|
+
"@arcblock/icons": "^2.10.3",
|
|
46
|
+
"@arcblock/license": "^2.10.3",
|
|
47
|
+
"@arcblock/react-hooks": "^2.10.3",
|
|
48
|
+
"@arcblock/ux": "^2.10.3",
|
|
49
|
+
"@blocklet/launcher-layout": "2.3.26",
|
|
50
|
+
"@blocklet/launcher-util": "2.3.26",
|
|
51
|
+
"@blocklet/launcher-ux": "2.3.26",
|
|
52
|
+
"@blocklet/payment": "^1.13.287",
|
|
53
|
+
"@blocklet/payment-react": "^1.13.287",
|
|
54
54
|
"@emotion/react": "^11.11.4",
|
|
55
55
|
"@emotion/styled": "^11.11.5",
|
|
56
|
-
"@mui/icons-material": "^5.15.
|
|
56
|
+
"@mui/icons-material": "^5.15.21",
|
|
57
57
|
"@mui/lab": "^5.0.0-alpha.170",
|
|
58
|
-
"@mui/material": "^5.15.
|
|
59
|
-
"@ocap/util": "^1.18.
|
|
58
|
+
"@mui/material": "^5.15.21",
|
|
59
|
+
"@ocap/util": "^1.18.124",
|
|
60
60
|
"@splidejs/react-splide": "^0.7.12",
|
|
61
61
|
"@splidejs/splide": "^4.1.4",
|
|
62
62
|
"@splidejs/splide-extension-grid": "^0.4.1",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"moment": "^2.30.1",
|
|
76
76
|
"prop-types": "^15.8.1",
|
|
77
77
|
"react-lottie-player": "^1.5.6",
|
|
78
|
-
"react-router-dom": "^6.
|
|
78
|
+
"react-router-dom": "^6.24.0",
|
|
79
79
|
"react-use": "^17.5.0",
|
|
80
80
|
"url-join": "^4.0.1"
|
|
81
81
|
},
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"require": "./lib/locales/index.js"
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "9f84a9c3637c6eace67fb9bb47b682bc19638714"
|
|
109
109
|
}
|