diff --git a/.changeset/great-grapes-burn.md b/.changeset/great-grapes-burn.md index beaa934c..cd155382 100644 --- a/.changeset/great-grapes-burn.md +++ b/.changeset/great-grapes-burn.md @@ -4,9 +4,9 @@ This version of Frog removes the concept of "Render Cycles". All frames now facilitate a single cycle. -There are a couple of small **breaking changes**: +There are a couple of small **deprecations**: -1. Removed `cycle` from context – you can now omit the conditionals completely. +1. Deprecated `cycle` from context – you can now omit the conditionals completely. ```diff app.frame('/', c => { @@ -15,7 +15,7 @@ app.frame('/', c => { }) ``` -2. Moved `fonts` property in `c.res` to frame route options: +2. Deprecated `fonts` property in `c.res` in favor of `fonts` on frame route options: ```diff app.frame('/', c => { diff --git a/src/frog-base.tsx b/src/frog-base.tsx index 75e32eca..9962d817 100644 --- a/src/frog-base.tsx +++ b/src/frog-base.tsx @@ -213,8 +213,16 @@ export class FrogBase< imageAspectRatio: FrameImageAspectRatio = '1.91:1' /** Image options. */ imageOptions: - | Omit - | (() => Promise>) + | (Omit & { + /** @deprecated Pass `fonts` to the route options instead. @see https://frog.fm/reference/frog-frame-response#imageoptions */ + fonts?: ImageResponseOptions['fonts'] + }) + | (() => Promise< + Omit & { + /** @deprecated Pass `fonts` to the route options instead. @see https://frog.fm/reference/frog-frame-response#imageoptions */ + fonts?: ImageResponseOptions['fonts'] + } + >) | undefined fetch: Hono['fetch'] get: Hono['get'] @@ -360,7 +368,11 @@ export class FrogBase< ) const imageParams = toSearchParams({ image: encodedImage, - imageOptions, + imageOptions: { + ...imageOptions, + // TODO: Remove once `fonts` is removed from `imageOptions`. + fonts: undefined, + }, headers, }) return `${parsePath(context.url)}/image?${imageParams}` diff --git a/src/types/context.ts b/src/types/context.ts index 13aeba06..0e8052b3 100644 --- a/src/types/context.ts +++ b/src/types/context.ts @@ -92,6 +92,15 @@ export type FrameContext< // _state = env['State'], > = Context & { + /** + * @deprecated As of `v0.5.0`, this property is redundant (there is now only one render cycle) and will be removed in a future version. + * + * Current render cycle of the frame. + * + * - `main` - Render cycle for the main frame route. + * - `image` - Render cycle for the OG image route. + */ + cycle: 'main' | 'image' /** * Function to derive the frame's state based off the state from the * previous frame. diff --git a/src/utils/getFrameContext.ts b/src/utils/getFrameContext.ts index 75079094..5a88601f 100644 --- a/src/utils/getFrameContext.ts +++ b/src/utils/getFrameContext.ts @@ -79,6 +79,7 @@ export function getFrameContext< context: { buttonIndex: frameData?.buttonIndex, buttonValue, + cycle: 'main', deriveState: deriveState as FrameContext['deriveState'], env, frameData,