@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,110 +1,110 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { _after, _beforeLast } from "@webqit/util/str/index.js";
6
- import { _isString, _getType, _isObject } from "@webqit/util/js/index.js";
7
- import _Headers from './xHeaders.js';
8
-
9
- /**
10
- * The _Headers Mixin
11
- */
12
- const _ResponseHeaders = NativeHeaders => class extends _Headers(NativeHeaders) {
13
-
14
- set cookies(cookieJar) {
15
- if (!_isObject(cookieJar)) {
16
- throw new Error(`The "cookies" response directive cannot be of type: ${_getType(cookieJar)}`);
17
- }
18
- for (let cookieName in cookieJar) {
19
- let cookieBody = cookieJar[cookieName];
20
- if (_isObject(cookieBody)) {
21
- let attrsArr = [ cookieBody.value ];
22
- for (let attrName in cookieBody) {
23
- if (attrName === 'value') continue;
24
- let _attrName = attrName[0].toUpperCase() + attrName.substring(1);
25
- if (_attrName === 'MaxAge') { _attrName = 'Max-Age' };
26
- attrsArr.push(cookieBody[attrName] === true ? _attrName : `${_attrName}=${cookieBody[attrName]}`);
27
- }
28
- cookieBody = attrsArr.join('; ');
29
- }
30
- this.append('Set-Cookie', `${cookieName}=${cookieBody}`);
31
- }
32
- return true;
33
- }
34
-
35
- get cookies() {
36
- const cookiesStr = this.get('Set-Cookie');
37
- return cookiesStr && cookiesStr.split(',').reduce((cookieJar, str) => {
38
- let [ cookieDefinition, attrsStr ] = str.split(';');
39
- let [ cookieName, cookieValue ] = cookieDefinition.trim().split('=');
40
- cookieJar[cookieName] = { value: cookieValue, };
41
- if (attrsStr) {
42
- (attrsStr || '').split(/\;/g).map(attrStr => attrStr.trim().split('=')).forEach(attrsArr => {
43
- cookieJar[cookieName][attrsArr[0][0].toLowerCase() + attrsArr[0].substring(1).replace('-', '')] = attrsArr.length === 1 ? true : attrsArr[1];
44
- });
45
- }
46
- return cookieJar;
47
- }, {});
48
- }
49
-
50
- set contentRange(value) {
51
- if (Array.isArray(value)) {
52
- if ((value.length === 2 && !value[0].includes('-')) || value.length < 2) {
53
- throw new Error(`A Content-Range array must be in the format: [ 'start-end', 'total' ]`);
54
- }
55
- return this.set('Content-Range', `bytes ${value.join('/')}`);
56
- }
57
- return this.set('Content-Range', value);
58
- }
59
-
60
- get contentRange() {
61
- const value = this.get('Content-Range');
62
- return value && _after(value, 'bytes ').split('/');
63
- }
64
-
65
- set cors(value) {
66
- return this.set('Access-Control-Allow-Origin', value === true ? '*' : (value === false ? '' : value));
67
- }
68
-
69
- get cors() {
70
- return this.get('Access-Control-Allow-Origin');
71
- }
72
-
73
- set attachment(value) {
74
- value = value === true ? 'attachment' : (value === false ? 'inline' : value);
75
- if (!_isString(value)) {
76
- throw new Error(`The "download" response directive does not support the type: ${_getType(value)}`);
77
- }
78
- if (![ 'attachment', 'inline' ].includes(value)) {
79
- value = `attachment; filename="${value}"`;
80
- }
81
- return this.set('Content-Disposition', value);
82
- }
83
-
84
- get attachment() {
85
- var value = (this.get('Content-Disposition') || '').trim();
86
- value = value === 'attachment' ? true : (
87
- value === 'inline' ? false : _after(_beforeLast(value, '"'), 'filename="')
88
- );
89
- return value;
90
- }
91
-
92
- get location() {
93
- return this.get('Location');
94
- }
95
-
96
- set location(value) {
97
- return this.set('Location', value);
98
- }
99
-
100
- get redirect() {
101
- return this.get('Location');
102
- }
103
-
104
- set redirect(value) {
105
- return this.set('Location', value);
106
- }
107
-
108
- }
109
-
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import { _after, _beforeLast } from "@webqit/util/str/index.js";
6
+ import { _isString, _getType, _isObject } from "@webqit/util/js/index.js";
7
+ import _Headers from './xHeaders.js';
8
+
9
+ /**
10
+ * The _Headers Mixin
11
+ */
12
+ const _ResponseHeaders = NativeHeaders => class extends _Headers(NativeHeaders) {
13
+
14
+ set cookies(cookieJar) {
15
+ if (!_isObject(cookieJar)) {
16
+ throw new Error(`The "cookies" response directive cannot be of type: ${_getType(cookieJar)}`);
17
+ }
18
+ for (let cookieName in cookieJar) {
19
+ let cookieBody = cookieJar[cookieName];
20
+ if (_isObject(cookieBody)) {
21
+ let attrsArr = [ cookieBody.value ];
22
+ for (let attrName in cookieBody) {
23
+ if (attrName === 'value') continue;
24
+ let _attrName = attrName[0].toUpperCase() + attrName.substring(1);
25
+ if (_attrName === 'MaxAge') { _attrName = 'Max-Age' };
26
+ attrsArr.push(cookieBody[attrName] === true ? _attrName : `${_attrName}=${cookieBody[attrName]}`);
27
+ }
28
+ cookieBody = attrsArr.join('; ');
29
+ }
30
+ this.append('Set-Cookie', `${cookieName}=${cookieBody}`);
31
+ }
32
+ return true;
33
+ }
34
+
35
+ get cookies() {
36
+ const cookiesStr = this.get('Set-Cookie');
37
+ return cookiesStr && cookiesStr.split(',').reduce((cookieJar, str) => {
38
+ let [ cookieDefinition, attrsStr ] = str.split(';');
39
+ let [ cookieName, cookieValue ] = cookieDefinition.trim().split('=');
40
+ cookieJar[cookieName] = { value: cookieValue, };
41
+ if (attrsStr) {
42
+ (attrsStr || '').split(/\;/g).map(attrStr => attrStr.trim().split('=')).forEach(attrsArr => {
43
+ cookieJar[cookieName][attrsArr[0][0].toLowerCase() + attrsArr[0].substring(1).replace('-', '')] = attrsArr.length === 1 ? true : attrsArr[1];
44
+ });
45
+ }
46
+ return cookieJar;
47
+ }, {});
48
+ }
49
+
50
+ set contentRange(value) {
51
+ if (Array.isArray(value)) {
52
+ if ((value.length === 2 && !value[0].includes('-')) || value.length < 2) {
53
+ throw new Error(`A Content-Range array must be in the format: [ 'start-end', 'total' ]`);
54
+ }
55
+ return this.set('Content-Range', `bytes ${value.join('/')}`);
56
+ }
57
+ return this.set('Content-Range', value);
58
+ }
59
+
60
+ get contentRange() {
61
+ const value = this.get('Content-Range');
62
+ return value && _after(value, 'bytes ').split('/');
63
+ }
64
+
65
+ set cors(value) {
66
+ return this.set('Access-Control-Allow-Origin', value === true ? '*' : (value === false ? '' : value));
67
+ }
68
+
69
+ get cors() {
70
+ return this.get('Access-Control-Allow-Origin');
71
+ }
72
+
73
+ set attachment(value) {
74
+ value = value === true ? 'attachment' : (value === false ? 'inline' : value);
75
+ if (!_isString(value)) {
76
+ throw new Error(`The "download" response directive does not support the type: ${_getType(value)}`);
77
+ }
78
+ if (![ 'attachment', 'inline' ].includes(value)) {
79
+ value = `attachment; filename="${value}"`;
80
+ }
81
+ return this.set('Content-Disposition', value);
82
+ }
83
+
84
+ get attachment() {
85
+ var value = (this.get('Content-Disposition') || '').trim();
86
+ value = value === 'attachment' ? true : (
87
+ value === 'inline' ? false : _after(_beforeLast(value, '"'), 'filename="')
88
+ );
89
+ return value;
90
+ }
91
+
92
+ get location() {
93
+ return this.get('Location');
94
+ }
95
+
96
+ set location(value) {
97
+ return this.set('Location', value);
98
+ }
99
+
100
+ get redirect() {
101
+ return this.get('Location');
102
+ }
103
+
104
+ set redirect(value) {
105
+ return this.set('Location', value);
106
+ }
107
+
108
+ }
109
+
110
110
  export default _ResponseHeaders;
