@borurio-print/print-designer 1.0.6 → 1.0.8

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
@@ -104,27 +104,159 @@ i18n.global.mergeLocaleMessage('zh-cn', printDesignerZhCN)
104
104
  i18n.global.mergeLocaleMessage('en', printDesignerEnUS)
105
105
  ```
106
106
 
107
- ## npm 发布
108
-
109
- 首次发布前,需要确认当前 npm 账号拥有 `@borurio-print` 组织作用域的发布权限。先登录并检查
110
- 即将进入安装包的文件:
111
-
112
- ```bash
113
- npm login
114
- pnpm build:lib
115
- npm pack --dry-run
116
- ```
117
-
118
- 确认内容无误后发布公开包:
119
-
120
- ```bash
121
- pnpm publish --access public
122
- ```
123
-
124
- 同一个版本号不能重复发布;后续修改需要先更新 `package.json` 中的版本号。
107
+ ## npm 发布
108
+
109
+ 包名和 npm registry 已在 `package.json` 中配置:
110
+
111
+ - 包名:`@borurio-print/print-designer`
112
+ - registry:`https://registry.npmjs.org/`
113
+ - 公开范围:`public`
114
+ - 发布前钩子:`prepublishOnly` 会自动执行 `pnpm build:lib`
115
+
116
+ ### 1. 检查本地和线上版本
117
+
118
+ 进入项目目录,确认当前工作区状态以及本地版本:
119
+
120
+ ```bash
121
+ git status
122
+ node -p "require('./package.json').version"
123
+ ```
124
+
125
+ 查询 npm 当前已经发布的版本:
126
+
127
+ ```bash
128
+ npm view @borurio-print/print-designer version --registry=https://registry.npmjs.org/
129
+ ```
130
+
131
+ 同一个版本不能重复发布。如果本地版本与线上版本相同,先升级版本号:
132
+
133
+ ```bash
134
+ pnpm version patch --no-git-tag-version
135
+ ```
136
+
137
+ 根据实际变更范围,也可以把 `patch` 换成 `minor` 或 `major`。如果上一次发布只是因为
138
+ 登录失效或权限不足而失败,并且线上还没有该版本,不要再次升级版本号。
139
+
140
+ ### 2. 检查 npm 登录和发布权限
141
+
142
+ 先检查当前 npm 登录状态:
143
+
144
+ ```bash
145
+ npm whoami --registry=https://registry.npmjs.org/
146
+ ```
147
+
148
+ 如果返回 `E401 Unauthorized`,重新登录:
149
+
150
+ ```bash
151
+ npm login --auth-type=web --registry=https://registry.npmjs.org/
152
+ ```
153
+
154
+ 登录成功后,再检查当前账号是否拥有该包的发布权限:
155
+
156
+ ```bash
157
+ npm owner ls @borurio-print/print-designer --registry=https://registry.npmjs.org/
158
+ ```
159
+
160
+ 当前账号必须出现在 owner 列表中。如果不在,需要使用已有 owner 账号登录,或者由已有
161
+ owner 为当前账号授予权限。
162
+
163
+ ### 3. 执行发布前构建和检查
164
+
165
+ 安装锁文件对应的依赖,并完整构建 Web 与 npm 两种产物:
166
+
167
+ ```bash
168
+ pnpm install --frozen-lockfile
169
+ pnpm build
170
+ ```
171
+
172
+ 检查 npm 包最终会包含哪些文件:
173
+
174
+ ```bash
175
+ npm pack --dry-run
176
+ ```
177
+
178
+ 至少应确认以下文件存在:
179
+
180
+ - `dist-lib/index.js`
181
+ - `dist-lib/index.d.ts`
182
+ - `dist-lib/style.css`
183
+ - `dist-lib/PrintDesigner.vue.d.ts`
184
+ - `dist-lib/core/types.d.ts`
185
+ - `dist-lib/core/theme.d.ts`
186
+ - `package.json`
187
+
188
+ 如果仓库跟踪 `dist-lib`,发布前应检查并提交最新构建产物。不要在存在来源不明的工作区
189
+ 改动时直接执行批量提交。
190
+
191
+ ### 4. 正式发布
192
+
193
+ 确认版本、账号、权限和打包内容无误后执行:
194
+
195
+ ```bash
196
+ npm publish --access public --registry=https://registry.npmjs.org/
197
+ ```
198
+
199
+ 发布时会再次触发 `prepublishOnly`,自动执行 `pnpm build:lib`。终端出现下面格式的输出才
200
+ 表示上传成功:
201
+
202
+ ```text
203
+ + @borurio-print/print-designer@1.0.7
204
+ ```
205
+
206
+ `resolveComponent is imported ... but never used` 和 chunk size 属于构建警告,不等于发布
207
+ 失败;应以命令退出码和最后的 npm 发布结果为准。
208
+
209
+ ### 5. 发布后验证
210
+
211
+ npm 新版本可能需要短暂处理时间。查询线上版本:
212
+
213
+ ```bash
214
+ npm view @borurio-print/print-designer version --registry=https://registry.npmjs.org/
215
+ ```
216
+
217
+ 在临时目录或业务系统中安装明确版本进行验证:
218
+
219
+ ```bash
220
+ npm install @borurio-print/print-designer@1.0.7
221
+ ```
222
+
223
+ 确认线上版本和业务系统验证正常后,再按团队 Git 流程提交版本变更并创建对应版本标签。
224
+
225
+ ### 常见发布错误
226
+
227
+ #### `E401 Unauthorized`
228
+
229
+ 当前 npm 登录已失效。重新执行:
230
+
231
+ ```bash
232
+ npm login --auth-type=web --registry=https://registry.npmjs.org/
233
+ npm whoami --registry=https://registry.npmjs.org/
234
+ ```
235
+
236
+ #### scoped 包发布时报 `E404 Not Found - PUT`
237
+
238
+ 对于已经存在的 scoped 包,这通常表示当前账号没有发布权限,或者认证信息已经失效,并不
239
+ 代表包真的不存在。依次检查:
240
+
241
+ ```bash
242
+ npm whoami --registry=https://registry.npmjs.org/
243
+ npm owner ls @borurio-print/print-designer --registry=https://registry.npmjs.org/
244
+ npm view @borurio-print/print-designer version --registry=https://registry.npmjs.org/
245
+ ```
246
+
247
+ 如果 `npm whoami` 返回 `E401`,重新登录后再发布。如果账号不在 owner 列表中,需要切换
248
+ 到有权限的账号或申请权限。权限问题解决前不要继续递增版本号。
249
+
250
+ #### 版本已经存在
251
+
252
+ npm 不允许覆盖已经发布的相同版本。确认线上已经存在当前版本后,执行:
253
+
254
+ ```bash
255
+ pnpm version patch --no-git-tag-version
256
+ ```
257
+
258
+ 重新构建、检查并发布新版本。
125
259
 
