@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,46 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import Router from '../Router.js';
|
|
6
|
-
|
|
7
|
-
export default class WorkerClient {
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* WorkerClient
|
|
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
|
-
let response = await router.route([httpMethodName === 'delete' ? 'del' : httpMethodName, 'default'], httpEvent, {}, async event => {
|
|
35
|
-
return remoteFetch(event.request);
|
|
36
|
-
}, remoteFetch);
|
|
37
|
-
if (!(response instanceof httpEvent.Response)) {
|
|
38
|
-
response = httpEvent.Response.compat(response);
|
|
39
|
-
}
|
|
40
|
-
return response;
|
|
41
|
-
};
|
|
42
|
-
return handle();
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import Router from '../Router.js';
|
|
6
|
+
|
|
7
|
+
export default class WorkerClient {
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* WorkerClient
|
|
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
|
+
let response = await router.route([httpMethodName === 'delete' ? 'del' : httpMethodName, 'default'], httpEvent, {}, async event => {
|
|
35
|
+
return remoteFetch(event.request);
|
|
36
|
+
}, remoteFetch);
|
|
37
|
+
if (!(response instanceof httpEvent.Response)) {
|
|
38
|
+
response = httpEvent.Response.compat(response);
|
|
39
|
+
}
|
|
40
|
+
return response;
|
|
41
|
+
};
|
|
42
|
+
return handle();
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
}
|
|
46
|
+
|
|
@@ -1,80 +1,80 @@
|
|
|
1
|
-
|
|
2
|
-
export default class Workport {
|
|
3
|
-
|
|
4
|
-
constructor() {
|
|
5
|
-
// --------
|
|
6
|
-
// Post messaging
|
|
7
|
-
// --------
|
|
8
|
-
this.messaging = {
|
|
9
|
-
post: (message, client = this.client) => {
|
|
10
|
-
if (!client) throw new Error(`No client for this operation.`);
|
|
11
|
-
client.postMessage(message);
|
|
12
|
-
return this.post;
|
|
13
|
-
},
|
|
14
|
-
listen: (callback, client = this.client) => {
|
|
15
|
-
if (!client) {
|
|
16
|
-
self.addEventListener('message', evt => {
|
|
17
|
-
this.client = evt.source;
|
|
18
|
-
callback(evt);
|
|
19
|
-
});
|
|
20
|
-
return this.post;
|
|
21
|
-
}
|
|
22
|
-
client.addEventListener('message', callback);
|
|
23
|
-
return this.post;
|
|
24
|
-
},
|
|
25
|
-
request: (message, client = this.client) => {
|
|
26
|
-
if (!client) throw new Error(`No client for this operation.`);
|
|
27
|
-
return new Promise(res => {
|
|
28
|
-
let messageChannel = new MessageChannel();
|
|
29
|
-
client.postMessage(message, [ messageChannel.port2 ]);
|
|
30
|
-
messageChannel.port1.onmessage = e => res(e.data);
|
|
31
|
-
});
|
|
32
|
-
},
|
|
33
|
-
channel(channelId) {
|
|
34
|
-
if (!this.channels.has(channelId)) { this.channels.set(channelId, new BroadcastChannel(channel)); }
|
|
35
|
-
let channel = this.channels.get(channelId);
|
|
36
|
-
return {
|
|
37
|
-
broadcast: message => channel.postMessage(message),
|
|
38
|
-
listen: callback => channel.addEventListener('message', callback),
|
|
39
|
-
};
|
|
40
|
-
},
|
|
41
|
-
channels: new Map,
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// --------
|
|
45
|
-
// Notifications
|
|
46
|
-
// --------
|
|
47
|
-
this.notifications = {
|
|
48
|
-
fire: (title, params = {}) => {
|
|
49
|
-
return new Promise((res, rej) => {
|
|
50
|
-
if (!(self.Notification && self.Notification.permission === 'granted')) {
|
|
51
|
-
return rej(self.Notification && self.Notification.permission);
|
|
52
|
-
}
|
|
53
|
-
notification.addEventListener('error', rej);
|
|
54
|
-
let notification = new self.Notification(title, params);
|
|
55
|
-
notification.addEventListener('click', res);
|
|
56
|
-
notification.addEventListener('close', res);
|
|
57
|
-
});
|
|
58
|
-
},
|
|
59
|
-
handle: callback => {
|
|
60
|
-
self.addEventListener('notificationclick', callback);
|
|
61
|
-
return this.notifications;
|
|
62
|
-
},
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
// --------
|
|
66
|
-
// Push Notifications
|
|
67
|
-
// --------
|
|
68
|
-
this.push = {
|
|
69
|
-
listen: callback => {
|
|
70
|
-
self.addEventListener('push', callback);
|
|
71
|
-
return this.post;
|
|
72
|
-
},
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
setCurrentClient(client) {
|
|
77
|
-
this.client = client;
|
|
78
|
-
}
|
|
79
|
-
|
|
1
|
+
|
|
2
|
+
export default class Workport {
|
|
3
|
+
|
|
4
|
+
constructor() {
|
|
5
|
+
// --------
|
|
6
|
+
// Post messaging
|
|
7
|
+
// --------
|
|
8
|
+
this.messaging = {
|
|
9
|
+
post: (message, client = this.client) => {
|
|
10
|
+
if (!client) throw new Error(`No client for this operation.`);
|
|
11
|
+
client.postMessage(message);
|
|
12
|
+
return this.post;
|
|
13
|
+
},
|
|
14
|
+
listen: (callback, client = this.client) => {
|
|
15
|
+
if (!client) {
|
|
16
|
+
self.addEventListener('message', evt => {
|
|
17
|
+
this.client = evt.source;
|
|
18
|
+
callback(evt);
|
|
19
|
+
});
|
|
20
|
+
return this.post;
|
|
21
|
+
}
|
|
22
|
+
client.addEventListener('message', callback);
|
|
23
|
+
return this.post;
|
|
24
|
+
},
|
|
25
|
+
request: (message, client = this.client) => {
|
|
26
|
+
if (!client) throw new Error(`No client for this operation.`);
|
|
27
|
+
return new Promise(res => {
|
|
28
|
+
let messageChannel = new MessageChannel();
|
|
29
|
+
client.postMessage(message, [ messageChannel.port2 ]);
|
|
30
|
+
messageChannel.port1.onmessage = e => res(e.data);
|
|
31
|
+
});
|
|
32
|
+
},
|
|
33
|
+
channel(channelId) {
|
|
34
|
+
if (!this.channels.has(channelId)) { this.channels.set(channelId, new BroadcastChannel(channel)); }
|
|
35
|
+
let channel = this.channels.get(channelId);
|
|
36
|
+
return {
|
|
37
|
+
broadcast: message => channel.postMessage(message),
|
|
38
|
+
listen: callback => channel.addEventListener('message', callback),
|
|
39
|
+
};
|
|
40
|
+
},
|
|
41
|
+
channels: new Map,
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
// --------
|
|
45
|
+
// Notifications
|
|
46
|
+
// --------
|
|
47
|
+
this.notifications = {
|
|
48
|
+
fire: (title, params = {}) => {
|
|
49
|
+
return new Promise((res, rej) => {
|
|
50
|
+
if (!(self.Notification && self.Notification.permission === 'granted')) {
|
|
51
|
+
return rej(self.Notification && self.Notification.permission);
|
|
52
|
+
}
|
|
53
|
+
notification.addEventListener('error', rej);
|
|
54
|
+
let notification = new self.Notification(title, params);
|
|
55
|
+
notification.addEventListener('click', res);
|
|
56
|
+
notification.addEventListener('close', res);
|
|
57
|
+
});
|
|
58
|
+
},
|
|
59
|
+
handle: callback => {
|
|
60
|
+
self.addEventListener('notificationclick', callback);
|
|
61
|
+
return this.notifications;
|
|
62
|
+
},
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
// --------
|
|
66
|
+
// Push Notifications
|
|
67
|
+
// --------
|
|
68
|
+
this.push = {
|
|
69
|
+
listen: callback => {
|
|
70
|
+
self.addEventListener('push', callback);
|
|
71
|
+
return this.post;
|
|
72
|
+
},
|
|
73
|
+
};
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
setCurrentClient(client) {
|
|
77
|
+
this.client = client;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
80
|
}
|
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import Context from './Context.js';
|
|
6
|
-
import WorkerClient from './WorkerClient.js';
|
|
7
|
-
import Worker from './Worker.js';
|
|
8
|
-
|
|
9
|
-
/**
|
|
10
|
-
* @start
|
|
11
|
-
*/
|
|
12
|
-
export async function start(clientCallback = null) {
|
|
13
|
-
const cx = this || {};
|
|
14
|
-
const defaultClientCallback = _cx => new WorkerClient(_cx);
|
|
15
|
-
return new Worker(Context.create(cx), ( ...args ) => {
|
|
16
|
-
return clientCallback ? clientCallback( ...args.concat( defaultClientCallback ) ) : defaultClientCallback( ...args );
|
|
17
|
-
});
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
/**
|
|
21
|
-
* @APIS
|
|
22
|
-
*/
|
|
23
|
-
export * as APIS from './Worker.js';
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import Context from './Context.js';
|
|
6
|
+
import WorkerClient from './WorkerClient.js';
|
|
7
|
+
import Worker from './Worker.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* @start
|
|
11
|
+
*/
|
|
12
|
+
export async function start(clientCallback = null) {
|
|
13
|
+
const cx = this || {};
|
|
14
|
+
const defaultClientCallback = _cx => new WorkerClient(_cx);
|
|
15
|
+
return new Worker(Context.create(cx), ( ...args ) => {
|
|
16
|
+
return clientCallback ? clientCallback( ...args.concat( defaultClientCallback ) ) : defaultClientCallback( ...args );
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* @APIS
|
|
22
|
+
*/
|
|
23
|
+
export * as APIS from './Worker.js';
|
package/src/runtime-pi/index.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import * as server from './server/index.js';
|
|
6
|
-
import * as client from './client/generate.js';
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* @exports
|
|
10
|
-
*/
|
|
11
|
-
export {
|
|
12
|
-
server,
|
|
13
|
-
client,
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import * as server from './server/index.js';
|
|
6
|
+
import * as client from './client/generate.js';
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* @exports
|
|
10
|
+
*/
|
|
11
|
+
export {
|
|
12
|
+
server,
|
|
13
|
+
client,
|
|
14
14
|
}
|
|
@@ -1,16 +1,16 @@
|
|
|
1
|
-
|
|
2
|
-
/**
|
|
3
|
-
* @imports
|
|
4
|
-
*/
|
|
5
|
-
import _Contex from '../../Context.js';
|
|
6
|
-
|
|
7
|
-
export default class Context extends _Contex {
|
|
8
|
-
// env
|
|
9
|
-
get env() {
|
|
10
|
-
return this.dict.env || {};
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
set env(value) {
|
|
14
|
-
this.dict.env = value;
|
|
15
|
-
}
|
|
1
|
+
|
|
2
|
+
/**
|
|
3
|
+
* @imports
|
|
4
|
+
*/
|
|
5
|
+
import _Contex from '../../Context.js';
|
|
6
|
+
|
|
7
|
+
export default class Context extends _Contex {
|
|
8
|
+
// env
|
|
9
|
+
get env() {
|
|
10
|
+
return this.dict.env || {};
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
set env(value) {
|
|
14
|
+
this.dict.env = value;
|
|
15
|
+
}
|
|
16
16
|
}
|