@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,128 +1,128 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
- import { Dotfile } from '@webqit/backpack';
7
-
8
- export default class Server extends Dotfile {
9
-
10
- // Base name
11
- get name() {
12
- return 'server';
13
- }
14
-
15
- // @desc
16
- static get ['@desc']() {
17
- return 'Server Runtime config.';
18
- }
19
-
20
- // Defaults merger
21
- withDefaults(config) {
22
- return _merge(true, {
23
- port: process.env.port || 3000,
24
- https: {
25
- port: 0,
26
- keyfile: '',
27
- certfile: '',
28
- certdoms: ['*'],
29
- force: false,
30
- },
31
- force_www: '',
32
- oohtml_support: 'full',
33
- shared: false,
34
- }, config);
35
- }
36
-
37
- // Questions generator
38
- questions(config, choices = {}) {
39
- // Choices
40
- const CHOICES = _merge({
41
- force_www: [
42
- {value: '', title: 'do nothing'},
43
- {value: 'add',},
44
- {value: 'remove',},
45
- ],
46
- oohtml_support: [
47
- {value: 'full', title: 'full'},
48
- {value: 'namespacing', title: 'namespacing'},
49
- {value: 'scripting', title: 'scripting'},
50
- {value: 'templating', title: 'templating'},
51
- {value: 'none', title: 'none'},
52
- ],
53
- }, choices);
54
- // Questions
55
- return [
56
- {
57
- name: 'port',
58
- type: 'number',
59
- message: '[port]: Enter port number',
60
- initial: config.port,
61
- validation: ['important'],
62
- },
63
- {
64
- name: 'https',
65
- controls: {
66
- name: 'https',
67
- },
68
- initial: config.https,
69
- questions: [
70
- {
71
- name: 'port',
72
- type: 'number',
73
- message: '[port]: Enter HTTPS port number',
74
- validation: ['important'],
75
- },
76
- {
77
- name: 'keyfile',
78
- type: 'text',
79
- message: '[keyfile]: Enter SSL KEY file',
80
- validation: ['important'],
81
- },
82
- {
83
- name: 'certfile',
84
- type: 'text',
85
- message: '[certfile]: Enter SSL CERT file',
86
- validation: ['important'],
87
- },
88
- {
89
- name: 'certdoms',
90
- type: 'list',
91
- message: '[certdoms]: Enter the CERT domains (comma-separated)',
92
- validation: ['important'],
93
- },
94
- {
95
- name: 'force',
96
- type: 'toggle',
97
- message: '[force]: Force HTTPS?',
98
- active: 'YES',
99
- inactive: 'NO',
100
- },
101
- ],
102
- },
103
- {
104
- name: 'force_www',
105
- type: 'select',
106
- message: '[force_www]: Force add/remove "www" on hostname?',
107
- choices: CHOICES.force_www,
108
- initial: this.indexOfInitial(CHOICES.force_www, config.force_www),
109
- },
110
- {
111
- name: 'oohtml_support',
112
- type: 'select',
113
- message: '[oohtml_support]: Specify OOHTML support level',
114
- choices: CHOICES.oohtml_support,
115
- initial: this.indexOfInitial(CHOICES.oohtml_support, config.oohtml_support),
116
- validation: ['important'],
117
- },
118
- {
119
- name: 'shared',
120
- type: 'toggle',
121
- message: '[shared]: Shared server?',
122
- active: 'YES',
123
- inactive: 'NO',
124
- initial: config.shared,
125
- },
126
- ];
127
- }
128
- }
1
+
2
+ /**
3
+ * imports
4
+ */
5
+ import { _merge } from '@webqit/util/obj/index.js';
6
+ import { Dotfile } from '@webqit/backpack';
7
+
8
+ export default class Server extends Dotfile {
9
+
10
+ // Base name
11
+ get name() {
12
+ return 'server';
13
+ }
14
+
15
+ // @desc
16
+ static get ['@desc']() {
17
+ return 'Server Runtime config.';
18
+ }
19
+
20
+ // Defaults merger
21
+ withDefaults(config) {
22
+ return _merge(true, {
23
+ port: process.env.port || 3000,
24
+ https: {
25
+ port: 0,
26
+ keyfile: '',
27
+ certfile: '',
28
+ certdoms: ['*'],
29
+ force: false,
30
+ },
31
+ force_www: '',
32
+ oohtml_support: 'full',
33
+ shared: false,
34
+ }, config);
35
+ }
36
+
37
+ // Questions generator
38
+ questions(config, choices = {}) {
39
+ // Choices
40
+ const CHOICES = _merge({
41
+ force_www: [
42
+ {value: '', title: 'do nothing'},
43
+ {value: 'add',},
44
+ {value: 'remove',},
45
+ ],
46
+ oohtml_support: [
47
+ {value: 'full', title: 'full'},
48
+ {value: 'namespacing', title: 'namespacing'},
49
+ {value: 'scripting', title: 'scripting'},
50
+ {value: 'templating', title: 'templating'},
51
+ {value: 'none', title: 'none'},
52
+ ],
53
+ }, choices);
54
+ // Questions
55
+ return [
56
+ {
57
+ name: 'port',
58
+ type: 'number',
59
+ message: '[port]: Enter port number',
60
+ initial: config.port,
61
+ validation: ['important'],
62
+ },
63
+ {
64
+ name: 'https',
65
+ controls: {
66
+ name: 'https',
67
+ },
68
+ initial: config.https,
69
+ questions: [
70
+ {
71
+ name: 'port',
72
+ type: 'number',
73
+ message: '[port]: Enter HTTPS port number',
74
+ validation: ['important'],
75
+ },
76
+ {
77
+ name: 'keyfile',
78
+ type: 'text',
79
+ message: '[keyfile]: Enter SSL KEY file',
80
+ validation: ['important'],
81
+ },
82
+ {
83
+ name: 'certfile',
84
+ type: 'text',
85
+ message: '[certfile]: Enter SSL CERT file',
86
+ validation: ['important'],
87
+ },
88
+ {
89
+ name: 'certdoms',
90
+ type: 'list',
91
+ message: '[certdoms]: Enter the CERT domains (comma-separated)',
92
+ validation: ['important'],
93
+ },
94
+ {
95
+ name: 'force',
96
+ type: 'toggle',
97
+ message: '[force]: Force HTTPS?',
98
+ active: 'YES',
99
+ inactive: 'NO',
100
+ },
101
+ ],
102
+ },
103
+ {
104
+ name: 'force_www',
105
+ type: 'select',
106
+ message: '[force_www]: Force add/remove "www" on hostname?',
107
+ choices: CHOICES.force_www,
108
+ initial: this.indexOfInitial(CHOICES.force_www, config.force_www),
109
+ },
110
+ {
111
+ name: 'oohtml_support',
112
+ type: 'select',
113
+ message: '[oohtml_support]: Specify OOHTML support level',
114
+ choices: CHOICES.oohtml_support,
115
+ initial: this.indexOfInitial(CHOICES.oohtml_support, config.oohtml_support),
116
+ validation: ['important'],
117
+ },
118
+ {
119
+ name: 'shared',
120
+ type: 'toggle',
121
+ message: '[shared]: Shared server?',
122
+ active: 'YES',
123
+ inactive: 'NO',
124
+ initial: config.shared,
125
+ },
126
+ ];
127
+ }
128
+ }
@@ -1,135 +1,135 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import { _merge } from '@webqit/util/obj/index.js';
6
- import { _isNumeric } from '@webqit/util/js/index.js';
7
- import { _before, _after } from '@webqit/util/str/index.js';
8
- import { Dotfile } from '@webqit/backpack';
9
-
10
- export default class Worker extends Dotfile {
11
-
12
- // Base name
13
- get name() {
14
- return 'worker';
15
- }
16
-
17
- // @desc
18
- static get ['@desc']() {
19
- return 'Application Service Worker config.';
20
- }
21
-
22
- // Defaults merger
23
- withDefaults(config) {
24
- return _merge(true, {
25
- cache_name: 'cache_v0',
26
- default_fetching_strategy: 'network-first',
27
- network_first_urls: [],
28
- cache_first_urls: [],
29
- network_only_urls: [],
30
- cache_only_urls: [],
31
- skip_waiting: false,
32
- // -----------------
33
- support_push: false,
34
- push_registration_url: '',
35
- push_deregistration_url: '',
36
- push_public_key: '',
37
- }, config);
38
- }
39
-
40
- // Questions generator
41
- questions(config, choices = {}) {
42
- // Increment cache
43
- if (config.cache_name && config.cache_name.indexOf('_v') > -1 && _isNumeric(_after(config.cache_name, '_v'))) {
44
- config.cache_name = _before(config.cache_name, '_v') + '_v' + (parseInt(_after(config.cache_name, '_v')) + 1);
45
- }
46
- // Choices
47
- const CHOICES = _merge({
48
- default_fetching_strategy: [
49
- {value: 'network-first', title: 'Network-first (Webflo default)'},
50
- {value: 'cache-first', title: 'Cache-first'},
51
- {value: 'network-only', title: 'Network-only'},
52
- {value: 'cache-only', title: 'Cache-only'},
53
- ],
54
- }, choices);
55
- // Questions
56
- return [
57
- {
58
- name: 'cache_name',
59
- type: 'text',
60
- message: 'Enter the Service Worker cache name',
61
- initial: config.cache_name,
62
- },
63
- {
64
- name: 'default_fetching_strategy',
65
- type: 'select',
66
- message: '[default_fetching_strategy]: Choose the default fetching strategy',
67
- choices: CHOICES.default_fetching_strategy,
68
- initial: this.indexOfInitial(CHOICES.default_fetching_strategy, config.default_fetching_strategy),
69
- validation: ['important'],
70
- },
71
- {
72
- name: 'network_first_urls',
73
- type: (prev, answers) => answers.default_fetching_strategy === 'network-first' ? null : 'list',
74
- message: 'Specify URLs for a "network-first-then-cache" fetching strategy (comma-separated, globe supported)',
75
- initial: (config.network_first_urls || []).join(', '),
76
- },
77
- {
78
- name: 'cache_first_urls',
79
- type: (prev, answers) => answers.default_fetching_strategy === 'cache-first' ? null : 'list',
80
- message: 'Specify URLs for a "cache-first-then-network" fetching strategy (comma-separated, globe supported)',
81
- initial: (config.cache_first_urls || []).join(', '),
82
- },
83
- {
84
- name: 'network_only_urls',
85
- type: (prev, answers) => answers.default_fetching_strategy === 'network-only' ? null : 'list',
86
- message: 'Specify URLs for a "network-only" fetching strategy (comma-separated, globe supported)',
87
- initial: (config.network_only_urls || []).join(', '),
88
- },
89
- {
90
- name: 'cache_only_urls',
91
- type: (prev, answers) => answers.default_fetching_strategy === 'cache-only' ? null : 'list',
92
- message: 'Specify URLs for a "cache-only" fetching strategy (comma-separated, globe supported)',
93
- initial: (config.cache_only_urls || []).join(', '),
94
- },
95
- {
96
- name: 'skip_waiting',
97
- type: 'toggle',
98
- message: 'Choose whether to skip the "waiting" state for updated Service Workers',
99
- active: 'YES',
100
- inactive: 'NO',
101
- initial: config.skip_waiting,
102
- },
103
- // ------------- notification --------------
104
- {
105
- name: 'support_push',
106
- type: 'toggle',
107
- message: 'Support push-notifications?',
108
- active: 'YES',
109
- inactive: 'NO',
110
- initial: config.support_push,
111
- },
112
- {
113
- name: 'push_registration_url',
114
- type: (prev, answers) => answers.support_push ? 'text' : null,
115
- message: 'Enter the URL for push notification subscription',
116
- initial: config.push_registration_url,
117
- validation: ['important'],
118
- },
119
- {
120
- name: 'push_deregistration_url',
121
- type: (prev, answers) => answers.support_push ? 'text' : null,
122
- message: 'Enter the URL for push notification unsubscription',
123
- initial: config.push_deregistration_url,
124
- validation: ['important'],
125
- },
126
- {
127
- name: 'push_key',
128
- type: (prev, answers) => answers.support_push ? 'text' : null,
129
- message: 'Enter the Public Key for push notification subscription',
130
- initial: config.push_key,
131
- validation: ['important'],
132
- },
133
- ];
134
- }
135
- }
1
+
2
+ /**
3
+ * imports
4
+ */
5
+ import { _merge } from '@webqit/util/obj/index.js';
6
+ import { _isNumeric } from '@webqit/util/js/index.js';
7
+ import { _before, _after } from '@webqit/util/str/index.js';
8
+ import { Dotfile } from '@webqit/backpack';
9
+
10
+ export default class Worker extends Dotfile {
11
+
12
+ // Base name
13
+ get name() {
14
+ return 'worker';
15
+ }
16
+
17
+ // @desc
18
+ static get ['@desc']() {
19
+ return 'Application Service Worker config.';
20
+ }
21
+
22
+ // Defaults merger
23
+ withDefaults(config) {
24
+ return _merge(true, {
25
+ cache_name: 'cache_v0',
26
+ default_fetching_strategy: 'network-first',
27
+ network_first_urls: [],
28
+ cache_first_urls: [],
29
+ network_only_urls: [],
30
+ cache_only_urls: [],
31
+ skip_waiting: false,
32
+ // -----------------
33
+ support_push: false,
34
+ push_registration_url: '',
35
+ push_deregistration_url: '',
36
+ push_public_key: '',
37
+ }, config);
38
+ }
39
+
40
+ // Questions generator
41
+ questions(config, choices = {}) {
42
+ // Increment cache
43
+ if (config.cache_name && config.cache_name.indexOf('_v') > -1 && _isNumeric(_after(config.cache_name, '_v'))) {
44
+ config.cache_name = _before(config.cache_name, '_v') + '_v' + (parseInt(_after(config.cache_name, '_v')) + 1);
45
+ }
46
+ // Choices
47
+ const CHOICES = _merge({
48
+ default_fetching_strategy: [
49
+ {value: 'network-first', title: 'Network-first (Webflo default)'},
50
+ {value: 'cache-first', title: 'Cache-first'},
51
+ {value: 'network-only', title: 'Network-only'},
52
+ {value: 'cache-only', title: 'Cache-only'},
53
+ ],
54
+ }, choices);
55
+ // Questions
56
+ return [
57
+ {
58
+ name: 'cache_name',
59
+ type: 'text',
60
+ message: 'Enter the Service Worker cache name',
61
+ initial: config.cache_name,
62
+ },
63
+ {
64
+ name: 'default_fetching_strategy',
65
+ type: 'select',
66
+ message: '[default_fetching_strategy]: Choose the default fetching strategy',
67
+ choices: CHOICES.default_fetching_strategy,
68
+ initial: this.indexOfInitial(CHOICES.default_fetching_strategy, config.default_fetching_strategy),
69
+ validation: ['important'],
70
+ },
71
+ {
72
+ name: 'network_first_urls',
73
+ type: (prev, answers) => answers.default_fetching_strategy === 'network-first' ? null : 'list',
74
+ message: 'Specify URLs for a "network-first-then-cache" fetching strategy (comma-separated, globe supported)',
75
+ initial: (config.network_first_urls || []).join(', '),
76
+ },
77
+ {
78
+ name: 'cache_first_urls',
79
+ type: (prev, answers) => answers.default_fetching_strategy === 'cache-first' ? null : 'list',
80
+ message: 'Specify URLs for a "cache-first-then-network" fetching strategy (comma-separated, globe supported)',
81
+ initial: (config.cache_first_urls || []).join(', '),
82
+ },
83
+ {
84
+ name: 'network_only_urls',
85
+ type: (prev, answers) => answers.default_fetching_strategy === 'network-only' ? null : 'list',
86
+ message: 'Specify URLs for a "network-only" fetching strategy (comma-separated, globe supported)',
87
+ initial: (config.network_only_urls || []).join(', '),
88
+ },
89
+ {
90
+ name: 'cache_only_urls',
91
+ type: (prev, answers) => answers.default_fetching_strategy === 'cache-only' ? null : 'list',
92
+ message: 'Specify URLs for a "cache-only" fetching strategy (comma-separated, globe supported)',
93
+ initial: (config.cache_only_urls || []).join(', '),
94
+ },
95
+ {
96
+ name: 'skip_waiting',
97
+ type: 'toggle',
98
+ message: 'Choose whether to skip the "waiting" state for updated Service Workers',
99
+ active: 'YES',
100
+ inactive: 'NO',
101
+ initial: config.skip_waiting,
102
+ },
103
+ // ------------- notification --------------
104
+ {
105
+ name: 'support_push',
106
+ type: 'toggle',
107
+ message: 'Support push-notifications?',
108
+ active: 'YES',
109
+ inactive: 'NO',
110
+ initial: config.support_push,
111
+ },
112
+ {
113
+ name: 'push_registration_url',
114
+ type: (prev, answers) => answers.support_push ? 'text' : null,
115
+ message: 'Enter the URL for push notification subscription',
116
+ initial: config.push_registration_url,
117
+ validation: ['important'],
118
+ },
119
+ {
120
+ name: 'push_deregistration_url',
121
+ type: (prev, answers) => answers.support_push ? 'text' : null,
122
+ message: 'Enter the URL for push notification unsubscription',
123
+ initial: config.push_deregistration_url,
124
+ validation: ['important'],
125
+ },
126
+ {
127
+ name: 'push_key',
128
+ type: (prev, answers) => answers.support_push ? 'text' : null,
129
+ message: 'Enter the Public Key for push notification subscription',
130
+ initial: config.push_key,
131
+ validation: ['important'],
132
+ },
133
+ ];
134
+ }
135
+ }
@@ -1,12 +1,12 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import Worker from './Worker.js';
6
-
7
- /**
8
- * @exports
9
- */
10
- export {
11
- Worker,
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import Worker from './Worker.js';
6
+
7
+ /**
8
+ * @exports
9
+ */
10
+ export {
11
+ Worker,
12
12
  }
@@ -1,18 +1,18 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import Client from './Client.js';
6
- import Server from './Server.js';
7
- import * as client from './client/index.js';
8
- import * as server from './server/index.js';
9
-
10
- /**
11
- * @exports
12
- */
13
- export {
14
- Client,
15
- Server,
16
- client,
17
- server,
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import Client from './Client.js';
6
+ import Server from './Server.js';
7
+ import * as client from './client/index.js';
8
+ import * as server from './server/index.js';
9
+
10
+ /**
11
+ * @exports
12
+ */
13
+ export {
14
+ Client,
15
+ Server,
16
+ client,
17
+ server,
18
18
  }