Skip to content

Commit 644d785

Browse files
committed
refactor: rename print SDK to printer across repo
1 parent 9606c5c commit 644d785

18 files changed

Lines changed: 87 additions & 87 deletions

File tree

docs/advanced/print-drivers.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ context.onDiagnostic?.({
292292

293293
## Playground 参考
294294

295-
Playground 已迁移到高层 print SDK,不再维护业务侧驱动包装。可以直接对照两个 hook:
295+
Playground 已迁移到高层打印器,不再维护业务侧驱动包装。可以直接对照两个 hook:
296296

297-
- `playground/src/hooks/useEasyInkPrint.ts`:创建 EasyInk Printer client 和托管 print SDK
298-
- `playground/src/hooks/useHiPrint.ts`:创建 HiPrint client 和托管 print SDK
297+
- `playground/src/hooks/useEasyInkPrint.ts`:创建 EasyInk Printer client 和托管打印器
298+
- `playground/src/hooks/useHiPrint.ts`:创建 HiPrint client 和托管打印器

docs/dotnet/getting-started.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ EasyInk Printer 是 Windows 本地静默打印服务,适合需要稳定 PDF
66

77
1. 在 Windows 机器上启动 `EasyInk.Printer.exe`
88
2. 确认服务已经能返回打印机列表。
9-
3. 前端创建 `@easyink/print-integration-easyink-printer` 的 print SDK
9+
3. 前端创建 `@easyink/print-integration-easyink-printer` 的打印器
1010
4. 调用 `printer.print({ schema, data })`
1111

1212
这篇文档只覆盖浏览器如何接入本地打印服务。如果你要部署、配置端口或启用 API Key,继续看 [Printer 应用](./printer)[API 参考](./api-reference)
@@ -58,18 +58,18 @@ curl http://localhost:18080/api/printers
5858
- 端口是否被改过
5959
- 当前机器是否真的安装了打印机驱动
6060

61-
## 第四步:创建 SDK 并打印
61+
## 第四步:创建打印器并打印
6262

6363
```ts
64-
import { createEasyInkPrinterClient, createEasyInkPrinterPrintSdk } from '@easyink/print-integration-easyink-printer'
64+
import { createEasyInkPrinterClient, createEasyInkPrinter } from '@easyink/print-integration-easyink-printer'
6565

6666
const client = createEasyInkPrinterClient({
6767
serviceUrl: 'http://localhost:18080',
6868
reconnect: true,
6969
maxReconnectAttempts: 3,
7070
})
7171

72-
const printer = createEasyInkPrinterPrintSdk({
72+
const printer = createEasyInkPrinter({
7373
client,
7474
viewer: 'iframe',
7575
})
@@ -78,13 +78,13 @@ await client.useDefaultPrinter()
7878
await printer.print({ schema, data })
7979
```
8080

81-
`createEasyInkPrinterPrintSdk()` 默认使用 `pageSizeMode: 'fixed'`,会自动创建托管 Viewer、把页面生成 PDF,再发送给 EasyInk.Printer。调用方不用再处理 Viewer 生命周期、PDF 导出插件、WebSocket 二进制帧、分块上传或任务轮询。
81+
`createEasyInkPrinter()` 默认使用 `pageSizeMode: 'fixed'`,会自动创建托管 Viewer、把页面生成 PDF,再发送给 EasyInk.Printer。调用方不用再处理 Viewer 生命周期、PDF 导出插件、WebSocket 二进制帧、分块上传或任务轮询。
8282

8383
客户端内部使用 VueUse 的 `useWebSocket` 管理长连接。连接意外断开时会进入 `reconnecting`,按配置重试;达到最大重连次数后进入 `error`,并把原因写入 `lastError`
8484

8585
如果这段代码跑通,意味着下面几层都已经工作正常:
8686

87-
- SDK 已经用托管 Viewer 渲染出页面
87+
- 打印器已经用托管 Viewer 渲染出页面
8888
- 前端能连接本地打印服务
8989
- 本地服务能选中打印机并创建任务
9090
- PDF 生成和上传链路没有问题
@@ -101,7 +101,7 @@ const client = createEasyInkPrinterClient({
101101
defaultCopies: settings.copies,
102102
})
103103

104-
const printer = createEasyInkPrinterPrintSdk({
104+
const printer = createEasyInkPrinter({
105105
client,
106106
viewer: 'iframe',
107107
printerName: () => settings.printerName,
@@ -119,14 +119,14 @@ const printer = createEasyInkPrinterPrintSdk({
119119
await printer.print({ schema, data })
120120
```
121121

122-
这里推荐传函数而不是静态值。原因是用户切换打印机或份数后,不需要重新创建 SDK
122+
这里推荐传函数而不是静态值。原因是用户切换打印机或份数后,不需要重新创建打印器
123123

124124
这里的参数可以分成两类来看:
125125

126126
- `serviceUrl``apiKey`、重连参数属于“怎么连服务”
127127
- `printerName``copies``forcePageSize``dpi``userData` 属于“这次打印怎么投递”
128128

129-
如果服务端启用了 API Key,前端只需要在创建客户端时传 `apiKey`SDK 会自动把它带到 HTTP Header 和 WebSocket 查询参数里,不需要业务代码自己拼认证逻辑。
129+
如果服务端启用了 API Key,前端只需要在创建客户端时传 `apiKey`客户端会自动把它带到 HTTP Header 和 WebSocket 查询参数里,不需要业务代码自己拼认证逻辑。
130130

131131
## 业务里最常用的打印参数
132132

@@ -253,7 +253,7 @@ await printer.printPdfAndWait(file, {
253253
标签机必须显式按模板尺寸打印时再开启:
254254

255255
```ts
256-
const printer = createEasyInkPrinterPrintSdk({
256+
const printer = createEasyInkPrinter({
257257
client,
258258
viewer: 'iframe',
259259
forcePageSize: true,
@@ -277,7 +277,7 @@ const printer = createEasyInkPrinterPrintSdk({
277277
Playground 已使用官方包集成:
278278

279279
- [playground/src/hooks/useEasyInkPrint.ts](../../playground/src/hooks/useEasyInkPrint.ts) 只保留 Vue 状态和设置持久化
280-
- 预览页调用 hook 暴露的 `easyInkPrint.print({ schema, data })`由 SDK 自动创建和销毁托管 Viewer
280+
- 预览页调用 hook 暴露的 `easyInkPrint.print({ schema, data })`由打印器自动创建和销毁托管 Viewer
281281
- Playground 的 EasyInk Printer 设置面板里还提供了 `UserId``LabelType` 演示字段,方便直接验证审计日志链路
282282

283283
## 常见问题

docs/hiprint/getting-started.md

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ HiPrint 通道适合跨平台静默打印,尤其适合标签、小票、卡片
99

1010
1. 启动 electron-hiprint。
1111
2. 确认本机能刷新到打印机列表。
12-
3. 前端创建 `@easyink/print-integration-hiprint` 的 print SDK
12+
3. 前端创建 `@easyink/print-integration-hiprint` 的打印器
1313
4. 调用 `printer.print({ schema, data })`
1414

1515
这篇文档只讲浏览器如何接入 HiPrint。electron-hiprint 本身的安装和系统打印驱动问题,仍然以它的发行包和操作系统配置为准。
@@ -44,16 +44,16 @@ console.log(printers)
4444

4545
如果这里拿不到打印机,优先排查本地环境,而不是继续调模板渲染。
4646

47-
## 第四步:创建 SDK 并打印
47+
## 第四步:创建打印器并打印
4848

4949
```ts
50-
import { createHiPrintClient, createHiPrintPrintSdk } from '@easyink/print-integration-hiprint'
50+
import { createHiPrintClient, createHiPrintPrinter } from '@easyink/print-integration-hiprint'
5151

5252
const hiPrint = createHiPrintClient({
5353
serviceUrl: 'http://localhost:17521',
5454
})
5555

56-
const printer = createHiPrintPrintSdk({
56+
const printer = createHiPrintPrinter({
5757
client: hiPrint,
5858
viewer: 'iframe',
5959
})
@@ -62,11 +62,11 @@ await hiPrint.useDefaultPrinter()
6262
await printer.print({ schema, data })
6363
```
6464

65-
`createHiPrintPrintSdk()` 默认使用 `pageSizeMode: 'driver'`,适合小票机、连续纸和由驱动决定介质的场景。用户只需要选择打印机,不需要理解 Viewer 的底层打印策略。
65+
`createHiPrintPrinter()` 默认使用 `pageSizeMode: 'driver'`,适合小票机、连续纸和由驱动决定介质的场景。用户只需要选择打印机,不需要理解 Viewer 的底层打印策略。
6666

6767
如果这段代码能跑通,说明这条链路已经成立:
6868

69-
- SDK 已经用托管 Viewer 渲染出可打印页面
69+
- 打印器已经用托管 Viewer 渲染出可打印页面
7070
- electron-hiprint 已建立连接
7171
- 当前机器能发现系统打印机
7272
- HiPrint 已经按页提交 HTML 到本地打印运行时
@@ -78,7 +78,7 @@ await printer.print({ schema, data })
7878
```ts
7979
import { hiprint } from 'vue-plugin-hiprint'
8080
import {
81-
createHiPrintPrintSdk,
81+
createHiPrintPrinter,
8282
createHiPrintRuntimeClient,
8383
} from '@easyink/print-integration-hiprint'
8484

@@ -89,7 +89,7 @@ const hiPrint = createHiPrintRuntimeClient({
8989
forcePageSize: settings.forcePageSize,
9090
})
9191

92-
const printer = createHiPrintPrintSdk({
92+
const printer = createHiPrintPrinter({
9393
client: hiPrint,
9494
viewer: 'iframe',
9595
resolveRequestOptions: () => ({
@@ -131,7 +131,7 @@ const hiPrint = createHiPrintClient({
131131
defaultCopies: settings.copies,
132132
})
133133

134-
const printer = createHiPrintPrintSdk({
134+
const printer = createHiPrintPrinter({
135135
client: hiPrint,
136136
viewer: 'iframe',
137137
printerName: () => settings.printerName,
@@ -184,14 +184,14 @@ await printer.print({ schema, data })
184184
Playground 已使用官方包集成:
185185

186186
- [playground/src/hooks/useHiPrint.ts](../../playground/src/hooks/useHiPrint.ts) 只保留 Vue 状态和设置持久化
187-
- 预览页调用 hook 暴露的 `hiPrint.print({ schema, data })`由 SDK 自动创建和销毁托管 Viewer
187+
- 预览页调用 hook 暴露的 `hiPrint.print({ schema, data })`由打印器自动创建和销毁托管 Viewer
188188

189189
## 常见问题
190190

191191
**连接超时**:确认 electron-hiprint 客户端已启动并监听 17521 端口。
192192

193193
**未发现打印机**:先确认系统打印机已正常安装,再调用 `hiPrint.refreshPrinters()`;如果这里拿不到设备,问题通常不在模板渲染。
194194

195-
**标签内容缩印到 A4**:确认当前打印任务需要显式纸张尺寸时,调用 `hiPrint.setForcePageSize(true)` 或在 SDK 配置里传 `forcePageSize`
195+
**标签内容缩印到 A4**:确认当前打印任务需要显式纸张尺寸时,调用 `hiPrint.setForcePageSize(true)` 或在打印器配置里传 `forcePageSize`
196196

197197
**第一张单应该怎么验收**:最小验收标准不是前端 Promise resolve,而是设备确实打印出预期尺寸的纸张,且没有被驱动缩放到默认 A4。

docs/printing/index.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ EasyInk 的本地打印目标很明确:让业务代码只关心“打印什么
1515

1616
1. 安装对应的打印包。
1717
2. 创建打印客户端,管理连接地址、默认打印机和份数。
18-
3. 创建对应的 print SDK,选择 `viewer: 'iframe'``viewer: 'dom'`
18+
3. 创建对应的打印器,选择 `viewer: 'iframe'``viewer: 'dom'`
1919
4. 调用 `printer.print({ schema, data })`
2020
5. 在设置页暴露打印机列表、连接状态和错误信息。
2121

@@ -36,7 +36,7 @@ EasyInk 的本地打印目标很明确:让业务代码只关心“打印什么
3636
| **渲染质量** | 适合对矢量质量要求高的正式单据 | 适合标签、小票、跨平台打印 |
3737
| **通信方式** | HTTP + WebSocket | WebSocket |
3838
| **典型场景** | 面单、正式报表、A4 文档 | 小票、标签、嵌入 Electron 的桌面应用 |
39-
| **SDK 默认 pageSizeMode** | `fixed` | `driver` |
39+
| **打印器默认 pageSizeMode** | `fixed` | `driver` |
4040
| **官方包** | `@easyink/print-integration-easyink-printer` | `@easyink/print-integration-hiprint` |
4141

4242
## 如何选择
@@ -55,7 +55,7 @@ EasyInk 的本地打印目标很明确:让业务代码只关心“打印什么
5555

5656
### 不要自己实现驱动的情况
5757

58-
如果你的打印目标只是“把 schema/data 打给本地服务”,官方 SDK 已经覆盖了绝大多数需求。只有在下面这些情况才建议写自定义驱动:
58+
如果你的打印目标只是“把 schema/data 打给本地服务”,官方打印器已经覆盖了绝大多数需求。只有在下面这些情况才建议写自定义驱动:
5959

6060
- 你有独立的企业打印网关,需要走自定义协议。
6161
- 你要接专用硬件或厂商 SDK。
@@ -67,7 +67,7 @@ EasyInk 的本地打印目标很明确:让业务代码只关心“打印什么
6767

6868
```ts
6969
const client = createEasyInkPrinterClient(...)
70-
const printer = createEasyInkPrinterPrintSdk({
70+
const printer = createEasyInkPrinter({
7171
client,
7272
viewer: 'iframe',
7373
})
@@ -91,7 +91,7 @@ export function usePrintService() {
9191

9292
这样做的原因有两个:
9393

94-
- print SDK 负责“本次 schema/data 如何渲染并提交”,不负责“配置存在哪、何时重连”。
94+
- 打印器负责“本次 schema/data 如何渲染并提交”,不负责“配置存在哪、何时重连”。
9595
- 打印设置页、诊断页、预览页都能共享同一份连接状态。
9696

9797
EasyInk Printer 官方客户端内部使用 VueUse `useWebSocket` 管理长连接。默认会自动重连 3 次,初始延迟 500ms,按 2 倍退避,最大延迟 5000ms;达到上限后进入 `error`,错误信息写入 `lastError`

packages/print/core/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
# @easyink/print-core
22

3-
Shared utilities for EasyInk print SDKs.
3+
Shared utilities for EasyInk printers.
44

55
This package is intended for official and custom print integration packages. It
66
contains shared unit conversion, Viewer page extraction, diagnostics mapping,
7-
and the managed `iframe` / `dom` Viewer lifecycle used by high-level print SDKs.
7+
and the managed `iframe` / `dom` Viewer lifecycle used by high-level printers.
88
Application code usually consumes `@easyink/print-integration-easyink-printer`
99
or `@easyink/print-integration-hiprint` instead.

packages/print/core/src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ export interface PrintDriverBaseOptions<TClient, TRequestOptions> {
4949
}
5050

5151
/**
52-
* Selects the managed rendering surface used by high-level print SDKs.
52+
* Selects the managed rendering surface used by high-level printers.
5353
*
5454
* - `iframe`: isolated document, default and recommended for production.
5555
* - `dom`: regular DOM element in the current document, useful for tests or
@@ -235,8 +235,8 @@ export function resolvePrintDriverValue<T>(value: PrintDriverValue<T> | undefine
235235
}
236236

237237
/**
238-
* Creates a small managed Viewer runtime for print SDKs. Application code can
239-
* stay focused on client connection + print input while the SDK owns the
238+
* Creates a small managed Viewer runtime for printers. Application code can
239+
* stay focused on client connection + print input while the printer owns the
240240
* transient render surface.
241241
*/
242242
export function createManagedPrintViewer(options: ManagedPrintViewerOptions = {}): ManagedPrintViewer {

packages/print/integration-easyink-printer/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
# @easyink/print-integration-easyink-printer
22

3-
Official EasyInk Printer client and managed print SDK.
3+
Official EasyInk Printer client and managed document printer.
44

55
```ts
66
import {
7+
createEasyInkPrinter,
78
createEasyInkPrinterClient,
8-
createEasyInkPrinterPrintSdk,
99
} from '@easyink/print-integration-easyink-printer'
1010

1111
const client = createEasyInkPrinterClient({
1212
serviceUrl: 'http://localhost:18080',
1313
reconnect: true,
1414
})
1515

16-
const printer = createEasyInkPrinterPrintSdk({
16+
const printer = createEasyInkPrinter({
1717
client,
1818
viewer: 'iframe',
1919
})
@@ -33,7 +33,7 @@ await printer.print({
3333
})
3434
```
3535

36-
The SDK owns the Viewer render lifecycle and PDF pipeline. Each `print()` call
36+
The printer owns the Viewer render lifecycle and PDF pipeline. Each `print()` call
3737
creates the configured render surface, opens the schema/data, renders Viewer
3838
pages to PDF, uploads the PDF through EasyInk Printer, waits for completion by
3939
default, and destroys the render surface.

packages/print/integration-easyink-printer/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "@easyink/print-integration-easyink-printer",
33
"type": "module",
44
"version": "0.0.13",
5-
"description": "Official EasyInk Printer client and managed EasyInk print SDK",
5+
"description": "Official EasyInk Printer client and managed document printer",
66
"author": "hackycy <hackycy@outlook.com>",
77
"license": "MIT",
88
"publishConfig": {

packages/print/integration-easyink-printer/src/index.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ export {
1313
} from './client'
1414

1515
export {
16-
createEasyInkPrinterPrintSdk,
17-
type EasyInkPrinterPrintInput,
18-
type EasyInkPrinterPrintSdk,
19-
type EasyInkPrinterPrintSdkOptions,
16+
createEasyInkPrinter,
17+
type EasyInkPrinter,
18+
type EasyInkPrinterOptions,
19+
type EasyInkPrinterPrintRequest,
2020
} from './sdk'

packages/print/integration-easyink-printer/src/sdk.test.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { DocumentSchema } from '@easyink/viewer'
22
import { beforeEach, describe, expect, it, vi } from 'vitest'
3-
import { createEasyInkPrinterPrintSdk } from './sdk'
3+
import { createEasyInkPrinter } from './sdk'
44

55
const { renderPagesToPdfBlob } = vi.hoisted(() => ({
66
renderPagesToPdfBlob: vi.fn(async () => new Blob(['pdf'])),
@@ -28,21 +28,21 @@ beforeEach(() => {
2828
renderPagesToPdfBlob.mockClear()
2929
})
3030

31-
describe('easy ink printer print sdk', () => {
31+
describe('easy ink printer', () => {
3232
it('creates the managed viewer, renders PDF, and submits the job', async () => {
3333
const client = {
3434
printPdf: vi.fn(async () => 'job-12345678'),
3535
waitForJob: vi.fn(async () => ({ jobId: 'job-12345678', status: 'completed' })),
3636
}
37-
const sdk = createEasyInkPrinterPrintSdk({
37+
const printer = createEasyInkPrinter({
3838
client: client as never,
3939
viewer: 'dom',
4040
printerName: () => 'Printer A',
4141
copies: () => 3,
4242
forcePageSize: () => true,
4343
})
4444

45-
await sdk.print({
45+
await printer.print({
4646
schema: createFixedSchema(),
4747
data: {},
4848
})

0 commit comments

Comments
 (0)