From 0cead47f76f7b8d12f008333bfb1cc2ca41fb335 Mon Sep 17 00:00:00 2001 From: TheComputerM Date: Tue, 13 Oct 2020 09:51:22 +0530 Subject: [PATCH 1/7] add types for stores --- runtime/index.d.ts | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/runtime/index.d.ts b/runtime/index.d.ts index b342e3cba..6d78dac78 100644 --- a/runtime/index.d.ts +++ b/runtime/index.d.ts @@ -1,4 +1,7 @@ declare module '@sapper/app' { + import { Readable, Writable } from 'svelte/store'; + import { PageContext } from '@sapper/app/types'; + export interface Redirect { statusCode: number location: string @@ -8,7 +11,11 @@ declare module '@sapper/app' { export function prefetch(href: string): Promise<{ redirect?: Redirect; data?: unknown }>; export function prefetchRoutes(pathnames: string[]): Promise; export function start(opts: { target: Node }): Promise; - export const stores: () => unknown; + export function stores(): { + preloading: Readable + page: Readable + session: Writable + }; } declare module '@sapper/server' { @@ -39,15 +46,9 @@ declare module '@sapper/common' { redirect: (statusCode: number, location: string) => void; } - export interface Page { - host: string; - path: string; - params: Record; - query: Record; - error?: Error; - } + export { PageContext as Page } from '@sapper/app/types'; export interface Preload { - (this: PreloadContext, page: Page, session: any): object | Promise; + (this: PreloadContext, page: PageContext, session: any): object | Promise; } } From 5f4097a870e11b05a13e485e824ea73bebc53908 Mon Sep 17 00:00:00 2001 From: TheComputerM Date: Tue, 13 Oct 2020 15:24:38 +0530 Subject: [PATCH 2/7] make middleware opts optional ts --- runtime/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/index.d.ts b/runtime/index.d.ts index 6d78dac78..332181355 100644 --- a/runtime/index.d.ts +++ b/runtime/index.d.ts @@ -28,7 +28,7 @@ declare module '@sapper/server' { ignore?: Ignore } - export function middleware(opts: MiddlewareOptions): Handler; + export function middleware(opts?: MiddlewareOptions): Handler; } declare module '@sapper/service-worker' { From 0d60b9ef9255b9bc4a46002c133e42a76e8c4bce Mon Sep 17 00:00:00 2001 From: TheComputerM Date: Wed, 14 Oct 2020 10:21:13 +0530 Subject: [PATCH 3/7] fix some types --- runtime/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/index.d.ts b/runtime/index.d.ts index 332181355..929018319 100644 --- a/runtime/index.d.ts +++ b/runtime/index.d.ts @@ -7,10 +7,10 @@ declare module '@sapper/app' { location: string } - export function goto(href: string, opts: { noscroll?: boolean, replaceState?: boolean }): Promise; + export function goto(href: string, opts?: { noscroll?: boolean, replaceState?: boolean }): Promise; export function prefetch(href: string): Promise<{ redirect?: Redirect; data?: unknown }>; export function prefetchRoutes(pathnames: string[]): Promise; - export function start(opts: { target: Node }): Promise; + export function start(opts: { target: Element }): Promise; export function stores(): { preloading: Readable page: Readable From 60bb696d4ad35541a09662adf709cf82938a6cde Mon Sep 17 00:00:00 2001 From: TheComputerM Date: Thu, 15 Oct 2020 19:51:20 +0530 Subject: [PATCH 4/7] change Element to Node --- runtime/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/index.d.ts b/runtime/index.d.ts index 929018319..47ca97194 100644 --- a/runtime/index.d.ts +++ b/runtime/index.d.ts @@ -10,7 +10,7 @@ declare module '@sapper/app' { export function goto(href: string, opts?: { noscroll?: boolean, replaceState?: boolean }): Promise; export function prefetch(href: string): Promise<{ redirect?: Redirect; data?: unknown }>; export function prefetchRoutes(pathnames: string[]): Promise; - export function start(opts: { target: Element }): Promise; + export function start(opts: { target: Node }): Promise; export function stores(): { preloading: Readable page: Readable From fecc322336f15a0519aab33626cf0e137ca92ed7 Mon Sep 17 00:00:00 2001 From: TheComputerM Date: Fri, 23 Oct 2020 13:14:48 +0530 Subject: [PATCH 5/7] define session type Co-authored-by: Ben Cates --- runtime/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/runtime/index.d.ts b/runtime/index.d.ts index 47ca97194..5f2db1882 100644 --- a/runtime/index.d.ts +++ b/runtime/index.d.ts @@ -11,10 +11,10 @@ declare module '@sapper/app' { export function prefetch(href: string): Promise<{ redirect?: Redirect; data?: unknown }>; export function prefetchRoutes(pathnames: string[]): Promise; export function start(opts: { target: Node }): Promise; - export function stores(): { + export function stores(): { preloading: Readable page: Readable - session: Writable + session: Writable }; } From 042c9a0705893e331e0ff94a023983138b4c2816 Mon Sep 17 00:00:00 2001 From: TheComputerM Date: Fri, 23 Oct 2020 13:15:29 +0530 Subject: [PATCH 6/7] add session type to middleware Co-authored-by: Ben Cates --- runtime/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/index.d.ts b/runtime/index.d.ts index 5f2db1882..e9d858a95 100644 --- a/runtime/index.d.ts +++ b/runtime/index.d.ts @@ -28,7 +28,7 @@ declare module '@sapper/server' { ignore?: Ignore } - export function middleware(opts?: MiddlewareOptions): Handler; + export function middleware(opts?: MiddlewareOptions): Handler; } declare module '@sapper/service-worker' { From 7f079e6c41ea87fc7cb32782d7c114a4ed5d14e3 Mon Sep 17 00:00:00 2001 From: TheComputerM Date: Mon, 26 Oct 2020 10:24:22 +0530 Subject: [PATCH 7/7] get PageContext from @sapper/common --- runtime/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/runtime/index.d.ts b/runtime/index.d.ts index 3cd033ab4..f41c61204 100644 --- a/runtime/index.d.ts +++ b/runtime/index.d.ts @@ -7,7 +7,7 @@ declare module '@sapper/app' { import { Readable, Writable } from 'svelte/store'; - import { PageContext } from '@sapper/app/types'; + import { PageContext } from '@sapper/common'; export interface Redirect { statusCode: number