@jon49/sw 0.15.0 → 0.15.2

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.
@@ -25,7 +25,7 @@ async function setPagesToReturn(targetDirectory: string) {
25
25
  await Promise.all(files.map(async (file: string) => {
26
26
  let filename = path.join(targetDirectory, file)
27
27
  let content = await readFile(filename, "utf-8")
28
- let matched = content.match(/,(\w*)=(\w*);export/)
28
+ let matched = content.match(/,(\w*)=([\w|\$]*);export/)
29
29
  if (matched) {
30
30
  let [, name, value] = matched
31
31
  content = content.replace(`,${name}=${value}`, "")
@@ -147,9 +147,8 @@ async function executeHandler({ url, req, ctx }: ExectuteHandlerOptions): Promis
147
147
  || call(handlers[method], args)
148
148
  || Promise.reject("I'm sorry, I didn't understand where to route your request.")))
149
149
  } catch (e: any) {
150
- if (e.reasons) {
151
- ctx.messages =
152
- e.reasons.map((x: any) => x.reason.reasons).flat().map((x: any) => x.reason).flat()
150
+ if (Array.isArray(e)) {
151
+ ctx.messages = e
153
152
  return {
154
153
  status: 204,
155
154
  }
@@ -290,14 +289,20 @@ export interface RouteObjectReturn {
290
289
  json?: any
291
290
  }
292
291
 
293
- export interface RouteHandler<T> {
292
+ export type RouteHandler<T> = {
294
293
  (options: T): Promise<
295
294
  AsyncGenerator
296
295
  | Response
297
296
  | RouteObjectReturn
298
297
  | undefined
299
298
  | null
300
- | void>
299
+ | void> | (
300
+ AsyncGenerator
301
+ | Response
302
+ | RouteObjectReturn
303
+ | undefined
304
+ | null
305
+ | void)
301
306
  }
302
307
 
303
308
  export interface RoutePostHandler {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jon49/sw",
3
- "version": "0.15.0",
3
+ "version": "0.15.2",
4
4
  "description": "Packages for MVC service workers.",
5
5
  "type": "module",
6
6
  "files": [