@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,80 +1,80 @@
1
-
2
- /**
3
- * imports
4
- */
5
- import Fs from 'fs';
6
- import { spawn } from 'child_process';
7
- import { _from as _arrFrom } from '@webqit/util/arr/index.js';
8
-
9
- /**
10
- * @description
11
- */
12
- export const desc = {
13
- generate: 'Generate an SSL cert for a domain or list of domains.',
14
- };
15
-
16
- /**
17
- * Reads SSL from file.
18
- *
19
- * @param string allDomains
20
- *
21
- * @return object
22
- */
23
- export async function generate(allDomains) {
24
- const cx = this || {};
25
- if (!cx.config.runtime?.Server) {
26
- throw new Error(`The Server configurator "config.runtime.Server" is required in context.`);
27
- }
28
- const domains = _arrFrom(allDomains).reduce((all, d) => all.concat(d.split(',')), []).filter(d => d.trim());
29
- const args = [
30
- 'certonly',
31
- '--manual',
32
- '--preferred-challenges', 'http',
33
- ].concat(domains.reduce((all, d) => all.concat('-d', d), []))
34
- .concat([
35
- '--manual-auth-hook', 'webflo-certbot-http-auth-hook',
36
- '--manual-cleanup-hook', 'webflo-certbot-http-cleanup-hook',
37
- '--debug-challenges',
38
- '--force-interactive',
39
- ]);
40
- const child = spawn('certbot', args);
41
- process.stdin.pipe(child.stdin);
42
-
43
- child.stdout.on('data', data => {
44
- if (cx.logger) {
45
- cx.logger.log('[' + cx.logger.style.keyword('CERTBOT') + '][' + cx.logger.style.var('OUT') + ']:', data + '');
46
- }
47
- });
48
-
49
- child.stderr.on('data', data => {
50
- if (cx.logger) {
51
- cx.logger.log('[' + cx.logger.style.keyword('CERTBOT') + '][' + cx.logger.style.err('ERR') + ']:', (data + '').trim());
52
- }
53
- });
54
-
55
- child.on('error', data => {
56
- cx.logger && cx.logger.error(data);
57
- process.exit();
58
- });
59
-
60
- child.on('exit', async exitCode => {
61
- const serverConfig = new cx.config.runtime.Server(cx);
62
- const server = await serverConfig.read();
63
- const domain = domains[0], certDir = `/etc/letsencrypt/live/${domain}`;
64
- if (!exitCode && cx.flags && (cx.flags['auto-config'] || cx.flags.c)) {
65
- if (Fs.existsSync(certDir)) {
66
- cx.logger && cx.logger.log('Automatically configuring the server with the generated cert.');
67
- if (!server.https) {
68
- server.https = {};
69
- }
70
- server.https.keyfile = `${certDir}/privkey.pem`;
71
- server.https.certfile = `${certDir}/fullchain.pem`;
72
- await serverConfig.write(server);
73
- } else {
74
- cx.logger && cx.logger.log(`Generated cert files not found in ${certDir}; be sure to configure the server with the valid cert files.`);
75
- }
76
- }
77
- process.exit();
78
- });
79
-
1
+
2
+ /**
3
+ * imports
4
+ */
5
+ import Fs from 'fs';
6
+ import { spawn } from 'child_process';
7
+ import { _from as _arrFrom } from '@webqit/util/arr/index.js';
8
+
9
+ /**
10
+ * @description
11
+ */
12
+ export const desc = {
13
+ generate: 'Generate an SSL cert for a domain or list of domains.',
14
+ };
15
+
16
+ /**
17
+ * Reads SSL from file.
18
+ *
19
+ * @param string allDomains
20
+ *
21
+ * @return object
22
+ */
23
+ export async function generate(allDomains) {
24
+ const cx = this || {};
25
+ if (!cx.config.runtime?.Server) {
26
+ throw new Error(`The Server configurator "config.runtime.Server" is required in context.`);
27
+ }
28
+ const domains = _arrFrom(allDomains).reduce((all, d) => all.concat(d.split(',')), []).filter(d => d.trim());
29
+ const args = [
30
+ 'certonly',
31
+ '--manual',
32
+ '--preferred-challenges', 'http',
33
+ ].concat(domains.reduce((all, d) => all.concat('-d', d), []))
34
+ .concat([
35
+ '--manual-auth-hook', 'webflo-certbot-http-auth-hook',
36
+ '--manual-cleanup-hook', 'webflo-certbot-http-cleanup-hook',
37
+ '--debug-challenges',
38
+ '--force-interactive',
39
+ ]);
40
+ const child = spawn('certbot', args);
41
+ process.stdin.pipe(child.stdin);
42
+
43
+ child.stdout.on('data', data => {
44
+ if (cx.logger) {
45
+ cx.logger.log('[' + cx.logger.style.keyword('CERTBOT') + '][' + cx.logger.style.var('OUT') + ']:', data + '');
46
+ }
47
+ });
48
+
49
+ child.stderr.on('data', data => {
50
+ if (cx.logger) {
51
+ cx.logger.log('[' + cx.logger.style.keyword('CERTBOT') + '][' + cx.logger.style.err('ERR') + ']:', (data + '').trim());
52
+ }
53
+ });
54
+
55
+ child.on('error', data => {
56
+ cx.logger && cx.logger.error(data);
57
+ process.exit();
58
+ });
59
+
60
+ child.on('exit', async exitCode => {
61
+ const serverConfig = new cx.config.runtime.Server(cx);
62
+ const server = await serverConfig.read();
63
+ const domain = domains[0], certDir = `/etc/letsencrypt/live/${domain}`;
64
+ if (!exitCode && cx.flags && (cx.flags['auto-config'] || cx.flags.c)) {
65
+ if (Fs.existsSync(certDir)) {
66
+ cx.logger && cx.logger.log('Automatically configuring the server with the generated cert.');
67
+ if (!server.https) {
68
+ server.https = {};
69
+ }
70
+ server.https.keyfile = `${certDir}/privkey.pem`;
71
+ server.https.certfile = `${certDir}/fullchain.pem`;
72
+ await serverConfig.write(server);
73
+ } else {
74
+ cx.logger && cx.logger.log(`Generated cert files not found in ${certDir}; be sure to configure the server with the valid cert files.`);
75
+ }
76
+ }
77
+ process.exit();
78
+ });
79
+
80
80
  }
@@ -1,9 +1,9 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import * as certbot from './certbot/index.js';
6
-
7
- export {
8
- certbot,
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import * as certbot from './certbot/index.js';
6
+
7
+ export {
8
+ certbot,
9
9
  }
@@ -1,11 +1,11 @@
1
-
2
- /**
3
- * @imports
4
- import * as client from './client/index.js';
5
- import * as server from './server/index.js';
6
- */
7
-
8
- export {
9
- //client,
10
- //server,
1
+
2
+ /**
3
+ * @imports
4
+ import * as client from './client/index.js';
5
+ import * as server from './server/index.js';
6
+ */
7
+
8
+ export {
9
+ //client,
10
+ //server,
11
11
  }
package/src/webflo.js CHANGED
@@ -1,31 +1,31 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * @imports
5
- */
6
- import Url from 'url';
7
- import Path from 'path';
8
- import { jsonFile } from '@webqit/backpack/src/dotfile/index.js';
9
- import { Logger, Cli } from '@webqit/backpack';
10
- import * as WebfloPI from './index.js';
11
-
12
- const dirSelf = Path.dirname(Url.fileURLToPath(import.meta.url));
13
- const webfloJson = jsonFile.read(Path.join(dirSelf, '../package.json'));
14
- const appJson = jsonFile.read('./package.json');
15
-
16
- /**
17
- * @cx
18
- */
19
- const cx = WebfloPI.Context.create({
20
- meta: { title: webfloJson.title, version: webfloJson.version },
21
- app: { title: appJson.title, version: appJson.version },
22
- logger: Logger,
23
- config: WebfloPI.config,
24
- middlewares: [ WebfloPI.deployment.origins.webhook, ],
25
- });
26
-
27
- /**
28
- * @cli
29
- */
30
- const cli = new Cli(WebfloPI);
31
- await cli.exec(cx);
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * @imports
5
+ */
6
+ import Url from 'url';
7
+ import Path from 'path';
8
+ import { jsonFile } from '@webqit/backpack/src/dotfile/index.js';
9
+ import { Logger, Cli } from '@webqit/backpack';
10
+ import * as WebfloPI from './index.js';
11
+
12
+ const dirSelf = Path.dirname(Url.fileURLToPath(import.meta.url));
13
+ const webfloJson = jsonFile.read(Path.join(dirSelf, '../package.json'));
14
+ const appJson = jsonFile.read('./package.json');
15
+
16
+ /**
17
+ * @cx
18
+ */
19
+ const cx = WebfloPI.Context.create({
20
+ meta: { title: webfloJson.title, version: webfloJson.version },
21
+ app: { title: appJson.title, version: appJson.version },
22
+ logger: Logger,
23
+ config: WebfloPI.config,
24
+ middlewares: [ WebfloPI.deployment.origins.webhook, ],
25
+ });
26
+
27
+ /**
28
+ * @cli
29
+ */
30
+ const cli = new Cli(WebfloPI);
31
+ await cli.exec(cx);
@@ -1,25 +1,26 @@
1
- /**
2
- * @imports
3
- */
4
- import { config, runtime, Context } from '../src/index.js';
5
-
6
- let client = {
7
- handle: function(httpEvent) {
8
- return new httpEvent.Response({ abcd: '1234' }, {
9
- status: 302,
10
- headers: {
11
- //location: '/dddd',
12
- cookies: {
13
- cookie1: { value: 'value1' },
14
- cookie2: { value: 'value2' },
15
- }
16
- }
17
- });
18
- },
19
- };
20
-
21
- const cx = Context.create({ config: config, });
22
- const clientCallback = (_cx, hostName, defaultClientCallback) => client;
23
- const app = await runtime.server.start.call(cx, clientCallback);
24
-
25
- const response = await app.go('http://localhost/', { headers: { range: 'bytes=0-5, 6' } } );
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import { config, runtime, Context } from '../src/index.js';
6
+
7
+ let client = {
8
+ handle: function( httpEvent ) {
9
+ return new httpEvent.Response({ abcd: '1234' }, {
10
+ status: 302,
11
+ headers: {
12
+ //location: '/dddd',
13
+ cookies: {
14
+ cookie1: { value: 'value1' },
15
+ cookie2: { value: 'value2' },
16
+ }
17
+ }
18
+ });
19
+ },
20
+ };
21
+
22
+ const cx = Context.create( { config: config, } );
23
+ const clientCallback = ( _cx, hostName, defaultClientCallback ) => client;
24
+ const app = await runtime.server.start.call( cx, clientCallback );
25
+
26
+ const response = await app.go( 'http://localhost/', { headers: { range: 'bytes=0-5, 6' } } );
@@ -1,9 +1,9 @@
1
- {
2
- "title": "Webflo Test",
3
- "type": "module",
4
- "scripts": {
5
- "generate": "webflo generate::client --recursive --compression --auto-embed",
6
- "bundle": "cd public && oohtml bundle --recursive --auto-embed=routes",
7
- "build": "npm run generate && npm run bundle"
8
- }
9
- }
1
+ {
2
+ "title": "Webflo Test",
3
+ "type": "module",
4
+ "scripts": {
5
+ "generate": "webflo generate::client --recursive --compression --auto-embed",
6
+ "bundle": "cd public && oohtml bundle --recursive --auto-embed=routes",
7
+ "build": "npm run generate && npm run bundle"
8
+ }
9
+ }
@@ -1,6 +1,6 @@
1
-
2
- <template name="page-3">
3
- <img src="/page-3/logo-130x130.png" exportgroup="logo-130x130.png" />
4
- </template>
5
- <template name="page-4">
1
+
2
+ <template name="page-3">
3
+ <img src="/page-3/logo-130x130.png" exportgroup="logo-130x130.png" />
4
+ </template>
5
+ <template name="page-4">
6
6
  </template>
@@ -1,4 +1,4 @@
1
- {
2
- "page-3": {},
3
- "page-4": {}
1
+ {
2
+ "page-3": {},
3
+ "page-4": {}
4
4
  }
@@ -1,2 +1,2 @@
1
- /** @webqit/webflo */
2
- var{start:e}=WebQit.Webflo,r={},o={bundle_filename:"bundle.js",public_base_url:"/",spa_routing:!0,oohtml_support:"full",service_worker_support:!0,worker_scope:"/",worker_filename:"worker.js",routing:{root:"/",subroots:["/page-2","/page-4/subpage"],targets:2}};e.call({layout:r,params:o});
1
+ /** @webqit/webflo */
2
+ var{start:e}=WebQit.Webflo,r={},o={bundle_filename:"bundle.js",public_base_url:"/",spa_routing:!0,oohtml_support:"full",service_worker_support:!0,worker_scope:"/",worker_filename:"worker.js",routing:{root:"/",subroots:["/page-2","/page-4/subpage"],targets:2}};e.call({layout:r,params:o});