@webqit/webflo 0.9.3 → 0.9.6

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.3",
15
+ "version": "0.9.6",
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/index.js",
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 = 300;
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
@@ -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
- //Fs.unlinkSync(bundlingConfig.entry);
238
+ Fs.unlinkSync(bundlingConfig.entry);
239
239
  resolve(log);
240
240
  });
241
241
  });
@@ -77,7 +77,7 @@ export default class Worker {
77
77
  // ONFETCH
78
78
  self.addEventListener('fetch', async evt => {
79
79
  // URL schemes that might arrive here but not supported; e.g.: chrome-extension://
80
- if (!evt.request.url.startsWith('http')) return;
80
+ if (!evt.request.url.startsWith('http') || evt.request.mode === 'navigate') return;
81
81
  const requestInit = [
82
82
  'method', 'headers', 'body', 'mode', 'credentials', 'cache', 'redirect', 'referrer', 'integrity',
83
83
  ].reduce((init, prop) => ({ [prop]: evt.request[prop], ...init }), {});
@@ -109,6 +109,10 @@ export default class Worker {
109
109
  // ------------
110
110
  // The request object
111
111
  let request = this.generateRequest(url.href, init);
112
+ if (detail.event instanceof self.Request) {
113
+ request = detail.event.request;
114
+ //Object.defineProperty(detail.event, 'request', { value: request });
115
+ }
112
116
  // The navigation event
113
117
  let httpEvent = new HttpEvent(request, detail, (id = null, persistent = false) => this.getSession(httpEvent, id, persistent));
114
118
  httpEvent.port.listen(message => {
@@ -120,7 +124,7 @@ export default class Worker {
120
124
  // Response
121
125
  let response;
122
126
  if (httpEvent.request.url.startsWith(self.origin)/* && httpEvent.request.mode === 'navigate'*/) {
123
- response = await this.clients.get('*').handle(httpEvent, (...args) => this.remoteFetch(...args));
127
+ response = await this.clients.get('*').handle(httpEvent, ( ...args ) => this.remoteFetch( ...args ));
124
128
  } else {
125
129
  response = await this.remoteFetch(httpEvent.request);
126
130
  }
@@ -152,7 +156,10 @@ export default class Worker {
152
156
  }
153
157
 
154
158
  // Initiates remote fetch and sets the status
155
- remoteFetch(request) {
159
+ remoteFetch(request, ...args) {
160
+ if (arguments.length > 1) {
161
+ request = this.generateRequest(request, ...args);
162
+ }
156
163
  const execFetch = () => {
157
164
  if (_any((this.cx.params.cache_only_urls || []).map(c => c.trim()).filter(c => c), pattern => Minimatch.Minimatch(request.url, pattern))) {
158
165
  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
  }