Skip to content

Commit

Permalink
deprecate instead
Browse files Browse the repository at this point in the history
  • Loading branch information
jxom committed Mar 7, 2024
1 parent 3564d39 commit c80bae7
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 6 deletions.
6 changes: 3 additions & 3 deletions .changeset/great-grapes-burn.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand All @@ -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 => {
Expand Down
18 changes: 15 additions & 3 deletions src/frog-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,16 @@ export class FrogBase<
imageAspectRatio: FrameImageAspectRatio = '1.91:1'
/** Image options. */
imageOptions:
| Omit<ImageResponseOptions, 'fonts'>
| (() => Promise<Omit<ImageResponseOptions, 'fonts'>>)
| (Omit<ImageResponseOptions, 'fonts'> & {
/** @deprecated Pass `fonts` to the route options instead. @see https://frog.fm/reference/frog-frame-response#imageoptions */
fonts?: ImageResponseOptions['fonts']
})
| (() => Promise<
Omit<ImageResponseOptions, 'fonts'> & {
/** @deprecated Pass `fonts` to the route options instead. @see https://frog.fm/reference/frog-frame-response#imageoptions */
fonts?: ImageResponseOptions['fonts']
}
>)
| undefined
fetch: Hono<env, schema, basePath>['fetch']
get: Hono<env, schema, basePath>['get']
Expand Down Expand Up @@ -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}`
Expand Down
9 changes: 9 additions & 0 deletions src/types/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,15 @@ export type FrameContext<
//
_state = env['State'],
> = Context<env, path, _state> & {
/**
* @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.
Expand Down
1 change: 1 addition & 0 deletions src/utils/getFrameContext.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ export function getFrameContext<
context: {
buttonIndex: frameData?.buttonIndex,
buttonValue,
cycle: 'main',
deriveState: deriveState as FrameContext['deriveState'],
env,
frameData,
Expand Down

0 comments on commit c80bae7

Please sign in to comment.