@fullcalendar/google-calendar 7.0.0-rc.0 → 7.0.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +1 -1
- package/README.md +11 -5
- package/{index.global.js → global.js} +66 -38
- package/index.d.ts +50 -13
- package/index.js +21 -26
- package/package.json +12 -12
- package/index.cjs +0 -141
- package/index.global.min.js +0 -6
package/LICENSE.md
CHANGED
package/README.md
CHANGED
|
@@ -5,10 +5,10 @@ Display events from a public [Google Calendar feed](https://support.google.com/c
|
|
|
5
5
|
|
|
6
6
|
## Installation
|
|
7
7
|
|
|
8
|
-
Install the FullCalendar
|
|
8
|
+
Install the FullCalendar vanilla-JS package, the Google Calendar plugin, and any other plugins (like [daygrid](https://fullcalendar.io/docs/month-view)):
|
|
9
9
|
|
|
10
10
|
```sh
|
|
11
|
-
npm install
|
|
11
|
+
npm install fullcalendar @fullcalendar/google-calendar temporal-polyfill
|
|
12
12
|
```
|
|
13
13
|
|
|
14
14
|
## Usage
|
|
@@ -16,15 +16,21 @@ npm install @fullcalendar/core @fullcalendar/google-calendar @fullcalendar/daygr
|
|
|
16
16
|
Instantiate a Calendar with the necessary plugin:
|
|
17
17
|
|
|
18
18
|
```js
|
|
19
|
-
import { Calendar } from '
|
|
19
|
+
import { Calendar } from 'fullcalendar'
|
|
20
|
+
import classicThemePlugin from 'fullcalendar/themes/classic'
|
|
21
|
+
import dayGridPlugin from 'fullcalendar/daygrid'
|
|
20
22
|
import googleCalendarPlugin from '@fullcalendar/google-calendar'
|
|
21
|
-
|
|
23
|
+
|
|
24
|
+
import 'fullcalendar/skeleton.css'
|
|
25
|
+
import 'fullcalendar/themes/classic/theme.css'
|
|
26
|
+
import 'fullcalendar/themes/classic/palette.css'
|
|
22
27
|
|
|
23
28
|
const calendarEl = document.getElementById('calendar')
|
|
24
29
|
const calendar = new Calendar(calendarEl, {
|
|
25
30
|
plugins: [
|
|
26
31
|
googleCalendarPlugin,
|
|
27
|
-
dayGridPlugin
|
|
32
|
+
dayGridPlugin,
|
|
33
|
+
classicThemePlugin
|
|
28
34
|
],
|
|
29
35
|
initialView: 'dayGridMonth',
|
|
30
36
|
events: {
|
|
@@ -1,15 +1,54 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
FullCalendar Google Calendar Plugin v7.0.0-rc.
|
|
2
|
+
FullCalendar Google Calendar Plugin v7.0.0-rc.1
|
|
3
3
|
Docs & License: https://fullcalendar.io/docs/google-calendar
|
|
4
|
-
(c)
|
|
4
|
+
(c) 2025 Adam Shaw
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
(function () {
|
|
7
7
|
'use strict';
|
|
8
8
|
|
|
9
|
+
class JsonRequestError extends Error {
|
|
10
|
+
constructor(message, response) {
|
|
11
|
+
super(message);
|
|
12
|
+
this.response = response;
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
function requestJson(method, url, params) {
|
|
16
|
+
method = method.toUpperCase();
|
|
17
|
+
const fetchOptions = {
|
|
18
|
+
method,
|
|
19
|
+
};
|
|
20
|
+
if (method === 'GET') {
|
|
21
|
+
url += (url.indexOf('?') === -1 ? '?' : '&') +
|
|
22
|
+
new URLSearchParams(params);
|
|
23
|
+
}
|
|
24
|
+
else {
|
|
25
|
+
fetchOptions.body = new URLSearchParams(params);
|
|
26
|
+
fetchOptions.headers = {
|
|
27
|
+
'Content-Type': 'application/x-www-form-urlencoded',
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
return fetch(url, fetchOptions).then((fetchRes) => {
|
|
31
|
+
if (fetchRes.ok) {
|
|
32
|
+
return fetchRes.json().then((parsedResponse) => {
|
|
33
|
+
return [parsedResponse, fetchRes];
|
|
34
|
+
}, () => {
|
|
35
|
+
throw new JsonRequestError('Failure parsing JSON', fetchRes);
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
else {
|
|
39
|
+
throw new JsonRequestError('Request failed', fetchRes);
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
function identity(raw) {
|
|
44
|
+
return raw;
|
|
45
|
+
}
|
|
46
|
+
|
|
9
47
|
// TODO: expose somehow
|
|
10
48
|
const API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
|
|
11
49
|
const eventSourceDef = {
|
|
12
|
-
parseMeta(refined
|
|
50
|
+
parseMeta(refined // wtf -- GCalMeta & { url: string }
|
|
51
|
+
) {
|
|
13
52
|
let { googleCalendarId } = refined;
|
|
14
53
|
if (!googleCalendarId && refined.url) {
|
|
15
54
|
googleCalendarId = parseGoogleCalendarId(refined.url);
|
|
@@ -24,7 +63,8 @@ FullCalendar.GoogleCalendar = (function (exports, core, internal) {
|
|
|
24
63
|
}
|
|
25
64
|
return null;
|
|
26
65
|
},
|
|
27
|
-
fetch(arg, successCallback,
|
|
66
|
+
fetch(arg, successCallback, // TODO
|
|
67
|
+
errorCallback) {
|
|
28
68
|
let { dateEnv, options } = arg.context;
|
|
29
69
|
let meta = arg.eventSource.meta;
|
|
30
70
|
let apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
|
|
@@ -37,9 +77,9 @@ FullCalendar.GoogleCalendar = (function (exports, core, internal) {
|
|
|
37
77
|
let { extraParams } = meta;
|
|
38
78
|
let extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
|
|
39
79
|
let requestParams = buildRequestParams(arg.range, apiKey, extraParamsObj, dateEnv);
|
|
40
|
-
return
|
|
80
|
+
return requestJson('GET', url, requestParams).then(([body, response]) => {
|
|
41
81
|
if (body.error) {
|
|
42
|
-
errorCallback(new
|
|
82
|
+
errorCallback(new JsonRequestError('Google Calendar API: ' + body.error.message, response));
|
|
43
83
|
}
|
|
44
84
|
else {
|
|
45
85
|
successCallback({
|
|
@@ -73,21 +113,16 @@ FullCalendar.GoogleCalendar = (function (exports, core, internal) {
|
|
|
73
113
|
}
|
|
74
114
|
function buildRequestParams(range, apiKey, extraParams, dateEnv) {
|
|
75
115
|
let params;
|
|
76
|
-
let startStr;
|
|
77
|
-
let endStr;
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
// (start/end will be UTC-coerced dates, so toISOString is okay)
|
|
87
|
-
startStr = internal.addDays(range.start, -1).toISOString();
|
|
88
|
-
endStr = internal.addDays(range.end, 1).toISOString();
|
|
89
|
-
}
|
|
90
|
-
params = Object.assign(Object.assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
|
|
116
|
+
let startStr = dateEnv.formatIso(range.start);
|
|
117
|
+
let endStr = dateEnv.formatIso(range.end);
|
|
118
|
+
params = {
|
|
119
|
+
...(extraParams || {}),
|
|
120
|
+
key: apiKey,
|
|
121
|
+
timeMin: startStr,
|
|
122
|
+
timeMax: endStr,
|
|
123
|
+
singleEvents: true,
|
|
124
|
+
maxResults: 9999,
|
|
125
|
+
};
|
|
91
126
|
if (dateEnv.timeZone !== 'local') {
|
|
92
127
|
params.timeZone = dateEnv.timeZone;
|
|
93
128
|
}
|
|
@@ -105,8 +140,8 @@ FullCalendar.GoogleCalendar = (function (exports, core, internal) {
|
|
|
105
140
|
return {
|
|
106
141
|
id: item.id,
|
|
107
142
|
title: item.summary,
|
|
108
|
-
start: item.start.dateTime || item.start.date,
|
|
109
|
-
end: item.end.dateTime || item.end.date,
|
|
143
|
+
start: item.start.dateTime || item.start.date, // try timed. will fall back to all-day
|
|
144
|
+
end: item.end.dateTime || item.end.date, // same
|
|
110
145
|
url,
|
|
111
146
|
location: item.location,
|
|
112
147
|
description: item.description,
|
|
@@ -124,27 +159,20 @@ FullCalendar.GoogleCalendar = (function (exports, core, internal) {
|
|
|
124
159
|
const OPTION_REFINERS = {
|
|
125
160
|
googleCalendarApiKey: String,
|
|
126
161
|
};
|
|
127
|
-
|
|
128
162
|
const EVENT_SOURCE_REFINERS = {
|
|
129
|
-
googleCalendarApiKey: String,
|
|
163
|
+
googleCalendarApiKey: String, // TODO: rename with no prefix?
|
|
130
164
|
googleCalendarId: String,
|
|
131
165
|
googleCalendarApiBase: String,
|
|
132
|
-
extraParams:
|
|
166
|
+
extraParams: identity,
|
|
133
167
|
};
|
|
134
168
|
|
|
135
|
-
var plugin =
|
|
136
|
-
name: '
|
|
169
|
+
var plugin = {
|
|
170
|
+
name: 'google-calendar',
|
|
137
171
|
eventSourceDefs: [eventSourceDef],
|
|
138
172
|
optionRefiners: OPTION_REFINERS,
|
|
139
173
|
eventSourceRefiners: EVENT_SOURCE_REFINERS,
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
core.globalPlugins.push(plugin);
|
|
143
|
-
|
|
144
|
-
exports["default"] = plugin;
|
|
145
|
-
|
|
146
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
174
|
+
};
|
|
147
175
|
|
|
148
|
-
|
|
176
|
+
FullCalendar.globalPlugins.push(plugin);
|
|
149
177
|
|
|
150
|
-
})(
|
|
178
|
+
})();
|
package/index.d.ts
CHANGED
|
@@ -1,30 +1,67 @@
|
|
|
1
|
-
import
|
|
2
|
-
import {
|
|
1
|
+
import * as _fullcalendar_core_protected_api from '@fullcalendar/core/protected-api';
|
|
2
|
+
import { RawOptionsFromRefiners, RefinedOptionsFromRefiners, Identity } from '@fullcalendar/core/protected-api';
|
|
3
|
+
import * as _full_ui_headless_calendar from '@full-ui/headless-calendar';
|
|
4
|
+
|
|
5
|
+
interface GCalMeta {
|
|
6
|
+
googleCalendarId: string;
|
|
7
|
+
googleCalendarApiKey?: string;
|
|
8
|
+
googleCalendarApiBase?: string;
|
|
9
|
+
extraParams?: Record<string, any> | (() => Record<string, any>);
|
|
10
|
+
}
|
|
3
11
|
|
|
4
12
|
declare const OPTION_REFINERS: {
|
|
5
13
|
googleCalendarApiKey: StringConstructor;
|
|
6
14
|
};
|
|
7
|
-
|
|
15
|
+
type GoogleCalendarOptionRefiners = typeof OPTION_REFINERS;
|
|
16
|
+
type GoogleCalendarOptions = RawOptionsFromRefiners<GoogleCalendarOptionRefiners>;
|
|
17
|
+
type GoogleCalendarOptionsRefined = RefinedOptionsFromRefiners<GoogleCalendarOptionRefiners>;
|
|
8
18
|
declare const EVENT_SOURCE_REFINERS: {
|
|
9
19
|
googleCalendarApiKey: StringConstructor;
|
|
10
20
|
googleCalendarId: StringConstructor;
|
|
11
21
|
googleCalendarApiBase: StringConstructor;
|
|
12
|
-
extraParams: Identity<
|
|
22
|
+
extraParams: Identity<Record<string, any> | (() => Record<string, any>)>;
|
|
13
23
|
};
|
|
24
|
+
type GoogleCalendarEventSourceRefiners = typeof EVENT_SOURCE_REFINERS;
|
|
25
|
+
type GoogleCalendarEventSourceOptions = RawOptionsFromRefiners<GoogleCalendarEventSourceRefiners>;
|
|
26
|
+
type GoogleCalendarEventSourceOptionsRefined = RefinedOptionsFromRefiners<GoogleCalendarEventSourceRefiners>;
|
|
14
27
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
declare module '@fullcalendar/core/internal' {
|
|
18
|
-
interface BaseOptionRefiners extends ExtraOptionRefiners {
|
|
28
|
+
declare module '@fullcalendar/core/protected-api' {
|
|
29
|
+
interface BaseOptions extends GoogleCalendarOptions {
|
|
19
30
|
}
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
interface
|
|
31
|
+
interface BaseOptionsRefined extends GoogleCalendarOptionsRefined {
|
|
32
|
+
}
|
|
33
|
+
interface EventSourceOptions extends GoogleCalendarEventSourceOptions {
|
|
34
|
+
}
|
|
35
|
+
interface EventSourceOptionsRefined extends GoogleCalendarEventSourceOptionsRefined {
|
|
23
36
|
}
|
|
24
37
|
}
|
|
25
38
|
//# sourceMappingURL=ambient.d.ts.map
|
|
26
39
|
|
|
27
|
-
declare const _default:
|
|
40
|
+
declare const _default: {
|
|
41
|
+
name: string;
|
|
42
|
+
eventSourceDefs: {
|
|
43
|
+
parseMeta(refined: any): GCalMeta | null;
|
|
44
|
+
fetch(arg: {
|
|
45
|
+
range: _full_ui_headless_calendar.DateRange;
|
|
46
|
+
eventSource: any & {
|
|
47
|
+
meta: GCalMeta;
|
|
48
|
+
};
|
|
49
|
+
context: any & {
|
|
50
|
+
dateEnv: _full_ui_headless_calendar.DateEnv;
|
|
51
|
+
options: _fullcalendar_core_protected_api.BaseOptions;
|
|
52
|
+
};
|
|
53
|
+
}, successCallback: any, errorCallback: any): Promise<void>;
|
|
54
|
+
}[];
|
|
55
|
+
optionRefiners: {
|
|
56
|
+
googleCalendarApiKey: StringConstructor;
|
|
57
|
+
};
|
|
58
|
+
eventSourceRefiners: {
|
|
59
|
+
googleCalendarApiKey: StringConstructor;
|
|
60
|
+
googleCalendarId: StringConstructor;
|
|
61
|
+
googleCalendarApiBase: StringConstructor;
|
|
62
|
+
extraParams: _fullcalendar_core_protected_api.Identity<Record<string, any> | (() => Record<string, any>)>;
|
|
63
|
+
};
|
|
64
|
+
};
|
|
28
65
|
//# sourceMappingURL=index.d.ts.map
|
|
29
66
|
|
|
30
|
-
export { _default as default };
|
|
67
|
+
export { GoogleCalendarOptions, _default as default };
|
package/index.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { JsonRequestError,
|
|
2
|
-
import { requestJson, addDays, identity } from '@fullcalendar/core/internal.js';
|
|
1
|
+
import { requestJson, JsonRequestError, identity } from '@fullcalendar/core/protected-api';
|
|
3
2
|
|
|
4
3
|
// TODO: expose somehow
|
|
5
4
|
const API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
|
|
6
5
|
const eventSourceDef = {
|
|
7
|
-
parseMeta(refined
|
|
6
|
+
parseMeta(refined // wtf -- GCalMeta & { url: string }
|
|
7
|
+
) {
|
|
8
8
|
let { googleCalendarId } = refined;
|
|
9
9
|
if (!googleCalendarId && refined.url) {
|
|
10
10
|
googleCalendarId = parseGoogleCalendarId(refined.url);
|
|
@@ -19,7 +19,8 @@ const eventSourceDef = {
|
|
|
19
19
|
}
|
|
20
20
|
return null;
|
|
21
21
|
},
|
|
22
|
-
fetch(arg, successCallback,
|
|
22
|
+
fetch(arg, successCallback, // TODO
|
|
23
|
+
errorCallback) {
|
|
23
24
|
let { dateEnv, options } = arg.context;
|
|
24
25
|
let meta = arg.eventSource.meta;
|
|
25
26
|
let apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
|
|
@@ -68,21 +69,16 @@ function buildUrl(meta) {
|
|
|
68
69
|
}
|
|
69
70
|
function buildRequestParams(range, apiKey, extraParams, dateEnv) {
|
|
70
71
|
let params;
|
|
71
|
-
let startStr;
|
|
72
|
-
let endStr;
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
// (start/end will be UTC-coerced dates, so toISOString is okay)
|
|
82
|
-
startStr = addDays(range.start, -1).toISOString();
|
|
83
|
-
endStr = addDays(range.end, 1).toISOString();
|
|
84
|
-
}
|
|
85
|
-
params = Object.assign(Object.assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
|
|
72
|
+
let startStr = dateEnv.formatIso(range.start);
|
|
73
|
+
let endStr = dateEnv.formatIso(range.end);
|
|
74
|
+
params = {
|
|
75
|
+
...(extraParams || {}),
|
|
76
|
+
key: apiKey,
|
|
77
|
+
timeMin: startStr,
|
|
78
|
+
timeMax: endStr,
|
|
79
|
+
singleEvents: true,
|
|
80
|
+
maxResults: 9999,
|
|
81
|
+
};
|
|
86
82
|
if (dateEnv.timeZone !== 'local') {
|
|
87
83
|
params.timeZone = dateEnv.timeZone;
|
|
88
84
|
}
|
|
@@ -100,8 +96,8 @@ function gcalItemToRawEventDef(item, gcalTimezone) {
|
|
|
100
96
|
return {
|
|
101
97
|
id: item.id,
|
|
102
98
|
title: item.summary,
|
|
103
|
-
start: item.start.dateTime || item.start.date,
|
|
104
|
-
end: item.end.dateTime || item.end.date,
|
|
99
|
+
start: item.start.dateTime || item.start.date, // try timed. will fall back to all-day
|
|
100
|
+
end: item.end.dateTime || item.end.date, // same
|
|
105
101
|
url,
|
|
106
102
|
location: item.location,
|
|
107
103
|
description: item.description,
|
|
@@ -119,19 +115,18 @@ function injectQsComponent(url, component) {
|
|
|
119
115
|
const OPTION_REFINERS = {
|
|
120
116
|
googleCalendarApiKey: String,
|
|
121
117
|
};
|
|
122
|
-
|
|
123
118
|
const EVENT_SOURCE_REFINERS = {
|
|
124
|
-
googleCalendarApiKey: String,
|
|
119
|
+
googleCalendarApiKey: String, // TODO: rename with no prefix?
|
|
125
120
|
googleCalendarId: String,
|
|
126
121
|
googleCalendarApiBase: String,
|
|
127
122
|
extraParams: identity,
|
|
128
123
|
};
|
|
129
124
|
|
|
130
|
-
var index =
|
|
131
|
-
name: '
|
|
125
|
+
var index = {
|
|
126
|
+
name: 'google-calendar',
|
|
132
127
|
eventSourceDefs: [eventSourceDef],
|
|
133
128
|
optionRefiners: OPTION_REFINERS,
|
|
134
129
|
eventSourceRefiners: EVENT_SOURCE_REFINERS,
|
|
135
|
-
}
|
|
130
|
+
};
|
|
136
131
|
|
|
137
132
|
export { index as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fullcalendar/google-calendar",
|
|
3
|
-
"version": "7.0.0-rc.
|
|
3
|
+
"version": "7.0.0-rc.1",
|
|
4
4
|
"title": "FullCalendar Google Calendar Plugin",
|
|
5
5
|
"description": "Display events from a public Google Calendar feed",
|
|
6
6
|
"homepage": "https://fullcalendar.io/docs/google-calendar",
|
|
@@ -11,8 +11,12 @@
|
|
|
11
11
|
"fullcalendar",
|
|
12
12
|
"google-calendar"
|
|
13
13
|
],
|
|
14
|
+
"dependencies": {
|
|
15
|
+
"@full-ui/headless-calendar": "7.0.0-rc.1",
|
|
16
|
+
"@fullcalendar/core": "7.0.0-rc.1"
|
|
17
|
+
},
|
|
14
18
|
"peerDependencies": {
|
|
15
|
-
"
|
|
19
|
+
"temporal-polyfill": "^0.3.2"
|
|
16
20
|
},
|
|
17
21
|
"type": "module",
|
|
18
22
|
"bugs": "https://fullcalendar.io/reporting-bugs",
|
|
@@ -27,21 +31,17 @@
|
|
|
27
31
|
"email": "arshaw@arshaw.com",
|
|
28
32
|
"url": "http://arshaw.com/"
|
|
29
33
|
},
|
|
30
|
-
"copyright": "
|
|
34
|
+
"copyright": "2025 Adam Shaw",
|
|
31
35
|
"types": "./index.d.ts",
|
|
32
|
-
"main": "./index.
|
|
33
|
-
"module": "./index.js",
|
|
34
|
-
"unpkg": "./index.global.min.js",
|
|
35
|
-
"jsdelivr": "./index.global.min.js",
|
|
36
|
+
"main": "./index.js",
|
|
36
37
|
"exports": {
|
|
37
38
|
"./package.json": "./package.json",
|
|
38
|
-
"./index.cjs": "./index.cjs",
|
|
39
|
-
"./index.js": "./index.js",
|
|
40
39
|
".": {
|
|
41
40
|
"types": "./index.d.ts",
|
|
42
|
-
"
|
|
43
|
-
"import": "./index.js"
|
|
41
|
+
"default": "./index.js"
|
|
44
42
|
}
|
|
45
43
|
},
|
|
46
|
-
"sideEffects":
|
|
44
|
+
"sideEffects": [
|
|
45
|
+
"./global.js"
|
|
46
|
+
]
|
|
47
47
|
}
|
package/index.cjs
DELETED
|
@@ -1,141 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var index_cjs = require('@fullcalendar/core/index.cjs');
|
|
6
|
-
var internal_cjs = require('@fullcalendar/core/internal.cjs');
|
|
7
|
-
|
|
8
|
-
// TODO: expose somehow
|
|
9
|
-
const API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
|
|
10
|
-
const eventSourceDef = {
|
|
11
|
-
parseMeta(refined) {
|
|
12
|
-
let { googleCalendarId } = refined;
|
|
13
|
-
if (!googleCalendarId && refined.url) {
|
|
14
|
-
googleCalendarId = parseGoogleCalendarId(refined.url);
|
|
15
|
-
}
|
|
16
|
-
if (googleCalendarId) {
|
|
17
|
-
return {
|
|
18
|
-
googleCalendarId,
|
|
19
|
-
googleCalendarApiKey: refined.googleCalendarApiKey,
|
|
20
|
-
googleCalendarApiBase: refined.googleCalendarApiBase,
|
|
21
|
-
extraParams: refined.extraParams,
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
return null;
|
|
25
|
-
},
|
|
26
|
-
fetch(arg, successCallback, errorCallback) {
|
|
27
|
-
let { dateEnv, options } = arg.context;
|
|
28
|
-
let meta = arg.eventSource.meta;
|
|
29
|
-
let apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
|
|
30
|
-
if (!apiKey) {
|
|
31
|
-
errorCallback(new Error('Specify a googleCalendarApiKey. See https://fullcalendar.io/docs/google-calendar'));
|
|
32
|
-
}
|
|
33
|
-
else {
|
|
34
|
-
let url = buildUrl(meta);
|
|
35
|
-
// TODO: make DRY with json-feed-event-source
|
|
36
|
-
let { extraParams } = meta;
|
|
37
|
-
let extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
|
|
38
|
-
let requestParams = buildRequestParams(arg.range, apiKey, extraParamsObj, dateEnv);
|
|
39
|
-
return internal_cjs.requestJson('GET', url, requestParams).then(([body, response]) => {
|
|
40
|
-
if (body.error) {
|
|
41
|
-
errorCallback(new index_cjs.JsonRequestError('Google Calendar API: ' + body.error.message, response));
|
|
42
|
-
}
|
|
43
|
-
else {
|
|
44
|
-
successCallback({
|
|
45
|
-
rawEvents: gcalItemsToRawEventDefs(body.items, requestParams.timeZone),
|
|
46
|
-
response,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
}, errorCallback);
|
|
50
|
-
}
|
|
51
|
-
},
|
|
52
|
-
};
|
|
53
|
-
function parseGoogleCalendarId(url) {
|
|
54
|
-
let match;
|
|
55
|
-
// detect if the ID was specified as a single string.
|
|
56
|
-
// will match calendars like "asdf1234@calendar.google.com" in addition to person email calendars.
|
|
57
|
-
if (/^[^/]+@([^/.]+\.)*(google|googlemail|gmail)\.com$/.test(url)) {
|
|
58
|
-
return url;
|
|
59
|
-
}
|
|
60
|
-
if ((match = /^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^/]*)/.exec(url)) ||
|
|
61
|
-
(match = /^https?:\/\/www.google.com\/calendar\/feeds\/([^/]*)/.exec(url))) {
|
|
62
|
-
return decodeURIComponent(match[1]);
|
|
63
|
-
}
|
|
64
|
-
return null;
|
|
65
|
-
}
|
|
66
|
-
function buildUrl(meta) {
|
|
67
|
-
let apiBase = meta.googleCalendarApiBase;
|
|
68
|
-
if (!apiBase) {
|
|
69
|
-
apiBase = API_BASE;
|
|
70
|
-
}
|
|
71
|
-
return apiBase + '/' + encodeURIComponent(meta.googleCalendarId) + '/events';
|
|
72
|
-
}
|
|
73
|
-
function buildRequestParams(range, apiKey, extraParams, dateEnv) {
|
|
74
|
-
let params;
|
|
75
|
-
let startStr;
|
|
76
|
-
let endStr;
|
|
77
|
-
if (dateEnv.canComputeOffset) {
|
|
78
|
-
// strings will naturally have offsets, which GCal needs
|
|
79
|
-
startStr = dateEnv.formatIso(range.start);
|
|
80
|
-
endStr = dateEnv.formatIso(range.end);
|
|
81
|
-
}
|
|
82
|
-
else {
|
|
83
|
-
// when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
|
|
84
|
-
// from the UTC day-start to guarantee we're getting all the events
|
|
85
|
-
// (start/end will be UTC-coerced dates, so toISOString is okay)
|
|
86
|
-
startStr = internal_cjs.addDays(range.start, -1).toISOString();
|
|
87
|
-
endStr = internal_cjs.addDays(range.end, 1).toISOString();
|
|
88
|
-
}
|
|
89
|
-
params = Object.assign(Object.assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
|
|
90
|
-
if (dateEnv.timeZone !== 'local') {
|
|
91
|
-
params.timeZone = dateEnv.timeZone;
|
|
92
|
-
}
|
|
93
|
-
return params;
|
|
94
|
-
}
|
|
95
|
-
function gcalItemsToRawEventDefs(items, gcalTimezone) {
|
|
96
|
-
return items.map((item) => gcalItemToRawEventDef(item, gcalTimezone));
|
|
97
|
-
}
|
|
98
|
-
function gcalItemToRawEventDef(item, gcalTimezone) {
|
|
99
|
-
let url = item.htmlLink || null;
|
|
100
|
-
// make the URLs for each event show times in the correct timezone
|
|
101
|
-
if (url && gcalTimezone) {
|
|
102
|
-
url = injectQsComponent(url, 'ctz=' + gcalTimezone);
|
|
103
|
-
}
|
|
104
|
-
return {
|
|
105
|
-
id: item.id,
|
|
106
|
-
title: item.summary,
|
|
107
|
-
start: item.start.dateTime || item.start.date,
|
|
108
|
-
end: item.end.dateTime || item.end.date,
|
|
109
|
-
url,
|
|
110
|
-
location: item.location,
|
|
111
|
-
description: item.description,
|
|
112
|
-
attachments: item.attachments || [],
|
|
113
|
-
extendedProps: (item.extendedProperties || {}).shared || {},
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
// Injects a string like "arg=value" into the querystring of a URL
|
|
117
|
-
// TODO: move to a general util file?
|
|
118
|
-
function injectQsComponent(url, component) {
|
|
119
|
-
// inject it after the querystring but before the fragment
|
|
120
|
-
return url.replace(/(\?.*?)?(#|$)/, (whole, qs, hash) => (qs ? qs + '&' : '?') + component + hash);
|
|
121
|
-
}
|
|
122
|
-
|
|
123
|
-
const OPTION_REFINERS = {
|
|
124
|
-
googleCalendarApiKey: String,
|
|
125
|
-
};
|
|
126
|
-
|
|
127
|
-
const EVENT_SOURCE_REFINERS = {
|
|
128
|
-
googleCalendarApiKey: String,
|
|
129
|
-
googleCalendarId: String,
|
|
130
|
-
googleCalendarApiBase: String,
|
|
131
|
-
extraParams: internal_cjs.identity,
|
|
132
|
-
};
|
|
133
|
-
|
|
134
|
-
var index = index_cjs.createPlugin({
|
|
135
|
-
name: '@fullcalendar/google-calendar',
|
|
136
|
-
eventSourceDefs: [eventSourceDef],
|
|
137
|
-
optionRefiners: OPTION_REFINERS,
|
|
138
|
-
eventSourceRefiners: EVENT_SOURCE_REFINERS,
|
|
139
|
-
});
|
|
140
|
-
|
|
141
|
-
exports["default"] = index;
|
package/index.global.min.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
FullCalendar Google Calendar Plugin v7.0.0-rc.0
|
|
3
|
-
Docs & License: https://fullcalendar.io/docs/google-calendar
|
|
4
|
-
(c) 2024 Adam Shaw
|
|
5
|
-
*/
|
|
6
|
-
FullCalendar.GoogleCalendar=function(e,a,t){"use strict";const n={parseMeta(e){let{googleCalendarId:a}=e;return!a&&e.url&&(a=function(e){let a;if(/^[^/]+@([^/.]+\.)*(google|googlemail|gmail)\.com$/.test(e))return e;if((a=/^https:\/\/www.googleapis.com\/calendar\/v3\/calendars\/([^/]*)/.exec(e))||(a=/^https?:\/\/www.google.com\/calendar\/feeds\/([^/]*)/.exec(e)))return decodeURIComponent(a[1]);return null}(e.url)),a?{googleCalendarId:a,googleCalendarApiKey:e.googleCalendarApiKey,googleCalendarApiBase:e.googleCalendarApiBase,extraParams:e.extraParams}:null},fetch(e,n,r){let{dateEnv:o,options:l}=e.context,s=e.eventSource.meta,i=s.googleCalendarApiKey||l.googleCalendarApiKey;if(i){let l=function(e){let a=e.googleCalendarApiBase;a||(a="https://www.googleapis.com/calendar/v3/calendars");return a+"/"+encodeURIComponent(e.googleCalendarId)+"/events"}(s),{extraParams:d}=s,g="function"==typeof d?d():d,c=function(e,a,n,r){let o,l,s;r.canComputeOffset?(l=r.formatIso(e.start),s=r.formatIso(e.end)):(l=t.addDays(e.start,-1).toISOString(),s=t.addDays(e.end,1).toISOString());o=Object.assign(Object.assign({},n||{}),{key:a,timeMin:l,timeMax:s,singleEvents:!0,maxResults:9999}),"local"!==r.timeZone&&(o.timeZone=r.timeZone);return o}(e.range,i,g,o);return t.requestJson("GET",l,c).then(([e,t])=>{var o,l;e.error?r(new a.JsonRequestError("Google Calendar API: "+e.error.message,t)):n({rawEvents:(o=e.items,l=c.timeZone,o.map(e=>function(e,a){let t=e.htmlLink||null;t&&a&&(t=function(e,a){return e.replace(/(\?.*?)?(#|$)/,(e,t,n)=>(t?t+"&":"?")+a+n)}(t,"ctz="+a));return{id:e.id,title:e.summary,start:e.start.dateTime||e.start.date,end:e.end.dateTime||e.end.date,url:t,location:e.location,description:e.description,attachments:e.attachments||[],extendedProps:(e.extendedProperties||{}).shared||{}}}(e,l))),response:t})},r)}r(new Error("Specify a googleCalendarApiKey. See https://fullcalendar.io/docs/google-calendar"))}};const r={googleCalendarApiKey:String},o={googleCalendarApiKey:String,googleCalendarId:String,googleCalendarApiBase:String,extraParams:t.identity};var l=a.createPlugin({name:"@fullcalendar/google-calendar",eventSourceDefs:[n],optionRefiners:r,eventSourceRefiners:o});return a.globalPlugins.push(l),e.default=l,Object.defineProperty(e,"__esModule",{value:!0}),e}({},FullCalendar,FullCalendar.Internal);
|