@webqit/webflo 0.8.76 → 0.9.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.
Files changed (97) hide show
  1. package/package.json +5 -12
  2. package/src/Cli.js +131 -0
  3. package/src/Configurator.js +97 -0
  4. package/src/Context.js +76 -0
  5. package/src/config-pi/deployment/Env.js +69 -0
  6. package/src/config-pi/deployment/Layout.js +65 -0
  7. package/src/config-pi/deployment/Origins.js +133 -0
  8. package/src/config-pi/deployment/Virtualization.js +65 -0
  9. package/src/config-pi/deployment/index.js +18 -0
  10. package/src/config-pi/index.js +16 -0
  11. package/src/config-pi/runtime/Client.js +59 -0
  12. package/src/config-pi/runtime/Server.js +174 -0
  13. package/src/config-pi/runtime/client/Worker.js +117 -0
  14. package/src/config-pi/runtime/client/index.js +12 -0
  15. package/src/config-pi/runtime/index.js +18 -0
  16. package/src/config-pi/runtime/server/Headers.js +90 -0
  17. package/src/config-pi/runtime/server/Redirects.js +108 -0
  18. package/src/config-pi/runtime/server/index.js +14 -0
  19. package/src/config-pi/static/Manifest.js +321 -0
  20. package/src/config-pi/static/Ssg.js +72 -0
  21. package/src/config-pi/static/index.js +14 -0
  22. package/src/deployment-pi/index.js +10 -0
  23. package/src/{services → deployment-pi}/origins/index.js +88 -58
  24. package/src/index.js +14 -147
  25. package/src/{runtime → runtime-pi}/Router.js +19 -19
  26. package/src/runtime-pi/client/Context.js +7 -0
  27. package/src/{runtime → runtime-pi}/client/Router.js +2 -2
  28. package/src/{runtime/client/Navigator.js → runtime-pi/client/Runtime.js} +143 -102
  29. package/src/runtime-pi/client/RuntimeClient.js +114 -0
  30. package/src/{runtime → runtime-pi}/client/Storage.js +8 -7
  31. package/src/{runtime → runtime-pi}/client/Url.js +2 -6
  32. package/src/{runtime/client/WorkerClient.js → runtime-pi/client/WorkerComm.js} +2 -2
  33. package/src/runtime-pi/client/generate.js +242 -0
  34. package/src/runtime-pi/client/generate.oohtml.js +7 -0
  35. package/src/runtime-pi/client/index.js +18 -0
  36. package/src/runtime-pi/client/whatwag.js +27 -0
  37. package/src/runtime-pi/client/worker/Context.js +7 -0
  38. package/src/runtime-pi/client/worker/Worker.js +243 -0
  39. package/src/runtime-pi/client/worker/WorkerClient.js +46 -0
  40. package/src/runtime-pi/client/worker/index.js +18 -0
  41. package/src/runtime-pi/index.js +14 -0
  42. package/src/runtime-pi/server/Context.js +16 -0
  43. package/src/{runtime → runtime-pi}/server/Router.js +6 -6
  44. package/src/runtime-pi/server/Runtime.js +531 -0
  45. package/src/runtime-pi/server/RuntimeClient.js +102 -0
  46. package/src/runtime-pi/server/index.js +41 -0
  47. package/src/runtime-pi/server/whatwag.js +35 -0
  48. package/src/{runtime → runtime-pi}/util.js +0 -0
  49. package/src/{runtime/_FormData.js → runtime-pi/xFormData.js} +2 -2
  50. package/src/{runtime/_Headers.js → runtime-pi/xHeaders.js} +4 -4
  51. package/src/runtime-pi/xHttpEvent.js +93 -0
  52. package/src/runtime-pi/xHttpMessage.js +179 -0
  53. package/src/runtime-pi/xRequest.js +67 -0
  54. package/src/runtime-pi/xRequestHeaders.js +95 -0
  55. package/src/runtime-pi/xResponse.js +62 -0
  56. package/src/{runtime/_ResponseHeaders.js → runtime-pi/xResponseHeaders.js} +38 -18
  57. package/src/{runtime/_URL.js → runtime-pi/xURL.js} +4 -4
  58. package/src/runtime-pi/xfetch.js +7 -0
  59. package/src/{services → services-pi}/certbot/http-auth-hook.js +0 -0
  60. package/src/{services → services-pi}/certbot/http-cleanup-hook.js +0 -0
  61. package/src/{services → services-pi}/certbot/index.js +21 -15
  62. package/src/services-pi/index.js +9 -0
  63. package/src/static-pi/index.js +11 -0
  64. package/src/webflo.js +33 -0
  65. package/test/index.test.js +26 -0
  66. package/src/build/client/index.js +0 -261
  67. package/src/build/index.js +0 -5
  68. package/src/config/client.js +0 -191
  69. package/src/config/headers.js +0 -121
  70. package/src/config/index.js +0 -14
  71. package/src/config/layout.js +0 -83
  72. package/src/config/manifest.js +0 -341
  73. package/src/config/origins.js +0 -165
  74. package/src/config/prerendering.js +0 -100
  75. package/src/config/redirects.js +0 -137
  76. package/src/config/server.js +0 -201
  77. package/src/config/variables.js +0 -102
  78. package/src/config/vhosts.js +0 -93
  79. package/src/runtime/_MessageStream.js +0 -195
  80. package/src/runtime/_NavigationEvent.js +0 -91
  81. package/src/runtime/_Request.js +0 -61
  82. package/src/runtime/_RequestHeaders.js +0 -72
  83. package/src/runtime/_Response.js +0 -56
  84. package/src/runtime/client/Cache.js +0 -38
  85. package/src/runtime/client/Http.js +0 -225
  86. package/src/runtime/client/NavigationEvent.js +0 -21
  87. package/src/runtime/client/Runtime.js +0 -126
  88. package/src/runtime/client/StdRequest.js +0 -74
  89. package/src/runtime/client/Worker.js +0 -312
  90. package/src/runtime/client/WorkerComm.js +0 -183
  91. package/src/runtime/client/effects/sounds.js +0 -64
  92. package/src/runtime/index.js +0 -5
  93. package/src/runtime/server/NavigationEvent.js +0 -39
  94. package/src/runtime/server/Runtime.js +0 -593
  95. package/src/runtime/server/index.js +0 -183
  96. package/src/runtime/server/index.mjs +0 -10
  97. package/src/services/index.js +0 -6
