@rdlabo/ionic-angular-kit 21.5.40 → 21.6.1
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/fesm2022/rdlabo-ionic-angular-kit-app-update.mjs +7 -11
- package/fesm2022/rdlabo-ionic-angular-kit-app-update.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-social.mjs +31 -44
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase-social.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase.mjs +28 -32
- package/fesm2022/rdlabo-ionic-angular-kit-auth-firebase.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs +408 -319
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs +186 -1
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit.mjs +131 -150
- package/fesm2022/rdlabo-ionic-angular-kit.mjs.map +1 -1
- package/package.json +1 -1
- package/types/rdlabo-ionic-angular-kit-offline.d.ts +12 -9
- package/types/rdlabo-ionic-angular-kit-printer.d.ts +51 -2
|
@@ -204,6 +204,191 @@ const kitBuildLabelPdf = async (params) => {
|
|
|
204
204
|
return pdf.save();
|
|
205
205
|
};
|
|
206
206
|
|
|
207
|
+
const defaultDependencies = () => ({
|
|
208
|
+
document,
|
|
209
|
+
url: URL,
|
|
210
|
+
schedule: (callback, delay) => globalThis.setTimeout(callback, delay),
|
|
211
|
+
});
|
|
212
|
+
const createPdfUrl = (pdfBytes, dependencies) => dependencies.url.createObjectURL(new Blob([Uint8Array.from(pdfBytes).buffer], {
|
|
213
|
+
type: 'application/pdf',
|
|
214
|
+
}));
|
|
215
|
+
const cleanupDelay = (value) => (value !== undefined && Number.isFinite(value) && value >= 0 ? value : 60_000);
|
|
216
|
+
const createCleanup = (pdfUrl, dependencies, resource) => {
|
|
217
|
+
let cleaned = false;
|
|
218
|
+
return () => {
|
|
219
|
+
if (cleaned)
|
|
220
|
+
return;
|
|
221
|
+
cleaned = true;
|
|
222
|
+
try {
|
|
223
|
+
resource?.link?.remove();
|
|
224
|
+
}
|
|
225
|
+
catch {
|
|
226
|
+
// Cleanup is best-effort and must not turn successful PDF output into a failure.
|
|
227
|
+
}
|
|
228
|
+
finally {
|
|
229
|
+
try {
|
|
230
|
+
dependencies.url.revokeObjectURL(pdfUrl);
|
|
231
|
+
}
|
|
232
|
+
catch {
|
|
233
|
+
// Object URL cleanup is best-effort for the same reason.
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
};
|
|
237
|
+
};
|
|
238
|
+
const prepareDownloadLink = (resource, pdfUrl, filename, dependencies) => {
|
|
239
|
+
const link = dependencies.document.createElement('a');
|
|
240
|
+
resource.link = link;
|
|
241
|
+
link.href = pdfUrl;
|
|
242
|
+
link.download = filename;
|
|
243
|
+
link.style.display = 'none';
|
|
244
|
+
dependencies.document.body.appendChild(link);
|
|
245
|
+
return link;
|
|
246
|
+
};
|
|
247
|
+
const openPreviewWindow = (resource, options, dependencies) => {
|
|
248
|
+
const target = dependencies.document.defaultView?.open('', '_blank') ?? null;
|
|
249
|
+
resource.target = target;
|
|
250
|
+
if (!target)
|
|
251
|
+
return null;
|
|
252
|
+
target.opener = null;
|
|
253
|
+
target.document.title = options.title;
|
|
254
|
+
target.document.body.textContent = options.pendingText;
|
|
255
|
+
return target;
|
|
256
|
+
};
|
|
257
|
+
const scheduleCleanup = (cleanup, delay, dependencies) => {
|
|
258
|
+
try {
|
|
259
|
+
dependencies.schedule(cleanup, delay);
|
|
260
|
+
return true;
|
|
261
|
+
}
|
|
262
|
+
catch {
|
|
263
|
+
try {
|
|
264
|
+
globalThis.setTimeout(cleanup, delay);
|
|
265
|
+
return true;
|
|
266
|
+
}
|
|
267
|
+
catch {
|
|
268
|
+
return false;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
};
|
|
272
|
+
const isWindowClosed = (target) => {
|
|
273
|
+
try {
|
|
274
|
+
return target.closed;
|
|
275
|
+
}
|
|
276
|
+
catch {
|
|
277
|
+
return true;
|
|
278
|
+
}
|
|
279
|
+
};
|
|
280
|
+
const closeWindow = (target) => {
|
|
281
|
+
try {
|
|
282
|
+
if (target && !target.closed)
|
|
283
|
+
target.close();
|
|
284
|
+
}
|
|
285
|
+
catch {
|
|
286
|
+
// Closing a placeholder is best-effort and must never replace the original output error.
|
|
287
|
+
}
|
|
288
|
+
};
|
|
289
|
+
/**
|
|
290
|
+
* Download generated PDF bytes without navigating the current application page.
|
|
291
|
+
*
|
|
292
|
+
* @remarks Browser-only. Do not call during server-side rendering.
|
|
293
|
+
*
|
|
294
|
+
* The temporary anchor and object URL stay alive long enough for browsers to start the download.
|
|
295
|
+
* Cleanup is registered before clicking so a cleanup scheduling error cannot be mistaken for a PDF
|
|
296
|
+
* generation failure after the download has already started.
|
|
297
|
+
*/
|
|
298
|
+
const kitDownloadPdf = (pdfBytes, options) => {
|
|
299
|
+
const dependencies = options.dependencies ?? defaultDependencies();
|
|
300
|
+
const pdfUrl = createPdfUrl(pdfBytes, dependencies);
|
|
301
|
+
const resource = {};
|
|
302
|
+
const cleanup = createCleanup(pdfUrl, dependencies, resource);
|
|
303
|
+
let link;
|
|
304
|
+
try {
|
|
305
|
+
link = prepareDownloadLink(resource, pdfUrl, options.filename, dependencies);
|
|
306
|
+
}
|
|
307
|
+
catch (error) {
|
|
308
|
+
cleanup();
|
|
309
|
+
throw error;
|
|
310
|
+
}
|
|
311
|
+
const cleanupScheduled = scheduleCleanup(cleanup, cleanupDelay(options.cleanupDelayMs), dependencies);
|
|
312
|
+
try {
|
|
313
|
+
link.click();
|
|
314
|
+
}
|
|
315
|
+
catch (error) {
|
|
316
|
+
cleanup();
|
|
317
|
+
throw error;
|
|
318
|
+
}
|
|
319
|
+
finally {
|
|
320
|
+
if (!cleanupScheduled)
|
|
321
|
+
cleanup();
|
|
322
|
+
}
|
|
323
|
+
};
|
|
324
|
+
/**
|
|
325
|
+
* Open a placeholder window synchronously for an asynchronously generated PDF.
|
|
326
|
+
*
|
|
327
|
+
* Call this directly from the user's click handler, before awaiting PDF generation, to avoid popup
|
|
328
|
+
* blocking. If the preview cannot be opened or is closed while generating, showing the PDF safely
|
|
329
|
+
* falls back to a file download and keeps the current application page in place.
|
|
330
|
+
*/
|
|
331
|
+
const preparePdfPreview = (options) => {
|
|
332
|
+
const dependencies = options.dependencies ?? defaultDependencies();
|
|
333
|
+
const resource = { target: null };
|
|
334
|
+
try {
|
|
335
|
+
openPreviewWindow(resource, options, dependencies);
|
|
336
|
+
}
|
|
337
|
+
catch {
|
|
338
|
+
closeWindow(resource.target);
|
|
339
|
+
resource.target = null;
|
|
340
|
+
}
|
|
341
|
+
return {
|
|
342
|
+
show: (pdfBytes) => {
|
|
343
|
+
const target = resource.target;
|
|
344
|
+
if (!target || isWindowClosed(target)) {
|
|
345
|
+
kitDownloadPdf(pdfBytes, {
|
|
346
|
+
filename: options.fallbackFilename,
|
|
347
|
+
cleanupDelayMs: options.cleanupDelayMs,
|
|
348
|
+
dependencies,
|
|
349
|
+
});
|
|
350
|
+
return;
|
|
351
|
+
}
|
|
352
|
+
const pdfUrl = createPdfUrl(pdfBytes, dependencies);
|
|
353
|
+
const cleanup = createCleanup(pdfUrl, dependencies);
|
|
354
|
+
const cleanupScheduled = scheduleCleanup(cleanup, cleanupDelay(options.cleanupDelayMs), dependencies);
|
|
355
|
+
try {
|
|
356
|
+
target.location.replace(pdfUrl);
|
|
357
|
+
}
|
|
358
|
+
catch {
|
|
359
|
+
cleanup();
|
|
360
|
+
closeWindow(target);
|
|
361
|
+
kitDownloadPdf(pdfBytes, {
|
|
362
|
+
filename: options.fallbackFilename,
|
|
363
|
+
cleanupDelayMs: options.cleanupDelayMs,
|
|
364
|
+
dependencies,
|
|
365
|
+
});
|
|
366
|
+
return;
|
|
367
|
+
}
|
|
368
|
+
finally {
|
|
369
|
+
if (!cleanupScheduled)
|
|
370
|
+
cleanup();
|
|
371
|
+
}
|
|
372
|
+
},
|
|
373
|
+
close: () => closeWindow(resource.target),
|
|
374
|
+
};
|
|
375
|
+
};
|
|
376
|
+
/**
|
|
377
|
+
* Preview an asynchronously generated PDF without risking a popup-blocked result.
|
|
378
|
+
*
|
|
379
|
+
* This function opens its placeholder window synchronously, before invoking `buildPdf`. Call it
|
|
380
|
+
* directly from the user's click handler and pass PDF generation as the callback. Generation errors
|
|
381
|
+
* close the placeholder and are rethrown for the application to present with its own UI.
|
|
382
|
+
*/
|
|
383
|
+
const kitPreviewGeneratedPdf = async (buildPdf, options) => {
|
|
384
|
+
const preview = preparePdfPreview(options);
|
|
385
|
+
const buildAndShow = async () => preview.show(await buildPdf());
|
|
386
|
+
await buildAndShow().catch((error) => {
|
|
387
|
+
preview.close();
|
|
388
|
+
throw error;
|
|
389
|
+
});
|
|
390
|
+
};
|
|
391
|
+
|
|
207
392
|
// Printer: Brother label plumbing (DOM→PNG, rotation, print-settings assembly).
|
|
208
393
|
// Split into its own entry point so only apps that print pull in `@rdlabo/capacitor-brotherprint`
|
|
209
394
|
// and `dom-to-image-more`; the core entry stays free of those native peers.
|
|
@@ -212,5 +397,5 @@ const kitBuildLabelPdf = async (params) => {
|
|
|
212
397
|
* Generated bundle index. Do not edit.
|
|
213
398
|
*/
|
|
214
399
|
|
|
215
|
-
export { kitBuildBrotherPrintSettings, kitBuildLabelPdf, kitCalculatePrintLayout, kitDomToPng, kitPrintPaperSizes, kitRotationImage };
|
|
400
|
+
export { kitBuildBrotherPrintSettings, kitBuildLabelPdf, kitCalculatePrintLayout, kitDomToPng, kitDownloadPdf, kitPreviewGeneratedPdf, kitPrintPaperSizes, kitRotationImage };
|
|
216
401
|
//# sourceMappingURL=rdlabo-ionic-angular-kit-printer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rdlabo-ionic-angular-kit-printer.mjs","sources":["../../../projects/kit/printer/src/kit-printer.ts","../../../projects/kit/printer/src/kit-pdf-printer.ts","../../../projects/kit/printer/src/public-api.ts","../../../projects/kit/printer/src/rdlabo-ionic-angular-kit-printer.ts"],"sourcesContent":["import { Capacitor } from '@capacitor/core';\nimport type { BRLMPrinterLabelName, BRLMPrinterModelName, BRLMPrintOptions } from '@rdlabo/capacitor-brotherprint';\nimport {\n BRLMPrinterCustomPaperType,\n BRLMPrinterCustomPaperUnit,\n BRLMPrinterHalftone,\n BRLMPrinterHorizontalAlignment,\n BRLMPrinterImageRotation,\n BRLMPrinterPrintQuality,\n BRLMPrinterScaleMode,\n BRLMPrinterVerticalAlignment,\n} from '@rdlabo/capacitor-brotherprint';\nimport domtoimage from 'dom-to-image-more';\n\n/**\n * Rotate a base64 image 90°, returning a new base64 data URL of the same MIME type.\n *\n * @remarks\n * Pure DOM/canvas work — no DI. Used before sending a label to the printer when the artwork must be\n * turned to match the tape orientation. Extracted verbatim from the fleet's printer services so the\n * canvas handling lives in one place.\n *\n * @param imageData - a base64 data URL (e.g. `data:image/png;base64,...`)\n * @returns a Promise resolving to the rotated image as a base64 data URL\n */\nexport const kitRotationImage = async (imageData: string): Promise<string> => {\n const imgType = imageData.substring(5, imageData.indexOf(';'));\n\n const image = new Image();\n const loaded = new Promise<void>((resolve) => {\n image.onload = () => resolve();\n });\n image.src = imageData;\n await loaded;\n\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n\n canvas.width = image.height;\n canvas.height = image.width;\n\n ctx!.rotate((90 * Math.PI) / 180);\n ctx!.translate(0, -image.height);\n ctx!.drawImage(image, 0, 0, image.width, image.height);\n\n return canvas.toDataURL(imgType);\n};\n\n/** Options for {@link kitDomToPng}. */\nexport interface KitDomToPngOptions {\n /** When `true`, the rendered PNG is rotated 90° via {@link kitRotationImage}. Defaults to `false`. */\n readonly rotate?: boolean;\n /** Rendering scale passed to `dom-to-image-more`. Defaults to `3` (the fleet's print resolution). */\n readonly scale?: number;\n}\n\n/**\n * Render a DOM element to a base64 PNG for label printing, with the fleet's device-specific fixes.\n *\n * @remarks\n * Pure function — no DI (reads the platform from `Capacitor`, uses the global `document`), so the\n * caller presents its own loading UI around it. Centralizes the hard-won device quirks: on iOS it\n * pads width/height by 2px (otherwise the bottom is clipped), on Android it does not (the padding\n * introduces a black line). Retries the `dom-to-image-more` render up to 10 times because the first\n * pass can occasionally return empty. This is exactly the kind of plumbing where a future fix should\n * land in every app at once.\n *\n * @param element - the element to rasterize (e.g. the label preview host)\n * @param options - rendering options; see {@link KitDomToPngOptions}\n * @returns a Promise resolving to the PNG as a base64 data URL (empty string if every attempt failed)\n * @example\n * ```ts\n * const loading = await this.#loadingCtrl.create({ message: this.text.generating });\n * await loading.present();\n * const png = await kitDomToPng(this.preview().nativeElement, { rotate: true });\n * await loading.dismiss();\n * ```\n */\nexport const kitDomToPng = async (element: HTMLElement, options?: KitDomToPngOptions): Promise<string> => {\n await new Promise((resolve) => requestAnimationFrame(resolve));\n\n const { clientHeight, clientWidth } = element;\n\n // デバイス毎の問題解決のため、px 調整。\n // iOS: ないと下が途切れる。Android: あると黒線が入る。\n const addClient = Capacitor.getPlatform() === 'ios' ? 2 : 0;\n\n let dataUrl = '';\n for (let i = 0; i < 10; i++) {\n const url = await domtoimage.toPng(element, {\n width: clientWidth + addClient,\n height: clientHeight + addClient,\n scale: options?.scale ?? 3,\n copyDefaultStyles: false,\n });\n if (url) {\n dataUrl = url;\n break;\n }\n }\n\n return options?.rotate ? kitRotationImage(dataUrl) : dataUrl;\n};\n\n/** Parameters for {@link kitBuildBrotherPrintSettings}. */\nexport interface KitBrotherPrintSettingsParams {\n /** The target printer model. */\n readonly modelName: BRLMPrinterModelName;\n /** The label artwork as a base64 data URL (the `data:...,` prefix is stripped internally). */\n readonly printBase64: string;\n /** The selected label/paper (its `W<width>H<height>` code drives the tape dimensions). */\n readonly label: BRLMPrinterLabelName;\n /** Number of copies to print. Passed by the caller (apps differ: some use the print option, some fix 1). */\n readonly numberOfCopies: number;\n /** Halftone threshold for the print. */\n readonly halftoneThreshold: number;\n}\n\n/**\n * Assemble the Brother `BRLMPrintOptions` for a die-cut label print, minus the transport fields.\n *\n * @remarks\n * Pure function — no DI. Centralizes the fleet's canonical print settings (fit-page scale, centered,\n * best quality, threshold halftone, 2mm/1mm margins, `gapLength` 2.0) and the tape sizing derived\n * from the label's `W<width>H<height>` code. The caller merges the printer's `port` / `channelInfo`\n * onto the result before calling `BrotherPrint.printImage()`, so channel selection and loading UI stay\n * in the app.\n *\n * @param params - model, artwork, label, copies, and halftone threshold; see {@link KitBrotherPrintSettingsParams}\n * @returns the `BRLMPrintOptions` ready to be spread with `{ port, channelInfo }`\n * @example\n * ```ts\n * const settings = kitBuildBrotherPrintSettings({\n * modelName, printBase64, label, numberOfCopies: printOptions.printNum, halftoneThreshold: printOptions.halftoneThreshold,\n * });\n * await BrotherPrint.printImage({ ...settings, port: channel.port, channelInfo: channel.channelInfo });\n * ```\n */\nexport const kitBuildBrotherPrintSettings = (params: KitBrotherPrintSettingsParams): BRLMPrintOptions => {\n const startPoint = params.printBase64.indexOf(',');\n const tapeSize = params.label.match(/W(\\d+)H(\\d+)/);\n const tapeWidth = tapeSize && tapeSize.length >= 2 ? parseInt(tapeSize[1], 10) : 0;\n const tapeLength = tapeSize && tapeSize.length >= 3 ? parseInt(tapeSize[2], 10) : 0;\n\n // `BRLMPrintOptions` is a `QL | TD` union; a die-cut label legitimately carries fields from both\n // groups, so the object is composed via spreads to bypass the union's excess-property checks — the\n // same technique the source printer services used.\n return {\n ...{\n modelName: params.modelName,\n encodedImage: params.printBase64.slice(startPoint + 1),\n numberOfCopies: params.numberOfCopies,\n autoCut: true,\n\n scaleMode: BRLMPrinterScaleMode.FitPageAspect,\n imageRotation: BRLMPrinterImageRotation.Rotate0,\n verticalAlignment: BRLMPrinterVerticalAlignment.Center,\n horizontalAlignment: BRLMPrinterHorizontalAlignment.Center,\n printQuality: BRLMPrinterPrintQuality.Best,\n },\n ...{\n labelName: params.label,\n },\n ...{\n paperType: BRLMPrinterCustomPaperType.dieCutPaper,\n paperUnit: BRLMPrinterCustomPaperUnit.mm,\n halftone: BRLMPrinterHalftone.Threshold,\n halftoneThreshold: params.halftoneThreshold,\n tapeWidth: Number(tapeWidth.toFixed(1)),\n tapeLength: Number(tapeLength.toFixed(1)),\n gapLength: 2.0,\n\n marginTop: 1.0,\n marginRight: 2.0,\n marginBottom: 1.0,\n marginLeft: 2.0,\n\n paperMarkPosition: 0,\n paperMarkLength: 0,\n },\n };\n};\n","import { PDFDocument } from 'pdf-lib';\n\n/** Physical paper dimensions used to build a PDF page. */\nexport interface KitPrintPaper {\n /** Human-readable paper name. */\n readonly label: string;\n /** Paper width in millimetres. */\n readonly widthMm: number;\n /** Paper height in millimetres. */\n readonly heightMm: number;\n}\n\n/** Standard paper presets shared by the printing applications. */\nexport const kitPrintPaperSizes = {\n a4: { label: 'A4', widthMm: 210, heightMm: 297 },\n b5: { label: 'B5', widthMm: 182, heightMm: 257 },\n} as const satisfies Record<string, KitPrintPaper>;\n\n/** A position for one label on a PDF page, expressed in PDF points. */\nexport interface KitPrintPosition {\n readonly pageIndex: number;\n readonly x: number;\n readonly y: number;\n}\n\n/** Calculated PDF page and label dimensions. */\nexport interface KitPrintLayout {\n readonly paperWidth: number;\n readonly paperHeight: number;\n readonly labelWidth: number;\n readonly labelHeight: number;\n readonly positions: readonly KitPrintPosition[];\n}\n\n/** Optional physical size override for a label. */\nexport interface KitPrintMeasure {\n readonly type: 'width' | 'height';\n readonly sizeMm: number;\n}\n\n/** Parameters for {@link kitCalculatePrintLayout}. */\nexport interface KitCalculatePrintLayoutParams {\n readonly paper: KitPrintPaper;\n readonly labelWidthPx: number;\n readonly labelHeightPx: number;\n readonly copies: number;\n readonly measure?: KitPrintMeasure | null;\n /** Outer page margin in millimetres. Defaults to 5mm. */\n readonly marginMm?: number;\n}\n\n/**\n * Calculate page dimensions and row-major label positions for a printable PDF.\n *\n * Labels keep their aspect ratio, are never enlarged beyond their requested pixel/physical size,\n * and automatically continue on additional pages when the current page is full.\n */\nexport const kitCalculatePrintLayout = (params: KitCalculatePrintLayoutParams): KitPrintLayout => {\n const pointsPerMm = 72 / 25.4;\n const pointsPerPixel = 72 / 96;\n const paperWidth = params.paper.widthMm * pointsPerMm;\n const paperHeight = params.paper.heightMm * pointsPerMm;\n const margin = (params.marginMm ?? 5) * pointsPerMm;\n const aspect = params.labelWidthPx / params.labelHeightPx;\n let labelWidth = params.labelWidthPx * pointsPerPixel;\n let labelHeight = params.labelHeightPx * pointsPerPixel;\n\n if (params.measure?.type === 'width') {\n labelWidth = params.measure.sizeMm * pointsPerMm;\n labelHeight = labelWidth / aspect;\n } else if (params.measure?.type === 'height') {\n labelHeight = params.measure.sizeMm * pointsPerMm;\n labelWidth = labelHeight * aspect;\n }\n\n const scale = Math.min(1, (paperWidth - margin * 2) / labelWidth, (paperHeight - margin * 2) / labelHeight);\n labelWidth *= scale;\n labelHeight *= scale;\n\n const positions: KitPrintPosition[] = [];\n let pageIndex = 0;\n let x = margin;\n let y = paperHeight - margin;\n for (let index = 0; index < Math.max(0, params.copies); index++) {\n if (x + labelWidth > paperWidth - margin + 0.01) {\n x = margin;\n y -= labelHeight;\n }\n if (y - labelHeight < margin - 0.01) {\n pageIndex++;\n x = margin;\n y = paperHeight - margin;\n }\n positions.push({ pageIndex, x, y: y - labelHeight });\n x += labelWidth;\n }\n\n return { paperWidth, paperHeight, labelWidth, labelHeight, positions };\n};\n\n/** Parameters for {@link kitBuildLabelPdf}. */\nexport interface KitBuildLabelPdfParams extends KitCalculatePrintLayoutParams {\n /** PNG label artwork as a data URL or base64 string accepted by pdf-lib. */\n readonly imageData: string;\n}\n\n/** Build a multi-page label PDF and return its bytes without choosing an output destination. */\nexport const kitBuildLabelPdf = async (params: KitBuildLabelPdfParams): Promise<Uint8Array> => {\n const pdf = await PDFDocument.create();\n const image = await pdf.embedPng(params.imageData);\n const layout = kitCalculatePrintLayout(params);\n const pages = layout.positions.length > 0 ? [pdf.addPage([layout.paperWidth, layout.paperHeight])] : [];\n\n for (const position of layout.positions) {\n while (pages.length <= position.pageIndex) pages.push(pdf.addPage([layout.paperWidth, layout.paperHeight]));\n pages[position.pageIndex].drawImage(image, {\n x: position.x,\n y: position.y,\n width: layout.labelWidth,\n height: layout.labelHeight,\n });\n }\n\n return pdf.save();\n};\n","// Printer: Brother label plumbing (DOM→PNG, rotation, print-settings assembly).\n// Split into its own entry point so only apps that print pull in `@rdlabo/capacitor-brotherprint`\n// and `dom-to-image-more`; the core entry stays free of those native peers.\nexport * from './kit-printer';\nexport * from './kit-pdf-printer';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAcA;;;;;;;;;;AAUG;MACU,gBAAgB,GAAG,OAAO,SAAiB,KAAqB;AAC3E,IAAA,MAAM,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAE9D,IAAA,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE;IACzB,MAAM,MAAM,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,KAAI;QAC3C,KAAK,CAAC,MAAM,GAAG,MAAM,OAAO,EAAE;AAChC,IAAA,CAAC,CAAC;AACF,IAAA,KAAK,CAAC,GAAG,GAAG,SAAS;AACrB,IAAA,MAAM,MAAM;IAEZ,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;AAEnC,IAAA,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM;AAC3B,IAAA,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK;AAE3B,IAAA,GAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,GAAG,CAAC;IACjC,GAAI,CAAC,SAAS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AC,MAAM,CAAC,SAAS,CAAC;AAClD,IAAA,MAAM,MAAM,GAAG,uBAAuB,CAAC,MAAM,CAAC;AAC9C,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE;AAEvG,IAAA,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE;AACvC,QAAA,OAAO,KAAK,CAAC,MAAM,IAAI,QAAQ,CAAC,SAAS;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;QAC3G,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE;YACzC,CAAC,EAAE,QAAQ,CAAC,CAAC;YACb,CAAC,EAAE,QAAQ,CAAC,CAAC;YACb,KAAK,EAAE,MAAM,CAAC,UAAU;YACxB,MAAM,EAAE,MAAM,CAAC,WAAW;AAC3B,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,GAAG,CAAC,IAAI,EAAE;AACnB;;AC5HA;AACA;AACA;;ACFA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"rdlabo-ionic-angular-kit-printer.mjs","sources":["../../../projects/kit/printer/src/kit-printer.ts","../../../projects/kit/printer/src/kit-pdf-printer.ts","../../../projects/kit/printer/src/kit-browser-pdf.ts","../../../projects/kit/printer/src/public-api.ts","../../../projects/kit/printer/src/rdlabo-ionic-angular-kit-printer.ts"],"sourcesContent":["import { Capacitor } from '@capacitor/core';\nimport type { BRLMPrinterLabelName, BRLMPrinterModelName, BRLMPrintOptions } from '@rdlabo/capacitor-brotherprint';\nimport {\n BRLMPrinterCustomPaperType,\n BRLMPrinterCustomPaperUnit,\n BRLMPrinterHalftone,\n BRLMPrinterHorizontalAlignment,\n BRLMPrinterImageRotation,\n BRLMPrinterPrintQuality,\n BRLMPrinterScaleMode,\n BRLMPrinterVerticalAlignment,\n} from '@rdlabo/capacitor-brotherprint';\nimport domtoimage from 'dom-to-image-more';\n\n/**\n * Rotate a base64 image 90°, returning a new base64 data URL of the same MIME type.\n *\n * @remarks\n * Pure DOM/canvas work — no DI. Used before sending a label to the printer when the artwork must be\n * turned to match the tape orientation. Extracted verbatim from the fleet's printer services so the\n * canvas handling lives in one place.\n *\n * @param imageData - a base64 data URL (e.g. `data:image/png;base64,...`)\n * @returns a Promise resolving to the rotated image as a base64 data URL\n */\nexport const kitRotationImage = async (imageData: string): Promise<string> => {\n const imgType = imageData.substring(5, imageData.indexOf(';'));\n\n const image = new Image();\n const loaded = new Promise<void>((resolve) => {\n image.onload = () => resolve();\n });\n image.src = imageData;\n await loaded;\n\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n\n canvas.width = image.height;\n canvas.height = image.width;\n\n ctx!.rotate((90 * Math.PI) / 180);\n ctx!.translate(0, -image.height);\n ctx!.drawImage(image, 0, 0, image.width, image.height);\n\n return canvas.toDataURL(imgType);\n};\n\n/** Options for {@link kitDomToPng}. */\nexport interface KitDomToPngOptions {\n /** When `true`, the rendered PNG is rotated 90° via {@link kitRotationImage}. Defaults to `false`. */\n readonly rotate?: boolean;\n /** Rendering scale passed to `dom-to-image-more`. Defaults to `3` (the fleet's print resolution). */\n readonly scale?: number;\n}\n\n/**\n * Render a DOM element to a base64 PNG for label printing, with the fleet's device-specific fixes.\n *\n * @remarks\n * Pure function — no DI (reads the platform from `Capacitor`, uses the global `document`), so the\n * caller presents its own loading UI around it. Centralizes the hard-won device quirks: on iOS it\n * pads width/height by 2px (otherwise the bottom is clipped), on Android it does not (the padding\n * introduces a black line). Retries the `dom-to-image-more` render up to 10 times because the first\n * pass can occasionally return empty. This is exactly the kind of plumbing where a future fix should\n * land in every app at once.\n *\n * @param element - the element to rasterize (e.g. the label preview host)\n * @param options - rendering options; see {@link KitDomToPngOptions}\n * @returns a Promise resolving to the PNG as a base64 data URL (empty string if every attempt failed)\n * @example\n * ```ts\n * const loading = await this.#loadingCtrl.create({ message: this.text.generating });\n * await loading.present();\n * const png = await kitDomToPng(this.preview().nativeElement, { rotate: true });\n * await loading.dismiss();\n * ```\n */\nexport const kitDomToPng = async (element: HTMLElement, options?: KitDomToPngOptions): Promise<string> => {\n await new Promise((resolve) => requestAnimationFrame(resolve));\n\n const { clientHeight, clientWidth } = element;\n\n // デバイス毎の問題解決のため、px 調整。\n // iOS: ないと下が途切れる。Android: あると黒線が入る。\n const addClient = Capacitor.getPlatform() === 'ios' ? 2 : 0;\n\n let dataUrl = '';\n for (let i = 0; i < 10; i++) {\n const url = await domtoimage.toPng(element, {\n width: clientWidth + addClient,\n height: clientHeight + addClient,\n scale: options?.scale ?? 3,\n copyDefaultStyles: false,\n });\n if (url) {\n dataUrl = url;\n break;\n }\n }\n\n return options?.rotate ? kitRotationImage(dataUrl) : dataUrl;\n};\n\n/** Parameters for {@link kitBuildBrotherPrintSettings}. */\nexport interface KitBrotherPrintSettingsParams {\n /** The target printer model. */\n readonly modelName: BRLMPrinterModelName;\n /** The label artwork as a base64 data URL (the `data:...,` prefix is stripped internally). */\n readonly printBase64: string;\n /** The selected label/paper (its `W<width>H<height>` code drives the tape dimensions). */\n readonly label: BRLMPrinterLabelName;\n /** Number of copies to print. Passed by the caller (apps differ: some use the print option, some fix 1). */\n readonly numberOfCopies: number;\n /** Halftone threshold for the print. */\n readonly halftoneThreshold: number;\n}\n\n/**\n * Assemble the Brother `BRLMPrintOptions` for a die-cut label print, minus the transport fields.\n *\n * @remarks\n * Pure function — no DI. Centralizes the fleet's canonical print settings (fit-page scale, centered,\n * best quality, threshold halftone, 2mm/1mm margins, `gapLength` 2.0) and the tape sizing derived\n * from the label's `W<width>H<height>` code. The caller merges the printer's `port` / `channelInfo`\n * onto the result before calling `BrotherPrint.printImage()`, so channel selection and loading UI stay\n * in the app.\n *\n * @param params - model, artwork, label, copies, and halftone threshold; see {@link KitBrotherPrintSettingsParams}\n * @returns the `BRLMPrintOptions` ready to be spread with `{ port, channelInfo }`\n * @example\n * ```ts\n * const settings = kitBuildBrotherPrintSettings({\n * modelName, printBase64, label, numberOfCopies: printOptions.printNum, halftoneThreshold: printOptions.halftoneThreshold,\n * });\n * await BrotherPrint.printImage({ ...settings, port: channel.port, channelInfo: channel.channelInfo });\n * ```\n */\nexport const kitBuildBrotherPrintSettings = (params: KitBrotherPrintSettingsParams): BRLMPrintOptions => {\n const startPoint = params.printBase64.indexOf(',');\n const tapeSize = params.label.match(/W(\\d+)H(\\d+)/);\n const tapeWidth = tapeSize && tapeSize.length >= 2 ? parseInt(tapeSize[1], 10) : 0;\n const tapeLength = tapeSize && tapeSize.length >= 3 ? parseInt(tapeSize[2], 10) : 0;\n\n // `BRLMPrintOptions` is a `QL | TD` union; a die-cut label legitimately carries fields from both\n // groups, so the object is composed via spreads to bypass the union's excess-property checks — the\n // same technique the source printer services used.\n return {\n ...{\n modelName: params.modelName,\n encodedImage: params.printBase64.slice(startPoint + 1),\n numberOfCopies: params.numberOfCopies,\n autoCut: true,\n\n scaleMode: BRLMPrinterScaleMode.FitPageAspect,\n imageRotation: BRLMPrinterImageRotation.Rotate0,\n verticalAlignment: BRLMPrinterVerticalAlignment.Center,\n horizontalAlignment: BRLMPrinterHorizontalAlignment.Center,\n printQuality: BRLMPrinterPrintQuality.Best,\n },\n ...{\n labelName: params.label,\n },\n ...{\n paperType: BRLMPrinterCustomPaperType.dieCutPaper,\n paperUnit: BRLMPrinterCustomPaperUnit.mm,\n halftone: BRLMPrinterHalftone.Threshold,\n halftoneThreshold: params.halftoneThreshold,\n tapeWidth: Number(tapeWidth.toFixed(1)),\n tapeLength: Number(tapeLength.toFixed(1)),\n gapLength: 2.0,\n\n marginTop: 1.0,\n marginRight: 2.0,\n marginBottom: 1.0,\n marginLeft: 2.0,\n\n paperMarkPosition: 0,\n paperMarkLength: 0,\n },\n };\n};\n","import { PDFDocument } from 'pdf-lib';\n\n/** Physical paper dimensions used to build a PDF page. */\nexport interface KitPrintPaper {\n /** Human-readable paper name. */\n readonly label: string;\n /** Paper width in millimetres. */\n readonly widthMm: number;\n /** Paper height in millimetres. */\n readonly heightMm: number;\n}\n\n/** Standard paper presets shared by the printing applications. */\nexport const kitPrintPaperSizes = {\n a4: { label: 'A4', widthMm: 210, heightMm: 297 },\n b5: { label: 'B5', widthMm: 182, heightMm: 257 },\n} as const satisfies Record<string, KitPrintPaper>;\n\n/** A position for one label on a PDF page, expressed in PDF points. */\nexport interface KitPrintPosition {\n readonly pageIndex: number;\n readonly x: number;\n readonly y: number;\n}\n\n/** Calculated PDF page and label dimensions. */\nexport interface KitPrintLayout {\n readonly paperWidth: number;\n readonly paperHeight: number;\n readonly labelWidth: number;\n readonly labelHeight: number;\n readonly positions: readonly KitPrintPosition[];\n}\n\n/** Optional physical size override for a label. */\nexport interface KitPrintMeasure {\n readonly type: 'width' | 'height';\n readonly sizeMm: number;\n}\n\n/** Parameters for {@link kitCalculatePrintLayout}. */\nexport interface KitCalculatePrintLayoutParams {\n readonly paper: KitPrintPaper;\n readonly labelWidthPx: number;\n readonly labelHeightPx: number;\n readonly copies: number;\n readonly measure?: KitPrintMeasure | null;\n /** Outer page margin in millimetres. Defaults to 5mm. */\n readonly marginMm?: number;\n}\n\n/**\n * Calculate page dimensions and row-major label positions for a printable PDF.\n *\n * Labels keep their aspect ratio, are never enlarged beyond their requested pixel/physical size,\n * and automatically continue on additional pages when the current page is full.\n */\nexport const kitCalculatePrintLayout = (params: KitCalculatePrintLayoutParams): KitPrintLayout => {\n const pointsPerMm = 72 / 25.4;\n const pointsPerPixel = 72 / 96;\n const paperWidth = params.paper.widthMm * pointsPerMm;\n const paperHeight = params.paper.heightMm * pointsPerMm;\n const margin = (params.marginMm ?? 5) * pointsPerMm;\n const aspect = params.labelWidthPx / params.labelHeightPx;\n let labelWidth = params.labelWidthPx * pointsPerPixel;\n let labelHeight = params.labelHeightPx * pointsPerPixel;\n\n if (params.measure?.type === 'width') {\n labelWidth = params.measure.sizeMm * pointsPerMm;\n labelHeight = labelWidth / aspect;\n } else if (params.measure?.type === 'height') {\n labelHeight = params.measure.sizeMm * pointsPerMm;\n labelWidth = labelHeight * aspect;\n }\n\n const scale = Math.min(1, (paperWidth - margin * 2) / labelWidth, (paperHeight - margin * 2) / labelHeight);\n labelWidth *= scale;\n labelHeight *= scale;\n\n const positions: KitPrintPosition[] = [];\n let pageIndex = 0;\n let x = margin;\n let y = paperHeight - margin;\n for (let index = 0; index < Math.max(0, params.copies); index++) {\n if (x + labelWidth > paperWidth - margin + 0.01) {\n x = margin;\n y -= labelHeight;\n }\n if (y - labelHeight < margin - 0.01) {\n pageIndex++;\n x = margin;\n y = paperHeight - margin;\n }\n positions.push({ pageIndex, x, y: y - labelHeight });\n x += labelWidth;\n }\n\n return { paperWidth, paperHeight, labelWidth, labelHeight, positions };\n};\n\n/** Parameters for {@link kitBuildLabelPdf}. */\nexport interface KitBuildLabelPdfParams extends KitCalculatePrintLayoutParams {\n /** PNG label artwork as a data URL or base64 string accepted by pdf-lib. */\n readonly imageData: string;\n}\n\n/** Build a multi-page label PDF and return its bytes without choosing an output destination. */\nexport const kitBuildLabelPdf = async (params: KitBuildLabelPdfParams): Promise<Uint8Array> => {\n const pdf = await PDFDocument.create();\n const image = await pdf.embedPng(params.imageData);\n const layout = kitCalculatePrintLayout(params);\n const pages = layout.positions.length > 0 ? [pdf.addPage([layout.paperWidth, layout.paperHeight])] : [];\n\n for (const position of layout.positions) {\n while (pages.length <= position.pageIndex) pages.push(pdf.addPage([layout.paperWidth, layout.paperHeight]));\n pages[position.pageIndex].drawImage(image, {\n x: position.x,\n y: position.y,\n width: layout.labelWidth,\n height: layout.labelHeight,\n });\n }\n\n return pdf.save();\n};\n","/** Browser dependencies used by the PDF output helpers. */\nexport interface KitBrowserPdfDependencies {\n /** Document used to create download links and preview windows. */\n readonly document: Pick<Document, 'body' | 'createElement' | 'defaultView'>;\n /** Object URL implementation used for generated PDF blobs. */\n readonly url: Pick<typeof URL, 'createObjectURL' | 'revokeObjectURL'>;\n /** Scheduler used to delay DOM and object URL cleanup. */\n readonly schedule: (callback: () => void, delay: number) => unknown;\n}\n\n/** Options shared by browser PDF output helpers. */\nexport interface KitBrowserPdfOutputOptions {\n /** Delay before temporary resources are released. Invalid values fall back to 60 seconds. */\n readonly cleanupDelayMs?: number;\n /** Browser dependencies. Override in tests; production callers normally omit this. */\n readonly dependencies?: KitBrowserPdfDependencies;\n}\n\n/** Options for {@link kitDownloadPdf}. */\nexport interface KitDownloadPdfOptions extends KitBrowserPdfOutputOptions {\n /** Filename presented by the browser download. */\n readonly filename: string;\n}\n\n/** Options for {@link kitPreviewGeneratedPdf}. */\nexport interface KitPreviewGeneratedPdfOptions extends KitBrowserPdfOutputOptions {\n /** Title shown while the PDF is being generated. */\n readonly title: string;\n /** Text shown while the PDF is being generated. */\n readonly pendingText: string;\n /** Filename used when a preview window cannot be opened or has been closed. */\n readonly fallbackFilename: string;\n}\n\ninterface PdfPreview {\n readonly show: (pdfBytes: Uint8Array) => void;\n readonly close: () => void;\n}\n\ninterface DownloadResource {\n link?: HTMLAnchorElement;\n}\n\ninterface PreviewResource {\n target: Window | null;\n}\n\nconst defaultDependencies = (): KitBrowserPdfDependencies => ({\n document,\n url: URL,\n schedule: (callback, delay) => globalThis.setTimeout(callback, delay),\n});\n\nconst createPdfUrl = (pdfBytes: Uint8Array, dependencies: KitBrowserPdfDependencies): string =>\n dependencies.url.createObjectURL(\n new Blob([Uint8Array.from(pdfBytes).buffer], {\n type: 'application/pdf',\n }),\n );\n\nconst cleanupDelay = (value: number | undefined): number => (value !== undefined && Number.isFinite(value) && value >= 0 ? value : 60_000);\n\nconst createCleanup = (pdfUrl: string, dependencies: KitBrowserPdfDependencies, resource?: DownloadResource): (() => void) => {\n let cleaned = false;\n return (): void => {\n if (cleaned) return;\n cleaned = true;\n try {\n resource?.link?.remove();\n } catch {\n // Cleanup is best-effort and must not turn successful PDF output into a failure.\n } finally {\n try {\n dependencies.url.revokeObjectURL(pdfUrl);\n } catch {\n // Object URL cleanup is best-effort for the same reason.\n }\n }\n };\n};\n\nconst prepareDownloadLink = (\n resource: DownloadResource,\n pdfUrl: string,\n filename: string,\n dependencies: KitBrowserPdfDependencies,\n): HTMLAnchorElement => {\n const link = dependencies.document.createElement('a');\n resource.link = link;\n link.href = pdfUrl;\n link.download = filename;\n link.style.display = 'none';\n dependencies.document.body.appendChild(link);\n return link;\n};\n\nconst openPreviewWindow = (\n resource: PreviewResource,\n options: KitPreviewGeneratedPdfOptions,\n dependencies: KitBrowserPdfDependencies,\n): Window | null => {\n const target = dependencies.document.defaultView?.open('', '_blank') ?? null;\n resource.target = target;\n if (!target) return null;\n target.opener = null;\n target.document.title = options.title;\n target.document.body.textContent = options.pendingText;\n return target;\n};\n\nconst scheduleCleanup = (cleanup: () => void, delay: number, dependencies: KitBrowserPdfDependencies): boolean => {\n try {\n dependencies.schedule(cleanup, delay);\n return true;\n } catch {\n try {\n globalThis.setTimeout(cleanup, delay);\n return true;\n } catch {\n return false;\n }\n }\n};\n\nconst isWindowClosed = (target: Window): boolean => {\n try {\n return target.closed;\n } catch {\n return true;\n }\n};\n\nconst closeWindow = (target: Window | null): void => {\n try {\n if (target && !target.closed) target.close();\n } catch {\n // Closing a placeholder is best-effort and must never replace the original output error.\n }\n};\n\n/**\n * Download generated PDF bytes without navigating the current application page.\n *\n * @remarks Browser-only. Do not call during server-side rendering.\n *\n * The temporary anchor and object URL stay alive long enough for browsers to start the download.\n * Cleanup is registered before clicking so a cleanup scheduling error cannot be mistaken for a PDF\n * generation failure after the download has already started.\n */\nexport const kitDownloadPdf = (pdfBytes: Uint8Array, options: KitDownloadPdfOptions): void => {\n const dependencies = options.dependencies ?? defaultDependencies();\n const pdfUrl = createPdfUrl(pdfBytes, dependencies);\n const resource: DownloadResource = {};\n const cleanup = createCleanup(pdfUrl, dependencies, resource);\n let link: HTMLAnchorElement;\n\n try {\n link = prepareDownloadLink(resource, pdfUrl, options.filename, dependencies);\n } catch (error) {\n cleanup();\n throw error;\n }\n const cleanupScheduled = scheduleCleanup(cleanup, cleanupDelay(options.cleanupDelayMs), dependencies);\n try {\n link.click();\n } catch (error) {\n cleanup();\n throw error;\n } finally {\n if (!cleanupScheduled) cleanup();\n }\n};\n\n/**\n * Open a placeholder window synchronously for an asynchronously generated PDF.\n *\n * Call this directly from the user's click handler, before awaiting PDF generation, to avoid popup\n * blocking. If the preview cannot be opened or is closed while generating, showing the PDF safely\n * falls back to a file download and keeps the current application page in place.\n */\nconst preparePdfPreview = (options: KitPreviewGeneratedPdfOptions): PdfPreview => {\n const dependencies = options.dependencies ?? defaultDependencies();\n const resource: PreviewResource = { target: null };\n\n try {\n openPreviewWindow(resource, options, dependencies);\n } catch {\n closeWindow(resource.target);\n resource.target = null;\n }\n\n return {\n show: (pdfBytes): void => {\n const target = resource.target;\n if (!target || isWindowClosed(target)) {\n kitDownloadPdf(pdfBytes, {\n filename: options.fallbackFilename,\n cleanupDelayMs: options.cleanupDelayMs,\n dependencies,\n });\n return;\n }\n\n const pdfUrl = createPdfUrl(pdfBytes, dependencies);\n const cleanup = createCleanup(pdfUrl, dependencies);\n const cleanupScheduled = scheduleCleanup(cleanup, cleanupDelay(options.cleanupDelayMs), dependencies);\n try {\n target.location.replace(pdfUrl);\n } catch {\n cleanup();\n closeWindow(target);\n kitDownloadPdf(pdfBytes, {\n filename: options.fallbackFilename,\n cleanupDelayMs: options.cleanupDelayMs,\n dependencies,\n });\n return;\n } finally {\n if (!cleanupScheduled) cleanup();\n }\n },\n close: (): void => closeWindow(resource.target),\n };\n};\n\n/**\n * Preview an asynchronously generated PDF without risking a popup-blocked result.\n *\n * This function opens its placeholder window synchronously, before invoking `buildPdf`. Call it\n * directly from the user's click handler and pass PDF generation as the callback. Generation errors\n * close the placeholder and are rethrown for the application to present with its own UI.\n */\nexport const kitPreviewGeneratedPdf = async (\n buildPdf: () => Promise<Uint8Array>,\n options: KitPreviewGeneratedPdfOptions,\n): Promise<void> => {\n const preview = preparePdfPreview(options);\n const buildAndShow = async (): Promise<void> => preview.show(await buildPdf());\n await buildAndShow().catch((error: unknown) => {\n preview.close();\n throw error;\n });\n};\n","// Printer: Brother label plumbing (DOM→PNG, rotation, print-settings assembly).\n// Split into its own entry point so only apps that print pull in `@rdlabo/capacitor-brotherprint`\n// and `dom-to-image-more`; the core entry stays free of those native peers.\nexport * from './kit-printer';\nexport * from './kit-pdf-printer';\nexport * from './kit-browser-pdf';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAcA;;;;;;;;;;AAUG;MACU,gBAAgB,GAAG,OAAO,SAAiB,KAAqB;AAC3E,IAAA,MAAM,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAE9D,IAAA,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE;IACzB,MAAM,MAAM,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,KAAI;QAC3C,KAAK,CAAC,MAAM,GAAG,MAAM,OAAO,EAAE;AAChC,IAAA,CAAC,CAAC;AACF,IAAA,KAAK,CAAC,GAAG,GAAG,SAAS;AACrB,IAAA,MAAM,MAAM;IAEZ,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;AAEnC,IAAA,MAAM,CAAC,KAAK,GAAG,KAAK,CAAC,MAAM;AAC3B,IAAA,MAAM,CAAC,MAAM,GAAG,KAAK,CAAC,KAAK;AAE3B,IAAA,GAAI,CAAC,MAAM,CAAC,CAAC,EAAE,GAAG,IAAI,CAAC,EAAE,IAAI,GAAG,CAAC;IACjC,GAAI,CAAC,SAAS,C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