@webqit/webflo 0.9.0 → 0.9.3
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/package.json +2 -2
- package/src/runtime-pi/client/Runtime.js +8 -4
- package/src/runtime-pi/client/RuntimeClient.js +2 -5
- package/src/runtime-pi/client/worker/Worker.js +3 -0
- package/src/runtime-pi/server/Runtime.js +5 -5
- package/src/runtime-pi/server/RuntimeClient.js +3 -2
- package/src/runtime-pi/xHttpMessage.js +2 -2
- package/src/runtime-pi/xRequest.js +2 -2
- package/src/runtime-pi/xResponse.js +2 -2
package/package.json
CHANGED
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"vanila-javascript"
|
|
13
13
|
],
|
|
14
14
|
"homepage": "https://webqit.io/tooling/webflo",
|
|
15
|
-
"version": "0.9.
|
|
15
|
+
"version": "0.9.3",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
@@ -37,7 +37,7 @@
|
|
|
37
37
|
"dependencies": {
|
|
38
38
|
"@octokit/webhooks": "^7.15.1",
|
|
39
39
|
"@webqit/backpack": "^0.0.37",
|
|
40
|
-
"@webqit/oohtml-ssr": "^1.0.
|
|
40
|
+
"@webqit/oohtml-ssr": "^1.0.3",
|
|
41
41
|
"@webqit/util": "^0.8.9",
|
|
42
42
|
"client-sessions": "^0.8.0",
|
|
43
43
|
"form-data-encoder": "^1.6.0",
|
|
@@ -22,8 +22,8 @@ const FormData = xFormData(whatwag.FormData);
|
|
|
22
22
|
const ReadableStream = whatwag.ReadableStream;
|
|
23
23
|
const RequestHeaders = xRequestHeaders(whatwag.Headers);
|
|
24
24
|
const ResponseHeaders = xResponseHeaders(whatwag.Headers);
|
|
25
|
-
const Request = xRequest(whatwag.Request, RequestHeaders, FormData);
|
|
26
|
-
const Response = xResponse(whatwag.Response, ResponseHeaders, FormData);
|
|
25
|
+
const Request = xRequest(whatwag.Request, RequestHeaders, FormData, whatwag.Blob);
|
|
26
|
+
const Response = xResponse(whatwag.Response, ResponseHeaders, FormData, whatwag.Blob);
|
|
27
27
|
const fetch = xfetch(whatwag.fetch);
|
|
28
28
|
const HttpEvent = xHttpEvent(Request, Response, URL);
|
|
29
29
|
|
|
@@ -101,7 +101,7 @@ export default class Runtime {
|
|
|
101
101
|
if (!anchor.target && !anchor.download && (!anchor.origin || anchor.origin === this.location.origin)) {
|
|
102
102
|
if (e.metaKey || e.altKey || e.ctrlKey || e.shiftKey) return;
|
|
103
103
|
// Publish everything, including hash
|
|
104
|
-
this.go(Url.copy(anchor), { src: anchor, srcType: 'link', });
|
|
104
|
+
this.go(Url.copy(anchor), {}, { src: anchor, srcType: 'link', });
|
|
105
105
|
// URLs with # will cause a natural navigation
|
|
106
106
|
// even if pointing to a different page, a natural navigation will still happen
|
|
107
107
|
// because with the Observer.set() above, window.document.location.href would have become
|
|
@@ -144,7 +144,11 @@ export default class Runtime {
|
|
|
144
144
|
actionEl.search = wwwFormSerialize(query);
|
|
145
145
|
formData = null;
|
|
146
146
|
}
|
|
147
|
-
this.go(Url.copy(actionEl), {
|
|
147
|
+
this.go(Url.copy(actionEl), {
|
|
148
|
+
method: submitParams.method,
|
|
149
|
+
body: formData,
|
|
150
|
+
headers: { contentType: submitParams.enctype },
|
|
151
|
+
}, { ...submitParams, src: form, srcType: 'form', });
|
|
148
152
|
// URLs with # will cause a natural navigation
|
|
149
153
|
// even if pointing to a different page, a natural navigation will still happen
|
|
150
154
|
// because with the Observer.set() above, window.document.location.href would have become
|
|
@@ -83,7 +83,7 @@ export default class RuntimeClient {
|
|
|
83
83
|
window.document.setState({ page: data }, { update: 'merge' });
|
|
84
84
|
window.document.body.setAttribute('template', 'page/' + httpEvent.url.pathname.split('/').filter(a => a).map(a => a + '+-').join('/'));
|
|
85
85
|
await new Promise(res => (window.document.templatesReadyState === 'complete' && res(), window.document.addEventListener('templatesreadystatechange', res)));
|
|
86
|
-
return
|
|
86
|
+
return window;
|
|
87
87
|
});
|
|
88
88
|
}
|
|
89
89
|
|
|
@@ -97,16 +97,13 @@ export default class RuntimeClient {
|
|
|
97
97
|
async scrollIntoView(httpEvent) {
|
|
98
98
|
if (!(httpEvent.detail.src instanceof Element)) return;
|
|
99
99
|
await new Promise(res => setTimeout(res, 10));
|
|
100
|
-
let viewportTop;
|
|
100
|
+
let viewportTop, urlTarget;
|
|
101
101
|
if (httpEvent.url.hash && (urlTarget = document.querySelector(httpEvent.url.hash))) {
|
|
102
102
|
urlTarget.scrollIntoView();
|
|
103
103
|
} else if (viewportTop = Array.from(document.querySelectorAll('[data-viewport-top]')).pop()) {
|
|
104
104
|
viewportTop.focus();
|
|
105
105
|
} else {
|
|
106
|
-
document.documentElement.classList.add('scroll-reset');
|
|
107
106
|
document.body.scrollIntoView();
|
|
108
|
-
await new Promise(res => setTimeout(res, 600));
|
|
109
|
-
document.documentElement.classList.remove('scroll-reset');
|
|
110
107
|
}
|
|
111
108
|
}
|
|
112
109
|
|
|
@@ -88,6 +88,9 @@ export default class Worker {
|
|
|
88
88
|
Observer.set(this, 'location', {});
|
|
89
89
|
Observer.set(this, 'network', {});
|
|
90
90
|
// ---------------
|
|
91
|
+
Observer.observe(this.network, es => {
|
|
92
|
+
//console.log('//////////', ...es.map(e => `${e.name}: ${e.value}`))
|
|
93
|
+
});
|
|
91
94
|
}
|
|
92
95
|
|
|
93
96
|
/**
|
|
@@ -28,8 +28,8 @@ const FormData = xFormData(whatwag.FormData);
|
|
|
28
28
|
const ReadableStream = whatwag.ReadableStream;
|
|
29
29
|
const RequestHeaders = xRequestHeaders(whatwag.Headers);
|
|
30
30
|
const ResponseHeaders = xResponseHeaders(whatwag.Headers);
|
|
31
|
-
const Request = xRequest(whatwag.Request, RequestHeaders, FormData);
|
|
32
|
-
const Response = xResponse(whatwag.Response, ResponseHeaders, FormData);
|
|
31
|
+
const Request = xRequest(whatwag.Request, RequestHeaders, FormData, whatwag.Blob);
|
|
32
|
+
const Response = xResponse(whatwag.Response, ResponseHeaders, FormData, whatwag.Blob);
|
|
33
33
|
const fetch = xfetch(whatwag.fetch);
|
|
34
34
|
const HttpEvent = xHttpEvent(Request, Response, URL);
|
|
35
35
|
|
|
@@ -247,7 +247,7 @@ export default class Runtime {
|
|
|
247
247
|
if (this.cx.app.title && this.cx.logger) {
|
|
248
248
|
this.cx.logger.info(`> Server running (${this.cx.app.title || ''})`);
|
|
249
249
|
}
|
|
250
|
-
|
|
250
|
+
}
|
|
251
251
|
|
|
252
252
|
/**
|
|
253
253
|
* Performs a request.
|
|
@@ -303,7 +303,7 @@ export default class Runtime {
|
|
|
303
303
|
if (this.cx.server.shared) {
|
|
304
304
|
client = this.clients.get(url.hostname);
|
|
305
305
|
}
|
|
306
|
-
let response = await client.handle(httpEvent, (...args) => this.remoteFetch(...args));
|
|
306
|
+
let response = await client.handle(httpEvent, ( ...args ) => this.remoteFetch( ...args ));
|
|
307
307
|
let finalResponse = await this.handleResponse(httpEvent, response, autoHeaders.filter(header => header.type === 'response'));
|
|
308
308
|
// Logging
|
|
309
309
|
if (this.cx.logger) {
|
|
@@ -335,7 +335,6 @@ export default class Runtime {
|
|
|
335
335
|
});
|
|
336
336
|
}
|
|
337
337
|
} else {
|
|
338
|
-
baseObject = e.detail.request;
|
|
339
338
|
Sessions({
|
|
340
339
|
duration: 0, // how long the session will stay valid in ms
|
|
341
340
|
activeDuration: 0, // if expiresIn < activeDuration, the session will be extended by activeDuration milliseconds
|
|
@@ -348,6 +347,7 @@ export default class Runtime {
|
|
|
348
347
|
callback(e);
|
|
349
348
|
}
|
|
350
349
|
});
|
|
350
|
+
baseObject = e.detail.request;
|
|
351
351
|
}
|
|
352
352
|
// Where theres no error, instance is available
|
|
353
353
|
let instance = Object.getOwnPropertyDescriptor(baseObject, id);
|
|
@@ -70,7 +70,7 @@ export default class RuntimeClient {
|
|
|
70
70
|
// Renderer
|
|
71
71
|
async render(httpEvent, router, response) {
|
|
72
72
|
let data = await response.json();
|
|
73
|
-
|
|
73
|
+
let rendering = await router.route('render', httpEvent, data, async (httpEvent, data) => {
|
|
74
74
|
var renderFile, pathnameSplit = httpEvent.url.pathname.split('/');
|
|
75
75
|
while ((renderFile = Path.join(this.cx.CWD, this.cx.layout.PUBLIC_DIR, './' + pathnameSplit.join('/'), 'index.html'))
|
|
76
76
|
&& (this.renderFileCache[renderFile] === false/* false on previous runs */ || !Fs.existsSync(renderFile))) {
|
|
@@ -95,8 +95,9 @@ export default class RuntimeClient {
|
|
|
95
95
|
window.document.setState({ page: data, url: httpEvent.url }, { update: 'merge' });
|
|
96
96
|
window.document.body.setAttribute('template', 'page/' + httpEvent.url.pathname.split('/').filter(a => a).map(a => a + '+-').join('/'));
|
|
97
97
|
await new Promise(res => setTimeout(res, 10));
|
|
98
|
-
return window
|
|
98
|
+
return window;
|
|
99
99
|
});
|
|
100
|
+
return rendering + '';
|
|
100
101
|
}
|
|
101
102
|
|
|
102
103
|
}
|
|
@@ -123,7 +123,7 @@ const xHttpMessage = (whatwagHttpMessage, Headers, FormData) => {
|
|
|
123
123
|
}
|
|
124
124
|
|
|
125
125
|
export default xHttpMessage;
|
|
126
|
-
export function encodeBody(body, FormData) {
|
|
126
|
+
export function encodeBody(body, FormData, Blob) {
|
|
127
127
|
const detailsObj = { body, input: body };
|
|
128
128
|
const encodeFormData = (detailsObj, formData) => {
|
|
129
129
|
if (!FormData.encode) return;
|
|
@@ -170,7 +170,7 @@ export function encodeBody(body, FormData) {
|
|
|
170
170
|
detailsObj.body = JSON.stringify(body);
|
|
171
171
|
detailsObj.headers = {
|
|
172
172
|
contentType: 'application/json',
|
|
173
|
-
contentLength: Buffer.byteLength(detailsObj.body, 'utf8')
|
|
173
|
+
contentLength: (new Blob([ detailsObj.body ])).size, // Buffer.byteLength(detailsObj.body, 'utf8') isn't cross-environment
|
|
174
174
|
};
|
|
175
175
|
}
|
|
176
176
|
detailsObj.resolved = body;
|
|
@@ -7,7 +7,7 @@ import xHttpMessage, { encodeBody } from './xHttpMessage.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* The xRequest Mixin
|
|
9
9
|
*/
|
|
10
|
-
const xRequest = (whatwagRequest, Headers, FormData) => class extends xHttpMessage(whatwagRequest, Headers, FormData) {
|
|
10
|
+
const xRequest = (whatwagRequest, Headers, FormData, Blob) => class extends xHttpMessage(whatwagRequest, Headers, FormData) {
|
|
11
11
|
|
|
12
12
|
constructor(input, init = {}) {
|
|
13
13
|
init = { ...init };
|
|
@@ -30,7 +30,7 @@ const xRequest = (whatwagRequest, Headers, FormData) => class extends xHttpMessa
|
|
|
30
30
|
}
|
|
31
31
|
// Init can contain "already-parsed request content"
|
|
32
32
|
if (('body' in init)) {
|
|
33
|
-
bodyAttrs = encodeBody(init.body, FormData);
|
|
33
|
+
bodyAttrs = encodeBody(init.body, FormData, Blob);
|
|
34
34
|
init.body = bodyAttrs.body;
|
|
35
35
|
}
|
|
36
36
|
let isNavigateMode;
|
|
@@ -7,7 +7,7 @@ import xHttpMessage, { encodeBody } from './xHttpMessage.js';
|
|
|
7
7
|
/**
|
|
8
8
|
* The xResponse Mixin
|
|
9
9
|
*/
|
|
10
|
-
const xResponse = (whatwagResponse, Headers, FormData) => class extends xHttpMessage(whatwagResponse, Headers, FormData) {
|
|
10
|
+
const xResponse = (whatwagResponse, Headers, FormData, Blob) => class extends xHttpMessage(whatwagResponse, Headers, FormData) {
|
|
11
11
|
|
|
12
12
|
// construct
|
|
13
13
|
constructor(body = null, init = {}) {
|
|
@@ -22,7 +22,7 @@ const xResponse = (whatwagResponse, Headers, FormData) => class extends xHttpMes
|
|
|
22
22
|
bodyAttrs = body.bodyAttrs || {};
|
|
23
23
|
body = body.body;
|
|
24
24
|
} else {
|
|
25
|
-
bodyAttrs = encodeBody(body, FormData);
|
|
25
|
+
bodyAttrs = encodeBody(body, FormData, Blob);
|
|
26
26
|
body = bodyAttrs.body;
|
|
27
27
|
}
|
|
28
28
|
}
|