@rdlabo/ionic-angular-kit 0.0.13 → 0.0.15
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 +16 -10
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs +146 -0
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-kit-review.mjs +48 -0
- package/fesm2022/rdlabo-ionic-angular-kit-review.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-kit-theme.mjs +163 -0
- package/fesm2022/rdlabo-ionic-angular-kit-theme.mjs.map +1 -0
- package/fesm2022/rdlabo-ionic-angular-kit.mjs +122 -349
- package/fesm2022/rdlabo-ionic-angular-kit.mjs.map +1 -1
- package/package.json +30 -1
- package/types/rdlabo-ionic-angular-kit-printer.d.ts +81 -0
- package/types/rdlabo-ionic-angular-kit-review.d.ts +45 -0
- package/types/rdlabo-ionic-angular-kit-theme.d.ts +116 -0
- package/types/rdlabo-ionic-angular-kit.d.ts +144 -239
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import * as i0 from '@angular/core';
|
|
2
|
-
import { InjectionToken, EnvironmentProviders, OnInit, ElementRef, WritableSignal } from '@angular/core';
|
|
3
|
-
import { ModalOptions, PopoverOptions, ToastOptions, AlertController, ActionSheetController } from '@ionic/angular/standalone';
|
|
2
|
+
import { InjectionToken, EnvironmentProviders, InputSignalWithTransform, OnInit, ElementRef, WritableSignal } from '@angular/core';
|
|
3
|
+
import { ModalOptions, PopoverOptions, ToastOptions, LoadingOptions, AlertController, ActionSheetController } from '@ionic/angular/standalone';
|
|
4
4
|
import { PluginListenerHandle } from '@capacitor/core';
|
|
5
|
-
import { BehaviorSubject, Observable } from 'rxjs';
|
|
6
|
-
import { BRLMPrinterModelName, BRLMPrinterLabelName, BRLMPrintOptions } from '@rdlabo/capacitor-brotherprint';
|
|
7
5
|
import { RouterStateSnapshot, UrlTree, CanActivateFn } from '@angular/router';
|
|
6
|
+
import { Observable } from 'rxjs';
|
|
8
7
|
import { HttpRequest, HttpResponse, HttpErrorResponse, HttpEvent, HttpInterceptorFn } from '@angular/common/http';
|
|
9
8
|
import { ImpactStyle } from '@capacitor/haptics';
|
|
10
9
|
|
|
@@ -143,6 +142,83 @@ interface KitModalPresentOptions extends Omit<ModalOptions, 'component' | 'compo
|
|
|
143
142
|
*/
|
|
144
143
|
watchKeyboard?: boolean;
|
|
145
144
|
}
|
|
145
|
+
/**
|
|
146
|
+
* Optional static metadata a modal component may declare to make {@link KitOverlayController.presentModal}
|
|
147
|
+
* type-safe in its dismiss data: the value passed to `dismiss()` is inferred from `modalReturn`.
|
|
148
|
+
*
|
|
149
|
+
* @remarks
|
|
150
|
+
* Props do *not* need to be declared here — {@link KitOverlayController.presentModal} infers them directly
|
|
151
|
+
* from the component's `input()` fields (see {@link ModalPropsOf}), so `input()` stays the single source of
|
|
152
|
+
* truth and can never drift from a hand-written declaration. Only the dismiss-data shape, which has no
|
|
153
|
+
* counterpart on the component, is declared — as a `declare static modalReturn` phantom type with no runtime
|
|
154
|
+
* value, so it adds nothing to the bundle.
|
|
155
|
+
*
|
|
156
|
+
* @example
|
|
157
|
+
* ```ts
|
|
158
|
+
* export class EditPage {
|
|
159
|
+
* declare static modalReturn: { saved: boolean };
|
|
160
|
+
* readonly id = input.required<number>(); // props are inferred from here
|
|
161
|
+
* readonly note = input<string>(); // default-less input() → optional prop
|
|
162
|
+
* }
|
|
163
|
+
*
|
|
164
|
+
* // Caller — `id` is required (input.required), `note` optional; result is `{ saved: boolean } | undefined`:
|
|
165
|
+
* const result = await overlay.presentModal(EditPage, { id: 1 });
|
|
166
|
+
* ```
|
|
167
|
+
*/
|
|
168
|
+
interface ModalMetadata<R = unknown> {
|
|
169
|
+
/** Shape of the data the modal resolves with when dismissed. */
|
|
170
|
+
modalReturn?: R;
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Write type of a signal `input()` field (unwraps `input.required`, `input()` and transform inputs).
|
|
174
|
+
*
|
|
175
|
+
* @remarks
|
|
176
|
+
* Matched with `any` (not `unknown`): `InputSignalWithTransform`'s `TransformT` is contravariant, so
|
|
177
|
+
* `InputSignal<number>` is not assignable to `InputSignalWithTransform<unknown, unknown>`.
|
|
178
|
+
*/
|
|
179
|
+
type InputWriteType<F> = F extends InputSignalWithTransform<any, infer W> ? W : never;
|
|
180
|
+
/** Instance type of a component constructor; `never` for non-class components (string / HTMLElement refs). */
|
|
181
|
+
type InstanceOf<C> = C extends abstract new (...args: never[]) => infer I ? I : never;
|
|
182
|
+
/** Keys of the `input()` signal fields on a component instance. */
|
|
183
|
+
type InputFieldKeys<I> = {
|
|
184
|
+
[K in keyof I]-?: I[K] extends InputSignalWithTransform<any, any> ? K : never;
|
|
185
|
+
}[keyof I];
|
|
186
|
+
/**
|
|
187
|
+
* Props object inferred from a component's `input()` fields. Required vs. optional is decided by the write
|
|
188
|
+
* type: `input.required<T>()` / `input<T>(default)` yield `T` (no `undefined`) → required prop, while a
|
|
189
|
+
* default-less `input<T>()` yields `T | undefined` → optional prop.
|
|
190
|
+
*
|
|
191
|
+
* @remarks
|
|
192
|
+
* Angular's types cannot distinguish `input.required<T>()` from a defaulted `input<T>(default)` — both are
|
|
193
|
+
* `InputSignal<T>` — so a defaulted input is (safely) treated as required. Declare inputs you want to omit at
|
|
194
|
+
* the call site as default-less `input<T>()`.
|
|
195
|
+
*/
|
|
196
|
+
type ModalPropsOf<I> = {
|
|
197
|
+
[K in InputFieldKeys<I> as undefined extends InputWriteType<I[K]> ? never : K]: InputWriteType<I[K]>;
|
|
198
|
+
} & {
|
|
199
|
+
[K in InputFieldKeys<I> as undefined extends InputWriteType<I[K]> ? K : never]?: InputWriteType<I[K]>;
|
|
200
|
+
};
|
|
201
|
+
/** `input()` keys whose write type excludes `undefined` (required / defaulted inputs). Empty when none. */
|
|
202
|
+
type RequiredInputKeys<I> = {
|
|
203
|
+
[K in InputFieldKeys<I>]: undefined extends InputWriteType<I[K]> ? never : K;
|
|
204
|
+
}[InputFieldKeys<I>];
|
|
205
|
+
/**
|
|
206
|
+
* Dismiss-data type inferred from a component's static {@link ModalMetadata.modalReturn}. A component that
|
|
207
|
+
* declares no `modalReturn` resolves to `void`: it is treated as returning no dismiss data, so the compiler
|
|
208
|
+
* rejects any attempt to read the result. Declare `modalReturn` on modals that do resolve with data.
|
|
209
|
+
*/
|
|
210
|
+
type ModalReturnOf<C> = C extends {
|
|
211
|
+
modalReturn: infer R;
|
|
212
|
+
} ? R : void;
|
|
213
|
+
/** Loose trailing args (optional, untyped props) — used when a component exposes no signal `input()` fields. */
|
|
214
|
+
type LooseModalPresentArgs = [componentProps?: ModalOptions['componentProps'], options?: KitModalPresentOptions];
|
|
215
|
+
/**
|
|
216
|
+
* Trailing `presentModal` args derived from a component's `input()` fields: props are inferred and typed via
|
|
217
|
+
* {@link ModalPropsOf}. When the component declares at least one required input the props argument is required;
|
|
218
|
+
* when every input is optional the props argument itself is optional. Components with no signal inputs (plain
|
|
219
|
+
* classes, `@Input()`-decorator components, or non-class refs) fall back to loose, untyped props.
|
|
220
|
+
*/
|
|
221
|
+
type ModalPresentArgs<C, I = InstanceOf<C>> = [I] extends [never] ? LooseModalPresentArgs : [InputFieldKeys<I>] extends [never] ? LooseModalPresentArgs : [RequiredInputKeys<I>] extends [never] ? [componentProps?: ModalPropsOf<I>, options?: KitModalPresentOptions] : [componentProps: ModalPropsOf<I>, options?: KitModalPresentOptions];
|
|
146
222
|
/**
|
|
147
223
|
* Options for {@link KitOverlayController.alertClose}.
|
|
148
224
|
*/
|
|
@@ -182,7 +258,7 @@ interface KitAlertConfirmOptions extends KitAlertCloseOptions {
|
|
|
182
258
|
* constructor(private readonly overlay: KitOverlayController) {}
|
|
183
259
|
*
|
|
184
260
|
* async edit(): Promise<void> {
|
|
185
|
-
* const result = await this.overlay.presentModal
|
|
261
|
+
* const result = await this.overlay.presentModal(EditPage, { id: 1 });
|
|
186
262
|
* if (result) {
|
|
187
263
|
* await this.overlay.presentToast({ message: 'Saved' });
|
|
188
264
|
* }
|
|
@@ -202,12 +278,18 @@ declare class KitOverlayController {
|
|
|
202
278
|
* @remarks
|
|
203
279
|
* Presenting a modal triggers light native haptic feedback as an intentional kit UX choice,
|
|
204
280
|
* consistent with {@link presentPopover} and {@link presentToast}.
|
|
281
|
+
*
|
|
282
|
+
* Props are inferred from the component's `input()` fields (see {@link ModalPropsOf}): required inputs
|
|
283
|
+
* become required props, so the compiler rejects a call that omits them. The return type is inferred from
|
|
284
|
+
* a static `modalReturn` (see {@link ModalMetadata}); a component with no `modalReturn` resolves to `void`
|
|
285
|
+
* — the modal is treated as returning no dismiss data.
|
|
205
286
|
* @example
|
|
206
287
|
* ```ts
|
|
207
|
-
*
|
|
288
|
+
* // Inferred — `id` required (input.required), `note` optional; result is `{ saved: boolean } | undefined`:
|
|
289
|
+
* const result = await overlay.presentModal(EditPage, { id: 1 });
|
|
208
290
|
* ```
|
|
209
291
|
*/
|
|
210
|
-
presentModal<
|
|
292
|
+
presentModal<C extends ModalOptions['component']>(component: C, ...args: ModalPresentArgs<C>): Promise<ModalReturnOf<C> | undefined>;
|
|
211
293
|
/**
|
|
212
294
|
* Present a popover and resolve with the data passed to its dismissal.
|
|
213
295
|
*
|
|
@@ -287,6 +369,59 @@ declare class KitOverlayController {
|
|
|
287
369
|
static ɵprov: i0.ɵɵInjectableDeclaration<KitOverlayController>;
|
|
288
370
|
}
|
|
289
371
|
|
|
372
|
+
/**
|
|
373
|
+
* Reference-counted wrapper around Ionic's `LoadingController` that keeps at most one loading
|
|
374
|
+
* indicator on screen across concurrent async work.
|
|
375
|
+
*
|
|
376
|
+
* @remarks
|
|
377
|
+
* Each {@link presentLoading} increments a counter and each {@link dismissLoading} decrements it; the
|
|
378
|
+
* indicator is presented on the `0 → 1` transition and dismissed on the `N → 0` transition. This
|
|
379
|
+
* removes the flicker / "stuck spinner" bugs that come from every service calling
|
|
380
|
+
* `LoadingController.create/dismiss` independently.
|
|
381
|
+
*
|
|
382
|
+
* All operations are serialized through an internal promise chain, so a `create → present` sequence
|
|
383
|
+
* can never interleave with a concurrent `dismiss`. That is what makes the counter race-safe: a
|
|
384
|
+
* dismiss that arrives while the indicator is still being presented runs *after* `present()` settles
|
|
385
|
+
* and therefore tears the element down instead of leaving it orphaned on screen.
|
|
386
|
+
*
|
|
387
|
+
* Always pair every `presentLoading()` with exactly one `dismissLoading()` — a `try/finally` is the
|
|
388
|
+
* safest shape.
|
|
389
|
+
*
|
|
390
|
+
* @example
|
|
391
|
+
* ```ts
|
|
392
|
+
* constructor(private readonly loading: KitLoadingController) {}
|
|
393
|
+
*
|
|
394
|
+
* async save(): Promise<void> {
|
|
395
|
+
* await this.loading.presentLoading({ message: 'Saving…' });
|
|
396
|
+
* try {
|
|
397
|
+
* await this.api.save();
|
|
398
|
+
* } finally {
|
|
399
|
+
* await this.loading.dismissLoading();
|
|
400
|
+
* }
|
|
401
|
+
* }
|
|
402
|
+
* ```
|
|
403
|
+
*/
|
|
404
|
+
declare class KitLoadingController {
|
|
405
|
+
#private;
|
|
406
|
+
/**
|
|
407
|
+
* Show the loading indicator, or join the one already on screen.
|
|
408
|
+
*
|
|
409
|
+
* @param options - Ionic loading options; only applied by the call that actually creates the
|
|
410
|
+
* indicator (the `0 → 1` transition). Ignored while an indicator is already present.
|
|
411
|
+
* @returns a Promise that resolves once the indicator is on screen (or immediately when one already is)
|
|
412
|
+
*/
|
|
413
|
+
presentLoading(options?: LoadingOptions): Promise<void>;
|
|
414
|
+
/**
|
|
415
|
+
* Release one reference; dismiss the indicator once the last reference is gone.
|
|
416
|
+
*
|
|
417
|
+
* @returns a Promise that resolves once the reference is released (and the indicator dismissed if
|
|
418
|
+
* this was the last one). No-ops when the counter is already at zero.
|
|
419
|
+
*/
|
|
420
|
+
dismissLoading(): Promise<void>;
|
|
421
|
+
static ɵfac: i0.ɵɵFactoryDeclaration<KitLoadingController, never>;
|
|
422
|
+
static ɵprov: i0.ɵɵInjectableDeclaration<KitLoadingController>;
|
|
423
|
+
}
|
|
424
|
+
|
|
290
425
|
/**
|
|
291
426
|
* Content for {@link KitReloadAlertController.present}.
|
|
292
427
|
*/
|
|
@@ -550,236 +685,6 @@ type KitKeyboardAdjust = 'transform' | 'offset' | 'keyboard-offset';
|
|
|
550
685
|
*/
|
|
551
686
|
declare const kitKeyboardInit: (elementRef: ElementRef, type: KitKeyboardAdjust) => Promise<PluginListenerHandle[]>;
|
|
552
687
|
|
|
553
|
-
/**
|
|
554
|
-
* Theme configuration injected via `provideKitTheme()` and consumed by `KitThemeController`.
|
|
555
|
-
*
|
|
556
|
-
* @remarks
|
|
557
|
-
* All fields are required; the consuming application supplies a complete configuration so every app
|
|
558
|
-
* in the fleet has the same shape. The class lists absorb the per-app CSS drift: the kit toggles
|
|
559
|
-
* `darkClasses` on when dark and `lightClasses` on when light, so an app that only uses Ionic's
|
|
560
|
-
* palette passes `darkClasses: ['ion-palette-dark'], lightClasses: []`, while an app with an extra
|
|
561
|
-
* design-system palette adds its own classes (e.g. `darkClasses: ['ion-palette-dark', 'a2ui-dark']`,
|
|
562
|
-
* `lightClasses: ['a2ui-light']`).
|
|
563
|
-
*/
|
|
564
|
-
interface KitThemeConfig {
|
|
565
|
-
/** Key under which the chosen theme (`'light'` | `'dark'`) is persisted via `KitStorageService`. */
|
|
566
|
-
readonly storageKey: string;
|
|
567
|
-
/** Classes toggled **on** the document element when the dark theme is active. */
|
|
568
|
-
readonly darkClasses: readonly string[];
|
|
569
|
-
/** Classes toggled **on** the document element when the light theme is active. */
|
|
570
|
-
readonly lightClasses: readonly string[];
|
|
571
|
-
}
|
|
572
|
-
/**
|
|
573
|
-
* Injection token carrying the {@link KitThemeConfig} for `KitThemeController`.
|
|
574
|
-
*
|
|
575
|
-
* @remarks
|
|
576
|
-
* Provide it through {@link provideKitTheme} rather than registering it directly.
|
|
577
|
-
*/
|
|
578
|
-
declare const KIT_THEME_CONFIG: InjectionToken<KitThemeConfig>;
|
|
579
|
-
/**
|
|
580
|
-
* Wire `KitThemeController` into the application.
|
|
581
|
-
*
|
|
582
|
-
* @param config - theme configuration: the storage key and the light/dark class lists
|
|
583
|
-
* @returns environment providers to add to the application's provider list
|
|
584
|
-
* @example
|
|
585
|
-
* ```ts
|
|
586
|
-
* bootstrapApplication(AppComponent, {
|
|
587
|
-
* providers: [
|
|
588
|
-
* provideKitTheme({
|
|
589
|
-
* storageKey: StorageKeyEnum.theme,
|
|
590
|
-
* darkClasses: ['ion-palette-dark', 'a2ui-dark'],
|
|
591
|
-
* lightClasses: ['a2ui-light'],
|
|
592
|
-
* }),
|
|
593
|
-
* ],
|
|
594
|
-
* });
|
|
595
|
-
* ```
|
|
596
|
-
*/
|
|
597
|
-
declare const provideKitTheme: (config: KitThemeConfig) => EnvironmentProviders;
|
|
598
|
-
|
|
599
|
-
/** The active theme mode. */
|
|
600
|
-
type KitThemeMode = 'light' | 'dark';
|
|
601
|
-
/**
|
|
602
|
-
* Light/dark theme controller: persists the user's choice, follows the OS setting until the user
|
|
603
|
-
* overrides it, toggles the configured palette classes, and syncs the native Android status bar.
|
|
604
|
-
*
|
|
605
|
-
* @remarks
|
|
606
|
-
* Consolidates the theme logic that had drifted across the fleet into one behavior. Notably it fixes
|
|
607
|
-
* a latent leak in one variant where the system-theme listener stayed registered after a manual
|
|
608
|
-
* toggle: {@link changeTheme} always detaches the listener via {@link removeEventListener} before
|
|
609
|
-
* applying the forced theme, so a later OS change can no longer silently flip an app the user pinned.
|
|
610
|
-
*
|
|
611
|
-
* - **Persistence** — the chosen mode is stored via {@link KitStorageService} under the configured key.
|
|
612
|
-
* - **Follow OS until overridden** — on boot with nothing stored, it tracks
|
|
613
|
-
* `prefers-color-scheme` (idempotent registration); once the user calls {@link changeTheme} it stops
|
|
614
|
-
* following and honors the explicit choice.
|
|
615
|
-
* - **Class toggling** — toggles {@link KitThemeConfig.darkClasses} on when dark and
|
|
616
|
-
* {@link KitThemeConfig.lightClasses} on when light, absorbing per-app CSS differences via config.
|
|
617
|
-
* - **Native status bar** — on Android native only, mirrors the Ionic behavior of setting the status
|
|
618
|
-
* bar style to match (iOS derives it from the web content, so it is intentionally left untouched).
|
|
619
|
-
*
|
|
620
|
-
* Subscribe to {@link themeSubject} to reflect the current mode in the UI (e.g. a settings toggle).
|
|
621
|
-
*
|
|
622
|
-
* @example
|
|
623
|
-
* ```ts
|
|
624
|
-
* // On boot (app.component):
|
|
625
|
-
* inject(KitThemeController).setDefaultThemeMode();
|
|
626
|
-
*
|
|
627
|
-
* // From a settings toggle:
|
|
628
|
-
* const theme = inject(KitThemeController);
|
|
629
|
-
* theme.themeSubject.subscribe((mode) => this.isDark.set(mode === 'dark'));
|
|
630
|
-
* theme.changeTheme(true);
|
|
631
|
-
* ```
|
|
632
|
-
*/
|
|
633
|
-
declare class KitThemeController {
|
|
634
|
-
#private;
|
|
635
|
-
/**
|
|
636
|
-
* Emits the active theme, seeded with `'light'`.
|
|
637
|
-
*
|
|
638
|
-
* @remarks
|
|
639
|
-
* A `BehaviorSubject`, so a late subscriber immediately receives the current mode; it emits again
|
|
640
|
-
* on every {@link setDefaultThemeMode} / {@link changeTheme} and on OS theme changes while following.
|
|
641
|
-
*/
|
|
642
|
-
readonly themeSubject: BehaviorSubject<KitThemeMode>;
|
|
643
|
-
/**
|
|
644
|
-
* Apply the persisted theme, or start following the OS setting when nothing is stored yet.
|
|
645
|
-
*
|
|
646
|
-
* @remarks
|
|
647
|
-
* Call once on boot (e.g. from `app.component`).
|
|
648
|
-
*
|
|
649
|
-
* @returns a Promise that resolves once the initial theme has been applied
|
|
650
|
-
*/
|
|
651
|
-
setDefaultThemeMode(): Promise<void>;
|
|
652
|
-
/**
|
|
653
|
-
* Force a theme, persist it, and stop following the OS setting.
|
|
654
|
-
*
|
|
655
|
-
* @param isDark - `true` for the dark theme, `false` for light
|
|
656
|
-
* @returns a Promise that resolves once the theme has been persisted and applied
|
|
657
|
-
*/
|
|
658
|
-
changeTheme(isDark: boolean): Promise<void>;
|
|
659
|
-
static ɵfac: i0.ɵɵFactoryDeclaration<KitThemeController, never>;
|
|
660
|
-
static ɵprov: i0.ɵɵInjectableDeclaration<KitThemeController>;
|
|
661
|
-
}
|
|
662
|
-
|
|
663
|
-
/**
|
|
664
|
-
* Options for {@link kitRequestReview}.
|
|
665
|
-
*/
|
|
666
|
-
interface KitRequestReviewOptions {
|
|
667
|
-
/**
|
|
668
|
-
* Key under which the timestamp of the last review request is stored (via `@capacitor/preferences`).
|
|
669
|
-
*
|
|
670
|
-
* @remarks
|
|
671
|
-
* Supplied by the caller so the kit ships no storage keys of its own; each app passes its own enum
|
|
672
|
-
* value.
|
|
673
|
-
*/
|
|
674
|
-
readonly storageKey: string;
|
|
675
|
-
/**
|
|
676
|
-
* Minimum number of months between review prompts.
|
|
677
|
-
*
|
|
678
|
-
* @remarks
|
|
679
|
-
* A prompt is only shown when this much time has elapsed since the last one (or when there is no
|
|
680
|
-
* record yet), so the OS review dialog is never nagged repeatedly.
|
|
681
|
-
*/
|
|
682
|
-
readonly throttleMonths: number;
|
|
683
|
-
}
|
|
684
|
-
/**
|
|
685
|
-
* Request the native in-app review dialog, throttled so the user is prompted at most once per window.
|
|
686
|
-
*
|
|
687
|
-
* @remarks
|
|
688
|
-
* A plain function — no DI needed (`@capacitor/preferences`, `@capacitor-community/in-app-review` and
|
|
689
|
-
* `Capacitor` are all static), so the caller invokes it directly and passes its own config rather
|
|
690
|
-
* than injecting a controller. A no-op on non-native platforms. When enough time has elapsed since
|
|
691
|
-
* the last prompt (per {@link KitRequestReviewOptions.throttleMonths}, tracked under
|
|
692
|
-
* {@link KitRequestReviewOptions.storageKey}), it briefly waits for the app to settle, calls
|
|
693
|
-
* `InAppReview.requestReview()`, and records the new timestamp. The wait/throttle/record sequence
|
|
694
|
-
* was previously copy-pasted verbatim across the fleet; centralizing it means a single place to tune
|
|
695
|
-
* the prompt cadence.
|
|
696
|
-
*
|
|
697
|
-
* @param options - the storage key and throttle window; see {@link KitRequestReviewOptions}
|
|
698
|
-
* @returns a Promise that resolves once the request has been made (or immediately if throttled / on web)
|
|
699
|
-
* @example
|
|
700
|
-
* ```ts
|
|
701
|
-
* await kitRequestReview({ storageKey: StorageEnum.lastRequestRate, throttleMonths: 3 });
|
|
702
|
-
* ```
|
|
703
|
-
*/
|
|
704
|
-
declare const kitRequestReview: (options: KitRequestReviewOptions) => Promise<void>;
|
|
705
|
-
|
|
706
|
-
/**
|
|
707
|
-
* Rotate a base64 image 90°, returning a new base64 data URL of the same MIME type.
|
|
708
|
-
*
|
|
709
|
-
* @remarks
|
|
710
|
-
* Pure DOM/canvas work — no DI. Used before sending a label to the printer when the artwork must be
|
|
711
|
-
* turned to match the tape orientation. Extracted verbatim from the fleet's printer services so the
|
|
712
|
-
* canvas handling lives in one place.
|
|
713
|
-
*
|
|
714
|
-
* @param imageData - a base64 data URL (e.g. `data:image/png;base64,...`)
|
|
715
|
-
* @returns a Promise resolving to the rotated image as a base64 data URL
|
|
716
|
-
*/
|
|
717
|
-
declare const kitRotationImage: (imageData: string) => Promise<string>;
|
|
718
|
-
/** Options for {@link kitDomToPng}. */
|
|
719
|
-
interface KitDomToPngOptions {
|
|
720
|
-
/** When `true`, the rendered PNG is rotated 90° via {@link kitRotationImage}. Defaults to `false`. */
|
|
721
|
-
readonly rotate?: boolean;
|
|
722
|
-
/** Rendering scale passed to `dom-to-image-more`. Defaults to `3` (the fleet's print resolution). */
|
|
723
|
-
readonly scale?: number;
|
|
724
|
-
}
|
|
725
|
-
/**
|
|
726
|
-
* Render a DOM element to a base64 PNG for label printing, with the fleet's device-specific fixes.
|
|
727
|
-
*
|
|
728
|
-
* @remarks
|
|
729
|
-
* Pure function — no DI (reads the platform from `Capacitor`, uses the global `document`), so the
|
|
730
|
-
* caller presents its own loading UI around it. Centralizes the hard-won device quirks: on iOS it
|
|
731
|
-
* pads width/height by 2px (otherwise the bottom is clipped), on Android it does not (the padding
|
|
732
|
-
* introduces a black line). Retries the `dom-to-image-more` render up to 10 times because the first
|
|
733
|
-
* pass can occasionally return empty. This is exactly the kind of plumbing where a future fix should
|
|
734
|
-
* land in every app at once.
|
|
735
|
-
*
|
|
736
|
-
* @param element - the element to rasterize (e.g. the label preview host)
|
|
737
|
-
* @param options - rendering options; see {@link KitDomToPngOptions}
|
|
738
|
-
* @returns a Promise resolving to the PNG as a base64 data URL (empty string if every attempt failed)
|
|
739
|
-
* @example
|
|
740
|
-
* ```ts
|
|
741
|
-
* const loading = await this.#loadingCtrl.create({ message: this.text.generating });
|
|
742
|
-
* await loading.present();
|
|
743
|
-
* const png = await kitDomToPng(this.preview().nativeElement, { rotate: true });
|
|
744
|
-
* await loading.dismiss();
|
|
745
|
-
* ```
|
|
746
|
-
*/
|
|
747
|
-
declare const kitDomToPng: (element: HTMLElement, options?: KitDomToPngOptions) => Promise<string>;
|
|
748
|
-
/** Parameters for {@link kitBuildBrotherPrintSettings}. */
|
|
749
|
-
interface KitBrotherPrintSettingsParams {
|
|
750
|
-
/** The target printer model. */
|
|
751
|
-
readonly modelName: BRLMPrinterModelName;
|
|
752
|
-
/** The label artwork as a base64 data URL (the `data:...,` prefix is stripped internally). */
|
|
753
|
-
readonly printBase64: string;
|
|
754
|
-
/** The selected label/paper (its `W<width>H<height>` code drives the tape dimensions). */
|
|
755
|
-
readonly label: BRLMPrinterLabelName;
|
|
756
|
-
/** Number of copies to print. Passed by the caller (apps differ: some use the print option, some fix 1). */
|
|
757
|
-
readonly numberOfCopies: number;
|
|
758
|
-
/** Halftone threshold for the print. */
|
|
759
|
-
readonly halftoneThreshold: number;
|
|
760
|
-
}
|
|
761
|
-
/**
|
|
762
|
-
* Assemble the Brother `BRLMPrintOptions` for a die-cut label print, minus the transport fields.
|
|
763
|
-
*
|
|
764
|
-
* @remarks
|
|
765
|
-
* Pure function — no DI. Centralizes the fleet's canonical print settings (fit-page scale, centered,
|
|
766
|
-
* best quality, threshold halftone, 2mm/1mm margins, `gapLength` 2.0) and the tape sizing derived
|
|
767
|
-
* from the label's `W<width>H<height>` code. The caller merges the printer's `port` / `channelInfo`
|
|
768
|
-
* onto the result before calling `BrotherPrint.printImage()`, so channel selection and loading UI stay
|
|
769
|
-
* in the app.
|
|
770
|
-
*
|
|
771
|
-
* @param params - model, artwork, label, copies, and halftone threshold; see {@link KitBrotherPrintSettingsParams}
|
|
772
|
-
* @returns the `BRLMPrintOptions` ready to be spread with `{ port, channelInfo }`
|
|
773
|
-
* @example
|
|
774
|
-
* ```ts
|
|
775
|
-
* const settings = kitBuildBrotherPrintSettings({
|
|
776
|
-
* modelName, printBase64, label, numberOfCopies: printOptions.printNum, halftoneThreshold: printOptions.halftoneThreshold,
|
|
777
|
-
* });
|
|
778
|
-
* await BrotherPrint.printImage({ ...settings, port: channel.port, channelInfo: channel.channelInfo });
|
|
779
|
-
* ```
|
|
780
|
-
*/
|
|
781
|
-
declare const kitBuildBrotherPrintSettings: (params: KitBrotherPrintSettingsParams) => BRLMPrintOptions;
|
|
782
|
-
|
|
783
688
|
/**
|
|
784
689
|
* Discriminated set of authentication states the guards react to.
|
|
785
690
|
*
|
|
@@ -1331,5 +1236,5 @@ declare const kitChangeEventDisabled: (completeEvent: WritableSignal<HTMLIonInfi
|
|
|
1331
1236
|
*/
|
|
1332
1237
|
declare const kitCreateDidEnter: (el: ElementRef) => Observable<boolean>;
|
|
1333
1238
|
|
|
1334
|
-
export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_OVERLAY_CONFIG,
|
|
1335
|
-
export type { KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthRedirects, KitAuthState,
|
|
1239
|
+
export { KIT_AUTH_CONFIG, KIT_HTTP_CONFIG, KIT_OVERLAY_CONFIG, KitAutofillDirective, KitLoadingController, KitOverlayController, KitReloadAlertController, KitStorageService, arrayConcatById, disableHandler, kitAuthInterceptor, kitChangeEventDisabled, kitCreateDidEnter, kitImpact, kitKeyboardInit, kitPresentAuthFailedAlert, kitPresentLanguageActionSheet, kitRequireAuthorizedGuard, kitRequireConfirmingGuard, kitRequiredUnauthorizedGuard, objectEqual, provideKitAuth, provideKitHttp, provideKitOverlay };
|
|
1240
|
+
export type { KitAlertCloseOptions, KitAlertConfirmOptions, KitAuthConfig, KitAuthFailedAlertOptions, KitAuthRedirects, KitAuthState, KitHttpConfig, KitKeyboardAdjust, KitLabels, KitLanguageActionSheetOptions, KitLanguageOption, KitModalPresentOptions, KitOverlayConfig, KitReloadAlertOptions, ModalMetadata };
|