@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,98 +1,98 @@
1
-
2
- /**
3
- * @imports
4
- */
5
- import Router from './Router.js';
6
-
7
- export default class RuntimeClient {
8
-
9
- /**
10
- * RuntimeClient
11
- *
12
- * @param Context cx
13
- */
14
- constructor(cx) {
15
- this.cx = cx;
16
- }
17
-
18
- /**
19
- * Handles HTTP events.
20
- *
21
- * @param HttpEvent httpEvent
22
- * @param Function remoteFetch
23
- *
24
- * @return Response
25
- */
26
- async handle(httpEvent, remoteFetch) {
27
- // The app router
28
- const router = new Router(this.cx, httpEvent.url.pathname);
29
- const handle = async () => {
30
- // --------
31
- // ROUTE FOR DATA
32
- // --------
33
- let httpMethodName = httpEvent.request.method.toLowerCase();
34
- return router.route([httpMethodName === 'delete' ? 'del' : httpMethodName, 'default'], httpEvent, {}, async event => {
35
- return remoteFetch(event.request);
36
- }, remoteFetch);
37
- };
38
- // --------
39
- // PIPE THROUGH MIDDLEWARES
40
- // --------
41
- return await (this.cx.middlewares || []).concat(handle).reverse().reduce((next, fn) => {
42
- return () => fn.call(this.cx, httpEvent, router, next);
43
- }, null)();
44
- }
45
-
46
- // Renderer
47
- async render(httpEvent, response) {
48
- let data = await response.json();
49
- const router = new Router(this.cx, httpEvent.url.pathname);
50
- return router.route('render', httpEvent, data, async (httpEvent, data) => {
51
- // --------
52
- // OOHTML would waiting for DOM-ready in order to be initialized
53
- if (window.WebQit.DOM) {
54
- await new Promise(res => window.WebQit.DOM.ready(res));
55
- }
56
- if (window.document.state) {
57
- if (!window.document.state.env) {
58
- window.document.setState({
59
- env: 'client',
60
- onHydration: (httpEvent.detail || {}).srcType === 'init',
61
- network: this.cx.runtime.network,
62
- url: this.cx.runtime.location,
63
- }, { update: true });
64
- }
65
- window.document.setState({ data }, { update: 'merge' });
66
- }
67
- if (window.document.templates) {
68
- window.document.body.setAttribute('template', 'routes/' + httpEvent.url.pathname.split('/').filter(a => a).map(a => a + '+-').join('/'));
69
- await new Promise(res => (window.document.templatesReadyState === 'complete' && res(), window.document.addEventListener('templatesreadystatechange', res)));
70
- }
71
- await this.scrollIntoView(httpEvent);
72
- return window;
73
- });
74
- }
75
-
76
- // Unrender
77
- async unrender(httpEvent) {
78
- if (window.document.state) {
79
- window.document.setState({ data: {} }, { update: 'merge' });
80
- }
81
- }
82
-
83
- // Normalize scroll position
84
- async scrollIntoView(httpEvent) {
85
- if (!(httpEvent.detail.src instanceof Element)) return;
86
- await new Promise(res => setTimeout(res, 10));
87
- let viewportTop, urlTarget;
88
- if (httpEvent.url.hash && (urlTarget = document.querySelector(httpEvent.url.hash))) {
89
- urlTarget.scrollIntoView();
90
- } else if (viewportTop = Array.from(document.querySelectorAll('[data-viewport-top]')).pop()) {
91
- viewportTop.focus();
92
- } else {
93
- document.body.scrollIntoView();
94
- }
95
- }
96
-
97
- }
98
-
1
+
2
+ /**
3
+ * @imports
4
+ */
5
+ import Router from './Router.js';
6
+
7
+ export default class RuntimeClient {
8
+
9
+ /**
10
+ * RuntimeClient
11
+ *
12
+ * @param Context cx
13
+ */
14
+ constructor(cx) {
15
+ this.cx = cx;
16
+ }
17
+
18
+ /**
19
+ * Handles HTTP events.
20
+ *
21
+ * @param HttpEvent httpEvent
22
+ * @param Function remoteFetch
23
+ *
24
+ * @return Response
25
+ */
26
+ async handle(httpEvent, remoteFetch) {
27
+ // The app router
28
+ const router = new Router(this.cx, httpEvent.url.pathname);
29
+ const handle = async () => {
30
+ // --------
31
+ // ROUTE FOR DATA
32
+ // --------
33
+ let httpMethodName = httpEvent.request.method.toLowerCase();
34
+ return router.route([httpMethodName === 'delete' ? 'del' : httpMethodName, 'default'], httpEvent, {}, async event => {
35
+ return remoteFetch(event.request);
36
+ }, remoteFetch);
37
+ };
38
+ // --------
39
+ // PIPE THROUGH MIDDLEWARES
40
+ // --------
41
+ return await (this.cx.middlewares || []).concat(handle).reverse().reduce((next, fn) => {
42
+ return () => fn.call(this.cx, httpEvent, router, next);
43
+ }, null)();
44
+ }
45
+
46
+ // Renderer
47
+ async render(httpEvent, response) {
48
+ let data = await response.json();
49
+ const router = new Router(this.cx, httpEvent.url.pathname);
50
+ return router.route('render', httpEvent, data, async (httpEvent, data) => {
51
+ // --------
52
+ // OOHTML would waiting for DOM-ready in order to be initialized
53
+ if (window.WebQit.DOM) {
54
+ await new Promise(res => window.WebQit.DOM.ready(res));
55
+ }
56
+ if (window.document.state) {
57
+ if (!window.document.state.env) {
58
+ window.document.setState({
59
+ env: 'client',
60
+ onHydration: (httpEvent.detail || {}).srcType === 'init',
61
+ network: this.cx.runtime.network,
62
+ url: this.cx.runtime.location,
63
+ }, { update: true });
64
+ }
65
+ window.document.setState({ data }, { update: 'merge' });
66
+ }
67
+ if (window.document.templates) {
68
+ window.document.body.setAttribute('template', 'routes/' + httpEvent.url.pathname.split('/').filter(a => a).map(a => a + '+-').join('/'));
69
+ await new Promise(res => (window.document.templatesReadyState === 'complete' && res(), window.document.addEventListener('templatesreadystatechange', res)));
70
+ }
71
+ await this.scrollIntoView(httpEvent);
72
+ return window;
73
+ });
74
+ }
75
+
76
+ // Unrender
77
+ async unrender(httpEvent) {
78
+ if (window.document.state) {
79
+ window.document.setState({ data: {} }, { update: 'merge' });
80
+ }
81
+ }
82
+
83
+ // Normalize scroll position
84
+ async scrollIntoView(httpEvent) {
85
+ if (!(httpEvent.detail.src instanceof Element)) return;
86
+ await new Promise(res => setTimeout(res, 10));
87
+ let viewportTop, urlTarget;
88
+ if (httpEvent.url.hash && (urlTarget = document.querySelector(httpEvent.url.hash))) {
89
+ urlTarget.scrollIntoView();
90
+ } else if (viewportTop = Array.from(document.querySelectorAll('[data-viewport-top]')).pop()) {
91
+ viewportTop.focus();
92
+ } else {
93
+ document.body.scrollIntoView();
94
+ }
95
+ }
96
+
97
+ }
98
+
@@ -1,57 +1,57 @@
1
-
2
-
3
- /**
4
- * @imports
5
- */
6
- import { _isString, _isUndefined } from '@webqit/util/js/index.js';
7
- import { Observer } from './Runtime.js';
8
-
9
- export default function(namespace = null, persistent = false) {
10
-
11
- const storeType = persistent ? 'localStorage' : 'sessionStorage';
12
- if (!window[storeType]) {
13
- throw new Error(`The specified Web Storage API ${storeType} is invalid or not supported`);
14
- }
15
-
16
- const _storage = {};
17
- Observer.intercept(_storage, (event, received, next) => {
18
- const key = namespace ? `${namespace}.${event.name}` : event.name;
19
- if (event.type === 'get' && _isString(key)) {
20
- const value = window[storeType].getItem(key);
21
- return !_isUndefined(value) ? JSON.parse(value) : value;
22
- }
23
- if (event.type === 'set') {
24
- window[storeType].setItem(key, !_isUndefined(event.value) ? JSON.stringify(event.value) : event.value);
25
- return true;
26
- }
27
- if (event.type === 'deleteProperty') {
28
- window[storeType].removeItem(key);
29
- return true;
30
- }
31
- if (event.type === 'has') {
32
- for(var i = 0; i < window[storeType].length; i ++){
33
- if (window[storeType].key(i) === key) {
34
- return true;
35
- }
36
- };
37
- return false;
38
- }
39
- if (event.type === 'ownKeys') {
40
- var keys = [];
41
- for(var i = 0; i < window[storeType].length; i ++){
42
- keys.push(window[storeType].key(i));
43
- };
44
- return keys;
45
- }
46
- if (event.type === 'getOwnPropertyDescriptor') {
47
- return { enumerable: true, configurable: true };
48
- }
49
- return next();
50
- });
51
-
52
- return Observer.proxy(_storage);
53
- }
54
-
55
- export {
56
- Observer,
1
+
2
+
3
+ /**
4
+ * @imports
5
+ */
6
+ import { _isString, _isUndefined } from '@webqit/util/js/index.js';
7
+ import { Observer } from './Runtime.js';
8
+
9
+ export default function(namespace = null, persistent = false) {
10
+
11
+ const storeType = persistent ? 'localStorage' : 'sessionStorage';
12
+ if (!window[storeType]) {
13
+ throw new Error(`The specified Web Storage API ${storeType} is invalid or not supported`);
14
+ }
15
+
16
+ const _storage = {};
17
+ Observer.intercept(_storage, (event, received, next) => {
18
+ const key = namespace ? `${namespace}.${event.name}` : event.name;
19
+ if (event.type === 'get' && _isString(key)) {
20
+ const value = window[storeType].getItem(key);
21
+ return !_isUndefined(value) ? JSON.parse(value) : value;
22
+ }
23
+ if (event.type === 'set') {
24
+ window[storeType].setItem(key, !_isUndefined(event.value) ? JSON.stringify(event.value) : event.value);
25
+ return true;
26
+ }
27
+ if (event.type === 'deleteProperty') {
28
+ window[storeType].removeItem(key);
29
+ return true;
30
+ }
31
+ if (event.type === 'has') {
32
+ for(var i = 0; i < window[storeType].length; i ++){
33
+ if (window[storeType].key(i) === key) {
34
+ return true;
35
+ }
36
+ };
37
+ return false;
38
+ }
39
+ if (event.type === 'ownKeys') {
40
+ var keys = [];
41
+ for(var i = 0; i < window[storeType].length; i ++){
42
+ keys.push(window[storeType].key(i));
43
+ };
44
+ return keys;
45
+ }
46
+ if (event.type === 'getOwnPropertyDescriptor') {
47
+ return { enumerable: true, configurable: true };
48
+ }
49
+ return next();
50
+ });
51
+
52
+ return Observer.proxy(_storage);
53
+ }
54
+
55
+ export {
56
+ Observer,
57
57
  }