@abtnode/ux 1.16.25-next-0ba03ffc → 1.16.25-next-44800645

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 (51) hide show
  1. package/es/blocklet/actions.js +9 -8
  2. package/es/blocklet/router/action/add-rule.js +12 -0
  3. package/es/blocklet/router/action/config-routing-rule.js +55 -4
  4. package/es/blocklet/router/action/update-rule.js +12 -0
  5. package/es/blocklet/router/rule-list.js +10 -2
  6. package/es/locales/ar.js +5 -1
  7. package/es/locales/de.js +5 -1
  8. package/es/locales/en.js +5 -1
  9. package/es/locales/es.js +5 -1
  10. package/es/locales/fr.js +5 -1
  11. package/es/locales/hi.js +5 -1
  12. package/es/locales/i18n.db +0 -0
  13. package/es/locales/id.js +5 -1
  14. package/es/locales/ja.js +5 -1
  15. package/es/locales/ko.js +5 -1
  16. package/es/locales/pt.js +5 -1
  17. package/es/locales/ru.js +5 -1
  18. package/es/locales/th.js +5 -1
  19. package/es/locales/vi.js +5 -1
  20. package/es/locales/zh-tw.js +5 -1
  21. package/es/locales/zh.js +5 -1
  22. package/es/{subscription/server.js → subscription.js} +28 -23
  23. package/es/util/index.js +5 -42
  24. package/lib/blocklet/actions.js +9 -8
  25. package/lib/blocklet/router/action/add-rule.js +12 -0
  26. package/lib/blocklet/router/action/config-routing-rule.js +52 -3
  27. package/lib/blocklet/router/action/update-rule.js +13 -0
  28. package/lib/blocklet/router/rule-list.js +10 -1
  29. package/lib/locales/ar.js +5 -1
  30. package/lib/locales/de.js +5 -1
  31. package/lib/locales/en.js +5 -1
  32. package/lib/locales/es.js +5 -1
  33. package/lib/locales/fr.js +5 -1
  34. package/lib/locales/hi.js +5 -1
  35. package/lib/locales/i18n.db +0 -0
  36. package/lib/locales/id.js +5 -1
  37. package/lib/locales/ja.js +5 -1
  38. package/lib/locales/ko.js +5 -1
  39. package/lib/locales/pt.js +5 -1
  40. package/lib/locales/ru.js +5 -1
  41. package/lib/locales/th.js +5 -1
  42. package/lib/locales/vi.js +5 -1
  43. package/lib/locales/zh-tw.js +5 -1
  44. package/lib/locales/zh.js +5 -1
  45. package/lib/{subscription/server.js → subscription.js} +35 -29
  46. package/lib/util/index.js +13 -51
  47. package/package.json +7 -7
  48. package/es/subscription/blocklet.js +0 -174
  49. package/es/subscription/chip-label.js +0 -22
  50. package/lib/subscription/blocklet.js +0 -186
  51. package/lib/subscription/chip-label.js +0 -29
@@ -22,13 +22,14 @@ import Alert from '@mui/material/Alert';
22
22
  import Button from '@arcblock/ux/lib/Button';
23
23
  import { getAppMissingConfigs, isDeletableBlocklet, hasRunnableComponent, getDisplayName, isInProgress } from '@blocklet/meta/lib/util';
24
24
  import { LocaleContext } from '@arcblock/ux/lib/Locale/context';
25
- import { BLOCKLET_CONTROLLER_STATUS, BLOCKLET_MODES } from '@blocklet/constant';
25
+ import { BLOCKLET_CONTROLLER_STATUS, BLOCKLET_MODES, SUSPENDED_REASON } from '@blocklet/constant';
26
26
  import Toast from '@arcblock/ux/lib/Toast';
27
27
  import { sleep, formatError, isDownloading } from '../util';
28
28
  import { getServerUrl } from './util';
29
29
  import { useNodeContext } from '../contexts/node';
30
30
  import Confirm from '../confirm';
31
31
  import Icons from './icons';
32
+ import { useBlockletContext } from '../contexts/blocklet';
32
33
  import { jsx as _jsx } from "react/jsx-runtime";
33
34
  import { jsxs as _jsxs } from "react/jsx-runtime";
