yh-hiprint 2.5.2 → 2.5.3

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/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- declare module "yh-hiprint";
1
+ declare module 'yh-hiprint';
2
2
 
3
3
  /** JQuery 简化dom操作的库 */
4
4
  export declare const jquery: JQuery;
@@ -12,7 +12,6 @@ export declare const zIndex;
12
12
  /** hiprint 侧边栏配置 */
13
13
  export declare const panel;
14
14
 
15
- export declare const hiprint;
16
15
  export declare const defaultElementTypeProvider: (options: any) => {
17
16
  addElementTypes: (context) => void;
18
17
  };
@@ -64,4 +63,315 @@ export declare interface HiprintOption {
64
63
  isCustom: boolean;
65
64
  }
66
65
 
67
- export declare const hiprint: (HiprintOption) => void;
66
+ //#region Hiprint 类型文件
67
+
68
+
69
+ /** 打印元素唯一标识 */
70
+ type Tid = string;
71
+
72
+ export interface Field {
73
+ field: string;
74
+ text: string;
75
+ }
76
+
77
+ export interface TextPrintElementType {
78
+ printElementType: {
79
+ tid: Tid;
80
+ title: string;
81
+ field: string;
82
+ data: string;
83
+ formatter: (title,value,options,templateData,target) => string;
84
+ styler: (value,options,target,templateData,) => CSSStyleDeclaration;
85
+ onRendered: (target,options,paperTarget) => void;
86
+ fields: Field[],
87
+ },
88
+ options: {
89
+ /**
90
+ * 标题
91
+ * field 存在则
92
+ */
93
+ title: string;
94
+ /** 字段名称,从数据源获取数据的属性名称 */
95
+ field: string;
96
+ /** 测试数据 设计时使用 */
97
+ testData: string;
98
+ /** 字体名称 */
99
+ fontFamily: string;
100
+ /** 字体大小 */
101
+ fontSize: string;
102
+ /** 字体粗细 */
103
+ fontWeight: string;
104
+ /** 字体间距 */
105
+ letterSpacing: number;
106
+ /** 字体颜色 */
107
+ color: string;
108
+ /** 文本描述 */
109
+ textDecoration: string;
110
+ /** 文字水平对齐 */
111
+ textAlign: 'left'|'center'|'right';
112
+ /** 行高 数字带单位 例如 18pt */
113
+ lineHeight: string;
114
+ /**
115
+ * 文本类型
116
+ * text - 纯文本
117
+ * barcode - 条形码
118
+ * qrcode - 二维码
119
+ */
120
+ textType: 'text' | 'barcode' | 'qrcode';
121
+ /** 条形码格式 */
122
+ barcodeMode: string;
123
+ /** 因此标题 */
124
+ hideTitle: boolean;
125
+ /**
126
+ * 页眉/页脚/固定定位等元素显示规则
127
+ * first - 首页显示
128
+ * odd - 奇数页显示
129
+ */
130
+ showInPage: 'first' | 'odd' | 'even' | 'last';
131
+ /** 固定定位 */
132
+ fixed: boolean;
133
+ /** 打印设计时拖拽方向 */
134
+ axis: 'v' | 'h';
135
+ /** 旋转角度 */
136
+ transform: number;
137
+ }
138
+ }
139
+
140
+ export interface ImagePrintElementType {
141
+ printElementType: {
142
+ tid: string;
143
+ field: string;
144
+ data: string;
145
+ formatter: () => void;
146
+ styler: () => void;
147
+ onRendered: () => void;
148
+ fields: Field[];
149
+ },
150
+ options: {
151
+ title: string;
152
+ field: string;
153
+ src: string;
154
+ showInPage: string;
155
+ fixed: boolean;
156
+ axis: string;
157
+ transform: number;
158
+ }
159
+ }
160
+
161
+ export interface HlinePrintElementType {
162
+ printElementType: {
163
+ tid: string;
164
+ onRendered: () => void;
165
+ },
166
+ options: {
167
+ borderColor: string;
168
+ borderWidth: string;
169
+ showInPage: string;
170
+ fixed: boolean;
171
+ axis: string;
172
+ transform: number;
173
+ }
174
+ }
175
+ export interface VlinePrintElementType {
176
+ printElementType: {
177
+ tid: string;
178
+ onRendered: () => void;
179
+ },
180
+ options: {
181
+ borderColor: string;
182
+ borderWidth: string;
183
+ showInPage: string;
184
+ fixed: boolean;
185
+ axis: string;
186
+ transform: number;
187
+ }
188
+ }
189
+ export interface RectPrintElementType {
190
+ printElementType: {
191
+ tid: string;
192
+ onRendered: () => void;
193
+ },
194
+ options: {
195
+ borderColor: string;
196
+ borderWidth: string;
197
+ showInPage: string;
198
+ fixed: boolean;
199
+ axis: string;
200
+ transform: number;
201
+ }
202
+ }
203
+ export interface OvalPrintElementType {
204
+ printElementType: {
205
+ tid: string;
206
+ onRendered: () => void;
207
+ },
208
+ options: {
209
+ borderColor: string;
210
+ borderWidth: string;
211
+ showInPage: string;
212
+ fixed: boolean;
213
+ axis: string;
214
+ transform: number;
215
+ }
216
+ }
217
+ export interface HlinePrintElementType {
218
+ printElementType: {
219
+ tid: string;
220
+ onRendered: () => void;
221
+ },
222
+ options: {
223
+ borderColor: string;
224
+ borderWidth: string;
225
+ showInPage: string;
226
+ fixed: boolean;
227
+ axis: string;
228
+ transform: number;
229
+ }
230
+ }
231
+
232
+ export interface TableColumn {
233
+ width: number;
234
+ title: string;
235
+ field: string;
236
+ fixed: boolean;
237
+ rowspan: number;
238
+ colspan: number;
239
+ align: string;
240
+ halign: string;
241
+ formater: () => void;
242
+ styler: () => void;
243
+ }
244
+
245
+ export interface TablePrintElementType {
246
+ printElementType: {
247
+ tid: string;
248
+ title: string;
249
+ field: string;
250
+ columns: TableColumn[]
251
+ styler: () => void;
252
+ rowStyler: () => void;
253
+ formatter: () => void;
254
+ groupFields: any[];
255
+ groupFormatter: () => void;
256
+ fotterFormatter: () => void;
257
+ gridColumnsFooterFormatter: () => void;
258
+ groupFooterFormatter: () => void;
259
+ onRendered: () => void;
260
+ fields: Field[];
261
+ },
262
+ options: {
263
+ field: string;
264
+ fontFamily: string;
265
+ fontSize: number;
266
+ lineHeight: number;
267
+ textAlign: 'left'|'center'|'right';
268
+ tableBorder: 'noBorder' | 'border';
269
+ tableHeaderBorder: 'noBorder'|'border'|'topBorder'|'bottomBorder'|'topBottomBorder';
270
+ tableHeaderCellBorder: 'noBorder'|'border';
271
+ tableHeaderRowHeight: number;
272
+ tableHeaderBackground: string;
273
+ tableHeaderFontSize: number;
274
+ tableHeaderFontWeight: string;
275
+ tableBodyCellBorder: string;
276
+ tableBodyRowBorder: string;
277
+ tableBodyRowHeight: number;
278
+ axis: 'v' | 'h';
279
+ lHeight: number;
280
+ }
281
+ }
282
+ export interface LongTextPrintElementType {
283
+ printElementType: {
284
+ tid: string;
285
+ title: string;
286
+ field: string;
287
+ data: string;
288
+ formatter: () => void;
289
+ styler: () => void;
290
+ onRendered: () => void;
291
+ fields: Field[];
292
+ },
293
+ options: {
294
+ title: string;
295
+ field: string;
296
+ testData: string;
297
+ fontFamily: string;
298
+ fontSize: number;
299
+ fontWeight: string;
300
+ letterSpacing: number;
301
+ color: string;
302
+ textDecoration: string;
303
+ textAlign: string;
304
+ lineHeight: number;
305
+ hideTitle: boolean;
306
+ longTextIndent: number;
307
+ showInPage: string;
308
+ fixed: boolean;
309
+ leftSpaceRemoved: boolean;
310
+ axis: string;
311
+ lHeight: number;
312
+ transform: number;
313
+ }
314
+ }
315
+ export interface HTMLPrintElementType {
316
+ printElementType: {
317
+ tid: string;
318
+ title: string;
319
+ field: string;
320
+ data: string;
321
+ formatter: () => void;
322
+ styler: () => void;
323
+ onRendered: () => void;
324
+ },
325
+ options: {
326
+ title: string;
327
+ field: string;
328
+ testData: string;
329
+ fontFamily: string;
330
+ showInPage: string;
331
+ fixed: boolean;
332
+ axis: string;
333
+ transform: number;
334
+ }
335
+ }
336
+
337
+ /** Hiprint 打印面板对象 */
338
+ export interface PrintPanel {
339
+ addPrintText: (options?) => void;
340
+ addPrintLongText: () => void;
341
+ }
342
+
343
+ /** Hprint 打印面板创建配置对象 */
344
+ export interface PrintPanelOptions {
345
+ /** 宽度 */
346
+ width: number;
347
+ /** 高度 */
348
+ height: number;
349
+ /** 页脚高度 */
350
+ paperFotter: number;
351
+ /** 页眉高度 */
352
+ paperHeader: number;
353
+ }
354
+
355
+ export interface PrintTemplateData {
356
+
357
+ }
358
+
359
+ export interface PrintTemplateOptions {
360
+ template: PrintTemplateData
361
+ }
362
+
363
+ export interface PrintTemplate {
364
+ addPrintPanel:(options:PrintPanelOptions) => void;
365
+ design: () => void;
366
+ }
367
+
368
+ export declare const hiprint = {
369
+ /** 初始化 Hiprint */
370
+ init:() => viod,
371
+ /** 创建打印模板对象 */
372
+ PrintTemplate: {
373
+ new (options: PrintTemplateOptions): PrintTemplate;
374
+ }
375
+ }
376
+
377
+ //#endregion
package/index.js CHANGED
@@ -1,3 +1,4 @@
1
+ // @ts-check
1
2
  import './libs/jquery';
