@fullcalendar/google-calendar 7.0.0-beta.6 → 7.0.0-beta.8
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/README.md +8 -8
- package/global.js +57 -35
- package/index.d.ts +67 -0
- package/{esm/index.js → index.js} +13 -24
- package/package.json +11 -14
- package/cjs/index.cjs +0 -140
- package/esm/index.d.ts +0 -35
- package/global.min.js +0 -6
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,14 +16,14 @@ 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
|
-
import dayGridPlugin from '@fullcalendar/daygrid'
|
|
22
|
-
import classicThemePlugin from '@fullcalendar/theme-classic'
|
|
23
23
|
|
|
24
|
-
import '
|
|
25
|
-
import '
|
|
26
|
-
import '
|
|
24
|
+
import 'fullcalendar/skeleton.css'
|
|
25
|
+
import 'fullcalendar/themes/classic/theme.css'
|
|
26
|
+
import 'fullcalendar/themes/classic/palette.css'
|
|
27
27
|
|
|
28
28
|
const calendarEl = document.getElementById('calendar')
|
|
29
29
|
const calendar = new Calendar(calendarEl, {
|
package/global.js
CHANGED
|
@@ -1,15 +1,54 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
FullCalendar Google Calendar Plugin v7.0.0-beta.
|
|
2
|
+
FullCalendar Google Calendar Plugin v7.0.0-beta.8
|
|
3
3
|
Docs & License: https://fullcalendar.io/docs/google-calendar
|
|
4
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,20 +113,8 @@ 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
|
-
if (dateEnv.canComputeOffset) {
|
|
79
|
-
// strings will naturally have offsets, which GCal needs
|
|
80
|
-
startStr = dateEnv.formatIso(range.start);
|
|
81
|
-
endStr = dateEnv.formatIso(range.end);
|
|
82
|
-
}
|
|
83
|
-
else {
|
|
84
|
-
// when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
|
|
85
|
-
// from the UTC day-start to guarantee we're getting all the events
|
|
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
|
-
}
|
|
116
|
+
let startStr = dateEnv.formatIso(range.start);
|
|
117
|
+
let endStr = dateEnv.formatIso(range.end);
|
|
90
118
|
params = Object.assign(Object.assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
|
|
91
119
|
if (dateEnv.timeZone !== 'local') {
|
|
92
120
|
params.timeZone = dateEnv.timeZone;
|
|
@@ -105,8 +133,8 @@ FullCalendar.GoogleCalendar = (function (exports, core, internal) {
|
|
|
105
133
|
return {
|
|
106
134
|
id: item.id,
|
|
107
135
|
title: item.summary,
|
|
108
|
-
start: item.start.dateTime || item.start.date,
|
|
109
|
-
end: item.end.dateTime || item.end.date,
|
|
136
|
+
start: item.start.dateTime || item.start.date, // try timed. will fall back to all-day
|
|
137
|
+
end: item.end.dateTime || item.end.date, // same
|
|
110
138
|
url,
|
|
111
139
|
location: item.location,
|
|
112
140
|
description: item.description,
|
|
@@ -125,25 +153,19 @@ FullCalendar.GoogleCalendar = (function (exports, core, internal) {
|
|
|
125
153
|
googleCalendarApiKey: String,
|
|
126
154
|
};
|
|
127
155
|
const EVENT_SOURCE_REFINERS = {
|
|
128
|
-
googleCalendarApiKey: String,
|
|
156
|
+
googleCalendarApiKey: String, // TODO: rename with no prefix?
|
|
129
157
|
googleCalendarId: String,
|
|
130
158
|
googleCalendarApiBase: String,
|
|
131
|
-
extraParams:
|
|
159
|
+
extraParams: identity,
|
|
132
160
|
};
|
|
133
161
|
|
|
134
|
-
var plugin =
|
|
135
|
-
name: '
|
|
162
|
+
var plugin = {
|
|
163
|
+
name: 'google-calendar',
|
|
136
164
|
eventSourceDefs: [eventSourceDef],
|
|
137
165
|
optionRefiners: OPTION_REFINERS,
|
|
138
166
|
eventSourceRefiners: EVENT_SOURCE_REFINERS,
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
core.globalPlugins.push(plugin);
|
|
142
|
-
|
|
143
|
-
exports["default"] = plugin;
|
|
144
|
-
|
|
145
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
167
|
+
};
|
|
146
168
|
|
|
147
|
-
|
|
169
|
+
FullCalendar.globalPlugins.push(plugin);
|
|
148
170
|
|
|
149
|
-
})(
|
|
171
|
+
})();
|
package/index.d.ts
ADDED
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
}
|
|
11
|
+
|
|
12
|
+
declare const OPTION_REFINERS: {
|
|
13
|
+
googleCalendarApiKey: StringConstructor;
|
|
14
|
+
};
|
|
15
|
+
type GoogleCalendarOptionRefiners = typeof OPTION_REFINERS;
|
|
16
|
+
type GoogleCalendarOptions = RawOptionsFromRefiners<GoogleCalendarOptionRefiners>;
|
|
17
|
+
type GoogleCalendarOptionsRefined = RefinedOptionsFromRefiners<GoogleCalendarOptionRefiners>;
|
|
18
|
+
declare const EVENT_SOURCE_REFINERS: {
|
|
19
|
+
googleCalendarApiKey: StringConstructor;
|
|
20
|
+
googleCalendarId: StringConstructor;
|
|
21
|
+
googleCalendarApiBase: StringConstructor;
|
|
22
|
+
extraParams: Identity<Record<string, any> | (() => Record<string, any>)>;
|
|
23
|
+
};
|
|
24
|
+
type GoogleCalendarEventSourceRefiners = typeof EVENT_SOURCE_REFINERS;
|
|
25
|
+
type GoogleCalendarEventSourceOptions = RawOptionsFromRefiners<GoogleCalendarEventSourceRefiners>;
|
|
26
|
+
type GoogleCalendarEventSourceOptionsRefined = RefinedOptionsFromRefiners<GoogleCalendarEventSourceRefiners>;
|
|
27
|
+
|
|
28
|
+
declare module '@fullcalendar/core/protected-api' {
|
|
29
|
+
interface BaseOptions extends GoogleCalendarOptions {
|
|
30
|
+
}
|
|
31
|
+
interface BaseOptionsRefined extends GoogleCalendarOptionsRefined {
|
|
32
|
+
}
|
|
33
|
+
interface EventSourceOptions extends GoogleCalendarEventSourceOptions {
|
|
34
|
+
}
|
|
35
|
+
interface EventSourceOptionsRefined extends GoogleCalendarEventSourceOptionsRefined {
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
//# sourceMappingURL=ambient.d.ts.map
|
|
39
|
+
|
|
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
|
+
};
|
|
65
|
+
//# sourceMappingURL=index.d.ts.map
|
|
66
|
+
|
|
67
|
+
export { GoogleCalendarOptions, _default as default };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { JsonRequestError,
|
|
2
|
-
import { requestJson, addDays, identity } from '@fullcalendar/core/internal';
|
|
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,20 +69,8 @@ function buildUrl(meta) {
|
|
|
68
69
|
}
|
|
69
70
|
function buildRequestParams(range, apiKey, extraParams, dateEnv) {
|
|
70
71
|
let params;
|
|
71
|
-
let startStr;
|
|
72
|
-
let endStr;
|
|
73
|
-
if (dateEnv.canComputeOffset) {
|
|
74
|
-
// strings will naturally have offsets, which GCal needs
|
|
75
|
-
startStr = dateEnv.formatIso(range.start);
|
|
76
|
-
endStr = dateEnv.formatIso(range.end);
|
|
77
|
-
}
|
|
78
|
-
else {
|
|
79
|
-
// when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
|
|
80
|
-
// from the UTC day-start to guarantee we're getting all the events
|
|
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
|
-
}
|
|
72
|
+
let startStr = dateEnv.formatIso(range.start);
|
|
73
|
+
let endStr = dateEnv.formatIso(range.end);
|
|
85
74
|
params = Object.assign(Object.assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
|
|
86
75
|
if (dateEnv.timeZone !== 'local') {
|
|
87
76
|
params.timeZone = dateEnv.timeZone;
|
|
@@ -100,8 +89,8 @@ function gcalItemToRawEventDef(item, gcalTimezone) {
|
|
|
100
89
|
return {
|
|
101
90
|
id: item.id,
|
|
102
91
|
title: item.summary,
|
|
103
|
-
start: item.start.dateTime || item.start.date,
|
|
104
|
-
end: item.end.dateTime || item.end.date,
|
|
92
|
+
start: item.start.dateTime || item.start.date, // try timed. will fall back to all-day
|
|
93
|
+
end: item.end.dateTime || item.end.date, // same
|
|
105
94
|
url,
|
|
106
95
|
location: item.location,
|
|
107
96
|
description: item.description,
|
|
@@ -120,17 +109,17 @@ const OPTION_REFINERS = {
|
|
|
120
109
|
googleCalendarApiKey: String,
|
|
121
110
|
};
|
|
122
111
|
const EVENT_SOURCE_REFINERS = {
|
|
123
|
-
googleCalendarApiKey: String,
|
|
112
|
+
googleCalendarApiKey: String, // TODO: rename with no prefix?
|
|
124
113
|
googleCalendarId: String,
|
|
125
114
|
googleCalendarApiBase: String,
|
|
126
115
|
extraParams: identity,
|
|
127
116
|
};
|
|
128
117
|
|
|
129
|
-
var index =
|
|
130
|
-
name: '
|
|
118
|
+
var index = {
|
|
119
|
+
name: 'google-calendar',
|
|
131
120
|
eventSourceDefs: [eventSourceDef],
|
|
132
121
|
optionRefiners: OPTION_REFINERS,
|
|
133
122
|
eventSourceRefiners: EVENT_SOURCE_REFINERS,
|
|
134
|
-
}
|
|
123
|
+
};
|
|
135
124
|
|
|
136
125
|
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-beta.
|
|
3
|
+
"version": "7.0.0-beta.8",
|
|
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-beta.8",
|
|
16
|
+
"@fullcalendar/core": "7.0.0-beta.8"
|
|
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",
|
|
@@ -28,23 +32,16 @@
|
|
|
28
32
|
"url": "http://arshaw.com/"
|
|
29
33
|
},
|
|
30
34
|
"copyright": "2025 Adam Shaw",
|
|
31
|
-
"types": "./
|
|
32
|
-
"
|
|
33
|
-
"main": "./cjs/index.cjs",
|
|
34
|
-
"unpkg": "./global.min.js",
|
|
35
|
-
"jsdelivr": "./global.min.js",
|
|
35
|
+
"types": "./index.d.ts",
|
|
36
|
+
"main": "./index.js",
|
|
36
37
|
"exports": {
|
|
37
38
|
"./package.json": "./package.json",
|
|
38
39
|
".": {
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
"default": "./esm/index.js"
|
|
42
|
-
},
|
|
43
|
-
"require": "./cjs/index.cjs"
|
|
40
|
+
"types": "./index.d.ts",
|
|
41
|
+
"default": "./index.js"
|
|
44
42
|
}
|
|
45
43
|
},
|
|
46
44
|
"sideEffects": [
|
|
47
|
-
"./global.js"
|
|
48
|
-
"./global.min.js"
|
|
45
|
+
"./global.js"
|
|
49
46
|
]
|
|
50
47
|
}
|
package/cjs/index.cjs
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
-
|
|
5
|
-
var core = require('@fullcalendar/core');
|
|
6
|
-
var internal = require('@fullcalendar/core/internal');
|
|
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.requestJson('GET', url, requestParams).then(([body, response]) => {
|
|
40
|
-
if (body.error) {
|
|
41
|
-
errorCallback(new core.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.addDays(range.start, -1).toISOString();
|
|
87
|
-
endStr = internal.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
|
-
const EVENT_SOURCE_REFINERS = {
|
|
127
|
-
googleCalendarApiKey: String,
|
|
128
|
-
googleCalendarId: String,
|
|
129
|
-
googleCalendarApiBase: String,
|
|
130
|
-
extraParams: internal.identity,
|
|
131
|
-
};
|
|
132
|
-
|
|
133
|
-
var index = core.createPlugin({
|
|
134
|
-
name: '@fullcalendar/google-calendar',
|
|
135
|
-
eventSourceDefs: [eventSourceDef],
|
|
136
|
-
optionRefiners: OPTION_REFINERS,
|
|
137
|
-
eventSourceRefiners: EVENT_SOURCE_REFINERS,
|
|
138
|
-
});
|
|
139
|
-
|
|
140
|
-
exports["default"] = index;
|
package/esm/index.d.ts
DELETED
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { PluginDef } from '@fullcalendar/core';
|
|
2
|
-
import { RawOptionsFromRefiners, RefinedOptionsFromRefiners, Identity, Dictionary } from '@fullcalendar/core/internal';
|
|
3
|
-
|
|
4
|
-
declare const OPTION_REFINERS: {
|
|
5
|
-
googleCalendarApiKey: StringConstructor;
|
|
6
|
-
};
|
|
7
|
-
type GoogleCalendarOptionRefiners = typeof OPTION_REFINERS;
|
|
8
|
-
type GoogleCalendarOptions = RawOptionsFromRefiners<GoogleCalendarOptionRefiners>;
|
|
9
|
-
type GoogleCalendarOptionsRefined = RefinedOptionsFromRefiners<GoogleCalendarOptionRefiners>;
|
|
10
|
-
declare const EVENT_SOURCE_REFINERS: {
|
|
11
|
-
googleCalendarApiKey: StringConstructor;
|
|
12
|
-
googleCalendarId: StringConstructor;
|
|
13
|
-
googleCalendarApiBase: StringConstructor;
|
|
14
|
-
extraParams: Identity<Dictionary | (() => Dictionary)>;
|
|
15
|
-
};
|
|
16
|
-
type GoogleCalendarEventSourceRefiners = typeof EVENT_SOURCE_REFINERS;
|
|
17
|
-
type GoogleCalendarEventSourceOptions = RawOptionsFromRefiners<GoogleCalendarEventSourceRefiners>;
|
|
18
|
-
type GoogleCalendarEventSourceOptionsRefined = RefinedOptionsFromRefiners<GoogleCalendarEventSourceRefiners>;
|
|
19
|
-
|
|
20
|
-
declare module '@fullcalendar/core/internal' {
|
|
21
|
-
interface BaseOptions extends GoogleCalendarOptions {
|
|
22
|
-
}
|
|
23
|
-
interface BaseOptionsRefined extends GoogleCalendarOptionsRefined {
|
|
24
|
-
}
|
|
25
|
-
interface EventSourceOptions extends GoogleCalendarEventSourceOptions {
|
|
26
|
-
}
|
|
27
|
-
interface EventSourceOptionsRefined extends GoogleCalendarEventSourceOptionsRefined {
|
|
28
|
-
}
|
|
29
|
-
}
|
|
30
|
-
//# sourceMappingURL=ambient.d.ts.map
|
|
31
|
-
|
|
32
|
-
declare const _default: PluginDef;
|
|
33
|
-
//# sourceMappingURL=index.d.ts.map
|
|
34
|
-
|
|
35
|
-
export { GoogleCalendarOptions, _default as default };
|
package/global.min.js
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
/*!
|
|
2
|
-
FullCalendar Google Calendar Plugin v7.0.0-beta.6
|
|
3
|
-
Docs & License: https://fullcalendar.io/docs/google-calendar
|
|
4
|
-
(c) 2025 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);
|