@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.
- package/.gitignore +7 -7
- package/LICENSE +20 -20
- package/README.md +2074 -2071
- package/package.json +82 -82
- package/src/Context.js +79 -79
- package/src/config-pi/deployment/Env.js +69 -69
- package/src/config-pi/deployment/Layout.js +65 -65
- package/src/config-pi/deployment/Origins.js +133 -133
- package/src/config-pi/deployment/Virtualization.js +65 -65
- package/src/config-pi/deployment/index.js +17 -17
- package/src/config-pi/index.js +15 -15
- package/src/config-pi/runtime/Client.js +101 -101
- package/src/config-pi/runtime/Server.js +128 -128
- package/src/config-pi/runtime/client/Worker.js +135 -135
- package/src/config-pi/runtime/client/index.js +11 -11
- package/src/config-pi/runtime/index.js +17 -17
- package/src/config-pi/runtime/server/Headers.js +77 -77
- package/src/config-pi/runtime/server/Redirects.js +73 -73
- package/src/config-pi/runtime/server/index.js +13 -13
- package/src/config-pi/static/Manifest.js +321 -321
- package/src/config-pi/static/Ssg.js +51 -51
- package/src/config-pi/static/index.js +13 -13
- package/src/deployment-pi/index.js +10 -10
- package/src/deployment-pi/origins/index.js +215 -215
- package/src/index.js +19 -19
- package/src/runtime-pi/Router.js +131 -131
- package/src/runtime-pi/client/Context.js +6 -6
- package/src/runtime-pi/client/Router.js +47 -47
- package/src/runtime-pi/client/Runtime.js +357 -341
- package/src/runtime-pi/client/RuntimeClient.js +98 -98
- package/src/runtime-pi/client/Storage.js +56 -56
- package/src/runtime-pi/client/Url.js +205 -205
- package/src/runtime-pi/client/Workport.js +163 -163
- package/src/runtime-pi/client/generate.js +467 -467
- package/src/runtime-pi/client/index.js +23 -23
- package/src/runtime-pi/client/oohtml/full.js +6 -6
- package/src/runtime-pi/client/oohtml/namespacing.js +6 -6
- package/src/runtime-pi/client/oohtml/scripting.js +7 -7
- package/src/runtime-pi/client/oohtml/templating.js +7 -7
- package/src/runtime-pi/client/whatwag.js +27 -27
- package/src/runtime-pi/client/worker/Context.js +6 -6
- package/src/runtime-pi/client/worker/Worker.js +291 -291
- package/src/runtime-pi/client/worker/WorkerClient.js +46 -46
- package/src/runtime-pi/client/worker/Workport.js +79 -79
- package/src/runtime-pi/client/worker/index.js +23 -23
- package/src/runtime-pi/index.js +13 -13
- package/src/runtime-pi/server/Context.js +15 -15
- package/src/runtime-pi/server/Router.js +157 -157
- package/src/runtime-pi/server/Runtime.js +547 -547
- package/src/runtime-pi/server/RuntimeClient.js +112 -112
- package/src/runtime-pi/server/index.js +23 -23
- package/src/runtime-pi/server/whatwag.js +35 -35
- package/src/runtime-pi/util.js +162 -162
- package/src/runtime-pi/xFormData.js +59 -59
- package/src/runtime-pi/xHeaders.js +87 -87
- package/src/runtime-pi/xHttpEvent.js +92 -92
- package/src/runtime-pi/xHttpMessage.js +179 -179
- package/src/runtime-pi/xRequest.js +73 -73
- package/src/runtime-pi/xRequestHeaders.js +94 -94
- package/src/runtime-pi/xResponse.js +68 -68
- package/src/runtime-pi/xResponseHeaders.js +109 -109
- package/src/runtime-pi/xURL.js +110 -110
- package/src/runtime-pi/xfetch.js +6 -6
- package/src/services-pi/certbot/http-auth-hook.js +22 -22
- package/src/services-pi/certbot/http-cleanup-hook.js +22 -22
- package/src/services-pi/certbot/index.js +79 -79
- package/src/services-pi/index.js +8 -8
- package/src/static-pi/index.js +10 -10
- package/src/webflo.js +31 -31
- package/test/index.test.js +26 -25
- package/test/site/package.json +9 -9
- package/test/site/public/bundle.html +5 -5
- package/test/site/public/bundle.html.json +3 -3
- package/test/site/public/bundle.js +2 -2
- package/test/site/public/bundle.webflo.js +15 -15
- package/test/site/public/index.html +29 -29
- package/test/site/public/index1.html +34 -34
- package/test/site/public/page-2/bundle.html +4 -4
- package/test/site/public/page-2/bundle.js +2 -2
- package/test/site/public/page-2/index.html +45 -45
- package/test/site/public/page-2/main.html +2 -2
- package/test/site/public/page-4/subpage/bundle.js +2 -2
- package/test/site/public/page-4/subpage/index.html +30 -30
- package/test/site/public/sparoots.json +4 -4
- package/test/site/public/worker.js +3 -3
- 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
|
}
|