@takumi-rs/core 0.7.4 → 0.8.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -9,21 +9,21 @@ import { writeFile } from "fs/promises";
9
9
 
10
10
  const render = new Renderer();
11
11
 
12
- const buffer = await render.renderAsync(
13
- container({
14
- children: [
15
- image("https://yeecord.com/img/logo.png", {
16
- width: 128,
17
- height: 128,
18
- }),
19
- ],
20
- background_color: 0xffffff,
21
- width: percentage(100),
22
- height: percentage(100),
23
- }),
24
- 1200,
25
- 630
26
- );
12
+ const node = container({
13
+ children: [
14
+ image("https://yeecord.com/img/logo.png", {
15
+ width: 128,
16
+ height: 128,
17
+ }),
18
+ ],
19
+ background_color: 0xffffff,
20
+ width: percentage(100),
21
+ height: percentage(100),
22
+ });
27
23
 
28
- await writeFile("./demo.webp", buffer);
24
+ const buffer = await render.renderAsync(node, {
25
+ width: 1200,
26
+ height: 630,
27
+ format: "webp"
28
+ });
29
29
  ```
package/index.d.ts CHANGED
@@ -2,9 +2,24 @@
2
2
  /* eslint-disable */
3
3
  export declare class Renderer {
4
4
  constructor()
5
+ loadLocalImageAsync(key: string, data: ArrayBuffer, signal?: AbortSignal | undefined | null): Promise<void>
5
6
  loadFontAsync(data: ArrayBuffer, signal?: AbortSignal | undefined | null): Promise<number>
6
7
  loadFontsAsync(fonts: Array<ArrayBuffer>, signal?: AbortSignal | undefined | null): Promise<number>
7
8
  clearImageStore(): void
9
+ clearLocalImageStore(): void
8
10
  preloadImageAsync(url: string, signal?: AbortSignal | undefined | null): Promise<void>
9
- renderAsync(source: { type: string }, width: number, height: number, signal?: AbortSignal): Promise<Buffer>
11
+ renderAsync(source: { type: string }, options: RenderOptions, signal?: AbortSignal): Promise<Buffer>
12
+ }
13
+
14
+ export declare const enum OutputFormat {
15
+ WebP = 'WebP',
16
+ Png = 'Png',
17
+ Jpeg = 'Jpeg'
18
+ }
19
+
20
+ export interface RenderOptions {
21
+ width: number
22
+ height: number
23
+ format?: OutputFormat
24
+ quality?: number
10
25
  }
package/index.js CHANGED
@@ -377,3 +377,4 @@ if (!nativeBinding) {
377
377
 
378
378
  module.exports = nativeBinding
379
379
  module.exports.Renderer = nativeBinding.Renderer
380
+ module.exports.OutputFormat = nativeBinding.OutputFormat
package/package.json CHANGED
@@ -1,22 +1,26 @@
1
1
  {
2
2
  "name": "@takumi-rs/core",
3
- "version": "0.7.4",
4
- "license": "MIT",
5
- "engines": {
6
- "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0"
7
- },
8
- "repository": {
9
- "url": "git+https://github.com/kane50613/takumi.git"
10
- },
3
+ "version": "0.8.0",
11
4
  "author": {
12
5
  "email": "me@kane.tw",
13
6
  "name": "Kane Wang",
14
7
  "url": "https://kane.tw"
15
8
  },
16
- "type": "commonjs",
9
+ "repository": {
10
+ "url": "git+https://github.com/kane50613/takumi.git"
11
+ },
17
12
  "main": "index.js",
18
- "types": "index.d.ts",
13
+ "devDependencies": {
14
+ "@napi-rs/cli": "3.0.0-alpha.89",
15
+ "@takumi-rs/helpers": "workspace:*",
16
+ "@types/bun": "^1.2.17",
17
+ "typescript": "^5.8.3"
18
+ },
19
19
  "browser": "browser.js",
20
+ "engines": {
21
+ "node": ">= 12.22.0 < 13 || >= 14.17.0 < 15 || >= 15.12.0 < 16 || >= 16.0.0"
22
+ },
23
+ "license": "MIT",
20
24
  "napi": {
21
25
  "binaryName": "core",
22
26
  "targets": [
@@ -34,17 +38,13 @@
34
38
  "artifacts": "napi create-npm-dirs && napi artifacts",
35
39
  "version": "napi version"
36
40
  },
37
- "devDependencies": {
38
- "@napi-rs/cli": "^3.0.0-alpha.89",
39
- "@takumi-rs/helpers": "workspace:*",
40
- "@types/bun": "^1.2.17",
41
- "typescript": "^5.8.3"
42
- },
41
+ "type": "commonjs",
42
+ "types": "index.d.ts",
43
43
  "optionalDependencies": {
44
- "@takumi-rs/core-darwin-arm64": "0.7.4",
45
- "@takumi-rs/core-linux-arm64-gnu": "0.7.4",
46
- "@takumi-rs/core-linux-arm64-musl": "0.7.4",
47
- "@takumi-rs/core-linux-x64-gnu": "0.7.4",
48
- "@takumi-rs/core-linux-x64-musl": "0.7.4"
44
+ "@takumi-rs/core-darwin-arm64": "0.8.0",
45
+ "@takumi-rs/core-linux-arm64-gnu": "0.8.0",
46
+ "@takumi-rs/core-linux-arm64-musl": "0.8.0",
47
+ "@takumi-rs/core-linux-x64-gnu": "0.8.0",
48
+ "@takumi-rs/core-linux-x64-musl": "0.8.0"
49
49
  }
50
50
  }
package/tsconfig.json CHANGED
@@ -11,7 +11,7 @@
11
11
  // Bundler mode
12
12
  "moduleResolution": "bundler",
13
13
  "allowImportingTsExtensions": true,
14
- "verbatimModuleSyntax": true,
14
+ "verbatimModuleSyntax": false,
15
15
  "noEmit": true,
16
16
 
17
17
  // Best practices