@blocklet/constant 1.16.8 → 1.16.9

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 (3) hide show
  1. package/LICENSE +13 -0
  2. package/index.js +166 -234
  3. package/package.json +18 -7
package/LICENSE ADDED
@@ -0,0 +1,13 @@
1
+ Copyright 2018-2020 ArcBlock
2
+
3
+ Licensed under the Apache License, Version 2.0 (the "License");
4
+ you may not use this file except in compliance with the License.
5
+ You may obtain a copy of the License at
6
+
7
+ http://www.apache.org/licenses/LICENSE-2.0
8
+
9
+ Unless required by applicable law or agreed to in writing, software
10
+ distributed under the License is distributed on an "AS IS" BASIS,
11
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
+ See the License for the specific language governing permissions and
13
+ limitations under the License.
package/index.js CHANGED
@@ -1,277 +1,209 @@
1
+ "use strict";
2
+ /* eslint-disable prettier/prettier */
3
+ Object.defineProperty(exports, "__esModule", { value: true });
4
+ exports.CHAIN_PROP_MAP_REVERSE = exports.CHAIN_PROP_MAP = exports.RESTORE_PROGRESS_STATUS = exports.CHAIN_INFO_CONFIG = exports.BLOCKLET_APP_SPACE_ENDPOINTS = exports.BLOCKLET_CONFIGURABLE_KEY = exports.BLOCKLET_LATEST_REQUIREMENT_ABTNODE = exports.BLOCKLET_LATEST_REQUIREMENT_SERVER = exports.BLOCKLET_LATEST_SPEC_VERSION = exports.BLOCKLET_UPLOADS_DIR = exports.BLOCKLET_DEFAULT_VERSION = exports.BLOCKLET_PREFERENCE_PREFIX = exports.BLOCKLET_PREFERENCE_FILE = exports.BLOCKLET_META_FILE_ALT = exports.BLOCKLET_META_FILE = exports.BLOCKLET_ENTRY_FILE = exports.BLOCKLET_BUNDLE_FILE = exports.BLOCKLET_BUNDLE_FOLDER = exports.BLOCKLET_RELEASE_FILE = exports.BLOCKLET_RELEASE_FOLDER = exports.BLOCKLET_DEFAULT_PATH_REWRITE = exports.BLOCKLET_DEFAULT_PORT_NAME = exports.BLOCKLET_DYNAMIC_PATH_PREFIX = exports.BLOCKLET_INTERFACE_PROTOCOLS = exports.BLOCKLET_INTERFACE_PROTOCOL_UDP = exports.BLOCKLET_INTERFACE_PROTOCOL_TCP = exports.BLOCKLET_INTERFACE_PROTOCOL_HTTP = exports.BLOCKLET_STANDARD_INTERFACES = exports.BLOCKLET_UI_INTERFACES = exports.BLOCKLET_INTERFACE_WELLKNOWN = exports.BLOCKLET_INTERFACE_PUBLIC = exports.BLOCKLET_INTERFACE_TYPES = exports.BLOCKLET_INTERFACE_TYPE_WELLKNOWN = exports.BLOCKLET_INTERFACE_TYPE_SERVICE = exports.BLOCKLET_INTERFACE_TYPE_WEB = exports.BLOCKLET_FACTORY_SHARES = exports.BLOCKLET_MODES = exports.BLOCKLET_ARCHITECTURES = exports.BLOCKLET_PLATFORMS = exports.BlockletEvents = exports.BLOCKLET_GROUPS = exports.BlockletGroup = exports.toBlockletSource = exports.fromBlockletSource = exports.BlockletSource = exports.toBlockletStatus = exports.fromBlockletStatus = exports.BlockletStatus = void 0;
1
5
  const fromEntry = (entries) => (v) => {
2
- const match = Object.entries(entries).find((x) => x[1] === Number(v));
3
- return match ? match[0] : 'unknown';
6
+ const match = Object.entries(entries).find((x) => x[1] === Number(v));
7
+ return match ? match[0] : 'unknown';
4
8
  };