@@ -1,111 +1,111 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import _isArray from '@webqit/util/js/isArray.js';
6
- import _isObject from '@webqit/util/js/isObject.js';
7
- import { wwwFormUnserialize, wwwFormSerialize } from './util.js';
8
-
9
- /**
10
- * ---------------------------
11
- * The xURL Mixin
12
- * ---------------------------
13
- */
14
- const xURL = whatwagURL => {
15
- const URL = class extends whatwagURL {
16
-
17
- // constructor
18
- constructor(...args) {
19
- super(...args);
20
- var query = wwwFormUnserialize(this.search);
21
- const updateSearch = query => {
22
- // "query" was updated. So we update "search"
23
- var search = wwwFormSerialize(query);
24
- search = search ? '?' + search : '';
25
- if (search !== this.search) {
26
- this.search = search;
27
- }
28
- };
29
- this.__query = {
30
- value: query,
31
- proxy: new Proxy(query, {
32
- set(t, n, v) {
33
- t[n] = v;
34
- updateSearch(t);
35
- return true;
36
- },
37
- deleteProperty(t, n) {
38
- delete t[n];
39
- updateSearch(t);
40
- return true;
41
- }
42
- })
43
- };
44
- }
45
-
46
- // Set search
47
- set search(value) {
48
- super.search = value;
49
- // "search" was updated. So we update "query"
50
- var query = wwwFormUnserialize(value);
51
- if (!_strictEven(query, this.query)) {
52
- this.query = query;
53
- }
54
- }
55
-
56
- // Get search
57
- get search() {
58
- return super.search;
59
- }
60
-
61
- // Get query
62
- get query() {
63
- return this.__query.proxy;
64
- }
65
-
66
- };
67
- // ----------
68
- URL.Observable = class extends URL {
69
-
70
- constructor() {
71
- super(...arguments);
72
- const { Observer } = WebQit;
73
- Observer.accessorize(this, [
74
- 'protocol',
75
- 'username',
76
- 'password',
77
- 'host',
78
- 'hostname',
79
- 'port',
80
- 'origin',
81
- 'pathname',
82
- 'search',
83
- 'query',
84
- 'hash',
85
- 'href',
86
- ]);
87
- }
88
-
89
- };
90
- // ----------
91
- return URL;
92
- }
93
-
94
- /**
95
- * ---------------------------
96
- * Helpers
97
- * ---------------------------
98
- */
99
- var _strictEven = (a, b) => {
100
- if (_isObject(a) && _isObject(b)) {
101
- return _strictEven(Object.keys(a), Object.keys(b))
102
- && _strictEven(Object.values(a), Object.values(b));
103
- }
104
- if (_isArray(a) && _isArray(b)) {
105
- return a.length === b.length
106
- && a.reduce((recieved, item, i) => recieved && item === b[i], true);
107
- }
108
- return a === b;
109
- };
110
-
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import _isArray from '@webqit/util/js/isArray.js';
6
+ import _isObject from '@webqit/util/js/isObject.js';
7
+ import { wwwFormUnserialize, wwwFormSerialize } from './util.js';
8
+
9
+ /**
10
+ * ---------------------------
11
+ * The xURL Mixin
12
+ * ---------------------------
13
+ */
14
+ const xURL = whatwagURL => {
15
+ const URL = class extends whatwagURL {
16
+
17
+ // constructor
18
+ constructor(...args) {
19
+ super(...args);
20
+ var query = wwwFormUnserialize(this.search);
21
+ const updateSearch = query => {
22
+ // "query" was updated. So we update "search"
23
+ var search = wwwFormSerialize(query);
24
+ search = search ? '?' + search : '';
25
+ if (search !== this.search) {
26
+ this.search = search;
27
+ }
28
+ };
29
+ this.__query = {
30
+ value: query,
31
+ proxy: new Proxy(query, {
32
+ set(t, n, v) {
33
+ t[n] = v;
34
+ updateSearch(t);
35
+ return true;
36
+ },
37
+ deleteProperty(t, n) {
38
+ delete t[n];
39
+ updateSearch(t);
40
+ return true;
41
+ }
42
+ })
43
+ };
44
+ }
45
+
46
+ // Set search
47
+ set search(value) {
48
+ super.search = value;
49
+ // "search" was updated. So we update "query"
50
+ var query = wwwFormUnserialize(value);
51
+ if (!_strictEven(query, this.query)) {
52
+ this.query = query;
53
+ }
54
+ }
55
+
56
+ // Get search
57
+ get search() {
58
+ return super.search;
59
+ }
60
+
61
+ // Get query
62
+ get query() {
63
+ return this.__query.proxy;
64
+ }
65
+
66
+ };
67
+ // ----------
68
+ URL.Observable = class extends URL {
69
+
70
+ constructor() {
71
+ super(...arguments);
72
+ const { Observer } = WebQit;
73
+ Observer.accessorize(this, [
74
+ 'protocol',
75
+ 'username',
76
+ 'password',
77
+ 'host',
78
+ 'hostname',
79
+ 'port',
80
+ 'origin',
81
+ 'pathname',
82
+ 'search',
83
+ 'query',
84
+ 'hash',
85
+ 'href',
86
+ ]);
87
+ }
88
+
89
+ };
90
+ // ----------
91
+ return URL;
92
+ }
93
+
94
+ /**
95
+ * ---------------------------
96
+ * Helpers
97
+ * ---------------------------
98
+ */
99
+ var _strictEven = (a, b) => {
100
+ if (_isObject(a) && _isObject(b)) {
101
+ return _strictEven(Object.keys(a), Object.keys(b))
102
+ && _strictEven(Object.values(a), Object.values(b));
103
+ }
104
+ if (_isArray(a) && _isArray(b)) {
105
+ return a.length === b.length
106
+ && a.reduce((recieved, item, i) => recieved && item === b[i], true);
107
+ }
108
+ return a === b;
109
+ };
110
+
111
111
  export default xURL;
