canvacord
Advanced tools
Comparing version 6.0.0-beta.1 to 6.0.0-beta.2
@@ -20,6 +20,6 @@ import { Font as Font$1, SatoriOptions } from 'satori'; | ||
* @param [alias] The font alias. If not provided, a random UUID will be used. | ||
* @example ```typescript | ||
* | ||
* const data = await readFile('path/to/font.ttf'); | ||
* const font = new Font(data, 'my-font'); | ||
* ``` | ||
*/ | ||
@@ -47,5 +47,5 @@ constructor(data: Buffer, alias?: string); | ||
* @param [alias] The font alias. If not provided, a random UUID will be used. | ||
* @example ```typescript | ||
* | ||
* const font = await Font.fromFile('path/to/font.ttf', 'my-font'); | ||
* ``` | ||
*/ | ||
@@ -57,5 +57,4 @@ static fromFile(path: string, alias?: string): Promise<Font>; | ||
* @param [alias] The font alias. If not provided, a random UUID will be used. | ||
* @example ```typescript | ||
* | ||
* const font = Font.fromFileSync('path/to/font.ttf', 'my-font'); | ||
* ``` | ||
*/ | ||
@@ -67,6 +66,6 @@ static fromFileSync(path: string, alias?: string): Font; | ||
* @param [alias] The font alias. If not provided, a random UUID will be used. | ||
* @example ```typescript | ||
* | ||
* const buffer = await readFile('path/to/font.ttf'); | ||
* const font = Font.fromBuffer(buffer, 'my-font'); | ||
* ``` | ||
*/ | ||
@@ -76,5 +75,5 @@ static fromBuffer(buffer: Buffer, alias?: string): Font; | ||
* Loads the default font bundled with this package. | ||
* @example ```typescript | ||
* | ||
* const font = Font.loadDefault(); | ||
* ``` | ||
*/ | ||
@@ -131,3 +130,3 @@ static loadDefault(): Font; | ||
type EncodingFormat = 'png' | 'jpeg' | 'webp' | 'avif'; | ||
type EncodingFormat = "png" | "jpeg" | "webp" | "avif"; | ||
declare abstract class Encodable { | ||
@@ -146,3 +145,3 @@ /** | ||
*/ | ||
encode(format: 'png'): Promise<Buffer>; | ||
encode(format: "png"): Promise<Buffer>; | ||
/** | ||
@@ -153,3 +152,3 @@ * Encodes the canvas to a jpeg or webp buffer. | ||
*/ | ||
encode(format: 'jpeg' | 'webp', options?: number): Promise<Buffer>; | ||
encode(format: "jpeg" | "webp", options?: number): Promise<Buffer>; | ||
/** | ||
@@ -160,3 +159,3 @@ * Encodes the canvas to an avif buffer. | ||
*/ | ||
encode(format: 'avif', options?: AvifConfig): Promise<Buffer>; | ||
encode(format: "avif", options?: AvifConfig): Promise<Buffer>; | ||
} | ||
@@ -270,11 +269,11 @@ | ||
*/ | ||
align?: 'left' | 'center' | 'right'; | ||
align?: "left" | "center" | "right"; | ||
/** | ||
* The baseline of the text. | ||
*/ | ||
baseline?: 'top' | 'middle' | 'bottom'; | ||
baseline?: "top" | "middle" | "bottom"; | ||
/** | ||
* The directionality of the text. | ||
*/ | ||
direction?: 'inherit' | 'ltr' | 'rtl'; | ||
direction?: "inherit" | "ltr" | "rtl"; | ||
/** | ||
@@ -567,5 +566,5 @@ * The function to call before processing this step. | ||
* @param source The image source | ||
* @example ```typescript | ||
* | ||
* const image = new TemplateImage('https://example.com/image.png'); | ||
* ``` | ||
*/ | ||
@@ -659,2 +658,6 @@ constructor(source: ImageSource); | ||
type GraphemeProvider = Record<string, string>; | ||
declare const BuiltInGraphemeProvider: { | ||
TWEMOJI: GraphemeProvider; | ||
}; | ||
/** | ||
@@ -684,3 +687,3 @@ * The builder template. | ||
*/ | ||
type BuildFormat = 'svg' | 'png' | 'avif' | 'jpeg' | 'webp'; | ||
type BuildFormat = "svg" | "png" | "avif" | "jpeg" | "webp"; | ||
/** | ||
@@ -729,2 +732,6 @@ * The builder build options. | ||
/** | ||
* The grapheme provider of this builder. | ||
*/ | ||
graphemeProvider: GraphemeProvider; | ||
/** | ||
* Create a new builder. | ||
@@ -757,2 +764,6 @@ * @param width the width of this builder. | ||
/** | ||
* Set grapheme image provider for this builder. | ||
*/ | ||
setGraphemeProvider(provider: GraphemeProvider): this; | ||
/** | ||
* Set the style of this builder. | ||
@@ -854,3 +865,3 @@ * @param newStyle the new style. | ||
*/ | ||
setHeader(data: LeaderboardProps['header'] & {}): this; | ||
setHeader(data: LeaderboardProps["header"] & {}): this; | ||
/** | ||
@@ -860,3 +871,3 @@ * Set players for this leaderboard ui | ||
*/ | ||
setPlayers(players: LeaderboardProps['players']): this; | ||
setPlayers(players: LeaderboardProps["players"]): this; | ||
/** | ||
@@ -873,239 +884,106 @@ * Render this leaderboard ui on the canvas | ||
*/ | ||
renderTop({ avatar, displayName, level, rank, username, xp }: LeaderboardProps['players'][number]): Promise<JSX.Element>; | ||
renderTop({ avatar, displayName, level, rank, username, xp }: LeaderboardProps["players"][number]): Promise<JSX.Element>; | ||
/** | ||
* Render player ui on the canvas | ||
*/ | ||
renderPlayer({ avatar, displayName, level, rank, username, xp }: LeaderboardProps['players'][number]): Promise<JSX.Element>; | ||
renderPlayer({ avatar, displayName, level, rank, username, xp }: LeaderboardProps["players"][number]): Promise<JSX.Element>; | ||
} | ||
declare enum RankCardUserStatus { | ||
Online = "ONLINE", | ||
Idle = "IDLE", | ||
DoNotDisturb = "DND", | ||
Offline = "OFFLINE", | ||
Streaming = "STREAMING", | ||
None = "NONE" | ||
} | ||
interface RankCardProps { | ||
handle: string | null; | ||
username: string | null; | ||
avatar: string; | ||
status: RankCardUserStatus | null; | ||
currentXP: number | null; | ||
requiredXP: number | null; | ||
rank: number | null; | ||
level: number | null; | ||
backgroundColor: string; | ||
overlay: boolean | number | string; | ||
abbreviate: boolean; | ||
texts: Partial<{ | ||
level: string; | ||
xp: string; | ||
rank: string; | ||
}>; | ||
styles: Partial<{ | ||
container: string; | ||
background: string; | ||
overlay: string; | ||
avatar: Partial<{ | ||
container: string; | ||
image: string; | ||
status: string; | ||
}>; | ||
username: Partial<{ | ||
container: string; | ||
name: string; | ||
handle: string; | ||
}>; | ||
progressbar: Partial<{ | ||
container: string; | ||
thumb: string; | ||
track: string; | ||
}>; | ||
statistics: Partial<{ | ||
container: string; | ||
level: Partial<{ | ||
container: string; | ||
text: string; | ||
value: string; | ||
}>; | ||
xp: Partial<{ | ||
container: string; | ||
text: string; | ||
value: string; | ||
}>; | ||
rank: Partial<{ | ||
container: string; | ||
text: string; | ||
value: string; | ||
}>; | ||
}>; | ||
}>; | ||
} | ||
/** | ||
* The user status type. | ||
*/ | ||
type StatusType = 'online' | 'idle' | 'dnd' | 'invisible'; | ||
/** | ||
* The rank card builder props. | ||
*/ | ||
interface RankCardBuilderProps { | ||
/** | ||
* The avatar for this rank card. | ||
*/ | ||
avatar: ImageSource | null; | ||
/** | ||
* The style for this rank card. | ||
*/ | ||
style: CSSPropertiesLike | null; | ||
/** | ||
* The fonts to be used for this rank card. | ||
*/ | ||
interface RankCardBuilderProps extends Omit<RankCardProps, "avatar" | "backgroundColor"> { | ||
avatar: ImageSource; | ||
background: ImageSource; | ||
backgroundCrop?: Partial<{ | ||
x: number; | ||
y: number; | ||
width: number; | ||
height: number; | ||
}>; | ||
fonts: Partial<{ | ||
/** | ||
* The username font. | ||
*/ | ||
username: string; | ||
/** | ||
* The progress font. | ||
*/ | ||
progress: string; | ||
/** | ||
* The stats font. | ||
*/ | ||
stats: string; | ||
username: Partial<{ | ||
name: string; | ||
handle: string; | ||
}>; | ||
progress: Partial<{ | ||
level: Partial<{ | ||
text: string; | ||
value: string; | ||
}>; | ||
xp: Partial<{ | ||
text: string; | ||
value: string; | ||
}>; | ||
rank: Partial<{ | ||
text: string; | ||
value: string; | ||
}>; | ||
}>; | ||
}>; | ||
/** | ||
* The status for this rank card. | ||
*/ | ||
status: StatusType; | ||
/** | ||
* The current xp for this rank card. | ||
*/ | ||
currentXP: number; | ||
/** | ||
* The required xp for this rank card. | ||
*/ | ||
requiredXP: number; | ||
/** | ||
* The username for this rank card. | ||
*/ | ||
username: string; | ||
/** | ||
* The display name for this rank card. | ||
*/ | ||
displayName: string; | ||
/** | ||
* The discriminator for this rank card. | ||
*/ | ||
discriminator: string; | ||
/** | ||
* The level of this rank card. | ||
*/ | ||
level: number; | ||
/** | ||
* The rank of this rank card. | ||
*/ | ||
rank: number; | ||
/** | ||
* The background for this rank card. | ||
*/ | ||
background: ImageSource; | ||
/** | ||
* The styles for each element of this rank card. | ||
*/ | ||
tw: { | ||
/** | ||
* The username style. | ||
*/ | ||
username: string; | ||
/** | ||
* The discriminator style. | ||
*/ | ||
discriminator: string; | ||
/** | ||
* The display name style. | ||
*/ | ||
displayName: string; | ||
/** | ||
* The level style. | ||
*/ | ||
level: string; | ||
/** | ||
* The rank style. | ||
*/ | ||
rank: string; | ||
/** | ||
* The xp style. | ||
*/ | ||
xp: string; | ||
/** | ||
* The progressbar style. | ||
*/ | ||
progress: { | ||
/** | ||
* The progressbar track style. | ||
*/ | ||
track: string; | ||
/** | ||
* The progressbar thumb style. | ||
*/ | ||
thumb: string; | ||
}; | ||
/** | ||
* The overlay style. | ||
*/ | ||
overlay: string; | ||
/** | ||
* The percentage style. | ||
*/ | ||
percentage: string; | ||
/** | ||
* The avatar style. | ||
*/ | ||
avatar: string; | ||
/** | ||
* The status style. | ||
*/ | ||
status: string; | ||
}; | ||
/** | ||
* The renderer configuration for this rank card. | ||
*/ | ||
renders: { | ||
/** | ||
* Whether to render the avatar. | ||
*/ | ||
avatar: boolean; | ||
/** | ||
* Whether to render the background. | ||
*/ | ||
background: boolean; | ||
/** | ||
* Whether to render the level. | ||
*/ | ||
level: boolean; | ||
/** | ||
* Whether to render the rank. | ||
*/ | ||
rank: boolean; | ||
/** | ||
* Whether to render the status. | ||
*/ | ||
status: boolean; | ||
/** | ||
* Whether to render the username. | ||
*/ | ||
username: boolean; | ||
/** | ||
* Whether to render the display name. | ||
*/ | ||
displayName: boolean; | ||
/** | ||
* Whether to render the discriminator. | ||
*/ | ||
discriminator: boolean; | ||
/** | ||
* Whether to render the progress. | ||
*/ | ||
progress: boolean; | ||
/** | ||
* Whether to render the xp. | ||
*/ | ||
xp: boolean; | ||
/** | ||
* Whether to render the progressbar. | ||
*/ | ||
progressbar: boolean; | ||
/** | ||
* The constants for this rank card. | ||
*/ | ||
constants: { | ||
/** | ||
* The rank constant. | ||
*/ | ||
rank: string; | ||
/** | ||
* The level constant. | ||
*/ | ||
level: string; | ||
/** | ||
* The xp constant. | ||
*/ | ||
xp: string; | ||
/** | ||
* The status colors constant. | ||
*/ | ||
statusColors: { | ||
/** | ||
* The light gray color. | ||
*/ | ||
LightGray: string; | ||
/** | ||
* The gray color. | ||
*/ | ||
Gray: string; | ||
/** | ||
* The dark gray color. | ||
*/ | ||
DarkGray: string; | ||
/** | ||
* The white color. | ||
*/ | ||
White: string; | ||
/** | ||
* The green color. | ||
*/ | ||
Green: string; | ||
/** | ||
* The yellow color. | ||
*/ | ||
Yellow: string; | ||
/** | ||
* The red color. | ||
*/ | ||
Red: string; | ||
/** | ||
* The blue color. | ||
*/ | ||
Blue: string; | ||
}; | ||
}; | ||
}; | ||
} | ||
@@ -1136,3 +1014,3 @@ declare class RankCardBuilder extends Builder<RankCardBuilderProps> { | ||
*/ | ||
setFonts(fontConfig: Required<RankCardBuilderProps['fonts']>): this; | ||
setFonts(fontConfig: Required<RankCardBuilderProps["fonts"]>): this; | ||
/** | ||
@@ -1152,3 +1030,3 @@ * Sets the avatar for this rank card. | ||
*/ | ||
setStatus(status: StatusType): this; | ||
setStatus(status: RankCardUserStatus): this; | ||
/** | ||
@@ -1160,11 +1038,10 @@ * Sets the username for this rank card. | ||
/** | ||
* Sets the display name for this rank card. | ||
* @param name The display name for this rank card. | ||
* Sets the handle name for this rank card. | ||
* @param name The handle name for this rank card. | ||
*/ | ||
setDisplayName(name: string): this; | ||
setHandle(name: string): this; | ||
/** | ||
* Sets the discriminator for this rank card. | ||
* @param discriminator The discriminator for this rank card. | ||
* Set overlay for this rank card. | ||
*/ | ||
setDiscriminator(discriminator: string): this; | ||
setOverlay(overlay: RankCardProps["overlay"]): this; | ||
/** | ||
@@ -1194,4 +1071,13 @@ * Sets the current xp for this rank card. | ||
*/ | ||
configureRenderer(config: Partial<RankCardBuilderProps['renders']>): this; | ||
setStyles(config: Partial<RankCardBuilderProps["styles"]>): this; | ||
/** | ||
* Set background crop for this rank card. | ||
*/ | ||
setBackgroundCrop(pos: Partial<RankCardBuilderProps["backgroundCrop"]>): this; | ||
/** | ||
* Configures the texts for this rank card. | ||
* @param config The configuration for this rank card. | ||
*/ | ||
setTextStyles(config: Partial<RankCardBuilderProps["texts"]>): this; | ||
/** | ||
* Renders this rank card into the canvas. | ||
@@ -1206,5 +1092,5 @@ */ | ||
* @returns The canvas image | ||
* @example ```typescript | ||
* | ||
* const image = await createCanvasImage('https://example.com/image.png'); | ||
* ``` | ||
*/ | ||
@@ -1374,3 +1260,3 @@ declare const createCanvasImage: (img: ImageSource) => Promise<_napi_rs_canvas.Image>; | ||
*/ | ||
flip(axis: 'x' | 'y'): void; | ||
flip(axis: "x" | "y"): void; | ||
/** | ||
@@ -1419,3 +1305,3 @@ * Scales the canvas. | ||
type ImageGeneratorImplementor = { | ||
[K in Lowercase<Exclude<keyof typeof TemplateFactory, 'Triggered'>>]: (...args: Parameters<(typeof TemplateFactory)[Capitalize<K>]>) => Promise<Buffer>; | ||
[K in Lowercase<Exclude<keyof typeof TemplateFactory, "Triggered">>]: (...args: Parameters<(typeof TemplateFactory)[Capitalize<K>]>) => Promise<Buffer>; | ||
}; | ||
@@ -1484,2 +1370,2 @@ interface CanvacordFactory extends ImageGeneratorImplementor { | ||
export { BuildFormat, Builder, BuilderBuildOptions, BuilderOptionsManager, BuilderTemplate, CSSPropertiesLike, Canvacord, CanvacordFactory, CanvacordInit, CanvasHelper, CanvasImage, ContextManipulationStep, CustomGenerationStep, DropShadowConfig, Element, ElementInit, Encodable, EncodingFormat, Font, FontFactory, Fonts, IImageGenerationTemplate, ImageFactory, ImageFilterer, ImageGen, ImageGenerationStep, ImageGenerationTemplate, ImageGeneratorImplementor, ImageManipulator, ImageSource, ImgenStep, JSX$1 as JSX, LeaderboardBuilder, LeaderboardProps, LoadImageOptions, Node, RankCardBuilder, StyleSheet, TemplateFactory, TemplateImage, TextGenerationStep, canvacord, createCanvasImage, createImageGenerator, createTemplate, loadImage, performObjectCleanup, render }; | ||
export { BuildFormat, Builder, BuilderBuildOptions, BuilderOptionsManager, BuilderTemplate, BuiltInGraphemeProvider, CSSPropertiesLike, Canvacord, CanvacordFactory, CanvacordInit, CanvasHelper, CanvasImage, ContextManipulationStep, CustomGenerationStep, DropShadowConfig, Element, ElementInit, Encodable, EncodingFormat, Font, FontFactory, Fonts, GraphemeProvider, IImageGenerationTemplate, ImageFactory, ImageFilterer, ImageGen, ImageGenerationStep, ImageGenerationTemplate, ImageGeneratorImplementor, ImageManipulator, ImageSource, ImgenStep, JSX$1 as JSX, LeaderboardBuilder, LeaderboardProps, LoadImageOptions, Node, RankCardBuilder, StyleSheet, TemplateFactory, TemplateImage, TextGenerationStep, canvacord, createCanvasImage, createImageGenerator, createTemplate, loadImage, performObjectCleanup, render }; |
{ | ||
"name": "canvacord", | ||
"description": "Generate images on-the-fly with the help of wide range of templates.", | ||
"version": "6.0.0-beta.1", | ||
"version": "6.0.0-beta.2", | ||
"main": "./dist/index.js", | ||
@@ -6,0 +6,0 @@ "types": "./dist/index.d.ts", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
973229
7547