From c7081b7950f5f2df6bd25bc822b48baff4583718 Mon Sep 17 00:00:00 2001 From: Rich Harris Date: Tue, 30 Aug 2022 07:08:55 -0400 Subject: [PATCH] fix docs --- packages/kit/src/exports/hooks/sequence.js | 9 --------- packages/kit/types/ambient.d.ts | 17 +++++++++++++++-- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/packages/kit/src/exports/hooks/sequence.js b/packages/kit/src/exports/hooks/sequence.js index 2c7ba157944e..c65afca9eb1d 100644 --- a/packages/kit/src/exports/hooks/sequence.js +++ b/packages/kit/src/exports/hooks/sequence.js @@ -1,13 +1,4 @@ /** - * Merge an array of multiple handlers into one. The `resolve` passed - * to the first handler will call the second handler, and so on, - * until the last handler calls the framework. - * - * If handlers use the `transformPageChunk` option, the functions - * will be 'chained', meaning a transform function specified in - * the first handler will be applied to later handlers, and - * multiple transformations can be applied. - * * @param {...import('types').Handle} handlers * @returns {import('types').Handle} */ diff --git a/packages/kit/types/ambient.d.ts b/packages/kit/types/ambient.d.ts index ebde74cb4a44..427040fcec29 100644 --- a/packages/kit/types/ambient.d.ts +++ b/packages/kit/types/ambient.d.ts @@ -300,7 +300,13 @@ declare module '@sveltejs/kit/hooks' { * /** @type {import('@sveltejs/kit').Handle} *\/ * async function first({ event, resolve }) { * console.log('first pre-processing'); - * const result = await resolve(event); + * const result = await resolve(event, { + * transformPageChunk: ({ html }) => { + * // transforms are applied in reverse order + * console.log('first transform'); + * return html; + * } + * }); * console.log('first post-processing'); * return result; * } @@ -308,7 +314,12 @@ declare module '@sveltejs/kit/hooks' { * /** @type {import('@sveltejs/kit').Handle} *\/ * async function second({ event, resolve }) { * console.log('second pre-processing'); - * const result = await resolve(event); + * const result = await resolve(event, { + * transformPageChunk: ({ html }) => { + * console.log('second transform'); + * return html; + * } + * }); * console.log('second post-processing'); * return result; * } @@ -321,6 +332,8 @@ declare module '@sveltejs/kit/hooks' { * ``` * first pre-processing * second pre-processing + * second transform + * first transform * second post-processing * first post-processing * ```