@webqit/webflo 0.9.4 → 0.9.7-0
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
|
@@ -147,7 +147,6 @@ export default class Runtime {
|
|
|
147
147
|
this.go(Url.copy(actionEl), {
|
|
148
148
|
method: submitParams.method,
|
|
149
149
|
body: formData,
|
|
150
|
-
headers: { contentType: submitParams.enctype },
|
|
151
150
|
}, { ...submitParams, src: form, srcType: 'form', });
|
|
152
151
|
// URLs with # will cause a natural navigation
|
|
153
152
|
// even if pointing to a different page, a natural navigation will still happen
|
|
@@ -191,7 +190,7 @@ export default class Runtime {
|
|
|
191
190
|
this._abortController.abort();
|
|
192
191
|
}
|
|
193
192
|
this._abortController = new AbortController();
|
|
194
|
-
this._xRedirectCode =
|
|
193
|
+
this._xRedirectCode = 200;
|
|
195
194
|
// ------------
|
|
196
195
|
url = typeof url === 'string' ? new whatwag.URL(url) : url;
|
|
197
196
|
init = { referrer: this.location.href, ...init };
|
|
@@ -213,7 +212,7 @@ export default class Runtime {
|
|
|
213
212
|
// The navigation event
|
|
214
213
|
let httpEvent = new HttpEvent(request, detail, (id = null, persistent = false) => this.getSession(httpEvent, id, persistent));
|
|
215
214
|
// Response
|
|
216
|
-
let response = await this.clients.get('*').handle(httpEvent, (...args) => this.remoteFetch(...args));
|
|
215
|
+
let response = await this.clients.get('*').handle(httpEvent, ( ...args ) => this.remoteFetch( ...args ));
|
|
217
216
|
let finalResponse = this.handleResponse(httpEvent, response);
|
|
218
217
|
// Return value
|
|
219
218
|
return finalResponse;
|
|
@@ -240,9 +239,9 @@ export default class Runtime {
|
|
|
240
239
|
}
|
|
241
240
|
|
|
242
241
|
// Initiates remote fetch and sets the status
|
|
243
|
-
remoteFetch(request) {
|
|
242
|
+
remoteFetch(request, ...args) {
|
|
244
243
|
Observer.set(this.network, 'remote', true);
|
|
245
|
-
let _response = fetch(request);
|
|
244
|
+
let _response = fetch(request, ...args);
|
|
246
245
|
// This catch() is NOT intended to handle failure of the fetch
|
|
247
246
|
_response.catch(e => Observer.set(this.network, 'error', e.message));
|
|
248
247
|
// Return xResponse
|
|
@@ -235,7 +235,7 @@ function bundle(gen, output, asModule = false) {
|
|
|
235
235
|
let log = stats.toString({ colors: true, });
|
|
236
236
|
cx.logger && cx.logger.log(log);
|
|
237
237
|
// Remove moduleFile build
|
|
238
|
-
|
|
238
|
+
Fs.unlinkSync(bundlingConfig.entry);
|
|
239
239
|
resolve(log);
|
|
240
240
|
});
|
|
241
241
|
});
|
|
@@ -76,8 +76,9 @@ export default class Worker {
|
|
|
76
76
|
// -------------
|
|
77
77
|
// ONFETCH
|
|
78
78
|
self.addEventListener('fetch', async evt => {
|
|
79
|
+
return;
|
|
79
80
|
// URL schemes that might arrive here but not supported; e.g.: chrome-extension://
|
|
80
|
-
if (!evt.request.url.startsWith('http')) return;
|
|
81
|
+
if (!evt.request.url.startsWith('http') || evt.request.mode === 'navigate') return;
|
|
81
82
|
const requestInit = [
|
|
82
83
|
'method', 'headers', 'body', 'mode', 'credentials', 'cache', 'redirect', 'referrer', 'integrity',
|
|
83
84
|
].reduce((init, prop) => ({ [prop]: evt.request[prop], ...init }), {});
|
|
@@ -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
|
}
|