@ebarooni/capacitor-calendar 7.1.0 → 7.3.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.
- package/EbarooniCapacitorCalendar.podspec +1 -1
- package/Package.swift +2 -2
- package/README.md +949 -452
- package/android/src/main/java/dev/barooni/capacitor/calendar/CapacitorCalendarPlugin.kt +74 -7
- package/android/src/main/java/dev/barooni/capacitor/calendar/PluginError.kt +36 -18
- package/android/src/main/java/dev/barooni/capacitor/calendar/implementation/CapacitorCalendar.kt +325 -83
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/CalendarEvent.kt +4 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventDeleteInfo.kt +8 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/data/EventRecurrenceRule.kt +135 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/enums/EventSpan.kt +13 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CheckPermissionInput.kt +0 -4
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateCalendarInput.kt +3 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventInput.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/CreateEventWithPromptInput.kt +5 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteCalendarInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventWithPromptInput.kt +4 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/DeleteEventsByIdInput.kt +2 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/GetDefaultCalendarInput.kt +9 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyCalendarInput.kt +22 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEvent.kt +3 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/ModifyEventWithPromptInput.kt +3 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/inputs/RequestPermissionInput.kt +3 -5
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CheckAllPermissionsResult.kt +3 -2
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CreateEventResult.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/CreateEventWithPromptResult.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/GetDefaultCalendarResult.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ListCalendarsResult.kt +1 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/ListEventsInRangeResult.kt +4 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/results/RequestAllPermissionsResult.kt +1 -1
- package/android/src/main/java/dev/barooni/capacitor/calendar/models/templates/PluginCompletion.kt +8 -0
- package/android/src/main/java/dev/barooni/capacitor/calendar/utils/ImplementationHelper.kt +468 -39
- package/dist/docs.json +3321 -1121
- package/dist/esm/definitions.d.ts +5 -5
- package/dist/esm/definitions.js.map +1 -1
- package/dist/esm/index.d.ts +71 -46
- package/dist/esm/index.js +17 -17
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/schemas/enums/attendee-role.js.map +1 -1
- package/dist/esm/schemas/enums/attendee-status.js.map +1 -1
- package/dist/esm/schemas/enums/attendee-type.js.map +1 -1
- package/dist/esm/schemas/enums/calendar-permission-scope.d.ts +9 -1
- package/dist/esm/schemas/enums/calendar-permission-scope.js +9 -1
- package/dist/esm/schemas/enums/calendar-permission-scope.js.map +1 -1
- package/dist/esm/schemas/enums/event-span.d.ts +4 -0
- package/dist/esm/schemas/enums/event-span.js +4 -0
- package/dist/esm/schemas/enums/event-span.js.map +1 -1
- package/dist/esm/schemas/enums/event-status.js.map +1 -1
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.d.ts +5 -5
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js +5 -5
- package/dist/esm/schemas/enums/reminder-recurrence-frequency.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-event.d.ts +145 -70
- package/dist/esm/schemas/interfaces/calendar-event.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar-source.d.ts +4 -1
- package/dist/esm/schemas/interfaces/calendar-source.js.map +1 -1
- package/dist/esm/schemas/interfaces/calendar.d.ts +22 -4
- package/dist/esm/schemas/interfaces/calendar.js.map +1 -1
- package/dist/esm/schemas/interfaces/check-permission-options.d.ts +19 -0
- package/dist/esm/schemas/interfaces/check-permission-options.js +2 -0
- package/dist/esm/schemas/interfaces/check-permission-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-calendar-options.d.ts +19 -6
- package/dist/esm/schemas/interfaces/create-calendar-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-calendar-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/create-calendar-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-calendar-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-event-options.d.ts +86 -51
- package/dist/esm/schemas/interfaces/create-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-event-result.d.ts +22 -0
- package/dist/esm/schemas/interfaces/create-event-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-event-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.d.ts +73 -36
- package/dist/esm/schemas/interfaces/create-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-event-with-prompt-result.d.ts +23 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-event-with-prompt-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-reminder-options.d.ts +42 -12
- package/dist/esm/schemas/interfaces/create-reminder-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/create-reminder-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/create-reminder-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-reminder-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-options.d.ts +46 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-options.js +2 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-result.js +2 -0
- package/dist/esm/schemas/interfaces/create-reminders-list-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-calendar-options.d.ts +1 -0
- package/dist/esm/schemas/interfaces/delete-calendar-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-options.d.ts +29 -4
- package/dist/esm/schemas/interfaces/delete-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.d.ts +39 -14
- package/dist/esm/schemas/interfaces/delete-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.d.ts +16 -4
- package/dist/esm/schemas/interfaces/delete-events-by-id-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-reminder-options.d.ts +10 -0
- package/dist/esm/schemas/interfaces/delete-reminder-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-options.d.ts +35 -0
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-result.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminder-with-prompt-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-reminders-by-id-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/delete-reminders-by-id-result.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminders-by-id-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/delete-reminders-list-options.d.ts +23 -0
- package/dist/esm/schemas/interfaces/delete-reminders-list-options.js +2 -0
- package/dist/esm/schemas/interfaces/delete-reminders-list-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/event-recurrence-rule.d.ts +96 -0
- package/dist/esm/schemas/interfaces/event-recurrence-rule.js +2 -0
- package/dist/esm/schemas/interfaces/event-recurrence-rule.js.map +1 -0
- package/dist/esm/schemas/interfaces/fetch-all-calendar-sources-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/fetch-all-calendar-sources-result.js +2 -0
- package/dist/esm/schemas/interfaces/fetch-all-calendar-sources-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-default-calendar-options.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-default-calendar-options.js +2 -0
- package/dist/esm/schemas/interfaces/get-default-calendar-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-default-reminders-list-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-default-reminders-list-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-default-reminders-list-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-reminder-by-id-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-reminder-by-id-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-reminder-by-id-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-reminders-from-lists-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-reminders-from-lists-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-reminders-from-lists-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/get-reminders-lists-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/get-reminders-lists-result.js +2 -0
- package/dist/esm/schemas/interfaces/get-reminders-lists-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/list-calendars-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/list-calendars-result.js +2 -0
- package/dist/esm/schemas/interfaces/list-calendars-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-options.d.ts +7 -2
- package/dist/esm/schemas/interfaces/list-events-in-range-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/list-events-in-range-result.d.ts +13 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-result.js +2 -0
- package/dist/esm/schemas/interfaces/list-events-in-range-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/modify-calendar-options.d.ts +32 -0
- package/dist/esm/schemas/interfaces/modify-calendar-options.js +2 -0
- package/dist/esm/schemas/interfaces/modify-calendar-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/modify-event-options.d.ts +61 -44
- package/dist/esm/schemas/interfaces/modify-event-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.d.ts +77 -2
- package/dist/esm/schemas/interfaces/modify-event-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/modify-reminder-options.d.ts +77 -13
- package/dist/esm/schemas/interfaces/modify-reminder-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/open-calendar-options.d.ts +5 -1
- package/dist/esm/schemas/interfaces/open-calendar-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/recurrence-rule.d.ts +8 -2
- package/dist/esm/schemas/interfaces/recurrence-rule.js.map +1 -1
- package/dist/esm/schemas/interfaces/reminder-recurrence-rule.d.ts +1 -1
- package/dist/esm/schemas/interfaces/reminder-recurrence-rule.js.map +1 -1
- package/dist/esm/schemas/interfaces/reminder.d.ts +4 -1
- package/dist/esm/schemas/interfaces/reminder.js.map +1 -1
- package/dist/esm/schemas/interfaces/reminders-list.d.ts +8 -2
- package/dist/esm/schemas/interfaces/reminders-list.js.map +1 -1
- package/dist/esm/schemas/interfaces/request-permission-options.d.ts +16 -0
- package/dist/esm/schemas/interfaces/request-permission-options.js +2 -0
- package/dist/esm/schemas/interfaces/request-permission-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.d.ts +1 -1
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-options.js.map +1 -1
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-result.d.ts +14 -0
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-result.js +2 -0
- package/dist/esm/schemas/interfaces/select-calendars-with-prompt-result.js.map +1 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-options.d.ts +43 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-options.js +2 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-options.js.map +1 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-result.d.ts +12 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-result.js +2 -0
- package/dist/esm/schemas/interfaces/update-reminders-list-result.js.map +1 -0
- package/dist/esm/schemas/types/event-edit-action.d.ts +1 -1
- package/dist/esm/schemas/types/event-edit-action.js.map +1 -1
- package/dist/esm/schemas/types/recurrence-frequency.d.ts +4 -0
- package/dist/esm/schemas/types/recurrence-frequency.js +2 -0
- package/dist/esm/schemas/types/recurrence-frequency.js.map +1 -0
- package/dist/esm/schemas/types/system-color-name.d.ts +6 -0
- package/dist/esm/schemas/types/system-color-name.js +2 -0
- package/dist/esm/schemas/types/system-color-name.js.map +1 -0
- package/dist/esm/sub-definitions/calendar-access.d.ts +26 -14
- package/dist/esm/sub-definitions/calendar-access.js.map +1 -1
- package/dist/esm/sub-definitions/calendar-operations.d.ts +75 -20
- package/dist/esm/sub-definitions/calendar-operations.js.map +1 -1
- package/dist/esm/sub-definitions/event-operations.d.ts +46 -25
- package/dist/esm/sub-definitions/event-operations.js.map +1 -1
- package/dist/esm/sub-definitions/reminders-access.d.ts +6 -2
- package/dist/esm/sub-definitions/reminders-access.js.map +1 -1
- package/dist/esm/sub-definitions/reminders-operations.d.ts +82 -37
- package/dist/esm/sub-definitions/reminders-operations.js.map +1 -1
- package/dist/esm/web/download-ics-file.d.ts +18 -0
- package/dist/esm/web/download-ics-file.js +33 -0
- package/dist/esm/web/download-ics-file.js.map +1 -0
- package/dist/esm/web/ics.d.ts +27 -0
- package/dist/esm/web/ics.js +294 -0
- package/dist/esm/web/ics.js.map +1 -0
- package/dist/esm/web.d.ts +71 -77
- package/dist/esm/web.js +127 -6
- package/dist/esm/web.js.map +1 -1
- package/dist/plugin.cjs.js +470 -35
- package/dist/plugin.cjs.js.map +1 -1
- package/dist/plugin.js +470 -35
- package/dist/plugin.js.map +1 -1
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/CapacitorCalendarPlugin.swift +168 -75
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Implementation/CapacitorCalendar.swift +242 -107
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Models/Enums/EventSpan.swift +8 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateCalendarInput.swift +6 -4
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateEventInput.swift +25 -21
- package/ios/Plugin/Models/Inputs/CreateEventWithPromptInput.swift +171 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CreateReminderInput.swift +14 -4
- package/ios/Plugin/Models/Inputs/CreateRemindersListInput.swift +43 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteCalendarInput.swift +1 -1
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventInput.swift +9 -4
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventWithPromptInput.swift +9 -4
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteEventsByIdInput.swift +9 -4
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteReminderInput.swift +7 -1
- package/ios/Plugin/Models/Inputs/DeleteReminderWithPromptInput.swift +46 -0
- package/ios/Plugin/Models/Inputs/DeleteRemindersListInput.swift +22 -0
- package/ios/Plugin/Models/Inputs/GetDefaultCalendarInput.swift +13 -0
- package/ios/Plugin/Models/Inputs/ModifyCalendarInput.swift +35 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyEventInput.swift +63 -41
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyReminderInput.swift +66 -5
- package/ios/Plugin/Models/Inputs/UpdateRemindersListInput.swift +41 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateEventResult.swift +1 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateEventWithPromptResult.swift +1 -0
- package/ios/Plugin/Models/Results/CreateRemindersListResult.swift +15 -0
- package/ios/Plugin/Models/Results/ListEventsInRangeResult.swift +29 -0
- package/ios/Plugin/Models/Results/UpdateRemindersListResult.swift +15 -0
- package/ios/Plugin/Models/Structs/RecurrenceInput.swift +41 -0
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginConfig.swift +30 -25
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/PluginError.swift +74 -56
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/ImplementationHelper.swift +140 -24
- package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Utils/UIColorFromHexExtension.swift +5 -0
- package/package.json +36 -43
- package/dist/esm/schemas/enums/recurrence-frequency.d.ts +0 -21
- package/dist/esm/schemas/enums/recurrence-frequency.js +0 -23
- package/dist/esm/schemas/enums/recurrence-frequency.js.map +0 -1
- package/ios/Sources/CapacitorCalendarPlugin/Models/Inputs/CreateEventWithPromptInput.swift +0 -89
- package/ios/Sources/CapacitorCalendarPlugin/Models/Results/ListEventsInRangeResult.swift +0 -16
- package/ios/Tests/CapacitorCalendarPluginTests/CapacitorCalendarPluginTests.swift +0 -15
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/CAPPermissionState.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/CalendarPermissionScope.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Enums/EventEditAction.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/CheckPermissionInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/DeleteRemindersByIdInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/GetReminderByIdInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/GetRemindersFromListsInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ListEventsInRangeInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/ModifyEventWithPromptInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/OpenCalendarInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/RequestPermissionInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Inputs/SelectCalendarsWithPromptInput.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CheckAllPermissionsResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CheckPermissionResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateCalendarResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/CreateReminderResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteEventWithPromptResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteEventsByIdResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/DeleteRemindersByIdResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/FetchAllCalendarSourcesResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetDefaultCalendarResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetReminderByIdResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/GetRemindersFromListsResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ListCalendarsResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/ModifyEventWithPromptResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/RequestAllPermissionsResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/RequestPermissionResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Results/SelectCalendarsWithPromptResult.swift +0 -0
- /package/ios/{Sources/CapacitorCalendarPlugin → Plugin}/Models/Templates/JSResult.swift +0 -0
|
@@ -1,13 +1,43 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
import type {
|
|
3
|
-
import type {
|
|
4
|
-
import type {
|
|
5
|
-
import type {
|
|
6
|
-
import type {
|
|
7
|
-
import type {
|
|
8
|
-
import type {
|
|
9
|
-
import type {
|
|
1
|
+
import type { CreateReminderOptions } from '../schemas/interfaces/create-reminder-options';
|
|
2
|
+
import type { CreateReminderResult } from '../schemas/interfaces/create-reminder-result';
|
|
3
|
+
import type { CreateRemindersListOptions } from '../schemas/interfaces/create-reminders-list-options';
|
|
4
|
+
import type { CreateRemindersListResult } from '../schemas/interfaces/create-reminders-list-result';
|
|
5
|
+
import type { DeleteReminderOptions } from '../schemas/interfaces/delete-reminder-options';
|
|
6
|
+
import type { DeleteReminderWithPromptOptions } from '../schemas/interfaces/delete-reminder-with-prompt-options';
|
|
7
|
+
import type { DeleteReminderWithPromptResult } from '../schemas/interfaces/delete-reminder-with-prompt-result';
|
|
8
|
+
import type { DeleteRemindersByIdOptions } from '../schemas/interfaces/delete-reminders-by-id-options';
|
|
9
|
+
import type { DeleteRemindersByIdResult } from '../schemas/interfaces/delete-reminders-by-id-result';
|
|
10
|
+
import type { DeleteRemindersListOptions } from '../schemas/interfaces/delete-reminders-list-options';
|
|
11
|
+
import type { FetchAllCalendarSourcesResult } from '../schemas/interfaces/fetch-all-calendar-sources-result';
|
|
12
|
+
import type { GetDefaultRemindersListResult } from '../schemas/interfaces/get-default-reminders-list-result';
|
|
13
|
+
import type { GetReminderByIdOptions } from '../schemas/interfaces/get-reminder-by-id-options';
|
|
14
|
+
import type { GetReminderByIdResult } from '../schemas/interfaces/get-reminder-by-id-result';
|
|
15
|
+
import type { GetRemindersFromListsOptions } from '../schemas/interfaces/get-reminders-from-lists-options';
|
|
16
|
+
import type { GetRemindersFromListsResult } from '../schemas/interfaces/get-reminders-from-lists-result';
|
|
17
|
+
import type { GetRemindersListsResult } from '../schemas/interfaces/get-reminders-lists-result';
|
|
18
|
+
import type { ModifyReminderOptions } from '../schemas/interfaces/modify-reminder-options';
|
|
19
|
+
import type { UpdateRemindersListOptions } from '../schemas/interfaces/update-reminders-list-options';
|
|
20
|
+
import type { UpdateRemindersListResult } from '../schemas/interfaces/update-reminders-list-result';
|
|
10
21
|
export interface RemindersOperations {
|
|
22
|
+
/**
|
|
23
|
+
* Creates a new reminders list.
|
|
24
|
+
*
|
|
25
|
+
* @throws {Error} `Title must be provided.` — when `title` is missing.
|
|
26
|
+
* @throws {Error} `Invalid color format.` — when `color` is present but invalid.
|
|
27
|
+
*
|
|
28
|
+
* @platform iOS
|
|
29
|
+
* @since 7.3.0
|
|
30
|
+
*/
|
|
31
|
+
createRemindersList(options: CreateRemindersListOptions): Promise<CreateRemindersListResult>;
|
|
32
|
+
/**
|
|
33
|
+
* Deletes a reminders list.
|
|
34
|
+
*
|
|
35
|
+
* @throws {Error} `List not found.` — when no list exists for `id`.
|
|
36
|
+
*
|
|
37
|
+
* @platform iOS
|
|
38
|
+
* @since 7.3.0
|
|
39
|
+
*/
|
|
40
|
+
deleteRemindersList(options: DeleteRemindersListOptions): Promise<void>;
|
|
11
41
|
/**
|
|
12
42
|
* Retrieves a list of calendar sources.
|
|
13
43
|
*
|
|
@@ -15,12 +45,12 @@ export interface RemindersOperations {
|
|
|
15
45
|
* @platform iOS
|
|
16
46
|
* @since 6.6.0
|
|
17
47
|
*/
|
|
18
|
-
fetchAllRemindersSources(): Promise<
|
|
19
|
-
result: CalendarSource[];
|
|
20
|
-
}>;
|
|
48
|
+
fetchAllRemindersSources(): Promise<FetchAllCalendarSourcesResult>;
|
|
21
49
|
/**
|
|
22
50
|
* Opens the reminders app.
|
|
23
51
|
*
|
|
52
|
+
* @throws {Error} `Failed to launch reminders app.` — when the system cannot open Reminders.
|
|
53
|
+
*
|
|
24
54
|
* @platform iOS
|
|
25
55
|
* @since 7.1.0
|
|
26
56
|
*/
|
|
@@ -31,27 +61,27 @@ export interface RemindersOperations {
|
|
|
31
61
|
* @platform iOS
|
|
32
62
|
* @since 7.1.0
|
|
33
63
|
*/
|
|
34
|
-
getDefaultRemindersList(): Promise<
|
|
35
|
-
result: RemindersList | null;
|
|
36
|
-
}>;
|
|
64
|
+
getDefaultRemindersList(): Promise<GetDefaultRemindersListResult>;
|
|
37
65
|
/**
|
|
38
66
|
* Retrieves all available reminders lists.
|
|
39
67
|
*
|
|
40
68
|
* @platform iOS
|
|
41
69
|
* @since 7.1.0
|
|
42
70
|
*/
|
|
43
|
-
getRemindersLists(): Promise<
|
|
44
|
-
result: RemindersList[];
|
|
45
|
-
}>;
|
|
71
|
+
getRemindersLists(): Promise<GetRemindersListsResult>;
|
|
46
72
|
/**
|
|
47
73
|
* Creates a reminder.
|
|
48
74
|
*
|
|
75
|
+
* @throws {Error} `Title must be provided.` — when `title` is missing.
|
|
76
|
+
* @throws {Error} `List not found.` — when `listId` is set and no list matches.
|
|
77
|
+
* @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is present but invalid.
|
|
78
|
+
* @throws {Error} `Frequency must be provided.` — when recurrence is set without `frequency`.
|
|
79
|
+
* @throws {Error} `Interval must be provided.` — when recurrence is set without `interval`.
|
|
80
|
+
*
|
|
49
81
|
* @platform iOS
|
|
50
82
|
* @since 0.5.0
|
|
51
83
|
*/
|
|
52
|
-
createReminder(options: CreateReminderOptions): Promise<
|
|
53
|
-
id: string;
|
|
54
|
-
}>;
|
|
84
|
+
createReminder(options: CreateReminderOptions): Promise<CreateReminderResult>;
|
|
55
85
|
/**
|
|
56
86
|
* Deletes multiple reminders.
|
|
57
87
|
*
|
|
@@ -65,6 +95,8 @@ export interface RemindersOperations {
|
|
|
65
95
|
/**
|
|
66
96
|
* Deletes a reminder.
|
|
67
97
|
*
|
|
98
|
+
* @throws {Error} `Reminder not found.` — when no reminder exists for `id`.
|
|
99
|
+
*
|
|
68
100
|
* @platform iOS
|
|
69
101
|
* @since 7.1.0
|
|
70
102
|
*/
|
|
@@ -72,39 +104,52 @@ export interface RemindersOperations {
|
|
|
72
104
|
/**
|
|
73
105
|
* Modifies a reminder.
|
|
74
106
|
*
|
|
107
|
+
* @throws {Error} `Reminder not found.` — when no reminder exists for `id`.
|
|
108
|
+
* @throws {Error} `List not found.` — when `listId` is set and no list matches.
|
|
109
|
+
* @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is present but invalid.
|
|
110
|
+
* @throws {Error} `Frequency must be provided.` — when recurrence is set without `frequency`.
|
|
111
|
+
* @throws {Error} `Interval must be provided.` — when recurrence is set without `interval`.
|
|
112
|
+
*
|
|
75
113
|
* @platform iOS
|
|
76
114
|
* @since 6.7.0
|
|
77
115
|
*/
|
|
78
116
|
modifyReminder(options: ModifyReminderOptions): Promise<void>;
|
|
79
117
|
/**
|
|
80
|
-
*
|
|
118
|
+
* Retrieves a reminder by id.
|
|
81
119
|
*
|
|
82
120
|
* @platform iOS
|
|
83
121
|
* @since 7.1.0
|
|
84
122
|
*/
|
|
85
|
-
getReminderById(options: GetReminderByIdOptions): Promise<
|
|
86
|
-
result: Reminder | null;
|
|
87
|
-
}>;
|
|
123
|
+
getReminderById(options: GetReminderByIdOptions): Promise<GetReminderByIdResult>;
|
|
88
124
|
/**
|
|
89
125
|
* Retrieves reminders from multiple lists.
|
|
90
126
|
*
|
|
127
|
+
* @throws {Error} `List not found.` — when a requested list id does not exist.
|
|
128
|
+
*
|
|
91
129
|
* @platform iOS
|
|
92
130
|
* @since 5.3.0
|
|
93
131
|
*/
|
|
94
|
-
getRemindersFromLists(options: GetRemindersFromListsOptions): Promise<
|
|
95
|
-
result: Reminder[];
|
|
96
|
-
}>;
|
|
97
|
-
}
|
|
98
|
-
/**
|
|
99
|
-
* @since 7.1.0
|
|
100
|
-
*/
|
|
101
|
-
export interface DeleteRemindersByIdResult {
|
|
132
|
+
getRemindersFromLists(options: GetRemindersFromListsOptions): Promise<GetRemindersFromListsResult>;
|
|
102
133
|
/**
|
|
103
|
-
*
|
|
134
|
+
* Opens a dialog to delete a reminder.
|
|
135
|
+
*
|
|
136
|
+
* @throws {Error} `Reminder not found.` — when no reminder exists for `id`.
|
|
137
|
+
* @throws {Error} `Missing view controller.` — when the plugin cannot present the dialog.
|
|
138
|
+
*
|
|
139
|
+
* @platform iOS
|
|
140
|
+
* @since 7.2.0
|
|
104
141
|
*/
|
|
105
|
-
|
|
142
|
+
deleteReminderWithPrompt(options: DeleteReminderWithPromptOptions): Promise<DeleteReminderWithPromptResult>;
|
|
106
143
|
/**
|
|
107
|
-
*
|
|
144
|
+
* Updates a reminders list.
|
|
145
|
+
*
|
|
146
|
+
* @throws {Error} `Event ID must be provided.` — when `id` is missing.
|
|
147
|
+
* @throws {Error} `List not found.` — when no list exists for `id`.
|
|
148
|
+
* @throws {Error} `List is not modifiable.` — when the list does not allow edits.
|
|
149
|
+
* @throws {Error} `Invalid color format.` — when `color` is present but invalid.
|
|
150
|
+
*
|
|
151
|
+
* @platform iOS
|
|
152
|
+
* @since 7.3.0
|
|
108
153
|
*/
|
|
109
|
-
|
|
154
|
+
updateRemindersList(options: UpdateRemindersListOptions): Promise<UpdateRemindersListResult>;
|
|
110
155
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reminders-operations.js","sourceRoot":"","sources":["../../../src/sub-definitions/reminders-operations.ts"],"names":[],"mappings":"","sourcesContent":["import type {
|
|
1
|
+
{"version":3,"file":"reminders-operations.js","sourceRoot":"","sources":["../../../src/sub-definitions/reminders-operations.ts"],"names":[],"mappings":"","sourcesContent":["import type { CreateReminderOptions } from '../schemas/interfaces/create-reminder-options';\nimport type { CreateReminderResult } from '../schemas/interfaces/create-reminder-result';\nimport type { CreateRemindersListOptions } from '../schemas/interfaces/create-reminders-list-options';\nimport type { CreateRemindersListResult } from '../schemas/interfaces/create-reminders-list-result';\nimport type { DeleteReminderOptions } from '../schemas/interfaces/delete-reminder-options';\nimport type { DeleteReminderWithPromptOptions } from '../schemas/interfaces/delete-reminder-with-prompt-options';\nimport type { DeleteReminderWithPromptResult } from '../schemas/interfaces/delete-reminder-with-prompt-result';\nimport type { DeleteRemindersByIdOptions } from '../schemas/interfaces/delete-reminders-by-id-options';\nimport type { DeleteRemindersByIdResult } from '../schemas/interfaces/delete-reminders-by-id-result';\nimport type { DeleteRemindersListOptions } from '../schemas/interfaces/delete-reminders-list-options';\nimport type { FetchAllCalendarSourcesResult } from '../schemas/interfaces/fetch-all-calendar-sources-result';\nimport type { GetDefaultRemindersListResult } from '../schemas/interfaces/get-default-reminders-list-result';\nimport type { GetReminderByIdOptions } from '../schemas/interfaces/get-reminder-by-id-options';\nimport type { GetReminderByIdResult } from '../schemas/interfaces/get-reminder-by-id-result';\nimport type { GetRemindersFromListsOptions } from '../schemas/interfaces/get-reminders-from-lists-options';\nimport type { GetRemindersFromListsResult } from '../schemas/interfaces/get-reminders-from-lists-result';\nimport type { GetRemindersListsResult } from '../schemas/interfaces/get-reminders-lists-result';\nimport type { ModifyReminderOptions } from '../schemas/interfaces/modify-reminder-options';\nimport type { UpdateRemindersListOptions } from '../schemas/interfaces/update-reminders-list-options';\nimport type { UpdateRemindersListResult } from '../schemas/interfaces/update-reminders-list-result';\n\nexport interface RemindersOperations {\n /**\n * Creates a new reminders list.\n *\n * @throws {Error} `Title must be provided.` — when `title` is missing.\n * @throws {Error} `Invalid color format.` — when `color` is present but invalid.\n *\n * @platform iOS\n * @since 7.3.0\n */\n createRemindersList(options: CreateRemindersListOptions): Promise<CreateRemindersListResult>;\n /**\n * Deletes a reminders list.\n *\n * @throws {Error} `List not found.` — when no list exists for `id`.\n *\n * @platform iOS\n * @since 7.3.0\n */\n deleteRemindersList(options: DeleteRemindersListOptions): Promise<void>;\n /**\n * Retrieves a list of calendar sources.\n *\n * @deprecated Duplicates {@link CalendarOperations#fetchAllCalendarSources}\n * @platform iOS\n * @since 6.6.0\n */\n fetchAllRemindersSources(): Promise<FetchAllCalendarSourcesResult>;\n /**\n * Opens the reminders app.\n *\n * @throws {Error} `Failed to launch reminders app.` — when the system cannot open Reminders.\n *\n * @platform iOS\n * @since 7.1.0\n */\n openReminders(): Promise<void>;\n /**\n * Retrieves the default reminders list.\n *\n * @platform iOS\n * @since 7.1.0\n */\n getDefaultRemindersList(): Promise<GetDefaultRemindersListResult>;\n /**\n * Retrieves all available reminders lists.\n *\n * @platform iOS\n * @since 7.1.0\n */\n getRemindersLists(): Promise<GetRemindersListsResult>;\n /**\n * Creates a reminder.\n *\n * @throws {Error} `Title must be provided.` — when `title` is missing.\n * @throws {Error} `List not found.` — when `listId` is set and no list matches.\n * @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is present but invalid.\n * @throws {Error} `Frequency must be provided.` — when recurrence is set without `frequency`.\n * @throws {Error} `Interval must be provided.` — when recurrence is set without `interval`.\n *\n * @platform iOS\n * @since 0.5.0\n */\n createReminder(options: CreateReminderOptions): Promise<CreateReminderResult>;\n /**\n * Deletes multiple reminders.\n *\n * @deprecated Use `deleteReminder(...)`.\n * @platform iOS\n * @since 5.3.0\n */\n deleteRemindersById(options: DeleteRemindersByIdOptions): Promise<{ result: DeleteRemindersByIdResult }>;\n /**\n * Deletes a reminder.\n *\n * @throws {Error} `Reminder not found.` — when no reminder exists for `id`.\n *\n * @platform iOS\n * @since 7.1.0\n */\n deleteReminder(options: DeleteReminderOptions): Promise<void>;\n /**\n * Modifies a reminder.\n *\n * @throws {Error} `Reminder not found.` — when no reminder exists for `id`.\n * @throws {Error} `List not found.` — when `listId` is set and no list matches.\n * @throws {Error} `Invalid frequency.` — when `recurrence.frequency` is present but invalid.\n * @throws {Error} `Frequency must be provided.` — when recurrence is set without `frequency`.\n * @throws {Error} `Interval must be provided.` — when recurrence is set without `interval`.\n *\n * @platform iOS\n * @since 6.7.0\n */\n modifyReminder(options: ModifyReminderOptions): Promise<void>;\n /**\n * Retrieves a reminder by id.\n *\n * @platform iOS\n * @since 7.1.0\n */\n getReminderById(options: GetReminderByIdOptions): Promise<GetReminderByIdResult>;\n /**\n * Retrieves reminders from multiple lists.\n *\n * @throws {Error} `List not found.` — when a requested list id does not exist.\n *\n * @platform iOS\n * @since 5.3.0\n */\n getRemindersFromLists(options: GetRemindersFromListsOptions): Promise<GetRemindersFromListsResult>;\n /**\n * Opens a dialog to delete a reminder.\n *\n * @throws {Error} `Reminder not found.` — when no reminder exists for `id`.\n * @throws {Error} `Missing view controller.` — when the plugin cannot present the dialog.\n *\n * @platform iOS\n * @since 7.2.0\n */\n deleteReminderWithPrompt(options: DeleteReminderWithPromptOptions): Promise<DeleteReminderWithPromptResult>;\n /**\n * Updates a reminders list.\n *\n * @throws {Error} `Event ID must be provided.` — when `id` is missing.\n * @throws {Error} `List not found.` — when no list exists for `id`.\n * @throws {Error} `List is not modifiable.` — when the list does not allow edits.\n * @throws {Error} `Invalid color format.` — when `color` is present but invalid.\n *\n * @platform iOS\n * @since 7.3.0\n */\n updateRemindersList(options: UpdateRemindersListOptions): Promise<UpdateRemindersListResult>;\n}\n"]}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Triggers a browser download for an `.ics` `File`.
|
|
3
|
+
* Resolves after the object URL is revoked.
|
|
4
|
+
*
|
|
5
|
+
* @throws If `document` or `URL` is not available.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const { ics } = await CapacitorCalendar.createEvent({
|
|
9
|
+
* title: 'Team standup',
|
|
10
|
+
* icsFileName: 'team-standup.ics',
|
|
11
|
+
* });
|
|
12
|
+
* if (ics) {
|
|
13
|
+
* await downloadIcsFile(ics);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* @since 7.3.0
|
|
17
|
+
*/
|
|
18
|
+
export declare function downloadIcsFile(file: File): Promise<void>;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Triggers a browser download for an `.ics` `File`.
|
|
3
|
+
* Resolves after the object URL is revoked.
|
|
4
|
+
*
|
|
5
|
+
* @throws If `document` or `URL` is not available.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* const { ics } = await CapacitorCalendar.createEvent({
|
|
9
|
+
* title: 'Team standup',
|
|
10
|
+
* icsFileName: 'team-standup.ics',
|
|
11
|
+
* });
|
|
12
|
+
* if (ics) {
|
|
13
|
+
* await downloadIcsFile(ics);
|
|
14
|
+
* }
|
|
15
|
+
*
|
|
16
|
+
* @since 7.3.0
|
|
17
|
+
*/
|
|
18
|
+
export async function downloadIcsFile(file) {
|
|
19
|
+
if (typeof document === 'undefined' || typeof URL === 'undefined') {
|
|
20
|
+
throw new Error('downloadIcsFile requires a browser document environment.');
|
|
21
|
+
}
|
|
22
|
+
const url = URL.createObjectURL(file);
|
|
23
|
+
const link = document.createElement('a');
|
|
24
|
+
link.href = url;
|
|
25
|
+
link.download = file.name.length > 0 ? file.name : 'event.ics';
|
|
26
|
+
document.body.appendChild(link);
|
|
27
|
+
link.click();
|
|
28
|
+
link.remove();
|
|
29
|
+
// Delay revoke so the browser can start the download
|
|
30
|
+
await new Promise((resolve) => setTimeout(resolve, 1000));
|
|
31
|
+
URL.revokeObjectURL(url);
|
|
32
|
+
}
|
|
33
|
+
//# sourceMappingURL=download-ics-file.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"download-ics-file.js","sourceRoot":"","sources":["../../../src/web/download-ics-file.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AACH,MAAM,CAAC,KAAK,UAAU,eAAe,CAAC,IAAU;IAC9C,IAAI,OAAO,QAAQ,KAAK,WAAW,IAAI,OAAO,GAAG,KAAK,WAAW,EAAE,CAAC;QAClE,MAAM,IAAI,KAAK,CAAC,0DAA0D,CAAC,CAAC;IAC9E,CAAC;IAED,MAAM,GAAG,GAAG,GAAG,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC;IACtC,MAAM,IAAI,GAAG,QAAQ,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC;IAChB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,WAAW,CAAC;IAC/D,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC;IAChC,IAAI,CAAC,KAAK,EAAE,CAAC;IACb,IAAI,CAAC,MAAM,EAAE,CAAC;IACd,qDAAqD;IACrD,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC,CAAC;IAC1D,GAAG,CAAC,eAAe,CAAC,GAAG,CAAC,CAAC;AAC3B,CAAC","sourcesContent":["/**\n * Triggers a browser download for an `.ics` `File`.\n * Resolves after the object URL is revoked.\n *\n * @throws If `document` or `URL` is not available.\n *\n * @example\n * const { ics } = await CapacitorCalendar.createEvent({\n * title: 'Team standup',\n * icsFileName: 'team-standup.ics',\n * });\n * if (ics) {\n * await downloadIcsFile(ics);\n * }\n *\n * @since 7.3.0\n */\nexport async function downloadIcsFile(file: File): Promise<void> {\n if (typeof document === 'undefined' || typeof URL === 'undefined') {\n throw new Error('downloadIcsFile requires a browser document environment.');\n }\n\n const url = URL.createObjectURL(file);\n const link = document.createElement('a');\n link.href = url;\n link.download = file.name.length > 0 ? file.name : 'event.ics';\n document.body.appendChild(link);\n link.click();\n link.remove();\n // Delay revoke so the browser can start the download\n await new Promise((resolve) => setTimeout(resolve, 1000));\n URL.revokeObjectURL(url);\n}\n"]}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { CreateEventOptions } from '../schemas/interfaces/create-event-options';
|
|
2
|
+
/**
|
|
3
|
+
* Builds an RFC 5545 `VCALENDAR` document with one `VEVENT` from CreateEventOptions.
|
|
4
|
+
* End comes from `endDate`, else `duration` (RFC 2445), else one hour (or next day if all-day).
|
|
5
|
+
* All-day ends that fall on the start's local day bump to the next day (exclusive `DTEND`).
|
|
6
|
+
*/
|
|
7
|
+
export declare function buildEventIcs(options: CreateEventOptions): string;
|
|
8
|
+
/**
|
|
9
|
+
* Resolves the `.ics` download filename.
|
|
10
|
+
* Uses `icsFileName` when set; otherwise derives a name from `title` (fallback `event.ics`).
|
|
11
|
+
* Appends `.ics` when the chosen name has no such extension.
|
|
12
|
+
*/
|
|
13
|
+
export declare function resolveIcsFileName(options: Pick<CreateEventOptions, 'icsFileName' | 'title'>): string;
|
|
14
|
+
/**
|
|
15
|
+
* Resolves event end milliseconds the same way ICS export does.
|
|
16
|
+
* Prefers `endDate`, else `duration` (RFC 2445), else one hour (or next day if all-day).
|
|
17
|
+
* All-day ends that fall on the start's local day bump to the next day (exclusive `DTEND`).
|
|
18
|
+
*/
|
|
19
|
+
export declare function resolveEndDate(startDate: number, endDate: number | undefined, duration: string | undefined, isAllDay: boolean): number;
|
|
20
|
+
/**
|
|
21
|
+
* Escapes TEXT values per RFC 5545 §3.3.11.
|
|
22
|
+
*/
|
|
23
|
+
export declare function escapeText(value: string): string;
|
|
24
|
+
/**
|
|
25
|
+
* Folds a content line so each physical line is at most 75 octets (RFC 5545 §3.1).
|
|
26
|
+
*/
|
|
27
|
+
export declare function foldLine(line: string): string;
|
|
@@ -0,0 +1,294 @@
|
|
|
1
|
+
import { EventAvailability } from '../schemas/enums/event-availability';
|
|
2
|
+
const HOUR_MS = 60 * 60 * 1000;
|
|
3
|
+
const DAY_MS = 24 * HOUR_MS;
|
|
4
|
+
const CRLF = '\r\n';
|
|
5
|
+
/**
|
|
6
|
+
* Builds an RFC 5545 `VCALENDAR` document with one `VEVENT` from CreateEventOptions.
|
|
7
|
+
* End comes from `endDate`, else `duration` (RFC 2445), else one hour (or next day if all-day).
|
|
8
|
+
* All-day ends that fall on the start's local day bump to the next day (exclusive `DTEND`).
|
|
9
|
+
*/
|
|
10
|
+
export function buildEventIcs(options) {
|
|
11
|
+
var _a;
|
|
12
|
+
const startDate = (_a = options.startDate) !== null && _a !== void 0 ? _a : Date.now();
|
|
13
|
+
const isAllDay = options.isAllDay === true;
|
|
14
|
+
const endDate = resolveEndDate(startDate, options.endDate, options.duration, isAllDay);
|
|
15
|
+
const lines = [
|
|
16
|
+
'BEGIN:VCALENDAR',
|
|
17
|
+
'VERSION:2.0',
|
|
18
|
+
'PRODID:-//ebarooni/capacitor-calendar//EN',
|
|
19
|
+
'CALSCALE:GREGORIAN',
|
|
20
|
+
'METHOD:PUBLISH',
|
|
21
|
+
'BEGIN:VEVENT',
|
|
22
|
+
`UID:${generateUid()}`,
|
|
23
|
+
`DTSTAMP:${formatDateTimeUtc(Date.now())}`,
|
|
24
|
+
];
|
|
25
|
+
if (isAllDay) {
|
|
26
|
+
lines.push(`DTSTART;VALUE=DATE:${formatDateOnlyLocal(startDate)}`);
|
|
27
|
+
lines.push(`DTEND;VALUE=DATE:${formatDateOnlyLocal(endDate)}`);
|
|
28
|
+
}
|
|
29
|
+
else {
|
|
30
|
+
lines.push(`DTSTART:${formatDateTimeUtc(startDate)}`);
|
|
31
|
+
lines.push(`DTEND:${formatDateTimeUtc(endDate)}`);
|
|
32
|
+
}
|
|
33
|
+
lines.push(`SUMMARY:${escapeText(options.title)}`);
|
|
34
|
+
if (options.description != null && options.description.length > 0) {
|
|
35
|
+
lines.push(`DESCRIPTION:${escapeText(options.description)}`);
|
|
36
|
+
}
|
|
37
|
+
if (options.location != null && options.location.length > 0) {
|
|
38
|
+
lines.push(`LOCATION:${escapeText(options.location)}`);
|
|
39
|
+
}
|
|
40
|
+
if (options.url != null && options.url.length > 0) {
|
|
41
|
+
lines.push(`URL:${escapeText(options.url)}`);
|
|
42
|
+
}
|
|
43
|
+
if (options.organizer != null && options.organizer.length > 0) {
|
|
44
|
+
lines.push(`ORGANIZER:mailto:${escapeText(options.organizer)}`);
|
|
45
|
+
}
|
|
46
|
+
const transp = mapTransparency(options.availability);
|
|
47
|
+
if (transp != null) {
|
|
48
|
+
lines.push(`TRANSP:${transp}`);
|
|
49
|
+
}
|
|
50
|
+
if (options.recurrence != null) {
|
|
51
|
+
lines.push(`RRULE:${toRRule(options.recurrence, isAllDay)}`);
|
|
52
|
+
}
|
|
53
|
+
if (options.attendees != null) {
|
|
54
|
+
for (const guest of options.attendees) {
|
|
55
|
+
if (guest.email.length === 0) {
|
|
56
|
+
continue;
|
|
57
|
+
}
|
|
58
|
+
const cn = guest.name != null && guest.name.length > 0 ? `;CN=${formatParamValue(guest.name)}` : '';
|
|
59
|
+
lines.push(`ATTENDEE${cn}:mailto:${escapeText(guest.email)}`);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
if (options.alerts != null) {
|
|
63
|
+
for (const minutes of options.alerts) {
|
|
64
|
+
lines.push(...buildAlarm(minutes));
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
lines.push('END:VEVENT', 'END:VCALENDAR');
|
|
68
|
+
return lines.map(foldLine).join(CRLF) + CRLF;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Resolves the `.ics` download filename.
|
|
72
|
+
* Uses `icsFileName` when set; otherwise derives a name from `title` (fallback `event.ics`).
|
|
73
|
+
* Appends `.ics` when the chosen name has no such extension.
|
|
74
|
+
*/
|
|
75
|
+
export function resolveIcsFileName(options) {
|
|
76
|
+
var _a;
|
|
77
|
+
const custom = (_a = options.icsFileName) === null || _a === void 0 ? void 0 : _a.trim();
|
|
78
|
+
if (custom != null && custom.length > 0) {
|
|
79
|
+
return /\.ics$/i.test(custom) ? custom : `${custom}.ics`;
|
|
80
|
+
}
|
|
81
|
+
return fileNameFromTitle(options.title);
|
|
82
|
+
}
|
|
83
|
+
function fileNameFromTitle(title) {
|
|
84
|
+
const base = (title !== null && title !== void 0 ? title : 'event')
|
|
85
|
+
.trim()
|
|
86
|
+
.replace(/[^\w\s-]+/g, '')
|
|
87
|
+
.replace(/\s+/g, '-')
|
|
88
|
+
.replace(/-+/g, '-')
|
|
89
|
+
.replace(/^-|-$/g, '')
|
|
90
|
+
.slice(0, 64);
|
|
91
|
+
return `${base.length > 0 ? base : 'event'}.ics`;
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Resolves event end milliseconds the same way ICS export does.
|
|
95
|
+
* Prefers `endDate`, else `duration` (RFC 2445), else one hour (or next day if all-day).
|
|
96
|
+
* All-day ends that fall on the start's local day bump to the next day (exclusive `DTEND`).
|
|
97
|
+
*/
|
|
98
|
+
export function resolveEndDate(startDate, endDate, duration, isAllDay) {
|
|
99
|
+
let resolved;
|
|
100
|
+
if (endDate != null) {
|
|
101
|
+
resolved = endDate;
|
|
102
|
+
}
|
|
103
|
+
else if (duration != null && duration.trim().length > 0) {
|
|
104
|
+
resolved = startDate + parseRfc2445DurationMs(duration.trim());
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
resolved = isAllDay ? startDate + DAY_MS : startDate + HOUR_MS;
|
|
108
|
+
}
|
|
109
|
+
if (!isAllDay) {
|
|
110
|
+
return resolved;
|
|
111
|
+
}
|
|
112
|
+
// ICS all-day DTEND is exclusive; same local date as DTSTART is zero-length.
|
|
113
|
+
// Also covers short durations (e.g. PT1H) on all-day events — treat as one whole day.
|
|
114
|
+
if (formatDateOnlyLocal(resolved) <= formatDateOnlyLocal(startDate)) {
|
|
115
|
+
return startDate + DAY_MS;
|
|
116
|
+
}
|
|
117
|
+
return resolved;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Parses an RFC 2445 / RFC 5545 duration string into milliseconds.
|
|
121
|
+
* Supports forms such as `PT1H`, `P1D`, `P3W`, `P2DT4H30M`.
|
|
122
|
+
*
|
|
123
|
+
* @throws If the string is empty, negative, zero-length, or not a valid duration.
|
|
124
|
+
*/
|
|
125
|
+
function parseRfc2445DurationMs(value) {
|
|
126
|
+
var _a, _b, _c, _d, _e;
|
|
127
|
+
const match = /^([+-])?P(?:(\d+)W)?(?:(\d+)D)?(?:T(?:(\d+)H)?(?:(\d+)M)?(?:(\d+)S)?)?$/i.exec(value);
|
|
128
|
+
if (match == null) {
|
|
129
|
+
throw new Error(`Invalid duration: ${value}`);
|
|
130
|
+
}
|
|
131
|
+
const sign = match[1] === '-' ? -1 : 1;
|
|
132
|
+
const weeks = Number((_a = match[2]) !== null && _a !== void 0 ? _a : 0);
|
|
133
|
+
const days = Number((_b = match[3]) !== null && _b !== void 0 ? _b : 0);
|
|
134
|
+
const hours = Number((_c = match[4]) !== null && _c !== void 0 ? _c : 0);
|
|
135
|
+
const minutes = Number((_d = match[5]) !== null && _d !== void 0 ? _d : 0);
|
|
136
|
+
const seconds = Number((_e = match[6]) !== null && _e !== void 0 ? _e : 0);
|
|
137
|
+
// Require at least one unit so bare "P" / "PT" are rejected.
|
|
138
|
+
if (weeks === 0 && days === 0 && hours === 0 && minutes === 0 && seconds === 0) {
|
|
139
|
+
throw new Error(`Invalid duration: ${value}`);
|
|
140
|
+
}
|
|
141
|
+
const ms = weeks * 7 * DAY_MS + days * DAY_MS + hours * HOUR_MS + minutes * 60 * 1000 + seconds * 1000;
|
|
142
|
+
const signed = sign * ms;
|
|
143
|
+
if (signed <= 0) {
|
|
144
|
+
throw new Error(`Invalid duration: ${value}`);
|
|
145
|
+
}
|
|
146
|
+
return signed;
|
|
147
|
+
}
|
|
148
|
+
function mapTransparency(availability) {
|
|
149
|
+
if (availability == null) {
|
|
150
|
+
return null;
|
|
151
|
+
}
|
|
152
|
+
if (availability === EventAvailability.FREE) {
|
|
153
|
+
return 'TRANSPARENT';
|
|
154
|
+
}
|
|
155
|
+
if (availability === EventAvailability.BUSY) {
|
|
156
|
+
return 'OPAQUE';
|
|
157
|
+
}
|
|
158
|
+
return 'OPAQUE';
|
|
159
|
+
}
|
|
160
|
+
function toRRule(rule, isAllDay) {
|
|
161
|
+
var _a;
|
|
162
|
+
const parts = [`FREQ=${rule.frequency.toUpperCase()}`, `INTERVAL=${Math.max(1, (_a = rule.interval) !== null && _a !== void 0 ? _a : 1)}`];
|
|
163
|
+
if (rule.count != null) {
|
|
164
|
+
parts.push(`COUNT=${rule.count}`);
|
|
165
|
+
}
|
|
166
|
+
else if (rule.end != null) {
|
|
167
|
+
// RFC 5545: UNTIL must match DTSTART value type (DATE vs DATE-TIME).
|
|
168
|
+
parts.push(`UNTIL=${isAllDay ? formatDateOnlyLocal(rule.end) : formatDateTimeUtc(rule.end)}`);
|
|
169
|
+
}
|
|
170
|
+
if (rule.byWeekDay != null && rule.byWeekDay.length > 0) {
|
|
171
|
+
const mapped = rule.byWeekDay.map(mapWeekday).filter((d) => d != null);
|
|
172
|
+
if (mapped.length > 0) {
|
|
173
|
+
parts.push(`BYDAY=${[...new Set(mapped)].join(',')}`);
|
|
174
|
+
}
|
|
175
|
+
}
|
|
176
|
+
if (rule.byMonthDay != null && rule.byMonthDay.length > 0) {
|
|
177
|
+
parts.push(`BYMONTHDAY=${rule.byMonthDay.join(',')}`);
|
|
178
|
+
}
|
|
179
|
+
if (rule.byMonth != null && rule.byMonth.length > 0) {
|
|
180
|
+
parts.push(`BYMONTH=${rule.byMonth.join(',')}`);
|
|
181
|
+
}
|
|
182
|
+
if (rule.weeksOfTheYear != null && rule.weeksOfTheYear.length > 0) {
|
|
183
|
+
parts.push(`BYWEEKNO=${rule.weeksOfTheYear.join(',')}`);
|
|
184
|
+
}
|
|
185
|
+
if (rule.daysOfTheYear != null && rule.daysOfTheYear.length > 0) {
|
|
186
|
+
parts.push(`BYYEARDAY=${rule.daysOfTheYear.join(',')}`);
|
|
187
|
+
}
|
|
188
|
+
return parts.join(';');
|
|
189
|
+
}
|
|
190
|
+
function mapWeekday(day) {
|
|
191
|
+
switch (day) {
|
|
192
|
+
case 1:
|
|
193
|
+
return 'MO';
|
|
194
|
+
case 2:
|
|
195
|
+
return 'TU';
|
|
196
|
+
case 3:
|
|
197
|
+
return 'WE';
|
|
198
|
+
case 4:
|
|
199
|
+
return 'TH';
|
|
200
|
+
case 5:
|
|
201
|
+
return 'FR';
|
|
202
|
+
case 6:
|
|
203
|
+
return 'SA';
|
|
204
|
+
case 7:
|
|
205
|
+
return 'SU';
|
|
206
|
+
default:
|
|
207
|
+
return null;
|
|
208
|
+
}
|
|
209
|
+
}
|
|
210
|
+
function buildAlarm(minutes) {
|
|
211
|
+
const trigger = minutes < 0 ? `-PT${Math.abs(minutes)}M` : `PT${minutes}M`;
|
|
212
|
+
return ['BEGIN:VALARM', 'ACTION:DISPLAY', 'DESCRIPTION:Reminder', `TRIGGER:${trigger}`, 'END:VALARM'];
|
|
213
|
+
}
|
|
214
|
+
function generateUid() {
|
|
215
|
+
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
216
|
+
return `${crypto.randomUUID()}@capacitor-calendar`;
|
|
217
|
+
}
|
|
218
|
+
return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}@capacitor-calendar`;
|
|
219
|
+
}
|
|
220
|
+
function formatDateTimeUtc(ms) {
|
|
221
|
+
const date = new Date(ms);
|
|
222
|
+
const fullYear = date.getUTCFullYear();
|
|
223
|
+
const month = padTwoDigits(date.getUTCMonth() + 1);
|
|
224
|
+
const dayOfMonth = padTwoDigits(date.getUTCDate());
|
|
225
|
+
const hours = padTwoDigits(date.getUTCHours());
|
|
226
|
+
const minutes = padTwoDigits(date.getUTCMinutes());
|
|
227
|
+
const seconds = padTwoDigits(date.getUTCSeconds());
|
|
228
|
+
return `${fullYear}${month}${dayOfMonth}T${hours}${minutes}${seconds}Z`;
|
|
229
|
+
}
|
|
230
|
+
function formatDateOnlyLocal(ms) {
|
|
231
|
+
const date = new Date(ms);
|
|
232
|
+
return `${date.getFullYear()}${padTwoDigits(date.getMonth() + 1)}${padTwoDigits(date.getDate())}`;
|
|
233
|
+
}
|
|
234
|
+
function padTwoDigits(value) {
|
|
235
|
+
return value < 10 ? `0${value}` : String(value);
|
|
236
|
+
}
|
|
237
|
+
/**
|
|
238
|
+
* Escapes TEXT values per RFC 5545 §3.3.11.
|
|
239
|
+
*/
|
|
240
|
+
export function escapeText(value) {
|
|
241
|
+
return value
|
|
242
|
+
.replace(/\\/g, '\\\\')
|
|
243
|
+
.replace(/;/g, '\\;')
|
|
244
|
+
.replace(/,/g, '\\,')
|
|
245
|
+
.replace(/\r\n|\n|\r/g, '\\n');
|
|
246
|
+
}
|
|
247
|
+
/**
|
|
248
|
+
* Formats a property parameter value per RFC 5545 §3.2.
|
|
249
|
+
* Values with COMMA, SEMICOLON, or COLON are quoted; DQUOTE and line breaks are sanitized.
|
|
250
|
+
*/
|
|
251
|
+
function formatParamValue(value) {
|
|
252
|
+
const sanitized = value.replace(/[\r\n]+/g, ' ').replace(/"/g, "'");
|
|
253
|
+
if (/[;:,]/.test(sanitized)) {
|
|
254
|
+
return `"${sanitized}"`;
|
|
255
|
+
}
|
|
256
|
+
return sanitized;
|
|
257
|
+
}
|
|
258
|
+
/**
|
|
259
|
+
* Folds a content line so each physical line is at most 75 octets (RFC 5545 §3.1).
|
|
260
|
+
*/
|
|
261
|
+
export function foldLine(line) {
|
|
262
|
+
const max = 75;
|
|
263
|
+
if (byteLength(line) <= max) {
|
|
264
|
+
return line;
|
|
265
|
+
}
|
|
266
|
+
const chars = [...line];
|
|
267
|
+
let result = '';
|
|
268
|
+
let current = '';
|
|
269
|
+
for (const ch of chars) {
|
|
270
|
+
const next = current + ch;
|
|
271
|
+
if (byteLength(next) > max) {
|
|
272
|
+
result += result.length === 0 ? current : `${CRLF} ${current}`;
|
|
273
|
+
current = ch;
|
|
274
|
+
// Continuations are limited to 74 octets of content + leading space = 75
|
|
275
|
+
while (byteLength(current) > max - 1) {
|
|
276
|
+
// Extremely rare for a single code point; split by taking first unit as-is
|
|
277
|
+
result += `${CRLF} ${current}`;
|
|
278
|
+
current = '';
|
|
279
|
+
break;
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
else {
|
|
283
|
+
current = next;
|
|
284
|
+
}
|
|
285
|
+
}
|
|
286
|
+
if (current.length > 0) {
|
|
287
|
+
result += result.length === 0 ? current : `${CRLF} ${current}`;
|
|
288
|
+
}
|
|
289
|
+
return result;
|
|
290
|
+
}
|
|
291
|
+
function byteLength(s) {
|
|
292
|
+
return new TextEncoder().encode(s).length;
|
|
293
|
+
}
|
|
294
|
+
//# sourceMappingURL=ics.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ics.js","sourceRoot":"","sources":["../../../src/web/ics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,qCAAqC,CAAC;AAIxE,MAAM,OAAO,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC;AAC/B,MAAM,MAAM,GAAG,EAAE,GAAG,OAAO,CAAC;AAC5B,MAAM,IAAI,GAAG,MAAM,CAAC;AAEpB;;;;GAIG;AACH,MAAM,UAAU,aAAa,CAAC,OAA2B;;IACvD,MAAM,SAAS,GAAG,MAAA,OAAO,CAAC,SAAS,mCAAI,IAAI,CAAC,GAAG,EAAE,CAAC;IAClD,M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'../schemas/enums/event-availability';\nimport type { CreateEventOptions } from '../schemas/interfaces/create-event-options';\nimport type { EventRecurrenceRule } from '../schemas/interfaces/event-recurrence-rule';\n\nconst HOUR_MS = 60 * 60 * 1000;\nconst DAY_MS = 24 * HOUR_MS;\nconst CRLF = '\\r\\n';\n\n/**\n * Builds an RFC 5545 `VCALENDAR` document with one `VEVENT` from CreateEventOptions.\n * End comes from `endDate`, else `duration` (RFC 2445), else one hour (or next day if all-day).\n * All-day ends that fall on the start's local day bump to the next day (exclusive `DTEND`).\n */\nexport function buildEventIcs(options: CreateEventOptions): string {\n const startDate = options.startDate ?? Date.now();\n const isAllDay = options.isAllDay === true;\n const endDate = resolveEndDate(startDate, options.endDate, options.duration, isAllDay);\n\n const lines: string[] = [\n 'BEGIN:VCALENDAR',\n 'VERSION:2.0',\n 'PRODID:-//ebarooni/capacitor-calendar//EN',\n 'CALSCALE:GREGORIAN',\n 'METHOD:PUBLISH',\n 'BEGIN:VEVENT',\n `UID:${generateUid()}`,\n `DTSTAMP:${formatDateTimeUtc(Date.now())}`,\n ];\n\n if (isAllDay) {\n lines.push(`DTSTART;VALUE=DATE:${formatDateOnlyLocal(startDate)}`);\n lines.push(`DTEND;VALUE=DATE:${formatDateOnlyLocal(endDate)}`);\n } else {\n lines.push(`DTSTART:${formatDateTimeUtc(startDate)}`);\n lines.push(`DTEND:${formatDateTimeUtc(endDate)}`);\n }\n\n lines.push(`SUMMARY:${escapeText(options.title)}`);\n\n if (options.description != null && options.description.length > 0) {\n lines.push(`DESCRIPTION:${escapeText(options.description)}`);\n }\n if (options.location != null && options.location.length > 0) {\n lines.push(`LOCATION:${escapeText(options.location)}`);\n }\n if (options.url != null && options.url.length > 0) {\n lines.push(`URL:${escapeText(options.url)}`);\n }\n if (options.organizer != null && options.organizer.length > 0) {\n lines.push(`ORGANIZER:mailto:${escapeText(options.organizer)}`);\n }\n\n const transp = mapTransparency(options.availability);\n if (transp != null) {\n lines.push(`TRANSP:${transp}`);\n }\n\n if (options.recurrence != null) {\n lines.push(`RRULE:${toRRule(options.recurrence, isAllDay)}`);\n }\n\n if (options.attendees != null) {\n for (const guest of options.attendees) {\n if (guest.email.length === 0) {\n continue;\n }\n const cn = guest.name != null && guest.name.length > 0 ? `;CN=${formatParamValue(guest.name)}` : '';\n lines.push(`ATTENDEE${cn}:mailto:${escapeText(guest.email)}`);\n }\n }\n\n if (options.alerts != null) {\n for (const minutes of options.alerts) {\n lines.push(...buildAlarm(minutes));\n }\n }\n\n lines.push('END:VEVENT', 'END:VCALENDAR');\n\n return lines.map(foldLine).join(CRLF) + CRLF;\n}\n\n/**\n * Resolves the `.ics` download filename.\n * Uses `icsFileName` when set; otherwise derives a name from `title` (fallback `event.ics`).\n * Appends `.ics` when the chosen name has no such extension.\n */\nexport function resolveIcsFileName(options: Pick<CreateEventOptions, 'icsFileName' | 'title'>): string {\n const custom = options.icsFileName?.trim();\n if (custom != null && custom.length > 0) {\n return /\\.ics$/i.test(custom) ? custom : `${custom}.ics`;\n }\n return fileNameFromTitle(options.title);\n}\n\nfunction fileNameFromTitle(title?: string): string {\n const base = (title ?? 'event')\n .trim()\n .replace(/[^\\w\\s-]+/g, '')\n .replace(/\\s+/g, '-')\n .replace(/-+/g, '-')\n .replace(/^-|-$/g, '')\n .slice(0, 64);\n return `${base.length > 0 ? base : 'event'}.ics`;\n}\n\n/**\n * Resolves event end milliseconds the same way ICS export does.\n * Prefers `endDate`, else `duration` (RFC 2445), else one hour (or next day if all-day).\n * All-day ends that fall on the start's local day bump to the next day (exclusive `DTEND`).\n */\nexport function resolveEndDate(\n startDate: number,\n endDate: number | undefined,\n duration: string | undefined,\n isAllDay: boolean,\n): number {\n let resolved: number;\n if (endDate != null) {\n resolved = endDate;\n } else if (duration != null && duration.trim().length > 0) {\n resolved = startDate + parseRfc2445DurationMs(duration.trim());\n } else {\n resolved = isAllDay ? startDate + DAY_MS : startDate + HOUR_MS;\n }\n\n if (!isAllDay) {\n return resolved;\n }\n\n // ICS all-day DTEND is exclusive; same local date as DTSTART is zero-length.\n // Also covers short durations (e.g. PT1H) on all-day events — treat as one whole day.\n if (formatDateOnlyLocal(resolved) <= formatDateOnlyLocal(startDate)) {\n return startDate + DAY_MS;\n }\n return resolved;\n}\n\n/**\n * Parses an RFC 2445 / RFC 5545 duration string into milliseconds.\n * Supports forms such as `PT1H`, `P1D`, `P3W`, `P2DT4H30M`.\n *\n * @throws If the string is empty, negative, zero-length, or not a valid duration.\n */\nfunction parseRfc2445DurationMs(value: string): number {\n const match = /^([+-])?P(?:(\\d+)W)?(?:(\\d+)D)?(?:T(?:(\\d+)H)?(?:(\\d+)M)?(?:(\\d+)S)?)?$/i.exec(value);\n if (match == null) {\n throw new Error(`Invalid duration: ${value}`);\n }\n\n const sign = match[1] === '-' ? -1 : 1;\n const weeks = Number(match[2] ?? 0);\n const days = Number(match[3] ?? 0);\n const hours = Number(match[4] ?? 0);\n const minutes = Number(match[5] ?? 0);\n const seconds = Number(match[6] ?? 0);\n\n // Require at least one unit so bare \"P\" / \"PT\" are rejected.\n if (weeks === 0 && days === 0 && hours === 0 && minutes === 0 && seconds === 0) {\n throw new Error(`Invalid duration: ${value}`);\n }\n\n const ms = weeks * 7 * DAY_MS + days * DAY_MS + hours * HOUR_MS + minutes * 60 * 1000 + seconds * 1000;\n const signed = sign * ms;\n if (signed <= 0) {\n throw new Error(`Invalid duration: ${value}`);\n }\n return signed;\n}\n\nfunction mapTransparency(availability: EventAvailability | undefined): 'OPAQUE' | 'TRANSPARENT' | null {\n if (availability == null) {\n return null;\n }\n if (availability === EventAvailability.FREE) {\n return 'TRANSPARENT';\n }\n if (availability === EventAvailability.BUSY) {\n return 'OPAQUE';\n }\n return 'OPAQUE';\n}\n\nfunction toRRule(rule: EventRecurrenceRule, isAllDay: boolean): string {\n const parts: string[] = [`FREQ=${rule.frequency.toUpperCase()}`, `INTERVAL=${Math.max(1, rule.interval ?? 1)}`];\n\n if (rule.count != null) {\n parts.push(`COUNT=${rule.count}`);\n } else if (rule.end != null) {\n // RFC 5545: UNTIL must match DTSTART value type (DATE vs DATE-TIME).\n parts.push(`UNTIL=${isAllDay ? formatDateOnlyLocal(rule.end) : formatDateTimeUtc(rule.end)}`);\n }\n\n if (rule.byWeekDay != null && rule.byWeekDay.length > 0) {\n const mapped = rule.byWeekDay.map(mapWeekday).filter((d): d is string => d != null);\n if (mapped.length > 0) {\n parts.push(`BYDAY=${[...new Set(mapped)].join(',')}`);\n }\n }\n\n if (rule.byMonthDay != null && rule.byMonthDay.length > 0) {\n parts.push(`BYMONTHDAY=${rule.byMonthDay.join(',')}`);\n }\n if (rule.byMonth != null && rule.byMonth.length > 0) {\n parts.push(`BYMONTH=${rule.byMonth.join(',')}`);\n }\n if (rule.weeksOfTheYear != null && rule.weeksOfTheYear.length > 0) {\n parts.push(`BYWEEKNO=${rule.weeksOfTheYear.join(',')}`);\n }\n if (rule.daysOfTheYear != null && rule.daysOfTheYear.length > 0) {\n parts.push(`BYYEARDAY=${rule.daysOfTheYear.join(',')}`);\n }\n\n return parts.join(';');\n}\n\nfunction mapWeekday(day: number): string | null {\n switch (day) {\n case 1:\n return 'MO';\n case 2:\n return 'TU';\n case 3:\n return 'WE';\n case 4:\n return 'TH';\n case 5:\n return 'FR';\n case 6:\n return 'SA';\n case 7:\n return 'SU';\n default:\n return null;\n }\n}\n\nfunction buildAlarm(minutes: number): string[] {\n const trigger = minutes < 0 ? `-PT${Math.abs(minutes)}M` : `PT${minutes}M`;\n return ['BEGIN:VALARM', 'ACTION:DISPLAY', 'DESCRIPTION:Reminder', `TRIGGER:${trigger}`, 'END:VALARM'];\n}\n\nfunction generateUid(): string {\n if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {\n return `${crypto.randomUUID()}@capacitor-calendar`;\n }\n return `${Date.now()}-${Math.random().toString(36).slice(2, 11)}@capacitor-calendar`;\n}\n\nfunction formatDateTimeUtc(ms: number): string {\n const date = new Date(ms);\n const fullYear = date.getUTCFullYear();\n const month = padTwoDigits(date.getUTCMonth() + 1);\n const dayOfMonth = padTwoDigits(date.getUTCDate());\n const hours = padTwoDigits(date.getUTCHours());\n const minutes = padTwoDigits(date.getUTCMinutes());\n const seconds = padTwoDigits(date.getUTCSeconds());\n return `${fullYear}${month}${dayOfMonth}T${hours}${minutes}${seconds}Z`;\n}\n\nfunction formatDateOnlyLocal(ms: number): string {\n const date = new Date(ms);\n return `${date.getFullYear()}${padTwoDigits(date.getMonth() + 1)}${padTwoDigits(date.getDate())}`;\n}\n\nfunction padTwoDigits(value: number): string {\n return value < 10 ? `0${value}` : String(value);\n}\n\n/**\n * Escapes TEXT values per RFC 5545 §3.3.11.\n */\nexport function escapeText(value: string): string {\n return value\n .replace(/\\\\/g, '\\\\\\\\')\n .replace(/;/g, '\\\\;')\n .replace(/,/g, '\\\\,')\n .replace(/\\r\\n|\\n|\\r/g, '\\\\n');\n}\n\n/**\n * Formats a property parameter value per RFC 5545 §3.2.\n * Values with COMMA, SEMICOLON, or COLON are quoted; DQUOTE and line breaks are sanitized.\n */\nfunction formatParamValue(value: string): string {\n const sanitized = value.replace(/[\\r\\n]+/g, ' ').replace(/\"/g, \"'\");\n if (/[;:,]/.test(sanitized)) {\n return `\"${sanitized}\"`;\n }\n return sanitized;\n}\n\n/**\n * Folds a content line so each physical line is at most 75 octets (RFC 5545 §3.1).\n */\nexport function foldLine(line: string): string {\n const max = 75;\n if (byteLength(line) <= max) {\n return line;\n }\n\n const chars = [...line];\n let result = '';\n let current = '';\n\n for (const ch of chars) {\n const next = current + ch;\n if (byteLength(next) > max) {\n result += result.length === 0 ? current : `${CRLF} ${current}`;\n current = ch;\n // Continuations are limited to 74 octets of content + leading space = 75\n while (byteLength(current) > max - 1) {\n // Extremely rare for a single code point; split by taking first unit as-is\n result += `${CRLF} ${current}`;\n current = '';\n break;\n }\n } else {\n current = next;\n }\n }\n\n if (current.length > 0) {\n result += result.length === 0 ? current : `${CRLF} ${current}`;\n }\n\n return result;\n}\n\nfunction byteLength(s: string): number {\n return new TextEncoder().encode(s).length;\n}\n"]}
|