@webqit/webflo 0.11.21 → 0.11.24

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