payment-kit 1.18.56 → 1.19.1

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.
Files changed (214) hide show
  1. package/.eslintrc.js +6 -0
  2. package/api/src/crons/index.ts +8 -0
  3. package/api/src/index.ts +4 -0
  4. package/api/src/libs/credit-grant.ts +146 -0
  5. package/api/src/libs/env.ts +1 -0
  6. package/api/src/libs/invoice.ts +4 -3
  7. package/api/src/libs/notification/template/base.ts +388 -2
  8. package/api/src/libs/notification/template/customer-credit-grant-granted.ts +149 -0
  9. package/api/src/libs/notification/template/customer-credit-grant-low-balance.ts +151 -0
  10. package/api/src/libs/notification/template/customer-credit-insufficient.ts +254 -0
  11. package/api/src/libs/notification/template/subscription-canceled.ts +193 -202
  12. package/api/src/libs/notification/template/subscription-refund-succeeded.ts +215 -237
  13. package/api/src/libs/notification/template/subscription-renewed.ts +130 -200
  14. package/api/src/libs/notification/template/subscription-succeeded.ts +100 -202
  15. package/api/src/libs/notification/template/subscription-trial-start.ts +142 -188
  16. package/api/src/libs/notification/template/subscription-trial-will-end.ts +146 -174
  17. package/api/src/libs/notification/template/subscription-upgraded.ts +96 -192
  18. package/api/src/libs/notification/template/subscription-will-canceled.ts +94 -135
  19. package/api/src/libs/notification/template/subscription-will-renew.ts +220 -245
  20. package/api/src/libs/payment.ts +69 -0
  21. package/api/src/libs/queue/index.ts +3 -2
  22. package/api/src/libs/session.ts +8 -0
  23. package/api/src/libs/subscription.ts +74 -3
  24. package/api/src/libs/ws.ts +23 -1
  25. package/api/src/locales/en.ts +33 -0
  26. package/api/src/locales/zh.ts +31 -0
  27. package/api/src/queues/credit-consume.ts +715 -0
  28. package/api/src/queues/credit-grant.ts +572 -0
  29. package/api/src/queues/notification.ts +173 -128
  30. package/api/src/queues/payment.ts +210 -122
  31. package/api/src/queues/subscription.ts +179 -0
  32. package/api/src/routes/checkout-sessions.ts +157 -9
  33. package/api/src/routes/connect/shared.ts +3 -2
  34. package/api/src/routes/credit-grants.ts +241 -0
  35. package/api/src/routes/credit-transactions.ts +208 -0
  36. package/api/src/routes/index.ts +8 -0
  37. package/api/src/routes/meter-events.ts +347 -0
  38. package/api/src/routes/meters.ts +219 -0
  39. package/api/src/routes/payment-currencies.ts +14 -2
  40. package/api/src/routes/payment-links.ts +1 -1
  41. package/api/src/routes/payment-methods.ts +14 -2
  42. package/api/src/routes/prices.ts +43 -0
  43. package/api/src/routes/pricing-table.ts +13 -7
  44. package/api/src/routes/products.ts +63 -4
  45. package/api/src/routes/settings.ts +1 -1
  46. package/api/src/routes/subscriptions.ts +4 -0
  47. package/api/src/store/migrations/20250610-billing-credit.ts +43 -0
  48. package/api/src/store/models/credit-grant.ts +486 -0
  49. package/api/src/store/models/credit-transaction.ts +268 -0
  50. package/api/src/store/models/customer.ts +8 -0
  51. package/api/src/store/models/index.ts +52 -1
  52. package/api/src/store/models/meter-event.ts +423 -0
  53. package/api/src/store/models/meter.ts +176 -0
  54. package/api/src/store/models/payment-currency.ts +66 -14
  55. package/api/src/store/models/price.ts +6 -0
  56. package/api/src/store/models/product.ts +2 -2
  57. package/api/src/store/models/subscription.ts +24 -0
  58. package/api/src/store/models/types.ts +28 -2
  59. package/api/tests/libs/subscription.spec.ts +53 -0
  60. package/blocklet.yml +9 -1
  61. package/package.json +57 -58
  62. package/scripts/sdk.js +233 -1
  63. package/src/app.tsx +10 -0
  64. package/src/components/actions.tsx +22 -9
  65. package/src/components/balance-list.tsx +40 -12
  66. package/src/components/collapse.tsx +33 -15
  67. package/src/components/copyable.tsx +8 -7
  68. package/src/components/currency.tsx +15 -7
  69. package/src/components/customer/actions.tsx +1 -5
  70. package/src/components/customer/credit-grant-item-list.tsx +99 -0
  71. package/src/components/customer/credit-overview.tsx +233 -0
  72. package/src/components/customer/form.tsx +7 -2
  73. package/src/components/customer/link.tsx +4 -12
  74. package/src/components/customer/notification-preference.tsx +18 -9
  75. package/src/components/customer/overdraft-protection.tsx +112 -41
  76. package/src/components/drawer-form.tsx +42 -18
  77. package/src/components/error.tsx +1 -5
  78. package/src/components/event/list.tsx +9 -10
  79. package/src/components/filter-toolbar.tsx +20 -19
  80. package/src/components/info-card.tsx +32 -18
  81. package/src/components/info-metric.tsx +16 -6
  82. package/src/components/info-row-group.tsx +1 -7
  83. package/src/components/info-row.tsx +30 -24
  84. package/src/components/invoice/action.tsx +1 -7
  85. package/src/components/invoice/list.tsx +34 -26
  86. package/src/components/invoice/recharge.tsx +5 -7
  87. package/src/components/invoice/table.tsx +17 -12
  88. package/src/components/layout/user.tsx +1 -1
  89. package/src/components/metadata/form.tsx +290 -94
  90. package/src/components/metadata/list.tsx +11 -3
  91. package/src/components/meter/actions.tsx +101 -0
  92. package/src/components/meter/add-usage-dialog.tsx +239 -0
  93. package/src/components/meter/events-list.tsx +657 -0
  94. package/src/components/meter/form.tsx +245 -0
  95. package/src/components/meter/products.tsx +264 -0
  96. package/src/components/meter/usage-guide.tsx +174 -0
  97. package/src/components/passport/actions.tsx +9 -4
  98. package/src/components/payment-currency/add.tsx +16 -3
  99. package/src/components/payment-currency/form.tsx +14 -6
  100. package/src/components/payment-intent/actions.tsx +24 -16
  101. package/src/components/payment-intent/list.tsx +30 -9
  102. package/src/components/payment-link/actions.tsx +1 -5
  103. package/src/components/payment-link/after-pay.tsx +4 -2
  104. package/src/components/payment-link/before-pay.tsx +14 -4
  105. package/src/components/payment-link/item.tsx +27 -6
  106. package/src/components/payment-link/preview.tsx +9 -9
  107. package/src/components/payment-link/product-select.tsx +69 -15
  108. package/src/components/payment-method/arcblock.tsx +8 -1
  109. package/src/components/payment-method/base.tsx +8 -1
  110. package/src/components/payment-method/bitcoin.tsx +8 -1
  111. package/src/components/payment-method/ethereum.tsx +8 -1
  112. package/src/components/payment-method/evm-rpc-input.tsx +11 -7
  113. package/src/components/payment-method/form.tsx +2 -7
  114. package/src/components/payment-method/stripe.tsx +2 -0
  115. package/src/components/payouts/actions.tsx +1 -5
  116. package/src/components/payouts/list.tsx +30 -10
  117. package/src/components/payouts/portal/list.tsx +11 -9
  118. package/src/components/price/currency-select.tsx +63 -32
  119. package/src/components/price/form.tsx +895 -370
  120. package/src/components/price/upsell-select.tsx +10 -2
  121. package/src/components/price/upsell.tsx +7 -2
  122. package/src/components/pricing-table/actions.tsx +1 -5
  123. package/src/components/pricing-table/customer-settings.tsx +5 -1
  124. package/src/components/pricing-table/payment-settings.tsx +14 -4
  125. package/src/components/pricing-table/preview.tsx +9 -9
  126. package/src/components/pricing-table/price-item.tsx +6 -1
  127. package/src/components/pricing-table/product-item.tsx +6 -1
  128. package/src/components/pricing-table/product-settings.tsx +17 -4
  129. package/src/components/product/actions.tsx +1 -5
  130. package/src/components/product/add-price.tsx +9 -7
  131. package/src/components/product/create.tsx +8 -9
  132. package/src/components/product/cross-sell-select.tsx +5 -1
  133. package/src/components/product/cross-sell.tsx +7 -2
  134. package/src/components/product/edit-price.tsx +21 -12
  135. package/src/components/product/features.tsx +26 -6
  136. package/src/components/product/form.tsx +115 -72
  137. package/src/components/progress-bar.tsx +1 -1
  138. package/src/components/refund/actions.tsx +1 -7
  139. package/src/components/refund/list.tsx +31 -18
  140. package/src/components/section/header.tsx +12 -14
  141. package/src/components/subscription/actions/cancel.tsx +22 -5
  142. package/src/components/subscription/actions/index.tsx +9 -10
  143. package/src/components/subscription/actions/pause.tsx +32 -6
  144. package/src/components/subscription/actions/slash-stake.tsx +5 -3
  145. package/src/components/subscription/description.tsx +12 -8
  146. package/src/components/subscription/items/index.tsx +31 -16
  147. package/src/components/subscription/items/usage-records.tsx +19 -5
  148. package/src/components/subscription/list.tsx +5 -7
  149. package/src/components/subscription/metrics.tsx +62 -15
  150. package/src/components/subscription/portal/actions.tsx +78 -71
  151. package/src/components/subscription/portal/cancel.tsx +10 -3
  152. package/src/components/subscription/portal/list.tsx +48 -26
  153. package/src/components/uploader.tsx +5 -13
  154. package/src/components/webhook/attempts.tsx +51 -16
  155. package/src/components/webhook/request-info.tsx +8 -6
  156. package/src/contexts/products.tsx +27 -10
  157. package/src/hooks/subscription.ts +34 -0
  158. package/src/libs/meter-utils.ts +196 -0
  159. package/src/libs/util.ts +4 -0
  160. package/src/locales/en.tsx +385 -4
  161. package/src/locales/zh.tsx +364 -0
  162. package/src/pages/admin/billing/index.tsx +61 -33
  163. package/src/pages/admin/billing/invoices/detail.tsx +49 -13
  164. package/src/pages/admin/billing/meters/create.tsx +60 -0
  165. package/src/pages/admin/billing/meters/detail.tsx +435 -0
  166. package/src/pages/admin/billing/meters/index.tsx +210 -0
  167. package/src/pages/admin/billing/meters/meter-event.tsx +346 -0
  168. package/src/pages/admin/billing/subscriptions/detail.tsx +90 -25
  169. package/src/pages/admin/customers/customers/credit-grant/detail.tsx +391 -0
  170. package/src/pages/admin/customers/customers/detail.tsx +67 -14
  171. package/src/pages/admin/customers/customers/index.tsx +6 -1
  172. package/src/pages/admin/customers/index.tsx +5 -0
  173. package/src/pages/admin/developers/events/detail.tsx +37 -11
  174. package/src/pages/admin/developers/index.tsx +1 -1
  175. package/src/pages/admin/developers/webhooks/detail.tsx +41 -11
  176. package/src/pages/admin/index.tsx +15 -2
  177. package/src/pages/admin/overview.tsx +107 -19
  178. package/src/pages/admin/payments/intents/detail.tsx +58 -14
  179. package/src/pages/admin/payments/payouts/detail.tsx +63 -15
  180. package/src/pages/admin/payments/refunds/detail.tsx +58 -14
  181. package/src/pages/admin/products/index.tsx +11 -4
  182. package/src/pages/admin/products/links/create.tsx +22 -4
  183. package/src/pages/admin/products/links/detail.tsx +43 -14
  184. package/src/pages/admin/products/passports/index.tsx +23 -4
  185. package/src/pages/admin/products/prices/actions.tsx +16 -9
  186. package/src/pages/admin/products/prices/detail.tsx +73 -14
  187. package/src/pages/admin/products/prices/list.tsx +15 -3
  188. package/src/pages/admin/products/pricing-tables/create.tsx +45 -12
  189. package/src/pages/admin/products/pricing-tables/detail.tsx +45 -14
  190. package/src/pages/admin/products/products/create.tsx +233 -54
  191. package/src/pages/admin/products/products/detail.tsx +74 -18
  192. package/src/pages/admin/settings/index.tsx +8 -1
  193. package/src/pages/admin/settings/payment-methods/index.tsx +87 -19
  194. package/src/pages/admin/settings/vault-config/edit-form.tsx +42 -28
  195. package/src/pages/admin/settings/vault-config/index.tsx +57 -10
  196. package/src/pages/customer/credit-grant/detail.tsx +308 -0
  197. package/src/pages/customer/index.tsx +76 -17
  198. package/src/pages/customer/invoice/detail.tsx +63 -14
  199. package/src/pages/customer/invoice/past-due.tsx +11 -3
  200. package/src/pages/customer/payout/detail.tsx +56 -13
  201. package/src/pages/customer/recharge/account.tsx +78 -18
  202. package/src/pages/customer/recharge/subscription.tsx +86 -25
  203. package/src/pages/customer/refund/list.tsx +60 -24
  204. package/src/pages/customer/subscription/change-payment.tsx +17 -6
  205. package/src/pages/customer/subscription/change-plan.tsx +34 -7
  206. package/src/pages/customer/subscription/detail.tsx +134 -34
  207. package/src/pages/customer/subscription/embed.tsx +25 -5
  208. package/src/pages/home.tsx +26 -4
  209. package/src/pages/integrations/donations/edit-form.tsx +25 -9
  210. package/src/pages/integrations/donations/index.tsx +26 -9
  211. package/src/pages/integrations/donations/preview.tsx +59 -15
  212. package/src/pages/integrations/index.tsx +10 -1
  213. package/src/pages/integrations/overview.tsx +78 -17
  214. package/vite.config.ts +60 -30