2
3
  export { hiprint, defaultElementTypeProvider, print, print2, usePaper, useScale, useDataSource } from './hooks/useHiprint';
3
4
  export { default as fontSize } from './font-size';
@@ -0,0 +1,42 @@
1
+ import * as babelCore from "@babel/core";
2
+ import parser from "@babel/parser";
3
+
4
+ // ✅ 只导入实际用到的插件
5
+ import pluginTransformArrowFunctions from "@babel/plugin-transform-arrow-functions";
6
+ import pluginTransformBlockScoping from "@babel/plugin-transform-block-scoping";
7
+ import pluginTransformTemplateLiterals from "@babel/plugin-transform-template-literals";
8
+ import pluginTransformShorthandProperties from "@babel/plugin-transform-shorthand-properties";
9
+ import pluginTransformComputedProperties from "@babel/plugin-transform-computed-properties";
10
+
11
+ /**
12
+ * 将 ES6 代码转换为 ES5
13
+ * @param {string} code - 用户输入的 ES6+ 代码
14
+ * @returns {string} - 编译后的 ES5 代码
15
+ */
16
+ export default function compileES6toES5 (code) {
17
+ try {
18
+ // 1. 解析为 AST
19
+ const ast = parser.parse(code, {
20
+ sourceType: "script",
21
+ plugins: [],
22
+ });
23
+
24
+ // 2. 转换 AST → ES5(内部自动调用 generator)
25
+ const result = babelCore.transformFromAstSync(ast, code, {
26
+ plugins: [
27
+ pluginTransformArrowFunctions,
28
+ pluginTransformBlockScoping,
29
+ pluginTransformTemplateLiterals,
30
+ pluginTransformShorthandProperties,
31
+ pluginTransformComputedProperties,
32
+ ],
33
+ sourceMaps: false,
34
+ ast: false, // ✅ 如果你不需要返回 AST,设为 false 更轻量
35
+ });
36
+
37
+ return result.code;
38
+ } catch (err) {
39
+ console.error("Babel 编译错误:", err);
40
+ throw new Error("编译失败:" + (err.message || err));
41
+ }
42
+ }
@@ -2291,6 +2291,7 @@ var hiprint = (function (t) {
2291
2291
  useSVG: !0,
2292
2292
  correctLevel: t.tableQRCodeLevel || 0,
2293
2293
  typeNumber,
2294
+ mode: 4,
2294
2295
  }).makeCode(p);
