@jon49/sw 0.14.3 → 0.14.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.
@@ -10,9 +10,10 @@ function streamResponse(response: { body: Generator, headers?: any }): Response
10
10
  if (typeof x === "string")
11
11
  controller.enqueue(encoder.encode(x))
12
12
  }
13
- controller.close()
14
13
  } catch (error) {
15
14
  console.error(error)
15
+ } finally {
16
+ controller.close()
16
17
  }
17
18
  }
18
19
  })
@@ -160,7 +160,7 @@ async function executeHandler({ url, req, ctx }: ExectuteHandlerOptions): Promis
160
160
  } else if (result.messages?.length > 0) {
161
161
  messages.push(...result.messages)
162
162
  }
163
- ctx.messages = messages
163
+ ctx.messages = result.messages = messages
164
164
  ctx.events = result.events
165
165
 
166
166
  if (isHtml(result)) {
@@ -180,13 +180,17 @@ async function executeHandler({ url, req, ctx }: ExectuteHandlerOptions): Promis
180
180
  result.headers = {
181
181
  ...result.headers,
182
182
  }
183
+ } else if (result.messages?.length > 0) {
184
+ return {
185
+ ...result,
186
+ status: result.status || 204,
187
+ }
183
188
  }
184
189
  return {
185
190
  ...result,
186
191
  type: "application/json"
187
192
  }
188
193
  }
189
-
190
194
  } catch (error) {
191
195
  console.error(`"${method}" error:`, error, "\nURL:", url);
192
196
  if (isPost) {
@@ -306,4 +310,3 @@ type RequireAtLeastOne<T, Keys extends keyof T = keyof T> =
306
310
 
307
311
  export type Route = RequireAtLeastOne<Route_, "file" | "get" | "post">
308
312
  export type RoutePage = Pick<Route_, "get" | "post">
309
-
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jon49/sw",
3
- "version": "0.14.3",
3
+ "version": "0.14.5",
4
4
  "description": "Packages for MVC service workers.",
5
5
  "type": "module",
6
6
  "files": [