@webqit/webflo 0.8.77 → 0.9.1

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} +148 -103
  29. package/src/runtime-pi/client/RuntimeClient.js +114 -0
  30. package/src/{runtime → runtime-pi}/client/Storage.js +1 -1
  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 +103 -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 -59
  82. package/src/runtime/_RequestHeaders.js +0 -72
  83. package/src/runtime/_Response.js +0 -56
  84. package/src/runtime/client/NavigationEvent.js +0 -21
  85. package/src/runtime/client/Runtime.js +0 -126
  86. package/src/runtime/client/Worker.js +0 -317
  87. package/src/runtime/client/archive/Cache.js +0 -38
  88. package/src/runtime/client/archive/Http.js +0 -225
  89. package/src/runtime/client/archive/StdRequest.js +0 -74
  90. package/src/runtime/client/archive/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,183 +0,0 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import Url from 'url';
6
- import Path from 'path';
7
- //import Pm2 from 'pm2';
8
- import _promise from '@webqit/util/js/promise.js';
9
- import * as DotJson from '@webqit/backpack/src/dotfiles/DotJson.js';
10
- import * as server from '../../config/server.js'
11
- import Runtime from './Runtime.js';
12
-
13
- /**
14
- * @description
15
- */
16
- export const desc = {
17
- start: 'Starts the Webflo server. (--p or --prod to run as a background process.)',
18
- stop: 'Stops a Webflo background process.',
19
- restart: 'Restarts a Webflo background process that has been stopped.',
20
- processes: 'Lists all Webflo background processes.',
21
- };
22
-
23
- /**
24
- * @start
25
- */
26
- export async function start(Ui, flags = {}, layout = {}) {
27
- const config = await server.read(flags, layout);
28
- const currentDir = Path.dirname(Url.fileURLToPath(import.meta.url));
29
- const script = Path.resolve(currentDir, './index.mjs');
30
- // -------------------
31
- // Splash screen
32
- // -------------------
33
- const showRunning = (processName = null, processAutoRestart = false) => {
34
- // -------------------
35
- // Splash screen
36
- // -------------------
37
- const WEBFLO = DotJson.read(Path.join(currentDir, '../../../package.json'));
38
- Ui.banner(WEBFLO.title, WEBFLO.version);
39
- Ui.log('');
40
- Ui.log(Ui.f`${'-------------------------------'}`);
41
- Ui.log('');
42
- const runtimeDetails = {
43
- HTTP: process.env.PORT ? `${process.env.PORT} (Overriding ${config.port})` : config.port,
44
- HTTPS: process.env.PORT2 ? `${process.env.PORT2} (Overriding ${config.https.port || 0})` : config.https.port || 0,
45
- };
46
- if (config.shared) {
47
- runtimeDetails.MODE = 'Virtual Hosts';
48
- } else {
49
- runtimeDetails.PUBLIC_DIR = layout.PUBLIC_DIR;
50
- runtimeDetails.SERVER_DIR = layout.SERVER_DIR;
51
- }
52
- Ui.log(Ui.f`${runtimeDetails}`);
53
- Ui.log('');
54
- Ui.log(Ui.f`${'-------------------------------'}`);
55
- Ui.log('');
56
- if (processName) {
57
- Ui.success(`Runtime running in ${Ui.style.keyword('production')}; ${(processAutoRestart ? 'will' : 'wo\'nt')} autorestart on crash!`);
58
- Ui.info(Ui.f`Process name: ${processName}`);
59
- Ui.log('');
60
- }
61
-
62
- };
63
-
64
- if (flags.env !== 'prod' && flags.watch) {
65
- var nodemon, ecpt;
66
- try {
67
- nodemon = await import(Path.resolve('./node_modules/nodemon/lib/nodemon.js'));
68
- } catch(e) {
69
- ecpt = e;
70
- }
71
- if (nodemon) {
72
- try {
73
- nodemon.default({script, ext: 'js json html'});
74
- showRunning();
75
- return;
76
- } catch(e) {
77
- throw e;
78
- }
79
- } else {
80
- Ui.error('Filesystem watch could not be enabled. ' + ecpt);
81
- }
82
- }
83
-
84
- if (flags.env === 'prod') {
85
- return new Promise(resolve => {
86
- Pm2.connect(true/* no_daemon_mode */, err => {
87
- if (err) {
88
- Ui.error(err);
89
- resolve();
90
- } else {
91
-
92
- var name = config.process.name,
93
- scriptArgs = ['__cmd__', '__keywords__'].concat(Object.keys(flags).map(f => '--' + f + (flags[f] === true ? '=TRUE' : (flags[f] === false ? '=FALSE' : (flags[f] !== undefined ? '=' + flags[f] : ''))))),
94
- exec_mode = config.process.exec_mode || 'fork',
95
- autorestart = 'AUTO_RESTART' in config ? config.process.autorestart : true,
96
- merge_logs = 'merge_logs' in config.process ? config.process.merge_logs : false,
97
- output = config.process.outfile || Path.resolve('./.webqit/webflo/runtime/output.log'),
98
- error = config.process.errfile || Path.resolve('./.webqit/webflo/runtime/error.log'),
99
- log_date_format = 'YYYY-MM-DD HH:mm Z',
100
- watch = flags.watch;
101
- const pm2Opts = { name, scriptArgs, watch, exec_mode, autorestart, merge_logs, output, error, log_date_format, force: true};
102
- Pm2.start(script, pm2Opts, err => {
103
- if (err) {
104
- Ui.error(err);
105
- } else {
106
- Ui.log('');
107
- showRunning(name, autorestart);
108
- }
109
- //Pm2.disconnect(resolve);
110
- });
111
- }
112
- });
113
- });
114
- }
115
- await Runtime.call(null, Ui, flags);
116
- showRunning();
117
- };
118
-
119
- /**
120
- * ----------
121
- * Stops a pm2 instance
122
- * ----------
123
- */
124
- export function stop(Ui, name, flags = {}) {
125
- return new Promise(resolve => {
126
- const cb = err => {
127
- if (err) {
128
- Ui.error(err);
129
- } else {
130
- Ui.success(Ui.f`Runtime ${flags.kill ? 'killed' : 'stopped'}: ${name}`);
131
- }
132
- resolve();
133
- };
134
- if (flags.kill) {
135
- //Pm2.kill(name, cb); API changed
136
- Pm2.kill(cb);
137
- } else {
138
- Pm2.stop(name, cb);
139
- }
140
- });
141
- };
142
-
143
- /**
144
- * ----------
145
- * Restarts a pm2 instance
146
- * ----------
147
- */
148
- export function restart(Ui, name, flags = {}) {
149
- return new Promise(resolve => {
150
- Pm2.restart(name, err => {
151
- if (err) {
152
- Ui.error(err);
153
- } else {
154
- Ui.success(Ui.f`Runtime restarted: ${name}`);
155
- }
156
- resolve();
157
- });
158
- });
159
- };
160
-
161
- /**
162
- * ----------
163
- * Lists pm2 instances
164
- * ----------
165
- */
166
- export function processes(Ui, flags = {}) {
167
- return new Promise(resolve => {
168
- Pm2.list((err, list) => {
169
- if (err) {
170
- Ui.error(err);
171
- resolve();
172
- } else {
173
- resolve(list.map(p => ({
174
- name: p.name,
175
- status: p.pm2_env.status,
176
- instances: p.pm2_env.instances,
177
- uptime: p.pm2_env.pm_uptime,
178
- created: p.pm2_env.created_at,
179
- })));
180
- }
181
- });
182
- });
183
- };
@@ -1,10 +0,0 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import parseArgs from '@webqit/backpack/src/cli/parseArgs.js';
6
- import Ui from '@webqit/backpack/src/cli/Ui.js';
7
- import Runtime from './Runtime.js';
8
-
9
- const { flags } = parseArgs(process.argv);
10
- Runtime.call(null, Ui, flags);
@@ -1,6 +0,0 @@
1
-
2
- /**
3
- * exports
4
- */
5
- export * as certbot from './certbot/index.js';
6
- export * as origins from './origins/index.js';