@rdlabo/ionic-angular-kit 21.2.0-3 → 21.2.0-5

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rdlabo/ionic-angular-kit",
3
- "version": "21.2.0-3",
3
+ "version": "21.2.0-5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/rdlabo-team/ionic-angular-library.git"
@@ -24,6 +24,7 @@
24
24
  "@capacitor-community/apple-sign-in": "*",
25
25
  "@rdlabo/capacitor-brotherprint": ">=6.0.0 <9.0.0",
26
26
  "dom-to-image-more": "^3.0.0",
27
+ "pdf-lib": "^1.17.1",
27
28
  "firebase": ">=11 <13",
28
29
  "rxjs": "^7.8.0"
29
30
  },
@@ -54,6 +55,9 @@
54
55
  },
55
56
  "dom-to-image-more": {
56
57
  "optional": true
58
+ },
59
+ "pdf-lib": {
60
+ "optional": true
57
61
  }
58
62
  },
59
63
  "dependencies": {
@@ -77,5 +77,71 @@ interface KitBrotherPrintSettingsParams {
77
77
  */
78
78
  declare const kitBuildBrotherPrintSettings: (params: KitBrotherPrintSettingsParams) => BRLMPrintOptions;
79
79
 
80
- export { kitBuildBrotherPrintSettings, kitDomToPng, kitRotationImage };
81
- export type { KitBrotherPrintSettingsParams, KitDomToPngOptions };
80
+ /** Physical paper dimensions used to build a PDF page. */
81
+ interface KitPrintPaper {
82
+ /** Human-readable paper name. */
83
+ readonly label: string;
84
+ /** Paper width in millimetres. */
85
+ readonly widthMm: number;
86
+ /** Paper height in millimetres. */
87
+ readonly heightMm: number;
88
+ }
89
+ /** Standard paper presets shared by the printing applications. */
90
+ declare const kitPrintPaperSizes: {
91
+ readonly a4: {
92
+ readonly label: "A4";
93
+ readonly widthMm: 210;
94
+ readonly heightMm: 297;
95
+ };
96
+ readonly b5: {
97
+ readonly label: "B5";
98
+ readonly widthMm: 182;
99
+ readonly heightMm: 257;
100
+ };
101
+ };
102
+ /** A position for one label on a PDF page, expressed in PDF points. */
103
+ interface KitPrintPosition {
104
+ readonly pageIndex: number;
105
+ readonly x: number;
106
+ readonly y: number;
107
+ }
108
+ /** Calculated PDF page and label dimensions. */
109
+ interface KitPrintLayout {
110
+ readonly paperWidth: number;
111
+ readonly paperHeight: number;
112
+ readonly labelWidth: number;
113
+ readonly labelHeight: number;
114
+ readonly positions: readonly KitPrintPosition[];
115
+ }
116
+ /** Optional physical size override for a label. */
117
+ interface KitPrintMeasure {
118
+ readonly type: 'width' | 'height';
119
+ readonly sizeMm: number;
120
+ }
121
+ /** Parameters for {@link kitCalculatePrintLayout}. */
122
+ interface KitCalculatePrintLayoutParams {
123
+ readonly paper: KitPrintPaper;
124
+ readonly labelWidthPx: number;
125
+ readonly labelHeightPx: number;
126
+ readonly copies: number;
127
+ readonly measure?: KitPrintMeasure | null;
128
+ /** Outer page margin in millimetres. Defaults to 5mm. */
129
+ readonly marginMm?: number;
130
+ }
131
+ /**
132
+ * Calculate page dimensions and row-major label positions for a printable PDF.
133
+ *
134
+ * Labels keep their aspect ratio, are never enlarged beyond their requested pixel/physical size,
135
+ * and automatically continue on additional pages when the current page is full.
136
+ */
137
+ declare const kitCalculatePrintLayout: (params: KitCalculatePrintLayoutParams) => KitPrintLayout;
138
+ /** Parameters for {@link kitBuildLabelPdf}. */
139
+ interface KitBuildLabelPdfParams extends KitCalculatePrintLayoutParams {
140
+ /** PNG label artwork as a data URL or base64 string accepted by pdf-lib. */
141
+ readonly imageData: string;
142
+ }
143
+ /** Build a multi-page label PDF and return its bytes without choosing an output destination. */
144
+ declare const kitBuildLabelPdf: (params: KitBuildLabelPdfParams) => Promise<Uint8Array>;
145
+
146
+ export { kitBuildBrotherPrintSettings, kitBuildLabelPdf, kitCalculatePrintLayout, kitDomToPng, kitPrintPaperSizes, kitRotationImage };
147
+ export type { KitBrotherPrintSettingsParams, KitBuildLabelPdfParams, KitCalculatePrintLayoutParams, KitDomToPngOptions, KitPrintLayout, KitPrintMeasure, KitPrintPaper, KitPrintPosition };
@@ -591,6 +591,70 @@ declare class KitReloadAlertController {
591
591
  static ɵprov: i0.ɵɵInjectableDeclaration<KitReloadAlertController>;
592
592
  }
593
593
 
594
+ /**
595
+ * Content for {@link KitMaintenanceController.present}.
596
+ */
597
+ interface KitMaintenanceOptions {
598
+ /** Alert header, e.g. "メンテナンス中です". */
599
+ header: string;
600
+ /** Alert body; keep short — the user cannot dismiss until maintenance ends. */
601
+ message: string;
602
+ /**
603
+ * Absolute URL of the fleet maintenance wait SSE (`GET /public/maintenance/wait`).
604
+ *
605
+ * @remarks
606
+ * Typically `environment.api + 'public/maintenance/wait'`. While the overlay is shown the
607
+ * controller opens an {@link EventSource} on this URL and dismisses on `event: ended`.
608
+ */
609
+ waitUrl: string;
610
+ }
611
+ /**
612
+ * Singleton "maintenance lock" overlay: backdrop-locked, no dismiss buttons, auto-clears via SSE.
613
+ *
614
+ * @remarks
615
+ * Mirrors {@link KitReloadAlertController} as a de-duped stateful controller, but the user cannot
616
+ * cancel or reload out of it — only the server `event: ended` on {@link KitMaintenanceOptions.waitUrl}
617
+ * (or an explicit {@link dismiss}) clears it. Uses Ionic's `AlertController` (not a feature modal)
618
+ * so the kit stays free of page components / i18n; all copy is supplied by the caller.
619
+ *
620
+ * Wire from {@link KitHttpConfig.onMaintenance} when the API returns `503` with
621
+ * `error.error?.code === 'MAINTENANCE'`.
622
+ *
623
+ * @example
624
+ * ```ts
625
+ * provideKitHttp(() => {
626
+ * const maintenance = inject(KitMaintenanceController);
627
+ * return {
628
+ * getAuthHeaders: async () => ({}),
629
+ * onMaintenance: () =>
630
+ * void maintenance.present({
631
+ * header: 'メンテナンス中です',
632
+ * message: 'しばらくお待ちください。終了次第、自動で閉じます。',
633
+ * waitUrl: environment.api + 'public/maintenance/wait',
634
+ * }),
635
+ * };
636
+ * });
637
+ * ```
638
+ */
639
+ declare class KitMaintenanceController {
640
+ #private;
641
+ /**
642
+ * Present the lock overlay and start waiting on the maintenance SSE, unless one is already showing.
643
+ *
644
+ * @param options - overlay copy plus the wait SSE URL
645
+ */
646
+ present(options: KitMaintenanceOptions): Promise<void>;
647
+ /**
648
+ * Dismiss the tracked overlay and tear down the wait SSE.
649
+ *
650
+ * @remarks
651
+ * Normally called when the wait stream emits `ended`. A no-op when nothing is showing.
652
+ */
653
+ dismiss(): Promise<void>;
654
+ static ɵfac: i0.ɵɵFactoryDeclaration<KitMaintenanceController, never>;
655
+ static ɵprov: i0.ɵɵInjectableDeclaration<KitMaintenanceController>;
656
+ }
657
+
594
658
  /**
595
659
  * Content for {@link kitPresentAuthFailedAlert}.
596
660
  */
@@ -969,6 +1033,17 @@ declare const kitRequireConfirmingGuard: CanActivateFn;
969
1033
  */
970
1034
  declare const kitRequireAuthorizedGuard: CanActivateFn;
971
1035
 
1036
+ /**
1037
+ * True when the error is the fleet maintenance short-circuit (`503` + body `code: 'MAINTENANCE'`).
1038
+ *
1039
+ * @remarks
1040
+ * Matches Angular `HttpErrorResponse` as `error.error?.code === 'MAINTENANCE'` (body top-level
1041
+ * `code`). Must not be retried and must not fall through to {@link KitHttpConfig.onServerBusy}.
1042
+ *
1043
+ * @param error - The failed response.
1044
+ * @returns Whether this is a maintenance response.
1045
+ */
1046
+ declare const isMaintenanceError: (error: HttpErrorResponse) => boolean;
972
1047
  /**
973
1048
  * Configuration that customizes the behavior of {@link kitAuthInterceptor}, injected through {@link provideKitHttp}.
974
1049
  *
@@ -1090,12 +1165,22 @@ interface KitHttpConfig {
1090
1165
  * @remarks
1091
1166
  * Optional; defaults to a no-op. Distinct from {@link KitHttpConfig.onNetworkError} — the device's
1092
1167
  * connection is fine, the server is momentarily unavailable — so the app can say "server busy, try
1093
- * again shortly" rather than prompt a reload.
1168
+ * again shortly" rather than prompt a reload. **Not** called for fleet maintenance (`503` with
1169
+ * `error.error?.code === 'MAINTENANCE'`) — that uses {@link KitHttpConfig.onMaintenance}.
1094
1170
  *
1095
1171
  * @param status - `502`, `503`, or `504`.
1096
1172
  * @param retryAfterSeconds - The server's `Retry-After` hint in seconds, when provided.
1097
1173
  */
1098
1174
  onServerBusy?(status: number, retryAfterSeconds?: number): void;
1175
+ /**
1176
+ * UX hook for fleet maintenance: HTTP `503` whose body has `code: 'MAINTENANCE'`.
1177
+ *
1178
+ * @remarks
1179
+ * Optional; defaults to a no-op. Fired **without retries** (maintenance is intentional, not
1180
+ * transient). Wire to {@link KitMaintenanceController.present} with the wait SSE URL so the lock
1181
+ * overlay auto-dismisses when maintenance ends.
1182
+ */
1183
+ onMaintenance?(): void;
1099
1184
  /**
1100
1185
  * UX hook for a `429 Too Many Requests` response, fired after retries are exhausted.
1101
1186
  *
@@ -1180,8 +1265,8 @@ declare const provideKitHttp: (configFactory: () => KitHttpConfig) => Environmen
1180
1265
  * When the device is offline it stops retrying immediately.
1181
1266
  * 5. On the final error, `offlineFallback` is consulted first; otherwise the error is classified by
1182
1267
  * status (see {@link dispatchError}): `401`→`onUnauthorized`, `403`→`onForbidden`, `0`→
1183
- * `onNetworkError` (when connected), `429`→`onRateLimited`, `502`/`503`/`504`→`onServerBusy`, and
1184
- * `400`/`422`/`500` with a body message→`onServerError`.
1268
+ * `onNetworkError` (when connected), `429`→`onRateLimited`, maintenance `503`→`onMaintenance`,
1269
+ * other `502`/`503`/`504`→`onServerBusy`, and `400`/`422`/`500` with a body message→`onServerError`.
1185
1270
  *
1186
1271
  * @param request - The outgoing request.
1187
1272
  * @param next - The next handler in the interceptor chain.
@@ -1364,5 +1449,5 @@ declare const kitChangeEventDisabled: (completeEvent: WritableSignal<HTMLIonInfi
1364
1449
  */
1365
1450
  declare const kitCreateDidEnter: (el: ElementRef) => Observable<boolean>;
1366
1451
 
1367
- export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KIT_THEME_STORAGE_KEY, KitAuthInputDirective, KitLoadingController, KitOverlayController, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay };
1368
- export type { KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthInputMode, KitAuthRedirects, KitAuthState, KitClearableStore, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitModalPresentOptions, KitOverlayConfig, KitReloadAlertOptions, ModalMetadata };
1452
+ export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_LAST_AUTH_EMAIL_KEY, KIT_OVERLAY_CONFIG, KIT_THEME_STORAGE_KEY, KitAuthInputDirective, KitLoadingController, KitMaintenanceController, KitOverlayController, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, isMaintenanceError, kitAuthInterceptor, kitChangeEventDisabled, kitClearStoragePreservingKeys, kitCreateDidEnter, kitForgetEmail, kitImpact, kitIsValidEmail, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRecallEmail, kitRememberEmail, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay };
1453
+ export type { KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthInputMode, KitAuthRedirects, KitAuthState, KitClearableStore, KitEmailStore, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitMaintenanceOptions, KitModalPresentOptions, KitOverlayConfig, KitReloadAlertOptions, ModalMetadata };