@webqit/webflo 0.9.2 → 0.9.5
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
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.5",
|
|
16
16
|
"license": "MIT",
|
|
17
17
|
"repository": {
|
|
18
18
|
"type": "git",
|
|
@@ -30,7 +30,7 @@
|
|
|
30
30
|
"postpublish": "git push && git push --tags"
|
|
31
31
|
},
|
|
32
32
|
"bin": {
|
|
33
|
-
"webflo": "src/
|
|
33
|
+
"webflo": "src/webflo.js",
|
|
34
34
|
"webflo-certbot-http-auth-hook": "src/services/certbot/http-auth-hook.js",
|
|
35
35
|
"webflo-certbot-http-cleanup-hook": "src/services/certbot/http-cleanup-hook.js"
|
|
36
36
|
},
|
|
@@ -191,7 +191,7 @@ export default class Runtime {
|
|
|
191
191
|
this._abortController.abort();
|
|
192
192
|
}
|
|
193
193
|
this._abortController = new AbortController();
|
|
194
|
-
this._xRedirectCode =
|
|
194
|
+
this._xRedirectCode = 200;
|
|
195
195
|
// ------------
|
|
196
196
|
url = typeof url === 'string' ? new whatwag.URL(url) : url;
|
|
197
197
|
init = { referrer: this.location.href, ...init };
|
|
@@ -213,7 +213,7 @@ export default class Runtime {
|
|
|
213
213
|
// The navigation event
|
|
214
214
|
let httpEvent = new HttpEvent(request, detail, (id = null, persistent = false) => this.getSession(httpEvent, id, persistent));
|
|
215
215
|
// Response
|
|
216
|
-
let response = await this.clients.get('*').handle(httpEvent, (...args) => this.remoteFetch(...args));
|
|
216
|
+
let response = await this.clients.get('*').handle(httpEvent, ( ...args ) => this.remoteFetch( ...args ));
|
|
217
217
|
let finalResponse = this.handleResponse(httpEvent, response);
|
|
218
218
|
// Return value
|
|
219
219
|
return finalResponse;
|
|
@@ -240,9 +240,9 @@ export default class Runtime {
|
|
|
240
240
|
}
|
|
241
241
|
|
|
242
242
|
// Initiates remote fetch and sets the status
|
|
243
|
-
remoteFetch(request) {
|
|
243
|
+
remoteFetch(request, ...args) {
|
|
244
244
|
Observer.set(this.network, 'remote', true);
|
|
245
|
-
let _response = fetch(request);
|
|
245
|
+
let _response = fetch(request, ...args);
|
|
246
246
|
// This catch() is NOT intended to handle failure of the fetch
|
|
247
247
|
_response.catch(e => Observer.set(this.network, 'error', e.message));
|
|
248
248
|
// Return xResponse
|
|
@@ -76,6 +76,7 @@ export default class Worker {
|
|
|
76
76
|
// -------------
|
|
77
77
|
// ONFETCH
|
|
78
78
|
self.addEventListener('fetch', async evt => {
|
|
79
|
+
return; // TODO
|
|
79
80
|
// URL schemes that might arrive here but not supported; e.g.: chrome-extension://
|
|
80
81
|
if (!evt.request.url.startsWith('http')) return;
|
|
81
82
|
const requestInit = [
|
|
@@ -88,6 +89,9 @@ export default class Worker {
|
|
|
88
89
|
Observer.set(this, 'location', {});
|
|
89
90
|
Observer.set(this, 'network', {});
|
|
90
91
|
// ---------------
|
|
92
|
+
Observer.observe(this.network, es => {
|
|
93
|
+
//console.log('//////////', ...es.map(e => `${e.name}: ${e.value}`))
|
|
94
|
+
});
|
|
91
95
|
}
|
|
92
96
|
|
|
93
97
|
/**
|
|
@@ -106,6 +110,10 @@ export default class Worker {
|
|
|
106
110
|
// ------------
|
|
107
111
|
// The request object
|
|
108
112
|
let request = this.generateRequest(url.href, init);
|
|
113
|
+
if (detail.event instanceof self.Request) {
|
|
114
|
+
request = detail.event.request;
|
|
115
|
+
//Object.defineProperty(detail.event, 'request', { value: request });
|
|
116
|
+
}
|
|
109
117
|
// The navigation event
|
|
110
118
|
let httpEvent = new HttpEvent(request, detail, (id = null, persistent = false) => this.getSession(httpEvent, id, persistent));
|
|
111
119
|
httpEvent.port.listen(message => {
|
|
@@ -117,7 +125,7 @@ export default class Worker {
|
|
|
117
125
|
// Response
|
|
118
126
|
let response;
|
|
119
127
|
if (httpEvent.request.url.startsWith(self.origin)/* && httpEvent.request.mode === 'navigate'*/) {
|
|
120
|
-
response = await this.clients.get('*').handle(httpEvent, (...args) => this.remoteFetch(...args));
|
|
128
|
+
response = await this.clients.get('*').handle(httpEvent, ( ...args ) => this.remoteFetch( ...args ));
|
|
121
129
|
} else {
|
|
122
130
|
response = await this.remoteFetch(httpEvent.request);
|
|
123
131
|
}
|
|
@@ -149,7 +157,10 @@ export default class Worker {
|
|
|
149
157
|
}
|
|
150
158
|
|
|
151
159
|
// Initiates remote fetch and sets the status
|
|
152
|
-
remoteFetch(request) {
|
|
160
|
+
remoteFetch(request, ...args) {
|
|
161
|
+
if (arguments.length > 1) {
|
|
162
|
+
request = this.generateRequest(request, ...args);
|
|
163
|
+
}
|
|
153
164
|
const execFetch = () => {
|
|
154
165
|
if (_any((this.cx.params.cache_only_urls || []).map(c => c.trim()).filter(c => c), pattern => Minimatch.Minimatch(request.url, pattern))) {
|
|
155
166
|
Observer.set(this.network, 'strategy', 'cache-only');
|
|
@@ -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);
|
|
@@ -356,9 +356,9 @@ export default class Runtime {
|
|
|
356
356
|
}
|
|
357
357
|
|
|
358
358
|
// Initiates remote fetch and sets the status
|
|
359
|
-
remoteFetch(request) {
|
|
359
|
+
remoteFetch(request, ...args) {
|
|
360
360
|
Observer.set(this.network, 'remote', true);
|
|
361
|
-
let _response = fetch(request);
|
|
361
|
+
let _response = fetch(request, ...args);
|
|
362
362
|
// This catch() is NOT intended to handle failure of the fetch
|
|
363
363
|
_response.catch(e => Observer.set(this.network, 'error', e.message));
|
|
364
364
|
// Save a reference to this
|
|
@@ -401,6 +401,7 @@ export default class Runtime {
|
|
|
401
401
|
response.attrs.status = xRedirectCode;
|
|
402
402
|
response.headers.json({
|
|
403
403
|
'X-Redirect-Code': response.status,
|
|
404
|
+
'Access-Control-Allow-Origin': '*',
|
|
404
405
|
'Cache-Control': 'no-store',
|
|
405
406
|
});
|
|
406
407
|
}
|