@rdlabo/ionic-angular-kit 21.6.0 → 21.6.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.
- package/README.md +65 -0
- 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 +664 -353
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs +40 -27
- 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 +208 -84
|
@@ -213,14 +213,14 @@ const createPdfUrl = (pdfBytes, dependencies) => dependencies.url.createObjectUR
|
|
|
213
213
|
type: 'application/pdf',
|
|
214
214
|
}));
|
|
215
215
|
const cleanupDelay = (value) => (value !== undefined && Number.isFinite(value) && value >= 0 ? value : 60_000);
|
|
216
|
-
const createCleanup = (pdfUrl, dependencies,
|
|
216
|
+
const createCleanup = (pdfUrl, dependencies, resource) => {
|
|
217
217
|
let cleaned = false;
|
|
218
218
|
return () => {
|
|
219
219
|
if (cleaned)
|
|
220
220
|
return;
|
|
221
221
|
cleaned = true;
|
|
222
222
|
try {
|
|
223
|
-
link?.remove();
|
|
223
|
+
resource?.link?.remove();
|
|
224
224
|
}
|
|
225
225
|
catch {
|
|
226
226
|
// Cleanup is best-effort and must not turn successful PDF output into a failure.
|
|
@@ -235,6 +235,25 @@ const createCleanup = (pdfUrl, dependencies, link) => {
|
|
|
235
235
|
}
|
|
236
236
|
};
|
|
237
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
|
+
};
|
|
238
257
|
const scheduleCleanup = (cleanup, delay, dependencies) => {
|
|
239
258
|
try {
|
|
240
259
|
dependencies.schedule(cleanup, delay);
|
|
@@ -279,18 +298,18 @@ const closeWindow = (target) => {
|
|
|
279
298
|
const kitDownloadPdf = (pdfBytes, options) => {
|
|
280
299
|
const dependencies = options.dependencies ?? defaultDependencies();
|
|
281
300
|
const pdfUrl = createPdfUrl(pdfBytes, dependencies);
|
|
301
|
+
const resource = {};
|
|
302
|
+
const cleanup = createCleanup(pdfUrl, dependencies, resource);
|
|
282
303
|
let link;
|
|
283
|
-
let cleanup = createCleanup(pdfUrl, dependencies);
|
|
284
|
-
let cleanupScheduled = false;
|
|
285
304
|
try {
|
|
286
|
-
link = dependencies
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
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 {
|
|
294
313
|
link.click();
|
|
295
314
|
}
|
|
296
315
|
catch (error) {
|
|
@@ -311,21 +330,17 @@ const kitDownloadPdf = (pdfBytes, options) => {
|
|
|
311
330
|
*/
|
|
312
331
|
const preparePdfPreview = (options) => {
|
|
313
332
|
const dependencies = options.dependencies ?? defaultDependencies();
|
|
314
|
-
|
|
333
|
+
const resource = { target: null };
|
|
315
334
|
try {
|
|
316
|
-
|
|
317
|
-
if (target) {
|
|
318
|
-
target.opener = null;
|
|
319
|
-
target.document.title = options.title;
|
|
320
|
-
target.document.body.textContent = options.pendingText;
|
|
321
|
-
}
|
|
335
|
+
openPreviewWindow(resource, options, dependencies);
|
|
322
336
|
}
|
|
323
337
|
catch {
|
|
324
|
-
closeWindow(target);
|
|
325
|
-
target = null;
|
|
338
|
+
closeWindow(resource.target);
|
|
339
|
+
resource.target = null;
|
|
326
340
|
}
|
|
327
341
|
return {
|
|
328
342
|
show: (pdfBytes) => {
|
|
343
|
+
const target = resource.target;
|
|
329
344
|
if (!target || isWindowClosed(target)) {
|
|
330
345
|
kitDownloadPdf(pdfBytes, {
|
|
331
346
|
filename: options.fallbackFilename,
|
|
@@ -355,7 +370,7 @@ const preparePdfPreview = (options) => {
|
|
|
355
370
|
cleanup();
|
|
356
371
|
}
|
|
357
372
|
},
|
|
358
|
-
close: () => closeWindow(target),
|
|
373
|
+
close: () => closeWindow(resource.target),
|
|
359
374
|
};
|
|
360
375
|
};
|
|
361
376
|
/**
|
|
@@ -367,13 +382,11 @@ const preparePdfPreview = (options) => {
|
|
|
367
382
|
*/
|
|
368
383
|
const kitPreviewGeneratedPdf = async (buildPdf, options) => {
|
|
369
384
|
const preview = preparePdfPreview(options);
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
}
|
|
373
|
-
catch (error) {
|
|
385
|
+
const buildAndShow = async () => preview.show(await buildPdf());
|
|
386
|
+
await buildAndShow().catch((error) => {
|
|
374
387
|
preview.close();
|
|
375
388
|
throw error;
|
|
376
|
-
}
|
|
389
|
+
});
|
|
377
390
|
};
|
|
378
391
|
|
|
379
392
|
// Printer: Brother label plumbing (DOM→PNG, rotation, print-settings assembly).
|
|
@@ -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/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\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, link?: HTMLAnchorElement): (() => void) => {\n let cleaned = false;\n return (): void => {\n if (cleaned) return;\n cleaned = true;\n try {\n 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 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 let link: HTMLAnchorElement | undefined;\n let cleanup = createCleanup(pdfUrl, dependencies);\n let cleanupScheduled = false;\n\n try {\n link = dependencies.document.createElement('a');\n cleanup = createCleanup(pdfUrl, dependencies, link);\n link.href = pdfUrl;\n link.download = options.filename;\n link.style.display = 'none';\n dependencies.document.body.appendChild(link);\n cleanupScheduled = scheduleCleanup(cleanup, cleanupDelay(options.cleanupDelayMs), dependencies);\n\n // Keep this as the final synchronous output operation: the browser may start immediately.\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 let target: Window | null = null;\n\n try {\n target = dependencies.document.defaultView?.open('', '_blank') ?? null;\n if (target) {\n target.opener = null;\n target.document.title = options.title;\n target.document.body.textContent = options.pendingText;\n }\n } catch {\n closeWindow(target);\n target = null;\n }\n\n return {\n show: (pdfBytes): void => {\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(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 try {\n preview.show(await buildPdf());\n } catch (error) {\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,CA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ACT,WAAW,CAAC,MAAM,CAAC;gBACnB,cAAc,CAAC,QAAQ,EAAE;oBACvB,QAAQ,EAAE,OAAO,CAAC,gBAAgB;oBAClC,cAAc,EAAE,OAAO,CAAC,cAAc;oBACtC,YAAY;AACb,iBAAA,CAAC;gBACF;YACF;oBAAU;AACR,gBAAA,IAAI,CAAC,gBAAgB;AAAE,oBAAA,OAAO,EAAE;YAClC;QACF,CAAC;AACD,QAAA,KAAK,EAAE,MAAY,WAAW,CAAC,MAAM,CAAC;KACvC;AACH,CAAC;AAED;;;;;;AAMG;AACI,MAAM,sBAAsB,GAAG,OACpC,QAAmC,EACnC,OAAsC,KACrB;AACjB,IAAA,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;AAC1C,IAAA,IAAI;AACF,QAAA,OAAO,CAAC,IAAI,CAAC,MAAM,QAAQ,EAAE,CAAC;IAChC;IAAE,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,EAAE;AACf,QAAA,MAAM,KAAK;IACb;AACF;;ACpNA;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,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,CAAC;AAChC,IAAA,GAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC,EAAE,CAAC,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC;AAEtD,IAAA,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