@@ -26,8 +26,8 @@ function YourComponent() {
26
26
  settings={{
27
27
  target: "post-123", // required, unique identifier for the donation instance
28
28
  title: "Support Author", // required, title of the donation modal
29
- description: "If you find this article helpful, feel free to buy me a coffee", // required, description of the donation
30
- reference: "https://your-site.com/posts/123", // required, reference link of the donation
29
+ description: "If you find this article helpful, feel free to buy me a coffee", // required, description of the donation
30
+ reference: "https://your-site.com/posts/123", // required, reference link of the donation
31
31
  beneficiaries: [
32
32
  {
33
33
  address: "tip user did", // required, address of the beneficiary
@@ -194,7 +194,12 @@ export default function DonationList() {
194
194
  return data[index]?.component_did || t('common.none');
195
195
  }
196
196
  return (
197
- <Stack direction="row" alignItems="center" gap={1}>
197
+ <Stack
198
+ direction="row"
199
+ sx={{
200
+ alignItems: 'center',
201
+ gap: 1,
202
+ }}>
198
203
  <Avatar
199
204
  src={joinURL(getPrefix(), `.well-known/service/blocklet/logo-bundle/${componentInfo.did}`)}
200
205
  alt={componentInfo?.title}
@@ -269,7 +274,13 @@ export default function DonationList() {
269
274
 
270
275
  return (
271
276
  <>
272
- <Stack direction="row" alignItems="center" gap={1} flexWrap="wrap">
277
+ <Stack
278
+ direction="row"
279
+ sx={{
280
+ alignItems: 'center',
281
+ gap: 1,
282
+ flexWrap: 'wrap',
283
+ }}>
273
284
  <Typography variant="body2">{t('admin.donate.intro')}</Typography>
274
285
  <Button variant="text" size="small" onClick={() => setShowExample(true)} sx={{ color: 'text.link' }}>
275
286
  {t('admin.donate.usage.viewExample')}
@@ -307,7 +318,6 @@ export default function DonationList() {
307
318
  }}
308
319
  onChange={onTableChange}
309
320
  />
310
-
311
321
  {showExample && (
312
322
  <Dialog
313
323
  open
@@ -317,17 +327,25 @@ export default function DonationList() {
317
327
  sx={{ '.MuiDialogContent-root': { padding: 0 } }}
318
328
  fullWidth>
319
329
  <Box sx={{ p: 3 }}>
320
- <Typography variant="body2" paragraph>
330
+ <Typography
331
+ variant="body2"
332
+ sx={{
333
+ marginBottom: '16px',
334
+ }}>
321
335
  {t('admin.donate.usage.description')}
322
336
  </Typography>
323
337
  <CodeExample code={exampleCode} />
324
- <Typography variant="body2" color="text.secondary" sx={{ mt: 2 }}>
338
+ <Typography
339
+ variant="body2"
340
+ sx={{
341
+ color: 'text.secondary',
342
+ mt: 2,
343
+ }}>
325
344
  {t('admin.donate.usage.note')}
326
345
  </Typography>
327
346
  </Box>
328
347
  </Dialog>
329
348
  )}
330
-
331
349
  {editingItem && (
332
350
  <Dialog
333
351
  open
@@ -346,7 +364,6 @@ export default function DonationList() {
346
364
  />
347
365
  </Dialog>
348
366
  )}
349
-
350
367
  {confirmDialog.open && (
351
368
  <ConfirmDialog
352
369
  title={t('admin.donate.status.inactiveTitle')}
@@ -5,7 +5,12 @@ import type { TSetting } from '@blocklet/payment-types';
5
5
 
6
6
  function PreviewAvatars({ count }: { count: number }) {
7
7
  return (
8
- <Stack flexDirection="row" justifyContent="center" alignItems="center">
8
+ <Stack
9
+ sx={{
10
+ flexDirection: 'row',
11
+ justifyContent: 'center',
12
+ alignItems: 'center',
13
+ }}>
9
14
  {/* Avatar Group */}
10
15
  <Box sx={{ display: 'flex', position: 'relative' }}>
11
16
  {Array(Math.min(count, 5))
@@ -28,7 +33,6 @@ function PreviewAvatars({ count }: { count: number }) {
28
33
  />
29
34
  ))}
30
35
  </Box>
31
-
32
36
  {/* Counter Box */}
33
37
  <Box
34
38
  sx={{
@@ -68,10 +72,14 @@ export default function DonationPreview({ config }: { config: TSetting['settings
68
72
 
69
73
  return (
70
74
  <Stack spacing={3}>
71
- <Typography variant="h6" gutterBottom color="text.primary">
75
+ <Typography
76
+ variant="h6"
77
+ gutterBottom
78
+ sx={{
79
+ color: 'text.primary',
80
+ }}>
72
81
  {t('admin.donate.previewTitle')}
73
82
  </Typography>
74
-
75
83
  {/* Button Preview */}
76
84
  <Paper
77
85
  elevation={0}
@@ -82,10 +90,21 @@ export default function DonationPreview({ config }: { config: TSetting['settings
82
90
  borderColor: 'divider',
83
91
  borderRadius: 1,
84
92
  }}>
85
- <Typography variant="caption" display="block" gutterBottom color="text.secondary" mb={1}>
93
+ <Typography
94
+ variant="caption"
95
+ gutterBottom
96
+ sx={{
97
+ display: 'block',
98
+ color: 'text.secondary',
99
+ mb: 1,
100
+ }}>
86
101
  {t('admin.donate.btn.preview')}
87
102
  </Typography>
88
- <Stack spacing={2} alignItems="center">
103
+ <Stack
104
+ spacing={2}
105
+ sx={{
106
+ alignItems: 'center',
107
+ }}>
89
108
  <Button variant="outlined" color="primary">
90
109
  {config.settings.btnText}
91
110
  </Button>
@@ -116,7 +135,13 @@ export default function DonationPreview({ config }: { config: TSetting['settings
116
135
  width: '100%',
117
136
  maxWidth: 240,
118
137
  }}>
119
- <Box display="flex" alignItems="center" gap={0.5} width="75%">
138
+ <Box
139
+ sx={{
140
+ display: 'flex',
141
+ alignItems: 'center',
142
+ gap: 0.5,
143
+ width: '75%',
144
+ }}>
120
145
  <Box
121
146
  // eslint-disable-next-line react/no-array-index-key
122
147
  key={i}
@@ -155,7 +180,6 @@ export default function DonationPreview({ config }: { config: TSetting['settings
155
180
  </Box>
156
181
  </Stack>
157
182
  </Paper>
158
-
159
183
  {/* Dialog Preview */}
160
184
  <Paper
161
185
  elevation={0}
@@ -166,11 +190,23 @@ export default function DonationPreview({ config }: { config: TSetting['settings
166
190
  borderColor: 'divider',
167
191
  borderRadius: 1,
168
192
  }}>
169
- <Typography variant="caption" display="block" gutterBottom color="text.secondary" mb={1}>
193
+ <Typography
194
+ variant="caption"
195
+ gutterBottom
196
+ sx={{
197
+ display: 'block',
198
+ color: 'text.secondary',
199
+ mb: 1,
200
+ }}>
170
201
  {t('admin.donate.dialog.preview')}
171
202
  </Typography>
172
203
  <Stack spacing={3}>
173
- <Box display="flex" gap={1} flexWrap="wrap">
204
+ <Box
205
+ sx={{
206
+ display: 'flex',
207
+ gap: 1,
208
+ flexWrap: 'wrap',
209
+ }}>
174
210
  {config.settings.amount.presets?.map((amount: string) => (
175
211
  <Button
176
212
  key={amount}
@@ -211,19 +247,27 @@ export default function DonationPreview({ config }: { config: TSetting['settings
211
247
  const { value } = e.target;
212
248
  setCustomAmount(value);
213
249
  }}
214
- InputProps={{
215
- endAdornment: <Typography sx={{ ml: 1 }}>ABT</Typography>,
216
- autoComplete: 'off',
217
- }}
218
250
  helperText={t('admin.donate.amountRange', {
219
251
  min: config.settings.amount.minimum,
220
252
  max: config.settings.amount.maximum,
221
253
  })}
254
+ slotProps={{
255
+ input: {
256
+ endAdornment: <Typography sx={{ ml: 1 }}>ABT</Typography>,
257
+ },
258
+ }}
259
+ autoComplete="off"
222
260
  />
223
261
  )}
224
262
  </Stack>
225
263
  <Divider sx={{ my: 2 }} />
226
- <Box display="flex" justifyContent="flex-end" alignItems="center" gap={1}>
264
+ <Box
265
+ sx={{
266
+ display: 'flex',
267
+ justifyContent: 'flex-end',
268
+ alignItems: 'center',
269
+ gap: 1,
270
+ }}>
227
271
  <Box
228
272
  sx={{
229
273
  px: 2,
@@ -35,7 +35,16 @@ function Integrations() {
35
35
  return (
36
36
  <>
37
37
  <ProgressBar pending={isPending} />
38
- <Stack direction="row" alignItems="center" justifyContent="end" flexWrap="wrap" spacing={1} sx={{ mt: 1, pb: 2 }}>
38
+ <Stack
39
+ direction="row"
40
+ spacing={1}
41
+ sx={{
42
+ alignItems: 'center',
43
+ justifyContent: 'end',
44
+ flexWrap: 'wrap',
45
+ mt: 1,
46
+ pb: 2,
47
+ }}>
39
48
  <Tabs
40
49
  tabs={tabs}
41
50
  current={group}
@@ -67,21 +67,51 @@ export default function Overview() {
67
67
 
68
68
  return (
69
69
  <Box>
70
- <Box mb={4}>
71
- <Typography variant="h2" gutterBottom fontWeight="bold" mb={1}>
70
+ <Box
71
+ sx={{
72
+ mb: 4,
73
+ }}>
74
+ <Typography
75
+ variant="h2"
76
+ gutterBottom
77
+ sx={{
78
+ fontWeight: 'bold',
79
+ mb: 1,
80
+ }}>
72
81
  {t('common.welcome')}
73
82
  </Typography>
74
- <Typography variant="body2" color="text.secondary" mb={2}>
83
+ <Typography
84
+ variant="body2"
85
+ sx={{
86
+ color: 'text.secondary',
87
+ mb: 2,
88
+ }}>
75
89
  {t('common.welcomeDesc')}
76
90
  </Typography>
77
91
  </Box>
78
-
79
- <Typography variant="h3" gutterBottom mb={2}>
92
+ <Typography
93
+ variant="h3"
94
+ gutterBottom
95
+ sx={{
96
+ mb: 2,
97
+ }}>
80
98
  {t('integrations.basicFeatures')} 🚀
81
99
  </Typography>
82
- <Grid container spacing={2} mb={4} sx={{ maxWidth: 1200 }}>
100
+ <Grid
101
+ container
102
+ spacing={2}
103
+ sx={{
104
+ mb: 4,
105
+ maxWidth: 1200,
106
+ }}>
83
107
  {basicFeatures.map((item) => (
84
- <Grid item xs={12} sm={6} md={4} key={item.path}>
108
+ <Grid
109
+ key={item.path}
110
+ size={{
111
+ xs: 12,
112
+ sm: 6,
113
+ md: 4,
114
+ }}>
85
115
  <Box
86
116
  className="base-card"
87
117
  onClick={() => handleClick(item)}
@@ -92,28 +122,48 @@ export default function Overview() {
92
122
  boxShadow: 2,
93
123
  },
94
124
  }}>
95
- <Box mb={1}>
125
+ <Box
126
+ sx={{
127
+ mb: 1,
128
+ }}>
96
129
  {item.icon}
97
- <Typography variant="h4" mt={1.5}>
130
+ <Typography
131
+ variant="h4"
132
+ sx={{
133
+ mt: 1.5,
134
+ }}>
98
135
  {t(item.title)}
99
136
  </Typography>
100
137
  </Box>
101
- <Typography variant="body2" color="text.secondary">
138
+ <Typography
139
+ variant="body2"
140
+ sx={{
141
+ color: 'text.secondary',
142
+ }}>
102
143
  {t(item.description)}
103
144
  </Typography>
104
145
  </Box>
105
146
  </Grid>
106
147
  ))}
107
148
  </Grid>
108
-
109
149
  <Divider sx={{ my: 4 }} />
110
-
111
- <Typography variant="h3" gutterBottom mb={2}>
150
+ <Typography
151
+ variant="h3"
152
+ gutterBottom
153
+ sx={{
154
+ mb: 2,
155
+ }}>
112
156
  {t('integrations.advancedFeatures')} 🔥
113
157
  </Typography>
114
158
  <Grid container spacing={2} sx={{ maxWidth: 1200 }}>
115
159
  {advancedFeatures.map((item) => (
116
- <Grid item xs={12} sm={6} md={4} key={item.path}>
160
+ <Grid
161
+ key={item.path}
162
+ size={{
163
+ xs: 12,
164
+ sm: 6,
165
+ md: 4,
166
+ }}>
117
167
  <Box
118
168
  className="base-card"
119
169
  onClick={() => handleClick(item)}
@@ -124,13 +174,24 @@ export default function Overview() {
124
174
  boxShadow: 2,
125
175
  },
126
176
  }}>
127
- <Box mb={1}>
177
+ <Box
178
+ sx={{
179
+ mb: 1,
180
+ }}>
128
181
  {item.icon}
129
- <Typography variant="h4" mt={1.5}>
182
+ <Typography
183
+ variant="h4"
184
+ sx={{
185
+ mt: 1.5,
186
+ }}>
130
187
  {t(item.title)}
131
188
  </Typography>
132
189
  </Box>
133
- <Typography variant="body2" color="text.secondary">
190
+ <Typography
191
+ variant="body2"
192
+ sx={{
193
+ color: 'text.secondary',
194
+ }}>
134
195
  {t(item.description)}
135
196
  </Typography>
136
197
  </Box>
package/vite.config.ts CHANGED
@@ -10,14 +10,27 @@ import path from 'path';
10
10
  // https://vitejs.dev/config/
11
11
  export default defineConfig(({ mode }) => {
12
12
  const isProduction = mode === 'production';
13
+ const isDevelopment = mode === 'development';
14
+ const alias: Record<string, string> = {};
15
+
16
+ if (isDevelopment) {
17
+ alias['@blocklet/payment-react'] = path.resolve(__dirname, '../../packages/react/src');
18
+ alias['@blocklet/payment-js'] = path.resolve(__dirname, '../../packages/client/src');
19
+ }
20
+
21
+ if (isProduction) {
22
+ // mui-datatable
23
+ alias['lodash.assign'] = 'lodash/assign';
24
+ alias['lodash.clonedeep'] = 'lodash/cloneDeep';
25
+ alias['lodash.isequal'] = 'lodash/isEqual';
26
+ alias['lodash.merge'] = 'lodash/merge';
27
+ alias['lodash.find'] = 'lodash/find';
28
+ }
29
+
13
30
  return {
14
31
  plugins: [
15
32
  tsconfigPaths(),
16
- react({
17
- babel: {
18
- plugins: isProduction ? [['lodash']] : [],
19
- },
20
- }),
33
+ react({ babel: { plugins: isProduction ? [['lodash']] : [] } }),
21
34
  createBlockletPlugin(),
22
35
  svgr(),
23
36
  process.env.ANALYZE && visualizer({ open: true, gzipSize: true, brotliSize: true }),
@@ -26,46 +39,63 @@ export default defineConfig(({ mode }) => {
26
39
  build: {
27
40
  cssCodeSplit: false,
28
41
  minify: 'terser',
29
- terserOptions: {
30
- compress: {
31
- drop_debugger: true,
32
- pure_funcs: ['assert', 'debug'],
33
- },
34
- },
42
+ terserOptions: { compress: { drop_debugger: true, pure_funcs: ['assert', 'debug'] } },
35
43
  reportCompressedSize: false,
36
44
  chunkSizeWarningLimit: 1000,
37
- commonjsOptions: {
38
- include: [/node_modules/],
39
- transformMixedEsModules: true,
40
- },
45
+ commonjsOptions: { include: [/node_modules/], transformMixedEsModules: true },
41
46
  rollupOptions: {
42
47
  external: [],
43
48
  output: {
44
49
  manualChunks: {
45
50
  'vendor-react': ['react', 'react-dom', 'react-router-dom'],
46
- 'vendor-mui': ['@mui/material', '@mui/system', '@mui/icons-material'],
51
+ 'vendor-mui': [
52
+ '@mui/material',
53
+ '@mui/icons-material',
54
+ '@mui/system',
55
+ '@mui/lab',
56
+ // '@mui/material-nextjs',
57
+ '@mui/styled-engine',
58
+ // '@mui/styled-engine-sc',
59
+ '@mui/utils',
60
+ // '@mui/x-data-grid',
61
+ // '@mui/x-data-grid-pro',
62
+ // '@mui/x-data-grid-premium',
63
+ // '@mui/x-date-pickers',
64
+ // '@mui/x-date-pickers-pro',
65
+ // '@mui/x-charts',
66
+ // '@mui/x-tree-view',
67
+ // '@mui/x-tree-view-pro',
68
+ ],
69
+ moment: ['moment', 'moment-timezone'],
47
70
  utils: ['dayjs', 'numbro', 'bn.js'],
48
71
  hooks: ['ahooks', 'use-bus'],
49
- 'vendor-arcblock': ['@arcblock/did-connect'],
72
+ lottie: ['lottie-web', 'react-lottie-player', '@lottiefiles/react-lottie-player'],
73
+ 'vendor-arcblock': ['@arcblock/did-connect', '@arcblock/ux'],
74
+ 'vendor-blocklet': ['@blocklet/ui-react'],
50
75
  },
51
76
  },
52
77
  },
53
78
  },
54
79
  optimizeDeps: {
55
80
  include: ['react', 'react-dom', 'react/jsx-runtime'],
56
- esbuildOptions: {
57
- mainFields: ['module', 'main'],
58
- resolveExtensions: ['.ts', '.tsx', '.js', '.jsx'],
59
- },
60
- exclude: mode === 'development' ? ['@blocklet/payment-react', '@blocklet/payment-js'] : [],
81
+ esbuildOptions: { mainFields: ['module', 'main'], resolveExtensions: ['.ts', '.tsx', '.js', '.jsx'] },
82
+ exclude: isDevelopment ? ['@blocklet/payment-react', '@blocklet/payment-js'] : [],
83
+ },
84
+ resolve: {
85
+ alias,
86
+ dedupe: [
87
+ //
88
+ '@blocklet/ui-react',
89
+ '@arcblock/ux',
90
+ '@arcblock/did-connect',
91
+ '@mui/material',
92
+ // '@mui/utils',
93
+ '@mui/icons-material',
94
+ 'react',
95
+ 'react-dom',
96
+ 'lodash',
97
+ 'bn.js',
98
+ ],
61
99
  },
62
- ...(mode === 'development' && {
63
- resolve: {
64
- alias: [
65
- { find: '@blocklet/payment-react', replacement: path.resolve(__dirname, '../../packages/react/src') },
66
- { find: '@blocklet/payment-js', replacement: path.resolve(__dirname, '../../packages/client/src') },
67
- ],
68
- },
69
- }),
70
100
  };
71
101
  });