@webqit/webflo 0.11.61-0 → 1.0.0
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.
- package/.gitignore +7 -7
- package/LICENSE +20 -20
- package/README.md +2079 -2074
- package/docker/Dockerfile +42 -42
- package/docker/README.md +91 -91
- package/docker/package.json +2 -2
- package/package.json +80 -81
- package/src/{Context.js → AbstractContext.js} +71 -79
- package/src/config-pi/deployment/Env.js +68 -68
- package/src/config-pi/deployment/Layout.js +63 -63
- package/src/config-pi/deployment/Origins.js +139 -139
- package/src/config-pi/deployment/Proxy.js +74 -74
- package/src/config-pi/deployment/index.js +17 -17
- package/src/config-pi/index.js +15 -15
- package/src/config-pi/runtime/Client.js +116 -98
- package/src/config-pi/runtime/Server.js +125 -125
- package/src/config-pi/runtime/client/Worker.js +109 -134
- package/src/config-pi/runtime/client/index.js +11 -11
- package/src/config-pi/runtime/index.js +17 -17
- package/src/config-pi/runtime/server/Headers.js +74 -74
- package/src/config-pi/runtime/server/Redirects.js +69 -69
- package/src/config-pi/runtime/server/index.js +13 -13
- package/src/config-pi/static/Manifest.js +319 -319
- package/src/config-pi/static/Ssg.js +49 -49
- package/src/config-pi/static/index.js +13 -13
- package/src/deployment-pi/index.js +10 -10
- package/src/deployment-pi/origins/index.js +216 -216
- package/src/index.js +11 -19
- package/src/runtime-pi/HttpEvent.js +126 -106
- package/src/runtime-pi/HttpUser.js +126 -0
- package/src/runtime-pi/MessagingOverBroadcast.js +9 -0
- package/src/runtime-pi/MessagingOverChannel.js +85 -0
- package/src/runtime-pi/MessagingOverSocket.js +106 -0
- package/src/runtime-pi/MultiportMessagingAPI.js +81 -0
- package/src/runtime-pi/WebfloCookieStorage.js +27 -0
- package/src/runtime-pi/WebfloEventTarget.js +39 -0
- package/src/runtime-pi/WebfloMessageEvent.js +58 -0
- package/src/runtime-pi/WebfloMessagingAPI.js +69 -0
- package/src/runtime-pi/{Router.js → WebfloRouter.js} +99 -130
- package/src/runtime-pi/WebfloRuntime.js +52 -0
- package/src/runtime-pi/WebfloStorage.js +109 -0
- package/src/runtime-pi/client/ClientMessaging.js +5 -0
- package/src/runtime-pi/client/Context.js +3 -7
- package/src/runtime-pi/client/CookieStorage.js +17 -0
- package/src/runtime-pi/client/Router.js +38 -48
- package/src/runtime-pi/client/SessionStorage.js +33 -0
- package/src/runtime-pi/client/Url.js +156 -205
- package/src/runtime-pi/client/WebfloClient.js +544 -0
- package/src/runtime-pi/client/WebfloRootClient1.js +179 -0
- package/src/runtime-pi/client/WebfloRootClient2.js +109 -0
- package/src/runtime-pi/client/WebfloSubClient.js +165 -0
- package/src/runtime-pi/client/Workport.js +118 -178
- package/src/runtime-pi/client/generate.js +480 -471
- package/src/runtime-pi/client/index.js +16 -21
- package/src/runtime-pi/client/worker/ClientMessaging.js +5 -0
- package/src/runtime-pi/client/worker/Context.js +3 -7
- package/src/runtime-pi/client/worker/CookieStorage.js +17 -0
- package/src/runtime-pi/client/worker/SessionStorage.js +13 -0
- package/src/runtime-pi/client/worker/WebfloWorker.js +294 -0
- package/src/runtime-pi/client/worker/Workport.js +17 -85
- package/src/runtime-pi/client/worker/index.js +10 -21
- package/src/runtime-pi/index.js +6 -13
- package/src/runtime-pi/server/ClientMessaging.js +18 -0
- package/src/runtime-pi/server/ClientMessagingRegistry.js +57 -0
- package/src/runtime-pi/server/Context.js +11 -15
- package/src/runtime-pi/server/CookieStorage.js +17 -0
- package/src/runtime-pi/server/Router.js +93 -159
- package/src/runtime-pi/server/SessionStorage.js +53 -0
- package/src/runtime-pi/server/WebfloServer.js +755 -0
- package/src/runtime-pi/server/index.js +10 -21
- package/src/runtime-pi/util-http.js +322 -86
- package/src/runtime-pi/util-url.js +146 -146
- package/src/runtime-pi/xURL.js +108 -105
- package/src/runtime-pi/xfetch.js +22 -22
- package/src/services-pi/cert/http-auth-hook.js +22 -22
- package/src/services-pi/cert/http-cleanup-hook.js +22 -22
- package/src/services-pi/cert/index.js +79 -79
- package/src/services-pi/index.js +8 -8
- package/src/static-pi/index.js +10 -10
- package/src/webflo.js +30 -30
- package/test/index.test.js +26 -26
- package/test/site/package.json +9 -9
- package/test/site/public/bundle.html +5 -5
- package/test/site/public/bundle.html.json +3 -3
- package/test/site/public/bundle.js +2 -2
- package/test/site/public/bundle.webflo.js +15 -15
- package/test/site/public/index.html +29 -29
- package/test/site/public/index1.html +34 -34
- package/test/site/public/page-2/bundle.html +4 -4
- package/test/site/public/page-2/bundle.js +2 -2
- package/test/site/public/page-2/index.html +45 -45
- package/test/site/public/page-2/main.html +2 -2
- package/test/site/public/page-4/subpage/bundle.js +2 -2
- package/test/site/public/page-4/subpage/index.html +30 -30
- package/test/site/public/sparoots.json +4 -4
- package/test/site/public/worker.js +3 -3
- package/test/site/server/index.js +15 -15
- package/src/runtime-pi/Application.js +0 -29
- package/src/runtime-pi/Cookies.js +0 -82
- package/src/runtime-pi/Runtime.js +0 -21
- package/src/runtime-pi/client/Application.js +0 -100
- package/src/runtime-pi/client/Runtime.js +0 -332
- package/src/runtime-pi/client/createStorage.js +0 -57
- package/src/runtime-pi/client/oohtml/full.js +0 -7
- package/src/runtime-pi/client/oohtml/namespacing.js +0 -7
- package/src/runtime-pi/client/oohtml/scripting.js +0 -8
- package/src/runtime-pi/client/oohtml/templating.js +0 -8
- package/src/runtime-pi/client/worker/Application.js +0 -44
- package/src/runtime-pi/client/worker/Runtime.js +0 -269
- package/src/runtime-pi/server/Application.js +0 -116
- package/src/runtime-pi/server/Runtime.js +0 -557
- package/src/runtime-pi/xFormData.js +0 -24
- package/src/runtime-pi/xHeaders.js +0 -146
- package/src/runtime-pi/xRequest.js +0 -46
- package/src/runtime-pi/xRequestHeaders.js +0 -109
- package/src/runtime-pi/xResponse.js +0 -33
- package/src/runtime-pi/xResponseHeaders.js +0 -117
- package/src/runtime-pi/xxHttpMessage.js +0 -102
|
@@ -1,319 +1,319 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* imports
|
|
4
|
-
*/
|
|
5
|
-
import Path from 'path';
|
|
6
|
-
import { _all } from '@webqit/util/arr/index.js';
|
|
7
|
-
import { _isNumeric } from '@webqit/util/js/index.js';
|
|
8
|
-
import { initialGetIndex } from '@webqit/backpack/src/cli/Promptx.js';
|
|
9
|
-
import { Dotfile } from '@webqit/backpack';
|
|
10
|
-
|
|
11
|
-
export default class Manifest extends Dotfile {
|
|
12
|
-
|
|
13
|
-
// Base name
|
|
14
|
-
get name() {
|
|
15
|
-
return 'manifest';
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// @desc
|
|
19
|
-
static get ['@desc']() {
|
|
20
|
-
return 'Application Manifest config.';
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
// Config dir
|
|
24
|
-
get configDir() {
|
|
25
|
-
return Path.join(this.cx.CWD || ``, this.cx.layout.PUBLIC_DIR || '');
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
// Defaults merger
|
|
29
|
-
withDefaults(config) {
|
|
30
|
-
const pkg = this.cx.PKG || {};
|
|
31
|
-
return this.merge({
|
|
32
|
-
// -----------------
|
|
33
|
-
name: pkg.value,
|
|
34
|
-
short_name: pkg.value,
|
|
35
|
-
description: pkg.description,
|
|
36
|
-
categories: pkg.keywords,
|
|
37
|
-
theme_color: 'transparent',
|
|
38
|
-
background_color: 'transparent',
|
|
39
|
-
icons: [],
|
|
40
|
-
display: 'browser',
|
|
41
|
-
orientation: 'any',
|
|
42
|
-
// advanced
|
|
43
|
-
screenshots: [],
|
|
44
|
-
shortcuts: [],
|
|
45
|
-
scope: '/',
|
|
46
|
-
start_url: '/',
|
|
47
|
-
lang: 'en-us',
|
|
48
|
-
dir: 'ltr',
|
|
49
|
-
related_applications: '',
|
|
50
|
-
prefer_related_applications: false,
|
|
51
|
-
}, config, 'patch');
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
// Questions generator
|
|
55
|
-
getSchema(config, choices = {}) {
|
|
56
|
-
// Choices hash...
|
|
57
|
-
const CHOICES = this.merge({
|
|
58
|
-
display: [
|
|
59
|
-
{value: 'browser',},
|
|
60
|
-
{value: 'fullscreen',},
|
|
61
|
-
{value: 'standalone',},
|
|
62
|
-
{value: 'minimal-ui',},
|
|
63
|
-
],
|
|
64
|
-
orientation: [
|
|
65
|
-
{value: 'any',},
|
|
66
|
-
{value: 'natural',},
|
|
67
|
-
{value: '::::::::::::::::', disabled: true,},
|
|
68
|
-
{value: 'landscape',},
|
|
69
|
-
{value: 'landscape-primary',},
|
|
70
|
-
{value: 'landscape-secondary',},
|
|
71
|
-
{value: '::::::::::::::::', disabled: true,},
|
|
72
|
-
{value: 'portrait',},
|
|
73
|
-
{value: 'portrait-primary',},
|
|
74
|
-
{value: 'portrait-secondary',},
|
|
75
|
-
],
|
|
76
|
-
}, choices, 'patch');
|
|
77
|
-
|
|
78
|
-
// Gets index...
|
|
79
|
-
const getSize = src => Path.basename(src).split(/[_\.\-]/g).reduce((size, chunk) => size || (_all(chunk.split('x'), c => _isNumeric(c)) ? chunk : ''), null);
|
|
80
|
-
const getMime = src => extensions[Path.extname(src)];
|
|
81
|
-
// extensions
|
|
82
|
-
const extensions = {
|
|
83
|
-
'.png': 'image/png',
|
|
84
|
-
'.jpg': 'image/jpg',
|
|
85
|
-
'.jpeg': 'image/jpeg',
|
|
86
|
-
'.ico': 'image/ico',
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
// Questions
|
|
90
|
-
return [
|
|
91
|
-
{
|
|
92
|
-
name: 'name',
|
|
93
|
-
type: 'text',
|
|
94
|
-
message: 'Enter the application name',
|
|
95
|
-
initial: config.name,
|
|
96
|
-
validation: ['important'],
|
|
97
|
-
},
|
|
98
|
-
{
|
|
99
|
-
name: 'short_name',
|
|
100
|
-
type: 'text',
|
|
101
|
-
message: 'Enter the application short name',
|
|
102
|
-
initial: prev => config.short_name || prev,
|
|
103
|
-
validation: ['important'],
|
|
104
|
-
},
|
|
105
|
-
{
|
|
106
|
-
name: 'description',
|
|
107
|
-
type: 'text',
|
|
108
|
-
message: 'Enter the application description',
|
|
109
|
-
initial: config.description,
|
|
110
|
-
validation: ['important'],
|
|
111
|
-
},
|
|
112
|
-
{
|
|
113
|
-
name: 'categories',
|
|
114
|
-
type: 'list',
|
|
115
|
-
message: 'Specify applications categories (comma-separated)',
|
|
116
|
-
initial: (config.categories || []).join(', '),
|
|
117
|
-
},
|
|
118
|
-
{
|
|
119
|
-
name: 'theme_color',
|
|
120
|
-
type: 'text',
|
|
121
|
-
message: 'Enter the application theme color',
|
|
122
|
-
initial: config.theme_color,
|
|
123
|
-
},
|
|
124
|
-
{
|
|
125
|
-
name: 'background_color',
|
|
126
|
-
type: 'text',
|
|
127
|
-
message: 'Enter the application background color',
|
|
128
|
-
initial: config.background_color,
|
|
129
|
-
},
|
|
130
|
-
{
|
|
131
|
-
name: 'icons',
|
|
132
|
-
type: 'recursive',
|
|
133
|
-
initial: config.icons,
|
|
134
|
-
controls: {
|
|
135
|
-
name: 'icon',
|
|
136
|
-
},
|
|
137
|
-
schema: [
|
|
138
|
-
{
|
|
139
|
-
name: 'src',
|
|
140
|
-
type: 'text',
|
|
141
|
-
message: 'Enter icon URL',
|
|
142
|
-
validation: ['important'],
|
|
143
|
-
},
|
|
144
|
-
{
|
|
145
|
-
name: 'type',
|
|
146
|
-
type: 'text',
|
|
147
|
-
message: 'Enter icon MIME type',
|
|
148
|
-
initial: prev => getMime(prev),
|
|
149
|
-
validation: ['important'],
|
|
150
|
-
},
|
|
151
|
-
{
|
|
152
|
-
name: 'sizes',
|
|
153
|
-
type: 'text',
|
|
154
|
-
message: 'Enter icon sizes',
|
|
155
|
-
initial: (prev, answers) => getSize(answers.src),
|
|
156
|
-
validation: ['important'],
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
},
|
|
160
|
-
{
|
|
161
|
-
name: 'display',
|
|
162
|
-
type: 'select',
|
|
163
|
-
message: 'Enter the application display mode',
|
|
164
|
-
choices: CHOICES.display,
|
|
165
|
-
initial: initialGetIndex(CHOICES.display, config.display),
|
|
166
|
-
},
|
|
167
|
-
{
|
|
168
|
-
name: 'orientation',
|
|
169
|
-
type: 'select',
|
|
170
|
-
message: 'Enter the application orientation mode',
|
|
171
|
-
choices: CHOICES.orientation,
|
|
172
|
-
initial: initialGetIndex(CHOICES.orientation, config.orientation),
|
|
173
|
-
},
|
|
174
|
-
// ------------- advanced --------------
|
|
175
|
-
{
|
|
176
|
-
name: '__advanced',
|
|
177
|
-
type: 'toggle',
|
|
178
|
-
message: 'Show advanced options?',
|
|
179
|
-
active: 'YES',
|
|
180
|
-
inactive: 'NO',
|
|
181
|
-
initial: config.__advanced,
|
|
182
|
-
exclude: true,
|
|
183
|
-
},
|
|
184
|
-
// ------------- advanced --------------
|
|
185
|
-
{
|
|
186
|
-
name: 'screenshots',
|
|
187
|
-
type: (prev, answers) => answers.__advanced ? 'recursive' : null,
|
|
188
|
-
initial: config.screenshots,
|
|
189
|
-
controls: {
|
|
190
|
-
name: 'screenshot',
|
|
191
|
-
},
|
|
192
|
-
schema: [
|
|
193
|
-
{
|
|
194
|
-
name: 'src',
|
|
195
|
-
type: 'text',
|
|
196
|
-
message: 'Enter screenshot URL',
|
|
197
|
-
validation: ['important'],
|
|
198
|
-
},
|
|
199
|
-
{
|
|
200
|
-
name: 'type',
|
|
201
|
-
type: 'text',
|
|
202
|
-
message: 'Enter screenshot MIME type',
|
|
203
|
-
initial: prev => getMime(prev),
|
|
204
|
-
validation: ['important'],
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
name: 'sizes',
|
|
208
|
-
type: 'text',
|
|
209
|
-
message: 'Enter screenshot sizes',
|
|
210
|
-
initial: (prev, answers) => getSize(answers.src),
|
|
211
|
-
validation: ['important'],
|
|
212
|
-
},
|
|
213
|
-
],
|
|
214
|
-
},
|
|
215
|
-
{
|
|
216
|
-
name: 'shortcuts',
|
|
217
|
-
type: (prev, answers) => answers.__advanced ? 'recursive' : null,
|
|
218
|
-
initial: config.shortcuts,
|
|
219
|
-
controls: {
|
|
220
|
-
name: 'shortcut',
|
|
221
|
-
},
|
|
222
|
-
schema: [
|
|
223
|
-
{
|
|
224
|
-
name: 'name',
|
|
225
|
-
type: 'text',
|
|
226
|
-
message: 'Enter shortcut name',
|
|
227
|
-
validation: ['important'],
|
|
228
|
-
},
|
|
229
|
-
{
|
|
230
|
-
name: 'short_name',
|
|
231
|
-
type: 'text',
|
|
232
|
-
message: 'Enter shortcut short name',
|
|
233
|
-
validation: ['important'],
|
|
234
|
-
},
|
|
235
|
-
{
|
|
236
|
-
name: 'description',
|
|
237
|
-
type: 'text',
|
|
238
|
-
message: 'Enter shortcut description',
|
|
239
|
-
validation: ['important'],
|
|
240
|
-
},
|
|
241
|
-
{
|
|
242
|
-
name: 'url',
|
|
243
|
-
type: 'text',
|
|
244
|
-
message: 'Enter shortcut URL',
|
|
245
|
-
validation: ['important'],
|
|
246
|
-
},
|
|
247
|
-
{
|
|
248
|
-
name: 'icons',
|
|
249
|
-
type: 'recursive',
|
|
250
|
-
controls: {
|
|
251
|
-
name: 'shortcut icon',
|
|
252
|
-
},
|
|
253
|
-
schema: [
|
|
254
|
-
{
|
|
255
|
-
name: 'src',
|
|
256
|
-
type: 'text',
|
|
257
|
-
message: 'Enter icon URL',
|
|
258
|
-
validation: ['important'],
|
|
259
|
-
},
|
|
260
|
-
{
|
|
261
|
-
name: 'type',
|
|
262
|
-
type: 'text',
|
|
263
|
-
message: 'Enter icon MIME type',
|
|
264
|
-
initial: prev => getMime(prev),
|
|
265
|
-
validation: ['important'],
|
|
266
|
-
},
|
|
267
|
-
{
|
|
268
|
-
name: 'sizes',
|
|
269
|
-
type: 'text',
|
|
270
|
-
message: 'Enter icon sizes',
|
|
271
|
-
initial: (prev, answers) => getSize(answers.src),
|
|
272
|
-
validation: ['important'],
|
|
273
|
-
},
|
|
274
|
-
],
|
|
275
|
-
},
|
|
276
|
-
],
|
|
277
|
-
},
|
|
278
|
-
{
|
|
279
|
-
name: 'scope',
|
|
280
|
-
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
281
|
-
message: 'Specify the manifest scope',
|
|
282
|
-
initial: config.scope,
|
|
283
|
-
},
|
|
284
|
-
{
|
|
285
|
-
name: 'start_url',
|
|
286
|
-
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
287
|
-
message: 'Specify the application start URL',
|
|
288
|
-
initial: config.start_url,
|
|
289
|
-
},
|
|
290
|
-
{
|
|
291
|
-
name: 'lang',
|
|
292
|
-
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
293
|
-
message: 'Specify the application language',
|
|
294
|
-
initial: config.lang,
|
|
295
|
-
},
|
|
296
|
-
{
|
|
297
|
-
name: 'dir',
|
|
298
|
-
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
299
|
-
message: 'Specify the application writing mode',
|
|
300
|
-
initial: config.dir,
|
|
301
|
-
},
|
|
302
|
-
{
|
|
303
|
-
name: 'related_applications',
|
|
304
|
-
type: (prev, answers) => answers.__advanced ? 'list' : null,
|
|
305
|
-
message: 'Specify related applications (comma-separated)',
|
|
306
|
-
initial: (config.related_applications || []).join(', '),
|
|
307
|
-
},
|
|
308
|
-
{
|
|
309
|
-
name: 'prefer_related_applications',
|
|
310
|
-
type: (prev, answers) => answers.related_applications ? 'toggle' : null,
|
|
311
|
-
message: 'Specify whether to "prefer" related applications',
|
|
312
|
-
active: 'YES',
|
|
313
|
-
inactive: 'NO',
|
|
314
|
-
initial: config.prefer_related_applications,
|
|
315
|
-
},
|
|
316
|
-
|
|
317
|
-
];
|
|
318
|
-
}
|
|
319
|
-
}
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* imports
|
|
4
|
+
*/
|
|
5
|
+
import Path from 'path';
|
|
6
|
+
import { _all } from '@webqit/util/arr/index.js';
|
|
7
|
+
import { _isNumeric } from '@webqit/util/js/index.js';
|
|
8
|
+
import { initialGetIndex } from '@webqit/backpack/src/cli/Promptx.js';
|
|
9
|
+
import { Dotfile } from '@webqit/backpack';
|
|
10
|
+
|
|
11
|
+
export default class Manifest extends Dotfile {
|
|
12
|
+
|
|
13
|
+
// Base name
|
|
14
|
+
get name() {
|
|
15
|
+
return 'manifest';
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// @desc
|
|
19
|
+
static get ['@desc']() {
|
|
20
|
+
return 'Application Manifest config.';
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
// Config dir
|
|
24
|
+
get configDir() {
|
|
25
|
+
return Path.join(this.cx.CWD || ``, this.cx.layout.PUBLIC_DIR || '');
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// Defaults merger
|
|
29
|
+
withDefaults(config) {
|
|
30
|
+
const pkg = this.cx.PKG || {};
|
|
31
|
+
return this.merge({
|
|
32
|
+
// -----------------
|
|
33
|
+
name: pkg.value,
|
|
34
|
+
short_name: pkg.value,
|
|
35
|
+
description: pkg.description,
|
|
36
|
+
categories: pkg.keywords,
|
|
37
|
+
theme_color: 'transparent',
|
|
38
|
+
background_color: 'transparent',
|
|
39
|
+
icons: [],
|
|
40
|
+
display: 'browser',
|
|
41
|
+
orientation: 'any',
|
|
42
|
+
// advanced
|
|
43
|
+
screenshots: [],
|
|
44
|
+
shortcuts: [],
|
|
45
|
+
scope: '/',
|
|
46
|
+
start_url: '/',
|
|
47
|
+
lang: 'en-us',
|
|
48
|
+
dir: 'ltr',
|
|
49
|
+
related_applications: '',
|
|
50
|
+
prefer_related_applications: false,
|
|
51
|
+
}, config, 'patch');
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
// Questions generator
|
|
55
|
+
getSchema(config, choices = {}) {
|
|
56
|
+
// Choices hash...
|
|
57
|
+
const CHOICES = this.merge({
|
|
58
|
+
display: [
|
|
59
|
+
{value: 'browser',},
|
|
60
|
+
{value: 'fullscreen',},
|
|
61
|
+
{value: 'standalone',},
|
|
62
|
+
{value: 'minimal-ui',},
|
|
63
|
+
],
|
|
64
|
+
orientation: [
|
|
65
|
+
{value: 'any',},
|
|
66
|
+
{value: 'natural',},
|
|
67
|
+
{value: '::::::::::::::::', disabled: true,},
|
|
68
|
+
{value: 'landscape',},
|
|
69
|
+
{value: 'landscape-primary',},
|
|
70
|
+
{value: 'landscape-secondary',},
|
|
71
|
+
{value: '::::::::::::::::', disabled: true,},
|
|
72
|
+
{value: 'portrait',},
|
|
73
|
+
{value: 'portrait-primary',},
|
|
74
|
+
{value: 'portrait-secondary',},
|
|
75
|
+
],
|
|
76
|
+
}, choices, 'patch');
|
|
77
|
+
|
|
78
|
+
// Gets index...
|
|
79
|
+
const getSize = src => Path.basename(src).split(/[_\.\-]/g).reduce((size, chunk) => size || (_all(chunk.split('x'), c => _isNumeric(c)) ? chunk : ''), null);
|
|
80
|
+
const getMime = src => extensions[Path.extname(src)];
|
|
81
|
+
// extensions
|
|
82
|
+
const extensions = {
|
|
83
|
+
'.png': 'image/png',
|
|
84
|
+
'.jpg': 'image/jpg',
|
|
85
|
+
'.jpeg': 'image/jpeg',
|
|
86
|
+
'.ico': 'image/ico',
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
// Questions
|
|
90
|
+
return [
|
|
91
|
+
{
|
|
92
|
+
name: 'name',
|
|
93
|
+
type: 'text',
|
|
94
|
+
message: 'Enter the application name',
|
|
95
|
+
initial: config.name,
|
|
96
|
+
validation: ['important'],
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
name: 'short_name',
|
|
100
|
+
type: 'text',
|
|
101
|
+
message: 'Enter the application short name',
|
|
102
|
+
initial: prev => config.short_name || prev,
|
|
103
|
+
validation: ['important'],
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
name: 'description',
|
|
107
|
+
type: 'text',
|
|
108
|
+
message: 'Enter the application description',
|
|
109
|
+
initial: config.description,
|
|
110
|
+
validation: ['important'],
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
name: 'categories',
|
|
114
|
+
type: 'list',
|
|
115
|
+
message: 'Specify applications categories (comma-separated)',
|
|
116
|
+
initial: (config.categories || []).join(', '),
|
|
117
|
+
},
|
|
118
|
+
{
|
|
119
|
+
name: 'theme_color',
|
|
120
|
+
type: 'text',
|
|
121
|
+
message: 'Enter the application theme color',
|
|
122
|
+
initial: config.theme_color,
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
name: 'background_color',
|
|
126
|
+
type: 'text',
|
|
127
|
+
message: 'Enter the application background color',
|
|
128
|
+
initial: config.background_color,
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
name: 'icons',
|
|
132
|
+
type: 'recursive',
|
|
133
|
+
initial: config.icons,
|
|
134
|
+
controls: {
|
|
135
|
+
name: 'icon',
|
|
136
|
+
},
|
|
137
|
+
schema: [
|
|
138
|
+
{
|
|
139
|
+
name: 'src',
|
|
140
|
+
type: 'text',
|
|
141
|
+
message: 'Enter icon URL',
|
|
142
|
+
validation: ['important'],
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
name: 'type',
|
|
146
|
+
type: 'text',
|
|
147
|
+
message: 'Enter icon MIME type',
|
|
148
|
+
initial: prev => getMime(prev),
|
|
149
|
+
validation: ['important'],
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
name: 'sizes',
|
|
153
|
+
type: 'text',
|
|
154
|
+
message: 'Enter icon sizes',
|
|
155
|
+
initial: (prev, answers) => getSize(answers.src),
|
|
156
|
+
validation: ['important'],
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: 'display',
|
|
162
|
+
type: 'select',
|
|
163
|
+
message: 'Enter the application display mode',
|
|
164
|
+
choices: CHOICES.display,
|
|
165
|
+
initial: initialGetIndex(CHOICES.display, config.display),
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
name: 'orientation',
|
|
169
|
+
type: 'select',
|
|
170
|
+
message: 'Enter the application orientation mode',
|
|
171
|
+
choices: CHOICES.orientation,
|
|
172
|
+
initial: initialGetIndex(CHOICES.orientation, config.orientation),
|
|
173
|
+
},
|
|
174
|
+
// ------------- advanced --------------
|
|
175
|
+
{
|
|
176
|
+
name: '__advanced',
|
|
177
|
+
type: 'toggle',
|
|
178
|
+
message: 'Show advanced options?',
|
|
179
|
+
active: 'YES',
|
|
180
|
+
inactive: 'NO',
|
|
181
|
+
initial: config.__advanced,
|
|
182
|
+
exclude: true,
|
|
183
|
+
},
|
|
184
|
+
// ------------- advanced --------------
|
|
185
|
+
{
|
|
186
|
+
name: 'screenshots',
|
|
187
|
+
type: (prev, answers) => answers.__advanced ? 'recursive' : null,
|
|
188
|
+
initial: config.screenshots,
|
|
189
|
+
controls: {
|
|
190
|
+
name: 'screenshot',
|
|
191
|
+
},
|
|
192
|
+
schema: [
|
|
193
|
+
{
|
|
194
|
+
name: 'src',
|
|
195
|
+
type: 'text',
|
|
196
|
+
message: 'Enter screenshot URL',
|
|
197
|
+
validation: ['important'],
|
|
198
|
+
},
|
|
199
|
+
{
|
|
200
|
+
name: 'type',
|
|
201
|
+
type: 'text',
|
|
202
|
+
message: 'Enter screenshot MIME type',
|
|
203
|
+
initial: prev => getMime(prev),
|
|
204
|
+
validation: ['important'],
|
|
205
|
+
},
|
|
206
|
+
{
|
|
207
|
+
name: 'sizes',
|
|
208
|
+
type: 'text',
|
|
209
|
+
message: 'Enter screenshot sizes',
|
|
210
|
+
initial: (prev, answers) => getSize(answers.src),
|
|
211
|
+
validation: ['important'],
|
|
212
|
+
},
|
|
213
|
+
],
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
name: 'shortcuts',
|
|
217
|
+
type: (prev, answers) => answers.__advanced ? 'recursive' : null,
|
|
218
|
+
initial: config.shortcuts,
|
|
219
|
+
controls: {
|
|
220
|
+
name: 'shortcut',
|
|
221
|
+
},
|
|
222
|
+
schema: [
|
|
223
|
+
{
|
|
224
|
+
name: 'name',
|
|
225
|
+
type: 'text',
|
|
226
|
+
message: 'Enter shortcut name',
|
|
227
|
+
validation: ['important'],
|
|
228
|
+
},
|
|
229
|
+
{
|
|
230
|
+
name: 'short_name',
|
|
231
|
+
type: 'text',
|
|
232
|
+
message: 'Enter shortcut short name',
|
|
233
|
+
validation: ['important'],
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
name: 'description',
|
|
237
|
+
type: 'text',
|
|
238
|
+
message: 'Enter shortcut description',
|
|
239
|
+
validation: ['important'],
|
|
240
|
+
},
|
|
241
|
+
{
|
|
242
|
+
name: 'url',
|
|
243
|
+
type: 'text',
|
|
244
|
+
message: 'Enter shortcut URL',
|
|
245
|
+
validation: ['important'],
|
|
246
|
+
},
|
|
247
|
+
{
|
|
248
|
+
name: 'icons',
|
|
249
|
+
type: 'recursive',
|
|
250
|
+
controls: {
|
|
251
|
+
name: 'shortcut icon',
|
|
252
|
+
},
|
|
253
|
+
schema: [
|
|
254
|
+
{
|
|
255
|
+
name: 'src',
|
|
256
|
+
type: 'text',
|
|
257
|
+
message: 'Enter icon URL',
|
|
258
|
+
validation: ['important'],
|
|
259
|
+
},
|
|
260
|
+
{
|
|
261
|
+
name: 'type',
|
|
262
|
+
type: 'text',
|
|
263
|
+
message: 'Enter icon MIME type',
|
|
264
|
+
initial: prev => getMime(prev),
|
|
265
|
+
validation: ['important'],
|
|
266
|
+
},
|
|
267
|
+
{
|
|
268
|
+
name: 'sizes',
|
|
269
|
+
type: 'text',
|
|
270
|
+
message: 'Enter icon sizes',
|
|
271
|
+
initial: (prev, answers) => getSize(answers.src),
|
|
272
|
+
validation: ['important'],
|
|
273
|
+
},
|
|
274
|
+
],
|
|
275
|
+
},
|
|
276
|
+
],
|
|
277
|
+
},
|
|
278
|
+
{
|
|
279
|
+
name: 'scope',
|
|
280
|
+
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
281
|
+
message: 'Specify the manifest scope',
|
|
282
|
+
initial: config.scope,
|
|
283
|
+
},
|
|
284
|
+
{
|
|
285
|
+
name: 'start_url',
|
|
286
|
+
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
287
|
+
message: 'Specify the application start URL',
|
|
288
|
+
initial: config.start_url,
|
|
289
|
+
},
|
|
290
|
+
{
|
|
291
|
+
name: 'lang',
|
|
292
|
+
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
293
|
+
message: 'Specify the application language',
|
|
294
|
+
initial: config.lang,
|
|
295
|
+
},
|
|
296
|
+
{
|
|
297
|
+
name: 'dir',
|
|
298
|
+
type: (prev, answers) => answers.__advanced ? 'text' : null,
|
|
299
|
+
message: 'Specify the application writing mode',
|
|
300
|
+
initial: config.dir,
|
|
301
|
+
},
|
|
302
|
+
{
|
|
303
|
+
name: 'related_applications',
|
|
304
|
+
type: (prev, answers) => answers.__advanced ? 'list' : null,
|
|
305
|
+
message: 'Specify related applications (comma-separated)',
|
|
306
|
+
initial: (config.related_applications || []).join(', '),
|
|
307
|
+
},
|
|
308
|
+
{
|
|
309
|
+
name: 'prefer_related_applications',
|
|
310
|
+
type: (prev, answers) => answers.related_applications ? 'toggle' : null,
|
|
311
|
+
message: 'Specify whether to "prefer" related applications',
|
|
312
|
+
active: 'YES',
|
|
313
|
+
inactive: 'NO',
|
|
314
|
+
initial: config.prefer_related_applications,
|
|
315
|
+
},
|
|
316
|
+
|
|
317
|
+
];
|
|
318
|
+
}
|
|
319
|
+
}
|