Skip to content

Commit

Permalink
fix: delete font from frame response imageOptions (#324)
Browse files Browse the repository at this point in the history
* fix: delete `font` from frame response `imageOptions`

Closes #303

* chore: changesets

* fix: types

* fix: build

* nit: prettify 💅
  • Loading branch information
dalechyn committed May 23, 2024
1 parent d8aabe7 commit a22492a
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
5 changes: 5 additions & 0 deletions .changeset/three-swans-admire.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"frog": patch
---

Deleted `font` property from `imageOptions` type in frame handler response.
10 changes: 2 additions & 8 deletions src/frog-base.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -603,13 +603,7 @@ export class FrogBase<
)
const imageParams = toSearchParams({
image: compressedImage,
imageOptions: imageOptions
? {
...imageOptions,
// TODO: Remove once `fonts` is removed from `imageOptions`.
fonts: undefined,
}
: undefined,
imageOptions,
headers,
})
return `${parsePath(context.url)}/image?${imageParams}`
Expand Down Expand Up @@ -692,7 +686,7 @@ export class FrogBase<
return Object.values(this.ui.vars.fonts).flat()
if (typeof options?.fonts === 'function') return await options.fonts()
if (options?.fonts) return options.fonts
return imageOptions?.fonts
return (imageOptions as ImageOptions | undefined)?.fonts
})()
const groupedFonts = new Map<string, NonNullable<typeof fonts>>()
if (fonts)
Expand Down
3 changes: 2 additions & 1 deletion src/types/frame.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { type ImageResponseOptions } from 'hono-og'
import type { Hash } from 'viem'
import type { TypedResponse } from './response.js'
import type { Pretty } from './utils.js'

export type Font = {
name: string
Expand Down Expand Up @@ -130,7 +131,7 @@ export type FrameResponse = {
* @example
* { width: 1200, height: 630 }
*/
imageOptions?: ImageOptions | undefined
imageOptions?: Pretty<Omit<ImageOptions, 'fonts'>> | undefined
}
| {
/**
Expand Down

0 comments on commit a22492a

Please sign in to comment.