77
88![ CI status] ( https://img.shields.io/github/actions/workflow/status/thuongtruong109/flashot/ci.yml?branch=main&label=ci&logo=github&style=flat&colorA=080f12&colorB=1fa669 )
99[ ![ Npm version] ( https://img.shields.io/npm/v/flashot?style=flat&label=version&colorA=080f12&colorB=1fa669&logo=npm )] ( https://npmjs.com/package/flashot )
10- [ ![ Npm downloads] ( https://img.shields.io/npm/dm/flashot?style=flat&colorA=080f12&colorB=1fa669 )] ( https://npmjs.com/package/flashot )
11- ![ Code size ] ( https://img.shields.io/github/languages/code-size/thuongtruong109/flashot ?style=flat&colorA=080f12&colorB=1fa669 )
12- [ ![ JSDocs ] ( https://img.shields.io/badge/jsdocs-reference-080f12 ?style=flat&colorA=080f12&colorB=1fa669 )] ( https://www.jsdocs.io/package/vite-unbundled )
10+ [ ![ Npm downloads] ( https://img.shields.io/npm/dm/flashot?style=flat&logo=jsr& colorA=080f12&colorB=1fa669 )] ( https://npmjs.com/package/flashot )
11+ [ ![ JSDocs ] ( https://img.shields.io/badge/jsdocs-reference-080f12 ?style=flat&logo=javascript& colorA=080f12&colorB=1fa669 )] ( https://www.jsdocs.io/package/vite-unbundled )
12+ ![ Code size ] ( https://img.shields.io/github/languages/code-size/thuongtruong109/flashot ?style=flat&logo=bun& colorA=080f12&colorB=1fa669 )
1313[ ![ License] ( https://img.shields.io/github/license/thuongtruong109/flashot.svg?style=flat&colorA=080f12&colorB=1fa669 )] ( https://github.com/antfu/vite-unbundled/blob/main/LICENSE )
14+ [ ![ Sponsor] ( https://img.shields.io/badge/sponsor-1fa669?logo=githubsponsors&labelColor=080f12 )] ( https://github.com/sponsors/thuongtruong109 )
1415
1516Flashot is the ** blazing-fast image generation tool** for code snippets, designed for flawless experience and speed.
1617
@@ -48,9 +49,11 @@ import { writeFile } from "node:fs/promises";
4849import { c2i } from " flashot" ;
4950
5051const buffer = await c2i (' console.log("hello, world!");' );
51- await writeFile (" image .png" , buffer);
52+ await writeFile (" output .png" , buffer); // Export the image
5253```
5354
55+ Then you can use the ` buffer ` to display the image or send it in a response.
56+
5457## ⚙️ API Options (default is not needed)
5558
5659``` js
@@ -60,7 +63,7 @@ const defaultOptions = {
6063 font: " https://fonts.bunny.net/ubuntu-sans-mono/files/ubuntu-sans-mono-latin-400-normal.woff2" , // custom font
6164 width: 800 , // default is auto
6265 height: 400 , // default is auto
63- backgroundColor : " transparent" , // default is theme's background
66+ bg : " transparent" , // default is theme's background
6467 gap: 1 , // gap between lines (default is 1)
6568 style: {
6669 borderRadius: 10 , // default is 8
@@ -72,31 +75,28 @@ const defaultOptions = {
7275const buffer = await c2i (' console.log("hello, world!");' , defaultOptions);
7376```
7477
75- | Option | Description | Default |
76- | -------- | ---------------------------------------------------------------------------------------- | -------------------- |
77- | ` lang ` | Code language ([ supported] ( https://shiki.style/languages ) ) | ` "typescript" ` |
78- | ` theme ` | Rendering theme ([ supported] ( https://shiki.style/themes ) ) | ` "github-dark" ` |
79- | ` style ` | Additional container styles ([ docs] ( https://takumi.kane.tw/docs/deep-dives/stylesheets ) ) | ` {} ` |
80- | ` font ` | Font for rendering (URL or ArrayBuffer) | System default |
81- | ` width ` | Image width | ` (columns + 2) * 10 ` |
82- | ` height ` | Image height | ` (lines + 2) * 20 ` |
83-
84- ## 🚀 Features
85-
86- - ** [ Bun] ( https://bun.sh ) ** - Fast all-in-one JavaScript runtime and toolkit
87- - ** [ TypeScript] ( https://www.typescriptlang.org/ ) ** - Type-safe development with strict mode enabled
88- - ** [ Vite] ( https://vitejs.dev/ ) ** - Lightning-fast build tool with optimized bundling
89- - ** [ Vitest] ( https://vitest.dev/ ) ** - Blazing fast unit testing framework
90- - ** [ shiki] ( https://github.com/shikijs/shiki ) ** and ** [ takumi] ( https://github.com/kane50613/takumi ) **
91- - ** Dual Module Support** - ESM and CommonJS output with proper type definitions
92- - ** [ Biome] ( https://biomejs.dev/ ) ** - Fast formatter and linter for consistent code style
93- - ** [ ESLint] ( https://eslint.org/ ) ** - Advanced linting with TypeScript and SonarJS rules
94- - ** Git Hooks** - Automated quality checks via Lefthook and Commitlint
95- - ** Watch Mode** - Hot rebuild during development
96- - ** Test Coverage** - Built-in coverage reporting with v8
97- - ** UI Testing** - Interactive test UI with ` @vitest/ui `
98- - ** Pre-commit Hooks** - Automatic linting and formatting on commit
99- - ** Pre-push Validation** - Full build and test suite before pushing
78+ | Option | Description | Default |
79+ | -------- | ---------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------- |
80+ | ` lang ` | Code language ([ supported] ( https://shiki.style/languages ) ) | ` "js" ` |
81+ | ` theme ` | Rendering theme ([ supported] ( https://shiki.style/themes ) ) | ` "dracula" ` |
82+ | ` font ` | Font for rendering (URL or ArrayBuffer) | [ ` ubuntu ` ] ( https://fonts.bunny.net/ubuntu-sans-mono/files/ubuntu-sans-mono-latin-400-normal.woff2 ) |
83+ | ` width ` | Image width | System default |
84+ | ` height ` | Image height | System default |
85+ | ` bg ` | Background color | Theme's background |
86+ | ` gap ` | Gap between lines | ` 1 ` |
87+ | ` style ` | Additional container styles ([ docs] ( https://takumi.kane.tw/docs/deep-dives/stylesheets ) ) | ` { borderRadius: 8, padding: 25 } ` |
88+
89+ ## 📚 Technologies
90+
91+ - ⚡ ** [ Bun] ( https://bun.sh ) ** - Fast all-in-one JavaScript runtime and toolkit
92+ - 🏗️ ** [ TypeScript] ( https://www.typescriptlang.org/ ) ** - Type-safe development with strict mode enabled
93+ - 📦 ** [ Vite] ( https://vitejs.dev/ ) ** - Lightning-fast build tool with optimized bundling
94+ - 🔋 ** [ Vitest] ( https://vitest.dev/ ) ** - Blazing fast unit testing & interactive test UI framework
95+ - 🪓 ** [ shiki] ( https://github.com/shikijs/shiki ) ** and ** [ takumi] ( https://github.com/kane50613/takumi ) **
96+ - 📝 ** [ Biome] ( https://biomejs.dev/ ) ** - Fast formatter and linter for consistent code style
97+ - 🚀 ** Dual Module Support** - ESM and CommonJS output with proper type definitions
98+ - 🔥 ** [ ESLint] ( https://eslint.org/ ) ** - Advanced linting with TypeScript and SonarJS rules
99+ - 🧩 ** [ Lefthook] ( https://github.com/evilmartians/lefthook ) ** and ** [ Commitlint] ( https://commitlint.js.org/ ) ** - Automated Git hooks for linting and formatting
100100
101101## 🧪 Code Coverage
102102
0 commit comments