34
35
  export default function BlockletActions({
@@ -54,14 +55,14 @@ export default function BlockletActions({
54
55
  loading: recommendedUrlLoading,
55
56
  recommendedUrl
56
57
  } = useBlockletUrlEvaluation(blocklet);
58
+ const {
59
+ nftState
60
+ } = useBlockletContext();
57
61
  const inProgress = isInProgress(blocklet.status);
58
- const disableStart = blocklet?.controller?.status?.value === BLOCKLET_CONTROLLER_STATUS.suspended;
59
-
60
- // TODO: PaymentKitV2 过期恢复后需要能立即启动
61
- // if (!nftState?.expired && blocklet?.controller?.status?.reason === SUSPENDED_REASON.expired) {
62
- // disableStart = false;
63
- // }
64
-
62
+ let disableStart = blocklet?.controller?.status?.value === BLOCKLET_CONTROLLER_STATUS.suspended;
63
+ if (!nftState?.expired && blocklet?.controller?.status?.reason === SUSPENDED_REASON.expired) {
64
+ disableStart = false;
65
+ }
65
66
  const {
66
67
  inService
67
68
  } = node;
@@ -65,6 +65,13 @@ export default function AddRule({
65
65
  if (params.type === ROUTING_RULE_TYPES.GENERAL_REWRITE) {
66
66
  rule.to.url = urlPathFriendly(params.url);
67
67
  }
68
+ if (params.type === ROUTING_RULE_TYPES.DIRECT_RESPONSE) {
69
+ rule.to.response = {
70
+ status: 200,
71
+ contentType: params.responseType,
72
+ body: params.responseBody
73
+ };
74
+ }
68
75
  await api.addRoutingRule({
69
76
  input: {
70
77
  id: siteId,
@@ -134,6 +141,9 @@ export default function AddRule({
134
141
  if (params.type === ROUTING_RULE_TYPES.GENERAL_REWRITE && !params.url) {
135
142
  disable = true;
136
143
  }
144
+ if (params.type === ROUTING_RULE_TYPES.DIRECT_RESPONSE && (!params.responseType || !params.responseBody)) {
145
+ disable = true;
146
+ }
137
147
  if (!e.target.value.trim()) {
138
148
  disable = true;
139
149
  setError(t('router.validation.pathPrefixRequired'));
@@ -167,6 +177,8 @@ export default function AddRule({
167
177
  componentId: '',
168
178
  pageGroup: '',
169
179
  redirectCode: 302,
180
+ responseType: 'text/plain',
181
+ responseBody: '',
170
182
  __disableConfirm: true
171
183
  },
172
184
  onConfirm,
@@ -3,7 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import TextField from '@mui/material/TextField';
4
4
  import MenuItem from '@mui/material/MenuItem';
5
5
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
6
- import { ROUTING_RULE_TYPES } from '@abtnode/constant';
6
+ import { ROUTING_RULE_TYPES, ROUTING_RESPONSE_TYPES } from '@abtnode/constant';
7
7
  import { BLOCKLET_INTERFACE_TYPE_WEB } from '@blocklet/constant';
8
8
  import { findWebInterface, getDisplayName } from '@blocklet/meta/lib/util';
9
9
  import { useBlockletContext } from '../../../contexts/blocklet';
@@ -194,18 +194,66 @@ export default function ConfigRoutingRule({
194
194
  marginBottom: 32
195
195
  },
196
196
  onChange: e => {
197
+ const value = e.target.value.trim();
197
198
  setParams({
198
199
  ...params,
199
200
  url: e.target.value,
200
- __disableConfirm: !e.target.value.trim()
201
+ __disableConfirm: !value
201
202
  });
202
- if (!e.target.value.trim()) {
203
+ if (!value) {
203
204
  setError(t('router.validation.rewriteUrlRequired'));
204
205
  } else {
205
206
  setError('');
206
207
  }
207
208
  }
208
- }, "url")]
209
+ }, "url"), params.type === ROUTING_RULE_TYPES.DIRECT_RESPONSE && [/*#__PURE__*/_jsx(TextField, {
210
+ select: true,
211
+ label: t('router.rule.add.responseType'),
212
+ autoComplete: "off",
213
+ variant: "outlined",
214
+ name: "responseType",
215
+ fullWidth: true,
216
+ value: params.responseType,
217
+ onChange: e => setParams({
218
+ ...params,
219
+ responseType: e.target.value
220
+ }),
221
+ style: {
222
+ marginBottom: 32
223
+ },
224
+ SelectProps: {},
225
+ children: ROUTING_RESPONSE_TYPES.map(x => /*#__PURE__*/_jsx(MenuItem, {
226
+ value: x.value,
227
+ children: x.text
228
+ }, x.value))
229
+ }, "responseType"), /*#__PURE__*/_jsx(TextField, {
230
+ label: t('router.rule.add.responseBody'),
231
+ autoComplete: "off",
232
+ variant: "outlined",
233
+ name: "responseBody",
234
+ "data-cy": "response-body-input",
235
+ fullWidth: true,
236
+ multiline: true,
237
+ minRows: 3,
238
+ value: params.responseBody,
239
+ helperText: t('router.rule.add.responseBodyTip'),
240
+ style: {
241
+ marginBottom: 32
242
+ },
243
+ onChange: e => {
244
+ const value = e.target.value.trim();
245
+ setParams({
246
+ ...params,
247
+ responseBody: e.target.value,
248
+ __disableConfirm: !value
249
+ });
250
+ if (!value) {
251
+ setError(t('router.rule.add.responseBodyRequired'));
252
+ } else {
253
+ setError('');
254
+ }
255
+ }
256
+ }, "response-body")]]
209
257
  });
210
258
  }
211
259
  ConfigRoutingRule.propTypes = {
@@ -225,6 +273,9 @@ ConfigRoutingRule.defaultProps = {
225
273
  }, {
226
274
  name: 'Rewrite - Route traffic without redirect',
227
275
  value: ROUTING_RULE_TYPES.GENERAL_REWRITE
276
+ }, {
277
+ name: 'Response - Response with provided content',
278
+ value: ROUTING_RULE_TYPES.DIRECT_RESPONSE
228
279
  }, {
229
280
  name: 'Component - Pass traffic to blocklet component',
230
281
  value: ROUTING_RULE_TYPES.COMPONENT
@@ -70,6 +70,13 @@ export default function UpdateRule({
70
70
  if (params.type === ROUTING_RULE_TYPES.GENERAL_REWRITE) {
71
71
  rule.to.url = urlPathFriendly(params.url);
72
72
  }
73
+ if (params.type === ROUTING_RULE_TYPES.DIRECT_RESPONSE) {
74
+ rule.to.response = {
75
+ status: 200,
76
+ contentType: params.responseType,
77
+ body: params.responseBody
78
+ };
79
+ }
73
80
  await api.updateRoutingRule({
74
81
  input: {
75
82
  id: siteId,
@@ -127,6 +134,9 @@ export default function UpdateRule({
127
134
  if (params.type === ROUTING_RULE_TYPES.GENERAL_REWRITE && !params.url) {
128
135
  disable = true;
129
136
  }
137
+ if (params.type === ROUTING_RULE_TYPES.DIRECT_RESPONSE && (!params.responseType || !params.responseBody)) {
138
+ disable = true;
139
+ }
130
140
  if (!e.target.value.trim()) {
131
141
  disable = true;
132
142
  setError(t('router.validation.pathPrefixRequired'));
@@ -162,6 +172,8 @@ export default function UpdateRule({
162
172
  componentId: to.componentId || '',
163
173
  pageGroup: to.pageGroup || '',
164
174
  url: to.url || '',
175
+ responseType: to.response?.contentType || '',
176
+ responseBody: (to.response?.body || '').replace(/\\"/g, '"'),
165
177
  __disableConfirm: false
166
178
  },
167
179
  onConfirm,
@@ -9,8 +9,9 @@ import IconButton from '@mui/material/IconButton';
9
9
  import Avatar from '@mui/material/Avatar';
10
10
  import LockIcon from '@arcblock/icons/lib/LockIcon';
11
11
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
12
- import { ROUTING_RULE_TYPES } from '@abtnode/constant';
12
+ import { ROUTING_RESPONSE_TYPES, ROUTING_RULE_TYPES } from '@abtnode/constant';
13
13
  import { getDisplayName } from '@blocklet/meta/lib/util';
14
+ import { TextSnippetOutlined } from '@mui/icons-material';
14
15
  import { getBlockletUrlParams, getAccessUrl, BlockletAdminRoles } from '../../util';
15
16
  import { useBlockletContext } from '../../contexts/blocklet';
16
17
  import { useNodeContext } from '../../contexts/node';
@@ -70,6 +71,13 @@ function RuleList({
70
71
  avatar = rule.to.redirectCode;
71
72
  } else if (rule.to.type === ROUTING_RULE_TYPES.GENERAL_REWRITE) {
72
73
  avatar = 'R';
74
+ } else if (rule.to.type === ROUTING_RULE_TYPES.DIRECT_RESPONSE) {
75
+ avatar = /*#__PURE__*/_jsx(TextSnippetOutlined, {
76
+ sx: {
77
+ color: 'text.secondary',
78
+ fontSize: '45px'
79
+ }
80
+ });
73
81
  } else if (rule.to.type === ROUTING_RULE_TYPES.COMPONENT) {
74
82
  component = blocklet.children.find(x => x.meta.did === rule.to.componentId);
75
83
  avatar = 'C';
@@ -127,7 +135,7 @@ function RuleList({
127
135
  color: '#222',
128
136
  fontSize: 16
129
137
  },
130
- children: [rule.to.type === ROUTING_RULE_TYPES.NONE && t('common.page404'), rule.to.type === ROUTING_RULE_TYPES.REDIRECT && t('common.redirect'), rule.to.type === ROUTING_RULE_TYPES.GENERAL_REWRITE && t('common.rewrite'), rule.to.type === ROUTING_RULE_TYPES.COMPONENT && getDisplayName(component, true)]
138
+ children: [rule.to.type === ROUTING_RULE_TYPES.NONE && t('common.page404'), rule.to.type === ROUTING_RULE_TYPES.REDIRECT && t('common.redirect'), rule.to.type === ROUTING_RULE_TYPES.GENERAL_REWRITE && t('common.rewrite'), rule.to.type === ROUTING_RULE_TYPES.DIRECT_RESPONSE && ROUTING_RESPONSE_TYPES.find(x => x.value === rule.to.response.contentType)?.text, rule.to.type === ROUTING_RULE_TYPES.COMPONENT && getDisplayName(component, true)]
131
139
  }), /*#__PURE__*/_jsxs(Box, {
132
140
  display: "flex",
133
141
  alignItems: "center",
package/es/locales/ar.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "إذا قمت بتعيين البادئة على '/بادئة-الخاصة-بي'، فسيتم توجيه جميع الطلبات التي تبدأ بتلك البادئة إلى البلوكليت المكون",
1040
1040
  blocklet: 'أي Blocklet سيتولى معالجة تلك الطلبات؟',
1041
1041
  port: 'ما هو المنفذ الذي سيتعامل مع طلبات البلوكليت؟',
1042
- portTip: 'هذا يعتمد على المنفذ الرئيسي للبلوكليت بشكل افتراضي ، إذا كان بلوكليت الخاص بك يستمع على منافذ متعددة ، فيمكنك تخصيص ذلك.'
1042
+ portTip: 'هذا يعتمد على المنفذ الرئيسي للبلوكليت بشكل افتراضي ، إذا كان بلوكليت الخاص بك يستمع على منافذ متعددة ، فيمكنك تخصيص ذلك.',
1043
+ responseType: 'نوع الاستجابة',
1044
+ responseBody: 'محتوى الرد',
1045
+ responseBodyTip: 'الصق محتوى الاستجابة الخاص بك هنا ، يجب ألا يتجاوز 4096 حرفًا.',
1046
+ responseBodyRequired: 'لا يمكن أن يكون محتوى الرد فارغاً'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'حذف تعيين عنوان URL',
package/es/locales/de.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "Wenn Sie das Präfix auf '/mein-präfix' setzen, werden alle Anfragen, die mit diesem Präfix beginnen, zum konfigurierten Blocklet weitergeleitet",
1040
1040
  blocklet: 'Welcher Blocklet wird diese Anfragen bearbeiten?',
1041
1041
  port: 'Welcher Port des Blocklet wird Anfragen bearbeiten?',
1042
- portTip: 'Dies ist standardmäßig der Hauptport von Blocklet. Wenn Blocklet auf mehreren Ports lauscht, können Sie dies anpassen.'
1042
+ portTip: 'Dies ist standardmäßig der Hauptport von Blocklet. Wenn Blocklet auf mehreren Ports lauscht, können Sie dies anpassen.',
1043
+ responseType: 'Antworttyp',
1044
+ responseBody: 'Antwortinhalt',
1045
+ responseBodyTip: 'Fügen Sie hier Ihren Antwortinhalt ein, der 4096 Zeichen nicht überschreiten sollte.',
1046
+ responseBodyRequired: 'Der Antwortinhalt darf nicht leer sein'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'URL-Mapping löschen',
package/es/locales/en.js CHANGED
@@ -1032,7 +1032,11 @@ export default {
1032
1032
  pathPrefixTip: "If you set prefix to '/my-prefix', then all requests that begins with that prefix will be routed to the configured blocklet",
1033
1033
  blocklet: 'Which Blocklet will be handling those requests?',
1034
1034
  port: 'Which port of the blocklet will be handling requests?',
1035
- portTip: 'This defaults to the main port of blocklet, if your blocklet listens on multiple ports, you can customize this'
1035
+ portTip: 'This defaults to the main port of blocklet, if your blocklet listens on multiple ports, you can customize this',
1036
+ responseType: 'Response Type',
1037
+ responseBody: 'Response Content',
1038
+ responseBodyTip: 'Paste your response content here, should not exceed 4096 characters',
1039
+ responseBodyRequired: 'Response content can not be empty'
1036
1040
  },
1037
1041
  delete: {
1038
1042
  title: 'Delete URL Mapping',
package/es/locales/es.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "Si configuras el prefijo como '/my-prefix', todas las solicitudes que comiencen con ese prefijo se dirigirán al bloque configurado",
1040
1040
  blocklet: '¿Qué Blocklet se encargará de manejar esas solicitudes?',
1041
1041
  port: '¿Qué puerto del blocklet manejará las solicitudes?',
1042
- portTip: 'Esto se establece por defecto en el puerto principal de blocklet, si tu blocklet escucha en varios puertos, puedes personalizar esto'
1042
+ portTip: 'Esto se establece por defecto en el puerto principal de blocklet, si tu blocklet escucha en varios puertos, puedes personalizar esto',
1043
+ responseType: 'Tipo de respuesta',
1044
+ responseBody: 'Contenido de respuesta',
1045
+ responseBodyTip: 'Pega tu contenido de respuesta aquí, no debe exceder los 4096 caracteres',
1046
+ responseBodyRequired: 'El contenido de respuesta no puede estar vacío'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'Eliminar asignación de URL',
package/es/locales/fr.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "Si vous définissez le préfixe sur '/mon-préfixe', alors toutes les demandes commençant par ce préfixe seront routées vers le blocklet configuré",
1040
1040
  blocklet: 'Quel Blocklet gérera ces demandes ?',
1041
1041
  port: 'Quel port du blocklet gérera les requêtes ?',
1042
- portTip: 'Par défaut, cela correspond au port principal du blocklet. Si votre blocklet écoute sur plusieurs ports, vous pouvez personnaliser cela.'
1042
+ portTip: 'Par défaut, cela correspond au port principal du blocklet. Si votre blocklet écoute sur plusieurs ports, vous pouvez personnaliser cela.',
1043
+ responseType: 'Type de réponse',
1044
+ responseBody: 'Contenu de la réponse',
1045
+ responseBodyTip: 'Veuillez coller votre contenu de réponse ici, ne doit pas dépasser 4096 caractères.',
1046
+ responseBodyRequired: 'Le contenu de la réponse ne peut pas être vide'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: "Supprimer la correspondance d'URL",
package/es/locales/hi.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "यदि आप प्रेफिक्स को '/मेरा प्रेफिक्स' सेट करते हैं, तो इस प्रेफिक्स के साथ शुरू होने वाले सभी अनुरोध विन्यासित ब्लॉकलेट को मार्ग-निर्दिष्ट में भेजे जाएंगे",
1040
1040
  blocklet: 'इन अनुरोधों का हैंडलिंग कौन सा ब्लॉकलेट करेगा?',
1041
1041
  port: 'ब्लॉकलेट का कौन सा पोर्ट अनुरोधों को संभालेगा?',
1042
- portTip: 'यह डिफ़ॉल्ट रूप से ब्लॉकलेट के मुख्य पोर्ट के लिए होता है, यदि आपका ब्लॉकलेट कई पोर्टों पर सुनता है, तो आप इसे अनुकूलित कर सकते हैं।'
1042
+ portTip: 'यह डिफ़ॉल्ट रूप से ब्लॉकलेट के मुख्य पोर्ट के लिए होता है, यदि आपका ब्लॉकलेट कई पोर्टों पर सुनता है, तो आप इसे अनुकूलित कर सकते हैं।',
1043
+ responseType: 'प्रतिक्रिया प्रकार',
1044
+ responseBody: 'प्रतिक्रिया सामग्री',
1045
+ responseBodyTip: 'अपनी प्रतिक्रिया सामग्री यहां पेस्ट करें, 4096 वर्णों से अधिक नहीं होनी चाहिए।',
1046
+ responseBodyRequired: 'प्रतिक्रिया सामग्री खाली नहीं हो सकती'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'URL मैपिंग हटाएं',
Binary file
package/es/locales/id.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "Jika Anda mengatur awalan menjadi '/awalan-saya', maka semua permintaan yang dimulai dengan awalan tersebut akan diarahkan ke blok yang dikonfigurasi",
1040
1040
  blocklet: 'Blocklet mana yang akan menangani permintaan tersebut?',
1041
1041
  port: 'Port mana dari blocklet yang akan menangani permintaan?',
1042
- portTip: 'Ini menjadi port utama blocklet, jika blocklet Anda mendengarkan di beberapa port, Anda dapat menyesuaikannya'
1042
+ portTip: 'Ini menjadi port utama blocklet, jika blocklet Anda mendengarkan di beberapa port, Anda dapat menyesuaikannya',
1043
+ responseType: 'Tipe Respons',
1044
+ responseBody: 'Konten Tanggapan',
1045
+ responseBodyTip: 'Tempelkan konten respon Anda di sini, tidak boleh melebihi 4096 karakter',
1046
+ responseBodyRequired: 'Konten respons tidak boleh kosong'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'Hapus Pemetaan URL',
package/es/locales/ja.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "'/my-prefix' をプレフィックスに設定すると、そのプレフィックスで始まるすべてのリクエストが設定されたブロックにルーティングされます",
1040
1040
  blocklet: 'どのBlockletがそれらのリクエストを処理しますか?',
1041
1041
  port: 'ブロックレットのどのポートがリクエストを処理しますか?',
1042
- portTip: 'これは、Blockletのメインポートにデフォルトで設定されます。Blockletが複数のポートでリッスンする場合は、これをカスタマイズできます'
1042
+ portTip: 'これは、Blockletのメインポートにデフォルトで設定されます。Blockletが複数のポートでリッスンする場合は、これをカスタマイズできます',
1043
+ responseType: 'レスポンスタイプ',
1044
+ responseBody: '応答内容',
1045
+ responseBodyTip: '以下に回答内容を貼り付けてください。4096文字を超えてはいけません。',
1046
+ responseBodyRequired: 'レスポンスの内容は空にできません'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'URLマッピングを削除する',
package/es/locales/ko.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "'/my-prefix'로 접두사를 설정하면 해당 접두사로 시작하는 모든 요청이 구성된 블록에 라우팅됩니다",
1040
1040
  blocklet: '어떤 블록이 그 요청을 처리하게 될까요?',
1041
1041
  port: '블록렛의 어떤 포트가 요청을 처리합니까?',
1042
- portTip: '이것은 블록릿의 기본 포트로 설정됩니다. 블록릿이 여러 포트로 수신 대기하는 경우, 이를 사용자 정의할 수 있습니다'
1042
+ portTip: '이것은 블록릿의 기본 포트로 설정됩니다. 블록릿이 여러 포트로 수신 대기하는 경우, 이를 사용자 정의할 수 있습니다',
1043
+ responseType: '응답 유형',
1044
+ responseBody: '응답 내용',
1045
+ responseBodyTip: '답변 내용을 여기에 붙여넣으세요. 4096자를 초과해서는 안 됩니다.',
1046
+ responseBodyRequired: '응답 내용은 비어 있을 수 없습니다'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'URL 매핑 삭제하기',
package/es/locales/pt.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "Se você definir o prefixo como '/meu-prefixo', todas as solicitações que começarem com esse prefixo serão direcionadas para o bloco configurado",
1040
1040
  blocklet: 'Qual Blocklet será responsável por essas solicitações?',
1041
1041
  port: 'Qual porta do blocklet será responsável por lidar com as solicitações?',
1042
- portTip: 'Isso se torna o porto principal do blocklet, se o seu blocklet estiver ouvindo em vários portos, você pode personalizar isso'
1042
+ portTip: 'Isso se torna o porto principal do blocklet, se o seu blocklet estiver ouvindo em vários portos, você pode personalizar isso',
1043
+ responseType: 'Tipo de resposta',
1044
+ responseBody: 'Conteúdo da resposta',
1045
+ responseBodyTip: 'Cole aqui o conteúdo da sua resposta, não deve exceder 4096 caracteres',
1046
+ responseBodyRequired: 'O conteúdo da resposta não pode estar vazio'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'Excluir mapeamento de URL',
package/es/locales/ru.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "Если вы установите префикс на '/мой-префикс', то все запросы, начинающиеся с этого префикса, будут маршрутизироваться к настроенному блоклету",
1040
1040
  blocklet: 'Какой блоклет будет обрабатывать эти запросы?',
1041
1041
  port: 'Какой порт блоклета будет обрабатывать запросы?',
1042
- portTip: 'По умолчанию используется основной порт блоклета. Если блоклет слушает несколько портов, вы можете настроить это.'
1042
+ portTip: 'По умолчанию используется основной порт блоклета. Если блоклет слушает несколько портов, вы можете настроить это.',
1043
+ responseType: 'Тип ответа',
1044
+ responseBody: 'Содержание ответа',
1045
+ responseBodyTip: 'Вставьте сюда содержимое вашего ответа, не превышающее 4096 символов.',
1046
+ responseBodyRequired: 'Содержимое ответа не может быть пустым'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'Удалить отображение URL',
package/es/locales/th.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "หากคุณตั้งค่าคำนำหน้าเป็น '/my-prefix' จะทำให้คำขอที่ตั้งต้นด้วยคำนำหน้าเหล่านั้นจะถูกส่งมายังบล็อกเลตที่กำหนด",
1040
1040
  blocklet: 'Blocklet ไหนจะดูแลการร้องขอเหล่านั้น?',
1041
1041
  port: 'พอร์ตของบล็อกเล็ตใดที่จะรับผิดชอบการร้องขอ?',
1042
- portTip: 'นี่คือค่าพื้นฐานของพอร์ตหลักของ blocklet ถ้า blocklet ของคุณฟังถึงพอร์ตหลายๆพอร์ต คุณสามารถปรับแต่งได้'
1042
+ portTip: 'นี่คือค่าพื้นฐานของพอร์ตหลักของ blocklet ถ้า blocklet ของคุณฟังถึงพอร์ตหลายๆพอร์ต คุณสามารถปรับแต่งได้',
1043
+ responseType: 'ประเภทการตอบกลับ',
1044
+ responseBody: 'เนื้อหาการตอบกลับ',
1045
+ responseBodyTip: 'วางเนื้อหาการตอบสนองของคุณที่นี่ ต้องไม่เกิน 4096 อักขระ',
1046
+ responseBodyRequired: 'เนื้อหาการตอบกลับต้องไม่เป็นค่าว่าง'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'ลบการแมปลิงก์ URL',
package/es/locales/vi.js CHANGED
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "Nếu bạn đặt tiền tố là '/tiền-tố-của-tôi', thì tất cả các yêu cầu bắt đầu bằng tiền tố đó sẽ được định tuyến đến khối đã được cấu hình",
1040
1040
  blocklet: 'Blocklet nào sẽ xử lý những yêu cầu đó?',
1041
1041
  port: 'Cổng nào của blocklet sẽ xử lý các yêu cầu?',
1042
- portTip: 'Mặc định là cổng chính của blocklet, nếu blocklet của bạn lắng nghe trên nhiều cổng, bạn có thể tùy chỉnh điều này'
1042
+ portTip: 'Mặc định là cổng chính của blocklet, nếu blocklet của bạn lắng nghe trên nhiều cổng, bạn có thể tùy chỉnh điều này',
1043
+ responseType: 'Loại phản hồi',
1044
+ responseBody: 'Nội dung phản hồi',
1045
+ responseBodyTip: 'Dán nội dung đáp ứng của bạn vào đây, không vượt quá 4096 ký tự',
1046
+ responseBodyRequired: 'Nội dung phản hồi không thể trống'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: 'Xóa Liên kết URL',
@@ -1039,7 +1039,11 @@ export default {
1039
1039
  pathPrefixTip: "如果您將前綴設置為'/my-prefix',則所有以該前綴開頭的請求將被路由到配置的區塊",
1040
1040
  blocklet: '哪一個Blocklet將處理這些請求?',
1041
1041
  port: '區塊上的哪個埠將處理請求?',
1042
- portTip: '這預設為 blocklet 的主要埠口,如果您的 blocklet 監聽多個埠口,您可以自訂這個'
1042
+ portTip: '這預設為 blocklet 的主要埠口,如果您的 blocklet 監聽多個埠口,您可以自訂這個',
1043
+ responseType: '回應類型',
1044
+ responseBody: '回應內容',
1045
+ responseBodyTip: '請將您的回覆內容貼上此處,不得超過4096個字元',
1046
+ responseBodyRequired: '回應內容不能為空'
1043
1047
  },
1044
1048
  delete: {
1045
1049
  title: '刪除URL映射',
package/es/locales/zh.js CHANGED
@@ -1043,7 +1043,11 @@ export default {
1043
1043
  pathPrefixTip: "如果你填写了 '/prefix',那么所有以其为前缀的请求都会被转发到配置的基石程序",
1044
1044
  blocklet: '把请求代理到哪个服务?',
1045
1045
  port: '把请求代理到哪个端口?',
1046
- portTip: '这里的默认值是应用默认监听的端口,如果你的应用会启用多个端口,你可以根据需要自定义'
1046
+ portTip: '这里的默认值是应用默认监听的端口,如果你的应用会启用多个端口,你可以根据需要自定义',
1047
+ responseType: '回应类型',
1048
+ responseBody: '响应内容',
1049
+ responseBodyTip: '请将您的回复内容粘贴在这里,不要超过4096个字符',
1050
+ responseBodyRequired: '响应内容不能为空'
1047
1051
  },
1048
1052
  delete: {
1049
1053
  title: '删除规则',
@@ -1,28 +1,43 @@
1
1
  import dayjs from '@abtnode/util/lib/dayjs';
2
2
  import { useLocaleContext } from '@arcblock/ux/lib/Locale/context';
3
+ import AccessTimeIcon from '@mui/icons-material/AccessTime';
4
+ import Box from '@mui/material/Box';
3
5
  import Chip from '@mui/material/Chip';
4
6
  import CircularProgress from '@mui/material/CircularProgress';
5
7
  import Popover from '@mui/material/Popover';
6
- import useMediaQuery from '@mui/material/useMediaQuery';
7
8
  import prettyMs from 'pretty-ms-i18n';
8
9
  import PropTypes from 'prop-types';
9
10
  import { useRef } from 'react';
10
11
  import useAsyncRetry from 'react-use/lib/useAsyncRetry';
11
12
  import useSetState from 'react-use/lib/useSetState';
12
- import { useNodeContext } from '../contexts/node';
13
- import { formatPrettyMsLocale, getAssetExpiration, getSubscriptionUrlV2 } from '../util';
14
- import ChipLabel from './chip-label';
13
+ import useMediaQuery from '@mui/material/useMediaQuery';
14
+ import { formatPrettyMsLocale, getAsset, getAssetExpiration, getSubscriptionURL } from './util';
15
15
  import { jsx as _jsx } from "react/jsx-runtime";
16
16
  import { jsxs as _jsxs } from "react/jsx-runtime";
17
17
  import { Fragment as _Fragment } from "react/jsx-runtime";
18
18
  const ALERT_THRESHOLD_MS = 30 * 24 * 60 * 60 * 1000;
19
19
  const DEFAULT_LAUNCHER_URL = 'https://launcher.arcblock.io/'; // 兼容: 旧版本的 blocklet.controller 没有 launcherUrl 字段
20
20
 
21
- function SubscriptionServer({
21
+ // eslint-disable-next-line react/prop-types
22
+ function ChipLabel({
23
+ children
24
+ }) {
25
+ return /*#__PURE__*/_jsxs(Box, {
26
+ sx: {
27
+ display: 'flex',
28
+ alignItems: 'center',
29
+ gap: 1
30
+ },
31
+ children: [/*#__PURE__*/_jsx(AccessTimeIcon, {
32
+ fontSize: "small"
33
+ }), children]
34
+ });
35
+ }
36
+ function Subscription({
22
37
  launcherUrl,
23
38
  chainHost,
24
39
  nftId,
25
- launcherSessionId,
40
+ retention,
26
41
  ...props
27
42
  }) {
28
43
  const {
@@ -35,22 +50,15 @@ function SubscriptionServer({
35
50
  });
36
51
  const iframeRef = useRef(null);
37
52
  const isMobile = useMediaQuery(x => x.breakpoints.down('md'));
38
- const node = useNodeContext();
39
53
  const {
40
54
  sx = {},
41
55
  ...rest
42
56
  } = props;
43
57
  const typoKey = isMobile ? 'mobile' : 'desktop';
44
58
  const asyncState = useAsyncRetry(async () => {
45
- const [asset, subscriptionURL] = await Promise.all([node.api.getLauncherSession({
46
- input: {
47
- launcherSessionId,
48
- launcherUrl
49
- }
50
- }), getSubscriptionUrlV2({
59
+ const [asset, subscriptionURL] = await Promise.all([getAsset(chainHost, nftId), getSubscriptionURL({
51
60
  launcherUrl: launcherUrl || DEFAULT_LAUNCHER_URL,
52
- nftDid: nftId,
53
- launcherSessionId,
61
+ nftId,
54
62
  locale
55
63
  })]);
56
64
  return {
@@ -154,18 +162,15 @@ function SubscriptionServer({
154
162
  })]
155
163
  });
156
164
  }
157
- SubscriptionServer.propTypes = {
165
+ Subscription.propTypes = {
158
166
  chainHost: PropTypes.string.isRequired,
159
- nftId: PropTypes.string,
160
- launcherSessionId: PropTypes.string,
167
+ nftId: PropTypes.string.isRequired,
161
168
  sx: PropTypes.object,
162
169
  retention: PropTypes.number,
163
170
  launcherUrl: PropTypes.string.isRequired
164
171
  };
165
- SubscriptionServer.defaultProps = {
172
+ Subscription.defaultProps = {
166
173
  sx: {},
167
- retention: 0,
168
- nftId: '',
169
- launcherSessionId: ''
174
+ retention: 0
170
175
  };
171
- export default SubscriptionServer;
176
+ export default Subscription;
package/es/util/index.js CHANGED
@@ -621,25 +621,11 @@ export const sortDomains = domains => {
621
621
  });
622
622
  };
623
623
  export const formatMountPoint = value => normalizePathPrefix(urlPathFriendly(value));
624
- const getLauncherBaseURL = async launcherUrl => {
625
- if (!launcherUrl) {
626
- return '';
627
- }
628
- let baseUrl = launcherUrl;
629
- try {
630
- const {
631
- data: appMeta
632
- } = await axios.get(joinUrl(launcherUrl, '__blocklet__.js?type=json'), {
633
- timeout: 5000
634
- });
635
- const mountPoint = appMeta.componentMountPoints?.find(item => item.did === 'z8iZkFBbrVQxZHvcWWB3Sa2TrfGmSeFz9MSU7');
636
- const launcherUrlObj = new URL(launcherUrl);
637
- baseUrl = joinUrl(launcherUrlObj.origin, mountPoint?.mountPoint);
638
- } catch (error) {
639
- console.error(error);
640
- }
641
- return baseUrl;
642
- };
624
+ export const getRenewBlockletURL = ({
625
+ launcherUrl = '',
626
+ nftId = '',
627
+ locale = 'en'
628
+ }) => joinUrl(launcherUrl, `/instances/${nftId}/renewal?locale=${locale}&return-url=${encodeURIComponent(window.location.href)}`);
643
629
  export const getSubscriptionURL = async ({
644
630
  launcherUrl = '',
645
631
  nftId = '',
@@ -663,29 +649,6 @@ export const getSubscriptionURL = async ({
663
649
  }
664
650
  return joinUrl(baseUrl, `/${nftId}/subscription?locale=${locale}&return-url=${encodeURIComponent(window.location.href)}`);
665
651
  };
666
- export const getSubscriptionUrlV2 = async ({
667
- launcherUrl = '',
668
- launcherSessionId = '',
669
- nftDid,
670
- locale = 'en'
671
- }) => {
672
- if (!launcherUrl) {
673
- return '';
674
- }
675
- const baseUrl = await getLauncherBaseURL(launcherUrl);
676
- return joinUrl(baseUrl, `/embed/subscription?launcherSessionId=${launcherSessionId}&nftDid=${nftDid}&locale=${locale}`); // nftDid 是兼容字段
677
- };
678
- export const getManageSubscriptionURL = async ({
679
- launcherUrl = '',
680
- launcherSessionId = '',
681
- locale = 'en'
682
- }) => {
683
- if (!launcherUrl) {
684
- return '';
685
- }
686
- const baseUrl = await getLauncherBaseURL(launcherUrl);
687
- return joinUrl(baseUrl, `/embed/manage-subscription?launcherSessionId=${launcherSessionId}&locale=${locale}`);
688
- };
689
652
  export const nanoid = (length = 16) => [...Array(length)].map(() => Math.random().toString(36)[2]).join('');
690
653
  export const getSystemDomains = domains => domains.filter(x => x.isProtected);
691
654
  export const getLogoHash = logo => encodeURIComponent((logo || '').split('/').slice(-1)[0].slice(0, 7));