2295
2296
  r.html(qrcodebox);
2296
2297
  }
@@ -10187,7 +10188,7 @@ var hiprint = (function (t) {
10187
10188
  QRCode({
10188
10189
  level: this.options.getQRcodeLevel(),
10189
10190
  fnc1: 'None',
10190
- mode: 'Auto',
10191
+ mode: 4,
10191
10192
  moduleSize: 8,
10192
10193
  quietZone: 0,
10193
10194
  aimIndicator: 0,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "yh-hiprint",
3
- "version": "2.5.2",
3
+ "version": "2.5.3",
4
4
  "description": "Hiprint for Vue3 by NoahLiu in ForceCon in Hunan Changesha",
5
5
  "main": "index.js",
6
6
  "types": "index.d.ts",
@@ -10,6 +10,15 @@
10
10
  "pub:npm": "npm publish --registry https://registry.npmjs.org/ --no-git-checks"
11
11
  },
12
12
  "dependencies": {
13
+ "@babel/core": "7.28.4",
14
+ "@babel/generator": "7.28.3",
15
+ "@babel/parser": "7.28.4",
16
+ "@babel/plugin-transform-arrow-functions": "^7.27.1",
17
+ "@babel/plugin-transform-block-scoping": "^7.28.4",
18
+ "@babel/plugin-transform-computed-properties": "^7.27.1",
19
+ "@babel/plugin-transform-shorthand-properties": "^7.27.1",
20
+ "@babel/plugin-transform-template-literals": "^7.27.1",
21
+ "@babel/traverse": "7.28.4",
13
22
  "@nuintun/qrcode": "^5.0.1",
14
23
  "canvg": "4.0.1",
15
24
  "html2canvas": "1.4.1",