Skip to content

Commit 614957a

Browse files
committed
Use unified takumi-js package
1 parent d00f1e0 commit 614957a

7 files changed

Lines changed: 100 additions & 66 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@fraqjs/plugin-takumi': patch
3+
---
4+
5+
`@takumi-rs` 下的依赖统一成 `takumi-js`

docs/content/docs/plugins/takumi.mdx

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ plugins:
2828
2929
{/* prettier-ignore */}
3030
<Callout type="warning">
31-
`@fraqjs/plugin-takumi` 依赖 `@takumi-rs/core` 包。Takumi 是一个 Rust 项目,在 Node.js 环境下只支持如下平台:
31+
`@fraqjs/plugin-takumi` 通过 `takumi-js/node` 使用 Takumi 的原生 Node.js 后端。Takumi 是一个 Rust 项目,在 Node.js 环境下只支持如下平台:
3232

3333
- Windows x64/arm64
3434
- macOS x64/arm64
@@ -214,9 +214,9 @@ npx takumi-preview src/templates/MyCard.tsx
214214
预览工具默认使用的渲染选项为 `{ devicePixelRatio: 1.5 }`。你可以通过在模板文件中导出一个名为 `previewRenderOptions` 的对象来覆盖默认选项:
215215

216216
```ts
217-
import type { RenderOptions } from '@takumi-rs/core';
217+
import type { RenderCallOptions } from '@fraqjs/plugin-takumi';
218218
219-
export const previewRenderOptions: RenderOptions = {
219+
export const previewRenderOptions: RenderCallOptions = {
220220
width: 800,
221221
height: 600,
222222
devicePixelRatio: 1,
@@ -241,11 +241,11 @@ const img = await ctx.takumi.renderJsx(<img src={src} alt="Example" />, {
241241
});
242242
```
243243

244-
如果同一个模板需要使用多张远程图片,可以使用 `@takumi-rs/helpers` 提供的 `prepareImages` 来收集节点中的图片地址并获取资源。`fetchCache` 可以在多次渲染之间复用图片字节,避免重复请求同一个 URL。
244+
如果同一个模板需要使用多张远程图片,可以使用 `takumi-js` 提供的 `prepareImages` 来收集节点中的图片地址并获取资源。由于模板直接使用这些辅助 API,需要将 `takumi-js` 添加到模板所在项目的依赖中。`fetchCache` 可以在多次渲染之间复用图片字节,避免重复请求同一个 URL。
245245

246246
```tsx
247-
import { prepareImages } from '@takumi-rs/helpers';
248-
import { fromJsx } from '@takumi-rs/helpers/jsx';
247+
import { prepareImages } from 'takumi-js/helpers';
248+
import { fromJsx } from 'takumi-js/helpers/jsx';
249249
250250
const element = (
251251
<div>

packages/takumi-preview/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
},
3030
"devDependencies": {
3131
"@fraqjs/plugin-takumi": "workspace:^",
32-
"@takumi-rs/helpers": "^2.10.0",
33-
"@types/react": "^19.2.18"
32+
"@types/react": "^19.2.18",
33+
"takumi-js": "^2.12.0"
3434
},
3535
"dependencies": {
3636
"@hono/node-server": "^2.1.1",

packages/takumi-preview/test/ExampleCard.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/// <reference types="@takumi-rs/helpers/jsx" />
1+
/// <reference types="takumi-js/helpers/jsx" />
22

33
import { PluginName, PreviewModuleId } from './dependency';
44

plugins/takumi/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@
3131
},
3232
"dependencies": {
3333
"@fraqjs/takumi-builtin-fonts": "^1.0.0",
34-
"@takumi-rs/core": "^2.10.0",
35-
"@takumi-rs/helpers": "^2.10.0"
34+
"takumi-js": "^2.12.0"
3635
},
3736
"devDependencies": {
3837
"@fraqjs/plugin-mock": "workspace:^",

plugins/takumi/src/service.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { type Context, type Disposable, serviceToken } from '@fraqjs/fraq';
2-
import { type FontLoader, type ImageLoader, type ImagesInput, Renderer, type RenderOptions } from '@takumi-rs/core';
3-
import { fontFromUrl, type Node, prepareImages, type ReactElementLike } from '@takumi-rs/helpers';
4-
import { type EmojiType, extractEmojis } from '@takumi-rs/helpers/emoji';
5-
import { fromHtml } from '@takumi-rs/helpers/html';
6-
import { fromJsx } from '@takumi-rs/helpers/jsx';
72
import type { ReactNode } from 'react';
3+
import { fontFromUrl, type Node, prepareImages, type ReactElementLike } from 'takumi-js/helpers';
4+
import { type EmojiType, extractEmojis } from 'takumi-js/helpers/emoji';
5+
import { fromHtml } from 'takumi-js/helpers/html';
6+
import { fromJsx } from 'takumi-js/helpers/jsx';
7+
import { type FontLoader, type ImageLoader, type ImagesInput, Renderer, type RenderOptions } from 'takumi-js/node';
88

99
import fs from 'node:fs/promises';
1010

pnpm-lock.yaml

Lines changed: 80 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)