@rdlabo/ionic-angular-kit 0.0.14 → 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.
@@ -0,0 +1,146 @@
1
+ import { Capacitor } from '@capacitor/core';
2
+ import { BRLMPrinterHalftone, BRLMPrinterCustomPaperUnit, BRLMPrinterCustomPaperType, BRLMPrinterPrintQuality, BRLMPrinterHorizontalAlignment, BRLMPrinterVerticalAlignment, BRLMPrinterImageRotation, BRLMPrinterScaleMode } from '@rdlabo/capacitor-brotherprint';
3
+ import domtoimage from 'dom-to-image-more';
4
+
5
+ /**
6
+ * Rotate a base64 image 90°, returning a new base64 data URL of the same MIME type.
7
+ *
8
+ * @remarks
9
+ * Pure DOM/canvas work — no DI. Used before sending a label to the printer when the artwork must be
10
+ * turned to match the tape orientation. Extracted verbatim from the fleet's printer services so the
11
+ * canvas handling lives in one place.
12
+ *
13
+ * @param imageData - a base64 data URL (e.g. `data:image/png;base64,...`)
14
+ * @returns a Promise resolving to the rotated image as a base64 data URL
15
+ */
16
+ const kitRotationImage = async (imageData) => {
17
+ const imgType = imageData.substring(5, imageData.indexOf(';'));
18
+ const image = new Image();
19
+ const loaded = new Promise((resolve) => {
20
+ image.onload = () => resolve();
21
+ });
22
+ image.src = imageData;
23
+ await loaded;
24
+ const canvas = document.createElement('canvas');
25
+ const ctx = canvas.getContext('2d');
26
+ canvas.width = image.height;
27
+ canvas.height = image.width;
28
+ ctx.rotate((90 * Math.PI) / 180);
29
+ ctx.translate(0, -image.height);
30
+ ctx.drawImage(image, 0, 0, image.width, image.height);
31
+ return canvas.toDataURL(imgType);
32
+ };
33
+ /**
34
+ * Render a DOM element to a base64 PNG for label printing, with the fleet's device-specific fixes.
35
+ *
36
+ * @remarks
37
+ * Pure function — no DI (reads the platform from `Capacitor`, uses the global `document`), so the
38
+ * caller presents its own loading UI around it. Centralizes the hard-won device quirks: on iOS it
39
+ * pads width/height by 2px (otherwise the bottom is clipped), on Android it does not (the padding
40
+ * introduces a black line). Retries the `dom-to-image-more` render up to 10 times because the first
41
+ * pass can occasionally return empty. This is exactly the kind of plumbing where a future fix should
42
+ * land in every app at once.
43
+ *
44
+ * @param element - the element to rasterize (e.g. the label preview host)
45
+ * @param options - rendering options; see {@link KitDomToPngOptions}
46
+ * @returns a Promise resolving to the PNG as a base64 data URL (empty string if every attempt failed)
47
+ * @example
48
+ * ```ts
49
+ * const loading = await this.#loadingCtrl.create({ message: this.text.generating });
50
+ * await loading.present();
51
+ * const png = await kitDomToPng(this.preview().nativeElement, { rotate: true });
52
+ * await loading.dismiss();
53
+ * ```
54
+ */
55
+ const kitDomToPng = async (element, options) => {
56
+ await new Promise((resolve) => requestAnimationFrame(resolve));
57
+ const { clientHeight, clientWidth } = element;
58
+ // デバイス毎の問題解決のため、px 調整。
59
+ // iOS: ないと下が途切れる。Android: あると黒線が入る。
60
+ const addClient = Capacitor.getPlatform() === 'ios' ? 2 : 0;
61
+ let dataUrl = '';
62
+ for (let i = 0; i < 10; i++) {
63
+ const url = await domtoimage.toPng(element, {
64
+ width: clientWidth + addClient,
65
+ height: clientHeight + addClient,
66
+ scale: options?.scale ?? 3,
67
+ copyDefaultStyles: false,
68
+ });
69
+ if (url) {
70
+ dataUrl = url;
71
+ break;
72
+ }
73
+ }
74
+ return options?.rotate ? kitRotationImage(dataUrl) : dataUrl;
75
+ };
76
+ /**
77
+ * Assemble the Brother `BRLMPrintOptions` for a die-cut label print, minus the transport fields.
78
+ *
79
+ * @remarks
80
+ * Pure function — no DI. Centralizes the fleet's canonical print settings (fit-page scale, centered,
81
+ * best quality, threshold halftone, 2mm/1mm margins, `gapLength` 2.0) and the tape sizing derived
82
+ * from the label's `W<width>H<height>` code. The caller merges the printer's `port` / `channelInfo`
83
+ * onto the result before calling `BrotherPrint.printImage()`, so channel selection and loading UI stay
84
+ * in the app.
85
+ *
86
+ * @param params - model, artwork, label, copies, and halftone threshold; see {@link KitBrotherPrintSettingsParams}
87
+ * @returns the `BRLMPrintOptions` ready to be spread with `{ port, channelInfo }`
88
+ * @example
89
+ * ```ts
90
+ * const settings = kitBuildBrotherPrintSettings({
91
+ * modelName, printBase64, label, numberOfCopies: printOptions.printNum, halftoneThreshold: printOptions.halftoneThreshold,
92
+ * });
93
+ * await BrotherPrint.printImage({ ...settings, port: channel.port, channelInfo: channel.channelInfo });
94
+ * ```
95
+ */
96
+ const kitBuildBrotherPrintSettings = (params) => {
97
+ const startPoint = params.printBase64.indexOf(',');
98
+ const tapeSize = params.label.match(/W(\d+)H(\d+)/);
99
+ const tapeWidth = tapeSize && tapeSize.length >= 2 ? parseInt(tapeSize[1], 10) : 0;
100
+ const tapeLength = tapeSize && tapeSize.length >= 3 ? parseInt(tapeSize[2], 10) : 0;
101
+ // `BRLMPrintOptions` is a `QL | TD` union; a die-cut label legitimately carries fields from both
102
+ // groups, so the object is composed via spreads to bypass the union's excess-property checks — the
103
+ // same technique the source printer services used.
104
+ return {
105
+ ...{
106
+ modelName: params.modelName,
107
+ encodedImage: params.printBase64.slice(startPoint + 1),
108
+ numberOfCopies: params.numberOfCopies,
109
+ autoCut: true,
110
+ scaleMode: BRLMPrinterScaleMode.FitPageAspect,
111
+ imageRotation: BRLMPrinterImageRotation.Rotate0,
112
+ verticalAlignment: BRLMPrinterVerticalAlignment.Center,
113
+ horizontalAlignment: BRLMPrinterHorizontalAlignment.Center,
114
+ printQuality: BRLMPrinterPrintQuality.Best,
115
+ },
116
+ ...{
117
+ labelName: params.label,
118
+ },
119
+ ...{
120
+ paperType: BRLMPrinterCustomPaperType.dieCutPaper,
121
+ paperUnit: BRLMPrinterCustomPaperUnit.mm,
122
+ halftone: BRLMPrinterHalftone.Threshold,
123
+ halftoneThreshold: params.halftoneThreshold,
124
+ tapeWidth: Number(tapeWidth.toFixed(1)),
125
+ tapeLength: Number(tapeLength.toFixed(1)),
126
+ gapLength: 2.0,
127
+ marginTop: 1.0,
128
+ marginRight: 2.0,
129
+ marginBottom: 1.0,
130
+ marginLeft: 2.0,
131
+ paperMarkPosition: 0,
132
+ paperMarkLength: 0,
133
+ },
134
+ };
135
+ };
136
+
137
+ // Printer: Brother label plumbing (DOM→PNG, rotation, print-settings assembly).
138
+ // Split into its own entry point so only apps that print pull in `@rdlabo/capacitor-brotherprint`
139
+ // and `dom-to-image-more`; the core entry stays free of those native peers.
140
+
141
+ /**
142
+ * Generated bundle index. Do not edit.
143
+ */
144
+
145
+ export { kitBuildBrotherPrintSettings, kitDomToPng, kitRotationImage };
146
+ //# sourceMappingURL=rdlabo-ionic-angular-kit-printer.mjs.map
@@ -0,0 +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,CAA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B,CAAC,IAAI;AAC3C,SAAA;QACD,GAAG;YACD,SAAS,EAAE,MAAM,CAAC,KAAK;AACxB,SAAA;QACD,GAAG;YACD,SAAS,EAAE,0BAA0B,CAAC,WAAW;YACjD,SAAS,EAAE,0BAA0B,CAAC,EAAE;YACxC,QAAQ,EAAE,mBAAmB,CAAC,SAAS;YACvC,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;YAC3C,SAAS,EAAE,MAAM,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACvC,UAAU,EAAE,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;AACzC,YAAA,SAAS,EAAE,GAAG;AAEd,YAAA,SAAS,EAAE,GAAG;AACd,YAAA,WAAW,EAAE,GAAG;AAChB,YAAA,YAAY,EAAE,GAAG;AACjB,YAAA,UAAU,EAAE,GAAG;AAEf,YAAA,iBAAiB,EAAE,CAAC;AACpB,YAAA,eAAe,EAAE,CAAC;AACnB,SAAA;KACF;AACH;;ACrLA;AACA;AACA;;ACFA;;AAEG;;;;"}
@@ -0,0 +1,48 @@
1
+ import { Capacitor } from '@capacitor/core';
2
+ import { Preferences } from '@capacitor/preferences';
3
+ import { InAppReview } from '@capacitor-community/in-app-review';
4
+
5
+ /**
6
+ * Request the native in-app review dialog, throttled so the user is prompted at most once per window.
7
+ *
8
+ * @remarks
9
+ * A plain function — no DI needed (`@capacitor/preferences`, `@capacitor-community/in-app-review` and
10
+ * `Capacitor` are all static), so the caller invokes it directly and passes its own config rather
11
+ * than injecting a controller. A no-op on non-native platforms. When enough time has elapsed since
12
+ * the last prompt (per {@link KitRequestReviewOptions.throttleMonths}, tracked under
13
+ * {@link KitRequestReviewOptions.storageKey}), it briefly waits for the app to settle, calls
14
+ * `InAppReview.requestReview()`, and records the new timestamp. The wait/throttle/record sequence
15
+ * was previously copy-pasted verbatim across the fleet; centralizing it means a single place to tune
16
+ * the prompt cadence.
17
+ *
18
+ * @param options - the storage key and throttle window; see {@link KitRequestReviewOptions}
19
+ * @returns a Promise that resolves once the request has been made (or immediately if throttled / on web)
20
+ * @example
21
+ * ```ts
22
+ * await kitRequestReview({ storageKey: StorageEnum.lastRequestRate, throttleMonths: 3 });
23
+ * ```
24
+ */
25
+ const kitRequestReview = async (options) => {
26
+ if (!Capacitor.isNativePlatform()) {
27
+ return;
28
+ }
29
+ await new Promise((resolve) => setTimeout(() => resolve(), 1000));
30
+ const threshold = new Date();
31
+ threshold.setMonth(threshold.getMonth() - options.throttleMonths);
32
+ const { value } = await Preferences.get({ key: options.storageKey });
33
+ if (!value || new Date(Number(value)).getTime() < threshold.getTime()) {
34
+ await InAppReview.requestReview();
35
+ await Preferences.set({ key: options.storageKey, value: new Date().getTime().toString() });
36
+ }
37
+ };
38
+
39
+ // Review: throttled native in-app review request.
40
+ // Its own entry point so only apps that request reviews pull in
41
+ // `@capacitor-community/in-app-review` and `@capacitor/preferences`.
42
+
43
+ /**
44
+ * Generated bundle index. Do not edit.
45
+ */
46
+
47
+ export { kitRequestReview };
48
+ //# sourceMappingURL=rdlabo-ionic-angular-kit-review.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"rdlabo-ionic-angular-kit-review.mjs","sources":["../../../projects/kit/review/src/kit-request-review.ts","../../../projects/kit/review/src/public-api.ts","../../../projects/kit/review/src/rdlabo-ionic-angular-kit-review.ts"],"sourcesContent":["import { Capacitor } from '@capacitor/core';\nimport { Preferences } from '@capacitor/preferences';\nimport { InAppReview } from '@capacitor-community/in-app-review';\n\n/**\n * Options for {@link kitRequestReview}.\n */\nexport interface KitRequestReviewOptions {\n /**\n * Key under which the timestamp of the last review request is stored (via `@capacitor/preferences`).\n *\n * @remarks\n * Supplied by the caller so the kit ships no storage keys of its own; each app passes its own enum\n * value.\n */\n readonly storageKey: string;\n /**\n * Minimum number of months between review prompts.\n *\n * @remarks\n * A prompt is only shown when this much time has elapsed since the last one (or when there is no\n * record yet), so the OS review dialog is never nagged repeatedly.\n */\n readonly throttleMonths: number;\n}\n\n/**\n * Request the native in-app review dialog, throttled so the user is prompted at most once per window.\n *\n * @remarks\n * A plain function — no DI needed (`@capacitor/preferences`, `@capacitor-community/in-app-review` and\n * `Capacitor` are all static), so the caller invokes it directly and passes its own config rather\n * than injecting a controller. A no-op on non-native platforms. When enough time has elapsed since\n * the last prompt (per {@link KitRequestReviewOptions.throttleMonths}, tracked under\n * {@link KitRequestReviewOptions.storageKey}), it briefly waits for the app to settle, calls\n * `InAppReview.requestReview()`, and records the new timestamp. The wait/throttle/record sequence\n * was previously copy-pasted verbatim across the fleet; centralizing it means a single place to tune\n * the prompt cadence.\n *\n * @param options - the storage key and throttle window; see {@link KitRequestReviewOptions}\n * @returns a Promise that resolves once the request has been made (or immediately if throttled / on web)\n * @example\n * ```ts\n * await kitRequestReview({ storageKey: StorageEnum.lastRequestRate, throttleMonths: 3 });\n * ```\n */\nexport const kitRequestReview = async (options: KitRequestReviewOptions): Promise<void> => {\n if (!Capacitor.isNativePlatform()) {\n return;\n }\n\n await new Promise<void>((resolve) => setTimeout(() => resolve(), 1000));\n const threshold = new Date();\n threshold.setMonth(threshold.getMonth() - options.throttleMonths);\n\n const { value } = await Preferences.get({ key: options.storageKey });\n if (!value || new Date(Number(value)).getTime() < threshold.getTime()) {\n await InAppReview.requestReview();\n await Preferences.set({ key: options.storageKey, value: new Date().getTime().toString() });\n }\n};\n","// Review: throttled native in-app review request.\n// Its own entry point so only apps that request reviews pull in\n// `@capacitor-community/in-app-review` and `@capacitor/preferences`.\nexport * from './kit-request-review';\n","/**\n * Generated bundle index. Do not edit.\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;;;AA0BA;;;;;;;;;;;;;;;;;;;AAmBG;MACU,gBAAgB,GAAG,OAAO,OAAgC,KAAmB;AACxF,IAAA,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE,EAAE;QACjC;IACF;AAEA,IAAA,MAAM,IAAI,OAAO,CAAO,CAAC,OAAO,KAAK,UAAU,CAAC,MAAM,OAAO,EAAE,EAAE,IAAI,CAAC,CAAC;AACvE,IAAA,MAAM,SAAS,GAAG,IAAI,IAAI,EAAE;AAC5B,IAAA,SAAS,CAAC,QAAQ,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG,OAAO,CAAC,cAAc,CAAC;AAEjE,IAAA,MAAM,EAAE,KAAK,EAAE,GAAG,MAAM,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE,CAAC;IACpE,IAAI,CAAC,KAAK,IAAI,IAAI,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC,OAAO,EAAE,GAAG,SAAS,CAAC,OAAO,EAAE,EAAE;AACrE,QAAA,MAAM,WAAW,CAAC,aAAa,EAAE;QACjC,MAAM,WAAW,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,OAAO,CAAC,UAAU,EAAE,KAAK,EAAE,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC,QAAQ,EAAE,EAAE,CAAC;IAC5F;AACF;;AC5DA;AACA;AACA;;ACFA;;AAEG;;;;"}
@@ -0,0 +1,163 @@
1
+ import * as i0 from '@angular/core';
2
+ import { InjectionToken, makeEnvironmentProviders, inject, DOCUMENT, Injectable } from '@angular/core';
3
+ import { Capacitor } from '@capacitor/core';
4
+ import { StatusBar, Style } from '@capacitor/status-bar';
5
+ import { BehaviorSubject } from 'rxjs';
6
+ import { KitStorageService } from '@rdlabo/ionic-angular-kit';
7
+
8
+ /**
9
+ * Injection token carrying the {@link KitThemeConfig} for `KitThemeController`.
10
+ *
11
+ * @remarks
12
+ * Provide it through {@link provideKitTheme} rather than registering it directly.
13
+ */
14
+ const KIT_THEME_CONFIG = new InjectionToken('@rdlabo/ionic-angular-kit:theme');
15
+ /**
16
+ * Wire `KitThemeController` into the application.
17
+ *
18
+ * @param config - theme configuration: the storage key and the light/dark class lists
19
+ * @returns environment providers to add to the application's provider list
20
+ * @example
21
+ * ```ts
22
+ * bootstrapApplication(AppComponent, {
23
+ * providers: [
24
+ * provideKitTheme({
25
+ * storageKey: StorageKeyEnum.theme,
26
+ * darkClasses: ['ion-palette-dark', 'a2ui-dark'],
27
+ * lightClasses: ['a2ui-light'],
28
+ * }),
29
+ * ],
30
+ * });
31
+ * ```
32
+ */
33
+ const provideKitTheme = (config) => makeEnvironmentProviders([{ provide: KIT_THEME_CONFIG, useValue: config }]);
34
+
35
+ /**
36
+ * Light/dark theme controller: persists the user's choice, follows the OS setting until the user
37
+ * overrides it, toggles the configured palette classes, and syncs the native Android status bar.
38
+ *
39
+ * @remarks
40
+ * Consolidates the theme logic that had drifted across the fleet into one behavior. Notably it fixes
41
+ * a latent leak in one variant where the system-theme listener stayed registered after a manual
42
+ * toggle: {@link changeTheme} always detaches the listener via {@link removeEventListener} before
43
+ * applying the forced theme, so a later OS change can no longer silently flip an app the user pinned.
44
+ *
45
+ * - **Persistence** — the chosen mode is stored via {@link KitStorageService} under the configured key.
46
+ * - **Follow OS until overridden** — on boot with nothing stored, it tracks
47
+ * `prefers-color-scheme` (idempotent registration); once the user calls {@link changeTheme} it stops
48
+ * following and honors the explicit choice.
49
+ * - **Class toggling** — toggles {@link KitThemeConfig.darkClasses} on when dark and
50
+ * {@link KitThemeConfig.lightClasses} on when light, absorbing per-app CSS differences via config.
51
+ * - **Native status bar** — on Android native only, mirrors the Ionic behavior of setting the status
52
+ * bar style to match (iOS derives it from the web content, so it is intentionally left untouched).
53
+ *
54
+ * Subscribe to {@link themeSubject} to reflect the current mode in the UI (e.g. a settings toggle).
55
+ *
56
+ * @example
57
+ * ```ts
58
+ * // On boot (app.component):
59
+ * inject(KitThemeController).setDefaultThemeMode();
60
+ *
61
+ * // From a settings toggle:
62
+ * const theme = inject(KitThemeController);
63
+ * theme.themeSubject.subscribe((mode) => this.isDark.set(mode === 'dark'));
64
+ * theme.changeTheme(true);
65
+ * ```
66
+ */
67
+ class KitThemeController {
68
+ constructor() {
69
+ this.#storage = inject(KitStorageService);
70
+ this.#document = inject(DOCUMENT);
71
+ this.#config = inject(KIT_THEME_CONFIG);
72
+ /**
73
+ * Emits the active theme, seeded with `'light'`.
74
+ *
75
+ * @remarks
76
+ * A `BehaviorSubject`, so a late subscriber immediately receives the current mode; it emits again
77
+ * on every {@link setDefaultThemeMode} / {@link changeTheme} and on OS theme changes while following.
78
+ */
79
+ this.themeSubject = new BehaviorSubject('light');
80
+ }
81
+ #storage;
82
+ #document;
83
+ #config;
84
+ #prefersDark;
85
+ #onSystemThemeChange;
86
+ /**
87
+ * Apply the persisted theme, or start following the OS setting when nothing is stored yet.
88
+ *
89
+ * @remarks
90
+ * Call once on boot (e.g. from `app.component`).
91
+ *
92
+ * @returns a Promise that resolves once the initial theme has been applied
93
+ */
94
+ async setDefaultThemeMode() {
95
+ const stored = await this.#storage.get(this.#config.storageKey);
96
+ if (stored) {
97
+ // 保存済みの選択を強制し、OS 追従は解除する。
98
+ this.#unwatchSystemTheme();
99
+ return this.#applyTheme(stored === 'dark');
100
+ }
101
+ // 未保存 → OS の設定に追従する。
102
+ this.#watchSystemTheme();
103
+ }
104
+ /**
105
+ * Force a theme, persist it, and stop following the OS setting.
106
+ *
107
+ * @param isDark - `true` for the dark theme, `false` for light
108
+ * @returns a Promise that resolves once the theme has been persisted and applied
109
+ */
110
+ async changeTheme(isDark) {
111
+ this.#unwatchSystemTheme();
112
+ await this.#storage.set(this.#config.storageKey, isDark ? 'dark' : 'light');
113
+ await this.#applyTheme(isDark);
114
+ }
115
+ #watchSystemTheme() {
116
+ if (this.#prefersDark) {
117
+ // 既に監視中なら二重登録しない(冪等)。
118
+ return;
119
+ }
120
+ this.#prefersDark = window.matchMedia('(prefers-color-scheme: dark)');
121
+ this.#onSystemThemeChange = (e) => void this.#applyTheme(e.matches);
122
+ this.#prefersDark.addEventListener('change', this.#onSystemThemeChange, { passive: true });
123
+ void this.#applyTheme(this.#prefersDark.matches);
124
+ }
125
+ #unwatchSystemTheme() {
126
+ if (this.#prefersDark && this.#onSystemThemeChange) {
127
+ this.#prefersDark.removeEventListener('change', this.#onSystemThemeChange);
128
+ }
129
+ this.#prefersDark = undefined;
130
+ this.#onSystemThemeChange = undefined;
131
+ }
132
+ async #applyTheme(isDark) {
133
+ if (Capacitor.isNativePlatform() && Capacitor.getPlatform() === 'android') {
134
+ await StatusBar.setStyle({ style: isDark ? Style.Dark : Style.Light });
135
+ }
136
+ const root = this.#document.documentElement;
137
+ for (const cls of this.#config.darkClasses) {
138
+ root.classList.toggle(cls, isDark);
139
+ }
140
+ for (const cls of this.#config.lightClasses) {
141
+ root.classList.toggle(cls, !isDark);
142
+ }
143
+ this.themeSubject.next(isDark ? 'dark' : 'light');
144
+ }
145
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: KitThemeController, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
146
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: KitThemeController, providedIn: 'root' }); }
147
+ }
148
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "21.2.17", ngImport: i0, type: KitThemeController, decorators: [{
149
+ type: Injectable,
150
+ args: [{
151
+ providedIn: 'root',
152
+ }]
153
+ }] });
154
+
155
+ // Theme: light/dark controller with OS-follow and native status-bar sync.
156
+ // Its own entry point so only apps that theme pull in `@capacitor/status-bar`.
157
+
158
+ /**
159
+ * Generated bundle index. Do not edit.
160
+ */
161
+
162
+ export { KIT_THEME_CONFIG, KitThemeController, provideKitTheme };
163
+ //# sourceMappingURL=rdlabo-ionic-angular-kit-theme.mjs.map
@@ -0,0 +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;;;;;;AAMG;AACM,QAAA,IAAA,CAAA,YAAY,GAAG,IAAI,eAAe,CAAe,OAAO,CAAC;AAqEnE,IAAA;AAhFU,IAAA,QAAQ;AACR,IAAA,SAAS;AACT,IAAA,OAAO;AAWhB,IAAA,YAAY;AACZ,IAAA,oBAAoB;AAEpB;;;;;;;AAOG;AACH,IAAA,MAAM,mBAAmB,GAAA;AACvB,QAAA,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAe,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC;QAC7E,IAAI,MAAM,EAAE;;YAEV,IAAI,CAAC,mBAAmB,EAAE;YAC1B,OAAO,IAAI,CAAC,WAAW,CAAC,MAAM,KAAK,MAAM,CAAC;QAC5C;;QAGA,IAAI,CAAC,iBAAiB,EAAE;IAC1B;AAEA;;;;;AAKG;IACH,MAAM,WAAW,CAAC,M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