5
-
9
+ // deprecated: toEntry is same as fromEntry
6
10
  const toEntry = (entries) => (v) => Object.keys(entries).find((x) => entries[x] === Number(v));
7
-
8
11
  // Blocklet Status
9
-
10
- const BlockletStatus = Object.freeze({
11
- added: 0,
12
- downloading: 1,
13
- downloaded: 2, // Deprecated
14
- installing: 3,
15
- installed: 4,
16
- starting: 5,
17
- running: 6,
18
- stopping: 7,
19
- stopped: 8,
20
- error: 9,
21
- upgrading: 10,
22
- restarting: 11, // Deprecated
23
- corrupted: 12,
24
- waiting: 13,
25
- deleted: 14,
12
+ exports.BlockletStatus = Object.freeze({
13
+ added: 0,
14
+ downloading: 1,
15
+ downloaded: 2,
16
+ installing: 3,
17
+ installed: 4,
18
+ starting: 5,
19
+ running: 6,
20
+ stopping: 7,
21
+ stopped: 8,
22
+ error: 9,
23
+ upgrading: 10,
24
+ restarting: 11,
25
+ corrupted: 12,
26
+ waiting: 13,
27
+ deleted: 14,
26
28
  });
27
-
28
- const fromBlockletStatus = fromEntry(BlockletStatus);
29
- const toBlockletStatus = toEntry(BlockletStatus);
30
-
29
+ exports.fromBlockletStatus = fromEntry(exports.BlockletStatus);
30
+ exports.toBlockletStatus = toEntry(exports.BlockletStatus); // deprecated
31
31
  // Blocklet Source
32
-
33
- const BlockletSource = Object.freeze({
34
- // Installed from Blocklet Store
35
- registry: 0,
36
-
37
- // Installed from local development source folder
38
- local: 1,
39
-
40
- // Installed from uploading bundle directly
41
- upload: 2,
42
-
43
- // Installed from a url (similar to Blocklet Store)
44
- url: 3,
45
-
46
- // Installed by custom creation
47
- custom: 4,
32
+ exports.BlockletSource = Object.freeze({
33
+ // Installed from Blocklet Store
34
+ registry: 0,
35
+ // Installed from local development source folder
36
+ local: 1,
37
+ // Installed from uploading bundle directly
38
+ upload: 2,
39
+ // Installed from a url (similar to Blocklet Store)
40
+ url: 3,
41
+ // Installed by custom creation
42
+ custom: 4,
48
43
  });
49
-
50
- const fromBlockletSource = fromEntry(BlockletSource);
51
- const toBlockletSource = toEntry(BlockletSource);
52
-
44
+ exports.fromBlockletSource = fromEntry(exports.BlockletSource);
45
+ exports.toBlockletSource = toEntry(exports.BlockletSource); // deprecated
53
46
  // Blocklet Group(Type)
54
-
55
- const BlockletGroup = Object.freeze({
56
- // Only static website
57
- // The website is served by by Blocklet Server at runtime
58
- static: 'static',
59
-
60
- // The runtime instance is provided by its own backend server
61
- dapp: 'dapp',
62
-
63
- starter: false, // deprecated
64
-
65
- // This type is used to combine other component blocklets
66
- // No instance will be spawned at runtime
67
- gateway: 'gateway',
47
+ exports.BlockletGroup = Object.freeze({
48
+ // Only static website
49
+ // The website is served by by Blocklet Server at runtime
50
+ static: 'static',
51
+ // The runtime instance is provided by its own backend server
52
+ dapp: 'dapp',
53
+ starter: false,
54
+ // This type is used to combine other component blocklets
55
+ // No instance will be spawned at runtime
56
+ gateway: 'gateway',
68
57
  });
69
-
70
- const BLOCKLET_GROUPS = ['dapp', 'static', 'gateway'];
71
-
58
+ exports.BLOCKLET_GROUPS = ['dapp', 'static', 'gateway'];
72
59
  // Blocklet Events
73
-
74
- const BlockletEvents = Object.freeze({
75
- // status updated
76
- added: 'blocklet.added',
77
- downloadFailed: 'blocklet.downloadFailed',
78
- installed: 'blocklet.installed',
79
- installFailed: 'blocklet.installFailed',
80
- upgraded: 'blocklet.upgraded',
81
- upgradeFailed: 'blocklet.upgradedFailed',
82
- downgraded: 'blocklet.downgraded',
83
- downgradeFailed: 'blocklet.downgradedFailed',
84
- removed: 'blocklet.removed',
85
- started: 'blocklet.started',
86
- startFailed: 'blocklet.startFailed',
87
- stopped: 'blocklet.stopped',
88
- reloaded: 'blocklet.reloaded', // Deprecated
89
- statusChange: 'blocklet.statusChange',
90
- dataCleaned: 'blocklet.dataCleaned',
91
-
92
- // 备份还原进度
93
- backupProgress: 'blocklet.backupProgress',
94
- restoreProgress: 'blocklet.restoreProgress',
95
-
96
- downloadBundleProgress: 'blocklet.downloadBundleProgress',
97
-
98
- // state updated
99
- updated: 'blocklet.updated',
100
- domainStatus: 'blocklet.domainStatus',
101
- storeChange: 'blocklet.storeChange',
102
- appDidChanged: 'blocklet.appDidChanged',
103
-
104
- // purchase
105
- purchaseChange: 'blocklet.purchaseChange',
106
-
107
- // cert
108
- certError: 'blocklet.certError',
109
- certIssued: 'blocklet.certIssued',
110
-
111
- // did-space
112
- spaceConnected: 'blocklet.spaceConnected',
113
-
114
- // install by nft
115
- nftConsumed: 'blocklet.nftConsumed',
60
+ exports.BlockletEvents = Object.freeze({
61
+ // status updated
62
+ added: 'blocklet.added',
63
+ downloadFailed: 'blocklet.downloadFailed',
64
+ installed: 'blocklet.installed',
65
+ installFailed: 'blocklet.installFailed',
66
+ upgraded: 'blocklet.upgraded',
67
+ upgradeFailed: 'blocklet.upgradedFailed',
68
+ downgraded: 'blocklet.downgraded',
69
+ downgradeFailed: 'blocklet.downgradedFailed',
70
+ removed: 'blocklet.removed',
71
+ started: 'blocklet.started',
72
+ startFailed: 'blocklet.startFailed',
73
+ stopped: 'blocklet.stopped',
74
+ reloaded: 'blocklet.reloaded',
75
+ statusChange: 'blocklet.statusChange',
76
+ dataCleaned: 'blocklet.dataCleaned',
77
+ // 备份还原进度
78
+ backupProgress: 'blocklet.backupProgress',
79
+ restoreProgress: 'blocklet.restoreProgress',
80
+ downloadBundleProgress: 'blocklet.downloadBundleProgress',
81
+ // state updated
82
+ updated: 'blocklet.updated',
83
+ domainStatus: 'blocklet.domainStatus',
84
+ storeChange: 'blocklet.storeChange',
85
+ appDidChanged: 'blocklet.appDidChanged',
86
+ // purchase
87
+ purchaseChange: 'blocklet.purchaseChange',
88
+ // cert
89
+ certError: 'blocklet.certError',
90
+ certIssued: 'blocklet.certIssued',
91
+ // did-space
92
+ spaceConnected: 'blocklet.spaceConnected',
93
+ // install by nft
94
+ nftConsumed: 'blocklet.nftConsumed',
116
95
  });
117
-
96
+ exports.BLOCKLET_PLATFORMS = ['aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', 'win32'];
97
+ exports.BLOCKLET_ARCHITECTURES = [
98
+ 'arm',
99
+ 'arm64',
100
+ 'ia32',
101
+ 'mips',
102
+ 'mipsel',
103
+ 'ppc',
104
+ 'ppc64',
105
+ 's390',
106
+ 's390x',
107
+ 'x32',
108
+ 'x64',
109
+ ];
110
+ exports.BLOCKLET_MODES = Object.freeze({
111
+ PRODUCTION: 'production',
112
+ DEVELOPMENT: 'development',
113
+ });
114
+ exports.BLOCKLET_FACTORY_SHARES = { developer: 0.7, store: 0.3 };
118
115
  // Blocklet Interface
119
-
120
- const BLOCKLET_INTERFACE_TYPE_WEB = 'web';
121
- const BLOCKLET_INTERFACE_TYPE_SERVICE = 'service';
122
-
116
+ exports.BLOCKLET_INTERFACE_TYPE_WEB = 'web';
117
+ exports.BLOCKLET_INTERFACE_TYPE_SERVICE = 'service';
123
118
  // Wellknown interface declares an sub-interface under web interface
124
119
  // The path of the wellknown interface must starts with /.well-known, e.g. /.well-known/acme-challenge)
125
120
  // The wellknown interface can be mounted to every endpoint of the abtnode and all blocklets on the abtnode
126
- const BLOCKLET_INTERFACE_TYPE_WELLKNOWN = 'wellknown';
127
- const BLOCKLET_INTERFACE_TYPES = [
128
- BLOCKLET_INTERFACE_TYPE_WEB,
129
- BLOCKLET_INTERFACE_TYPE_SERVICE,
130
- BLOCKLET_INTERFACE_TYPE_WELLKNOWN,
121
+ exports.BLOCKLET_INTERFACE_TYPE_WELLKNOWN = 'wellknown';
122
+ exports.BLOCKLET_INTERFACE_TYPES = [
123
+ exports.BLOCKLET_INTERFACE_TYPE_WEB,
124
+ exports.BLOCKLET_INTERFACE_TYPE_SERVICE,
125
+ exports.BLOCKLET_INTERFACE_TYPE_WELLKNOWN,
131
126
  ];
132
-
133
- const BLOCKLET_INTERFACE_PUBLIC = 'publicUrl';
134
- const BLOCKLET_INTERFACE_WELLKNOWN = 'wellknownUrl'; // Deprecated
135
- const BLOCKLET_UI_INTERFACES = [BLOCKLET_INTERFACE_PUBLIC];
136
- const BLOCKLET_STANDARD_INTERFACES = [BLOCKLET_INTERFACE_PUBLIC, BLOCKLET_INTERFACE_WELLKNOWN];
137
-
138
- const BLOCKLET_INTERFACE_PROTOCOL_HTTP = 'http';
139
- const BLOCKLET_INTERFACE_PROTOCOL_TCP = 'tcp';
140
- const BLOCKLET_INTERFACE_PROTOCOL_UDP = 'udp';
141
- const BLOCKLET_INTERFACE_PROTOCOLS = [
142
- BLOCKLET_INTERFACE_PROTOCOL_TCP,
143
- BLOCKLET_INTERFACE_PROTOCOL_UDP,
144
- BLOCKLET_INTERFACE_PROTOCOL_HTTP,
127
+ exports.BLOCKLET_INTERFACE_PUBLIC = 'publicUrl';
128
+ exports.BLOCKLET_INTERFACE_WELLKNOWN = 'wellknownUrl'; // Deprecated
129
+ exports.BLOCKLET_UI_INTERFACES = [exports.BLOCKLET_INTERFACE_PUBLIC];
130
+ exports.BLOCKLET_STANDARD_INTERFACES = [exports.BLOCKLET_INTERFACE_PUBLIC, exports.BLOCKLET_INTERFACE_WELLKNOWN];
131
+ exports.BLOCKLET_INTERFACE_PROTOCOL_HTTP = 'http';
132
+ exports.BLOCKLET_INTERFACE_PROTOCOL_TCP = 'tcp';
133
+ exports.BLOCKLET_INTERFACE_PROTOCOL_UDP = 'udp';
134
+ exports.BLOCKLET_INTERFACE_PROTOCOLS = [
135
+ exports.BLOCKLET_INTERFACE_PROTOCOL_TCP,
136
+ exports.BLOCKLET_INTERFACE_PROTOCOL_UDP,
137
+ exports.BLOCKLET_INTERFACE_PROTOCOL_HTTP,
145
138
  ];
146
-
147
- const RESTORE_PROGRESS_STATUS = {
148
- waiting: 0,
149
- start: 10,
150
- importData: 20,
151
- downloading: 30,
152
- importDataSuccess: 40,
153
- installing: 50,
154
- completed: 60,
155
- error: 70,
156
- };
157
-
158
- const CHAIN_PROP_MAP = {
159
- BLOCKLET_APP_CHAIN_HOST: 'CHAIN_HOST',
160
- BLOCKLET_APP_CHAIN_ID: 'CHAIN_ID',
161
- BLOCKLET_APP_CHAIN_TYPE: 'CHAIN_TYPE',
162
- };
163
-
164
- const CHAIN_PROP_MAP_REVERSE = Object.keys(CHAIN_PROP_MAP).reduce((acc, key) => {
165
- acc[CHAIN_PROP_MAP[key]] = key;
166
- return acc;
167
- }, {});
168
-
169
- module.exports = Object.freeze({
170
- BlockletStatus,
171
- fromBlockletStatus,
172
- toBlockletStatus,
173
-
174
- BlockletSource,
175
- fromBlockletSource,
176
- toBlockletSource,
177
-
178
- BlockletGroup,
179
- BLOCKLET_GROUPS,
180
-
181
- BlockletEvents,
182
-
183
- BLOCKLET_PLATFORMS: ['aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', 'win32'],
184
- BLOCKLET_ARCHITECTURES: ['arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', 'x64'],
185
-
186
- BLOCKLET_MODES: Object.freeze({
187
- PRODUCTION: 'production',
188
- DEVELOPMENT: 'development',
189
- }),
190
-
191
- BLOCKLET_FACTORY_SHARES: { developer: 0.7, store: 0.3 },
192
-
193
- // interface
194
- BLOCKLET_INTERFACE_PUBLIC,
195
- BLOCKLET_INTERFACE_WELLKNOWN, // Deprecated
196
- BLOCKLET_UI_INTERFACES,
197
- BLOCKLET_STANDARD_INTERFACES,
198
-
199
- BLOCKLET_INTERFACE_TYPE_WEB,
200
- BLOCKLET_INTERFACE_TYPE_SERVICE,
201
- BLOCKLET_INTERFACE_TYPE_WELLKNOWN,
202
- BLOCKLET_INTERFACE_TYPES,
203
-
204
- BLOCKLET_INTERFACE_PROTOCOL_HTTP,
205
- BLOCKLET_INTERFACE_PROTOCOL_TCP,
206
- BLOCKLET_INTERFACE_PROTOCOL_UDP,
207
- BLOCKLET_INTERFACE_PROTOCOLS,
208
-
209
- BLOCKLET_DYNAMIC_PATH_PREFIX: '*',
210
- BLOCKLET_DEFAULT_PORT_NAME: 'BLOCKLET_PORT',
211
- BLOCKLET_DEFAULT_PATH_REWRITE: '/',
212
-
213
- // bundle
214
- BLOCKLET_RELEASE_FOLDER: '.blocklet/release',
215
- BLOCKLET_RELEASE_FILE: 'blocklet.json',
216
- BLOCKLET_BUNDLE_FOLDER: '.blocklet/bundle',
217
- BLOCKLET_BUNDLE_FILE: 'blocklet.zip',
218
- BLOCKLET_ENTRY_FILE: 'blocklet.js',
219
- BLOCKLET_META_FILE: 'blocklet.yml',
220
- BLOCKLET_META_FILE_ALT: 'blocklet.yaml',
221
- BLOCKLET_PREFERENCE_FILE: 'blocklet.prefs.json',
222
- BLOCKLET_PREFERENCE_PREFIX: 'prefs.',
223
-
224
- BLOCKLET_DEFAULT_VERSION: '1.0.0',
225
-
226
- BLOCKLET_UPLOADS_DIR: '__uploads',
227
-
228
- BLOCKLET_LATEST_SPEC_VERSION: '1.2.8',
229
- BLOCKLET_LATEST_REQUIREMENT_SERVER: '>=1.7.0',
230
- BLOCKLET_LATEST_REQUIREMENT_ABTNODE: '>=1.5.15', // Deprecated
231
-
232
- BLOCKLET_CONFIGURABLE_KEY: {
139
+ exports.BLOCKLET_DYNAMIC_PATH_PREFIX = '*';
140
+ exports.BLOCKLET_DEFAULT_PORT_NAME = 'BLOCKLET_PORT';
141
+ exports.BLOCKLET_DEFAULT_PATH_REWRITE = '/';
142
+ // bundle
143
+ exports.BLOCKLET_RELEASE_FOLDER = '.blocklet/release';
144
+ exports.BLOCKLET_RELEASE_FILE = 'blocklet.json';
145
+ exports.BLOCKLET_BUNDLE_FOLDER = '.blocklet/bundle';
146
+ exports.BLOCKLET_BUNDLE_FILE = 'blocklet.zip';
147
+ exports.BLOCKLET_ENTRY_FILE = 'blocklet.js';
148
+ exports.BLOCKLET_META_FILE = 'blocklet.yml';
149
+ exports.BLOCKLET_META_FILE_ALT = 'blocklet.yaml';
150
+ exports.BLOCKLET_PREFERENCE_FILE = 'blocklet.prefs.json';
151
+ exports.BLOCKLET_PREFERENCE_PREFIX = 'prefs.';
152
+ exports.BLOCKLET_DEFAULT_VERSION = '1.0.0';
153
+ exports.BLOCKLET_UPLOADS_DIR = '__uploads';
154
+ exports.BLOCKLET_LATEST_SPEC_VERSION = '1.2.8';
155
+ exports.BLOCKLET_LATEST_REQUIREMENT_SERVER = '>=1.7.0';
156
+ exports.BLOCKLET_LATEST_REQUIREMENT_ABTNODE = '>=1.5.15'; // Deprecated
157
+ exports.BLOCKLET_CONFIGURABLE_KEY = {
233
158
  // APP Config Key that start with BLOCKLET_ cannot set to child component
234
159
  BLOCKLET_CLUSTER_SIZE: 'BLOCKLET_CLUSTER_SIZE',
235
160
  BLOCKLET_APP_NAME: 'BLOCKLET_APP_NAME',
236
161
  BLOCKLET_APP_DESCRIPTION: 'BLOCKLET_APP_DESCRIPTION',
237
162
  BLOCKLET_APP_SK: 'BLOCKLET_APP_SK',
238
- BLOCKLET_APP_LOGO: 'BLOCKLET_APP_LOGO', // deprecated
163
+ BLOCKLET_APP_LOGO: 'BLOCKLET_APP_LOGO',
239
164
  BLOCKLET_APP_LOGO_SQUARE: 'BLOCKLET_APP_LOGO_SQUARE',
240
165
  BLOCKLET_APP_LOGO_RECT: 'BLOCKLET_APP_LOGO_RECT',
241
166
  BLOCKLET_APP_LOGO_FAVICON: 'BLOCKLET_APP_LOGO_FAVICON',
242
167
  BLOCKLET_APP_URL: 'BLOCKLET_APP_URL',
243
168
  BLOCKLET_PASSPORT_COLOR: 'BLOCKLET_PASSPORT_COLOR',
244
- BLOCKLET_WALLET_TYPE: 'BLOCKLET_WALLET_TYPE', // deprecated
169
+ BLOCKLET_WALLET_TYPE: 'BLOCKLET_WALLET_TYPE',
245
170
  BLOCKLET_DELETABLE: 'BLOCKLET_DELETABLE',
246
-
247
171
  // 应用使用 DID Spaces 存储 文件/nft 的时候使用的环境变量
248
172
  BLOCKLET_APP_SPACE_ENDPOINT: 'BLOCKLET_APP_SPACE_ENDPOINT',
249
173
  BLOCKLET_APP_SPACES_URL: 'BLOCKLET_APP_SPACES_URL',
250
-
251
174
  // 应用使用 DID Spaces 备份的时候使用的环境变量
252
175
  BLOCKLET_APP_BACKUP_ENDPOINT: 'BLOCKLET_APP_BACKUP_ENDPOINT',
253
-
254
176
  BLOCKLET_APP_CHAIN_HOST: 'BLOCKLET_APP_CHAIN_HOST',
255
177
  BLOCKLET_APP_CHAIN_TYPE: 'BLOCKLET_APP_CHAIN_TYPE',
256
178
  BLOCKLET_APP_CHAIN_ID: 'BLOCKLET_APP_CHAIN_ID',
257
-
258
179
  // Component Key
259
180
  COMPONENT_ACCESS_WHO: 'COMPONENT_ACCESS_WHO',
260
- },
261
-
262
- BLOCKLET_APP_SPACE_ENDPOINTS: {
181
+ };
182
+ exports.BLOCKLET_APP_SPACE_ENDPOINTS = {
263
183
  REQUIRED: 'required',
264
184
  OPTIONAL: 'optional',
265
- },
266
-
267
- CHAIN_INFO_CONFIG: {
185
+ };
186
+ exports.CHAIN_INFO_CONFIG = {
268
187
  CHAIN_TYPE: ['type', 'arcblock'],
269
188
  CHAIN_ID: ['id', 'none'],
270
189
  CHAIN_HOST: ['host', 'none'],
271
- },
272
-
273
- CHAIN_PROP_MAP,
274
- CHAIN_PROP_MAP_REVERSE,
275
-
276
- RESTORE_PROGRESS_STATUS,
277
- });
190
+ };
191
+ exports.RESTORE_PROGRESS_STATUS = {
192
+ waiting: 0,
193
+ start: 10,
194
+ importData: 20,
195
+ downloading: 30,
196
+ importDataSuccess: 40,
197
+ installing: 50,
198
+ completed: 60,
199
+ error: 70,
200
+ };
201
+ exports.CHAIN_PROP_MAP = {
202
+ BLOCKLET_APP_CHAIN_HOST: 'CHAIN_HOST',
203
+ BLOCKLET_APP_CHAIN_ID: 'CHAIN_ID',
204
+ BLOCKLET_APP_CHAIN_TYPE: 'CHAIN_TYPE',
205
+ };
206
+ exports.CHAIN_PROP_MAP_REVERSE = Object.keys(exports.CHAIN_PROP_MAP).reduce((acc, key) => {
207
+ acc[exports.CHAIN_PROP_MAP[key]] = key;
208
+ return acc;
209
+ }, {});
package/package.json CHANGED
@@ -3,22 +3,33 @@
3
3
  "publishConfig": {
4
4
  "access": "public"
5
5
  },
6
- "version": "1.16.8",
6
+ "version": "1.16.9",
7
7
  "description": "Blocklet constants",
8
8
  "main": "index.js",
9
9
  "files": [
10
10
  "index.js"
11
11
  ],
12
12
  "scripts": {
13
- "lint": "eslint tests index.js",
14
- "lint:fix": "eslint --fix tests index.js",
13
+ "lint": "eslint tests index.ts",
14
+ "lint:fix": "npm run lint -- --fix",
15
15
  "test": "NODE_ENV=test node tools/jest.js",
16
- "coverage": "npm run test -- --coverage"
16
+ "coverage": "npm run test -- --coverage",
17
+ "clean": "rm -f index.d.ts index.js",
18
+ "build": "npm run clean && tsc"
17
19
  },
18
20
  "author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
19
- "license": "MIT",
21
+ "license": "Apache-2.0",
20
22
  "devDependencies": {
21
- "jest": "^27.5.1"
23
+ "@arcblock/eslint-config-ts": "^0.2.3",
24
+ "@types/jest": "^29.2.0",
25
+ "@types/node": "^18.11.0",
26
+ "@typescript-eslint/eslint-plugin": "^5.40.1",
27
+ "@typescript-eslint/parser": "^5.40.1",
28
+ "eslint": "^8.25.0",
29
+ "jest": "^27.5.1",
30
+ "prettier": "^2.7.1",
31
+ "ts-jest": "^27.1.5",
32
+ "typescript": "^5.0.4"
22
33
  },
23
- "gitHead": "00c2a9df97b7745fb3d76d07bc03172017cef352"
34
+ "gitHead": "700ce63e24f6f9b7ad8ecd4ca0aecc8305ee9693"
24
35
  }