126
260
  ## 自动生成文件
127
261
 
128
- `src/auto-imports.d.ts` 和 `src/components.d.ts` 由自动按需引入插件生成;`pnpm-lock.yaml` 由 pnpm 生成。这些文件不应手动添加说明或修改内容。
129
-
130
- pnpm publish --access public
262
+ `src/auto-imports.d.ts` 和 `src/components.d.ts` 由自动按需引入插件生成;`pnpm-lock.yaml` 由 pnpm 生成。这些文件不应手动添加说明或修改内容。
@@ -1,17 +1,19 @@
1
- import type { BusinessFieldGroup, PrintResult, PrintTemplate } from '@/core/types';
1
+ import type { BusinessFieldGroup, PrintRequest, PrintResult, PrintTemplate, PrintDesignerTheme } from '@/core/types';
2
2
  type __VLS_Props = {
3
3
  /**
4
4
  * 由业务系统提供的可打印字段目录。
5
5
  * 设计器只保存字段路径和用户最终选择的展示类型,不感知 WMS、OMS 业务含义。
6
6
  */
7
7
  fieldGroups?: readonly BusinessFieldGroup[];
8
+ /** 当前设计器实例使用的主色主题。 */
9
+ theme?: PrintDesignerTheme;
8
10
  };
9
11
  declare function getTemplate(): PrintTemplate;
