@blocklet/launcher-workflow 1.5.47 → 1.5.50

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.
@@ -15,6 +15,8 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
15
15
 
16
16
  var _lodash = _interopRequireDefault(require("lodash.get"));
17
17
 
18
+ var _lodash2 = _interopRequireDefault(require("lodash.throttle"));
19
+
18
20
  var _styledComponents = _interopRequireDefault(require("styled-components"));
19
21
 
20
22
  var _Button = _interopRequireDefault(require("@arcblock/ux/lib/Button"));
@@ -81,10 +83,6 @@ function OperationPage(_ref) {
81
83
  const {
82
84
  api
83
85
  } = (0, _request.default)();
84
- const [frameLoading, setFrameLoading] = (0, _react.useState)(true);
85
- (0, _reactUse.useInterval)(async () => {
86
- await getInstanceStatus();
87
- }, launchState.status === STATUS.launching && nftId ? 5000 : null); // TODO: 这样处理容易发出重复的请求
88
86
 
89
87
  const getInstanceStatus = async () => {
90
88
  try {
@@ -95,11 +93,16 @@ function OperationPage(_ref) {
95
93
  } = await api.get("/public/instances/".concat(nftId, "/status"));
96
94
 
97
95
  if (instance.status >= _constant.INSTANCE_STATUS.running) {
96
+ const url = (0, _util.getLaunchBlockletUrl)(instance.serverUrl, blockletMetaUrl, locale);
98
97
  setLaunchState(pre => _objectSpread(_objectSpread({}, pre), {}, {
99
98
  status: STATUS.success,
100
- appUrl: (0, _util.getLaunchBlockletUrl)(instance.serverUrl, blockletMetaUrl, locale)
99
+ appUrl: url
101
100
  }));
102
- return;
101
+ (0, _util.loadURL)(url).finally(() => {
102
+ setTimeout(() => {
103
+ window.location.href = url;
104
+ }, 1000);
105
+ });
103
106
  }
104
107
  } catch (error) {
105
108
  if ((0, _lodash.default)(error, 'response.status') === 404 && launchState.status !== STATUS.launching) {
@@ -117,6 +120,8 @@ function OperationPage(_ref) {
117
120
  }
118
121
  };
119
122
 
123
+ const poll = (0, _lodash2.default)(getInstanceStatus, 5000);
124
+ (0, _reactUse.useInterval)(poll, launchState.status === STATUS.launching && nftId ? 5000 : null);
120
125
  (0, _react.useEffect)(() => {
121
126
  if (!nftId) {
122
127
  return;
@@ -131,41 +136,6 @@ function OperationPage(_ref) {
131
136
  });
132
137
  }, [nftId]); // eslint-disable-line
133
138
 
134
- (0, _react.useEffect)(() => {
135
- let preloadFrame;
136
- let timer;
137
-
138
- if (launchState.appUrl) {
139
- preloadFrame = document.createElement('iframe');
140
- preloadFrame.src = launchState.appUrl;
141
- Object.assign(preloadFrame.style, {
142
- width: 0,
143
- height: 0,
144
- border: 0,
145
- display: 'block',
146
- position: 'absolute',
147
- top: 0
148
- });
149
- preloadFrame.addEventListener('load', () => {
150
- setFrameLoading(false);
151
- clearTimeout(timer);
152
- });
153
- document.body.appendChild(preloadFrame);
154
- timer = setTimeout(() => {
155
- setFrameLoading(false);
156
- }, 5000);
157
- }
158
-
159
- return () => {
160
- if (preloadFrame) {
161
- preloadFrame.parentNode.removeChild(preloadFrame);
162
- }
163
-
164
- if (timer) {
165
- clearTimeout(timer);
166
- }
167
- };
168
- }, [launchState.appUrl]);
169
139
  return /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, launchState.status !== STATUS.success && /*#__PURE__*/_react.default.createElement(_pageHeader.default, {
170
140
  title: t("".concat(type, ".title"))
171
141
  }), /*#__PURE__*/_react.default.createElement(Content, null, launchState.status === STATUS.waiting && /*#__PURE__*/_react.default.createElement("div", {
@@ -182,15 +152,11 @@ function OperationPage(_ref) {
182
152
  className: "message",
183
153
  variant: "success",
184
154
  title: t('launch.launched'),
185
- subTitle: blockletMetaUrl ? t('launch.launchBlockletTip') : '',
186
- footer: /*#__PURE__*/_react.default.createElement(_Button.default, {
187
- color: "primary",
188
- variant: "contained",
189
- rounded: true,
190
- loading: frameLoading,
155
+ footer: /*#__PURE__*/_react.default.createElement(_react.default.Fragment, null, /*#__PURE__*/_react.default.createElement("a", {
156
+ className: "link",
191
157
  href: launchState.appUrl,
192
- className: "button"
193
- }, blockletMetaUrl ? t('launch.launchApp') : t('launch.accessServer'))
158
+ target: "_self"
159
+ }, t('common.redirecting')), "...")
194
160
  }), [STATUS.error, STATUS.launchFailedError].includes(launchState.status) && /*#__PURE__*/_react.default.createElement(_launchResultMessage.default, {
195
161
  variant: "error",
196
162
  title: t("".concat(type, ".error.launchFailed")),
@@ -221,7 +187,7 @@ function OperationPage(_ref) {
221
187
  const Content = _styledComponents.default.div.withConfig({
222
188
  displayName: "instance-operation__Content",
223
189
  componentId: "sc-1fcaixs-0"
224
- })(["margin:auto;height:100%;.status{color:", ";display:flex;flex-direction:column;align-items:center;.status-spinner{color:inherit !important;}.status-text{display:inline-block;padding:0 20px;max-width:420px;margin-top:24px;text-align:center;}}.button{min-width:150px;margin-bottom:100px;}.center{display:flex;align-items:center;justify-content:center;width:100%;height:100%;}"], props => props.theme.palette.primary.main);
190
+ })(["margin:auto;height:100%;.link{color:#4f6af6;}.link:hover{text-decoration:underline !important;}.status{color:", ";display:flex;flex-direction:column;align-items:center;.status-spinner{color:inherit !important;}.status-text{display:inline-block;padding:0 20px;max-width:420px;margin-top:24px;text-align:center;}}.button{min-width:150px;margin-bottom:100px;}.center{display:flex;align-items:center;justify-content:center;width:100%;height:100%;}"], props => props.theme.palette.primary.main);
225
191
 
226
192
  OperationPage.propTypes = {
227
193
  type: _propTypes.default.oneOf(['launch', 'start']),
package/lib/locales/en.js CHANGED
@@ -12,7 +12,8 @@ module.exports = {
12
12
  launch: 'Launch',
13
13
  next: 'Next',
14
14
  purchase: 'Purchase',
15
- redeem: 'Redeem'
15
+ redeem: 'Redeem',
16
+ redirecting: 'Redirecting'
16
17
  },
17
18
  plan: {
18
19
  title: 'Select Blocklet Server Type',
@@ -41,7 +42,6 @@ module.exports = {
41
42
  launching: 'Your Blocklet Server is being baked, please be patient, it usually takes about 5 minutes',
42
43
  launched: 'Your Blocklet Server is up and running',
43
44
  launchSuccess: 'Blocklet Server is successfully launched',
44
- launchBlockletTip: 'Click the button below to launch the application',
45
45
  loadStatusFailed: 'Failed to load Blocklet Server status',
46
46
  waitingForLaunching: 'Your Blocklet Server launch request is being processed, please be patient, it usually takes about 5 minutes',
47
47
  accessServer: 'Access Blocklet Server',
package/lib/locales/zh.js CHANGED
@@ -12,7 +12,8 @@ module.exports = {
12
12
  launch: '启动',
13
13
  next: '下一步',
14
14
  redeem: '兑换',
15
- purchase: '购买'
15
+ purchase: '购买',
16
+ redirecting: '跳转中'
16
17
  },
17
18
  plan: {
18
19
  title: '创建节点',
@@ -41,7 +42,6 @@ module.exports = {
41
42
  launching: '节点正在启动中, 大约需要 5 分钟',
42
43
  launched: '节点已启动',
43
44
  launchSuccess: '创建节点成功',
44
- launchBlockletTip: '点击下面的按钮启动应用',
45
45
  loadStatusFailed: '加载实例状态失败',
46
46
  waitingForLaunching: '节点正在启动中,大约需要 5 分钟',
47
47
  accessServer: '访问节点',
package/lib/util.js CHANGED
@@ -4,7 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.getBlockletMetaUrl = getBlockletMetaUrl;
7
- exports.getLaunchBlockletUrl = void 0;
7
+ exports.loadURL = exports.getLaunchBlockletUrl = void 0;
8
8
 
9
9
  var _urlJoin = _interopRequireDefault(require("url-join"));
10
10
 
@@ -28,4 +28,31 @@ const getLaunchBlockletUrl = (serverUrl, blockletMetaUrl, locale) => {
28
28
  return result;
29
29
  };
30
30
 
31
- exports.getLaunchBlockletUrl = getLaunchBlockletUrl;
31
+ exports.getLaunchBlockletUrl = getLaunchBlockletUrl;
32
+
33
+ const loadURL = url => new Promise(resolve => {
34
+ let timer;
35
+ const iframe = document.createElement('iframe');
36
+ iframe.src = url;
37
+ Object.assign(iframe.style, {
38
+ width: 0,
39
+ height: 0,
40
+ border: 0,
41
+ display: 'block',
42
+ position: 'absolute',
43
+ top: 0
44
+ });
45
+
46
+ const done = () => {
47
+ clearTimeout(timer);
48
+ iframe.parentNode.removeChild(iframe);
49
+ resolve();
50
+ };
51
+
52
+ document.onload = done;
53
+ document.onerror = done;
54
+ document.body.appendChild(iframe);
55
+ timer = setTimeout(done, 5000);
56
+ });
57
+
58
+ exports.loadURL = loadURL;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-workflow",
3
- "version": "1.5.47",
3
+ "version": "1.5.50",
4
4
  "description": "Purchase components for Launcher UI",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -40,11 +40,11 @@
40
40
  "@arcblock/did-connect": "^1.16.40",
41
41
  "@arcblock/icons": "^1.16.40",
42
42
  "@arcblock/ux": "^1.16.40",
43
- "@blocklet/launcher-layout": "1.5.47",
43
+ "@blocklet/launcher-layout": "1.5.50",
44
44
  "@material-ui/core": "^4.12.3",
45
45
  "@material-ui/icons": "^4.11.2",
46
46
  "@material-ui/lab": "^4.0.0-alpha.60",
47
- "@ocap/util": "^1.14.19",
47
+ "@ocap/util": "^1.14.21",
48
48
  "@stripe/react-stripe-js": "^1.7.0",
49
49
  "@stripe/stripe-js": "^1.22.0",
50
50
  "@styled-icons/remix-fill": "^10.18.0",
@@ -66,5 +66,5 @@
66
66
  "babel-plugin-inline-react-svg": "^2.0.1",
67
67
  "babel-plugin-styled-components": "^1.10.7"
68
68
  },
69
- "gitHead": "2c78c6f17abbea9630fbdd8abbcc810933a405d2"
69
+ "gitHead": "ff686eb0309e6923778cf205337ae774cbc793c2"
70
70
  }