@takumi-rs/core 0.7.4 → 0.9.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 +17 -17
- package/index.d.ts +21 -2
- package/index.js +1 -0
- package/package.json +21 -21
- package/tsconfig.json +1 -1
package/README.md
CHANGED
|
@@ -3,27 +3,27 @@
|
|
|
3
3
|
## Usage
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
import { Renderer } from "@takumi-rs/core";
|
|
6
|
+
import { Renderer, OutputFormat } from "@takumi-rs/core";
|
|
7
7
|
import { container, image } from "@takumi-rs/helpers";
|
|
8
8
|
import { writeFile } from "fs/promises";
|
|
9
9
|
|
|
10
10
|
const render = new Renderer();
|
|
11
11
|
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
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
|
|
24
|
+
const buffer = await render.renderAsync(node, {
|
|
25
|
+
width: 1200,
|
|
26
|
+
height: 630,
|
|
27
|
+
format: OutputFormat.WebP
|
|
28
|
+
});
|
|
29
29
|
```
|
package/index.d.ts
CHANGED
|
@@ -1,10 +1,29 @@
|
|
|
1
1
|
/* auto-generated by NAPI-RS */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export declare class Renderer {
|
|
4
|
-
constructor()
|
|
4
|
+
constructor(options?: ConstructRendererOptions | undefined | null)
|
|
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 },
|
|
11
|
+
renderAsync(source: { type: string }, options: RenderOptions, signal?: AbortSignal): Promise<Buffer>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export interface ConstructRendererOptions {
|
|
15
|
+
debug?: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export declare const enum OutputFormat {
|
|
19
|
+
WebP = 'WebP',
|
|
20
|
+
Png = 'Png',
|
|
21
|
+
Jpeg = 'Jpeg'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface RenderOptions {
|
|
25
|
+
width: number
|
|
26
|
+
height: number
|
|
27
|
+
format?: OutputFormat
|
|
28
|
+
quality?: number
|
|
10
29
|
}
|
package/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,22 +1,26 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takumi-rs/core",
|
|
3
|
-
"version": "0.
|
|
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.9.0",
|
|
11
4
|
"author": {
|
|
12
5
|
"email": "me@kane.tw",
|
|
13
6
|
"name": "Kane Wang",
|
|
14
7
|
"url": "https://kane.tw"
|
|
15
8
|
},
|
|
16
|
-
"
|
|
9
|
+
"repository": {
|
|
10
|
+
"url": "git+https://github.com/kane50613/takumi.git"
|
|
11
|
+
},
|
|
17
12
|
"main": "index.js",
|
|
18
|
-
"
|
|
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
|
-
"
|
|
38
|
-
|
|
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.
|
|
45
|
-
"@takumi-rs/core-linux-arm64-gnu": "0.
|
|
46
|
-
"@takumi-rs/core-linux-arm64-musl": "0.
|
|
47
|
-
"@takumi-rs/core-linux-x64-gnu": "0.
|
|
48
|
-
"@takumi-rs/core-linux-x64-musl": "0.
|
|
44
|
+
"@takumi-rs/core-darwin-arm64": "0.9.0",
|
|
45
|
+
"@takumi-rs/core-linux-arm64-gnu": "0.9.0",
|
|
46
|
+
"@takumi-rs/core-linux-arm64-musl": "0.9.0",
|
|
47
|
+
"@takumi-rs/core-linux-x64-gnu": "0.9.0",
|
|
48
|
+
"@takumi-rs/core-linux-x64-musl": "0.9.0"
|
|
49
49
|
}
|
|
50
50
|
}
|