10
12
  declare function loadTemplate(template: PrintTemplate): void;
11
- /** 供业务系统获取 PDF Blob,后续可直接传给本地打印控件。 */
12
- declare function generatePdf(data: unknown): Promise<Blob>;
13
- /** 供业务系统直接在浏览器中打开数据打印预览。 */
14
- declare function previewPdf(data: unknown): Promise<void>;
13
+ /** 供业务系统生成 PDF,结果统一通过 print-result 事件通知。 */
14
+ declare function generatePdf(request: PrintRequest): Promise<void>;
15
+ /** 供业务系统打开 PDF 预览,结果统一通过 print-result 事件通知。 */
16
+ declare function previewPdf(request: PrintRequest): Promise<void>;
15
17
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {
16
18
  getTemplate: typeof getTemplate;
17
19
  loadTemplate: typeof loadTemplate;
@@ -0,0 +1,6 @@
1
+ import { type ComputedRef, type CSSProperties, type InjectionKey } from 'vue';
2
+ import type { PrintDesignerTheme } from './types';
3
+ export type PrintDesignerThemeStyle = CSSProperties & Record<`--bpd-${string}`, string>;
4
+ export declare const printDesignerThemeStyleKey: InjectionKey<ComputedRef<PrintDesignerThemeStyle>>;
5
+ export declare function createPrintDesignerThemeStyle(theme?: PrintDesignerTheme): PrintDesignerThemeStyle;
6
+ export declare function usePrintDesignerThemeStyle(): ComputedRef<PrintDesignerThemeStyle>;
@@ -36,13 +36,25 @@ export interface PrintRenderPage {
36
36
  data?: Record<string, unknown>;
37
37
  tableData: Record<string, TableRuntimeData>;
38
38
  }
39
- /** 设计器完成 PDF 预览或内部测试打印后通知业务系统的结果。 */
39
+ /** 业务系统发起一次 PDF 生成或预览的请求。 */
40
+ export interface PrintRequest<T = unknown> {
41
+ /** 由调用方生成,用于将异步结果与请求一一对应。 */
42
+ requestId: string;
43
+ data: T;
44
+ /** 只有显式需要获取 PDF 文件时才设置为 true。 */
45
+ returnBlob?: boolean;
46
+ }
47
+ /** 设计器完成 PDF 生成或预览后通过 print-result 通知的结果。 */
40
48
  export interface PrintResult {
41
- success: boolean;
42
- action: 'preview' | 'testPrint';
43
- pageCount: number;
44
- blob?: Blob;
45
- error?: unknown;
49
+ requestId: string;
50
+ result: 'success' | 'failed';
51
+ /** 成功固定为 ok,失败时为可展示的错误信息。 */
52
+ message: string;
53
+ data?: {
54
+ pageCount: number;
55
+ /** 只在请求中指定 returnBlob: true 时返回。 */
56
+ blob?: Blob;
57
+ };
46
58
  }
47
59
  /** 业务字段目前允许在标签中使用的三种展示方式。 */
48
60
  export type FieldElementType = 'text' | 'textBox' | 'qrcode' | 'barcode';
@@ -62,6 +74,17 @@ export interface BusinessFieldGroup {
62
74
  label: string;
63
75
  fields: readonly BusinessField[];
64
76
  }
77
+ /** 业务系统可为每个设计器实例单独配置的主色主题。 */
78
+ export interface PrintDesignerTheme {
79
+ /** 主色;未传入衍生色时,设计器会自动生成对应的明暗色阶。 */
80
+ primaryColor?: string;
81
+ primaryLight3?: string;
82
+ primaryLight5?: string;
83
+ primaryLight7?: string;
84
+ primaryLight8?: string;
85
+ primaryLight9?: string;
86
+ primaryDark2?: string;
87
+ }
65
88
  /**
66
89
  * 设计器支持的组件类型。
67
90
  *