@blocklet/launcher-util 2.1.58 → 2.1.60

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 (2) hide show
  1. package/lib/util.js +31 -1
  2. package/package.json +2 -2
package/lib/util.js CHANGED
@@ -3,7 +3,7 @@ require('moment/locale/zh-cn');
3
3
  const moment = require('moment');
4
4
  const joinURL = require('url-join');
5
5
  const get = require('lodash.get');
6
- const { TIME_LOCALE } = require('./constant');
6
+ const { TIME_LOCALE, LAUNCH_STATUS } = require('./constant');
7
7
 
8
8
  const formatPeriod = (duration) => {
9
9
  const value = Number(duration.slice(0, duration.length - 1));
@@ -86,6 +86,35 @@ const getBlockletAdminURL = (appURL) => joinURL(appURL, '/.well-known/service/ad
86
86
 
87
87
  const isDateExpired = (expirationDate) => !!expirationDate && new Date(expirationDate).getTime() <= Date.now();
88
88
 
89
+ const getContinueLaunchURL = ({ baseURL, launch }) => {
90
+ const urlObject = new URL(baseURL);
91
+
92
+ if (launch.status < LAUNCH_STATUS.paid) {
93
+ urlObject.pathname = joinURL(urlObject.pathname, '/purchase');
94
+
95
+ urlObject.searchParams.set('sessionId', launch._id);
96
+ urlObject.searchParams.set('blocklet_meta_url', launch.blockletMetaUrl);
97
+
98
+ return urlObject.href;
99
+ }
100
+
101
+ if (launch.status >= LAUNCH_STATUS.paid && launch.status < LAUNCH_STATUS.installed) {
102
+ urlObject.pathname = joinURL(urlObject.pathname, `/launch/${launch.nftDid}`);
103
+
104
+ urlObject.searchParams.set('sessionId', launch._id);
105
+ urlObject.searchParams.set('blocklet_meta_url', launch.blockletMetaUrl);
106
+ urlObject.searchParams.set('launchType', launch.type);
107
+
108
+ if (launch.from) {
109
+ urlObject.searchParams.set('from', launch.from);
110
+ }
111
+
112
+ return urlObject.href;
113
+ }
114
+
115
+ return '';
116
+ };
117
+
89
118
  module.exports = {
90
119
  formatPeriod,
91
120
  prettyDurationUnit,
@@ -98,4 +127,5 @@ module.exports = {
98
127
  getExplorerUrl,
99
128
  getBlockletDisplayName,
100
129
  getBlockletAdminURL,
130
+ getContinueLaunchURL,
101
131
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blocklet/launcher-util",
3
- "version": "2.1.58",
3
+ "version": "2.1.60",
4
4
  "description": "Common constants",
5
5
  "keywords": [
6
6
  "constant"
@@ -46,5 +46,5 @@
46
46
  "devDependencies": {
47
47
  "jest": "^27.5.1"
48
48
  },
49
- "gitHead": "6ca5c3cb3116700025424f95aceb7d85ef3e6814"
49
+ "gitHead": "890f1974f0f1f87d73680658d723c4d9ad0a39f5"
50
50
  }