@asiriindatissa/capacitor-health 8.2.1

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
+ export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight';
2
+ export type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram';
3
+ export interface AuthorizationOptions {
4
+ /** Data types that should be readable after authorization. */
5
+ read?: HealthDataType[];
6
+ /** Data types that should be writable after authorization. */
7
+ write?: HealthDataType[];
8
+ }
9
+ export interface AuthorizationStatus {
10
+ readAuthorized: HealthDataType[];
11
+ readDenied: HealthDataType[];
12
+ writeAuthorized: HealthDataType[];
13
+ writeDenied: HealthDataType[];
14
+ }
15
+ export interface AvailabilityResult {
16
+ available: boolean;
17
+ /** Platform specific details (for debugging/diagnostics). */
18
+ platform?: 'android' | 'web';
19
+ reason?: string;
20
+ }
21
+ export interface QueryOptions {
22
+ /** The type of data to retrieve from the health store. */
23
+ dataType: HealthDataType;
24
+ /** Inclusive ISO 8601 start date (defaults to now - 1 day). */
25
+ startDate?: string;
26
+ /** Exclusive ISO 8601 end date (defaults to now). */
27
+ endDate?: string;
28
+ /** Maximum number of samples to return (defaults to 100). */
29
+ limit?: number;
30
+ /** Return results sorted ascending by start date (defaults to false). */
31
+ ascending?: boolean;
32
+ }
33
+ export interface HealthSample {
34
+ dataType: HealthDataType;
35
+ value: number;
36
+ unit: HealthUnit;
37
+ startDate: string;
38
+ endDate: string;
39
+ sourceName?: string;
40
+ sourceId?: string;
41
+ }
42
+ export interface ReadSamplesResult {
43
+ samples: HealthSample[];
44
+ }
45
+ export type WorkoutType = 'running' | 'cycling' | 'walking' | 'swimming' | 'yoga' | 'strengthTraining' | 'hiking' | 'tennis' | 'basketball' | 'soccer' | 'americanFootball' | 'baseball' | 'crossTraining' | 'elliptical' | 'rowing' | 'stairClimbing' | 'traditionalStrengthTraining' | 'waterFitness' | 'waterPolo' | 'waterSports' | 'wrestling' | 'other';
46
+ export interface QueryWorkoutsOptions {
47
+ /** Optional workout type filter. If omitted, all workout types are returned. */
48
+ workoutType?: WorkoutType;
49
+ /** Inclusive ISO 8601 start date (defaults to now - 1 day). */
50
+ startDate?: string;
51
+ /** Exclusive ISO 8601 end date (defaults to now). */
52
+ endDate?: string;
53
+ /** Maximum number of workouts to return (defaults to 100). */
54
+ limit?: number;
55
+ /** Return results sorted ascending by start date (defaults to false). */
56
+ ascending?: boolean;
57
+ }
58
+ export interface Workout {
59
+ /** The type of workout. */
60
+ workoutType: WorkoutType;
61
+ /** Duration of the workout in seconds. */
62
+ duration: number;
63
+ /** Total energy burned in kilocalories (if available). */
64
+ totalEnergyBurned?: number;
65
+ /** Total distance in meters (if available). */
66
+ totalDistance?: number;
67
+ /** ISO 8601 start date of the workout. */
68
+ startDate: string;
69
+ /** ISO 8601 end date of the workout. */
70
+ endDate: string;
71
+ /** Source name that recorded the workout. */
72
+ sourceName?: string;
73
+ /** Source bundle identifier. */
74
+ sourceId?: string;
75
+ /** Additional metadata (if available). */
76
+ metadata?: Record<string, string>;
77
+ }
78
+ export interface QueryWorkoutsResult {
79
+ workouts: Workout[];
80
+ }
81
+ export interface WriteSampleOptions {
82
+ dataType: HealthDataType;
83
+ value: number;
84
+ /**
85
+ * Optional unit override. If omitted, the default unit for the data type is used
86
+ * (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`).
87
+ */
88
+ unit?: HealthUnit;
89
+ /** ISO 8601 start date for the sample. Defaults to now. */
90
+ startDate?: string;
91
+ /** ISO 8601 end date for the sample. Defaults to startDate. */
92
+ endDate?: string;
93
+ /** Metadata key-value pairs forwarded to the native APIs where supported. */
94
+ metadata?: Record<string, string>;
95
+ }
96
+ export interface HealthPlugin {
97
+ /** Returns whether the current platform supports the native health SDK. */
98
+ isAvailable(): Promise<AvailabilityResult>;
99
+ /** Requests read/write access to the provided data types. */
100
+ requestAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;
101
+ /** Checks authorization status for the provided data types without prompting the user. */
102
+ checkAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;
103
+ /** Reads samples for the given data type within the specified time frame. */
104
+ readSamples(options: QueryOptions): Promise<ReadSamplesResult>;
105
+ /** Writes a single sample to the native health store. */
106
+ saveSample(options: WriteSampleOptions): Promise<void>;
107
+ /**
108
+ * Get the native Capacitor plugin version
109
+ *
110
+ * @returns {Promise<{ version: string }>} a Promise with version for this device
111
+ * @throws An error if something went wrong
112
+ */
113
+ getPluginVersion(): Promise<{
114
+ version: string;
115
+ }>;
116
+ /**
117
+ * Opens the Health Connect settings screen.
118
+ *
119
+ * Use this to direct users to manage their Health Connect permissions
120
+ * or to install Health Connect if not available.
121
+ *
122
+ * @throws An error if Health Connect settings cannot be opened
123
+ */
124
+ openHealthConnectSettings(): Promise<void>;
125
+ /**
126
+ * Shows the app's privacy policy for Health Connect.
127
+ *
128
+ * This displays the same privacy policy screen that Health Connect shows
129
+ * when the user taps "Privacy policy" in the permissions dialog.
130
+ *
131
+ * The privacy policy URL can be configured by adding a string resource
132
+ * named "health_connect_privacy_policy_url" in your app's strings.xml,
133
+ * or by placing an HTML file at www/privacypolicy.html in your assets.
134
+ *
135
+ * @throws An error if the privacy policy cannot be displayed
136
+ */
137
+ showPrivacyPolicy(): Promise<void>;
138
+ /**
139
+ * Queries workout sessions from the native health store on Android (Health Connect).
140
+ *
141
+ * @param options Query options including optional workout type filter, date range, limit, and sort order
142
+ * @returns A promise that resolves with the workout sessions
143
+ * @throws An error if something went wrong
144
+ */
145
+ queryWorkouts(options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;
146
+ }
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"","sourcesContent":["export type HealthDataType = 'steps' | 'distance' | 'calories' | 'heartRate' | 'weight';\n\nexport type HealthUnit = 'count' | 'meter' | 'kilocalorie' | 'bpm' | 'kilogram';\n\nexport interface AuthorizationOptions {\n /** Data types that should be readable after authorization. */\n read?: HealthDataType[];\n /** Data types that should be writable after authorization. */\n write?: HealthDataType[];\n}\n\nexport interface AuthorizationStatus {\n readAuthorized: HealthDataType[];\n readDenied: HealthDataType[];\n writeAuthorized: HealthDataType[];\n writeDenied: HealthDataType[];\n}\n\nexport interface AvailabilityResult {\n available: boolean;\n /** Platform specific details (for debugging/diagnostics). */\n platform?: 'android' | 'web';\n reason?: string;\n}\n\nexport interface QueryOptions {\n /** The type of data to retrieve from the health store. */\n dataType: HealthDataType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of samples to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n}\n\nexport interface HealthSample {\n dataType: HealthDataType;\n value: number;\n unit: HealthUnit;\n startDate: string;\n endDate: string;\n sourceName?: string;\n sourceId?: string;\n}\n\nexport interface ReadSamplesResult {\n samples: HealthSample[];\n}\n\nexport type WorkoutType =\n | 'running'\n | 'cycling'\n | 'walking'\n | 'swimming'\n | 'yoga'\n | 'strengthTraining'\n | 'hiking'\n | 'tennis'\n | 'basketball'\n | 'soccer'\n | 'americanFootball'\n | 'baseball'\n | 'crossTraining'\n | 'elliptical'\n | 'rowing'\n | 'stairClimbing'\n | 'traditionalStrengthTraining'\n | 'waterFitness'\n | 'waterPolo'\n | 'waterSports'\n | 'wrestling'\n | 'other';\n\nexport interface QueryWorkoutsOptions {\n /** Optional workout type filter. If omitted, all workout types are returned. */\n workoutType?: WorkoutType;\n /** Inclusive ISO 8601 start date (defaults to now - 1 day). */\n startDate?: string;\n /** Exclusive ISO 8601 end date (defaults to now). */\n endDate?: string;\n /** Maximum number of workouts to return (defaults to 100). */\n limit?: number;\n /** Return results sorted ascending by start date (defaults to false). */\n ascending?: boolean;\n}\n\nexport interface Workout {\n /** The type of workout. */\n workoutType: WorkoutType;\n /** Duration of the workout in seconds. */\n duration: number;\n /** Total energy burned in kilocalories (if available). */\n totalEnergyBurned?: number;\n /** Total distance in meters (if available). */\n totalDistance?: number;\n /** ISO 8601 start date of the workout. */\n startDate: string;\n /** ISO 8601 end date of the workout. */\n endDate: string;\n /** Source name that recorded the workout. */\n sourceName?: string;\n /** Source bundle identifier. */\n sourceId?: string;\n /** Additional metadata (if available). */\n metadata?: Record<string, string>;\n}\n\nexport interface QueryWorkoutsResult {\n workouts: Workout[];\n}\n\nexport interface WriteSampleOptions {\n dataType: HealthDataType;\n value: number;\n /**\n * Optional unit override. If omitted, the default unit for the data type is used\n * (count for `steps`, meter for `distance`, kilocalorie for `calories`, bpm for `heartRate`, kilogram for `weight`).\n */\n unit?: HealthUnit;\n /** ISO 8601 start date for the sample. Defaults to now. */\n startDate?: string;\n /** ISO 8601 end date for the sample. Defaults to startDate. */\n endDate?: string;\n /** Metadata key-value pairs forwarded to the native APIs where supported. */\n metadata?: Record<string, string>;\n}\n\nexport interface HealthPlugin {\n /** Returns whether the current platform supports the native health SDK. */\n isAvailable(): Promise<AvailabilityResult>;\n /** Requests read/write access to the provided data types. */\n requestAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Checks authorization status for the provided data types without prompting the user. */\n checkAuthorization(options: AuthorizationOptions): Promise<AuthorizationStatus>;\n /** Reads samples for the given data type within the specified time frame. */\n readSamples(options: QueryOptions): Promise<ReadSamplesResult>;\n /** Writes a single sample to the native health store. */\n saveSample(options: WriteSampleOptions): Promise<void>;\n\n /**\n * Get the native Capacitor plugin version\n *\n * @returns {Promise<{ version: string }>} a Promise with version for this device\n * @throws An error if something went wrong\n */\n getPluginVersion(): Promise<{ version: string }>;\n\n /**\n * Opens the Health Connect settings screen.\n *\n * Use this to direct users to manage their Health Connect permissions\n * or to install Health Connect if not available.\n *\n * @throws An error if Health Connect settings cannot be opened\n */\n openHealthConnectSettings(): Promise<void>;\n\n /**\n * Shows the app's privacy policy for Health Connect.\n *\n * This displays the same privacy policy screen that Health Connect shows\n * when the user taps \"Privacy policy\" in the permissions dialog.\n *\n * The privacy policy URL can be configured by adding a string resource\n * named \"health_connect_privacy_policy_url\" in your app's strings.xml,\n * or by placing an HTML file at www/privacypolicy.html in your assets.\n *\n * @throws An error if the privacy policy cannot be displayed\n */\n showPrivacyPolicy(): Promise<void>;\n\n /**\n * Queries workout sessions from the native health store on Android (Health Connect).\n *\n * @param options Query options including optional workout type filter, date range, limit, and sort order\n * @returns A promise that resolves with the workout sessions\n * @throws An error if something went wrong\n */\n queryWorkouts(options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { HealthPlugin } from './definitions';
2
+ declare const Health: HealthPlugin;
3
+ export * from './definitions';
4
+ export { Health };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const Health = registerPlugin('Health', {
3
+ web: () => import('./web').then((m) => new m.HealthWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { Health };
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAIjD,MAAM,MAAM,GAAG,cAAc,CAAe,QAAQ,EAAE;IACpD,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;CAC1D,CAAC,CAAC;AAEH,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,MAAM,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { HealthPlugin } from './definitions';\n\nconst Health = registerPlugin<HealthPlugin>('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\n\nexport * from './definitions';\nexport { Health };\n"]}
@@ -0,0 +1,15 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ import type { AuthorizationOptions, AuthorizationStatus, AvailabilityResult, HealthPlugin, QueryOptions, QueryWorkoutsOptions, QueryWorkoutsResult, ReadSamplesResult, WriteSampleOptions } from './definitions';
3
+ export declare class HealthWeb extends WebPlugin implements HealthPlugin {
4
+ isAvailable(): Promise<AvailabilityResult>;
5
+ requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus>;
6
+ checkAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus>;
7
+ readSamples(_options: QueryOptions): Promise<ReadSamplesResult>;
8
+ saveSample(_options: WriteSampleOptions): Promise<void>;
9
+ getPluginVersion(): Promise<{
10
+ version: string;
11
+ }>;
12
+ openHealthConnectSettings(): Promise<void>;
13
+ showPrivacyPolicy(): Promise<void>;
14
+ queryWorkouts(_options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult>;
15
+ }
@@ -0,0 +1,35 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class HealthWeb extends WebPlugin {
3
+ async isAvailable() {
4
+ return {
5
+ available: false,
6
+ platform: 'web',
7
+ reason: 'Native health APIs are not accessible in a browser environment.',
8
+ };
9
+ }
10
+ async requestAuthorization(_options) {
11
+ throw this.unimplemented('Health permissions are only available on native platforms.');
12
+ }
13
+ async checkAuthorization(_options) {
14
+ throw this.unimplemented('Health permissions are only available on native platforms.');
15
+ }
16
+ async readSamples(_options) {
17
+ throw this.unimplemented('Reading health data is only available on native platforms.');
18
+ }
19
+ async saveSample(_options) {
20
+ throw this.unimplemented('Writing health data is only available on native platforms.');
21
+ }
22
+ async getPluginVersion() {
23
+ return { version: 'web' };
24
+ }
25
+ async openHealthConnectSettings() {
26
+ // No-op on web - Health Connect is Android only
27
+ }
28
+ async showPrivacyPolicy() {
29
+ // No-op on web - Health Connect privacy policy is Android only
30
+ }
31
+ async queryWorkouts(_options) {
32
+ throw this.unimplemented('Querying workouts is only available on native platforms.');
33
+ }
34
+ }
35
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAc5C,MAAM,OAAO,SAAU,SAAQ,SAAS;IACtC,KAAK,CAAC,WAAW;QACf,OAAO;YACL,SAAS,EAAE,KAAK;YAChB,QAAQ,EAAE,KAAK;YACf,MAAM,EAAE,iEAAiE;SAC1E,CAAC;IACJ,CAAC;IAED,KAAK,CAAC,oBAAoB,CAAC,QAA8B;QACvD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,kBAAkB,CAAC,QAA8B;QACrD,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,WAAW,CAAC,QAAsB;QACtC,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,QAA4B;QAC3C,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC,CAAC;IACzF,CAAC;IAED,KAAK,CAAC,gBAAgB;QACpB,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,yBAAyB;QAC7B,gDAAgD;IAClD,CAAC;IAED,KAAK,CAAC,iBAAiB;QACrB,+DAA+D;IACjE,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,QAA8B;QAChD,MAAM,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC,CAAC;IACvF,CAAC;CACF","sourcesContent":["import { WebPlugin } from '@capacitor/core';\n\nimport type {\n AuthorizationOptions,\n AuthorizationStatus,\n AvailabilityResult,\n HealthPlugin,\n QueryOptions,\n QueryWorkoutsOptions,\n QueryWorkoutsResult,\n ReadSamplesResult,\n WriteSampleOptions,\n} from './definitions';\n\nexport class HealthWeb extends WebPlugin implements HealthPlugin {\n async isAvailable(): Promise<AvailabilityResult> {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n\n async requestAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async checkAuthorization(_options: AuthorizationOptions): Promise<AuthorizationStatus> {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n\n async readSamples(_options: QueryOptions): Promise<ReadSamplesResult> {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n\n async saveSample(_options: WriteSampleOptions): Promise<void> {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n\n async getPluginVersion(): Promise<{ version: string }> {\n return { version: 'web' };\n }\n\n async openHealthConnectSettings(): Promise<void> {\n // No-op on web - Health Connect is Android only\n }\n\n async showPrivacyPolicy(): Promise<void> {\n // No-op on web - Health Connect privacy policy is Android only\n }\n\n async queryWorkouts(_options: QueryWorkoutsOptions): Promise<QueryWorkoutsResult> {\n throw this.unimplemented('Querying workouts is only available on native platforms.');\n }\n}\n"]}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ var core = require('@capacitor/core');
4
+
5
+ const Health = core.registerPlugin('Health', {
6
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.HealthWeb()),
7
+ });
8
+
9
+ class HealthWeb extends core.WebPlugin {
10
+ async isAvailable() {
11
+ return {
12
+ available: false,
13
+ platform: 'web',
14
+ reason: 'Native health APIs are not accessible in a browser environment.',
15
+ };
16
+ }
17
+ async requestAuthorization(_options) {
18
+ throw this.unimplemented('Health permissions are only available on native platforms.');
19
+ }
20
+ async checkAuthorization(_options) {
21
+ throw this.unimplemented('Health permissions are only available on native platforms.');
22
+ }
23
+ async readSamples(_options) {
24
+ throw this.unimplemented('Reading health data is only available on native platforms.');
25
+ }
26
+ async saveSample(_options) {
27
+ throw this.unimplemented('Writing health data is only available on native platforms.');
28
+ }
29
+ async getPluginVersion() {
30
+ return { version: 'web' };
31
+ }
32
+ async openHealthConnectSettings() {
33
+ // No-op on web - Health Connect is Android only
34
+ }
35
+ async showPrivacyPolicy() {
36
+ // No-op on web - Health Connect privacy policy is Android only
37
+ }
38
+ async queryWorkouts(_options) {
39
+ throw this.unimplemented('Querying workouts is only available on native platforms.');
40
+ }
41
+ }
42
+
43
+ var web = /*#__PURE__*/Object.freeze({
44
+ __proto__: null,
45
+ HealthWeb: HealthWeb
46
+ });
47
+
48
+ exports.Health = Health;
49
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async openHealthConnectSettings() {\n // No-op on web - Health Connect is Android only\n }\n async showPrivacyPolicy() {\n // No-op on web - Health Connect privacy policy is Android only\n }\n async queryWorkouts(_options) {\n throw this.unimplemented('Querying workouts is only available on native platforms.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;;AACK,MAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;AACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;AAC7D,CAAC;;ACFM,MAAM,SAAS,SAASC,cAAS,CAAC;AACzC,IAAI,MAAM,WAAW,GAAG;AACxB,QAAQ,OAAO;AACf,YAAY,SAAS,EAAE,KAAK;AAC5B,YAAY,QAAQ,EAAE,KAAK;AAC3B,YAAY,MAAM,EAAE,iEAAiE;AACrF,SAAS;AACT,IAAI;AACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;AACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;AACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;AAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;AAC9F,IAAI;AACJ,IAAI,MAAM,gBAAgB,GAAG;AAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;AACjC,IAAI;AACJ,IAAI,MAAM,yBAAyB,GAAG;AACtC;AACA,IAAI;AACJ,IAAI,MAAM,iBAAiB,GAAG;AAC9B;AACA,IAAI;AACJ,IAAI,MAAM,aAAa,CAAC,QAAQ,EAAE;AAClC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC;AAC5F,IAAI;AACJ;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,52 @@
1
+ var capacitorHealth = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ const Health = core.registerPlugin('Health', {
5
+ web: () => Promise.resolve().then(function () { return web; }).then((m) => new m.HealthWeb()),
6
+ });
7
+
8
+ class HealthWeb extends core.WebPlugin {
9
+ async isAvailable() {
10
+ return {
11
+ available: false,
12
+ platform: 'web',
13
+ reason: 'Native health APIs are not accessible in a browser environment.',
14
+ };
15
+ }
16
+ async requestAuthorization(_options) {
17
+ throw this.unimplemented('Health permissions are only available on native platforms.');
18
+ }
19
+ async checkAuthorization(_options) {
20
+ throw this.unimplemented('Health permissions are only available on native platforms.');
21
+ }
22
+ async readSamples(_options) {
23
+ throw this.unimplemented('Reading health data is only available on native platforms.');
24
+ }
25
+ async saveSample(_options) {
26
+ throw this.unimplemented('Writing health data is only available on native platforms.');
27
+ }
28
+ async getPluginVersion() {
29
+ return { version: 'web' };
30
+ }
31
+ async openHealthConnectSettings() {
32
+ // No-op on web - Health Connect is Android only
33
+ }
34
+ async showPrivacyPolicy() {
35
+ // No-op on web - Health Connect privacy policy is Android only
36
+ }
37
+ async queryWorkouts(_options) {
38
+ throw this.unimplemented('Querying workouts is only available on native platforms.');
39
+ }
40
+ }
41
+
42
+ var web = /*#__PURE__*/Object.freeze({
43
+ __proto__: null,
44
+ HealthWeb: HealthWeb
45
+ });
46
+
47
+ exports.Health = Health;
48
+
49
+ return exports;
50
+
51
+ })({}, capacitorExports);
52
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/index.js","esm/web.js"],"sourcesContent":["import { registerPlugin } from '@capacitor/core';\nconst Health = registerPlugin('Health', {\n web: () => import('./web').then((m) => new m.HealthWeb()),\n});\nexport * from './definitions';\nexport { Health };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class HealthWeb extends WebPlugin {\n async isAvailable() {\n return {\n available: false,\n platform: 'web',\n reason: 'Native health APIs are not accessible in a browser environment.',\n };\n }\n async requestAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async checkAuthorization(_options) {\n throw this.unimplemented('Health permissions are only available on native platforms.');\n }\n async readSamples(_options) {\n throw this.unimplemented('Reading health data is only available on native platforms.');\n }\n async saveSample(_options) {\n throw this.unimplemented('Writing health data is only available on native platforms.');\n }\n async getPluginVersion() {\n return { version: 'web' };\n }\n async openHealthConnectSettings() {\n // No-op on web - Health Connect is Android only\n }\n async showPrivacyPolicy() {\n // No-op on web - Health Connect privacy policy is Android only\n }\n async queryWorkouts(_options) {\n throw this.unimplemented('Querying workouts is only available on native platforms.');\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["registerPlugin","WebPlugin"],"mappings":";;;AACK,UAAC,MAAM,GAAGA,mBAAc,CAAC,QAAQ,EAAE;IACxC,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,SAAS,EAAE,CAAC;IAC7D,CAAC;;ICFM,MAAM,SAAS,SAASC,cAAS,CAAC;IACzC,IAAI,MAAM,WAAW,GAAG;IACxB,QAAQ,OAAO;IACf,YAAY,SAAS,EAAE,KAAK;IAC5B,YAAY,QAAQ,EAAE,KAAK;IAC3B,YAAY,MAAM,EAAE,iEAAiE;IACrF,SAAS;IACT,IAAI;IACJ,IAAI,MAAM,oBAAoB,CAAC,QAAQ,EAAE;IACzC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,kBAAkB,CAAC,QAAQ,EAAE;IACvC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,WAAW,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,UAAU,CAAC,QAAQ,EAAE;IAC/B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,4DAA4D,CAAC;IAC9F,IAAI;IACJ,IAAI,MAAM,gBAAgB,GAAG;IAC7B,QAAQ,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE;IACjC,IAAI;IACJ,IAAI,MAAM,yBAAyB,GAAG;IACtC;IACA,IAAI;IACJ,IAAI,MAAM,iBAAiB,GAAG;IAC9B;IACA,IAAI;IACJ,IAAI,MAAM,aAAa,CAAC,QAAQ,EAAE;IAClC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,0DAA0D,CAAC;IAC5F,IAAI;IACJ;;;;;;;;;;;;;;;"}
package/package.json ADDED
@@ -0,0 +1,75 @@
1
+ {
2
+ "name": "@asiriindatissa/capacitor-health",
3
+ "version": "8.2.1",
4
+ "description": "Capacitor plugin to interact with data from Health Connect on Android",
5
+ "main": "dist/plugin.cjs.js",
6
+ "module": "dist/esm/index.js",
7
+ "types": "dist/esm/index.d.ts",
8
+ "unpkg": "dist/plugin.js",
9
+ "files": [
10
+ "android/src/main/",
11
+ "android/build.gradle",
12
+ "dist/"
13
+ ],
14
+ "author": "Asiri Indatissa",
15
+ "license": "MPL-2.0",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/asiri1ndatissa/capacitor-health.git"
19
+ },
20
+ "bugs": {
21
+ "url": "https://github.com/asiri1ndatissa/capacitor-health/issues"
22
+ },
23
+ "homepage": "https://github.com/asiri1ndatissa/capacitor-health#readme",
24
+ "keywords": [
25
+ "capacitor",
26
+ "plugin",
27
+ "native",
28
+ "android",
29
+ "health-connect",
30
+ "health",
31
+ "fitness"
32
+ ],
33
+ "scripts": {
34
+ "verify": "npm run verify:android && npm run verify:web",
35
+ "verify:android": "cd android && ./gradlew clean build test && cd ..",
36
+ "verify:web": "npm run build",
37
+ "lint": "npm run eslint && npm run prettier -- --check",
38
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write",
39
+ "eslint": "eslint . --ext ts",
40
+ "prettier": "prettier-pretty-check \"**/*.{css,html,ts,js,java}\" --plugin=prettier-plugin-java",
41
+ "docgen": "docgen --api HealthPlugin --output-readme README.md --output-json dist/docs.json",
42
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.mjs",
43
+ "clean": "rimraf ./dist",
44
+ "watch": "tsc --watch",
45
+ "prepublishOnly": "npm run build"
46
+ },
47
+ "devDependencies": {
48
+ "@capacitor/android": "^8.0.0",
49
+ "@capacitor/core": "^8.0.0",
50
+ "@capacitor/docgen": "^0.3.1",
51
+ "@ionic/eslint-config": "^0.4.0",
52
+ "@ionic/prettier-config": "^4.0.0",
53
+ "@types/node": "^24.10.1",
54
+ "eslint": "^8.57.1",
55
+ "eslint-plugin-import": "^2.31.0",
56
+ "prettier": "^3.6.2",
57
+ "prettier-plugin-java": "^2.7.7",
58
+ "rimraf": "^6.1.0",
59
+ "rollup": "^4.53.2",
60
+ "typescript": "^5.9.3",
61
+ "prettier-pretty-check": "^0.2.0"
62
+ },
63
+ "peerDependencies": {
64
+ "@capacitor/core": ">=8.0.0"
65
+ },
66
+ "prettier": "@ionic/prettier-config",
67
+ "eslintConfig": {
68
+ "extends": "@ionic/eslint-config/recommended"
69
+ },
70
+ "capacitor": {
71
+ "android": {
72
+ "src": "android"
73
+ }
74
+ }
75
+ }