@blocklet/constant 1.8.27

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/README.md +3 -0
  2. package/index.js +192 -0
  3. package/package.json +24 -0
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # Blocklet Constants
2
+
3
+ Constants used in blocklet
package/index.js ADDED
@@ -0,0 +1,192 @@
1
+ const fromEntry = (entries) => (v) => {
2
+ const match = Object.entries(entries).find((x) => x[1] === Number(v));
3
+ return match ? match[0] : 'unknown';
4
+ };
5
+
6
+ const toEntry = (entries) => (v) => Object.keys(entries).find((x) => entries[x] === Number(v));
7
+
8
+ // 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,
26
+ });
27
+
28
+ const fromBlockletStatus = fromEntry(BlockletStatus);
29
+ const toBlockletStatus = toEntry(BlockletStatus);
30
+
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,
48
+ });
49
+
50
+ const fromBlockletSource = fromEntry(BlockletSource);
51
+ const toBlockletSource = toEntry(BlockletSource);
52
+
53
+ // 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',
68
+ });
69
+
70
+ const BLOCKLET_GROUPS = ['dapp', 'static', 'gateway'];
71
+
72
+ // Blocklet Events
73
+
74
+ const BlockletEvents = Object.freeze({
75
+ added: 'blocklet.added',
76
+ downloadFailed: 'blocklet.downloadFailed',
77
+ installed: 'blocklet.installed',
78
+ installFailed: 'blocklet.installFailed',
79
+ upgraded: 'blocklet.upgraded',
80
+ upgradeFailed: 'blocklet.upgradedFailed',
81
+ downgraded: 'blocklet.downgraded',
82
+ downgradeFailed: 'blocklet.downgradedFailed',
83
+ updated: 'blocklet.updated',
84
+ statusChange: 'blocklet.statusChange',
85
+ removed: 'blocklet.removed',
86
+ started: 'blocklet.started',
87
+ startFailed: 'blocklet.startFailed',
88
+ stopped: 'blocklet.stopped',
89
+ reloaded: 'blocklet.reloaded', // Deprecated
90
+ purchaseChange: 'blocklet.purchaseChange',
91
+ });
92
+
93
+ // Blocklet Interface
94
+
95
+ const BLOCKLET_INTERFACE_TYPE_WEB = 'web';
96
+ const BLOCKLET_INTERFACE_TYPE_SERVICE = 'service';
97
+
98
+ // Wellknown interface declares an sub-interface under web interface
99
+ // The path of the wellknown interface must starts with /.well-known, e.g. /.well-known/acme-challenge)
100
+ // The wellknown interface can be mounted to every endpoint of the abtnode and all blocklets on the abtnode
101
+ const BLOCKLET_INTERFACE_TYPE_WELLKNOWN = 'wellknown';
102
+ const BLOCKLET_INTERFACE_TYPES = [
103
+ BLOCKLET_INTERFACE_TYPE_WEB,
104
+ BLOCKLET_INTERFACE_TYPE_SERVICE,
105
+ BLOCKLET_INTERFACE_TYPE_WELLKNOWN,
106
+ ];
107
+
108
+ const BLOCKLET_INTERFACE_PUBLIC = 'publicUrl';
109
+ const BLOCKLET_INTERFACE_WELLKNOWN = 'wellknownUrl'; // Deprecated
110
+ const BLOCKLET_UI_INTERFACES = [BLOCKLET_INTERFACE_PUBLIC];
111
+ const BLOCKLET_STANDARD_INTERFACES = [BLOCKLET_INTERFACE_PUBLIC, BLOCKLET_INTERFACE_WELLKNOWN];
112
+
113
+ const BLOCKLET_INTERFACE_PROTOCOL_HTTP = 'http';
114
+ const BLOCKLET_INTERFACE_PROTOCOL_TCP = 'tcp';
115
+ const BLOCKLET_INTERFACE_PROTOCOL_UDP = 'udp';
116
+ const BLOCKLET_INTERFACE_PROTOCOLS = [
117
+ BLOCKLET_INTERFACE_PROTOCOL_TCP,
118
+ BLOCKLET_INTERFACE_PROTOCOL_UDP,
119
+ BLOCKLET_INTERFACE_PROTOCOL_HTTP,
120
+ ];
121
+
122
+ module.exports = Object.freeze({
123
+ BlockletStatus,
124
+ fromBlockletStatus,
125
+ toBlockletStatus,
126
+
127
+ BlockletSource,
128
+ fromBlockletSource,
129
+ toBlockletSource,
130
+
131
+ BlockletGroup,
132
+ BLOCKLET_GROUPS,
133
+
134
+ BlockletEvents,
135
+
136
+ BLOCKLET_PLATFORMS: ['aix', 'darwin', 'freebsd', 'linux', 'openbsd', 'sunos', 'win32'],
137
+ BLOCKLET_ARCHITECTURES: ['arm', 'arm64', 'ia32', 'mips', 'mipsel', 'ppc', 'ppc64', 's390', 's390x', 'x32', 'x64'],
138
+
139
+ BLOCKLET_MODES: Object.freeze({
140
+ PRODUCTION: 'production',
141
+ DEVELOPMENT: 'development',
142
+ }),
143
+
144
+ BLOCKLET_FACTORY_SHARES: { developer: 0.7, store: 0.3 },
145
+
146
+ // interface
147
+ BLOCKLET_INTERFACE_PUBLIC,
148
+ BLOCKLET_INTERFACE_WELLKNOWN, // Deprecated
149
+ BLOCKLET_UI_INTERFACES,
150
+ BLOCKLET_STANDARD_INTERFACES,
151
+
152
+ BLOCKLET_INTERFACE_TYPE_WEB,
153
+ BLOCKLET_INTERFACE_TYPE_SERVICE,
154
+ BLOCKLET_INTERFACE_TYPE_WELLKNOWN,
155
+ BLOCKLET_INTERFACE_TYPES,
156
+
157
+ BLOCKLET_INTERFACE_PROTOCOL_HTTP,
158
+ BLOCKLET_INTERFACE_PROTOCOL_TCP,
159
+ BLOCKLET_INTERFACE_PROTOCOL_UDP,
160
+ BLOCKLET_INTERFACE_PROTOCOLS,
161
+
162
+ BLOCKLET_DYNAMIC_PATH_PREFIX: '*',
163
+ BLOCKLET_DEFAULT_PORT_NAME: 'BLOCKLET_PORT',
164
+ BLOCKLET_DEFAULT_PATH_REWRITE: '/',
165
+
166
+ // bundle
167
+ BLOCKLET_RELEASE_FOLDER: '.blocklet/release',
168
+ BLOCKLET_RELEASE_FILE: 'blocklet.json',
169
+ BLOCKLET_BUNDLE_FOLDER: '.blocklet/bundle',
170
+ BLOCKLET_BUNDLE_FILE: 'blocklet.zip',
171
+ BLOCKLET_ENTRY_FILE: 'blocklet.js',
172
+ BLOCKLET_META_FILE: 'blocklet.yml',
173
+ BLOCKLET_META_FILE_ALT: 'blocklet.yaml',
174
+
175
+ BLOCKLET_DEFAULT_VERSION: '1.0.0',
176
+
177
+ BLOCKLET_LATEST_SPEC_VERSION: '1.2.7',
178
+ BLOCKLET_LATEST_REQUIREMENT_SERVER: '>=1.7.0',
179
+ BLOCKLET_LATEST_REQUIREMENT_ABTNODE: '>=1.5.15', // Deprecated
180
+
181
+ BLOCKLET_CONFIGURABLE_KEY: {
182
+ BLOCKLET_CLUSTER_SIZE: 'BLOCKLET_CLUSTER_SIZE',
183
+ BLOCKLET_APP_NAME: 'BLOCKLET_APP_NAME',
184
+ BLOCKLET_APP_DESCRIPTION: 'BLOCKLET_APP_DESCRIPTION',
185
+ BLOCKLET_APP_SK: 'BLOCKLET_APP_SK',
186
+ BLOCKLET_APP_LOGO: 'BLOCKLET_APP_LOGO',
187
+ BLOCKLET_APP_URL: 'BLOCKLET_APP_URL',
188
+ BLOCKLET_PASSPORT_COLOR: 'BLOCKLET_PASSPORT_COLOR',
189
+ BLOCKLET_WALLET_TYPE: 'BLOCKLET_WALLET_TYPE',
190
+ BLOCKLET_DELETABLE: 'BLOCKLET_DELETABLE',
191
+ },
192
+ });
package/package.json ADDED
@@ -0,0 +1,24 @@
1
+ {
2
+ "name": "@blocklet/constant",
3
+ "publishConfig": {
4
+ "access": "public"
5
+ },
6
+ "version": "1.8.27",
7
+ "description": "Blocklet constants",
8
+ "main": "index.js",
9
+ "files": [
10
+ "index.js"
11
+ ],
12
+ "scripts": {
13
+ "lint": "eslint tests index.js",
14
+ "lint:fix": "eslint --fix tests index.js",
15
+ "test": "NODE_ENV=test node tools/jest.js",
16
+ "coverage": "npm run test -- --coverage"
17
+ },
18
+ "author": "polunzh <polunzh@gmail.com> (http://github.com/polunzh)",
19
+ "license": "MIT",
20
+ "devDependencies": {
21
+ "jest": "^27.5.1"
22
+ },
23
+ "gitHead": "84b2cb3ee703479f17e88c91650ecf3015cbf6af"
24
+ }