@webqit/webflo 0.11.60 → 0.11.61

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 (91) hide show
  1. package/.gitignore +7 -7
  2. package/LICENSE +20 -20
  3. package/README.md +2079 -2074
  4. package/docker/Dockerfile +42 -42
  5. package/docker/README.md +91 -91
  6. package/docker/package.json +2 -2
  7. package/package.json +80 -81
  8. package/src/Context.js +79 -79
  9. package/src/config-pi/deployment/Env.js +68 -68
  10. package/src/config-pi/deployment/Layout.js +63 -63
  11. package/src/config-pi/deployment/Origins.js +139 -139
  12. package/src/config-pi/deployment/Proxy.js +74 -74
  13. package/src/config-pi/deployment/index.js +17 -17
  14. package/src/config-pi/index.js +15 -15
  15. package/src/config-pi/runtime/Client.js +116 -98
  16. package/src/config-pi/runtime/Server.js +125 -125
  17. package/src/config-pi/runtime/client/Worker.js +109 -134
  18. package/src/config-pi/runtime/client/index.js +11 -11
  19. package/src/config-pi/runtime/index.js +17 -17
  20. package/src/config-pi/runtime/server/Headers.js +74 -74
  21. package/src/config-pi/runtime/server/Redirects.js +69 -69
  22. package/src/config-pi/runtime/server/index.js +13 -13
  23. package/src/config-pi/static/Manifest.js +319 -319
  24. package/src/config-pi/static/Ssg.js +49 -49
  25. package/src/config-pi/static/index.js +13 -13
  26. package/src/deployment-pi/index.js +10 -10
  27. package/src/deployment-pi/origins/index.js +216 -216
  28. package/src/index.js +19 -19
  29. package/src/runtime-pi/Application.js +28 -28
  30. package/src/runtime-pi/Cookies.js +81 -81
  31. package/src/runtime-pi/HttpEvent.js +106 -106
  32. package/src/runtime-pi/Router.js +130 -130
  33. package/src/runtime-pi/Runtime.js +20 -20
  34. package/src/runtime-pi/client/Application.js +76 -100
  35. package/src/runtime-pi/client/Context.js +7 -7
  36. package/src/runtime-pi/client/Router.js +48 -48
  37. package/src/runtime-pi/client/Runtime.js +524 -331
  38. package/src/runtime-pi/client/Url.js +204 -205
  39. package/src/runtime-pi/client/Workport.js +190 -178
  40. package/src/runtime-pi/client/createStorage.js +57 -56
  41. package/src/runtime-pi/client/generate.js +480 -471
  42. package/src/runtime-pi/client/index.js +21 -21
  43. package/src/runtime-pi/client/worker/Application.js +44 -44
  44. package/src/runtime-pi/client/worker/Context.js +7 -7
  45. package/src/runtime-pi/client/worker/Runtime.js +274 -268
  46. package/src/runtime-pi/client/worker/Workport.js +77 -89
  47. package/src/runtime-pi/client/worker/index.js +21 -21
  48. package/src/runtime-pi/index.js +13 -13
  49. package/src/runtime-pi/server/Application.js +100 -115
  50. package/src/runtime-pi/server/Context.js +15 -15
  51. package/src/runtime-pi/server/Router.js +159 -159
  52. package/src/runtime-pi/server/Runtime.js +557 -556
  53. package/src/runtime-pi/server/index.js +21 -21
  54. package/src/runtime-pi/util-http.js +85 -85
  55. package/src/runtime-pi/util-url.js +146 -146
  56. package/src/runtime-pi/xFormData.js +23 -23
  57. package/src/runtime-pi/xHeaders.js +145 -145
  58. package/src/runtime-pi/xRequest.js +45 -45
  59. package/src/runtime-pi/xRequestHeaders.js +108 -108
  60. package/src/runtime-pi/xResponse.js +32 -32
  61. package/src/runtime-pi/xResponseHeaders.js +116 -116
  62. package/src/runtime-pi/xURL.js +105 -105
  63. package/src/runtime-pi/xfetch.js +22 -22
  64. package/src/runtime-pi/xxHttpMessage.js +101 -101
  65. package/src/services-pi/cert/http-auth-hook.js +22 -22
  66. package/src/services-pi/cert/http-cleanup-hook.js +22 -22
  67. package/src/services-pi/cert/index.js +79 -79
  68. package/src/services-pi/index.js +8 -8
  69. package/src/static-pi/index.js +10 -10
  70. package/src/webflo.js +30 -30
  71. package/test/index.test.js +26 -26
  72. package/test/site/package.json +9 -9
  73. package/test/site/public/bundle.html +5 -5
  74. package/test/site/public/bundle.html.json +3 -3
  75. package/test/site/public/bundle.js +2 -2
  76. package/test/site/public/bundle.webflo.js +15 -15
  77. package/test/site/public/index.html +29 -29
  78. package/test/site/public/index1.html +34 -34
  79. package/test/site/public/page-2/bundle.html +4 -4
  80. package/test/site/public/page-2/bundle.js +2 -2
  81. package/test/site/public/page-2/index.html +45 -45
  82. package/test/site/public/page-2/main.html +2 -2
  83. package/test/site/public/page-4/subpage/bundle.js +2 -2
  84. package/test/site/public/page-4/subpage/index.html +30 -30
  85. package/test/site/public/sparoots.json +4 -4
  86. package/test/site/public/worker.js +3 -3
  87. package/test/site/server/index.js +15 -15
  88. package/src/runtime-pi/client/oohtml/full.js +0 -7
  89. package/src/runtime-pi/client/oohtml/namespacing.js +0 -7
  90. package/src/runtime-pi/client/oohtml/scripting.js +0 -8
  91. package/src/runtime-pi/client/oohtml/templating.js +0 -8
