@rdlabo/ionic-angular-kit 0.0.25 → 21.2.0-10
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 +138 -61
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs +71 -1
- package/fesm2022/rdlabo-ionic-angular-kit-printer.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit-theme.mjs +4 -1
- package/fesm2022/rdlabo-ionic-angular-kit-theme.mjs.map +1 -1
- package/fesm2022/rdlabo-ionic-angular-kit.mjs +285 -21
- package/fesm2022/rdlabo-ionic-angular-kit.mjs.map +1 -1
- package/package.json +9 -1
- package/types/rdlabo-ionic-angular-kit-printer.d.ts +68 -2
- package/types/rdlabo-ionic-angular-kit-theme.d.ts +7 -1
- package/types/rdlabo-ionic-angular-kit.d.ts +180 -18
package/README.md
CHANGED
|
@@ -6,7 +6,8 @@ A small ergonomic kit for Ionic Angular applications. It provides:
|
|
|
6
6
|
- **KitOverlayController** — a unified presenter for Ionic Modal, Toast, and Alert
|
|
7
7
|
- **Auth guards** — functional `CanActivateFn` guards for a 4-state auth model
|
|
8
8
|
- **HTTP interceptor** — a fleet-canonical auth + retry + error-hook interceptor
|
|
9
|
-
- **
|
|
9
|
+
- **KitAuthInputDirective** — sign-in email remember/prefill + iOS autofill workaround for `ion-input`
|
|
10
|
+
- **kitClearStoragePreservingKeys** — `clear()` that restores selected keys (`KIT_LAST_AUTH_EMAIL_KEY`, `KIT_THEME_STORAGE_KEY`, …)
|
|
10
11
|
|
|
11
12
|
---
|
|
12
13
|
|
|
@@ -14,29 +15,33 @@ A small ergonomic kit for Ionic Angular applications. It provides:
|
|
|
14
15
|
|
|
15
16
|
```bash
|
|
16
17
|
npm install @rdlabo/ionic-angular-kit
|
|
18
|
+
# prereleases (np: X.Y.Z-N) are on the npm dist-tag `beta`:
|
|
19
|
+
# npm install @rdlabo/ionic-angular-kit@beta
|
|
17
20
|
```
|
|
18
21
|
|
|
22
|
+
Kit shares the repo `v*` release line with the other libraries (see root README § Release).
|
|
23
|
+
|
|
19
24
|
### Peer dependencies
|
|
20
25
|
|
|
21
|
-
| Package
|
|
22
|
-
|
|
23
|
-
| `@angular/common`
|
|
24
|
-
| `@angular/core`
|
|
25
|
-
| `@angular/router`
|
|
26
|
-
| `@ionic/angular`
|
|
27
|
-
| `@ionic/storage-angular`
|
|
28
|
-
| `@capacitor/core`
|
|
29
|
-
| `@capacitor/haptics`
|
|
30
|
-
| `@capacitor/keyboard`
|
|
31
|
-
| `@capacitor/network`
|
|
32
|
-
| `@capacitor/preferences`
|
|
33
|
-
| `@capacitor/status-bar`
|
|
26
|
+
| Package | Version |
|
|
27
|
+
| ------------------------------------ | ---------------- |
|
|
28
|
+
| `@angular/common` | `^21.0.0` |
|
|
29
|
+
| `@angular/core` | `^21.0.0` |
|
|
30
|
+
| `@angular/router` | `^21.0.0` |
|
|
31
|
+
| `@ionic/angular` | `^8.0.0` |
|
|
32
|
+
| `@ionic/storage-angular` | `^4.0.0` |
|
|
33
|
+
| `@capacitor/core` | `>=6.0.0 <9.0.0` |
|
|
34
|
+
| `@capacitor/haptics` | `>=6.0.0 <9.0.0` |
|
|
35
|
+
| `@capacitor/keyboard` | `>=6.0.0 <9.0.0` |
|
|
36
|
+
| `@capacitor/network` | `>=6.0.0 <9.0.0` |
|
|
37
|
+
| `@capacitor/preferences` | `>=6.0.0 <9.0.0` |
|
|
38
|
+
| `@capacitor/status-bar` | `>=6.0.0 <9.0.0` |
|
|
34
39
|
| `@capacitor-community/in-app-review` | `>=6.0.0 <9.0.0` |
|
|
35
|
-
| `@rdlabo/capacitor-brotherprint`
|
|
36
|
-
| `dom-to-image-more`
|
|
37
|
-
| `rxjs`
|
|
40
|
+
| `@rdlabo/capacitor-brotherprint` | `>=6.0.0 <9.0.0` |
|
|
41
|
+
| `dom-to-image-more` | `^3.0.0` |
|
|
42
|
+
| `rxjs` | `^7.8.0` |
|
|
38
43
|
|
|
39
|
-
Feature-scoped peers are only needed by the features that use them (`status-bar` → `KitThemeController`; `preferences` + `in-app-review` → `kitRequestReview`; `capacitor-brotherprint` + `dom-to-image-more` → the printer helpers); an app that doesn't use a feature can ignore its unmet-peer warning.
|
|
44
|
+
Feature-scoped peers are only needed by the features that use them (`status-bar` → `KitThemeController`; `preferences` + `in-app-review` → `kitRequestReview`; `capacitor-brotherprint` + `dom-to-image-more` → the Brother/PNG printer helpers; `pdf-lib` → the PDF printer helper); an app that doesn't use a feature can ignore its unmet-peer warning.
|
|
40
45
|
|
|
41
46
|
---
|
|
42
47
|
|
|
@@ -56,9 +61,7 @@ import { IonicStorageModule } from '@ionic/storage-angular';
|
|
|
56
61
|
import { importProvidersFrom } from '@angular/core';
|
|
57
62
|
|
|
58
63
|
export const appConfig: ApplicationConfig = {
|
|
59
|
-
providers: [
|
|
60
|
-
importProvidersFrom(IonicStorageModule.withConfig({ name: '__mydb' })),
|
|
61
|
-
],
|
|
64
|
+
providers: [importProvidersFrom(IonicStorageModule.withConfig({ name: '__mydb' }))],
|
|
62
65
|
};
|
|
63
66
|
```
|
|
64
67
|
|
|
@@ -180,13 +183,13 @@ alertConfirm(options: {
|
|
|
180
183
|
|
|
181
184
|
`watchKeyboard: true` (on `presentModal` options) expands a bottom sheet to full height when the native keyboard appears (iOS/Android only; no-op on web).
|
|
182
185
|
|
|
183
|
-
**How `presentModal` decides required vs. optional props.** Props are inferred from the component's `input()` fields, and whether each prop is **required** or **optional** is decided by a single rule:
|
|
186
|
+
**How `presentModal` decides required vs. optional props.** Props are inferred from the component's `input()` fields, and whether each prop is **required** or **optional** is decided by a single rule: _does the input's type include `undefined`?_ A default value is not "optional" — providing a default removes `undefined` from the input's type, so a defaulted input becomes a **required** prop.
|
|
184
187
|
|
|
185
|
-
| Declaration | Input type
|
|
186
|
-
| ------------------------ |
|
|
187
|
-
| `input.required<T>()` | `T`
|
|
188
|
-
| `input<T>(defaultValue)` | `T`
|
|
189
|
-
| `input<T>()` (no arg) | `T \| undefined
|
|
188
|
+
| Declaration | Input type | Includes `undefined`? | Prop |
|
|
189
|
+
| ------------------------ | ---------------- | --------------------- | ------------------------------------------ |
|
|
190
|
+
| `input.required<T>()` | `T` | No | required |
|
|
191
|
+
| `input<T>(defaultValue)` | `T` | No | **required** ← a default makes it required |
|
|
192
|
+
| `input<T>()` (no arg) | `T \| undefined` | Yes | optional |
|
|
190
193
|
|
|
191
194
|
To make a prop **optional**, drop the default and use a bare `input<T>()` (its type is `T | undefined`), then apply your fallback where you read it (e.g. `this.enabled() ?? true`). If a component has at least one required input, the `componentProps` argument itself becomes mandatory; if it has no required inputs, `componentProps` may be omitted; a component with no `input()` fields at all accepts loose, untyped props.
|
|
192
195
|
|
|
@@ -211,11 +214,11 @@ This centralizes presentation options, keeps component props and dismiss data ty
|
|
|
211
214
|
|
|
212
215
|
Functional `CanActivateFn` guards for a four-state auth model:
|
|
213
216
|
|
|
214
|
-
| State
|
|
215
|
-
|
|
216
|
-
| `'user'`
|
|
217
|
-
| `'confirm'`
|
|
218
|
-
| `'required'`
|
|
217
|
+
| State | Meaning |
|
|
218
|
+
| ------------- | ---------------------------------------------------- |
|
|
219
|
+
| `'user'` | Fully authenticated |
|
|
220
|
+
| `'confirm'` | Authenticated but email confirmation pending |
|
|
221
|
+
| `'required'` | Not authenticated |
|
|
219
222
|
| `'anonymous'` | Anonymous login active (can be prompted to register) |
|
|
220
223
|
|
|
221
224
|
**Convention:** every redirect path is supplied via `provideKitAuth`; the kit does not hard-code any routes. `authState` and `redirects` are required. The app-specific hooks `onAuthorized` / `onUnauthenticated` are **optional** and default to `true` (allow the authenticated user through) / `false` (fall through to the `whenUnauthorized` redirect), so an app only supplies the ones with real logic.
|
|
@@ -231,12 +234,12 @@ export const appConfig: ApplicationConfig = {
|
|
|
231
234
|
provideKitAuth(() => {
|
|
232
235
|
const auth = inject(AuthService);
|
|
233
236
|
return {
|
|
234
|
-
authState: () => auth.state$,
|
|
237
|
+
authState: () => auth.state$, // Observable<KitAuthState>
|
|
235
238
|
redirects: {
|
|
236
|
-
whenAuthorized: '/home',
|
|
237
|
-
whenConfirming: '/auth/confirm',
|
|
238
|
-
whenNotConfirming: '/auth/signin'
|
|
239
|
-
whenUnauthorized: '/auth',
|
|
239
|
+
whenAuthorized: '/home', // kitRequiredUnauthorizedGuard
|
|
240
|
+
whenConfirming: '/auth/confirm', // kitRequiredUnauthorizedGuard
|
|
241
|
+
whenNotConfirming: '/auth/signin', // kitRequireConfirmingGuard
|
|
242
|
+
whenUnauthorized: '/auth', // kitRequireAuthorizedGuard
|
|
240
243
|
},
|
|
241
244
|
// onAuthorized / onUnauthenticated omitted → defaults (allow / redirect).
|
|
242
245
|
// Supply onAuthorized only when 'user' needs extra work (token login, permissions):
|
|
@@ -272,11 +275,7 @@ const logged = await auth.tokenLogin().catch(async (e) => {
|
|
|
272
275
|
|
|
273
276
|
```typescript
|
|
274
277
|
// routes.ts
|
|
275
|
-
import {
|
|
276
|
-
kitRequiredUnauthorizedGuard,
|
|
277
|
-
kitRequireConfirmingGuard,
|
|
278
|
-
kitRequireAuthorizedGuard,
|
|
279
|
-
} from '@rdlabo/ionic-angular-kit';
|
|
278
|
+
import { kitRequiredUnauthorizedGuard, kitRequireConfirmingGuard, kitRequireAuthorizedGuard } from '@rdlabo/ionic-angular-kit';
|
|
280
279
|
|
|
281
280
|
export const routes: Routes = [
|
|
282
281
|
{
|
|
@@ -359,6 +358,7 @@ export const appConfig: ApplicationConfig = {
|
|
|
359
358
|
```
|
|
360
359
|
|
|
361
360
|
**Error dispatch** (after retries, in `catchError`):
|
|
361
|
+
|
|
362
362
|
1. `offlineFallback` non-null → return fallback observable (no further hooks called)
|
|
363
363
|
2. `401` → `onUnauthorized` · `403` → `onForbidden`
|
|
364
364
|
3. `0` (connected) → `onNetworkError` · `429` → `onRateLimited(retryAfter?)` · `502/503/504` → `onServerBusy(status, retryAfter?)`
|
|
@@ -395,15 +395,31 @@ await reload.dismiss();
|
|
|
395
395
|
|
|
396
396
|
---
|
|
397
397
|
|
|
398
|
-
###
|
|
398
|
+
### KitAuthInputDirective (`kitAuthInput`)
|
|
399
399
|
|
|
400
|
-
|
|
400
|
+
Sign-in / sign-up conveniences on `ion-input`:
|
|
401
|
+
|
|
402
|
+
- `'email'` — remember + prefill the last well-formed address (and forget when the user clears it)
|
|
403
|
+
- `'email-remember'` — remember on change only (no prefill — use on sign-up)
|
|
404
|
+
- `'autofill'` — iOS autofill propagation only (password fields)
|
|
401
405
|
|
|
402
406
|
```html
|
|
403
|
-
<ion-input
|
|
407
|
+
<ion-input type="email" autocomplete="email" kitAuthInput="email" [formField]="form.email" />
|
|
408
|
+
```
|
|
409
|
+
|
|
410
|
+
### kitClearStoragePreservingKeys
|
|
411
|
+
|
|
412
|
+
Fleet apps typically `storage.clear()` on sign-out. Pass keys that must survive (e.g. the last sign-in email):
|
|
413
|
+
|
|
414
|
+
```typescript
|
|
415
|
+
import { KIT_LAST_AUTH_EMAIL_KEY, KIT_THEME_STORAGE_KEY, kitClearStoragePreservingKeys } from '@rdlabo/ionic-angular-kit';
|
|
416
|
+
|
|
417
|
+
await kitSignOut(auth, {
|
|
418
|
+
success: () => kitClearStoragePreservingKeys(this.storage, [KIT_LAST_AUTH_EMAIL_KEY, KIT_THEME_STORAGE_KEY]),
|
|
419
|
+
});
|
|
404
420
|
```
|
|
405
421
|
|
|
406
|
-
|
|
422
|
+
It snapshots the listed keys, clears the store, then writes non-null values back.
|
|
407
423
|
|
|
408
424
|
---
|
|
409
425
|
|
|
@@ -516,7 +532,10 @@ import { kitPresentLanguageActionSheet } from '@rdlabo/ionic-angular-kit';
|
|
|
516
532
|
|
|
517
533
|
await kitPresentLanguageActionSheet(inject(ActionSheetController), {
|
|
518
534
|
header: $localize`言語設定`,
|
|
519
|
-
locales: [
|
|
535
|
+
locales: [
|
|
536
|
+
{ text: 'English', data: 'en-US' },
|
|
537
|
+
{ text: '日本語', data: 'ja' },
|
|
538
|
+
],
|
|
520
539
|
cancelText: $localize`キャンセル`,
|
|
521
540
|
currentLocale: normalizedLocale,
|
|
522
541
|
currentPath: this.#router.url,
|
|
@@ -528,24 +547,38 @@ await kitPresentLanguageActionSheet(inject(ActionSheetController), {
|
|
|
528
547
|
|
|
529
548
|
---
|
|
530
549
|
|
|
531
|
-
### Printer (
|
|
550
|
+
### Printer (label image and PDF plumbing)
|
|
532
551
|
|
|
533
|
-
|
|
552
|
+
Pure functions (no DI) that extract the i18n-free core of the fleet's label printing, so a device-quirk, layout, or PDF fix lands in every app at once. The UI orchestration — paper-selection alerts, loading overlays, storage, printer transport, and app-specific copies policy — stays in each app.
|
|
534
553
|
|
|
535
554
|
- `kitDomToPng(element, { rotate?, scale? })` — render a DOM element to a base64 PNG with the fleet's device fixes (iOS +2px to avoid bottom clipping, none on Android to avoid a black line; retries up to 10×). The caller presents its own loading UI.
|
|
536
555
|
- `kitRotationImage(base64)` — rotate a base64 image 90° via canvas.
|
|
537
556
|
- `kitBuildBrotherPrintSettings({ modelName, printBase64, label, numberOfCopies, halftoneThreshold })` — assemble the canonical `BRLMPrintOptions` (fit-page, centered, best quality, threshold halftone, standard margins, tape size parsed from the label's `W<w>H<h>` code). Merge `{ port, channelInfo }` from the selected channel before calling `BrotherPrint.printImage()`.
|
|
557
|
+
- `kitCalculatePrintLayout({ paper, labelWidthPx, labelHeightPx, copies, measure?, marginMm? })` — calculate row-major positions across as many pages as required. The default outer margin is 5mm.
|
|
558
|
+
- `kitBuildLabelPdf({ imageData, ...layoutOptions })` — embed the PNG artwork at the calculated positions and return PDF bytes. It deliberately does not open a browser tab or call a native printer.
|
|
559
|
+
- `kitPrintPaperSizes` — A4/B5 presets. Callers may pass any other `KitPrintPaper` dimensions without changing the kit.
|
|
538
560
|
|
|
539
561
|
```typescript
|
|
540
|
-
import { kitDomToPng,
|
|
562
|
+
import { kitBuildBrotherPrintSettings, kitBuildLabelPdf, kitDomToPng, kitPrintPaperSizes } from '@rdlabo/ionic-angular-kit/printer';
|
|
541
563
|
|
|
542
564
|
const png = await kitDomToPng(this.preview().nativeElement, { rotate: true });
|
|
543
565
|
const settings = kitBuildBrotherPrintSettings({
|
|
544
|
-
modelName,
|
|
566
|
+
modelName,
|
|
567
|
+
printBase64: png,
|
|
568
|
+
label,
|
|
545
569
|
numberOfCopies: printOptions.printNum,
|
|
546
570
|
halftoneThreshold: printOptions.halftoneThreshold,
|
|
547
571
|
});
|
|
548
572
|
await BrotherPrint.printImage({ ...settings, port: channel.port, channelInfo: channel.channelInfo });
|
|
573
|
+
|
|
574
|
+
const pdfBytes = await kitBuildLabelPdf({
|
|
575
|
+
imageData: png,
|
|
576
|
+
paper: kitPrintPaperSizes.a4,
|
|
577
|
+
labelWidthPx: 200,
|
|
578
|
+
labelHeightPx: 100,
|
|
579
|
+
copies: 6,
|
|
580
|
+
marginMm: 5,
|
|
581
|
+
});
|
|
549
582
|
```
|
|
550
583
|
|
|
551
584
|
---
|
|
@@ -565,7 +598,11 @@ provideKitFirebaseAnalytics(),
|
|
|
565
598
|
```typescript
|
|
566
599
|
import { inject, Injectable } from '@angular/core';
|
|
567
600
|
import {
|
|
568
|
-
KIT_FIREBASE_AUTH,
|
|
601
|
+
KIT_FIREBASE_AUTH,
|
|
602
|
+
kitSignIn,
|
|
603
|
+
kitSignOut,
|
|
604
|
+
kitResolveAuthStatus,
|
|
605
|
+
kitReauthWithRetry,
|
|
569
606
|
} from '@rdlabo/ionic-angular-kit/auth-firebase';
|
|
570
607
|
import { updatePassword } from 'firebase/auth'; // escape hatch for the reauth mutation
|
|
571
608
|
|
|
@@ -604,6 +641,53 @@ Surface:
|
|
|
604
641
|
|
|
605
642
|
---
|
|
606
643
|
|
|
644
|
+
### Live Update (`@rdlabo/ionic-angular-kit/live-update`)
|
|
645
|
+
|
|
646
|
+
A secondary entry point (so only apps that use it pull in `@capawesome/capacitor-live-update`, declared as an optional peer) for shipping [Capawesome Live Updates](https://capawesome.io/plugins/live-update/) — over-the-air replacement of the Web (Angular/Ionic) layer without a store review.
|
|
647
|
+
|
|
648
|
+
#### `provideLiveUpdateReadiness()`
|
|
649
|
+
|
|
650
|
+
Marks the running Live Update bundle **healthy** once the app has actually rendered, so Capawesome does not auto-roll-back a good bundle. It waits for Angular to become stable **and** the first route to finish (`NavigationEnd` + one animation frame) before calling `LiveUpdate.ready()`. This replaces a fixed `readyTimeout` in `capacitor.config.ts` with a signal tied to real readiness. **Native only** — a no-op on web.
|
|
651
|
+
|
|
652
|
+
```typescript
|
|
653
|
+
// app.config.ts
|
|
654
|
+
import { provideLiveUpdateReadiness } from '@rdlabo/ionic-angular-kit/live-update';
|
|
655
|
+
|
|
656
|
+
export const appConfig: ApplicationConfig = {
|
|
657
|
+
providers: [
|
|
658
|
+
provideZonelessChangeDetection(),
|
|
659
|
+
provideLiveUpdateReadiness(),
|
|
660
|
+
// ...
|
|
661
|
+
],
|
|
662
|
+
};
|
|
663
|
+
```
|
|
664
|
+
|
|
665
|
+
#### Release and channel model
|
|
666
|
+
|
|
667
|
+
Each app's release workflow runs when a `vX.Y.Z` or `vX.Y.Z-N` tag is pushed. The shared `classify-mobile-release` composite action in [`ionic-angular-library/.github/actions`](https://github.com/rdlabo-team/ionic-angular-library/tree/main/.github/actions) compares the tag with the previous release and selects the delivery path. Patch and prerelease updates within the same `major.minor` line use `publish-live-update`; major and minor updates use Capawesome Cloud Native Builds and App Store Publishing.
|
|
668
|
+
|
|
669
|
+
Every delivery channel is named **`production-<native-build-number>`**, where the Android `versionCode` and iOS `CURRENT_PROJECT_VERSION` must match. A Live Update replaces only the JS, HTML, and CSS on an existing native binary, so channels are isolated by build number and updates reach only compatible devices. The upload pins `--android-min/max` and `--ios-min/max` to that build number.
|
|
670
|
+
|
|
671
|
+
- **Same channel: eligible for Live Update**
|
|
672
|
+
Keep the native build number unchanged. This path is for JS, HTML, and CSS changes only, including bug fixes, copy, UI, application logic, and npm dependencies that do not affect native code. Incrementing only the patch version within the same `major.minor` line keeps the channel unchanged, so existing users receive the update without installing a new store build.
|
|
673
|
+
Example: `9.0.0` (build `9000000`) followed by a web-only `9.0.1` update; both use `production-9000000`.
|
|
674
|
+
|
|
675
|
+
- **New channel: store release required**
|
|
676
|
+
Increment the major or minor version and the native build number. Include changes to `app/android/**`, `app/ios/**`, `capacitor.config.ts` (or `.json`), and Capacitor plugin versions in this release type. The workflow submits iOS builds to TestFlight and Android builds to the Google Play Internal track; promotion to production happens in each store.
|
|
677
|
+
Example: a native update to `9.1.0` (build `9010000`) creates `production-9010000`. Devices still running `9.0.x` remain on `production-9000000` and are unaffected.
|
|
678
|
+
|
|
679
|
+
The build number encodes the major and minor versions at the front: `floor(buildNumber / 10000) === major * 100 + minor`.
|
|
680
|
+
|
|
681
|
+
| Version | Build number | Channel |
|
|
682
|
+
| -------- | ------------ | --------------------- |
|
|
683
|
+
| `9.0.x` | `9000000` | `production-9000000` |
|
|
684
|
+
| `9.1.x` | `9010000` | `production-9010000` |
|
|
685
|
+
| `10.2.x` | `10020000` | `production-10020000` |
|
|
686
|
+
|
|
687
|
+
`classify-mobile-release` fails CI when a patch or prerelease contains native, configuration, or Capacitor dependency changes and requires a major or minor bump instead. For store releases, it verifies that the tag matches the native marketing version, the Android and iOS versions and build numbers agree, the build number increases, and the encoding above is valid. `validate-live-update` remains available for compatibility with existing consumers.
|
|
688
|
+
|
|
689
|
+
---
|
|
690
|
+
|
|
607
691
|
## Consumer Vitest setup notes
|
|
608
692
|
|
|
609
693
|
When testing a consumer app that declares `@rdlabo/ionic-angular-kit` as a `file:` symlink dependency, add the following to your `vitest.config.ts`:
|
|
@@ -612,14 +696,7 @@ When testing a consumer app that declares `@rdlabo/ionic-angular-kit` as a `file
|
|
|
612
696
|
// vitest.config.ts
|
|
613
697
|
export default defineConfig({
|
|
614
698
|
resolve: {
|
|
615
|
-
dedupe: [
|
|
616
|
-
'@angular/core',
|
|
617
|
-
'@angular/common',
|
|
618
|
-
'@angular/router',
|
|
619
|
-
'@ionic/angular',
|
|
620
|
-
'@ionic/core',
|
|
621
|
-
'rxjs',
|
|
622
|
-
],
|
|
699
|
+
dedupe: ['@angular/core', '@angular/common', '@angular/router', '@ionic/angular', '@ionic/core', 'rxjs'],
|
|
623
700
|
},
|
|
624
701
|
test: {
|
|
625
702
|
server: {
|
|
@@ -628,7 +705,7 @@ export default defineConfig({
|
|
|
628
705
|
/@ionic\/angular/,
|
|
629
706
|
/@ionic\/core/,
|
|
630
707
|
/ionicons/,
|
|
631
|
-
/@rdlabo\/ionic-angular-kit/,
|
|
708
|
+
/@rdlabo\/ionic-angular-kit/, // inline the kit itself
|
|
632
709
|
],
|
|
633
710
|
},
|
|
634
711
|
},
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { Capacitor } from '@capacitor/core';
|
|
2
2
|
import { BRLMPrinterHalftone, BRLMPrinterCustomPaperUnit, BRLMPrinterCustomPaperType, BRLMPrinterPrintQuality, BRLMPrinterHorizontalAlignment, BRLMPrinterVerticalAlignment, BRLMPrinterImageRotation, BRLMPrinterScaleMode } from '@rdlabo/capacitor-brotherprint';
|
|
3
3
|
import domtoimage from 'dom-to-image-more';
|
|
4
|
+
import { PDFDocument } from 'pdf-lib';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* Rotate a base64 image 90°, returning a new base64 data URL of the same MIME type.
|
|
@@ -134,6 +135,75 @@ const kitBuildBrotherPrintSettings = (params) => {
|
|
|
134
135
|
};
|
|
135
136
|
};
|
|
136
137
|
|
|
138
|
+
/** Standard paper presets shared by the printing applications. */
|
|
139
|
+
const kitPrintPaperSizes = {
|
|
140
|
+
a4: { label: 'A4', widthMm: 210, heightMm: 297 },
|
|
141
|
+
b5: { label: 'B5', widthMm: 182, heightMm: 257 },
|
|
142
|
+
};
|
|
143
|
+
/**
|
|
144
|
+
* Calculate page dimensions and row-major label positions for a printable PDF.
|
|
145
|
+
*
|
|
146
|
+
* Labels keep their aspect ratio, are never enlarged beyond their requested pixel/physical size,
|
|
147
|
+
* and automatically continue on additional pages when the current page is full.
|
|
148
|
+
*/
|
|
149
|
+
const kitCalculatePrintLayout = (params) => {
|
|
150
|
+
const pointsPerMm = 72 / 25.4;
|
|
151
|
+
const pointsPerPixel = 72 / 96;
|
|
152
|
+
const paperWidth = params.paper.widthMm * pointsPerMm;
|
|
153
|
+
const paperHeight = params.paper.heightMm * pointsPerMm;
|
|
154
|
+
const margin = (params.marginMm ?? 5) * pointsPerMm;
|
|
155
|
+
const aspect = params.labelWidthPx / params.labelHeightPx;
|
|
156
|
+
let labelWidth = params.labelWidthPx * pointsPerPixel;
|
|
157
|
+
let labelHeight = params.labelHeightPx * pointsPerPixel;
|
|
158
|
+
if (params.measure?.type === 'width') {
|
|
159
|
+
labelWidth = params.measure.sizeMm * pointsPerMm;
|
|
160
|
+
labelHeight = labelWidth / aspect;
|
|
161
|
+
}
|
|
162
|
+
else if (params.measure?.type === 'height') {
|
|
163
|
+
labelHeight = params.measure.sizeMm * pointsPerMm;
|
|
164
|
+
labelWidth = labelHeight * aspect;
|
|
165
|
+
}
|
|
166
|
+
const scale = Math.min(1, (paperWidth - margin * 2) / labelWidth, (paperHeight - margin * 2) / labelHeight);
|
|
167
|
+
labelWidth *= scale;
|
|
168
|
+
labelHeight *= scale;
|
|
169
|
+
const positions = [];
|
|
170
|
+
let pageIndex = 0;
|
|
171
|
+
let x = margin;
|
|
172
|
+
let y = paperHeight - margin;
|
|
173
|
+
for (let index = 0; index < Math.max(0, params.copies); index++) {
|
|
174
|
+
if (x + labelWidth > paperWidth - margin + 0.01) {
|
|
175
|
+
x = margin;
|
|
176
|
+
y -= labelHeight;
|
|
177
|
+
}
|
|
178
|
+
if (y - labelHeight < margin - 0.01) {
|
|
179
|
+
pageIndex++;
|
|
180
|
+
x = margin;
|
|
181
|
+
y = paperHeight - margin;
|
|
182
|
+
}
|
|
183
|
+
positions.push({ pageIndex, x, y: y - labelHeight });
|
|
184
|
+
x += labelWidth;
|
|
185
|
+
}
|
|
186
|
+
return { paperWidth, paperHeight, labelWidth, labelHeight, positions };
|
|
187
|
+
};
|
|
188
|
+
/** Build a multi-page label PDF and return its bytes without choosing an output destination. */
|
|
189
|
+
const kitBuildLabelPdf = async (params) => {
|
|
190
|
+
const pdf = await PDFDocument.create();
|
|
191
|
+
const image = await pdf.embedPng(params.imageData);
|
|
192
|
+
const layout = kitCalculatePrintLayout(params);
|
|
193
|
+
const pages = layout.positions.length > 0 ? [pdf.addPage([layout.paperWidth, layout.paperHeight])] : [];
|
|
194
|
+
for (const position of layout.positions) {
|
|
195
|
+
while (pages.length <= position.pageIndex)
|
|
196
|
+
pages.push(pdf.addPage([layout.paperWidth, layout.paperHeight]));
|
|
197
|
+
pages[position.pageIndex].drawImage(image, {
|
|
198
|
+
x: position.x,
|
|
199
|
+
y: position.y,
|
|
200
|
+
width: layout.labelWidth,
|
|
201
|
+
height: layout.labelHeight,
|
|
202
|
+
});
|
|
203
|
+
}
|
|
204
|
+
return pdf.save();
|
|
205
|
+
};
|
|
206
|
+
|
|
137
207
|
// Printer: Brother label plumbing (DOM→PNG, rotation, print-settings assembly).
|
|
138
208
|
// Split into its own entry point so only apps that print pull in `@rdlabo/capacitor-brotherprint`
|
|
139
209
|
// and `dom-to-image-more`; the core entry stays free of those native peers.
|
|
@@ -142,5 +212,5 @@ const kitBuildBrotherPrintSettings = (params) => {
|
|
|
142
212
|
* Generated bundle index. Do not edit.
|
|
143
213
|
*/
|
|
144
214
|
|
|
145
|
-
export { kitBuildBrotherPrintSettings, kitDomToPng, kitRotationImage };
|
|
215
|
+
export { kitBuildBrotherPrintSettings, kitBuildLabelPdf, kitCalculatePrintLayout, kitDomToPng, kitPrintPaperSizes, kitRotationImage };
|
|
146
216
|
//# sourceMappingURL=rdlabo-ionic-angular-kit-printer.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rdlabo-ionic-angular-kit-printer.mjs","sources":["../../../projects/kit/printer/src/kit-printer.ts","../../../projects/kit/printer/src/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","// 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';\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;A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,YAAA,UAAU,EAAE,GAAG;AAEf,YAAA,iBAAiB,EAAE,CAAC;AACpB,YAAA,eAAe,EAAE,CAAC;AACnB,SAAA;KACF;AACH;;ACrLA;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/public-api.ts","../../../projects/kit/printer/src/rdlabo-ionic-angular-kit-printer.ts"],"sourcesContent":["import { Capacitor } from '@capacitor/core';\nimport type { BRLMPrinterLabelName, BRLMPrinterModelName, BRLMPrintOptions } from '@rdlabo/capacitor-brotherprint';\nimport {\n BRLMPrinterCustomPaperType,\n BRLMPrinterCustomPaperUnit,\n BRLMPrinterHalftone,\n BRLMPrinterHorizontalAlignment,\n BRLMPrinterImageRotation,\n BRLMPrinterPrintQuality,\n BRLMPrinterScaleMode,\n BRLMPrinterVerticalAlignment,\n} from '@rdlabo/capacitor-brotherprint';\nimport domtoimage from 'dom-to-image-more';\n\n/**\n * Rotate a base64 image 90°, returning a new base64 data URL of the same MIME type.\n *\n * @remarks\n * Pure DOM/canvas work — no DI. Used before sending a label to the printer when the artwork must be\n * turned to match the tape orientation. Extracted verbatim from the fleet's printer services so the\n * canvas handling lives in one place.\n *\n * @param imageData - a base64 data URL (e.g. `data:image/png;base64,...`)\n * @returns a Promise resolving to the rotated image as a base64 data URL\n */\nexport const kitRotationImage = async (imageData: string): Promise<string> => {\n const imgType = imageData.substring(5, imageData.indexOf(';'));\n\n const image = new Image();\n const loaded = new Promise<void>((resolve) => {\n image.onload = () => resolve();\n });\n image.src = imageData;\n await loaded;\n\n const canvas = document.createElement('canvas');\n const ctx = canvas.getContext('2d');\n\n canvas.width = image.height;\n canvas.height = image.width;\n\n ctx!.rotate((90 * Math.PI) / 180);\n ctx!.translate(0, -image.height);\n ctx!.drawImage(image, 0, 0, image.width, image.height);\n\n return canvas.toDataURL(imgType);\n};\n\n/** Options for {@link kitDomToPng}. */\nexport interface KitDomToPngOptions {\n /** When `true`, the rendered PNG is rotated 90° via {@link kitRotationImage}. Defaults to `false`. */\n readonly rotate?: boolean;\n /** Rendering scale passed to `dom-to-image-more`. Defaults to `3` (the fleet's print resolution). */\n readonly scale?: number;\n}\n\n/**\n * Render a DOM element to a base64 PNG for label printing, with the fleet's device-specific fixes.\n *\n * @remarks\n * Pure function — no DI (reads the platform from `Capacitor`, uses the global `document`), so the\n * caller presents its own loading UI around it. Centralizes the hard-won device quirks: on iOS it\n * pads width/height by 2px (otherwise the bottom is clipped), on Android it does not (the padding\n * introduces a black line). Retries the `dom-to-image-more` render up to 10 times because the first\n * pass can occasionally return empty. This is exactly the kind of plumbing where a future fix should\n * land in every app at once.\n *\n * @param element - the element to rasterize (e.g. the label preview host)\n * @param options - rendering options; see {@link KitDomToPngOptions}\n * @returns a Promise resolving to the PNG as a base64 data URL (empty string if every attempt failed)\n * @example\n * ```ts\n * const loading = await this.#loadingCtrl.create({ message: this.text.generating });\n * await loading.present();\n * const png = await kitDomToPng(this.preview().nativeElement, { rotate: true });\n * await loading.dismiss();\n * ```\n */\nexport const kitDomToPng = async (element: HTMLElement, options?: KitDomToPngOptions): Promise<string> => {\n await new Promise((resolve) => requestAnimationFrame(resolve));\n\n const { clientHeight, clientWidth } = element;\n\n // デバイス毎の問題解決のため、px 調整。\n // iOS: ないと下が途切れる。Android: あると黒線が入る。\n const addClient = Capacitor.getPlatform() === 'ios' ? 2 : 0;\n\n let dataUrl = '';\n for (let i = 0; i < 10; i++) {\n const url = await domtoimage.toPng(element, {\n width: clientWidth + addClient,\n height: clientHeight + addClient,\n scale: options?.scale ?? 3,\n copyDefaultStyles: false,\n });\n if (url) {\n dataUrl = url;\n break;\n }\n }\n\n return options?.rotate ? kitRotationImage(dataUrl) : dataUrl;\n};\n\n/** Parameters for {@link kitBuildBrotherPrintSettings}. */\nexport interface KitBrotherPrintSettingsParams {\n /** The target printer model. */\n readonly modelName: BRLMPrinterModelName;\n /** The label artwork as a base64 data URL (the `data:...,` prefix is stripped internally). */\n readonly printBase64: string;\n /** The selected label/paper (its `W<width>H<height>` code drives the tape dimensions). */\n readonly label: BRLMPrinterLabelName;\n /** Number of copies to print. Passed by the caller (apps differ: some use the print option, some fix 1). */\n readonly numberOfCopies: number;\n /** Halftone threshold for the print. */\n readonly halftoneThreshold: number;\n}\n\n/**\n * Assemble the Brother `BRLMPrintOptions` for a die-cut label print, minus the transport fields.\n *\n * @remarks\n * Pure function — no DI. Centralizes the fleet's canonical print settings (fit-page scale, centered,\n * best quality, threshold halftone, 2mm/1mm margins, `gapLength` 2.0) and the tape sizing derived\n * from the label's `W<width>H<height>` code. The caller merges the printer's `port` / `channelInfo`\n * onto the result before calling `BrotherPrint.printImage()`, so channel selection and loading UI stay\n * in the app.\n *\n * @param params - model, artwork, label, copies, and halftone threshold; see {@link KitBrotherPrintSettingsParams}\n * @returns the `BRLMPrintOptions` ready to be spread with `{ port, channelInfo }`\n * @example\n * ```ts\n * const settings = kitBuildBrotherPrintSettings({\n * modelName, printBase64, label, numberOfCopies: printOptions.printNum, halftoneThreshold: printOptions.halftoneThreshold,\n * });\n * await BrotherPrint.printImage({ ...settings, port: channel.port, channelInfo: channel.channelInfo });\n * ```\n */\nexport const kitBuildBrotherPrintSettings = (params: KitBrotherPrintSettingsParams): BRLMPrintOptions => {\n const startPoint = params.printBase64.indexOf(',');\n const tapeSize = params.label.match(/W(\\d+)H(\\d+)/);\n const tapeWidth = tapeSize && tapeSize.length >= 2 ? parseInt(tapeSize[1], 10) : 0;\n const tapeLength = tapeSize && tapeSize.length >= 3 ? parseInt(tapeSize[2], 10) : 0;\n\n // `BRLMPrintOptions` is a `QL | TD` union; a die-cut label legitimately carries fields from both\n // groups, so the object is composed via spreads to bypass the union's excess-property checks — the\n // same technique the source printer services used.\n return {\n ...{\n modelName: params.modelName,\n encodedImage: params.printBase64.slice(startPoint + 1),\n numberOfCopies: params.numberOfCopies,\n autoCut: true,\n\n scaleMode: BRLMPrinterScaleMode.FitPageAspect,\n imageRotation: BRLMPrinterImageRotation.Rotate0,\n verticalAlignment: BRLMPrinterVerticalAlignment.Center,\n horizontalAlignment: BRLMPrinterHorizontalAlignment.Center,\n printQuality: BRLMPrinterPrintQuality.Best,\n },\n ...{\n labelName: params.label,\n },\n ...{\n paperType: BRLMPrinterCustomPaperType.dieCutPaper,\n paperUnit: BRLMPrinterCustomPaperUnit.mm,\n halftone: BRLMPrinterHalftone.Threshold,\n halftoneThreshold: params.halftoneThreshold,\n tapeWidth: Number(tapeWidth.toFixed(1)),\n tapeLength: Number(tapeLength.toFixed(1)),\n gapLength: 2.0,\n\n marginTop: 1.0,\n marginRight: 2.0,\n marginBottom: 1.0,\n marginLeft: 2.0,\n\n paperMarkPosition: 0,\n paperMarkLength: 0,\n },\n };\n};\n","import { PDFDocument } from 'pdf-lib';\n\n/** Physical paper dimensions used to build a PDF page. */\nexport interface KitPrintPaper {\n /** Human-readable paper name. */\n readonly label: string;\n /** Paper width in millimetres. */\n readonly widthMm: number;\n /** Paper height in millimetres. */\n readonly heightMm: number;\n}\n\n/** Standard paper presets shared by the printing applications. */\nexport const kitPrintPaperSizes = {\n a4: { label: 'A4', widthMm: 210, heightMm: 297 },\n b5: { label: 'B5', widthMm: 182, heightMm: 257 },\n} as const satisfies Record<string, KitPrintPaper>;\n\n/** A position for one label on a PDF page, expressed in PDF points. */\nexport interface KitPrintPosition {\n readonly pageIndex: number;\n readonly x: number;\n readonly y: number;\n}\n\n/** Calculated PDF page and label dimensions. */\nexport interface KitPrintLayout {\n readonly paperWidth: number;\n readonly paperHeight: number;\n readonly labelWidth: number;\n readonly labelHeight: number;\n readonly positions: readonly KitPrintPosition[];\n}\n\n/** Optional physical size override for a label. */\nexport interface KitPrintMeasure {\n readonly type: 'width' | 'height';\n readonly sizeMm: number;\n}\n\n/** Parameters for {@link kitCalculatePrintLayout}. */\nexport interface KitCalculatePrintLayoutParams {\n readonly paper: KitPrintPaper;\n readonly labelWidthPx: number;\n readonly labelHeightPx: number;\n readonly copies: number;\n readonly measure?: KitPrintMeasure | null;\n /** Outer page margin in millimetres. Defaults to 5mm. */\n readonly marginMm?: number;\n}\n\n/**\n * Calculate page dimensions and row-major label positions for a printable PDF.\n *\n * Labels keep their aspect ratio, are never enlarged beyond their requested pixel/physical size,\n * and automatically continue on additional pages when the current page is full.\n */\nexport const kitCalculatePrintLayout = (params: KitCalculatePrintLayoutParams): KitPrintLayout => {\n const pointsPerMm = 72 / 25.4;\n const pointsPerPixel = 72 / 96;\n const paperWidth = params.paper.widthMm * pointsPerMm;\n const paperHeight = params.paper.heightMm * pointsPerMm;\n const margin = (params.marginMm ?? 5) * pointsPerMm;\n const aspect = params.labelWidthPx / params.labelHeightPx;\n let labelWidth = params.labelWidthPx * pointsPerPixel;\n let labelHeight = params.labelHeightPx * pointsPerPixel;\n\n if (params.measure?.type === 'width') {\n labelWidth = params.measure.sizeMm * pointsPerMm;\n labelHeight = labelWidth / aspect;\n } else if (params.measure?.type === 'height') {\n labelHeight = params.measure.sizeMm * pointsPerMm;\n labelWidth = labelHeight * aspect;\n }\n\n const scale = Math.min(1, (paperWidth - margin * 2) / labelWidth, (paperHeight - margin * 2) / labelHeight);\n labelWidth *= scale;\n labelHeight *= scale;\n\n const positions: KitPrintPosition[] = [];\n let pageIndex = 0;\n let x = margin;\n let y = paperHeight - margin;\n for (let index = 0; index < Math.max(0, params.copies); index++) {\n if (x + labelWidth > paperWidth - margin + 0.01) {\n x = margin;\n y -= labelHeight;\n }\n if (y - labelHeight < margin - 0.01) {\n pageIndex++;\n x = margin;\n y = paperHeight - margin;\n }\n positions.push({ pageIndex, x, y: y - labelHeight });\n x += labelWidth;\n }\n\n return { paperWidth, paperHeight, labelWidth, labelHeight, positions };\n};\n\n/** Parameters for {@link kitBuildLabelPdf}. */\nexport interface KitBuildLabelPdfParams extends KitCalculatePrintLayoutParams {\n /** PNG label artwork as a data URL or base64 string accepted by pdf-lib. */\n readonly imageData: string;\n}\n\n/** Build a multi-page label PDF and return its bytes without choosing an output destination. */\nexport const kitBuildLabelPdf = async (params: KitBuildLabelPdfParams): Promise<Uint8Array> => {\n const pdf = await PDFDocument.create();\n const image = await pdf.embedPng(params.imageData);\n const layout = kitCalculatePrintLayout(params);\n const pages = layout.positions.length > 0 ? [pdf.addPage([layout.paperWidth, layout.paperHeight])] : [];\n\n for (const position of layout.positions) {\n while (pages.length <= position.pageIndex) pages.push(pdf.addPage([layout.paperWidth, layout.paperHeight]));\n pages[position.pageIndex].drawImage(image, {\n x: position.x,\n y: position.y,\n width: layout.labelWidth,\n height: layout.labelHeight,\n });\n }\n\n return pdf.save();\n};\n","// Printer: Brother label plumbing (DOM→PNG, rotation, print-settings assembly).\n// Split into its own entry point so only apps that print pull in `@rdlabo/capacitor-brotherprint`\n// and `dom-to-image-more`; the core entry stays free of those native peers.\nexport * from './kit-printer';\nexport * from './kit-pdf-printer';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;AAcA;;;;;;;;;;AAUG;MACU,gBAAgB,GAAG,OAAO,SAAiB,KAAqB;AAC3E,IAAA,MAAM,OAAO,GAAG,SAAS,CAAC,SAAS,CAAC,CAAC,EAAE,SAAS,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;AAE9D,IAAA,MAAM,KAAK,GAAG,IAAI,KAAK,EAAE;IACzB,MAAM,MAAM,GAAG,IAAI,OAAO,CAAO,CAAC,OAAO,KAAI;QAC3C,KAAK,CAAC,MAAM,GAAG,MAAM,OAAO,EAAE;AAChC,IAAA,CAAC,CAAC;AACF,IAAA,KAAK,CAAC,GAAG,GAAG,SAAS;AACrB,IAAA,MAAM,MAAM;IAEZ,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC;IAC/C,MAAM,GAAG,GAAG,MAAM,CAAC,UAAU,CAAC,IAAI,CAAC;AAEnC,IAAA,MAAM,CA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E,UAAU,EAAE,WAAW,EAAE,SAAS,EAAE;AACxE;AAQA;MACa,gBAAgB,GAAG,OAAO,MAA8B,KAAyB;AAC5F,IAAA,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,MAAM,EAAE;IACtC,MAAM,KAAK,GAAG,MAAM,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,SAAS,CAAC;AAClD,IAAA,MAAM,MAAM,GAAG,uBAAuB,CAAC,MAAM,CAAC;AAC9C,IAAA,MAAM,KAAK,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,EAAE;AAEvG,IAAA,KAAK,MAAM,QAAQ,IAAI,MAAM,CAAC,SAAS,EAAE;AACvC,QAAA,OAAO,KAAK,CAAC,MAAM,IAAI,QAAQ,CAAC,SAAS;AAAE,YAAA,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;QAC3G,KAAK,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC,SAAS,CAAC,KAAK,EAAE;YACzC,CAAC,EAAE,QAAQ,CAAC,CAAC;YACb,CAAC,EAAE,QAAQ,CAAC,CAAC;YACb,KAAK,EAAE,MAAM,CAAC,UAAU;YACxB,MAAM,EAAE,MAAM,CAAC,WAAW;AAC3B,SAAA,CAAC;IACJ;AAEA,IAAA,OAAO,GAAG,CAAC,IAAI,EAAE;AACnB;;AC5HA;AACA;AACA;;ACFA;;AAEG;;;;"}
|
|
@@ -19,10 +19,13 @@ const KIT_THEME_CONFIG = new InjectionToken('@rdlabo/ionic-angular-kit:theme');
|
|
|
19
19
|
* @returns environment providers to add to the application's provider list
|
|
20
20
|
* @example
|
|
21
21
|
* ```ts
|
|
22
|
+
* import { KIT_THEME_STORAGE_KEY } from '@rdlabo/ionic-angular-kit';
|
|
23
|
+
* import { provideKitTheme } from '@rdlabo/ionic-angular-kit/theme';
|
|
24
|
+
*
|
|
22
25
|
* bootstrapApplication(AppComponent, {
|
|
23
26
|
* providers: [
|
|
24
27
|
* provideKitTheme({
|
|
25
|
-
* storageKey:
|
|
28
|
+
* storageKey: KIT_THEME_STORAGE_KEY,
|
|
26
29
|
* darkClasses: ['ion-palette-dark', 'a2ui-dark'],
|
|
27
30
|
* lightClasses: ['a2ui-light'],
|
|
28
31
|
* }),
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"rdlabo-ionic-angular-kit-theme.mjs","sources":["../../../projects/kit/theme/src/theme-config.ts","../../../projects/kit/theme/src/kit-theme.controller.ts","../../../projects/kit/theme/src/public-api.ts","../../../projects/kit/theme/src/rdlabo-ionic-angular-kit-theme.ts"],"sourcesContent":["import type { EnvironmentProviders } from '@angular/core';\nimport { InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\n/**\n * Theme configuration injected via `provideKitTheme()` and consumed by `KitThemeController`.\n *\n * @remarks\n * All fields are required; the consuming application supplies a complete configuration so every app\n * in the fleet has the same shape. The class lists absorb the per-app CSS drift: the kit toggles\n * `darkClasses` on when dark and `lightClasses` on when light, so an app that only uses Ionic's\n * palette passes `darkClasses: ['ion-palette-dark'], lightClasses: []`, while an app with an extra\n * design-system palette adds its own classes (e.g. `darkClasses: ['ion-palette-dark', 'a2ui-dark']`,\n * `lightClasses: ['a2ui-light']`).\n */\nexport interface KitThemeConfig {\n /** Key under which the chosen theme (`'light'` | `'dark'`) is persisted via `KitStorageService`. */\n readonly storageKey: string;\n /** Classes toggled **on** the document element when the dark theme is active. */\n readonly darkClasses: readonly string[];\n /** Classes toggled **on** the document element when the light theme is active. */\n readonly lightClasses: readonly string[];\n}\n\n/**\n * Injection token carrying the {@link KitThemeConfig} for `KitThemeController`.\n *\n * @remarks\n * Provide it through {@link provideKitTheme} rather than registering it directly.\n */\nexport const KIT_THEME_CONFIG = new InjectionToken<KitThemeConfig>('@rdlabo/ionic-angular-kit:theme');\n\n/**\n * Wire `KitThemeController` into the application.\n *\n * @param config - theme configuration: the storage key and the light/dark class lists\n * @returns environment providers to add to the application's provider list\n * @example\n * ```ts\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideKitTheme({\n * storageKey: StorageKeyEnum.theme,\n * darkClasses: ['ion-palette-dark', 'a2ui-dark'],\n * lightClasses: ['a2ui-light'],\n * }),\n * ],\n * });\n * ```\n */\nexport const provideKitTheme = (config: KitThemeConfig): EnvironmentProviders =>\n makeEnvironmentProviders([{ provide: KIT_THEME_CONFIG, useValue: config }]);\n","import { DOCUMENT, inject, Injectable } from '@angular/core';\nimport { Capacitor } from '@capacitor/core';\nimport { StatusBar, Style } from '@capacitor/status-bar';\nimport { BehaviorSubject } from 'rxjs';\n\nimport { KitStorageService } from '@rdlabo/ionic-angular-kit';\n\nimport { KIT_THEME_CONFIG } from './theme-config';\n\n/** The active theme mode. */\nexport type KitThemeMode = 'light' | 'dark';\n\n/**\n * Light/dark theme controller: persists the user's choice, follows the OS setting until the user\n * overrides it, toggles the configured palette classes, and syncs the native Android status bar.\n *\n * @remarks\n * Consolidates the theme logic that had drifted across the fleet into one behavior. Notably it fixes\n * a latent leak in one variant where the system-theme listener stayed registered after a manual\n * toggle: {@link changeTheme} always detaches the listener via {@link removeEventListener} before\n * applying the forced theme, so a later OS change can no longer silently flip an app the user pinned.\n *\n * - **Persistence** — the chosen mode is stored via {@link KitStorageService} under the configured key.\n * - **Follow OS until overridden** — on boot with nothing stored, it tracks\n * `prefers-color-scheme` (idempotent registration); once the user calls {@link changeTheme} it stops\n * following and honors the explicit choice.\n * - **Class toggling** — toggles {@link KitThemeConfig.darkClasses} on when dark and\n * {@link KitThemeConfig.lightClasses} on when light, absorbing per-app CSS differences via config.\n * - **Native status bar** — on Android native only, mirrors the Ionic behavior of setting the status\n * bar style to match (iOS derives it from the web content, so it is intentionally left untouched).\n *\n * Subscribe to {@link themeSubject} to reflect the current mode in the UI (e.g. a settings toggle).\n *\n * @example\n * ```ts\n * // On boot (app.component):\n * inject(KitThemeController).setDefaultThemeMode();\n *\n * // From a settings toggle:\n * const theme = inject(KitThemeController);\n * theme.themeSubject.subscribe((mode) => this.isDark.set(mode === 'dark'));\n * theme.changeTheme(true);\n * ```\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class KitThemeController {\n readonly #storage = inject(KitStorageService);\n readonly #document = inject(DOCUMENT);\n readonly #config = inject(KIT_THEME_CONFIG);\n\n /**\n * Emits the active theme, seeded with `'light'`.\n *\n * @remarks\n * A `BehaviorSubject`, so a late subscriber immediately receives the current mode; it emits again\n * on every {@link setDefaultThemeMode} / {@link changeTheme} and on OS theme changes while following.\n */\n readonly themeSubject = new BehaviorSubject<KitThemeMode>('light');\n\n #prefersDark?: MediaQueryList;\n #onSystemThemeChange?: (e: MediaQueryListEvent) => void;\n\n /**\n * Apply the persisted theme, or start following the OS setting when nothing is stored yet.\n *\n * @remarks\n * Call once on boot (e.g. from `app.component`).\n *\n * @returns a Promise that resolves once the initial theme has been applied\n */\n async setDefaultThemeMode(): Promise<void> {\n const stored = await this.#storage.get<KitThemeMode>(this.#config.storageKey);\n if (stored) {\n // 保存済みの選択を強制し、OS 追従は解除する。\n this.#unwatchSystemTheme();\n return this.#applyTheme(stored === 'dark');\n }\n\n // 未保存 → OS の設定に追従する。\n this.#watchSystemTheme();\n }\n\n /**\n * Force a theme, persist it, and stop following the OS setting.\n *\n * @param isDark - `true` for the dark theme, `false` for light\n * @returns a Promise that resolves once the theme has been persisted and applied\n */\n async changeTheme(isDark: boolean): Promise<void> {\n this.#unwatchSystemTheme();\n await this.#storage.set(this.#config.storageKey, isDark ? 'dark' : 'light');\n await this.#applyTheme(isDark);\n }\n\n #watchSystemTheme(): void {\n if (this.#prefersDark) {\n // 既に監視中なら二重登録しない(冪等)。\n return;\n }\n this.#prefersDark = window.matchMedia('(prefers-color-scheme: dark)');\n this.#onSystemThemeChange = (e) => void this.#applyTheme(e.matches);\n this.#prefersDark.addEventListener('change', this.#onSystemThemeChange, { passive: true });\n void this.#applyTheme(this.#prefersDark.matches);\n }\n\n #unwatchSystemTheme(): void {\n if (this.#prefersDark && this.#onSystemThemeChange) {\n this.#prefersDark.removeEventListener('change', this.#onSystemThemeChange);\n }\n this.#prefersDark = undefined;\n this.#onSystemThemeChange = undefined;\n }\n\n async #applyTheme(isDark: boolean): Promise<void> {\n if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {\n await StatusBar.setStyle({ style: isDark ? Style.Dark : Style.Light });\n }\n const root = this.#document.documentElement;\n for (const cls of this.#config.darkClasses) {\n root.classList.toggle(cls, isDark);\n }\n for (const cls of this.#config.lightClasses) {\n root.classList.toggle(cls, !isDark);\n }\n this.themeSubject.next(isDark ? 'dark' : 'light');\n }\n}\n","// Theme: light/dark controller with OS-follow and native status-bar sync.\n// Its own entry point so only apps that theme pull in `@capacitor/status-bar`.\nexport * from './theme-config';\nexport * from './kit-theme.controller';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AAuBA;;;;;AAKG;MACU,gBAAgB,GAAG,IAAI,cAAc,CAAiB,iCAAiC;AAEpG;;;;;;;;;;;;;;;;;AAiBG;MACU,eAAe,GAAG,CAAC,MAAsB,KACpD,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;;ACtC5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;MAIU,kBAAkB,CAAA;AAH/B,IAAA,WAAA,GAAA;AAIW,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,iBAAiB,CAAC;AACpC,QAAA,IAAA,CAAA,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC5B,QAAA,IAAA,CAAA,OAAO,GAAG,MAAM,CAAC,gBAAgB,CAAC;AAE3C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A,kBAAkB,cAFjB,MAAM,EAAA,CAAA,CAAA;;4FAEP,kBAAkB,EAAA,UAAA,EAAA,CAAA;kBAH9B,UAAU;AAAC,YAAA,IAAA,EAAA,CAAA;AACV,oBAAA,UAAU,EAAE,MAAM;AACnB,iBAAA;;;AC9CD;AACA;;ACDA;;AAEG;;;;"}
|
|
1
|
+
{"version":3,"file":"rdlabo-ionic-angular-kit-theme.mjs","sources":["../../../projects/kit/theme/src/theme-config.ts","../../../projects/kit/theme/src/kit-theme.controller.ts","../../../projects/kit/theme/src/public-api.ts","../../../projects/kit/theme/src/rdlabo-ionic-angular-kit-theme.ts"],"sourcesContent":["import type { EnvironmentProviders } from '@angular/core';\nimport { InjectionToken, makeEnvironmentProviders } from '@angular/core';\n\n/**\n * Theme configuration injected via `provideKitTheme()` and consumed by `KitThemeController`.\n *\n * @remarks\n * All fields are required; the consuming application supplies a complete configuration so every app\n * in the fleet has the same shape. The class lists absorb the per-app CSS drift: the kit toggles\n * `darkClasses` on when dark and `lightClasses` on when light, so an app that only uses Ionic's\n * palette passes `darkClasses: ['ion-palette-dark'], lightClasses: []`, while an app with an extra\n * design-system palette adds its own classes (e.g. `darkClasses: ['ion-palette-dark', 'a2ui-dark']`,\n * `lightClasses: ['a2ui-light']`).\n *\n * Prefer `KIT_THEME_STORAGE_KEY` (from `@rdlabo/ionic-angular-kit`) as `storageKey` so logout\n * clear-preserving lists stay in sync.\n */\nexport interface KitThemeConfig {\n /** Key under which the chosen theme (`'light'` | `'dark'`) is persisted via `KitStorageService`. */\n readonly storageKey: string;\n /** Classes toggled **on** the document element when the dark theme is active. */\n readonly darkClasses: readonly string[];\n /** Classes toggled **on** the document element when the light theme is active. */\n readonly lightClasses: readonly string[];\n}\n\n/**\n * Injection token carrying the {@link KitThemeConfig} for `KitThemeController`.\n *\n * @remarks\n * Provide it through {@link provideKitTheme} rather than registering it directly.\n */\nexport const KIT_THEME_CONFIG = new InjectionToken<KitThemeConfig>('@rdlabo/ionic-angular-kit:theme');\n\n/**\n * Wire `KitThemeController` into the application.\n *\n * @param config - theme configuration: the storage key and the light/dark class lists\n * @returns environment providers to add to the application's provider list\n * @example\n * ```ts\n * import { KIT_THEME_STORAGE_KEY } from '@rdlabo/ionic-angular-kit';\n * import { provideKitTheme } from '@rdlabo/ionic-angular-kit/theme';\n *\n * bootstrapApplication(AppComponent, {\n * providers: [\n * provideKitTheme({\n * storageKey: KIT_THEME_STORAGE_KEY,\n * darkClasses: ['ion-palette-dark', 'a2ui-dark'],\n * lightClasses: ['a2ui-light'],\n * }),\n * ],\n * });\n * ```\n */\nexport const provideKitTheme = (config: KitThemeConfig): EnvironmentProviders =>\n makeEnvironmentProviders([{ provide: KIT_THEME_CONFIG, useValue: config }]);\n","import { DOCUMENT, inject, Injectable } from '@angular/core';\nimport { Capacitor } from '@capacitor/core';\nimport { StatusBar, Style } from '@capacitor/status-bar';\nimport { BehaviorSubject } from 'rxjs';\n\nimport { KitStorageService } from '@rdlabo/ionic-angular-kit';\n\nimport { KIT_THEME_CONFIG } from './theme-config';\n\n/** The active theme mode. */\nexport type KitThemeMode = 'light' | 'dark';\n\n/**\n * Light/dark theme controller: persists the user's choice, follows the OS setting until the user\n * overrides it, toggles the configured palette classes, and syncs the native Android status bar.\n *\n * @remarks\n * Consolidates the theme logic that had drifted across the fleet into one behavior. Notably it fixes\n * a latent leak in one variant where the system-theme listener stayed registered after a manual\n * toggle: {@link changeTheme} always detaches the listener via {@link removeEventListener} before\n * applying the forced theme, so a later OS change can no longer silently flip an app the user pinned.\n *\n * - **Persistence** — the chosen mode is stored via {@link KitStorageService} under the configured key.\n * - **Follow OS until overridden** — on boot with nothing stored, it tracks\n * `prefers-color-scheme` (idempotent registration); once the user calls {@link changeTheme} it stops\n * following and honors the explicit choice.\n * - **Class toggling** — toggles {@link KitThemeConfig.darkClasses} on when dark and\n * {@link KitThemeConfig.lightClasses} on when light, absorbing per-app CSS differences via config.\n * - **Native status bar** — on Android native only, mirrors the Ionic behavior of setting the status\n * bar style to match (iOS derives it from the web content, so it is intentionally left untouched).\n *\n * Subscribe to {@link themeSubject} to reflect the current mode in the UI (e.g. a settings toggle).\n *\n * @example\n * ```ts\n * // On boot (app.component):\n * inject(KitThemeController).setDefaultThemeMode();\n *\n * // From a settings toggle:\n * const theme = inject(KitThemeController);\n * theme.themeSubject.subscribe((mode) => this.isDark.set(mode === 'dark'));\n * theme.changeTheme(true);\n * ```\n */\n@Injectable({\n providedIn: 'root',\n})\nexport class KitThemeController {\n readonly #storage = inject(KitStorageService);\n readonly #document = inject(DOCUMENT);\n readonly #config = inject(KIT_THEME_CONFIG);\n\n /**\n * Emits the active theme, seeded with `'light'`.\n *\n * @remarks\n * A `BehaviorSubject`, so a late subscriber immediately receives the current mode; it emits again\n * on every {@link setDefaultThemeMode} / {@link changeTheme} and on OS theme changes while following.\n */\n readonly themeSubject = new BehaviorSubject<KitThemeMode>('light');\n\n #prefersDark?: MediaQueryList;\n #onSystemThemeChange?: (e: MediaQueryListEvent) => void;\n\n /**\n * Apply the persisted theme, or start following the OS setting when nothing is stored yet.\n *\n * @remarks\n * Call once on boot (e.g. from `app.component`).\n *\n * @returns a Promise that resolves once the initial theme has been applied\n */\n async setDefaultThemeMode(): Promise<void> {\n const stored = await this.#storage.get<KitThemeMode>(this.#config.storageKey);\n if (stored) {\n // 保存済みの選択を強制し、OS 追従は解除する。\n this.#unwatchSystemTheme();\n return this.#applyTheme(stored === 'dark');\n }\n\n // 未保存 → OS の設定に追従する。\n this.#watchSystemTheme();\n }\n\n /**\n * Force a theme, persist it, and stop following the OS setting.\n *\n * @param isDark - `true` for the dark theme, `false` for light\n * @returns a Promise that resolves once the theme has been persisted and applied\n */\n async changeTheme(isDark: boolean): Promise<void> {\n this.#unwatchSystemTheme();\n await this.#storage.set(this.#config.storageKey, isDark ? 'dark' : 'light');\n await this.#applyTheme(isDark);\n }\n\n #watchSystemTheme(): void {\n if (this.#prefersDark) {\n // 既に監視中なら二重登録しない(冪等)。\n return;\n }\n this.#prefersDark = window.matchMedia('(prefers-color-scheme: dark)');\n this.#onSystemThemeChange = (e) => void this.#applyTheme(e.matches);\n this.#prefersDark.addEventListener('change', this.#onSystemThemeChange, { passive: true });\n void this.#applyTheme(this.#prefersDark.matches);\n }\n\n #unwatchSystemTheme(): void {\n if (this.#prefersDark && this.#onSystemThemeChange) {\n this.#prefersDark.removeEventListener('change', this.#onSystemThemeChange);\n }\n this.#prefersDark = undefined;\n this.#onSystemThemeChange = undefined;\n }\n\n async #applyTheme(isDark: boolean): Promise<void> {\n if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {\n await StatusBar.setStyle({ style: isDark ? Style.Dark : Style.Light });\n }\n const root = this.#document.documentElement;\n for (const cls of this.#config.darkClasses) {\n root.classList.toggle(cls, isDark);\n }\n for (const cls of this.#config.lightClasses) {\n root.classList.toggle(cls, !isDark);\n }\n this.themeSubject.next(isDark ? 'dark' : 'light');\n }\n}\n","// Theme: light/dark controller with OS-follow and native status-bar sync.\n// Its own entry point so only apps that theme pull in `@capacitor/status-bar`.\nexport * from './theme-config';\nexport * from './kit-theme.controller';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;;;;AA0BA;;;;;AAKG;MACU,gBAAgB,GAAG,IAAI,cAAc,CAAiB,iCAAiC;AAEpG;;;;;;;;;;;;;;;;;;;;AAoBG;MACU,eAAe,GAAG,CAAC,MAAsB,KACpD,wBAAwB,CAAC,CAAC,EAAE,OAAO,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC;;AC5C5E;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BG;MAIU,kBAAkB,CAAA;AAH/B,IAAA,WAAA,GAAA;AAIW,QAAA,IAAA,CAAA,QAAQ,GAAG,MAAM,CAAC,iBAAiB,CAAC;AACpC,QAAA,IAAA,CAAA,SAAS,GAAG,MAAM,CAAC,QAAQ,CAAC;AAC5B,QAAA,IAAA,CAAA,OA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