@rdlabo/ionic-angular-kit 21.6.10 → 21.7.0
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 +31 -1321
- package/docs/auth-http.md +36 -0
- package/docs/offline-realtime.md +36 -0
- package/docs/optional-features.md +31 -0
- package/docs/storage-overlays.md +52 -0
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs +121 -36
- package/fesm2022/rdlabo-ionic-angular-kit-offline.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs +43 -82
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs.map +1 -1
- package/package.json +1 -1
- package/types/rdlabo-ionic-angular-kit-offline.d.ts +85 -28
- package/types/rdlabo-ionic-angular-kit-printer.d.ts +23 -9
|
@@ -244,16 +244,6 @@ const prepareDownloadLink = (resource, pdfUrl, filename, dependencies) => {
|
|
|
244
244
|
dependencies.document.body.appendChild(link);
|
|
245
245
|
return link;
|
|
246
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
247
|
const scheduleCleanup = (cleanup, delay, dependencies) => {
|
|
258
248
|
try {
|
|
259
249
|
dependencies.schedule(cleanup, delay);
|
|
@@ -269,21 +259,12 @@ const scheduleCleanup = (cleanup, delay, dependencies) => {
|
|
|
269
259
|
}
|
|
270
260
|
}
|
|
271
261
|
};
|
|
272
|
-
const
|
|
273
|
-
|
|
274
|
-
return target.closed;
|
|
275
|
-
}
|
|
276
|
-
catch {
|
|
277
|
-
return true;
|
|
278
|
-
}
|
|
262
|
+
const clearWindowOpener = (target) => {
|
|
263
|
+
target.opener = null;
|
|
279
264
|
};
|
|
280
|
-
const
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
target.close();
|
|
284
|
-
}
|
|
285
|
-
catch {
|
|
286
|
-
// Closing a placeholder is best-effort and must never replace the original output error.
|
|
265
|
+
const closeWindowIfOpen = (target) => {
|
|
266
|
+
if (target && !target.closed) {
|
|
267
|
+
target.close();
|
|
287
268
|
}
|
|
288
269
|
};
|
|
289
270
|
/**
|
|
@@ -322,71 +303,51 @@ const kitDownloadPdf = (pdfBytes, options) => {
|
|
|
322
303
|
}
|
|
323
304
|
};
|
|
324
305
|
/**
|
|
325
|
-
*
|
|
306
|
+
* Preview an asynchronously generated PDF after generation completes in the source tab.
|
|
307
|
+
*
|
|
308
|
+
* `buildPdf` runs to completion while the calling tab stays active so DOM-based builders that rely
|
|
309
|
+
* on `requestAnimationFrame` are not stalled by a backgrounded placeholder tab. The completed PDF
|
|
310
|
+
* object URL is then opened in `_blank`. If opening is blocked or throws, the PDF is downloaded
|
|
311
|
+
* instead and the current application page stays in place. Generation errors are rethrown for the
|
|
312
|
+
* application to present with its own UI.
|
|
326
313
|
*
|
|
327
|
-
*
|
|
328
|
-
*
|
|
329
|
-
*
|
|
314
|
+
* @remarks Browser-only. Do not call during server-side rendering. Call from a user gesture when
|
|
315
|
+
* possible; after an `await`, browsers may still block the preview window and trigger the download
|
|
316
|
+
* fallback.
|
|
330
317
|
*/
|
|
331
|
-
const
|
|
318
|
+
const kitPreviewGeneratedPdf = async (buildPdf, options) => {
|
|
332
319
|
const dependencies = options.dependencies ?? defaultDependencies();
|
|
333
|
-
const
|
|
320
|
+
const pdfBytes = await buildPdf();
|
|
321
|
+
const pdfUrl = createPdfUrl(pdfBytes, dependencies);
|
|
322
|
+
const cleanup = createCleanup(pdfUrl, dependencies);
|
|
323
|
+
let target = null;
|
|
334
324
|
try {
|
|
335
|
-
|
|
325
|
+
target = dependencies.document.defaultView?.open(pdfUrl, '_blank') ?? null;
|
|
326
|
+
if (target)
|
|
327
|
+
clearWindowOpener(target);
|
|
336
328
|
}
|
|
337
329
|
catch {
|
|
338
|
-
|
|
339
|
-
|
|
330
|
+
try {
|
|
331
|
+
closeWindowIfOpen(target);
|
|
332
|
+
}
|
|
333
|
+
catch {
|
|
334
|
+
// Closing a partially opened preview is best-effort.
|
|
335
|
+
}
|
|
336
|
+
target = null;
|
|
337
|
+
}
|
|
338
|
+
if (!target) {
|
|
339
|
+
cleanup();
|
|
340
|
+
kitDownloadPdf(pdfBytes, {
|
|
341
|
+
filename: options.fallbackFilename,
|
|
342
|
+
cleanupDelayMs: options.cleanupDelayMs,
|
|
343
|
+
dependencies,
|
|
344
|
+
});
|
|
345
|
+
return;
|
|
346
|
+
}
|
|
347
|
+
const cleanupScheduled = scheduleCleanup(cleanup, cleanupDelay(options.cleanupDelayMs), dependencies);
|
|
348
|
+
if (!cleanupScheduled) {
|
|
349
|
+
cleanup();
|
|
340
350
|
}
|
|
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
351
|
};
|
|
391
352
|
|
|
392
353
|
// 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\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,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,MAAM,MAAM,GAAG,YAAY,CAAC,QAAQ,EAAE,YAAY,CAAC;YACnD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC;AACnD,YAAA,MAAM,gBAAgB,GAAG,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC;AACrG,YAAA,IAAI;AACF,gBAAA,MAAM,CAAC,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC;YACjC;AAAE,YAAA,MAAM;AACN,gBAAA,OAAO,EAAE;gBACT,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;QACD,KAAK,EAAE,MAAY,WAAW,CAAC,QAAQ,CAAC,MAAM,CAAC;KAChD;AACH,CAAC;AAED;;;;;;AAMG;AACI,MAAM,sBAAsB,GAAG,OACpC,QAAmC,EACnC,OAAsC,KACrB;AACjB,IAAA,MAAM,OAAO,GAAG,iBAAiB,CAAC,OAAO,CAAC;AAC1C,IAAA,MAAM,YAAY,GAAG,YAA2B,OAAO,CAAC,IAAI,CAAC,MAAM,QAAQ,EAAE,CAAC;IAC9E,MAAM,YAAY,EAAE,CAAC,KAAK,CAAC,CAAC,KAAc,KAAI;QAC5C,OAAO,CAAC,KAAK,EAAE;AACf,QAAA,MAAM,KAAK;AACb,IAAA,CAAC,CAAC;AACJ;;AClPA;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 /**\n * Previously used as the placeholder tab title while PDF generation was in progress.\n *\n * @deprecated No placeholder window is shown; this option is ignored. Kept for source compatibility.\n */\n readonly title?: string;\n /**\n * Previously used as the placeholder tab body text while PDF generation was in progress.\n *\n * @deprecated No placeholder window is shown; this option is ignored. Kept for source compatibility.\n */\n readonly pendingText?: string;\n /** Filename used when a preview window cannot be opened. */\n readonly fallbackFilename: string;\n}\n\ninterface DownloadResource {\n link?: HTMLAnchorElement;\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 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 clearWindowOpener = (target: Window): void => {\n target.opener = null;\n};\n\nconst closeWindowIfOpen = (target: Window | null): void => {\n if (target && !target.closed) {\n target.close();\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 * Preview an asynchronously generated PDF after generation completes in the source tab.\n *\n * `buildPdf` runs to completion while the calling tab stays active so DOM-based builders that rely\n * on `requestAnimationFrame` are not stalled by a backgrounded placeholder tab. The completed PDF\n * object URL is then opened in `_blank`. If opening is blocked or throws, the PDF is downloaded\n * instead and the current application page stays in place. Generation errors are rethrown for the\n * application to present with its own UI.\n *\n * @remarks Browser-only. Do not call during server-side rendering. Call from a user gesture when\n * possible; after an `await`, browsers may still block the preview window and trigger the download\n * fallback.\n */\nexport const kitPreviewGeneratedPdf = async (\n buildPdf: () => Promise<Uint8Array>,\n options: KitPreviewGeneratedPdfOptions,\n): Promise<void> => {\n const dependencies = options.dependencies ?? defaultDependencies();\n const pdfBytes = await buildPdf();\n const pdfUrl = createPdfUrl(pdfBytes, dependencies);\n const cleanup = createCleanup(pdfUrl, dependencies);\n\n let target: Window | null = null;\n try {\n target = dependencies.document.defaultView?.open(pdfUrl, '_blank') ?? null;\n if (target) clearWindowOpener(target);\n } catch {\n try {\n closeWindowIfOpen(target);\n } catch {\n // Closing a partially opened preview is best-effort.\n }\n target = null;\n }\n\n if (!target) {\n cleanup();\n kitDownloadPdf(pdfBytes, {\n filename: options.fallbackFilename,\n cleanupDelayMs: options.cleanupDelayMs,\n dependencies,\n });\n return;\n }\n\n const cleanupScheduled = scheduleCleanup(cleanup, cleanupDelay(options.cleanupDelayMs), dependencies);\n if (!cleanupScheduled) {\n cleanup();\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,OAAO,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC;AAClC;AAUA;;;;;;;;;;;;;;;;;;;;;AAqBG;AACI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AE,YAAY,CAAC;IACnD,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,EAAE,YAAY,CAAC;IAEnD,IAAI,MAAM,GAAkB,IAAI;AAChC,IAAA,IAAI;AACF,QAAA,MAAM,GAAG,YAAY,CAAC,QAAQ,CAAC,WAAW,EAAE,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,IAAI,IAAI;AAC1E,QAAA,IAAI,MAAM;YAAE,iBAAiB,CAAC,MAAM,CAAC;IACvC;AAAE,IAAA,MAAM;AACN,QAAA,IAAI;YACF,iBAAiB,CAAC,MAAM,CAAC;QAC3B;AAAE,QAAA,MAAM;;QAER;QACA,MAAM,GAAG,IAAI;IACf;IAEA,IAAI,CAAC,MAAM,EAAE;AACX,QAAA,OAAO,EAAE;QACT,cAAc,CAAC,QAAQ,EAAE;YACvB,QAAQ,EAAE,OAAO,CAAC,gBAAgB;YAClC,cAAc,EAAE,OAAO,CAAC,cAAc;YACtC,YAAY;AACb,SAAA,CAAC;QACF;IACF;AAEA,IAAA,MAAM,gBAAgB,GAAG,eAAe,CAAC,OAAO,EAAE,YAAY,CAAC,OAAO,CAAC,cAAc,CAAC,EAAE,YAAY,CAAC;IACrG,IAAI,CAAC,gBAAgB,EAAE;AACrB,QAAA,OAAO,EAAE;IACX;AACF;;ACzMA;AACA;AACA;;ACFA;;AAEG;;;;"}
|
package/package.json
CHANGED
|
@@ -941,14 +941,30 @@ interface OfflineMutationPersistenceOptions {
|
|
|
941
941
|
/** Initial value when no durable preference exists. Defaults to `true`. */
|
|
942
942
|
defaultEnabled?: boolean;
|
|
943
943
|
}
|
|
944
|
-
/**
|
|
945
|
-
|
|
944
|
+
/**
|
|
945
|
+
* Native SQLite encryption settings for {@link OfflineKitOptions}.
|
|
946
|
+
*
|
|
947
|
+
* Encryption is the default: omit `databaseEncryption` or set it to `true`, and
|
|
948
|
+
* `createEncryptionKey` is required. The factory may be omitted only when
|
|
949
|
+
* `databaseEncryption` is explicitly `false`.
|
|
950
|
+
*/
|
|
951
|
+
type OfflineKitEncryptionOptions = {
|
|
952
|
+
/** Enables SQLCipher for native SQLite. Defaults to `true`. */
|
|
953
|
+
databaseEncryption?: true;
|
|
954
|
+
/** Creates the native database encryption key on first install. Required when encryption is enabled. */
|
|
955
|
+
createEncryptionKey: () => Promise<string>;
|
|
956
|
+
} | {
|
|
957
|
+
/** Disables SQLCipher and opens a plaintext native SQLite database. */
|
|
958
|
+
databaseEncryption: false;
|
|
959
|
+
/** Unused when native encryption is disabled. */
|
|
960
|
+
createEncryptionKey?: () => Promise<string>;
|
|
961
|
+
};
|
|
962
|
+
/** Product-independent native offline persistence settings shared by all encryption modes. */
|
|
963
|
+
interface OfflineKitOptionsBase {
|
|
946
964
|
/** Runtime transport mode. Defaults to full synchronized replica/outbox behavior. */
|
|
947
965
|
mode?: 'synchronized' | 'readCacheOnly';
|
|
948
|
-
/**
|
|
966
|
+
/** SQLite database name used on iOS and Android. */
|
|
949
967
|
databaseName: string;
|
|
950
|
-
/** Creates the native database encryption key on first install. Required on iOS and Android. */
|
|
951
|
-
createEncryptionKey?: () => Promise<string>;
|
|
952
968
|
/** Versioned product replica schema applied to native SQLite during initialization. */
|
|
953
969
|
replicaSchema: OfflineReplicaSchemaBundle;
|
|
954
970
|
/**
|
|
@@ -982,6 +998,14 @@ interface OfflineKitOptions {
|
|
|
982
998
|
*/
|
|
983
999
|
onStorageUnavailable?: (error: OfflineStorageUnavailableError) => void | Promise<void>;
|
|
984
1000
|
}
|
|
1001
|
+
/**
|
|
1002
|
+
* Product-independent native offline persistence settings.
|
|
1003
|
+
*
|
|
1004
|
+
* Encryption is the default: omit `databaseEncryption` or set it to `true`, and
|
|
1005
|
+
* `createEncryptionKey` is required. The factory may be omitted only when
|
|
1006
|
+
* `databaseEncryption` is explicitly `false`.
|
|
1007
|
+
*/
|
|
1008
|
+
type OfflineKitOptions = OfflineKitOptionsBase & OfflineKitEncryptionOptions;
|
|
985
1009
|
/** Exact versioned wire contract exchanged by pull transport. */
|
|
986
1010
|
interface OfflineWireProtocolFingerprint {
|
|
987
1011
|
/** Monotonic product wire protocol version. */
|
|
@@ -1227,7 +1251,7 @@ interface OfflineLocalResetMarkerStore {
|
|
|
1227
1251
|
interface OfflineLocalResetReloadTarget {
|
|
1228
1252
|
reload(): void;
|
|
1229
1253
|
}
|
|
1230
|
-
/** Native SQLite connection lifecycle required to delete Kit's
|
|
1254
|
+
/** Native SQLite connection lifecycle required to delete Kit's database safely. */
|
|
1231
1255
|
interface OfflineLocalResetSqliteConnection {
|
|
1232
1256
|
checkConnectionsConsistency(): Promise<{
|
|
1233
1257
|
result?: boolean;
|
|
@@ -1235,10 +1259,14 @@ interface OfflineLocalResetSqliteConnection {
|
|
|
1235
1259
|
isDatabase(database: string): Promise<{
|
|
1236
1260
|
result?: boolean;
|
|
1237
1261
|
}>;
|
|
1262
|
+
isDatabaseEncrypted?(database: string): Promise<{
|
|
1263
|
+
result?: boolean;
|
|
1264
|
+
}>;
|
|
1238
1265
|
createConnection(database: string, encrypted: boolean, mode: string, version: number, readonly: boolean): Promise<{
|
|
1239
1266
|
delete(): Promise<void>;
|
|
1240
1267
|
}>;
|
|
1241
1268
|
closeConnection(database: string, readonly: boolean): Promise<void>;
|
|
1269
|
+
clearEncryptionSecret?(): Promise<void>;
|
|
1242
1270
|
}
|
|
1243
1271
|
/** Options for {@link requestOfflineLocalReset}. */
|
|
1244
1272
|
interface RequestOfflineLocalResetOptions {
|
|
@@ -1252,15 +1280,31 @@ interface RecoverOfflineLocalResetOptions {
|
|
|
1252
1280
|
markerKey: string;
|
|
1253
1281
|
sqliteConnection: OfflineLocalResetSqliteConnection;
|
|
1254
1282
|
/**
|
|
1255
|
-
* Kit database followed only by product databases using Kit's same
|
|
1256
|
-
*
|
|
1283
|
+
* Kit database followed only by product databases using Kit's same encryption
|
|
1284
|
+
* mode, connection-version-1, read/write lifecycle.
|
|
1257
1285
|
* Delete databases with other connection settings in {@link additionalCleanup}.
|
|
1258
1286
|
*/
|
|
1259
1287
|
kitCompatibleDatabaseNames: readonly [string, ...string[]];
|
|
1288
|
+
/** Connection mode used only to obtain the public `delete()` handle. Defaults to encrypted for compatibility. */
|
|
1289
|
+
databaseEncryption?: boolean;
|
|
1260
1290
|
nativePlatform?: boolean;
|
|
1261
1291
|
/** Product-owned cleanup, such as a media database or files, run before the marker is removed. */
|
|
1262
1292
|
additionalCleanup?: () => Promise<void>;
|
|
1263
1293
|
}
|
|
1294
|
+
/** Options for a versioned destructive encryption-mode migration. */
|
|
1295
|
+
interface MigrateOfflineDatabaseEncryptionOptions {
|
|
1296
|
+
markerStore: OfflineLocalResetMarkerStore;
|
|
1297
|
+
markerKey: string;
|
|
1298
|
+
migrationVersion: string;
|
|
1299
|
+
sqliteConnection: OfflineLocalResetSqliteConnection;
|
|
1300
|
+
kitCompatibleDatabaseNames: readonly [string, ...string[]];
|
|
1301
|
+
/** Existing database mode used only to obtain a valid public `delete()` handle. */
|
|
1302
|
+
sourceDatabaseEncryption: boolean | 'detect';
|
|
1303
|
+
/** Removes the obsolete plugin secret after every database and product cleanup succeeds. */
|
|
1304
|
+
clearEncryptionSecret?: boolean;
|
|
1305
|
+
nativePlatform?: boolean;
|
|
1306
|
+
additionalCleanup?: () => Promise<void>;
|
|
1307
|
+
}
|
|
1264
1308
|
/** Persists an explicit destructive reset request, then reloads into a cold bootstrap. */
|
|
1265
1309
|
declare function requestOfflineLocalReset(options: RequestOfflineLocalResetOptions): Promise<void>;
|
|
1266
1310
|
/**
|
|
@@ -1270,6 +1314,14 @@ declare function requestOfflineLocalReset(options: RequestOfflineLocalResetOptio
|
|
|
1270
1314
|
* Kit never invokes this helper automatically in response to a storage failure.
|
|
1271
1315
|
*/
|
|
1272
1316
|
declare function recoverOfflineLocalReset(options: RecoverOfflineLocalResetOptions): Promise<boolean>;
|
|
1317
|
+
/**
|
|
1318
|
+
* Deletes native databases once when changing their encryption mode.
|
|
1319
|
+
*
|
|
1320
|
+
* Products with a remote source of truth can use this before Angular bootstrap instead of
|
|
1321
|
+
* decrypting local replicas. The completion marker is written only after every deletion and
|
|
1322
|
+
* product cleanup succeeds, so interruption retries safely on the next cold start.
|
|
1323
|
+
*/
|
|
1324
|
+
declare function migrateOfflineDatabaseEncryption(options: MigrateOfflineDatabaseEncryptionOptions): Promise<boolean>;
|
|
1273
1325
|
|
|
1274
1326
|
/** Identity policy for a successful offline mutation response. */
|
|
1275
1327
|
type OfflineMutationEnvelopeIdPolicy = 'required' | 'optional' | 'forbidden';
|
|
@@ -1444,6 +1496,11 @@ interface CommunitySqliteDriver {
|
|
|
1444
1496
|
}): Promise<{
|
|
1445
1497
|
databaseId: string;
|
|
1446
1498
|
}>;
|
|
1499
|
+
/** Executes multiple schema statements through one native bridge call when the driver supports it. */
|
|
1500
|
+
executeBatch?(options: {
|
|
1501
|
+
databaseId: string;
|
|
1502
|
+
statements: readonly string[];
|
|
1503
|
+
}): Promise<void>;
|
|
1447
1504
|
execute(options: {
|
|
1448
1505
|
databaseId: string;
|
|
1449
1506
|
statement: string;
|
|
@@ -1470,6 +1527,7 @@ interface CommunitySqliteDriver {
|
|
|
1470
1527
|
/** Open community SQLite database surface used by the standard driver. */
|
|
1471
1528
|
interface CommunitySqliteDatabase {
|
|
1472
1529
|
open(): Promise<void>;
|
|
1530
|
+
execute?(statements: string, transaction?: boolean): Promise<unknown>;
|
|
1473
1531
|
run(statement: string, values?: unknown[], transaction?: boolean): Promise<unknown>;
|
|
1474
1532
|
query(statement: string, values?: unknown[]): Promise<{
|
|
1475
1533
|
values?: unknown[];
|
|
@@ -1479,7 +1537,7 @@ interface CommunitySqliteDatabase {
|
|
|
1479
1537
|
rollbackTransaction(): Promise<unknown>;
|
|
1480
1538
|
}
|
|
1481
1539
|
/**
|
|
1482
|
-
* Community SQLite connection surface used to provision
|
|
1540
|
+
* Community SQLite connection surface used to provision native databases.
|
|
1483
1541
|
*
|
|
1484
1542
|
* One object must exclusively own a native plugin connection registry. Consumers must not create another
|
|
1485
1543
|
* wrapper over the same native plugin or call `closeConnection` while its canonical driver is active.
|
|
@@ -1503,15 +1561,18 @@ declare const COMMUNITY_SQLITE: InjectionToken<CommunitySqliteDriver | null>;
|
|
|
1503
1561
|
*/
|
|
1504
1562
|
declare function createRandomOfflineEncryptionKey(): Promise<string>;
|
|
1505
1563
|
/**
|
|
1506
|
-
* Create the canonical
|
|
1564
|
+
* Create the canonical `@capacitor-community/sqlite` driver for a connection owner.
|
|
1507
1565
|
*
|
|
1508
|
-
*
|
|
1509
|
-
*
|
|
1510
|
-
*
|
|
1511
|
-
*
|
|
1512
|
-
*
|
|
1566
|
+
* Native databases are encrypted by default. Pass `encrypted: false` for plaintext. The supplied
|
|
1567
|
+
* connection is the identity and exclusive owner of its native plugin connections. Repeated calls
|
|
1568
|
+
* with the same object and the same encryption mode return the same driver so normal concurrent
|
|
1569
|
+
* access cannot be mistaken for a WebView-reload orphan. A later call with a different encryption
|
|
1570
|
+
* mode throws instead of silently reusing the cached driver. Consumers must route database access
|
|
1571
|
+
* through this driver and must not close or replace the connection while the driver is active. A
|
|
1572
|
+
* real WebView reload creates a new JavaScript owner, allowing the driver to close the native
|
|
1573
|
+
* connection orphaned by the previous owner and recreate it.
|
|
1513
1574
|
*/
|
|
1514
|
-
declare function createCommunitySqliteDriver(connection: CommunitySqliteConnection): CommunitySqliteDriver;
|
|
1575
|
+
declare function createCommunitySqliteDriver(connection: CommunitySqliteConnection, encrypted?: boolean): CommunitySqliteDriver;
|
|
1515
1576
|
type SQLiteValue = string | number | null;
|
|
1516
1577
|
/** Native iOS/Android repository backed by encrypted `@capacitor-community/sqlite`. */
|
|
1517
1578
|
declare class SqliteOfflineRepository implements OfflineRepository {
|
|
@@ -1546,7 +1607,7 @@ declare class SqliteOfflineRepository implements OfflineRepository {
|
|
|
1546
1607
|
}
|
|
1547
1608
|
|
|
1548
1609
|
/** Configuration for the standard offline repository, outbox, and request-policy runtime. */
|
|
1549
|
-
interface ProvideOfflineOptionsBase extends OfflineKitOptions {
|
|
1610
|
+
interface ProvideOfflineOptionsBase extends Omit<OfflineKitOptions, 'databaseEncryption' | 'createEncryptionKey'> {
|
|
1550
1611
|
/** Product policies that map URLs and DTOs to generic replica/outbox operations. */
|
|
1551
1612
|
requestPolicies: readonly Type<OfflineRequestPolicy>[];
|
|
1552
1613
|
/** Optional product hooks for entity projection and command cleanup. */
|
|
@@ -1559,10 +1620,8 @@ interface ProvideOfflineOptionsBase extends OfflineKitOptions {
|
|
|
1559
1620
|
sqliteConnection?: CommunitySqliteConnection;
|
|
1560
1621
|
}
|
|
1561
1622
|
/** Full replica pull and durable Outbox synchronization. */
|
|
1562
|
-
|
|
1623
|
+
type ProvideSynchronizedOfflineOptions = ProvideOfflineOptionsBase & OfflineKitEncryptionOptions & {
|
|
1563
1624
|
mode?: 'synchronized';
|
|
1564
|
-
/** Creates the encrypted native database key on first install. */
|
|
1565
|
-
createEncryptionKey: () => Promise<string>;
|
|
1566
1625
|
/** Product policies that replace matched writes with atomic local-first mutations. */
|
|
1567
1626
|
mutationPolicies?: readonly Type<OfflineMutationRequestPolicy>[];
|
|
1568
1627
|
/** Product adapter that sends opaque commands to its API. */
|
|
@@ -1578,23 +1637,21 @@ interface ProvideSynchronizedOfflineOptions extends ProvideOfflineOptionsBase {
|
|
|
1578
1637
|
* call the projector from product code.
|
|
1579
1638
|
*/
|
|
1580
1639
|
aggregateIntentProjector: Type<OfflineAggregateIntentProjector>;
|
|
1581
|
-
}
|
|
1640
|
+
};
|
|
1582
1641
|
/** Server- or external-source read cache with no mutation transport or Outbox. */
|
|
1583
|
-
|
|
1642
|
+
type ProvideReadCacheOfflineOptions = ProvideOfflineOptionsBase & OfflineKitEncryptionOptions & {
|
|
1584
1643
|
mode: 'readCacheOnly';
|
|
1585
|
-
/** Creates the encrypted native cache database key on first install. Unused by the web repository. */
|
|
1586
|
-
createEncryptionKey: () => Promise<string>;
|
|
1587
1644
|
mutationPolicies?: never;
|
|
1588
1645
|
mutationPersistence?: never;
|
|
1589
1646
|
commandExecutor?: never;
|
|
1590
1647
|
replicaPuller?: never;
|
|
1591
|
-
}
|
|
1648
|
+
};
|
|
1592
1649
|
type ProvideOfflineOptions = ProvideSynchronizedOfflineOptions | ProvideReadCacheOfflineOptions;
|
|
1593
1650
|
/**
|
|
1594
1651
|
* Provide the standard scoped offline runtime.
|
|
1595
1652
|
*
|
|
1596
1653
|
* @remarks
|
|
1597
|
-
* Web uses Ionic Storage. Native iOS/Android uses
|
|
1654
|
+
* Web uses Ionic Storage. Native iOS/Android uses `@capacitor-community/sqlite`, encrypted by default. The application owns
|
|
1598
1655
|
* URL/DTO policy and command execution; the kit owns persistence, ordering, retries, and session
|
|
1599
1656
|
* isolation.
|
|
1600
1657
|
*
|
|
@@ -1753,5 +1810,5 @@ declare class OfflineRequestFallbackService {
|
|
|
1753
1810
|
static ɵprov: i0.ɵɵInjectableDeclaration<OfflineRequestFallbackService>;
|
|
1754
1811
|
}
|
|
1755
1812
|
|
|
1756
|
-
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, IonicOfflineRepository, OFFLINE_AGGREGATE_INTENT_PROJECTOR, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, OFFLINE_KIT_OPTIONS, OFFLINE_MUTATION_REQUEST_POLICIES, OFFLINE_REPLICA_PROJECTOR, OFFLINE_REPLICA_PULLER, OFFLINE_REPOSITORY, OFFLINE_REQUEST_POLICIES, OFFLINE_RESPONSE_COMPLETE_HEADER, OFFLINE_RESPONSE_HEADER, OFFLINE_RETRY_RANDOM, OFFLINE_SCHEMA_VERSION, OFFLINE_SYNC_CONTEXT, OfflineCommandInFlightError, OfflineCoordinatorService, OfflineMutationPersistenceDisabledError, OfflineMutationPersistencePendingError, OfflineMutationPersistenceRequiresOnlineError, OfflineMutationPersistenceService, OfflineMutationPolicyConflictError, OfflineMutationProtocolError, OfflineMutationRequestPolicyRegistry, OfflineNetworkService, OfflineOutboxCapacityError, OfflinePayloadValidationError, OfflineReplicaMutationCoordinator, OfflineReplicaPullService, OfflineReplicaSchemaMismatchError, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineSessionService, OfflineStorageUnavailableError, OfflineSyncService, SqliteOfflineRepository, assertOfflineLocalId, assertOfflineReplicaGeneratedRemoteId, assertOfflineReplicaNaturalKeyBaseline, assertSupportedOfflineMode, booleanColumn, canonicalOfflineCommandIdentity, canonicalOfflinePrincipalId, canonicalOfflineRemoteIdentity, canonicalOfflineReplicaIdentity, canonicalOfflineReplicaRowKey, commandFootprintKeys, commandIdentityFromReplicaIdentity, commandIdentityMatchesReplicaRow, createCommunitySqliteDriver, createOfflineAuthBridge, createRandomOfflineEncryptionKey, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, generatedId, ignored, integer, isOfflineAggregateIntentConflict, isOfflineFallbackError, isOfflineStorageUnavailableError, json, localOnly, naturalKey, normalizeOfflineNaturalKey, normalizeOfflineReplicaPullPage, nullable, offlineAggregateIntentMutations, offlineCommandLookupIdentity, offlineCommandTargetFromReplicaRow, offlineCommandWithBaseRevision, offlineGeneratedReplicaIdentity, offlineInterceptor, offlineNaturalKeyFromValues, offlineNaturalReplicaIdentity, offlineReadEmission, offlineReadSource, offlineReplicaRemoteIdentity, offlineRetryDelayMs, offlineSessionManifestAllows, parseOfflineCommandIdentity, parseOfflineMutationEnvelope, parseOfflinePrincipalId, projectOfflineReplicaValues, provideOffline, provideOfflineMutationRequestPolicy, provideOfflineRequestPolicy, real, recoverOfflineLocalReset, replicaAddressFromIdentity, requestOfflineLocalReset, requirePositiveOfflineInteger, selectOfflineRepository, serializeOfflineCommandIdentity, sha256OfflineReplicaSchema, shouldCommitOfflineCollection, supportsSynchronizedOfflineRepository, text };
|
|
1757
|
-
export type { CommunitySqliteConnection, CommunitySqliteDatabase, CommunitySqliteDriver, CreateOfflineAuthBridgeOptions, EnqueueOfflineCommand, EnqueueOfflineCommandIdentity, EnqueueOfflineGeneratedIdentity, EnqueueOfflineNaturalIdentity, OfflineAggregateIntentConflict, OfflineAggregateIntentProjectInput, OfflineAggregateIntentProjectResult, OfflineAggregateIntentProjection, OfflineAggregateIntentProjector, OfflineAuthBridgeConfig, OfflineAuthExchangeContext, OfflineAuthExchangePhase, OfflineAuthResumeContext, OfflineCommand, OfflineCommandExecutor, OfflineCommandHooks, OfflineCommandIdentity, OfflineCommandResult, OfflineCommandState, OfflineCommandTarget, OfflineGeneratedRemoteId, OfflineKitOptions, OfflineLocalResetMarkerStore, OfflineLocalResetReloadTarget, OfflineLocalResetSqliteConnection, OfflineLogoutAction, OfflineMutationEnvelope, OfflineMutationEnvelopeIdPolicy, OfflineMutationEnvelopeOptions, OfflineMutationEnvelopeValuesPolicy, OfflineMutationPersistenceAdapter, OfflineMutationPersistenceOptions, OfflineMutationRequestPlan, OfflineMutationRequestPolicy, OfflineNaturalKey, OfflineNaturalKeyValue, OfflineNetworkState, OfflineOutboxLimits, OfflinePrincipalId, OfflinePullAttention, OfflinePullAttentionReason, OfflineReadEmission, OfflineReadRequestPlan, OfflineReadResponseSource, OfflineReadStrategy, OfflineRemoteIdentity, OfflineReplicaAddress, OfflineReplicaChange, OfflineReplicaChangeBase, OfflineReplicaChangeBatch, OfflineReplicaColumnDef, OfflineReplicaCursor, OfflineReplicaEntityDefinition, OfflineReplicaEntitySchema, OfflineReplicaEntityScope, OfflineReplicaFieldDescriptor, OfflineReplicaFieldPolicy, OfflineReplicaIdentity, OfflineReplicaIdentityDescriptor, OfflineReplicaIgnoredDef, OfflineReplicaLocalOnlyDef, OfflineReplicaMigration, OfflineReplicaMutation, OfflineReplicaNaturalKeyDef, OfflineReplicaProjector, OfflineReplicaPullPage, OfflineReplicaPullProjection, OfflineReplicaPullRequest, OfflineReplicaPuller, OfflineReplicaReconciliationTarget, OfflineReplicaRemoteIdDef, OfflineReplicaRemoteIdRelease, OfflineReplicaRemoteIdentity, OfflineReplicaRow, OfflineReplicaRowKey, OfflineReplicaSchemaBundle, OfflineReplicaSchemaDefinition, OfflineReplicaSqliteAffinity, OfflineReplicaStorageKind, OfflineReplicaSyncState, OfflineReplicaTransaction, OfflineReplicaVisibility, OfflineReplicaWebMigrationCallback, OfflineReplicaWebMigrationResult, OfflineReplicaWebMigrationRow, OfflineReplicaWireChange, OfflineReplicaWireIdentity, OfflineReplicaWirePullPage, OfflineRepository, OfflineRepositoryReader, OfflineRequestPlan, OfflineRequestPolicy, OfflineResponseSource, OfflineResumeRemoteSessionOptions, OfflineScope, OfflineSessionManifest, OfflineSessionTransitionLease, OfflineStorageState, OfflineStorageUnavailableReason, OfflineSyncContext, OfflineSyncSession, OfflineSyncState, OfflineWireProtocolFingerprint, PreparedOfflineBatchOptions, PreparedOfflineCommand, ProvideOfflineOptions, ProvideReadCacheOfflineOptions, ProvideSynchronizedOfflineOptions, RecoverOfflineLocalResetOptions, RequestOfflineLocalResetOptions };
|
|
1813
|
+
export { COMMUNITY_SQLITE, DEFAULT_OFFLINE_COMMAND_HOOKS, IonicOfflineRepository, OFFLINE_AGGREGATE_INTENT_PROJECTOR, OFFLINE_BYPASS, OFFLINE_COMMAND_EXECUTOR, OFFLINE_COMMAND_HOOKS, OFFLINE_KIT_OPTIONS, OFFLINE_MUTATION_REQUEST_POLICIES, OFFLINE_REPLICA_PROJECTOR, OFFLINE_REPLICA_PULLER, OFFLINE_REPOSITORY, OFFLINE_REQUEST_POLICIES, OFFLINE_RESPONSE_COMPLETE_HEADER, OFFLINE_RESPONSE_HEADER, OFFLINE_RETRY_RANDOM, OFFLINE_SCHEMA_VERSION, OFFLINE_SYNC_CONTEXT, OfflineCommandInFlightError, OfflineCoordinatorService, OfflineMutationPersistenceDisabledError, OfflineMutationPersistencePendingError, OfflineMutationPersistenceRequiresOnlineError, OfflineMutationPersistenceService, OfflineMutationPolicyConflictError, OfflineMutationProtocolError, OfflineMutationRequestPolicyRegistry, OfflineNetworkService, OfflineOutboxCapacityError, OfflinePayloadValidationError, OfflineReplicaMutationCoordinator, OfflineReplicaPullService, OfflineReplicaSchemaMismatchError, OfflineRequestFallbackService, OfflineRequestPolicyRegistry, OfflineSessionService, OfflineStorageUnavailableError, OfflineSyncService, SqliteOfflineRepository, assertOfflineLocalId, assertOfflineReplicaGeneratedRemoteId, assertOfflineReplicaNaturalKeyBaseline, assertSupportedOfflineMode, booleanColumn, canonicalOfflineCommandIdentity, canonicalOfflinePrincipalId, canonicalOfflineRemoteIdentity, canonicalOfflineReplicaIdentity, canonicalOfflineReplicaRowKey, commandFootprintKeys, commandIdentityFromReplicaIdentity, commandIdentityMatchesReplicaRow, createCommunitySqliteDriver, createOfflineAuthBridge, createRandomOfflineEncryptionKey, datetime, decodeOfflineReplicaValues, defineOfflineReplicaSchema, defineReplicaEntity, encodeOfflineReplicaValues, generatedId, ignored, integer, isOfflineAggregateIntentConflict, isOfflineFallbackError, isOfflineStorageUnavailableError, json, localOnly, migrateOfflineDatabaseEncryption, naturalKey, normalizeOfflineNaturalKey, normalizeOfflineReplicaPullPage, nullable, offlineAggregateIntentMutations, offlineCommandLookupIdentity, offlineCommandTargetFromReplicaRow, offlineCommandWithBaseRevision, offlineGeneratedReplicaIdentity, offlineInterceptor, offlineNaturalKeyFromValues, offlineNaturalReplicaIdentity, offlineReadEmission, offlineReadSource, offlineReplicaRemoteIdentity, offlineRetryDelayMs, offlineSessionManifestAllows, parseOfflineCommandIdentity, parseOfflineMutationEnvelope, parseOfflinePrincipalId, projectOfflineReplicaValues, provideOffline, provideOfflineMutationRequestPolicy, provideOfflineRequestPolicy, real, recoverOfflineLocalReset, replicaAddressFromIdentity, requestOfflineLocalReset, requirePositiveOfflineInteger, selectOfflineRepository, serializeOfflineCommandIdentity, sha256OfflineReplicaSchema, shouldCommitOfflineCollection, supportsSynchronizedOfflineRepository, text };
|
|
1814
|
+
export type { CommunitySqliteConnection, CommunitySqliteDatabase, CommunitySqliteDriver, CreateOfflineAuthBridgeOptions, EnqueueOfflineCommand, EnqueueOfflineCommandIdentity, EnqueueOfflineGeneratedIdentity, EnqueueOfflineNaturalIdentity, MigrateOfflineDatabaseEncryptionOptions, OfflineAggregateIntentConflict, OfflineAggregateIntentProjectInput, OfflineAggregateIntentProjectResult, OfflineAggregateIntentProjection, OfflineAggregateIntentProjector, OfflineAuthBridgeConfig, OfflineAuthExchangeContext, OfflineAuthExchangePhase, OfflineAuthResumeContext, OfflineCommand, OfflineCommandExecutor, OfflineCommandHooks, OfflineCommandIdentity, OfflineCommandResult, OfflineCommandState, OfflineCommandTarget, OfflineGeneratedRemoteId, OfflineKitEncryptionOptions, OfflineKitOptions, OfflineLocalResetMarkerStore, OfflineLocalResetReloadTarget, OfflineLocalResetSqliteConnection, OfflineLogoutAction, OfflineMutationEnvelope, OfflineMutationEnvelopeIdPolicy, OfflineMutationEnvelopeOptions, OfflineMutationEnvelopeValuesPolicy, OfflineMutationPersistenceAdapter, OfflineMutationPersistenceOptions, OfflineMutationRequestPlan, OfflineMutationRequestPolicy, OfflineNaturalKey, OfflineNaturalKeyValue, OfflineNetworkState, OfflineOutboxLimits, OfflinePrincipalId, OfflinePullAttention, OfflinePullAttentionReason, OfflineReadEmission, OfflineReadRequestPlan, OfflineReadResponseSource, OfflineReadStrategy, OfflineRemoteIdentity, OfflineReplicaAddress, OfflineReplicaChange, OfflineReplicaChangeBase, OfflineReplicaChangeBatch, OfflineReplicaColumnDef, OfflineReplicaCursor, OfflineReplicaEntityDefinition, OfflineReplicaEntitySchema, OfflineReplicaEntityScope, OfflineReplicaFieldDescriptor, OfflineReplicaFieldPolicy, OfflineReplicaIdentity, OfflineReplicaIdentityDescriptor, OfflineReplicaIgnoredDef, OfflineReplicaLocalOnlyDef, OfflineReplicaMigration, OfflineReplicaMutation, OfflineReplicaNaturalKeyDef, OfflineReplicaProjector, OfflineReplicaPullPage, OfflineReplicaPullProjection, OfflineReplicaPullRequest, OfflineReplicaPuller, OfflineReplicaReconciliationTarget, OfflineReplicaRemoteIdDef, OfflineReplicaRemoteIdRelease, OfflineReplicaRemoteIdentity, OfflineReplicaRow, OfflineReplicaRowKey, OfflineReplicaSchemaBundle, OfflineReplicaSchemaDefinition, OfflineReplicaSqliteAffinity, OfflineReplicaStorageKind, OfflineReplicaSyncState, OfflineReplicaTransaction, OfflineReplicaVisibility, OfflineReplicaWebMigrationCallback, OfflineReplicaWebMigrationResult, OfflineReplicaWebMigrationRow, OfflineReplicaWireChange, OfflineReplicaWireIdentity, OfflineReplicaWirePullPage, OfflineRepository, OfflineRepositoryReader, OfflineRequestPlan, OfflineRequestPolicy, OfflineResponseSource, OfflineResumeRemoteSessionOptions, OfflineScope, OfflineSessionManifest, OfflineSessionTransitionLease, OfflineStorageState, OfflineStorageUnavailableReason, OfflineSyncContext, OfflineSyncSession, OfflineSyncState, OfflineWireProtocolFingerprint, PreparedOfflineBatchOptions, PreparedOfflineCommand, ProvideOfflineOptions, ProvideReadCacheOfflineOptions, ProvideSynchronizedOfflineOptions, RecoverOfflineLocalResetOptions, RequestOfflineLocalResetOptions };
|
|
@@ -166,11 +166,19 @@ interface KitDownloadPdfOptions extends KitBrowserPdfOutputOptions {
|
|
|
166
166
|
}
|
|
167
167
|
/** Options for {@link kitPreviewGeneratedPdf}. */
|
|
168
168
|
interface KitPreviewGeneratedPdfOptions extends KitBrowserPdfOutputOptions {
|
|
169
|
-
/**
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
169
|
+
/**
|
|
170
|
+
* Previously used as the placeholder tab title while PDF generation was in progress.
|
|
171
|
+
*
|
|
172
|
+
* @deprecated No placeholder window is shown; this option is ignored. Kept for source compatibility.
|
|
173
|
+
*/
|
|
174
|
+
readonly title?: string;
|
|
175
|
+
/**
|
|
176
|
+
* Previously used as the placeholder tab body text while PDF generation was in progress.
|
|
177
|
+
*
|
|
178
|
+
* @deprecated No placeholder window is shown; this option is ignored. Kept for source compatibility.
|
|
179
|
+
*/
|
|
180
|
+
readonly pendingText?: string;
|
|
181
|
+
/** Filename used when a preview window cannot be opened. */
|
|
174
182
|
readonly fallbackFilename: string;
|
|
175
183
|
}
|
|
176
184
|
/**
|
|
@@ -184,11 +192,17 @@ interface KitPreviewGeneratedPdfOptions extends KitBrowserPdfOutputOptions {
|
|
|
184
192
|
*/
|
|
185
193
|
declare const kitDownloadPdf: (pdfBytes: Uint8Array, options: KitDownloadPdfOptions) => void;
|
|
186
194
|
/**
|
|
187
|
-
* Preview an asynchronously generated PDF
|
|
195
|
+
* Preview an asynchronously generated PDF after generation completes in the source tab.
|
|
188
196
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
191
|
-
*
|
|
197
|
+
* `buildPdf` runs to completion while the calling tab stays active so DOM-based builders that rely
|
|
198
|
+
* on `requestAnimationFrame` are not stalled by a backgrounded placeholder tab. The completed PDF
|
|
199
|
+
* object URL is then opened in `_blank`. If opening is blocked or throws, the PDF is downloaded
|
|
200
|
+
* instead and the current application page stays in place. Generation errors are rethrown for the
|
|
201
|
+
* application to present with its own UI.
|
|
202
|
+
*
|
|
203
|
+
* @remarks Browser-only. Do not call during server-side rendering. Call from a user gesture when
|
|
204
|
+
* possible; after an `await`, browsers may still block the preview window and trigger the download
|
|
205
|
+
* fallback.
|
|
192
206
|
*/
|
|
193
207
|
declare const kitPreviewGeneratedPdf: (buildPdf: () => Promise<Uint8Array>, options: KitPreviewGeneratedPdfOptions) => Promise<void>;
|
|
194
208
|
|