@bluechaine/print-designer 0.1.1 → 0.1.2

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.
@@ -0,0 +1,1055 @@
1
+ var _a, _b, _c, _d;
2
+ import * as VuePluginHiprint from "vue-plugin-hiprint";
3
+ import { defaultElementTypeProvider } from "vue-plugin-hiprint";
4
+ const DEFAULT_PAPER_LIST = [
5
+ { type: "自定义", width: 0, height: 0 },
6
+ { type: "A1", width: 594, height: 841 },
7
+ { type: "A2", width: 420, height: 594 },
8
+ { type: "A3", width: 297, height: 420 },
9
+ { type: "A4", width: 210, height: 297 },
10
+ { type: "A5", width: 148, height: 210 },
11
+ { type: "A6", width: 105, height: 148 },
12
+ { type: "A7", width: 74, height: 105 },
13
+ { type: "B1", width: 707, height: 1e3 },
14
+ { type: "B2", width: 500, height: 707 },
15
+ { type: "B3", width: 353, height: 500 },
16
+ { type: "B4", width: 250, height: 353 },
17
+ { type: "B5", width: 176, height: 250 },
18
+ { type: "B6", width: 125, height: 176 },
19
+ { type: "B7", width: 88, height: 125 }
20
+ ];
21
+ let defaultPaperList = DEFAULT_PAPER_LIST;
22
+ let patched = false;
23
+ const templateRegistry = /* @__PURE__ */ new Map();
24
+ function getJQuery() {
25
+ return window.jQuery || window.$;
26
+ }
27
+ function nearMm(a, b, eps = 1.5) {
28
+ return Math.abs(a - b) <= eps;
29
+ }
30
+ function detectPaperType(width, height, list = defaultPaperList) {
31
+ const match = list.find(
32
+ (p) => p.width > 0 && (nearMm(p.width, width) && nearMm(p.height, height) || nearMm(p.width, height) && nearMm(p.height, width))
33
+ );
34
+ return (match == null ? void 0 : match.type) || "自定义";
35
+ }
36
+ function resolveTemplate(tplId) {
37
+ var _a2;
38
+ const cached = templateRegistry.get(tplId);
39
+ if (cached) return cached;
40
+ try {
41
+ const lib = (hiprint == null ? void 0 : hiprint.instance) ?? hiprint;
42
+ return ((_a2 = lib == null ? void 0 : lib.getPrintTemplateById) == null ? void 0 : _a2.call(lib, tplId)) ?? null;
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+ function getTemplatePaperList(tpl) {
48
+ if (tpl == null ? void 0 : tpl.getPaperList) {
49
+ try {
50
+ const list = tpl.getPaperList();
51
+ if (Array.isArray(list) && list.length) return list;
52
+ } catch {
53
+ }
54
+ }
55
+ return defaultPaperList;
56
+ }
57
+ function applyPaperList(tpl, value, onApplied) {
58
+ if (!(tpl == null ? void 0 : tpl.setPaper) || !value) return;
59
+ const list = getTemplatePaperList(tpl);
60
+ try {
61
+ const preset = value.type !== "自定义" ? list.find((p) => p.type === value.type && p.width > 0) : null;
62
+ if (preset) {
63
+ tpl.setPaper(String(preset.width), String(preset.height));
64
+ } else if (value.width > 0 && value.height > 0) {
65
+ tpl.setPaper(String(value.width), String(value.height));
66
+ } else {
67
+ return;
68
+ }
69
+ const panel = tpl.editingPanel;
70
+ if (panel) panel.paperType = value.type || "自定义";
71
+ onApplied == null ? void 0 : onApplied();
72
+ } catch (e) {
73
+ console.warn("[hiprint-paper-list] setPaper failed", e);
74
+ }
75
+ }
76
+ function buildPaperListValue(panel, list) {
77
+ const width = Number((panel == null ? void 0 : panel.mmwidth) ?? (panel == null ? void 0 : panel.width) ?? 0);
78
+ const height = Number((panel == null ? void 0 : panel.mmheight) ?? (panel == null ? void 0 : panel.height) ?? 0);
79
+ return {
80
+ type: detectPaperType(width, height, list),
81
+ width,
82
+ height
83
+ };
84
+ }
85
+ function PaperListOptionItem() {
86
+ this.name = "paperList";
87
+ }
88
+ PaperListOptionItem.prototype.createTarget = function(printTemplate) {
89
+ const $ = getJQuery();
90
+ if (!$) return $("<div />");
91
+ this.printTemplate = printTemplate;
92
+ const wrapper = $('<div class="svp-hiprint-paper-list" />');
93
+ const typeRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
94
+ <div class="hiprint-option-item-label">纸张列表</div>
95
+ <div class="hiprint-option-item-field">
96
+ <select class="auto-submit svp-paper-type"></select>
97
+ </div>
98
+ </div>`);
99
+ const widthRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
100
+ <div class="hiprint-option-item-label">宽</div>
101
+ <div class="hiprint-option-item-field">
102
+ <input class="auto-submit svp-paper-width" type="number" min="1" placeholder="宽(mm)" />
103
+ </div>
104
+ </div>`);
105
+ const heightRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
106
+ <div class="hiprint-option-item-label">高</div>
107
+ <div class="hiprint-option-item-field">
108
+ <input class="auto-submit svp-paper-height" type="number" min="1" placeholder="高(mm)" />
109
+ </div>
110
+ </div>`);
111
+ this.typeSelect = typeRow.find("select");
112
+ this.widthInput = widthRow.find("input");
113
+ this.heightInput = heightRow.find("input");
114
+ const list = getTemplatePaperList(printTemplate);
115
+ list.forEach((p) => {
116
+ this.typeSelect.append(
117
+ $("<option />").attr("value", p.type).text(p.type)
118
+ );
119
+ });
120
+ this.typeSelect.on("change", () => {
121
+ const preset = list.find((p) => p.type === this.typeSelect.val());
122
+ if (preset && preset.width > 0) {
123
+ this.widthInput.val(preset.width);
124
+ this.heightInput.val(preset.height);
125
+ }
126
+ });
127
+ wrapper.append(typeRow, widthRow, heightRow);
128
+ this.target = wrapper;
129
+ return wrapper;
130
+ };
131
+ PaperListOptionItem.prototype.getValue = function() {
132
+ var _a2, _b2, _c2;
133
+ return {
134
+ type: String(((_a2 = this.typeSelect) == null ? void 0 : _a2.val()) || "自定义"),
135
+ width: Number((_b2 = this.widthInput) == null ? void 0 : _b2.val()) || 0,
136
+ height: Number((_c2 = this.heightInput) == null ? void 0 : _c2.val()) || 0
137
+ };
138
+ };
139
+ PaperListOptionItem.prototype.setValue = function(value) {
140
+ if (!value) return;
141
+ const $ = getJQuery();
142
+ if (!$) return;
143
+ const list = getTemplatePaperList(this.printTemplate);
144
+ list.forEach((p) => {
145
+ if (!this.typeSelect.find(`option[value="${p.type}"]`).length) {
146
+ this.typeSelect.append($("<option />").attr("value", p.type).text(p.type));
147
+ }
148
+ });
149
+ this.typeSelect.val(value.type || detectPaperType(value.width, value.height, list));
150
+ this.widthInput.val(value.width || "");
151
+ this.heightInput.val(value.height || "");
152
+ };
153
+ PaperListOptionItem.prototype.destroy = function() {
154
+ var _a2, _b2;
155
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
156
+ };
157
+ function OrientOptionItem() {
158
+ this.name = "orient";
159
+ }
160
+ OrientOptionItem.prototype.createTarget = function() {
161
+ const $ = getJQuery();
162
+ if (!$) return $("<div />");
163
+ const wrapper = $('<div class="svp-hiprint-orient" />');
164
+ wrapper.append(
165
+ $(`<div class="hiprint-option-item hiprint-option-item-row">
166
+ <div class="hiprint-option-item-label">打印方向</div>
167
+ <div class="hiprint-option-item-field">
168
+ <select class="auto-submit">
169
+ <option value="">默认</option>
170
+ <option value="1">纵向</option>
171
+ <option value="2">横向</option>
172
+ </select>
173
+ </div>
174
+ </div>`)
175
+ );
176
+ wrapper.append(
177
+ $('<div class="hiprint-option-item-desc">(仅自定义纸质有效)</div>')
178
+ );
179
+ this.target = wrapper;
180
+ return this.target;
181
+ };
182
+ OrientOptionItem.prototype.getValue = function() {
183
+ var _a2, _b2, _c2, _d2;
184
+ const val = (_d2 = (_c2 = (_b2 = (_a2 = this.target) == null ? void 0 : _a2.find) == null ? void 0 : _b2.call(_a2, "select")) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2);
185
+ if (val === "" || val == null) return void 0;
186
+ return parseFloat(String(val));
187
+ };
188
+ OrientOptionItem.prototype.setValue = function(value) {
189
+ var _a2, _b2, _c2, _d2;
190
+ (_d2 = (_c2 = (_b2 = (_a2 = this.target) == null ? void 0 : _a2.find) == null ? void 0 : _b2.call(_a2, "select")) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value ?? "");
191
+ };
192
+ OrientOptionItem.prototype.destroy = function() {
193
+ var _a2, _b2;
194
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
195
+ };
196
+ const WATERMARK_TIME_FORMATS = [
197
+ "YYYY-MM-DD HH:mm:ss",
198
+ "YYYY-MM-DD HH:mm",
199
+ "YYYY-MM-DD HH",
200
+ "YYYY-MM-DD",
201
+ "YYYY-MMMM",
202
+ "YYYY-MM",
203
+ "YYYY"
204
+ ];
205
+ function WatermarkOptionItem() {
206
+ this.name = "watermarkOptions";
207
+ }
208
+ WatermarkOptionItem.prototype.createTarget = function() {
209
+ const $ = getJQuery();
210
+ if (!$) return $("<div />");
211
+ const wrapper = $('<div class="svp-hiprint-watermark" />');
212
+ wrapper.append($('<div class="hiprint-option-title">水印功能</div>'));
213
+ const contentRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
214
+ <div class="hiprint-option-item-label">水印内容</div>
215
+ <div class="hiprint-option-item-field">
216
+ <input type="text" class="auto-submit" placeholder="水印内容" />
217
+ </div>
218
+ </div>`);
219
+ const fillStyleRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
220
+ <div class="hiprint-option-item-label">字体颜色</div>
221
+ <div class="hiprint-option-item-field">
222
+ <input type="text" class="auto-submit" data-format="rgb" data-opacity="0.3" placeholder="字体颜色" />
223
+ </div>
224
+ </div>`);
225
+ const fontSizeRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
226
+ <div class="hiprint-option-item-label">字体大小</div>
227
+ <div class="hiprint-option-item-field">
228
+ <input type="range" class="auto-submit" min="10" max="80" placeholder="字体大小" />
229
+ </div>
230
+ </div>`);
231
+ const rotateRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
232
+ <div class="hiprint-option-item-label">旋转角度</div>
233
+ <div class="hiprint-option-item-field">
234
+ <input type="range" class="auto-submit" min="0" max="180" placeholder="旋转角度" />
235
+ </div>
236
+ </div>`);
237
+ const widthRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
238
+ <div class="hiprint-option-item-label">水平密度</div>
239
+ <div class="hiprint-option-item-field">
240
+ <input type="range" class="auto-submit" min="100" max="800" placeholder="水平密度" />
241
+ </div>
242
+ </div>`);
243
+ const heightRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
244
+ <div class="hiprint-option-item-label">垂直密度</div>
245
+ <div class="hiprint-option-item-field">
246
+ <input type="range" class="auto-submit" min="100" max="800" placeholder="垂直密度" />
247
+ </div>
248
+ </div>`);
249
+ const timestampRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
250
+ <div class="hiprint-option-item-label">水印时间</div>
251
+ <div class="hiprint-option-item-field">
252
+ <input type="checkbox" class="auto-submit" placeholder="水印时间" />
253
+ </div>
254
+ </div>`);
255
+ const formatRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
256
+ <div class="hiprint-option-item-label">时间格式</div>
257
+ <div class="hiprint-option-item-field">
258
+ <select class="auto-submit"></select>
259
+ </div>
260
+ </div>`);
261
+ const formatSelect = formatRow.find("select");
262
+ formatSelect.append($('<option value="">默认(YYYY-MM-DD HH:mm)</option>'));
263
+ WATERMARK_TIME_FORMATS.forEach((fmt) => {
264
+ formatSelect.append($(`<option value="${fmt}">${fmt}</option>`));
265
+ });
266
+ wrapper.append(
267
+ contentRow,
268
+ fillStyleRow,
269
+ fontSizeRow,
270
+ rotateRow,
271
+ widthRow,
272
+ heightRow,
273
+ timestampRow,
274
+ formatRow
275
+ );
276
+ this.content = contentRow.find("input");
277
+ this.fillStyle = fillStyleRow.find("input");
278
+ this.fontSize = fontSizeRow.find("input");
279
+ this.rotate = rotateRow.find("input");
280
+ this.width = widthRow.find("input");
281
+ this.height = heightRow.find("input");
282
+ this.timestamp = timestampRow.find("input");
283
+ this.format = formatSelect;
284
+ this.target = wrapper;
285
+ return this.target;
286
+ };
287
+ WatermarkOptionItem.prototype.getValue = function() {
288
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p;
289
+ const format = (_b2 = (_a2 = this.format) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2);
290
+ return {
291
+ content: ((_d2 = (_c2 = this.content) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2)) || "",
292
+ fillStyle: ((_f = (_e = this.fillStyle) == null ? void 0 : _e.val) == null ? void 0 : _f.call(_e)) || "rgba(184, 184, 184, 0.3)",
293
+ fontSize: `${parseInt(String(((_h = (_g = this.fontSize) == null ? void 0 : _g.val) == null ? void 0 : _h.call(_g)) || "14"), 10)}px`,
294
+ rotate: parseInt(String(((_j = (_i = this.rotate) == null ? void 0 : _i.val) == null ? void 0 : _j.call(_i)) || "25"), 10),
295
+ width: parseInt(String(((_l = (_k = this.width) == null ? void 0 : _k.val) == null ? void 0 : _l.call(_k)) || "200"), 10),
296
+ height: parseInt(String(((_n = (_m = this.height) == null ? void 0 : _m.val) == null ? void 0 : _n.call(_m)) || "200"), 10),
297
+ timestamp: !!((_p = (_o = this.timestamp) == null ? void 0 : _o.is) == null ? void 0 : _p.call(_o, ":checked")),
298
+ format: format ? String(format) : "YYYY-MM-DD HH:mm"
299
+ };
300
+ };
301
+ WatermarkOptionItem.prototype.setValue = function(value) {
302
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
303
+ if (!value) value = {};
304
+ (_b2 = (_a2 = this.content) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2, value.content || "");
305
+ (_d2 = (_c2 = this.fillStyle) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value.fillStyle || "rgba(184, 184, 184, 0.3)");
306
+ try {
307
+ (_f = (_e = this.fillStyle) == null ? void 0 : _e.minicolors) == null ? void 0 : _f.call(_e, {
308
+ format: "rgb",
309
+ opacity: true,
310
+ theme: "bootstrap"
311
+ });
312
+ } catch {
313
+ }
314
+ const fontSize = parseInt(String(value.fontSize || "14").replace(/px$/i, ""), 10) || 14;
315
+ (_h = (_g = this.fontSize) == null ? void 0 : _g.val) == null ? void 0 : _h.call(_g, fontSize);
316
+ (_j = (_i = this.rotate) == null ? void 0 : _i.val) == null ? void 0 : _j.call(_i, value.rotate ?? 25);
317
+ (_l = (_k = this.width) == null ? void 0 : _k.val) == null ? void 0 : _l.call(_k, value.width ?? 200);
318
+ (_n = (_m = this.height) == null ? void 0 : _m.val) == null ? void 0 : _n.call(_m, value.height ?? 200);
319
+ (_p = (_o = this.timestamp) == null ? void 0 : _o.prop) == null ? void 0 : _p.call(_o, "checked", value.timestamp != null ? !!value.timestamp : false);
320
+ (_r = (_q = this.format) == null ? void 0 : _q.val) == null ? void 0 : _r.call(_q, value.format || "YYYY-MM-DD HH:mm");
321
+ };
322
+ WatermarkOptionItem.prototype.destroy = function() {
323
+ var _a2, _b2;
324
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
325
+ };
326
+ function PanelBackgroundColorOptionItem() {
327
+ this.name = "backgroundColor";
328
+ }
329
+ PanelBackgroundColorOptionItem.prototype.createTarget = function() {
330
+ const $ = getJQuery();
331
+ if (!$) return $("<div />");
332
+ const row = $(`<div class="hiprint-option-item hiprint-option-item-row">
333
+ <div class="hiprint-option-item-label">背景颜色</div>
334
+ <div class="hiprint-option-item-field">
335
+ <input type="text" class="auto-submit" />
336
+ </div>
337
+ </div>`);
338
+ this.input = row.find("input");
339
+ this.target = row;
340
+ return this.target;
341
+ };
342
+ PanelBackgroundColorOptionItem.prototype.getValue = function() {
343
+ var _a2, _b2;
344
+ const val = (_b2 = (_a2 = this.input) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2);
345
+ return val ? String(val) : void 0;
346
+ };
347
+ PanelBackgroundColorOptionItem.prototype.setValue = function(value) {
348
+ var _a2, _b2, _c2, _d2;
349
+ const color = value || "#ffffff";
350
+ try {
351
+ (_b2 = (_a2 = this.input) == null ? void 0 : _a2.minicolors) == null ? void 0 : _b2.call(_a2, {
352
+ defaultValue: color,
353
+ theme: "bootstrap"
354
+ });
355
+ } catch {
356
+ }
357
+ (_d2 = (_c2 = this.input) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, color);
358
+ };
359
+ PanelBackgroundColorOptionItem.prototype.css = function(target, value) {
360
+ const $ = getJQuery();
361
+ if (!$ || !(target == null ? void 0 : target.length)) return null;
362
+ if (value) {
363
+ $(target).css("background-color", value);
364
+ return `background-color:${value}`;
365
+ }
366
+ target[0].style.backgroundColor = "";
367
+ return null;
368
+ };
369
+ PanelBackgroundColorOptionItem.prototype.destroy = function() {
370
+ var _a2, _b2;
371
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
372
+ };
373
+ function applyPanelBackgroundColor(panel, color) {
374
+ var _a2, _b2, _c2, _d2;
375
+ if (!panel) return;
376
+ const value = color || "#ffffff";
377
+ panel.backgroundColor = value;
378
+ const $ = getJQuery();
379
+ const paper = ((_a2 = panel.designPaper) == null ? void 0 : _a2.target) || ((_c2 = (_b2 = panel.target) == null ? void 0 : _b2.find) == null ? void 0 : _c2.call(_b2, ".hiprint-printPaper")) || ($ && panel.target ? $(panel.target).find(".hiprint-printPaper") : null);
380
+ if (paper == null ? void 0 : paper.css) {
381
+ paper.css("background-color", value);
382
+ } else if ((paper == null ? void 0 : paper.length) && ((_d2 = paper[0]) == null ? void 0 : _d2.style)) {
383
+ paper[0].style.backgroundColor = value;
384
+ }
385
+ }
386
+ function PanelLayoutOptionItem() {
387
+ this.name = "panelLayoutOptions";
388
+ }
389
+ PanelLayoutOptionItem.prototype.createTarget = function() {
390
+ const $ = getJQuery();
391
+ if (!$) return $("<div />");
392
+ const wrapper = $('<div class="svp-hiprint-panel-layout" />');
393
+ wrapper.append($('<div class="hiprint-option-title">排列填充纸张</div>'));
394
+ wrapper.append(
395
+ $('<div class="hiprint-option-item-desc svp-panel-layout-hint">小模板传数组&填充纸张宽高打印</div>')
396
+ );
397
+ const layoutTypeRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
398
+ <div class="hiprint-option-item-label">排列方式</div>
399
+ <div class="hiprint-option-item-field">
400
+ <select class="auto-submit">
401
+ <option value="column">纵向</option>
402
+ <option value="row">横向</option>
403
+ </select>
404
+ </div>
405
+ </div>`);
406
+ const layoutRowGapRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
407
+ <div class="hiprint-option-item-label">垂直间距</div>
408
+ <div class="hiprint-option-item-field">
409
+ <input type="number" class="auto-submit" placeholder="垂直间距mm" />
410
+ </div>
411
+ </div>`);
412
+ const layoutColumnGapRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
413
+ <div class="hiprint-option-item-label">水平间距</div>
414
+ <div class="hiprint-option-item-field">
415
+ <input type="number" class="auto-submit" placeholder="水平间距mm" />
416
+ </div>
417
+ </div>`);
418
+ const paperWidthRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
419
+ <div class="hiprint-option-item-label">纸张宽度</div>
420
+ <div class="hiprint-option-item-field">
421
+ <input type="number" class="auto-submit" placeholder="纸张宽度mm" />
422
+ </div>
423
+ </div>`);
424
+ const paperHeightRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
425
+ <div class="hiprint-option-item-label">纸张高度</div>
426
+ <div class="hiprint-option-item-field">
427
+ <input type="number" class="auto-submit" placeholder="纸张高度mm" />
428
+ </div>
429
+ </div>`);
430
+ const paperStyleRow = $(`<div class="hiprint-option-item hiprint-option-item-row">
431
+ <div class="hiprint-option-item-label">纸张样式</div>
432
+ <div class="hiprint-option-item-field">
433
+ <input type="text" class="auto-submit" placeholder="align-content:center;justify-content:center" />
434
+ </div>
435
+ </div>`);
436
+ wrapper.append(
437
+ layoutTypeRow,
438
+ layoutRowGapRow,
439
+ layoutColumnGapRow,
440
+ paperWidthRow,
441
+ paperHeightRow,
442
+ paperStyleRow
443
+ );
444
+ this.layoutType = layoutTypeRow.find("select");
445
+ this.layoutRowGap = layoutRowGapRow.find("input");
446
+ this.layoutColumnGap = layoutColumnGapRow.find("input");
447
+ this.paperWidth = paperWidthRow.find("input");
448
+ this.paperHeight = paperHeightRow.find("input");
449
+ this.paperStyle = paperStyleRow.find("input");
450
+ this.target = wrapper;
451
+ return this.target;
452
+ };
453
+ PanelLayoutOptionItem.prototype.getValue = function() {
454
+ var _a2, _b2, _c2, _d2;
455
+ const num = (el) => {
456
+ var _a3;
457
+ return parseInt(String(((_a3 = el == null ? void 0 : el.val) == null ? void 0 : _a3.call(el)) || 0), 10) || 0;
458
+ };
459
+ return {
460
+ layoutType: ((_b2 = (_a2 = this.layoutType) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2)) || "column",
461
+ layoutRowGap: num(this.layoutRowGap),
462
+ layoutColumnGap: num(this.layoutColumnGap),
463
+ paperWidth: num(this.paperWidth),
464
+ paperHeight: num(this.paperHeight),
465
+ paperStyle: ((_d2 = (_c2 = this.paperStyle) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2)) || ""
466
+ };
467
+ };
468
+ PanelLayoutOptionItem.prototype.setValue = function(value) {
469
+ var _a2, _b2, _c2, _d2, _e, _f, _g, _h, _i, _j, _k, _l;
470
+ if (!value) return;
471
+ (_b2 = (_a2 = this.layoutType) == null ? void 0 : _a2.val) == null ? void 0 : _b2.call(_a2, value.layoutType || "column");
472
+ (_d2 = (_c2 = this.layoutRowGap) == null ? void 0 : _c2.val) == null ? void 0 : _d2.call(_c2, value.layoutRowGap ?? "");
473
+ (_f = (_e = this.layoutColumnGap) == null ? void 0 : _e.val) == null ? void 0 : _f.call(_e, value.layoutColumnGap ?? "");
474
+ (_h = (_g = this.paperWidth) == null ? void 0 : _g.val) == null ? void 0 : _h.call(_g, value.paperWidth ?? "");
475
+ (_j = (_i = this.paperHeight) == null ? void 0 : _i.val) == null ? void 0 : _j.call(_i, value.paperHeight ?? "");
476
+ (_l = (_k = this.paperStyle) == null ? void 0 : _k.val) == null ? void 0 : _l.call(_k, value.paperStyle ?? "");
477
+ };
478
+ PanelLayoutOptionItem.prototype.destroy = function() {
479
+ var _a2, _b2;
480
+ (_b2 = (_a2 = this.target) == null ? void 0 : _a2.remove) == null ? void 0 : _b2.call(_a2);
481
+ };
482
+ function reorderPanelSettingOptions(options, panel, paperList) {
483
+ const {
484
+ paperList: _pl,
485
+ panelLayoutOptions,
486
+ backgroundColor: _bg,
487
+ watermarkOptions,
488
+ ...rest
489
+ } = options;
490
+ return {
491
+ paperList,
492
+ ...rest,
493
+ backgroundColor: panel.backgroundColor ?? _bg ?? "#ffffff",
494
+ watermarkOptions,
495
+ panelLayoutOptions
496
+ };
497
+ }
498
+ function ensurePaperListSupportOptionsFirst() {
499
+ var _a2, _b2, _c2;
500
+ try {
501
+ const cfg = window.HIPRINT_CONFIG;
502
+ const instanceOpts = (_b2 = (_a2 = hiprint == null ? void 0 : hiprint.instance) == null ? void 0 : _a2.panel) == null ? void 0 : _b2.supportOptions;
503
+ const cfgOpts = (_c2 = cfg == null ? void 0 : cfg.panel) == null ? void 0 : _c2.supportOptions;
504
+ const opts = instanceOpts || cfgOpts;
505
+ if (!Array.isArray(opts)) return;
506
+ const idx = opts.findIndex((o) => o.name === "paperList");
507
+ if (idx > 0) {
508
+ const [item] = opts.splice(idx, 1);
509
+ opts.unshift(item);
510
+ } else if (idx < 0) {
511
+ opts.unshift({ name: "paperList", hidden: false });
512
+ }
513
+ if (!opts.some((o) => o.name === "backgroundColor")) {
514
+ const wmIdx = opts.findIndex((o) => o.name === "watermarkOptions");
515
+ const entry = { name: "backgroundColor", hidden: false };
516
+ if (wmIdx >= 0) opts.splice(wmIdx, 0, entry);
517
+ else opts.push(entry);
518
+ }
519
+ } catch {
520
+ }
521
+ }
522
+ function patchPrintTemplatePaperList() {
523
+ var _a2;
524
+ const proto = (_a2 = hiprint.PrintTemplate) == null ? void 0 : _a2.prototype;
525
+ if (!proto || proto.__svpPaperListPatched) return;
526
+ proto.setPaperList = function(list) {
527
+ this._paperList = Array.isArray(list) && list.length ? list : defaultPaperList;
528
+ };
529
+ proto.getPaperList = function() {
530
+ return this._paperList || defaultPaperList;
531
+ };
532
+ proto.__svpPaperListPatched = true;
533
+ }
534
+ function patchPanelSettingTrigger(onPaperApplied) {
535
+ var _a2;
536
+ const bus = (_a2 = window.hinnn) == null ? void 0 : _a2.event;
537
+ if (!bus || bus.__svpPaperListTriggerPatch) return;
538
+ const origTrigger = bus.trigger.bind(bus);
539
+ bus.trigger = function(key, ...args) {
540
+ var _a3;
541
+ if (typeof key === "string" && key.startsWith("BuildCustomOptionSettingEventKey_") && ((_a3 = args[0]) == null ? void 0 : _a3.options)) {
542
+ const tplId = key.slice("BuildCustomOptionSettingEventKey_".length);
543
+ const tpl = resolveTemplate(tplId);
544
+ const panel = tpl == null ? void 0 : tpl.editingPanel;
545
+ if (panel) {
546
+ const payload = args[0];
547
+ const list = getTemplatePaperList(tpl);
548
+ const paperList = buildPaperListValue(panel, list);
549
+ payload.options = reorderPanelSettingOptions(payload.options, panel, paperList);
550
+ const origCallback = payload.callback;
551
+ payload.callback = (values) => {
552
+ if ((values == null ? void 0 : values.paperList) && tpl) {
553
+ applyPaperList(tpl, values.paperList, () => onPaperApplied == null ? void 0 : onPaperApplied(tpl));
554
+ }
555
+ if (values && "backgroundColor" in values) {
556
+ applyPanelBackgroundColor(panel, values.backgroundColor);
557
+ }
558
+ origCallback == null ? void 0 : origCallback(values);
559
+ };
560
+ }
561
+ }
562
+ return origTrigger(key, ...args);
563
+ };
564
+ bus.__svpPaperListTriggerPatch = true;
565
+ }
566
+ function setupHiprintPaperList(paperList = DEFAULT_PAPER_LIST, onPaperApplied) {
567
+ defaultPaperList = paperList.length ? paperList : DEFAULT_PAPER_LIST;
568
+ if (patched) return;
569
+ patchPrintTemplatePaperList();
570
+ patchPanelSettingTrigger(onPaperApplied);
571
+ try {
572
+ hiprint.setConfig({
573
+ optionItems: [
574
+ PaperListOptionItem,
575
+ OrientOptionItem,
576
+ PanelBackgroundColorOptionItem,
577
+ WatermarkOptionItem,
578
+ PanelLayoutOptionItem
579
+ ],
580
+ panel: {
581
+ supportOptions: [
582
+ { name: "paperList", hidden: false },
583
+ { name: "backgroundColor", hidden: false }
584
+ ]
585
+ }
586
+ });
587
+ ensurePaperListSupportOptionsFirst();
588
+ } catch (e) {
589
+ console.warn("[hiprint-paper-list] setConfig failed", e);
590
+ }
591
+ patched = true;
592
+ }
593
+ const DEFAULT_TABLE_FIELDS = [
594
+ { text: "id", field: "id" },
595
+ { text: "姓名", field: "name" },
596
+ { text: "性别", field: "gender" },
597
+ { text: "数量", field: "count" }
598
+ ];
599
+ const DEFAULT_TABLE_COLUMNS = [
600
+ [
601
+ {
602
+ width: 102.30000000000001,
603
+ checked: true,
604
+ fixed: false,
605
+ rowspan: 1,
606
+ colspan: 1
607
+ },
608
+ {
609
+ width: 102.30000000000001,
610
+ title: "姓名",
611
+ field: "name",
612
+ checked: true,
613
+ columnId: "name",
614
+ fixed: false,
615
+ rowspan: 1,
616
+ colspan: 1,
617
+ align: "center",
618
+ tableSummary: "count"
619
+ },
620
+ {
621
+ width: 102.30000000000001,
622
+ title: "数量",
623
+ field: "count",
624
+ checked: true,
625
+ columnId: "count",
626
+ fixed: false,
627
+ rowspan: 1,
628
+ colspan: 1,
629
+ align: "center",
630
+ tableSummary: "sum"
631
+ },
632
+ {
633
+ width: 102.30000000000001,
634
+ checked: true,
635
+ fixed: false,
636
+ rowspan: 1,
637
+ colspan: 1
638
+ },
639
+ {
640
+ width: 102.30000000000001,
641
+ checked: true,
642
+ fixed: false,
643
+ rowspan: 1,
644
+ colspan: 1
645
+ },
646
+ {
647
+ width: 85.25,
648
+ title: "性别",
649
+ field: "gender",
650
+ checked: false,
651
+ columnId: "gender",
652
+ fixed: false,
653
+ rowspan: 1,
654
+ colspan: 1
655
+ }
656
+ ]
657
+ ];
658
+ const DEFAULT_TABLE_ELEMENT_TYPE = {
659
+ title: "表格",
660
+ type: "table",
661
+ field: "table",
662
+ fields: DEFAULT_TABLE_FIELDS.map((f) => ({ ...f })),
663
+ columns: DEFAULT_TABLE_COLUMNS.map((row) => row.map((col) => ({ ...col }))),
664
+ editable: true,
665
+ columnDisplayEditable: true,
666
+ columnDisplayIndexEditable: true,
667
+ columnTitleEditable: true,
668
+ columnResizable: true,
669
+ columnAlignEditable: true,
670
+ isEnableEditField: true,
671
+ isEnableContextMenu: true,
672
+ isEnableInsertRow: true,
673
+ isEnableDeleteRow: true,
674
+ isEnableInsertColumn: true,
675
+ isEnableDeleteColumn: true,
676
+ isEnableMergeCell: true
677
+ };
678
+ class Provider {
679
+ }
680
+ const TABLE_TID = "defaultModule.table";
681
+ function rebuildTableColumns(type) {
682
+ if (typeof type.createTableColumnArray !== "function") return;
683
+ type.columns = [];
684
+ DEFAULT_TABLE_ELEMENT_TYPE.columns.forEach((row) => {
685
+ type.columns.push(type.createTableColumnArray(row.map((col) => ({ ...col }))));
686
+ });
687
+ if (typeof type.makeColumnObj === "function") {
688
+ type.columnObj = type.makeColumnObj();
689
+ }
690
+ }
691
+ function applyCustomTableType(current) {
692
+ Object.assign(current, {
693
+ title: DEFAULT_TABLE_ELEMENT_TYPE.title,
694
+ type: DEFAULT_TABLE_ELEMENT_TYPE.type,
695
+ field: DEFAULT_TABLE_ELEMENT_TYPE.field,
696
+ fields: DEFAULT_TABLE_ELEMENT_TYPE.fields.map((f) => ({ ...f })),
697
+ editable: DEFAULT_TABLE_ELEMENT_TYPE.editable,
698
+ columnDisplayEditable: DEFAULT_TABLE_ELEMENT_TYPE.columnDisplayEditable,
699
+ columnDisplayIndexEditable: DEFAULT_TABLE_ELEMENT_TYPE.columnDisplayIndexEditable,
700
+ columnTitleEditable: DEFAULT_TABLE_ELEMENT_TYPE.columnTitleEditable,
701
+ columnResizable: DEFAULT_TABLE_ELEMENT_TYPE.columnResizable,
702
+ columnAlignEditable: DEFAULT_TABLE_ELEMENT_TYPE.columnAlignEditable,
703
+ isEnableEditField: DEFAULT_TABLE_ELEMENT_TYPE.isEnableEditField,
704
+ isEnableContextMenu: DEFAULT_TABLE_ELEMENT_TYPE.isEnableContextMenu,
705
+ isEnableInsertRow: DEFAULT_TABLE_ELEMENT_TYPE.isEnableInsertRow,
706
+ isEnableDeleteRow: DEFAULT_TABLE_ELEMENT_TYPE.isEnableDeleteRow,
707
+ isEnableInsertColumn: DEFAULT_TABLE_ELEMENT_TYPE.isEnableInsertColumn,
708
+ isEnableDeleteColumn: DEFAULT_TABLE_ELEMENT_TYPE.isEnableDeleteColumn,
709
+ isEnableMergeCell: DEFAULT_TABLE_ELEMENT_TYPE.isEnableMergeCell,
710
+ groupFields: [],
711
+ groupFooterFormatter: void 0,
712
+ groupFormatter: void 0
713
+ });
714
+ rebuildTableColumns(current);
715
+ return current;
716
+ }
717
+ class SvpElementTypeProvider extends Provider {
718
+ addElementTypes(context) {
719
+ var _a2;
720
+ new defaultElementTypeProvider().addElementTypes(context);
721
+ if (typeof context.updateElementType === "function") {
722
+ context.updateElementType(TABLE_TID, applyCustomTableType);
723
+ return;
724
+ }
725
+ const current = (_a2 = context.getElementType) == null ? void 0 : _a2.call(context, TABLE_TID);
726
+ if (current) applyCustomTableType(current);
727
+ }
728
+ }
729
+ function ensureProviders(providers) {
730
+ if (providers && providers.length) return providers;
731
+ return [new SvpElementTypeProvider()];
732
+ }
733
+ const plugin = VuePluginHiprint;
734
+ const hiprint = plugin.hiprint ?? ((_a = plugin.default) == null ? void 0 : _a.hiprint);
735
+ plugin.defaultElementTypeProvider ?? ((_b = plugin.default) == null ? void 0 : _b.defaultElementTypeProvider);
736
+ const autoConnect = plugin.autoConnect ?? ((_c = plugin.default) == null ? void 0 : _c.autoConnect);
737
+ const disAutoConnect = plugin.disAutoConnect ?? ((_d = plugin.default) == null ? void 0 : _d.disAutoConnect);
738
+ let initialized = false;
739
+ function initHiprint(options = {}) {
740
+ var _a2;
741
+ const providers = ensureProviders(options.providers);
742
+ if (!initialized) {
743
+ try {
744
+ hiprint.init({ providers, ...options.config ?? {} });
745
+ setupHiprintPaperList(
746
+ options.paperList ?? DEFAULT_PAPER_LIST,
747
+ options.onPaperApplied
748
+ );
749
+ } catch (e) {
750
+ console.error("[vue3-print-designer] hiprint.init failed", e);
751
+ }
752
+ initialized = true;
753
+ } else if ((_a2 = options.providers) == null ? void 0 : _a2.length) {
754
+ try {
755
+ options.providers.forEach(
756
+ (p) => {
757
+ var _a3, _b2;
758
+ return (_b2 = (_a3 = hiprint.PrintElementTypeManager) == null ? void 0 : _a3.build) == null ? void 0 : _b2.call(_a3, [p]);
759
+ }
760
+ );
761
+ } catch (e) {
762
+ console.warn("[vue3-print-designer] re-build providers failed", e);
763
+ }
764
+ }
765
+ if (options.autoConnect === false) {
766
+ try {
767
+ disAutoConnect();
768
+ } catch (_) {
769
+ }
770
+ }
771
+ return hiprint;
772
+ }
773
+ function normalizePrinterList(raw) {
774
+ if (!Array.isArray(raw)) return [];
775
+ return raw.map((item) => {
776
+ if (typeof item === "string") {
777
+ return { name: item, displayName: item };
778
+ }
779
+ if (!item || typeof item !== "object") return null;
780
+ const record = item;
781
+ const name = String(record.name ?? record.Name ?? "");
782
+ if (!name) return null;
783
+ return {
784
+ ...record,
785
+ name,
786
+ displayName: String(record.displayName ?? record.DisplayName ?? name),
787
+ isDefault: Boolean(record.isDefault ?? record.IsDefault ?? record.default)
788
+ };
789
+ }).filter((item) => item != null);
790
+ }
791
+ function normalizeClientList(raw) {
792
+ if (!Array.isArray(raw)) return [];
793
+ return raw.filter((item) => item && typeof item === "object");
794
+ }
795
+ function buildPrint2Payload(options) {
796
+ if (!options) {
797
+ return { printer: "", title: "print" };
798
+ }
799
+ const {
800
+ printer,
801
+ title,
802
+ client,
803
+ printByFragments,
804
+ generateHTMLInterval,
805
+ fragmentSize,
806
+ sendInterval,
807
+ ...rest
808
+ } = options;
809
+ return {
810
+ printer: printer ?? "",
811
+ title: title ?? "print",
812
+ ...client != null ? { client } : {},
813
+ ...printByFragments != null ? { printByFragments } : {},
814
+ ...generateHTMLInterval != null ? { generateHTMLInterval } : {},
815
+ ...fragmentSize != null ? { fragmentSize } : {},
816
+ ...sendInterval != null ? { sendInterval } : {},
817
+ ...rest
818
+ };
819
+ }
820
+ function readSocketConnected() {
821
+ try {
822
+ const ws = hiprint.hiwebSocket;
823
+ if (!ws) return false;
824
+ if (ws.opened === true || ws.connected === true) return true;
825
+ if (typeof ws.isConnected === "function" && ws.isConnected()) return true;
826
+ return false;
827
+ } catch {
828
+ return false;
829
+ }
830
+ }
831
+ const _PrintClient = class _PrintClient {
832
+ constructor() {
833
+ this.status = { connected: false };
834
+ this.initConfig = {};
835
+ this.connectPromise = null;
836
+ this.connectionCallbacks = /* @__PURE__ */ new Set();
837
+ this.printSuccessCallbacks = /* @__PURE__ */ new Set();
838
+ this.printErrorCallbacks = /* @__PURE__ */ new Set();
839
+ }
840
+ static getInstance() {
841
+ if (!_PrintClient.instance) _PrintClient.instance = new _PrintClient();
842
+ return _PrintClient.instance;
843
+ }
844
+ connect(options = {}) {
845
+ if (typeof window === "undefined") {
846
+ const status = { connected: false, message: "PrintClient requires a browser environment." };
847
+ this.updateStatus(status);
848
+ return Promise.resolve(status);
849
+ }
850
+ if (this.getStatus().connected) {
851
+ return Promise.resolve(this.getStatus());
852
+ }
853
+ if (this.connectPromise) return this.connectPromise;
854
+ this.connectPromise = new Promise((resolve) => {
855
+ var _a2;
856
+ const timeoutMs = options.timeout ?? 1e4;
857
+ let settled = false;
858
+ const finish = (status) => {
859
+ if (settled) return;
860
+ settled = true;
861
+ window.clearTimeout(timer);
862
+ this.connectPromise = null;
863
+ this.updateStatus(status);
864
+ resolve(status);
865
+ };
866
+ const timer = window.setTimeout(() => {
867
+ finish({
868
+ connected: false,
869
+ message: "Connection timeout. Is electron-hiprint running?"
870
+ });
871
+ }, timeoutMs);
872
+ const config = { ...this.initConfig };
873
+ if (options.host) config.host = options.host;
874
+ if (options.token) config.token = options.token;
875
+ this.initConfig = config;
876
+ initHiprint({
877
+ providers: ensureProviders(),
878
+ autoConnect: false,
879
+ config
880
+ });
881
+ try {
882
+ if (options.host && typeof ((_a2 = hiprint.hiwebSocket) == null ? void 0 : _a2.setHost) === "function") {
883
+ hiprint.hiwebSocket.setHost(options.host, options.token);
884
+ }
885
+ } catch (e) {
886
+ console.warn("[print-designer] hiwebSocket.setHost failed", e);
887
+ }
888
+ try {
889
+ autoConnect((status, msg) => {
890
+ const message = typeof msg === "string" ? msg : msg != null ? String(msg) : status ? void 0 : "Failed to connect to print client.";
891
+ finish({ connected: !!status, message });
892
+ });
893
+ } catch (e) {
894
+ finish({
895
+ connected: false,
896
+ message: e instanceof Error ? e.message : String(e)
897
+ });
898
+ }
899
+ });
900
+ return this.connectPromise;
901
+ }
902
+ disconnect() {
903
+ try {
904
+ disAutoConnect();
905
+ } catch {
906
+ }
907
+ this.connectPromise = null;
908
+ this.updateStatus({ connected: false, message: "Disconnected." });
909
+ }
910
+ getStatus() {
911
+ const socketConnected = readSocketConnected();
912
+ if (socketConnected && !this.status.connected) {
913
+ this.status = { connected: true };
914
+ }
915
+ if (!socketConnected && this.status.connected) {
916
+ this.status = { connected: false, message: this.status.message ?? "Disconnected." };
917
+ }
918
+ return { ...this.status };
919
+ }
920
+ getPrinterList() {
921
+ var _a2, _b2;
922
+ try {
923
+ const list = (_b2 = (_a2 = hiprint.hiwebSocket) == null ? void 0 : _a2.getPrinterList) == null ? void 0 : _b2.call(_a2);
924
+ return normalizePrinterList(list);
925
+ } catch {
926
+ return [];
927
+ }
928
+ }
929
+ getClients() {
930
+ try {
931
+ const ws = hiprint.hiwebSocket;
932
+ if (!ws) return [];
933
+ if (Array.isArray(ws.clients)) return normalizeClientList(ws.clients);
934
+ if (typeof ws.getClients === "function") {
935
+ return normalizeClientList(ws.getClients());
936
+ }
937
+ return [];
938
+ } catch {
939
+ return [];
940
+ }
941
+ }
942
+ async printByTemplate(template, printData, options) {
943
+ initHiprint({
944
+ providers: ensureProviders(),
945
+ autoConnect: false,
946
+ config: this.initConfig
947
+ });
948
+ const instance = new hiprint.PrintTemplate({ template });
949
+ return this.printByInstance(instance, printData, options);
950
+ }
951
+ async printByInstance(printTemplate, printData, options) {
952
+ if (!this.getStatus().connected) {
953
+ throw new Error("[print-designer] Print client is not connected. Call connect() first.");
954
+ }
955
+ if (typeof (printTemplate == null ? void 0 : printTemplate.print2) !== "function") {
956
+ throw new Error("[print-designer] print2 is not available on the template instance.");
957
+ }
958
+ return new Promise((resolve, reject) => {
959
+ var _a2, _b2;
960
+ const onSuccess = (data) => {
961
+ cleanup();
962
+ this.notifyPrintSuccess(data);
963
+ resolve();
964
+ };
965
+ const onError = (data) => {
966
+ cleanup();
967
+ this.notifyPrintError(data);
968
+ reject(data instanceof Error ? data : new Error(String(data ?? "Print failed")));
969
+ };
970
+ const cleanup = () => {
971
+ var _a3, _b3;
972
+ try {
973
+ (_a3 = printTemplate.off) == null ? void 0 : _a3.call(printTemplate, "printSuccess", onSuccess);
974
+ } catch {
975
+ }
976
+ try {
977
+ (_b3 = printTemplate.off) == null ? void 0 : _b3.call(printTemplate, "printError", onError);
978
+ } catch {
979
+ }
980
+ };
981
+ try {
982
+ (_a2 = printTemplate.on) == null ? void 0 : _a2.call(printTemplate, "printSuccess", onSuccess);
983
+ (_b2 = printTemplate.on) == null ? void 0 : _b2.call(printTemplate, "printError", onError);
984
+ printTemplate.print2(printData, buildPrint2Payload(options));
985
+ } catch (e) {
986
+ cleanup();
987
+ reject(e);
988
+ }
989
+ });
990
+ }
991
+ onConnectionChange(callback) {
992
+ this.connectionCallbacks.add(callback);
993
+ return () => {
994
+ this.connectionCallbacks.delete(callback);
995
+ };
996
+ }
997
+ onPrintSuccess(callback) {
998
+ this.printSuccessCallbacks.add(callback);
999
+ return () => {
1000
+ this.printSuccessCallbacks.delete(callback);
1001
+ };
1002
+ }
1003
+ onPrintError(callback) {
1004
+ this.printErrorCallbacks.add(callback);
1005
+ return () => {
1006
+ this.printErrorCallbacks.delete(callback);
1007
+ };
1008
+ }
1009
+ updateStatus(status) {
1010
+ this.status = status;
1011
+ this.notifyConnectionChange(status);
1012
+ }
1013
+ notifyConnectionChange(status) {
1014
+ this.connectionCallbacks.forEach((cb) => {
1015
+ try {
1016
+ cb(status);
1017
+ } catch (e) {
1018
+ console.error("[print-designer] connection listener failed", e);
1019
+ }
1020
+ });
1021
+ }
1022
+ notifyPrintSuccess(data) {
1023
+ this.printSuccessCallbacks.forEach((cb) => {
1024
+ try {
1025
+ cb(data);
1026
+ } catch (e) {
1027
+ console.error("[print-designer] printSuccess listener failed", e);
1028
+ }
1029
+ });
1030
+ }
1031
+ notifyPrintError(data) {
1032
+ this.printErrorCallbacks.forEach((cb) => {
1033
+ try {
1034
+ cb(data);
1035
+ } catch (e) {
1036
+ console.error("[print-designer] printError listener failed", e);
1037
+ }
1038
+ });
1039
+ }
1040
+ };
1041
+ _PrintClient.instance = null;
1042
+ let PrintClient = _PrintClient;
1043
+ function getPrintClient() {
1044
+ return PrintClient.getInstance();
1045
+ }
1046
+ export {
1047
+ PrintClient,
1048
+ autoConnect,
1049
+ disAutoConnect,
1050
+ ensureProviders,
1051
+ getPrintClient,
1052
+ hiprint,
1053
+ initHiprint
1054
+ };
1055
+ //# sourceMappingURL=index.mjs.map