@@ -1,7 +1,7 @@
1
-
2
- /**
3
- * The xfetch Mixin
4
- */
5
- const xfetch = whatwagFetch => whatwagFetch;
6
-
1
+
2
+ /**
3
+ * The xfetch Mixin
4
+ */
5
+ const xfetch = whatwagFetch => whatwagFetch;
6
+
7
7
  export default xfetch;
@@ -1,23 +1,23 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * imports
5
- */
6
- import Fs from 'fs';
7
- import Path from 'path';
8
- import * as _layout from '../../config/layout.js';
9
-
10
- // ------------------------------------------
11
-
12
- const domain = process.env.CERTBOT_DOMAIN,
13
- validation = process.env.CERTBOT_VALIDATION,
14
- token = process.env.CERTBOT_TOKEN,
15
- remainingChallenges = process.env.CERTBOT_REMAINING_CHALLENGES || 0/*,
16
- allDomains = process.env.CERTBOT_ALL_DOMAINS.split(',')*/
17
- ;
18
- (async function() {
19
- const layout = await _layout.read({});
20
- const acmeDir = Path.join(layout.PUBLIC_DIR, './.well-known/acme-challenge/');
21
- Fs.mkdirSync(acmeDir, {recursive:true});
22
- Fs.writeFileSync(Path.join(acmeDir, token), validation);
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * imports
5
+ */
6
+ import Fs from 'fs';
7
+ import Path from 'path';
8
+ import * as _layout from '../../config/layout.js';
9
+
10
+ // ------------------------------------------
11
+
12
+ const domain = process.env.CERTBOT_DOMAIN,
13
+ validation = process.env.CERTBOT_VALIDATION,
14
+ token = process.env.CERTBOT_TOKEN,
15
+ remainingChallenges = process.env.CERTBOT_REMAINING_CHALLENGES || 0/*,
16
+ allDomains = process.env.CERTBOT_ALL_DOMAINS.split(',')*/
17
+ ;
18
+ (async function() {
19
+ const layout = await _layout.read({});
20
+ const acmeDir = Path.join(layout.PUBLIC_DIR, './.well-known/acme-challenge/');
21
+ Fs.mkdirSync(acmeDir, {recursive:true});
22
+ Fs.writeFileSync(Path.join(acmeDir, token), validation);
23
23
  })();
@@ -1,23 +1,23 @@
1
- #!/usr/bin/env node
2
-
3
- /**
4
- * imports
5
- */
6
- import Fs from 'fs';
7
- import Path from 'path';
8
- import * as _layout from '../../config/layout.js';
9
-
10
- // ------------------------------------------
11
-
12
- const domain = process.env.CERTBOT_DOMAIN,
13
- validation = process.env.CERTBOT_VALIDATION,
14
- token = process.env.CERTBOT_TOKEN,
15
- authOutput = process.env.CERTBOT_AUTH_OUTPUT,
16
- remainingChallenges = process.env.CERTBOT_REMAINING_CHALLENGES || 0/*,
17
- allDomains = process.env.CERTBOT_ALL_DOMAINS.split(',')*/
18
- ;
19
- (async function() {
20
- const layout = await _layout.read({});
21
- const acmeFile = Path.join(layout.PUBLIC_DIR, './.well-known/acme-challenge/', token);
22
- Fs.unlinkSync(acmeFile);
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * imports
5
+ */
6
+ import Fs from 'fs';
7
+ import Path from 'path';
8
+ import * as _layout from '../../config/layout.js';
9
+
10
+ // ------------------------------------------
11
+
12
+ const domain = process.env.CERTBOT_DOMAIN,
13
+ validation = process.env.CERTBOT_VALIDATION,
14
+ token = process.env.CERTBOT_TOKEN,
15
+ authOutput = process.env.CERTBOT_AUTH_OUTPUT,
16
+ remainingChallenges = process.env.CERTBOT_REMAINING_CHALLENGES || 0/*,
17
+ allDomains = process.env.CERTBOT_ALL_DOMAINS.split(',')*/
18
+ ;
19
+ (async function() {
20
+ const layout = await _layout.read({});
21
+ const acmeFile = Path.join(layout.PUBLIC_DIR, './.well-known/acme-challenge/', token);
22
+ Fs.unlinkSync(acmeFile);
23
23
  })();