Skip to content

Commit

Permalink
Expose TldrawToImageOptions.
Browse files Browse the repository at this point in the history
  • Loading branch information
kitschpatrol committed Jan 18, 2024
1 parent 1b2d368 commit 73225bf
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/lib/index.ts
Original file line number Diff line number Diff line change
@@ -1 +1 @@
export { tldrawToImage } from './tldraw-to-image'
export { type TldrawToImageOptions, tldrawToImage } from './tldraw-to-image'
16 changes: 8 additions & 8 deletions src/lib/tldraw-to-image.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import type { CDPSession, Page } from 'puppeteer'
import untildify from 'untildify'
import { slugify } from 'voca'

export type TldrawImageOptions = {
export type TldrawToImageOptions = {
darkMode?: boolean
format?: 'png' | 'svg'
frames?: boolean | string[]
Expand All @@ -29,10 +29,10 @@ export type TldrawImageOptions = {

// Name should default to undefined

type TldrawImageOptionsRequired = Required<Omit<TldrawImageOptions, 'name'>> &
Pick<TldrawImageOptions, 'name'>
type TldrawToImageOptionsRequired = Required<Omit<TldrawToImageOptions, 'name'>> &
Pick<TldrawToImageOptions, 'name'>

const defaultOptions: TldrawImageOptionsRequired = {
const defaultOptions: TldrawToImageOptionsRequired = {
darkMode: false,
format: 'svg',
frames: false,
Expand All @@ -47,17 +47,17 @@ const defaultOptions: TldrawImageOptionsRequired = {
// TODO Maybe get rid of this and always return an array in 3.0
export async function tldrawToImage(
tldrPathOrUrl: string,
options?: TldrawImageOptions & { frames?: false | undefined },
options?: TldrawToImageOptions & { frames?: false | undefined },
): Promise<string>
export async function tldrawToImage(
tldrPathOrUrl: string,
options?: TldrawImageOptions & { frames: string[] | true },
options?: TldrawToImageOptions & { frames: string[] | true },
): Promise<string[]>
export async function tldrawToImage(
tldrPathOrUrl: string,
options?: TldrawImageOptions,
options?: TldrawToImageOptions,
): Promise<string | string[]> {
const resolvedOptions: TldrawImageOptionsRequired = {
const resolvedOptions: TldrawToImageOptionsRequired = {
...defaultOptions,
...stripUndefined(options ?? {}),
}
Expand Down

0 comments on commit 73225bf

Please sign in to comment.