@ebarooni/capacitor-calendar 0.1.0

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,94 @@
1
+ import type { PermissionState } from '@capacitor/core';
2
+ /**
3
+ * Enum for the possible results of actions performed on a calendar event.
4
+ * "saved" for completion of an operation. "Canceled" for a canceled process and "error"
5
+ * for when something went wrong.
6
+ *
7
+ * @enum
8
+ */
9
+ export declare enum CalendarEventActionResult {
10
+ Saved = "saved",
11
+ Canceled = "canceled",
12
+ Error = "error"
13
+ }
14
+ /**
15
+ * Describes the permission status for reading from the calendar.
16
+ *
17
+ * @interface
18
+ */
19
+ export interface CalendarPermissionStatus {
20
+ readCalendar: PermissionState;
21
+ }
22
+ export interface CapacitorCalendarPlugin {
23
+ /**
24
+ * Checks the current authorization status of a specific permission.
25
+ *
26
+ * @method
27
+ * @param options An object with the name of the permission
28
+ * @returns {Promise<{ result: PermissionState }>} – A promise that resolves with the current status of the requested permission.
29
+ * @example
30
+ * const status = await this.checkPermission({ alias: 'readCalendar' });
31
+ */
32
+ checkPermission(options: {
33
+ alias: keyof CalendarPermissionStatus;
34
+ }): Promise<{
35
+ result: PermissionState;
36
+ }>;
37
+ /**
38
+ * Checks the current authorization status of all the required permissions for the plugin.
39
+ *
40
+ * @method
41
+ * @returns {Promise&lt;CalendarPermissionStatus&gt;} – A promise that resolves with an object containing all the permissions and their status.
42
+ * @example
43
+ * const permissionsStatus = await this.checkAllPermissions();
44
+ */
45
+ checkAllPermissions(): Promise<CalendarPermissionStatus>;
46
+ /**
47
+ * Requests authorization to a specific permission, if not already granted.
48
+ * If the permission is already granted, it will directly return the status.
49
+ *
50
+ * @method
51
+ * @param options An object with the name of the permission
52
+ * @returns {Promise&lt;{ result: PermissionState }&gt;} – A promise that resolves with the new permission status after the request is made.
53
+ * @example
54
+ * const result = await this.requestPermission({ alias: 'readCalendar' });
55
+ */
56
+ requestPermission(options: {
57
+ alias: keyof CalendarPermissionStatus;
58
+ }): Promise<{
59
+ result: PermissionState;
60
+ }>;
61
+ /**
62
+ * Requests authorization to all the required permissions for the plugin, if they have not already been granted.
63
+ *
64
+ * @method
65
+ * @returns {Promise&lt;CalendarPermissionStatus&gt;} – A promise that resolves with the new permission statuses after the request is made.
66
+ * @example
67
+ * const permissionResults = await this.requestAllPermissions();
68
+ */
69
+ requestAllPermissions(): Promise<CalendarPermissionStatus>;
70
+ /**
71
+ * Creates an event in the calendar by using the native calendar.
72
+ * On iOS opens a native sheet and on Android opens an intent.
73
+ * This method does not need any read or write authorization from the user on iOS. However, the entries in the Info.plist file are still needed.
74
+ * On Android, the user has to authorize for read access.
75
+ *
76
+ * @method
77
+ * @returns {Promise&lt;{ result: CalendarEventActionResult }&gt;} – A promise that resolves with the result of the action.
78
+ * @example
79
+ * let result: CalendarEventActionResult;
80
+ * if (capacitor.getPlatform() === 'android') {
81
+ * const readCalendarStatus = this.requestPermission({ alias: 'readCalendar' }).result;
82
+ * if (readCalendarStatus === 'granted') {
83
+ * result = await this.createEventWithPrompt();
84
+ * } else {
85
+ * // handle the case when user rejects the permission
86
+ * }
87
+ * } else {
88
+ * result = await this.createEventWithPrompt();
89
+ * }
90
+ */
91
+ createEventWithPrompt(): Promise<{
92
+ result: CalendarEventActionResult;
93
+ }>;
94
+ }
@@ -0,0 +1,14 @@
1
+ /**
2
+ * Enum for the possible results of actions performed on a calendar event.
3
+ * "saved" for completion of an operation. "Canceled" for a canceled process and "error"
4
+ * for when something went wrong.
5
+ *
6
+ * @enum
7
+ */
8
+ export var CalendarEventActionResult;
9
+ (function (CalendarEventActionResult) {
10
+ CalendarEventActionResult["Saved"] = "saved";
11
+ CalendarEventActionResult["Canceled"] = "canceled";
12
+ CalendarEventActionResult["Error"] = "error";
13
+ })(CalendarEventActionResult || (CalendarEventActionResult = {}));
14
+ //# sourceMappingURL=definitions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"definitions.js","sourceRoot":"","sources":["../../src/definitions.ts"],"names":[],"mappings":"AAEA;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,yBAIX;AAJD,WAAY,yBAAyB;IACnC,4CAAe,CAAA;IACf,kDAAqB,CAAA;IACrB,4CAAe,CAAA;AACjB,CAAC,EAJW,yBAAyB,KAAzB,yBAAyB,QAIpC","sourcesContent":["import type { PermissionState } from '@capacitor/core';\n\n/**\n * Enum for the possible results of actions performed on a calendar event.\n * \"saved\" for completion of an operation. \"Canceled\" for a canceled process and \"error\"\n * for when something went wrong.\n *\n * @enum\n */\nexport enum CalendarEventActionResult {\n Saved = 'saved',\n Canceled = 'canceled',\n Error = 'error'\n}\n\n/**\n * Describes the permission status for reading from the calendar.\n *\n * @interface\n */\nexport interface CalendarPermissionStatus {\n readCalendar: PermissionState;\n}\n\nexport interface CapacitorCalendarPlugin {\n /**\n * Checks the current authorization status of a specific permission.\n *\n * @method\n * @param options An object with the name of the permission\n * @returns {Promise&lt;{ result: PermissionState }&gt;} – A promise that resolves with the current status of the requested permission.\n * @example\n * const status = await this.checkPermission({ alias: 'readCalendar' });\n */\n checkPermission(options: { alias: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }>;\n\n /**\n * Checks the current authorization status of all the required permissions for the plugin.\n *\n * @method\n * @returns {Promise&lt;CalendarPermissionStatus&gt;} – A promise that resolves with an object containing all the permissions and their status.\n * @example\n * const permissionsStatus = await this.checkAllPermissions();\n */\n checkAllPermissions(): Promise<CalendarPermissionStatus>;\n\n /**\n * Requests authorization to a specific permission, if not already granted.\n * If the permission is already granted, it will directly return the status.\n *\n * @method\n * @param options An object with the name of the permission\n * @returns {Promise&lt;{ result: PermissionState }&gt;} – A promise that resolves with the new permission status after the request is made.\n * @example\n * const result = await this.requestPermission({ alias: 'readCalendar' });\n */\n requestPermission(options: { alias: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }>;\n\n /**\n * Requests authorization to all the required permissions for the plugin, if they have not already been granted.\n *\n * @method\n * @returns {Promise&lt;CalendarPermissionStatus&gt;} – A promise that resolves with the new permission statuses after the request is made.\n * @example\n * const permissionResults = await this.requestAllPermissions();\n */\n requestAllPermissions(): Promise<CalendarPermissionStatus>;\n\n /**\n * Creates an event in the calendar by using the native calendar.\n * On iOS opens a native sheet and on Android opens an intent.\n * This method does not need any read or write authorization from the user on iOS. However, the entries in the Info.plist file are still needed.\n * On Android, the user has to authorize for read access.\n *\n * @method\n * @returns {Promise&lt;{ result: CalendarEventActionResult }&gt;} – A promise that resolves with the result of the action.\n * @example\n * let result: CalendarEventActionResult;\n * if (capacitor.getPlatform() === 'android') {\n * const readCalendarStatus = this.requestPermission({ alias: 'readCalendar' }).result;\n * if (readCalendarStatus === 'granted') {\n * result = await this.createEventWithPrompt();\n * } else {\n * // handle the case when user rejects the permission\n * }\n * } else {\n * result = await this.createEventWithPrompt();\n * }\n */\n createEventWithPrompt(): Promise<{ result: CalendarEventActionResult }>;\n}\n"]}
@@ -0,0 +1,4 @@
1
+ import type { CapacitorCalendarPlugin } from './definitions';
2
+ declare const CapacitorCalendar: CapacitorCalendarPlugin;
3
+ export * from './definitions';
4
+ export { CapacitorCalendar };
@@ -0,0 +1,7 @@
1
+ import { registerPlugin } from '@capacitor/core';
2
+ const CapacitorCalendar = registerPlugin('CapacitorCalendar', {
3
+ web: () => import('./web').then(m => new m.CapacitorCalendarWeb()),
4
+ });
5
+ export * from './definitions';
6
+ export { CapacitorCalendar };
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,iBAAiB,GAAG,cAAc,CACtC,mBAAmB,EACjB;IACI,GAAG,EAAE,GAAG,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;CACrE,CACJ,CAAC;AAEF,cAAc,eAAe,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,CAAC","sourcesContent":["import { registerPlugin } from '@capacitor/core';\n\nimport type { CapacitorCalendarPlugin } from './definitions';\n\nconst CapacitorCalendar = registerPlugin<CapacitorCalendarPlugin>(\n 'CapacitorCalendar',\n {\n web: () => import('./web').then(m => new m.CapacitorCalendarWeb()),\n },\n);\n\nexport * from './definitions';\nexport { CapacitorCalendar };\n"]}
@@ -0,0 +1,19 @@
1
+ import { PermissionState, WebPlugin } from '@capacitor/core';
2
+ import { CapacitorCalendarPlugin, CalendarEventActionResult, CalendarPermissionStatus } from './definitions';
3
+ export declare class CapacitorCalendarWeb extends WebPlugin implements CapacitorCalendarPlugin {
4
+ checkPermission(_options: {
5
+ alias: keyof CalendarPermissionStatus;
6
+ }): Promise<{
7
+ result: PermissionState;
8
+ }>;
9
+ checkAllPermissions(): Promise<CalendarPermissionStatus>;
10
+ requestPermission(_options: {
11
+ alias: keyof CalendarPermissionStatus;
12
+ }): Promise<{
13
+ result: PermissionState;
14
+ }>;
15
+ requestAllPermissions(): Promise<CalendarPermissionStatus>;
16
+ createEventWithPrompt(): Promise<{
17
+ result: CalendarEventActionResult;
18
+ }>;
19
+ }
@@ -0,0 +1,19 @@
1
+ import { WebPlugin } from '@capacitor/core';
2
+ export class CapacitorCalendarWeb extends WebPlugin {
3
+ checkPermission(_options) {
4
+ throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);
5
+ }
6
+ checkAllPermissions() {
7
+ throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);
8
+ }
9
+ requestPermission(_options) {
10
+ throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);
11
+ }
12
+ requestAllPermissions() {
13
+ throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);
14
+ }
15
+ createEventWithPrompt() {
16
+ throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);
17
+ }
18
+ }
19
+ //# sourceMappingURL=web.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"web.js","sourceRoot":"","sources":["../../src/web.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,SAAS,EAAC,MAAM,iBAAiB,CAAC;AAI3D,MAAM,OAAO,oBACT,SAAQ,SAAS;IAGV,eAAe,CAAC,QAAmD;QACtE,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,eAAe,CAAC,IAAI,gCAAgC,CAAC,CAAA;IAC1F,CAAC;IAEM,mBAAmB;QACtB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC/F,CAAC;IAEM,iBAAiB,CAAC,QAAmD;QACxE,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,iBAAiB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IAC7F,CAAC;IAEM,qBAAqB;QACxB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACjG,CAAC;IAEM,qBAAqB;QACxB,MAAM,IAAI,CAAC,aAAa,CAAC,GAAG,IAAI,CAAC,qBAAqB,CAAC,IAAI,gCAAgC,CAAC,CAAC;IACjG,CAAC;CACJ","sourcesContent":["import {PermissionState, WebPlugin} from '@capacitor/core';\n\nimport {CapacitorCalendarPlugin, CalendarEventActionResult, CalendarPermissionStatus} from './definitions';\n\nexport class CapacitorCalendarWeb\n extends WebPlugin\n implements CapacitorCalendarPlugin\n{\n public checkPermission(_options: { alias: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`)\n }\n\n public checkAllPermissions(): Promise<CalendarPermissionStatus> {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n\n public requestPermission(_options: { alias: keyof CalendarPermissionStatus }): Promise<{ result: PermissionState }> {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n\n public requestAllPermissions(): Promise<CalendarPermissionStatus> {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n\n public createEventWithPrompt(): Promise<{ result: CalendarEventActionResult}> {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n}\n"]}
@@ -0,0 +1,49 @@
1
+ 'use strict';
2
+
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ var core = require('@capacitor/core');
6
+
7
+ /**
8
+ * Enum for the possible results of actions performed on a calendar event.
9
+ * "saved" for completion of an operation. "Canceled" for a canceled process and "error"
10
+ * for when something went wrong.
11
+ *
12
+ * @enum
13
+ */
14
+ exports.CalendarEventActionResult = void 0;
15
+ (function (CalendarEventActionResult) {
16
+ CalendarEventActionResult["Saved"] = "saved";
17
+ CalendarEventActionResult["Canceled"] = "canceled";
18
+ CalendarEventActionResult["Error"] = "error";
19
+ })(exports.CalendarEventActionResult || (exports.CalendarEventActionResult = {}));
20
+
21
+ const CapacitorCalendar = core.registerPlugin('CapacitorCalendar', {
22
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorCalendarWeb()),
23
+ });
24
+
25
+ class CapacitorCalendarWeb extends core.WebPlugin {
26
+ checkPermission(_options) {
27
+ throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);
28
+ }
29
+ checkAllPermissions() {
30
+ throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);
31
+ }
32
+ requestPermission(_options) {
33
+ throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);
34
+ }
35
+ requestAllPermissions() {
36
+ throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);
37
+ }
38
+ createEventWithPrompt() {
39
+ throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);
40
+ }
41
+ }
42
+
43
+ var web = /*#__PURE__*/Object.freeze({
44
+ __proto__: null,
45
+ CapacitorCalendarWeb: CapacitorCalendarWeb
46
+ });
47
+
48
+ exports.CapacitorCalendar = CapacitorCalendar;
49
+ //# sourceMappingURL=plugin.cjs.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.cjs.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Enum for the possible results of actions performed on a calendar event.\n * \"saved\" for completion of an operation. \"Canceled\" for a canceled process and \"error\"\n * for when something went wrong.\n *\n * @enum\n */\nexport var CalendarEventActionResult;\n(function (CalendarEventActionResult) {\n CalendarEventActionResult[\"Saved\"] = \"saved\";\n CalendarEventActionResult[\"Canceled\"] = \"canceled\";\n CalendarEventActionResult[\"Error\"] = \"error\";\n})(CalendarEventActionResult || (CalendarEventActionResult = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorCalendar = registerPlugin('CapacitorCalendar', {\n web: () => import('./web').then(m => new m.CapacitorCalendarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorCalendar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorCalendarWeb extends WebPlugin {\n checkPermission(_options) {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);\n }\n checkAllPermissions() {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n requestPermission(_options) {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n requestAllPermissions() {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n createEventWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CalendarEventActionResult","registerPlugin","WebPlugin"],"mappings":";;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACWA,2CAA0B;AACrC,CAAC,UAAU,yBAAyB,EAAE;AACtC,IAAI,yBAAyB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACjD,IAAI,yBAAyB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;AACvD,IAAI,yBAAyB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;AACjD,CAAC,EAAEA,iCAAyB,KAAKA,iCAAyB,GAAG,EAAE,CAAC,CAAC;;ACX5D,MAAC,iBAAiB,GAAGC,mBAAc,CAAC,mBAAmB,EAAE;AAC9D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;AACtE,CAAC;;ACFM,MAAM,oBAAoB,SAASC,cAAS,CAAC;AACpD,IAAI,eAAe,CAAC,QAAQ,EAAE;AAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AAC/F,KAAK;AACL,IAAI,mBAAmB,GAAG;AAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACnG,KAAK;AACL,IAAI,iBAAiB,CAAC,QAAQ,EAAE;AAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACjG,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACrG,KAAK;AACL,IAAI,qBAAqB,GAAG;AAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;AACrG,KAAK;AACL;;;;;;;;;"}
package/dist/plugin.js ADDED
@@ -0,0 +1,52 @@
1
+ var capacitorCapacitorCalendar = (function (exports, core) {
2
+ 'use strict';
3
+
4
+ /**
5
+ * Enum for the possible results of actions performed on a calendar event.
6
+ * "saved" for completion of an operation. "Canceled" for a canceled process and "error"
7
+ * for when something went wrong.
8
+ *
9
+ * @enum
10
+ */
11
+ exports.CalendarEventActionResult = void 0;
12
+ (function (CalendarEventActionResult) {
13
+ CalendarEventActionResult["Saved"] = "saved";
14
+ CalendarEventActionResult["Canceled"] = "canceled";
15
+ CalendarEventActionResult["Error"] = "error";
16
+ })(exports.CalendarEventActionResult || (exports.CalendarEventActionResult = {}));
17
+
18
+ const CapacitorCalendar = core.registerPlugin('CapacitorCalendar', {
19
+ web: () => Promise.resolve().then(function () { return web; }).then(m => new m.CapacitorCalendarWeb()),
20
+ });
21
+
22
+ class CapacitorCalendarWeb extends core.WebPlugin {
23
+ checkPermission(_options) {
24
+ throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);
25
+ }
26
+ checkAllPermissions() {
27
+ throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);
28
+ }
29
+ requestPermission(_options) {
30
+ throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);
31
+ }
32
+ requestAllPermissions() {
33
+ throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);
34
+ }
35
+ createEventWithPrompt() {
36
+ throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);
37
+ }
38
+ }
39
+
40
+ var web = /*#__PURE__*/Object.freeze({
41
+ __proto__: null,
42
+ CapacitorCalendarWeb: CapacitorCalendarWeb
43
+ });
44
+
45
+ exports.CapacitorCalendar = CapacitorCalendar;
46
+
47
+ Object.defineProperty(exports, '__esModule', { value: true });
48
+
49
+ return exports;
50
+
51
+ })({}, capacitorExports);
52
+ //# sourceMappingURL=plugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"plugin.js","sources":["esm/definitions.js","esm/index.js","esm/web.js"],"sourcesContent":["/**\n * Enum for the possible results of actions performed on a calendar event.\n * \"saved\" for completion of an operation. \"Canceled\" for a canceled process and \"error\"\n * for when something went wrong.\n *\n * @enum\n */\nexport var CalendarEventActionResult;\n(function (CalendarEventActionResult) {\n CalendarEventActionResult[\"Saved\"] = \"saved\";\n CalendarEventActionResult[\"Canceled\"] = \"canceled\";\n CalendarEventActionResult[\"Error\"] = \"error\";\n})(CalendarEventActionResult || (CalendarEventActionResult = {}));\n//# sourceMappingURL=definitions.js.map","import { registerPlugin } from '@capacitor/core';\nconst CapacitorCalendar = registerPlugin('CapacitorCalendar', {\n web: () => import('./web').then(m => new m.CapacitorCalendarWeb()),\n});\nexport * from './definitions';\nexport { CapacitorCalendar };\n//# sourceMappingURL=index.js.map","import { WebPlugin } from '@capacitor/core';\nexport class CapacitorCalendarWeb extends WebPlugin {\n checkPermission(_options) {\n throw this.unimplemented(`${this.checkPermission.name} is not implemented on the web`);\n }\n checkAllPermissions() {\n throw this.unimplemented(`${this.checkAllPermissions.name} is not implemented on the web`);\n }\n requestPermission(_options) {\n throw this.unimplemented(`${this.requestPermission.name} is not implemented on the web`);\n }\n requestAllPermissions() {\n throw this.unimplemented(`${this.requestAllPermissions.name} is not implemented on the web`);\n }\n createEventWithPrompt() {\n throw this.unimplemented(`${this.createEventWithPrompt.name} is not implemented on the web`);\n }\n}\n//# sourceMappingURL=web.js.map"],"names":["CalendarEventActionResult","registerPlugin","WebPlugin"],"mappings":";;;IAAA;IACA;IACA;IACA;IACA;IACA;IACA;AACWA,+CAA0B;IACrC,CAAC,UAAU,yBAAyB,EAAE;IACtC,IAAI,yBAAyB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACjD,IAAI,yBAAyB,CAAC,UAAU,CAAC,GAAG,UAAU,CAAC;IACvD,IAAI,yBAAyB,CAAC,OAAO,CAAC,GAAG,OAAO,CAAC;IACjD,CAAC,EAAEA,iCAAyB,KAAKA,iCAAyB,GAAG,EAAE,CAAC,CAAC;;ACX5D,UAAC,iBAAiB,GAAGC,mBAAc,CAAC,mBAAmB,EAAE;IAC9D,IAAI,GAAG,EAAE,MAAM,mDAAe,CAAC,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,oBAAoB,EAAE,CAAC;IACtE,CAAC;;ICFM,MAAM,oBAAoB,SAASC,cAAS,CAAC;IACpD,IAAI,eAAe,CAAC,QAAQ,EAAE;IAC9B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,eAAe,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IAC/F,KAAK;IACL,IAAI,mBAAmB,GAAG;IAC1B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACnG,KAAK;IACL,IAAI,iBAAiB,CAAC,QAAQ,EAAE;IAChC,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,iBAAiB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACjG,KAAK;IACL,IAAI,qBAAqB,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrG,KAAK;IACL,IAAI,qBAAqB,GAAG;IAC5B,QAAQ,MAAM,IAAI,CAAC,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAC,CAAC;IACrG,KAAK;IACL;;;;;;;;;;;;;;;;;"}
@@ -0,0 +1,181 @@
1
+ import Foundation
2
+ import Capacitor
3
+ import EventKitUI
4
+
5
+
6
+ public class CapacitorCalendar: NSObject, EKEventEditViewDelegate {
7
+ private enum CalendarEventActionResult: String {
8
+ case saved = "saved"
9
+ case canceled = "canceled"
10
+ case error = "error"
11
+ }
12
+
13
+ private enum PermissionState: String {
14
+ case granted = "granted"
15
+ case denied = "denied"
16
+ case prompt = "prompt"
17
+ case promptWithRationale = "prompt-with-rationale"
18
+ }
19
+
20
+ private let bridge: (any CAPBridgeProtocol)?
21
+ private let store = EKEventStore()
22
+ private var eventCall: CAPPluginCall?
23
+
24
+ init(bridge: (any CAPBridgeProtocol)?) {
25
+ self.bridge = bridge
26
+ }
27
+
28
+ public func createEventWithPrompt(_ call: CAPPluginCall) {
29
+ guard let viewController = bridge?.viewController else {
30
+ call.reject("[CapacitorCalendar.\(#function)] Unable to retrieve view controller")
31
+ return
32
+ }
33
+
34
+ eventCall = call
35
+ let eventEditViewController = EKEventEditViewController()
36
+ eventEditViewController.eventStore = store
37
+ viewController.present(eventEditViewController, animated: true, completion: nil)
38
+ eventEditViewController.editViewDelegate = self
39
+ }
40
+
41
+ public func checkPermission(_ call: CAPPluginCall) {
42
+ guard let permissionName = call.getString("alias") else {
43
+ call.reject("[CapacitorCalendar.\(#function)] Permission name is not defined")
44
+ return
45
+ }
46
+
47
+ var permissionState: String
48
+ switch EKEventStore.authorizationStatus(for: .event) {
49
+ case .authorized, .fullAccess:
50
+ permissionState = PermissionState.granted.rawValue
51
+ case .denied, .restricted:
52
+ permissionState = PermissionState.denied.rawValue
53
+ case .notDetermined, .writeOnly:
54
+ permissionState = PermissionState.prompt.rawValue
55
+ @unknown default:
56
+ call.reject("[CapacitorCalendar.\(#function)] Could not determine the status of the requested permission")
57
+ return
58
+ }
59
+ call.resolve(["result": permissionState])
60
+ }
61
+
62
+ public func checkAllPermissions(_ call: CAPPluginCall) {
63
+ switch EKEventStore.authorizationStatus(for: .event) {
64
+ case .authorized, .fullAccess:
65
+ call.resolve(["readCalendar": PermissionState.granted.rawValue])
66
+ case .denied, .restricted:
67
+ call.resolve(["readCalendar": PermissionState.denied.rawValue])
68
+ case .notDetermined, .writeOnly:
69
+ call.resolve(["readCalendar": PermissionState.prompt.rawValue])
70
+ @unknown default:
71
+ call.reject("[CapacitorCalendar.\(#function)] Could not determine the status of the requested permissions")
72
+ return
73
+ }
74
+ }
75
+
76
+ public func requestPermission(_ call: CAPPluginCall) {
77
+ guard let permissionName = call.getString("alias") else {
78
+ call.reject("[CapacitorCalendar.\(#function)] Permission name is not defined")
79
+ return
80
+ }
81
+
82
+ switch permissionName {
83
+ case "readCalendar":
84
+ return requestReadAccessToEvents(call)
85
+ default:
86
+ call.reject("[CapacitorCalendar.\(#function)] Could not authorize \(permissionName)")
87
+ return
88
+ }
89
+ }
90
+
91
+ public func requestAllPermissions(_ call: CAPPluginCall) {
92
+ return requestAllAccessToEvents(call)
93
+
94
+ }
95
+
96
+ private func requestReadAccessToEvents(_ call: CAPPluginCall) {
97
+ if #available(iOS 17.0, *) {
98
+ store.requestFullAccessToEvents { granted, error in
99
+ if let error = error {
100
+ call.reject("[CapacitorCalendar.\(#function)] Could not authorize readCalendar")
101
+ return
102
+ }
103
+ var permissionState: String
104
+ if granted {
105
+ permissionState = PermissionState.granted.rawValue
106
+ } else {
107
+ permissionState = PermissionState.denied.rawValue
108
+ }
109
+ call.resolve(["result": permissionState])
110
+ }
111
+ } else {
112
+ store.requestAccess(to: .event) { granted, error in
113
+ if let error = error {
114
+ call.reject("[CapacitorCalendar.\(#function)] Could not authorize readCalendar")
115
+ return
116
+ }
117
+ var permissionState: String
118
+ if granted {
119
+ permissionState = PermissionState.granted.rawValue
120
+ } else {
121
+ permissionState = PermissionState.denied.rawValue
122
+ }
123
+ call.resolve(["result": permissionState])
124
+ }
125
+ }
126
+ }
127
+
128
+ private func requestAllAccessToEvents(_ call: CAPPluginCall) {
129
+ if #available(iOS 17.0, *) {
130
+ store.requestFullAccessToEvents { granted, error in
131
+ if let error = error {
132
+ call.reject("[CapacitorCalendar.\(#function)] Could not authorize readCalendar and writeCalendar")
133
+ return
134
+ }
135
+ var permissionState: String
136
+ if granted {
137
+ permissionState = PermissionState.granted.rawValue
138
+ } else {
139
+ permissionState = PermissionState.denied.rawValue
140
+ }
141
+ call.resolve(["readCalendar": permissionState])
142
+ }
143
+ } else {
144
+ store.requestAccess(to: .event) { granted, error in
145
+ if let error = error {
146
+ call.reject("[CapacitorCalendar.\(#function)] Could not authorize readCalendar and writeCalendar")
147
+ return
148
+ }
149
+ var permissionState: String
150
+ if granted {
151
+ permissionState = PermissionState.granted.rawValue
152
+ } else {
153
+ permissionState = PermissionState.denied.rawValue
154
+ }
155
+ call.resolve(["readCalendar": permissionState])
156
+ }
157
+ }
158
+ }
159
+
160
+ public func eventEditViewController(
161
+ _ controller: EKEventEditViewController,
162
+ didCompleteWith action: EKEventEditViewAction
163
+ ) {
164
+ controller.dismiss(animated: true) {
165
+ print(action)
166
+ if action == .saved {
167
+ self.eventCall?.resolve([
168
+ "result": CalendarEventActionResult.saved.rawValue
169
+ ])
170
+ } else if action == .canceled {
171
+ self.eventCall?.resolve([
172
+ "result": CalendarEventActionResult.canceled.rawValue
173
+ ])
174
+ } else {
175
+ self.eventCall?.resolve([
176
+ "result": CalendarEventActionResult.error.rawValue
177
+ ])
178
+ }
179
+ }
180
+ }
181
+ }
@@ -0,0 +1,10 @@
1
+ #import <UIKit/UIKit.h>
2
+
3
+ //! Project version number for Plugin.
4
+ FOUNDATION_EXPORT double PluginVersionNumber;
5
+
6
+ //! Project version string for Plugin.
7
+ FOUNDATION_EXPORT const unsigned char PluginVersionString[];
8
+
9
+ // In this header, you should import all the public headers of your framework using statements like #import <Plugin/PublicHeader.h>
10
+
@@ -0,0 +1,12 @@
1
+ #import <Foundation/Foundation.h>
2
+ #import <Capacitor/Capacitor.h>
3
+
4
+ // Define the plugin using the CAP_PLUGIN Macro, and
5
+ // each method the plugin supports using the CAP_PLUGIN_METHOD macro.
6
+ CAP_PLUGIN(CapacitorCalendarPlugin, "CapacitorCalendar",
7
+ CAP_PLUGIN_METHOD(createEventWithPrompt, CAPPluginReturnPromise);
8
+ CAP_PLUGIN_METHOD(checkPermission, CAPPluginReturnPromise);
9
+ CAP_PLUGIN_METHOD(checkAllPermissions, CAPPluginReturnPromise);
10
+ CAP_PLUGIN_METHOD(requestPermission, CAPPluginReturnPromise);
11
+ CAP_PLUGIN_METHOD(requestAllPermissions, CAPPluginReturnPromise);
12
+ )
@@ -0,0 +1,33 @@
1
+ import Foundation
2
+ import Capacitor
3
+
4
+ /**
5
+ * Please read the Capacitor iOS Plugin Development Guide
6
+ * here: https://capacitorjs.com/docs/plugins/ios
7
+ */
8
+ @objc(CapacitorCalendarPlugin)
9
+ public class CapacitorCalendarPlugin: CAPPlugin {
10
+ private lazy var implementation = CapacitorCalendar(bridge: self.bridge)
11
+
12
+ @objc public func checkPermission(_ call: CAPPluginCall) {
13
+ return implementation.checkPermission(call)
14
+ }
15
+
16
+ @objc public func checkAllPermissions(_ call: CAPPluginCall) {
17
+ return implementation.checkAllPermissions(call)
18
+ }
19
+
20
+ @objc public func requestPermission(_ call: CAPPluginCall) {
21
+ return implementation.requestPermission(call)
22
+ }
23
+
24
+ @objc public func requestAllPermissions(_ call: CAPPluginCall) {
25
+ return implementation.requestAllPermissions(call)
26
+ }
27
+
28
+ @objc public func createEventWithPrompt(_ call: CAPPluginCall) {
29
+ DispatchQueue.main.async {
30
+ return self.implementation.createEventWithPrompt(call)
31
+ }
32
+ }
33
+ }
@@ -0,0 +1,24 @@
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
3
+ <plist version="1.0">
4
+ <dict>
5
+ <key>CFBundleDevelopmentRegion</key>
6
+ <string>$(DEVELOPMENT_LANGUAGE)</string>
7
+ <key>CFBundleExecutable</key>
8
+ <string>$(EXECUTABLE_NAME)</string>
9
+ <key>CFBundleIdentifier</key>
10
+ <string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
11
+ <key>CFBundleInfoDictionaryVersion</key>
12
+ <string>6.0</string>
13
+ <key>CFBundleName</key>
14
+ <string>$(PRODUCT_NAME)</string>
15
+ <key>CFBundlePackageType</key>
16
+ <string>FMWK</string>
17
+ <key>CFBundleShortVersionString</key>
18
+ <string>1.0</string>
19
+ <key>CFBundleVersion</key>
20
+ <string>$(CURRENT_PROJECT_VERSION)</string>
21
+ <key>NSPrincipalClass</key>
22
+ <string></string>
23
+ </dict>
24
+ </plist>
package/package.json ADDED
@@ -0,0 +1,85 @@
1
+ {
2
+ "name": "@ebarooni/capacitor-calendar",
3
+ "version": "0.1.0",
4
+ "description": "The Capacitor Calendar Plugin exposes functionalities for interacting with the calendar of iOS and Android devices.",
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
+ "ios/Plugin/",
14
+ "EbarooniCapacitorCalendar.podspec"
15
+ ],
16
+ "author": "Ehsan Barooni",
17
+ "license": "MIT",
18
+ "repository": {
19
+ "type": "git",
20
+ "url": "git+https://github.com/ebarooni/capacitor-calendar.git"
21
+ },
22
+ "bugs": {
23
+ "url": "https://github.com/ebarooni/capacitor-calendar.git/issues"
24
+ },
25
+ "keywords": [
26
+ "capacitor",
27
+ "plugin",
28
+ "native",
29
+ "calendar"
30
+ ],
31
+ "homepage": "https://github.com/ebarooni/capacitor-calendar",
32
+ "scripts": {
33
+ "verify": "npm run verify:ios && npm run verify:android && npm run verify:web",
34
+ "verify:ios": "cd ios && pod install && xcodebuild -workspace Plugin.xcworkspace -scheme Plugin -destination generic/platform=iOS && cd ..",
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 && npm run swiftlint -- lint",
38
+ "fmt": "npm run eslint -- --fix && npm run prettier -- --write && npm run swiftlint -- --fix --format",
39
+ "eslint": "eslint . --ext ts",
40
+ "prettier": "prettier \"**/*.{css,html,ts,js,java}\"",
41
+ "swiftlint": "node-swiftlint",
42
+ "docgen": "docgen --api CapacitorCalendarPlugin --output-readme README.md --output-json dist/docs.json",
43
+ "build": "npm run clean && npm run docgen && tsc && rollup -c rollup.config.js",
44
+ "clean": "rimraf ./dist",
45
+ "watch": "tsc --watch",
46
+ "prepublishOnly": "npm run build"
47
+ },
48
+ "devDependencies": {
49
+ "@angular/cli": "^17.1.2",
50
+ "@capacitor/android": "^5.0.0",
51
+ "@capacitor/cli": "^5.6.0",
52
+ "@capacitor/core": "^5.0.0",
53
+ "@capacitor/docgen": "^0.0.18",
54
+ "@capacitor/ios": "^5.0.0",
55
+ "@ionic/eslint-config": "^0.3.0",
56
+ "@ionic/prettier-config": "^1.0.1",
57
+ "@ionic/swiftlint-config": "^1.1.2",
58
+ "eslint": "^7.11.0",
59
+ "prettier": "~2.3.0",
60
+ "prettier-plugin-java": "~1.0.2",
61
+ "rimraf": "^3.0.2",
62
+ "rollup": "^2.32.0",
63
+ "swiftlint": "^1.0.1",
64
+ "typescript": "~5.3.3"
65
+ },
66
+ "peerDependencies": {
67
+ "@capacitor/core": "^5.0.0"
68
+ },
69
+ "prettier": "@ionic/prettier-config",
70
+ "swiftlint": "@ionic/swiftlint-config",
71
+ "eslintConfig": {
72
+ "extends": "@ionic/eslint-config/recommended"
73
+ },
74
+ "capacitor": {
75
+ "ios": {
76
+ "src": "ios"
77
+ },
78
+ "android": {
79
+ "src": "android"
80
+ }
81
+ },
82
+ "publishConfig": {
83
+ "access": "public"
84
+ }
85
+ }