@@ -1,191 +0,0 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import Fs from 'fs';
6
- import Path from 'path';
7
- import _merge from '@webqit/util/obj/merge.js';
8
- import _before from '@webqit/util/str/before.js';
9
- import _after from '@webqit/util/str/after.js';
10
- import _isNumeric from '@webqit/util/js/isNumeric.js';
11
- import { DotJson, anyExists } from '@webqit/backpack/src/dotfiles/index.js';
12
-
13
- /**
14
- * Reads WORKER from file.
15
- *
16
- * @param object flags
17
- * @param object layout
18
- *
19
- * @return object
20
- */
21
- export async function read(flags = {}, layout = {}) {
22
- const ext = flags.env ? `.${flags.env}` : '';
23
- const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
24
- const fileName = ext => `${configDir}/client${ext}.json`;
25
- const availableExt = anyExists([ext, '', '.example'], fileName);
26
- const config = DotJson.read(fileName(availableExt));
27
- return _merge({
28
- bundling: {},
29
- // -----------------
30
- // SERVICE WORKER
31
- // -----------------
32
- worker: {
33
- scope: '/',
34
- cache_name: 'cache_v0',
35
- cache_only_url_list: [],
36
- cache_first_url_list: [],
37
- network_first_url_list: [],
38
- network_only_url_list: [],
39
- skip_waiting: false,
40
- lifecycle_logs: true,
41
- // -----------------
42
- support_push: false,
43
- push_registration_url: '',
44
- push_deregistration_url: '',
45
- push_public_key: '',
46
- bundling: {},
47
- },
48
- }, config);
49
- };
50
-
51
- /**
52
- * Writes WORKER to file.
53
- *
54
- * @param object config
55
- * @param object flags
56
- * @param object layout
57
- *
58
- * @return void
59
- */
60
- export async function write(config, flags = {}, layout = {}) {
61
- const ext = flags.env ? `.${flags.env}` : '';
62
- const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
63
- const fileName = ext => `${configDir}/client${ext}.json`;
64
- DotJson.write(config, fileName(ext));
65
- };
66
-
67
- /**
68
- * Configures WORKER.
69
- *
70
- * @param object config
71
- * @param object choices
72
- * @param object layout
73
- *
74
- * @return Array
75
- */
76
- export async function questions(config, choices = {}, layout = {}) {
77
-
78
- // Increment cache
79
- if (config.worker.cache_name && config.worker.cache_name.indexOf('_v') > -1 && _isNumeric(_after(config.worker.cache_name, '_v'))) {
80
- config.worker.cache_name = _before(config.worker.cache_name, '_v') + '_v' + (parseInt(_after(config.worker.cache_name, '_v')) + 1);
81
- }
82
-
83
- // Questions
84
- return [
85
- // -----------------
86
- // BUNDLING PARAMS
87
- // -----------------
88
- {
89
- name: 'bundling',
90
- initial: config.bundling,
91
- controls: {
92
- name: 'Bundling params',
93
- },
94
- questions: [],
95
- },
96
- // -----------------
97
- // SERVICE WORKER
98
- // -----------------
99
- {
100
- name: 'worker',
101
- initial: config.worker,
102
- controls: {
103
- name: 'Service Worker',
104
- },
105
- questions: [
106
- {
107
- name: 'scope',
108
- type: 'text',
109
- message: 'Specify the Service Worker scope',
110
- initial: config.scope,
111
- },
112
- {
113
- name: 'cache_name',
114
- type: 'text',
115
- message: 'Enter the Service Worker cache name',
116
- initial: config.cache_name,
117
- },
118
- {
119
- name: 'cache_only_url_list',
120
- type: 'list',
121
- message: 'Specify URLs for a "cache-only" fetching strategy (comma-separated, globe supported)',
122
- initial: (config.cache_only_url_list || []).join(', '),
123
- },
124
- {
125
- name: 'cache_first_url_list',
126
- type: 'list',
127
- message: 'Specify URLs for a "cache-first-then-network" fetching strategy (comma-separated, globe supported)',
128
- initial: (config.cache_first_url_list || []).join(', '),
129
- },
130
- {
131
- name: 'network_first_url_list',
132
- type: 'list',
133
- message: 'Specify URLs for a "network-first-then-cache" fetching strategy (comma-separated, globe supported)',
134
- initial: (config.network_first_url_list || []).join(', '),
135
- },
136
- {
137
- name: 'network_only_url_list',
138
- type: 'list',
139
- message: 'Specify URLs for a "network-only" fetching strategy (comma-separated, globe supported)',
140
- initial: (config.network_only_url_list || []).join(', '),
141
- },
142
- {
143
- name: 'skip_waiting',
144
- type: 'toggle',
145
- message: 'Choose whether to skip the "waiting" state for updated Service Workers',
146
- active: 'YES',
147
- inactive: 'NO',
148
- initial: config.skip_waiting,
149
- },
150
- {
151
- name: 'lifecycle_logs',
152
- type: 'toggle',
153
- message: 'Choose whether to show logs',
154
- active: 'YES',
155
- inactive: 'NO',
156
- initial: config.lifecycle_logs,
157
- },
158
- // ------------- notification --------------
159
- {
160
- name: 'support_push',
161
- type: 'toggle',
162
- message: 'Support push-notifications?',
163
- active: 'YES',
164
- inactive: 'NO',
165
- initial: config.support_push,
166
- },
167
- {
168
- name: 'push_registration_url',
169
- type: (prev, answers) => answers.support_push ? 'text' : null,
170
- message: 'Enter the URL for push notification subscription',
171
- initial: config.push_registration_url,
172
- validation: ['important'],
173
- },
174
- {
175
- name: 'push_deregistration_url',
176
- type: (prev, answers) => answers.support_push ? 'text' : null,
177
- message: 'Enter the URL for push notification unsubscription',
178
- initial: config.push_deregistration_url,
179
- validation: ['important'],
180
- },
181
- {
182
- name: 'push_key',
183
- type: (prev, answers) => answers.support_push ? 'text' : null,
184
- message: 'Enter the Public Key for push notification subscription',
185
- initial: config.push_key,
186
- validation: ['important'],
187
- },
188
- ],
189
- },
190
- ];
191
- };
@@ -1,121 +0,0 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import Fs from 'fs';
6
- import Url from 'url';
7
- import Path from 'path';
8
- import _merge from '@webqit/util/obj/merge.js';
9
- import _after from '@webqit/util/str/after.js';
10
- import _isObject from '@webqit/util/js/isObject.js';
11
- import { initialGetIndex } from '@webqit/backpack/src/cli/Promptx.js';
12
- import { DotJson, anyExists } from '@webqit/backpack/src/dotfiles/index.js';
13
- import Micromatch from 'micromatch';
14
-
15
- /**
16
- * Reads entries from file.
17
- *
18
- * @param object flags
19
- * @param object layout
20
- *
21
- * @return object
22
- */
23
- export async function read(flags = {}, layout = {}) {
24
- const ext = flags.env ? `.${flags.env}` : '';
25
- const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
26
- const fileName = ext => `${configDir}/headers${ext}.json`;
27
- const availableExt = anyExists([ext, '', '.example'], fileName);
28
- const config = DotJson.read(fileName(availableExt));
29
- return _merge({
30
- entries: [],
31
- }, config);
32
- };
33
-
34
- /**
35
- * Writes entries to file.
36
- *
37
- * @param object config
38
- * @param object flags
39
- * @param object layout
40
- *
41
- * @return void
42
- */
43
- export async function write(config, flags = {}, layout = {}) {
44
- const ext = flags.env ? `.${flags.env}` : '';
45
- const configDir = Path.join(layout.ROOT || ``, `./.webqit/webflo/config/`);
46
- const fileName = ext => `${configDir}/headers${ext}.json`;
47
- DotJson.write(config, fileName(ext));
48
- };
49
-
50
- /**
51
- * @match
52
- */
53
- export async function match(url, flags = {}, layout = {}) {
54
- if (!_isObject(url)) {
55
- url = Url.parse(url);
56
- }
57
- return ((await read(flags, layout)).entries || []).filter(header => {
58
- var regex = Micromatch.makeRe(header.url, {dot: true});
59
- var rootMatch = url.pathname.split('/').filter(seg => seg).map(seg => seg.trim()).reduce((str, seg) => str.endsWith(' ') ? str : ((str = str + '/' + seg) && str.match(regex) ? str + ' ' : str), '');
60
- return rootMatch.endsWith(' ');
61
- });
62
- };
63
-
64
- /**
65
- * Configures entries.
66
- *
67
- * @param object config
68
- * @param object choices
69
- * @param object layout
70
- *
71
- * @return Array
72
- */
73
- export async function questions(config, choices = {}, layout = {}) {
74
-
75
- const CHOICES = _merge({
76
- type: [
77
- {value: 'request', title: 'Request Header'},
78
- {value: 'response', title: 'Response Header'},
79
- ]
80
- }, choices);
81
-
82
- // Questions
83
- return [
84
- {
85
- name: 'entries',
86
- type: 'recursive',
87
- controls: {
88
- name: 'header',
89
- },
90
- initial: config.entries,
91
- questions: [
92
- {
93
- name: 'type',
94
- type: 'text',
95
- message: 'Choose header type',
96
- validation: ['important'],
97
- initial: function() { return initialGetIndex(CHOICES.type, this.value); },
98
- },
99
- {
100
- name: 'url',
101
- type: 'text',
102
- message: 'Enter URL',
103
- validation: ['important'],
104
- },
105
- {
106
- name: 'name',
107
- type: 'text',
108
- message: 'Enter header name',
109
- validation: ['important'],
110
- },
111
- {
112
- name: 'value',
113
- type: 'text',
114
- message: 'Enter header value',
115
- validation: ['important'],
116
- },
117
- ],
118
- },
119
-
120
- ];
121
- };
@@ -1,14 +0,0 @@
1
-
2
- /**
3
- * exports
4
- */
5
- export * as layout from './layout.js';
6
- export * as client from './client.js';
7
- export * as manifest from './manifest.js';
8
- export * as prerendering from './prerendering.js';
9
- export * as headers from './headers.js';
10
- export * as redirects from './redirects.js';
11
- export * as origins from './origins.js';
12
- export * as server from './server.js';
13
- export * as variables from './variables.js';
14
- export * as vhosts from './vhosts.js';
@@ -1,83 +0,0 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import Path from 'path';
6
- import _merge from '@webqit/util/obj/merge.js';
7
- import { DotJson } from '@webqit/backpack/src/dotfiles/index.js';
8
-
9
- /**
10
- * Reads PROJECT from file.
11
- *
12
- * @param object flags
13
- * @param object defaults
14
- *
15
- * @return object
16
- */
17
- export async function read(flags, defaults = {}) {
18
- const config = DotJson.read(Path.join(defaults.ROOT || '', './.webqit/webflo/config/setup.json'));
19
- return _merge({
20
- ROOT: defaults.ROOT || process.cwd(),
21
- PUBLIC_DIR: './public',
22
- SERVER_DIR: './server',
23
- CLIENT_DIR: './client',
24
- WORKER_DIR: './worker',
25
- }, config);
26
- };
27
-
28
- /**
29
- * Writes PROJECT to file.
30
- *
31
- * @param object config
32
- * @param object flags
33
- * @param object defaults
34
- *
35
- * @return void
36
- */
37
- export async function write(config, flags = {}, defaults = {}) {
38
- DotJson.write(config, Path.join(defaults.ROOT || '', './.webqit/webflo/config/setup.json'));
39
- };
40
-
41
- /**
42
- * Configures PROJECT.
43
- *
44
- * @param object config
45
- * @param object choices
46
- * @param object params
47
- *
48
- * @return Array
49
- */
50
- export async function questions(config, choices = {}, params = {}) {
51
-
52
- // Questions
53
- return [
54
- {
55
- name: 'PUBLIC_DIR',
56
- type: 'text',
57
- message: 'Enter the application\'s public directory',
58
- initial: config.PUBLIC_DIR,
59
- validation: ['important'],
60
- },
61
- {
62
- name: 'SERVER_DIR',
63
- type: 'text',
64
- message: 'Enter the directory for the application\'s server-side route handlers',
65
- initial: config.SERVER_DIR,
66
- validation: ['important'],
67
- },
68
- {
69
- name: 'CLIENT_DIR',
70
- type: 'text',
71
- message: 'Enter the directory for the application\'s client-side route handlers',
72
- initial: config.CLIENT_DIR,
73
- validation: ['important'],
74
- },
75
- {
76
- name: 'WORKER_DIR',
77
- type: 'text',
78
- message: 'Enter the directory for the application\'s offline route handlers',
79
- initial: config.WORKER_DIR,
80
- validation: ['important'],
81
- },
82
- ];
83
- };