@webqit/webflo 0.9.4 → 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
|
@@ -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 = [
|
|
@@ -109,6 +110,10 @@ export default class Worker {
|
|
|
109
110
|
// ------------
|
|
110
111
|
// The request object
|
|
111
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
|
+
}
|
|
112
117
|
// The navigation event
|
|
113
118
|
let httpEvent = new HttpEvent(request, detail, (id = null, persistent = false) => this.getSession(httpEvent, id, persistent));
|
|
114
119
|
httpEvent.port.listen(message => {
|
|
@@ -120,7 +125,7 @@ export default class Worker {
|
|
|
120
125
|
// Response
|
|
121
126
|
let response;
|
|
122
127
|
if (httpEvent.request.url.startsWith(self.origin)/* && httpEvent.request.mode === 'navigate'*/) {
|
|
123
|
-
response = await this.clients.get('*').handle(httpEvent, (...args) => this.remoteFetch(...args));
|
|
128
|
+
response = await this.clients.get('*').handle(httpEvent, ( ...args ) => this.remoteFetch( ...args ));
|
|
124
129
|
} else {
|
|
125
130
|
response = await this.remoteFetch(httpEvent.request);
|
|
126
131
|
}
|
|
@@ -152,7 +157,10 @@ export default class Worker {
|
|
|
152
157
|
}
|
|
153
158
|
|
|
154
159
|
// Initiates remote fetch and sets the status
|
|
155
|
-
remoteFetch(request) {
|
|
160
|
+
remoteFetch(request, ...args) {
|
|
161
|
+
if (arguments.length > 1) {
|
|
162
|
+
request = this.generateRequest(request, ...args);
|
|
163
|
+
}
|
|
156
164
|
const execFetch = () => {
|
|
157
165
|
if (_any((this.cx.params.cache_only_urls || []).map(c => c.trim()).filter(c => c), pattern => Minimatch.Minimatch(request.url, pattern))) {
|
|
158
166
|
Observer.set(this.network, 'strategy', 'cache-only');
|
|
@@ -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
|
}
|