@blocklet/launcher-workflow 2.3.33 → 2.3.35
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 +7 -2
- package/es/locales/zh.js +7 -2
- package/es/prepare.js +70 -58
- package/lib/locales/en.js +7 -2
- package/lib/locales/zh.js +7 -2
- package/lib/prepare.js +86 -72
- package/package.json +21 -21
package/es/locales/en.js
CHANGED
|
@@ -131,7 +131,7 @@ export default {
|
|
|
131
131
|
notRemind: 'No more reminders'
|
|
132
132
|
},
|
|
133
133
|
productType: {
|
|
134
|
-
|
|
134
|
+
serverless: 'On Demand Space',
|
|
135
135
|
dedicated: 'Dedicated Space'
|
|
136
136
|
},
|
|
137
137
|
paid: {
|
|
@@ -156,6 +156,11 @@ export default {
|
|
|
156
156
|
},
|
|
157
157
|
agreement: '{name} User Agreement',
|
|
158
158
|
estimatedCost: 'Estimated Cost',
|
|
159
|
-
|
|
159
|
+
estimatedCostFreeTrial: 'Estimated Cost After The Trial ends',
|
|
160
|
+
estimatedCostHint: 'The total cost will vary depending on the actual number and duration of components used in the application. The calculation method is: Unit price of component * Number of components * Duration.',
|
|
161
|
+
freeTrial: 'Free Trial',
|
|
162
|
+
freeTrialHint: 'Free trial for {duration}',
|
|
163
|
+
stakeAmount: 'Stake Amount',
|
|
164
|
+
stakeHint: 'On-demand spaces operate on a postpaid strategy. You need to stake {amount} for each space. If there are no due invoices when your subscription ends, the staking will be returned to you; otherwise, the staking will be slashed to pay for the due invoices.'
|
|
160
165
|
}
|
|
161
166
|
};
|
package/es/locales/zh.js
CHANGED
|
@@ -130,7 +130,7 @@ export default {
|
|
|
130
130
|
notRemind: '不再提醒'
|
|
131
131
|
},
|
|
132
132
|
productType: {
|
|
133
|
-
|
|
133
|
+
serverless: '按需空间',
|
|
134
134
|
dedicated: '专用空间'
|
|
135
135
|
},
|
|
136
136
|
paid: {
|
|
@@ -154,7 +154,12 @@ export default {
|
|
|
154
154
|
title: '选择支付货币'
|
|
155
155
|
},
|
|
156
156
|
agreement: '{name} 用户协议',
|
|
157
|
+
estimatedCostFreeTrial: '试用结束后估算成本',
|
|
157
158
|
estimatedCost: '估算成本',
|
|
158
|
-
estimatedCostHint: '总成本会根据应用实际使用的组件数量和时长而变化,计算方式为: 组件单价*组件数量*时长'
|
|
159
|
+
estimatedCostHint: '总成本会根据应用实际使用的组件数量和时长而变化,计算方式为: 组件单价*组件数量*时长',
|
|
160
|
+
freeTrial: '免费试用',
|
|
161
|
+
freeTrialHint: '免费试用{duration}',
|
|
162
|
+
stakeAmount: '质押金额',
|
|
163
|
+
stakeHint: '按需空间采用后付费策略,每个按需空间需要您质押 {amount} 作为服务使用保证金,如果服务结束后没有出现欠费,抵押金将会返还给您;否则会从抵押金中扣除欠费金额。'
|
|
159
164
|
}
|
|
160
165
|
};
|
package/es/prepare.js
CHANGED
|
@@ -34,26 +34,13 @@ const Root = styled('div')`
|
|
|
34
34
|
width: 100%;
|
|
35
35
|
}
|
|
36
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
|
-
};
|
|
52
37
|
function Content({
|
|
53
38
|
blocklet
|
|
54
39
|
}) {
|
|
55
40
|
const [state, setState] = useSetState({
|
|
56
|
-
productType:
|
|
41
|
+
productType: {
|
|
42
|
+
name: 'serverless'
|
|
43
|
+
}
|
|
57
44
|
});
|
|
58
45
|
const [params, setParams] = useSearchParams();
|
|
59
46
|
const {
|
|
@@ -73,59 +60,76 @@ function Content({
|
|
|
73
60
|
const navigate = useNavigate();
|
|
74
61
|
const sessionId = params.get('sessionId');
|
|
75
62
|
const blockletMetaUrl = getBlockletMetaUrlFromQuery(params);
|
|
76
|
-
const
|
|
63
|
+
const defaultProductTypeName = params.get('product_type');
|
|
77
64
|
const from = params.get('from');
|
|
65
|
+
const launchState = useAsync(async () => {
|
|
66
|
+
const createPromiseFn = (fn, ...args) => new Promise((resolve, reject) => {
|
|
67
|
+
fn(...args, (err, value) => {
|
|
68
|
+
if (err) {
|
|
69
|
+
reject(err);
|
|
70
|
+
} else {
|
|
71
|
+
resolve(value);
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
let launchFn = null;
|
|
76
|
+
if (sessionId) {
|
|
77
|
+
launchFn = createPromiseFn(launchSession.load, launchSessionAPI, routerPrefix, sessionId, blockletMetaUrl);
|
|
78
|
+
} else {
|
|
79
|
+
launchFn = createPromiseFn(launchSession.create, launchSessionAPI, routerPrefix, blockletMetaUrl);
|
|
80
|
+
}
|
|
81
|
+
const metadataFn = launchSessionAPI.get(`/metadata?blockletMetaUrl=${blockletMetaUrl}`).then(res => res.data);
|
|
82
|
+
const [launch, metadata] = await Promise.all([launchFn, metadataFn]);
|
|
83
|
+
return {
|
|
84
|
+
launch,
|
|
85
|
+
metadata
|
|
86
|
+
};
|
|
87
|
+
}, [session.user, blockletMetaUrl]);
|
|
78
88
|
const productTypes = useMemo(() => {
|
|
79
89
|
const result = [];
|
|
80
|
-
if (
|
|
81
|
-
result
|
|
82
|
-
}
|
|
90
|
+
if (launchState.loading) {
|
|
91
|
+
return result;
|
|
92
|
+
}
|
|
93
|
+
if (launchState.value?.metadata?.isBlockletSupportOnDemand === false) {
|
|
83
94
|
Toast.info(t('purchase.onDemandNotSupport'), {
|
|
84
95
|
persist: true
|
|
85
96
|
});
|
|
97
|
+
} else {
|
|
98
|
+
const name = 'serverless';
|
|
99
|
+
result.push({
|
|
100
|
+
name
|
|
101
|
+
});
|
|
86
102
|
}
|
|
87
103
|
if (window.blocklet?.preferences?.dedicatedPricingTableId) {
|
|
88
|
-
|
|
104
|
+
const name = 'dedicated';
|
|
105
|
+
result.push({
|
|
106
|
+
name
|
|
107
|
+
});
|
|
89
108
|
}
|
|
90
109
|
return result;
|
|
91
|
-
}, [
|
|
110
|
+
}, [launchState, t]);
|
|
92
111
|
useEffect(() => {
|
|
93
|
-
const defaultType = productTypes.
|
|
112
|
+
const defaultType = productTypes.find(x => x.name === defaultProductTypeName) ? {
|
|
113
|
+
name: defaultProductTypeName
|
|
114
|
+
} : productTypes?.[0];
|
|
94
115
|
if (defaultType) {
|
|
95
116
|
setState({
|
|
96
117
|
productType: defaultType
|
|
97
118
|
});
|
|
98
|
-
params.set('product_type', defaultType);
|
|
119
|
+
params.set('product_type', defaultType.name);
|
|
99
120
|
setParams(params, {
|
|
100
121
|
replace: true
|
|
101
122
|
});
|
|
102
123
|
}
|
|
103
|
-
}, [productTypes,
|
|
104
|
-
const launchState = useAsync(async () => {
|
|
105
|
-
const createPromiseFn = (fn, ...args) => new Promise((resolve, reject) => {
|
|
106
|
-
fn(...args, (err, value) => {
|
|
107
|
-
if (err) {
|
|
108
|
-
reject(err);
|
|
109
|
-
} else {
|
|
110
|
-
resolve(value);
|
|
111
|
-
}
|
|
112
|
-
});
|
|
113
|
-
});
|
|
114
|
-
if (sessionId) {
|
|
115
|
-
const launch = await createPromiseFn(launchSession.load, launchSessionAPI, routerPrefix, sessionId, blockletMetaUrl);
|
|
116
|
-
return launch;
|
|
117
|
-
}
|
|
118
|
-
const launch = await createPromiseFn(launchSession.create, launchSessionAPI, routerPrefix, blockletMetaUrl);
|
|
119
|
-
return launch;
|
|
120
|
-
});
|
|
124
|
+
}, [productTypes, defaultProductTypeName, params, setParams, setState]);
|
|
121
125
|
const getPurchaseNewLink = useCallback(() => {
|
|
122
|
-
window.location = launchState?.value?.app?.appURL;
|
|
126
|
+
window.location = launchState?.value?.launch?.app?.appURL;
|
|
123
127
|
const urlObj = new URL(window.location.href);
|
|
124
128
|
urlObj.searchParams.delete('sessionId');
|
|
125
129
|
return urlObj.href;
|
|
126
|
-
}, [launchState?.value?.app?.appURL]);
|
|
130
|
+
}, [launchState?.value?.launch?.app?.appURL]);
|
|
127
131
|
useEffect(() => {
|
|
128
|
-
const tmpLaunch = launchState.value;
|
|
132
|
+
const tmpLaunch = launchState.value?.launch;
|
|
129
133
|
if (!tmpLaunch) {
|
|
130
134
|
return;
|
|
131
135
|
}
|
|
@@ -135,7 +139,7 @@ function Content({
|
|
|
135
139
|
replace: true
|
|
136
140
|
});
|
|
137
141
|
}
|
|
138
|
-
}, [launchState.value, params, setParams]);
|
|
142
|
+
}, [launchState.value?.launch, params, setParams]);
|
|
139
143
|
if (launchState.loading || blocklet.loading) {
|
|
140
144
|
return /*#__PURE__*/_jsx(Center, {
|
|
141
145
|
relative: "parent",
|
|
@@ -148,14 +152,15 @@ function Content({
|
|
|
148
152
|
const handlePaid = () => {
|
|
149
153
|
navigate(`/paid?&sessionId=${launch._id}&blocklet_meta_url=${launch.blockletMetaUrl}&from=${from}`);
|
|
150
154
|
};
|
|
151
|
-
const handleChangeProductType = (
|
|
152
|
-
if (!
|
|
155
|
+
const handleChangeProductType = (_, typeName) => {
|
|
156
|
+
if (!typeName) {
|
|
153
157
|
return;
|
|
154
158
|
}
|
|
159
|
+
const newProductType = productTypes.find(x => x.name === typeName);
|
|
155
160
|
setState({
|
|
156
161
|
productType: newProductType
|
|
157
162
|
});
|
|
158
|
-
params.set('product_type', newProductType);
|
|
163
|
+
params.set('product_type', newProductType.name);
|
|
159
164
|
setParams(params, {
|
|
160
165
|
replace: true
|
|
161
166
|
});
|
|
@@ -163,7 +168,7 @@ function Content({
|
|
|
163
168
|
|
|
164
169
|
// TODO: PaymentKitV2 处理支付失败的情况
|
|
165
170
|
|
|
166
|
-
const launch = launchState.value;
|
|
171
|
+
const launch = launchState.value?.launch;
|
|
167
172
|
if ([LAUNCH_STATUS.paid, LAUNCH_STATUS.nftMinted, LAUNCH_STATUS.allocated].includes(launch.status)) {
|
|
168
173
|
return /*#__PURE__*/_jsx(ConfirmDialog, {
|
|
169
174
|
title: t('purchase.unexpectedLaunchSession.paid'),
|
|
@@ -215,18 +220,23 @@ function Content({
|
|
|
215
220
|
children: [productTypes.length > 1 && /*#__PURE__*/_jsx(ToggleButtonGroup, {
|
|
216
221
|
orientation: "horizontal",
|
|
217
222
|
color: "primary",
|
|
218
|
-
value: state.productType,
|
|
223
|
+
value: state.productType?.name,
|
|
219
224
|
size: "small",
|
|
220
225
|
onChange: handleChangeProductType,
|
|
221
226
|
exclusive: true,
|
|
222
|
-
|
|
227
|
+
sx: {
|
|
228
|
+
marginTop: '8px'
|
|
229
|
+
},
|
|
230
|
+
children: productTypes.map(({
|
|
231
|
+
name
|
|
232
|
+
}) => {
|
|
223
233
|
return /*#__PURE__*/_jsx(ToggleButton, {
|
|
224
|
-
value:
|
|
234
|
+
value: name,
|
|
225
235
|
sx: {
|
|
226
236
|
textTransform: 'capitalize'
|
|
227
237
|
},
|
|
228
|
-
children: t(`purchase.productType.${
|
|
229
|
-
},
|
|
238
|
+
children: t(`purchase.productType.${name}`)
|
|
239
|
+
}, name);
|
|
230
240
|
})
|
|
231
241
|
}), /*#__PURE__*/_jsxs(Box, {
|
|
232
242
|
sx: {
|
|
@@ -240,7 +250,7 @@ function Content({
|
|
|
240
250
|
maxWidth: '100%'
|
|
241
251
|
}
|
|
242
252
|
},
|
|
243
|
-
children: [state.productType === '
|
|
253
|
+
children: [state.productType?.name === 'serverless' && /*#__PURE__*/_jsx(CheckoutOnDemand, {
|
|
244
254
|
launchSessionId: sessionId,
|
|
245
255
|
handlePaid: handlePaid,
|
|
246
256
|
components: (blocklet.components || []).map(x => ({
|
|
@@ -259,8 +269,10 @@ function Content({
|
|
|
259
269
|
t: t,
|
|
260
270
|
locale: locale,
|
|
261
271
|
api: launchSessionAPI,
|
|
262
|
-
|
|
263
|
-
|
|
272
|
+
freeTrialProducts: launchState.value?.metadata?.freeTrialProducts || [],
|
|
273
|
+
checkoutPath: "/payment/checkout",
|
|
274
|
+
minStakeAmount: launchState.value?.metadata?.minStakeAmount
|
|
275
|
+
}), state.productType?.name === 'dedicated' && window.blocklet?.preferences?.dedicatedPricingTableId && /*#__PURE__*/_jsx(Box, {
|
|
264
276
|
sx: {
|
|
265
277
|
display: 'flex',
|
|
266
278
|
width: '100%',
|
package/lib/locales/en.js
CHANGED
|
@@ -137,7 +137,7 @@ var _default = exports.default = {
|
|
|
137
137
|
notRemind: 'No more reminders'
|
|
138
138
|
},
|
|
139
139
|
productType: {
|
|
140
|
-
|
|
140
|
+
serverless: 'On Demand Space',
|
|
141
141
|
dedicated: 'Dedicated Space'
|
|
142
142
|
},
|
|
143
143
|
paid: {
|
|
@@ -162,6 +162,11 @@ var _default = exports.default = {
|
|
|
162
162
|
},
|
|
163
163
|
agreement: '{name} User Agreement',
|
|
164
164
|
estimatedCost: 'Estimated Cost',
|
|
165
|
-
|
|
165
|
+
estimatedCostFreeTrial: 'Estimated Cost After The Trial ends',
|
|
166
|
+
estimatedCostHint: 'The total cost will vary depending on the actual number and duration of components used in the application. The calculation method is: Unit price of component * Number of components * Duration.',
|
|
167
|
+
freeTrial: 'Free Trial',
|
|
168
|
+
freeTrialHint: 'Free trial for {duration}',
|
|
169
|
+
stakeAmount: 'Stake Amount',
|
|
170
|
+
stakeHint: 'On-demand spaces operate on a postpaid strategy. You need to stake {amount} for each space. If there are no due invoices when your subscription ends, the staking will be returned to you; otherwise, the staking will be slashed to pay for the due invoices.'
|
|
166
171
|
}
|
|
167
172
|
};
|
package/lib/locales/zh.js
CHANGED
|
@@ -136,7 +136,7 @@ var _default = exports.default = {
|
|
|
136
136
|
notRemind: '不再提醒'
|
|
137
137
|
},
|
|
138
138
|
productType: {
|
|
139
|
-
|
|
139
|
+
serverless: '按需空间',
|
|
140
140
|
dedicated: '专用空间'
|
|
141
141
|
},
|
|
142
142
|
paid: {
|
|
@@ -160,7 +160,12 @@ var _default = exports.default = {
|
|
|
160
160
|
title: '选择支付货币'
|
|
161
161
|
},
|
|
162
162
|
agreement: '{name} 用户协议',
|
|
163
|
+
estimatedCostFreeTrial: '试用结束后估算成本',
|
|
163
164
|
estimatedCost: '估算成本',
|
|
164
|
-
estimatedCostHint: '总成本会根据应用实际使用的组件数量和时长而变化,计算方式为: 组件单价*组件数量*时长'
|
|
165
|
+
estimatedCostHint: '总成本会根据应用实际使用的组件数量和时长而变化,计算方式为: 组件单价*组件数量*时长',
|
|
166
|
+
freeTrial: '免费试用',
|
|
167
|
+
freeTrialHint: '免费试用{duration}',
|
|
168
|
+
stakeAmount: '质押金额',
|
|
169
|
+
stakeHint: '按需空间采用后付费策略,每个按需空间需要您质押 {amount} 作为服务使用保证金,如果服务结束后没有出现欠费,抵押金将会返还给您;否则会从抵押金中扣除欠费金额。'
|
|
165
170
|
}
|
|
166
171
|
};
|
package/lib/prepare.js
CHANGED
|
@@ -35,28 +35,15 @@ var _templateObject;
|
|
|
35
35
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
36
36
|
function _taggedTemplateLiteral(e, t) { return t || (t = e.slice(0)), Object.freeze(Object.defineProperties(e, { raw: { value: Object.freeze(t) } })); }
|
|
37
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
|
-
};
|
|
53
38
|
function Content(_ref) {
|
|
54
|
-
var _launchState$
|
|
39
|
+
var _launchState$value3, _launchState$value5, _launchState$value6, _state$productType, _state$productType2, _ref3, _launchState$value7, _launchState$value8, _state$productType3, _window$blocklet2, _window$blocklet3, _window$blocklet4;
|
|
55
40
|
let {
|
|
56
41
|
blocklet
|
|
57
42
|
} = _ref;
|
|
58
43
|
const [state, setState] = (0, _useSetState.default)({
|
|
59
|
-
productType:
|
|
44
|
+
productType: {
|
|
45
|
+
name: 'serverless'
|
|
46
|
+
}
|
|
60
47
|
});
|
|
61
48
|
const [params, setParams] = (0, _reactRouterDom.useSearchParams)();
|
|
62
49
|
const {
|
|
@@ -76,35 +63,8 @@ function Content(_ref) {
|
|
|
76
63
|
const navigate = (0, _reactRouterDom.useNavigate)();
|
|
77
64
|
const sessionId = params.get('sessionId');
|
|
78
65
|
const blockletMetaUrl = (0, _util.getBlockletMetaUrlFromQuery)(params);
|
|
79
|
-
const
|
|
66
|
+
const defaultProductTypeName = params.get('product_type');
|
|
80
67
|
const from = params.get('from');
|
|
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]);
|
|
96
|
-
(0, _react.useEffect)(() => {
|
|
97
|
-
const defaultType = productTypes.includes(defaultProductType) ? defaultProductType : productTypes === null || productTypes === void 0 ? void 0 : productTypes[0];
|
|
98
|
-
if (defaultType) {
|
|
99
|
-
setState({
|
|
100
|
-
productType: defaultType
|
|
101
|
-
});
|
|
102
|
-
params.set('product_type', defaultType);
|
|
103
|
-
setParams(params, {
|
|
104
|
-
replace: true
|
|
105
|
-
});
|
|
106
|
-
}
|
|
107
|
-
}, [productTypes, defaultProductType, params, setParams, setState]);
|
|
108
68
|
const launchState = (0, _useAsync.default)(async () => {
|
|
109
69
|
const createPromiseFn = function createPromiseFn(fn) {
|
|
110
70
|
for (var _len = arguments.length, args = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
|
|
@@ -120,22 +80,67 @@ function Content(_ref) {
|
|
|
120
80
|
});
|
|
121
81
|
});
|
|
122
82
|
};
|
|
83
|
+
let launchFn = null;
|
|
123
84
|
if (sessionId) {
|
|
124
|
-
|
|
125
|
-
|
|
85
|
+
launchFn = createPromiseFn(_util2.launchSession.load, launchSessionAPI, routerPrefix, sessionId, blockletMetaUrl);
|
|
86
|
+
} else {
|
|
87
|
+
launchFn = createPromiseFn(_util2.launchSession.create, launchSessionAPI, routerPrefix, blockletMetaUrl);
|
|
126
88
|
}
|
|
127
|
-
const
|
|
128
|
-
|
|
129
|
-
|
|
89
|
+
const metadataFn = launchSessionAPI.get("/metadata?blockletMetaUrl=".concat(blockletMetaUrl)).then(res => res.data);
|
|
90
|
+
const [launch, metadata] = await Promise.all([launchFn, metadataFn]);
|
|
91
|
+
return {
|
|
92
|
+
launch,
|
|
93
|
+
metadata
|
|
94
|
+
};
|
|
95
|
+
}, [session.user, blockletMetaUrl]);
|
|
96
|
+
const productTypes = (0, _react.useMemo)(() => {
|
|
97
|
+
var _launchState$value, _window$blocklet;
|
|
98
|
+
const result = [];
|
|
99
|
+
if (launchState.loading) {
|
|
100
|
+
return result;
|
|
101
|
+
}
|
|
102
|
+
if (((_launchState$value = launchState.value) === null || _launchState$value === void 0 || (_launchState$value = _launchState$value.metadata) === null || _launchState$value === void 0 ? void 0 : _launchState$value.isBlockletSupportOnDemand) === false) {
|
|
103
|
+
_Toast.default.info(t('purchase.onDemandNotSupport'), {
|
|
104
|
+
persist: true
|
|
105
|
+
});
|
|
106
|
+
} else {
|
|
107
|
+
const name = 'serverless';
|
|
108
|
+
result.push({
|
|
109
|
+
name
|
|
110
|
+
});
|
|
111
|
+
}
|
|
112
|
+
if ((_window$blocklet = window.blocklet) !== null && _window$blocklet !== void 0 && (_window$blocklet = _window$blocklet.preferences) !== null && _window$blocklet !== void 0 && _window$blocklet.dedicatedPricingTableId) {
|
|
113
|
+
const name = 'dedicated';
|
|
114
|
+
result.push({
|
|
115
|
+
name
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
return result;
|
|
119
|
+
}, [launchState, t]);
|
|
120
|
+
(0, _react.useEffect)(() => {
|
|
121
|
+
const defaultType = productTypes.find(x => x.name === defaultProductTypeName) ? {
|
|
122
|
+
name: defaultProductTypeName
|
|
123
|
+
} : productTypes === null || productTypes === void 0 ? void 0 : productTypes[0];
|
|
124
|
+
if (defaultType) {
|
|
125
|
+
setState({
|
|
126
|
+
productType: defaultType
|
|
127
|
+
});
|
|
128
|
+
params.set('product_type', defaultType.name);
|
|
129
|
+
setParams(params, {
|
|
130
|
+
replace: true
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
}, [productTypes, defaultProductTypeName, params, setParams, setState]);
|
|
130
134
|
const getPurchaseNewLink = (0, _react.useCallback)(() => {
|
|
131
|
-
var _launchState$
|
|
132
|
-
window.location = launchState === null || launchState === void 0 || (_launchState$
|
|
135
|
+
var _launchState$value2;
|
|
136
|
+
window.location = launchState === null || launchState === void 0 || (_launchState$value2 = launchState.value) === null || _launchState$value2 === void 0 || (_launchState$value2 = _launchState$value2.launch) === null || _launchState$value2 === void 0 || (_launchState$value2 = _launchState$value2.app) === null || _launchState$value2 === void 0 ? void 0 : _launchState$value2.appURL;
|
|
133
137
|
const urlObj = new URL(window.location.href);
|
|
134
138
|
urlObj.searchParams.delete('sessionId');
|
|
135
139
|
return urlObj.href;
|
|
136
|
-
}, [launchState === null || launchState === void 0 || (_launchState$
|
|
140
|
+
}, [launchState === null || launchState === void 0 || (_launchState$value3 = launchState.value) === null || _launchState$value3 === void 0 || (_launchState$value3 = _launchState$value3.launch) === null || _launchState$value3 === void 0 || (_launchState$value3 = _launchState$value3.app) === null || _launchState$value3 === void 0 ? void 0 : _launchState$value3.appURL]);
|
|
137
141
|
(0, _react.useEffect)(() => {
|
|
138
|
-
|
|
142
|
+
var _launchState$value4;
|
|
143
|
+
const tmpLaunch = (_launchState$value4 = launchState.value) === null || _launchState$value4 === void 0 ? void 0 : _launchState$value4.launch;
|
|
139
144
|
if (!tmpLaunch) {
|
|
140
145
|
return;
|
|
141
146
|
}
|
|
@@ -145,7 +150,7 @@ function Content(_ref) {
|
|
|
145
150
|
replace: true
|
|
146
151
|
});
|
|
147
152
|
}
|
|
148
|
-
}, [launchState.value, params, setParams]);
|
|
153
|
+
}, [(_launchState$value5 = launchState.value) === null || _launchState$value5 === void 0 ? void 0 : _launchState$value5.launch, params, setParams]);
|
|
149
154
|
if (launchState.loading || blocklet.loading) {
|
|
150
155
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_Center.default, {
|
|
151
156
|
relative: "parent",
|
|
@@ -158,14 +163,15 @@ function Content(_ref) {
|
|
|
158
163
|
const handlePaid = () => {
|
|
159
164
|
navigate("/paid?&sessionId=".concat(launch._id, "&blocklet_meta_url=").concat(launch.blockletMetaUrl, "&from=").concat(from));
|
|
160
165
|
};
|
|
161
|
-
const handleChangeProductType = (
|
|
162
|
-
if (!
|
|
166
|
+
const handleChangeProductType = (_, typeName) => {
|
|
167
|
+
if (!typeName) {
|
|
163
168
|
return;
|
|
164
169
|
}
|
|
170
|
+
const newProductType = productTypes.find(x => x.name === typeName);
|
|
165
171
|
setState({
|
|
166
172
|
productType: newProductType
|
|
167
173
|
});
|
|
168
|
-
params.set('product_type', newProductType);
|
|
174
|
+
params.set('product_type', newProductType.name);
|
|
169
175
|
setParams(params, {
|
|
170
176
|
replace: true
|
|
171
177
|
});
|
|
@@ -173,7 +179,7 @@ function Content(_ref) {
|
|
|
173
179
|
|
|
174
180
|
// TODO: PaymentKitV2 处理支付失败的情况
|
|
175
181
|
|
|
176
|
-
const launch = launchState.value;
|
|
182
|
+
const launch = (_launchState$value6 = launchState.value) === null || _launchState$value6 === void 0 ? void 0 : _launchState$value6.launch;
|
|
177
183
|
if ([_constant.LAUNCH_STATUS.paid, _constant.LAUNCH_STATUS.nftMinted, _constant.LAUNCH_STATUS.allocated].includes(launch.status)) {
|
|
178
184
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_confirm.default, {
|
|
179
185
|
title: t('purchase.unexpectedLaunchSession.paid'),
|
|
@@ -226,18 +232,24 @@ function Content(_ref) {
|
|
|
226
232
|
children: [productTypes.length > 1 && /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButtonGroup.default, {
|
|
227
233
|
orientation: "horizontal",
|
|
228
234
|
color: "primary",
|
|
229
|
-
value: state.productType,
|
|
235
|
+
value: (_state$productType = state.productType) === null || _state$productType === void 0 ? void 0 : _state$productType.name,
|
|
230
236
|
size: "small",
|
|
231
237
|
onChange: handleChangeProductType,
|
|
232
238
|
exclusive: true,
|
|
233
|
-
|
|
239
|
+
sx: {
|
|
240
|
+
marginTop: '8px'
|
|
241
|
+
},
|
|
242
|
+
children: productTypes.map(_ref2 => {
|
|
243
|
+
let {
|
|
244
|
+
name
|
|
245
|
+
} = _ref2;
|
|
234
246
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_ToggleButton.default, {
|
|
235
|
-
value:
|
|
247
|
+
value: name,
|
|
236
248
|
sx: {
|
|
237
249
|
textTransform: 'capitalize'
|
|
238
250
|
},
|
|
239
|
-
children: t("purchase.productType.".concat(
|
|
240
|
-
},
|
|
251
|
+
children: t("purchase.productType.".concat(name))
|
|
252
|
+
}, name);
|
|
241
253
|
})
|
|
242
254
|
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)(_Box.default, {
|
|
243
255
|
sx: {
|
|
@@ -251,7 +263,7 @@ function Content(_ref) {
|
|
|
251
263
|
maxWidth: '100%'
|
|
252
264
|
}
|
|
253
265
|
},
|
|
254
|
-
children: [state.productType === '
|
|
266
|
+
children: [((_state$productType2 = state.productType) === null || _state$productType2 === void 0 ? void 0 : _state$productType2.name) === 'serverless' && /*#__PURE__*/(0, _jsxRuntime.jsx)(_onDemand.default, {
|
|
255
267
|
launchSessionId: sessionId,
|
|
256
268
|
handlePaid: handlePaid,
|
|
257
269
|
components: (blocklet.components || []).map(x => ({
|
|
@@ -264,14 +276,16 @@ function Content(_ref) {
|
|
|
264
276
|
logoPath: x.meta.logo
|
|
265
277
|
})
|
|
266
278
|
})),
|
|
267
|
-
blockletStoreURL: (
|
|
279
|
+
blockletStoreURL: (_ref3 = from !== 'did-spaces') !== null && _ref3 !== void 0 ? _ref3 : blocklet.registryUrl,
|
|
268
280
|
connectApi: connectApi,
|
|
269
281
|
session: session,
|
|
270
282
|
t: t,
|
|
271
283
|
locale: locale,
|
|
272
284
|
api: launchSessionAPI,
|
|
273
|
-
|
|
274
|
-
|
|
285
|
+
freeTrialProducts: ((_launchState$value7 = launchState.value) === null || _launchState$value7 === void 0 || (_launchState$value7 = _launchState$value7.metadata) === null || _launchState$value7 === void 0 ? void 0 : _launchState$value7.freeTrialProducts) || [],
|
|
286
|
+
checkoutPath: "/payment/checkout",
|
|
287
|
+
minStakeAmount: (_launchState$value8 = launchState.value) === null || _launchState$value8 === void 0 || (_launchState$value8 = _launchState$value8.metadata) === null || _launchState$value8 === void 0 ? void 0 : _launchState$value8.minStakeAmount
|
|
288
|
+
}), ((_state$productType3 = state.productType) === null || _state$productType3 === void 0 ? void 0 : _state$productType3.name) === 'dedicated' && ((_window$blocklet2 = window.blocklet) === null || _window$blocklet2 === void 0 || (_window$blocklet2 = _window$blocklet2.preferences) === null || _window$blocklet2 === void 0 ? void 0 : _window$blocklet2.dedicatedPricingTableId) && /*#__PURE__*/(0, _jsxRuntime.jsx)(_Box.default, {
|
|
275
289
|
sx: {
|
|
276
290
|
display: 'flex',
|
|
277
291
|
width: '100%',
|
|
@@ -308,13 +322,13 @@ function Content(_ref) {
|
|
|
308
322
|
session: session,
|
|
309
323
|
connect: connectApi,
|
|
310
324
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_paymentReact.CheckoutTable, {
|
|
311
|
-
id: (_window$
|
|
325
|
+
id: (_window$blocklet3 = window.blocklet) === null || _window$blocklet3 === void 0 || (_window$blocklet3 = _window$blocklet3.preferences) === null || _window$blocklet3 === void 0 ? void 0 : _window$blocklet3.dedicatedPricingTableId,
|
|
312
326
|
mode: "inline",
|
|
313
327
|
extraParams: {
|
|
314
328
|
'metadata.session_id': launch._id,
|
|
315
329
|
'subscription_data.trial_end': (0, _util.getDefaultTrialEnd)(),
|
|
316
330
|
'subscription_data.days_until_due': 0,
|
|
317
|
-
'subscription_data.days_until_cancel': ((_window$
|
|
331
|
+
'subscription_data.days_until_cancel': ((_window$blocklet4 = window.blocklet) === null || _window$blocklet4 === void 0 || (_window$blocklet4 = _window$blocklet4.preferences) === null || _window$blocklet4 === void 0 ? void 0 : _window$blocklet4.daysUntilCancel) || 30
|
|
318
332
|
},
|
|
319
333
|
onPaid: handlePaid
|
|
320
334
|
})
|
|
@@ -342,10 +356,10 @@ function Content(_ref) {
|
|
|
342
356
|
})
|
|
343
357
|
});
|
|
344
358
|
}
|
|
345
|
-
function PreparePage(
|
|
359
|
+
function PreparePage(_ref4) {
|
|
346
360
|
let {
|
|
347
361
|
blocklet
|
|
348
|
-
} =
|
|
362
|
+
} = _ref4;
|
|
349
363
|
const {
|
|
350
364
|
t
|
|
351
365
|
} = (0, _locale.useLocaleContext)();
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@blocklet/launcher-workflow",
|
|
3
|
-
"version": "2.3.
|
|
3
|
+
"version": "2.3.35",
|
|
4
4
|
"description": "Purchase components for Launcher UI",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -41,21 +41,21 @@
|
|
|
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.
|
|
53
|
-
"@blocklet/payment-react": "^1.
|
|
54
|
-
"@emotion/react": "^11.
|
|
55
|
-
"@emotion/styled": "^11.
|
|
56
|
-
"@mui/icons-material": "^5.16.
|
|
57
|
-
"@mui/lab": "^5.0.0-alpha.
|
|
58
|
-
"@mui/material": "^5.16.
|
|
44
|
+
"@arcblock/did-connect": "^2.10.10",
|
|
45
|
+
"@arcblock/icons": "^2.10.10",
|
|
46
|
+
"@arcblock/license": "^2.10.10",
|
|
47
|
+
"@arcblock/react-hooks": "^2.10.10",
|
|
48
|
+
"@arcblock/ux": "^2.10.10",
|
|
49
|
+
"@blocklet/launcher-layout": "2.3.35",
|
|
50
|
+
"@blocklet/launcher-util": "2.3.35",
|
|
51
|
+
"@blocklet/launcher-ux": "2.3.35",
|
|
52
|
+
"@blocklet/payment": "^1.14.6",
|
|
53
|
+
"@blocklet/payment-react": "^1.14.6",
|
|
54
|
+
"@emotion/react": "^11.13.0",
|
|
55
|
+
"@emotion/styled": "^11.13.0",
|
|
56
|
+
"@mui/icons-material": "^5.16.5",
|
|
57
|
+
"@mui/lab": "^5.0.0-alpha.173",
|
|
58
|
+
"@mui/material": "^5.16.5",
|
|
59
59
|
"@ocap/util": "^1.18.126",
|
|
60
60
|
"@splidejs/react-splide": "^0.7.12",
|
|
61
61
|
"@splidejs/splide": "^4.1.4",
|
|
@@ -75,14 +75,14 @@
|
|
|
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.25.
|
|
79
|
-
"react-use": "^17.5.
|
|
78
|
+
"react-router-dom": "^6.25.1",
|
|
79
|
+
"react-use": "^17.5.1",
|
|
80
80
|
"url-join": "^4.0.1"
|
|
81
81
|
},
|
|
82
82
|
"devDependencies": {
|
|
83
83
|
"@babel/cli": "^7.24.8",
|
|
84
|
-
"@babel/core": "^7.
|
|
85
|
-
"@babel/preset-env": "^7.
|
|
84
|
+
"@babel/core": "^7.25.2",
|
|
85
|
+
"@babel/preset-env": "^7.25.2",
|
|
86
86
|
"@babel/preset-react": "^7.24.7",
|
|
87
87
|
"babel-plugin-inline-react-svg": "^2.0.2",
|
|
88
88
|
"glob": "^10.4.5"
|
|
@@ -105,5 +105,5 @@
|
|
|
105
105
|
"require": "./lib/locales/index.js"
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
|
-
"gitHead": "
|
|
108
|
+
"gitHead": "e911a8f6561282c5d6173098d1666725d1e7f1d1"
|
|
109
109
|
}
|