@webqit/webflo 0.20.13 → 0.20.15

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.20.13",
15
+ "version": "0.20.15",
16
16
  "license": "MIT",
17
17
  "repository": {
18
18
  "type": "git",
@@ -44,7 +44,7 @@
44
44
  "dependencies": {
45
45
  "@octokit/webhooks": "^7.15.1",
46
46
  "@webqit/backpack": "^0.1.12",
47
- "@webqit/oohtml-ssr": "^2.2.1",
47
+ "@webqit/oohtml-ssr": "^2.2.2",
48
48
  "@webqit/use-live": "^0.5.44",
49
49
  "@webqit/util": "^0.8.11",
50
50
  "chokidar": "^4.0.3",
@@ -109,7 +109,7 @@ export class WebfloRuntime {
109
109
 
110
110
  // Dispatch event
111
111
  const router = new this.constructor.Router(this, httpEvent.url.pathname);
112
- await router.route(['SETUP'], httpEvent);
112
+ await router.route(['SETUP'], httpEvent.extend());
113
113
 
114
114
  // Do proper routing for respone
115
115
  const response = await new Promise(async (resolve) => {
@@ -144,9 +144,9 @@ export const response = {
144
144
  status: {
145
145
  get: function () {
146
146
  return _wq(this, 'meta').get('status')
147
- || this instanceof Response
148
- ? responseOriginals.prototype.status.get.call(this)
149
- : this.status;
147
+ || (this instanceof Response
148
+ ? responseOriginals.prototype.status.get.call(this)
149
+ : this.status);
150
150
  }
151
151
  },
152
152
  carry: { get: function () { return _wq(this, 'meta').get('carry'); } },
@@ -364,7 +364,7 @@ export async function parseHttpMessage(httpMessage) {
364
364
  const contentType = httpMessage.headers.get('Content-Type') || '';
365
365
  if (contentType === 'application/x-www-form-urlencoded' || contentType.startsWith('multipart/form-data')) {
366
366
  const fd = await httpMessage.formData();
367
- result = fd && await formData.json.value(fd);
367
+ result = fd && await formData.prototype.json.value.call(fd);
368
368
  } else if (contentType.startsWith('application/json')/*can include charset*/) {
369
369
  result = await httpMessage.json();
370
370
  } else /*if (contentType === 'text/plain')*/ {
@@ -1,5 +1,6 @@
1
1
  import { _isObject } from '@webqit/util/js/index.js';
2
2
  import { _even } from '@webqit/util/obj/index.js';
3
+ import { HttpEvent } from './HttpEvent.js';
3
4
 
4
5
  export class HttpState {
5
6
 
@@ -134,6 +135,10 @@ export class HttpState {
134
135
  entries.push(returnValue);
135
136
  continue main;
136
137
  }
138
+ if (callback instanceof HttpEvent) {
139
+ await callback.redirectWith(handler.url, handler.with || {});
140
+ return new Promise(() => { });
141
+ }
137
142
  const urlRewrite = new URL(handler.url, this.#request.url);
138
143
  const newThread = this.#thread.extend(urlRewrite.searchParams.get('_thread'));
139
144
  urlRewrite.searchParams.set('_thread', newThread.threadID);
@@ -152,7 +157,9 @@ export class HttpState {
152
157
  }
153
158
  entries.push(await this.get(attr));
154
159
  }
155
- if (callback) return await callback(...entries);
160
+ if (callback && !(callback instanceof HttpEvent)) {
161
+ return await callback(...entries);
162
+ }
156
163
  return entries;
157
164
  }
158
165
  }
@@ -172,7 +172,7 @@ export class WebfloRouter {
172
172
 
173
173
  // Call the handler
174
174
  const returnValue = await handler.call(thisContext, thisTick.event, $next/*next*/, $fetch/*fetch*/);
175
-
175
+
176
176
  // Handle cleanup on abort
177
177
  if (LiveResponse.test(returnValue) === 'LiveProgramHandle') {
178
178
  thisTick.event.signal.addEventListener('abort', () => {