@@ -1,206 +1,205 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import { _with } from '@webqit/util/obj/index.js';
6
- import { _isArray, _isObject, _isTypeObject, _isString, _isEmpty } from '@webqit/util/js/index.js';
7
- import { Observer } from './Runtime.js';
8
- import { params } from '../util-url.js';
9
-
10
- /**
11
- * ---------------------------
12
- * The Url class
13
- * ---------------------------
14
- */
15
-
16
- export default class Url {
17
-
18
- /**
19
- * Constructs a new Url instance.
20
- *
21
- * @param object input
22
- * @param object pathMappingScheme
23
- *
24
- * @return void
25
- */
26
- constructor(input) {
27
- const Self = this.constructor;
28
- // -----------------------
29
- // Helpers
30
- var _strictEven = (a, b) => {
31
- if (_isObject(a) && _isObject(b)) {
32
- return _strictEven(Object.keys(a), Object.keys(b))
33
- && _strictEven(Object.values(a), Object.values(b));
34
- }
35
- if (_isArray(a) && _isArray(b)) {
36
- return a.length === b.length
37
- && a.reduce((recieved, item, i) => recieved && item === b[i], true);
38
- }
39
- return a === b;
40
- };
41
- Observer.intercept(this, 'set', (e, prev, next) => {
42
- if (e.name === 'hash' && e.value && !e.value.startsWith('#')) {
43
- return next('#' + e.value);
44
- }
45
- if (e.name === 'search' && e.value && !e.value.startsWith('?')) {
46
- return next('?' + e.value);
47
- }
48
- return next();
49
- });
50
- // -----------------------
51
- // When any one of these properties change,
52
- // the others are automatically derived
53
- Observer.observe(this, changes => {
54
- var urlObj = {};
55
- var onlyHrefChanged;
56
- for (var e of changes) {
57
- // ----------
58
- if (e.name === 'href' && e.related.length === 1) {
59
- var urlObj = Self.parseUrl(e.value);
60
- delete urlObj.query;
61
- delete urlObj.href;
62
- onlyHrefChanged = true;
63
- }
64
- // ----------
65
- if (e.name === 'query' && (e.path.length > 1 || !e.related.includes('search'))) {
66
- // "query" was updated. So we update "search"
67
- var search = Self.toSearch(this.query); // Not e.value, as that might be a subtree value
68
- if (search !== this.search) {
69
- urlObj.search = search;
70
- }
71
- }
72
- if (e.name === 'search') {
73
- // "search" was updated. So we update "query"
74
- var query = Self.toQuery(urlObj.search || this.search); // Not e.value, as that might be a href value
75
- if (!_strictEven(query, this.query)) {
76
- urlObj.query = query;
77
- }
78
- }
79
- }
80
- if (!onlyHrefChanged) {
81
- var fullOrigin = this.origin,
82
- usernamePassword = [ this.username, this.password ].filter(a => a);
83
- if (usernamePassword.length === 2) {
84
- fullOrigin = `${this.protocol}//${usernamePassword.join(':')}@${this.hostname}${(this.port ? `:${this.port}` : '')}`;
85
- }
86
- var href = [ fullOrigin, urlObj.pathname || this.pathname, urlObj.search || this.search, this.hash ].join('');
87
- if (href !== this.href) {
88
- urlObj.href = href;
89
- }
90
- }
91
- if (!_isEmpty(urlObj)) {
92
- return Observer.set(this, urlObj);
93
- }
94
- }, { subtree:true/*for pathmap/pathsplit/query updates*/, diff: true });
95
- // -----------------------
96
- // Validate e.detail
97
- Observer.observe(this, changes => {
98
- changes.forEach(e => {
99
- if (e && e.detail) {
100
- if (!_isTypeObject(e.detail)) {
101
- throw new Error('"e.detail" can only be of type object.');
102
- }
103
- if (e.detail.request && !_isObject(e.detail.request)) {
104
- throw new Error('"e.detail.request" can only be of type object.');
105
- }
106
- }
107
- });
108
- }, {diff: true});
109
- // -----------------------
110
- // Startup properties
111
- Observer.set(this, _isString(input) ? Self.parseUrl(input) : Url.copy(input));
112
- }
113
-
114
- /**
115
- * Converts the instance to string.
116
- *
117
- * @return string
118
- */
119
- toString() {
120
- return this.href;
121
- }
122
-
123
- /**
124
- * Creates an instance from parsing an URL string
125
- * or from a regular object.
126
- *
127
- * @param string|object href
128
- *
129
- * @return Url
130
- */
131
- static from(href) {
132
- return new this(_isObject(href) ? href : this.parseUrl(href));
133
- }
134
-
135
- /**
136
- * Copies URL properties off
137
- * the given object.
138
- *
139
- * @param object urlObj
140
- *
141
- * @return object
142
- */
143
- static copy(urlObj) {
144
- var url = urlProperties.reduce((obj, prop) => _with(obj, prop, urlObj[prop]), {});
145
- if (!('query' in urlObj)) {
146
- delete url.query;
147
- }
148
- return url;
149
- }
150
-
151
- /**
152
- * Parses an URL and returns its properties
153
- *
154
- * @param string href
155
- *
156
- * @return object
157
- */
158
- static parseUrl(href) {
159
- var a = document.createElement('a');
160
- a.href = href;
161
- return this.copy(a);
162
- }
163
-
164
- /**
165
- * Parses the input search string into a named map
166
- *
167
- * @param string search
168
- *
169
- * @return object
170
- */
171
- static toQuery(search) {
172
- return params.parse(search);
173
- }
174
-
175
- /**
176
- * Stringifies the input query to search string.
177
- *
178
- * @param object query
179
- *
180
- * @return string
181
- */
182
- static toSearch(query) {
183
- var search = params.stringify(query);
184
- return search ? '?' + search : '';
185
- }}
186
-
187
- /**
188
- * These are standard
189
- * and shouldnt'/can't be modified
190
- *
191
- * @array
192
- */
193
- const urlProperties = [
194
- 'protocol',
195
- 'username',
196
- 'password',
197
- 'host',
198
- 'hostname',
199
- 'port',
200
- 'origin',
201
- 'pathname',
202
- 'search',
203
- 'query',
204
- 'hash',
205
- 'href',
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import { _with } from '@webqit/util/obj/index.js';
6
+ import { _isArray, _isObject, _isTypeObject, _isString, _isEmpty } from '@webqit/util/js/index.js';
7
+ import { Observer } from './Runtime.js';
8
+ import { params } from '../util-url.js';
9
+
10
+ /**
11
+ * ---------------------------
12
+ * The Url class
13
+ * ---------------------------
14
+ */
15
+
16
+ export default class Url {
17
+
18
+ /**
19
+ * Constructs a new Url instance.
20
+ *
21
+ * @param object input
22
+ * @param object pathMappingScheme
23
+ *
24
+ * @return void
25
+ */
26
+ constructor(input) {
27
+ const Self = this.constructor;
28
+ // -----------------------
29
+ // Helpers
30
+ var _strictEven = (a, b) => {
31
+ if (_isObject(a) && _isObject(b)) {
32
+ return _strictEven(Object.keys(a), Object.keys(b))
33
+ && _strictEven(Object.values(a), Object.values(b));
34
+ }
35
+ if (_isArray(a) && _isArray(b)) {
36
+ return a.length === b.length
37
+ && a.reduce((recieved, item, i) => recieved && item === b[i], true);
38
+ }
39
+ return a === b;
40
+ };
41
+ Observer.intercept(this, 'set', (e, prev, next) => {
42
+ if (e.key === 'hash' && e.value && !e.value.startsWith('#')) {
43
+ e.value = '#' + e.value;
44
+ } else if (e.key === 'search' && e.value && !e.value.startsWith('?')) {
45
+ e.value = '?' + e.value;
46
+ }
47
+ return next();
48
+ });
49
+ // -----------------------
50
+ // When any one of these properties change,
51
+ // the others are automatically derived
52
+ Observer.observe(this, changes => {
53
+ var urlObj = {};
54
+ var onlyHrefChanged;
55
+ for (var e of changes) {
56
+ // ----------
57
+ if (e.key === 'href' && e.related.length === 1) {
58
+ var urlObj = Self.parseUrl(e.value);
59
+ delete urlObj.query;
60
+ delete urlObj.href;
61
+ onlyHrefChanged = true;
62
+ }
63
+ // ----------
64
+ if (e.key === 'query' && !e.related.includes('search')) {
65
+ // "query" was updated. So we update "search"
66
+ var search = Self.toSearch(this.query); // Not e.value, as that might be a subtree value
67
+ if (search !== this.search) {
68
+ urlObj.search = search;
69
+ }
70
+ }
71
+ if (e.key === 'search') {
72
+ // "search" was updated. So we update "query"
73
+ var query = Self.toQuery(urlObj.search || this.search); // Not e.value, as that might be a href value
74
+ if (!_strictEven(query, this.query)) {
75
+ urlObj.query = query;
76
+ }
77
+ }
78
+ }
79
+ if (!onlyHrefChanged) {
80
+ var fullOrigin = this.origin,
81
+ usernamePassword = [ this.username, this.password ].filter(a => a);
82
+ if (usernamePassword.length === 2) {
83
+ fullOrigin = `${this.protocol}//${usernamePassword.join(':')}@${this.hostname}${(this.port ? `:${this.port}` : '')}`;
84
+ }
85
+ var href = [ fullOrigin, urlObj.pathname || this.pathname, urlObj.search || this.search || (this.href.includes('?') ? '?' : ''), this.hash || (this.href.includes('#') ? '#' : '') ].join('');
86
+ if (href !== this.href) {
87
+ urlObj.href = href;
88
+ }
89
+ }
90
+ if (!_isEmpty(urlObj)) {
91
+ return Observer.set(this, urlObj);
92
+ }
93
+ }, { diff: true });
94
+ // -----------------------
95
+ // Validate e.detail
96
+ Observer.observe(this, changes => {
97
+ changes.forEach(e => {
98
+ if (e && e.detail) {
99
+ if (!_isTypeObject(e.detail)) {
100
+ throw new Error('"e.detail" can only be of type object.');
101
+ }
102
+ if (e.detail.request && !_isObject(e.detail.request)) {
103
+ throw new Error('"e.detail.request" can only be of type object.');
104
+ }
105
+ }
106
+ });
107
+ }, { diff: true });
108
+ // -----------------------
109
+ // Startup properties
110
+ Observer.set(this, _isString(input) ? Self.parseUrl(input) : Url.copy(input));
111
+ }
112
+
113
+ /**
114
+ * Converts the instance to string.
115
+ *
116
+ * @return string
117
+ */
118
+ toString() {
119
+ return this.href;
120
+ }
121
+
122
+ /**
123
+ * Creates an instance from parsing an URL string
124
+ * or from a regular object.
125
+ *
126
+ * @param string|object href
127
+ *
128
+ * @return Url
129
+ */
130
+ static from(href) {
131
+ return new this(_isObject(href) ? href : this.parseUrl(href));
132
+ }
133
+
134
+ /**
135
+ * Copies URL properties off
136
+ * the given object.
137
+ *
138
+ * @param object urlObj
139
+ *
140
+ * @return object
141
+ */
142
+ static copy(urlObj) {
143
+ var url = urlProperties.reduce((obj, prop) => _with(obj, prop, urlObj[prop]), {});
144
+ if (!('query' in urlObj)) {
145
+ delete url.query;
146
+ }
147
+ return url;
148
+ }
149
+
150
+ /**
151
+ * Parses an URL and returns its properties
152
+ *
153
+ * @param string href
154
+ *
155
+ * @return object
156
+ */
157
+ static parseUrl(href) {
158
+ var a = document.createElement('a');
159
+ a.href = href;
160
+ return this.copy(a);
161
+ }
162
+
163
+ /**
164
+ * Parses the input search string into a named map
165
+ *
166
+ * @param string search
167
+ *
168
+ * @return object
169
+ */
170
+ static toQuery(search) {
171
+ return params.parse(search);
172
+ }
173
+
174
+ /**
175
+ * Stringifies the input query to search string.
176
+ *
177
+ * @param object query
178
+ *
179
+ * @return string
180
+ */
181
+ static toSearch(query) {
182
+ var search = params.stringify(query);
183
+ return search ? '?' + search : '';
184
+ }}
185
+
186
+ /**
187
+ * These are standard
188
+ * and shouldnt'/can't be modified
189
+ *
190
+ * @array
191
+ */
192
+ const urlProperties = [
193
+ 'protocol',
194
+ 'username',
195
+ 'password',
196
+ 'host',
197
+ 'hostname',
198
+ 'port',
199
+ 'origin',
200
+ 'pathname',
201
+ 'search',
202
+ 'query',
203
+ 'hash',
204
+ 'href',
206
205
  ];