@fullcalendar/google-calendar 6.0.0-beta.1 → 6.0.0-beta.2

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.
File without changes
@@ -1,29 +1,13 @@
1
- /*!
2
- FullCalendar v6.0.0-beta.1
3
- Docs & License: https://fullcalendar.io/
4
- (c) 2022 Adam Shaw
5
- */
6
1
  'use strict';
7
2
 
8
3
  Object.defineProperty(exports, '__esModule', { value: true });
9
4
 
10
- var common = require('@fullcalendar/common');
11
-
12
- // rename this file to options.ts like other packages?
13
- const OPTION_REFINERS = {
14
- googleCalendarApiKey: String,
15
- };
16
-
17
- const EVENT_SOURCE_REFINERS = {
18
- googleCalendarApiKey: String,
19
- googleCalendarId: String,
20
- googleCalendarApiBase: String,
21
- extraParams: common.identity,
22
- };
5
+ var index_cjs = require('@fullcalendar/core/index.cjs');
6
+ var internal_cjs = require('@fullcalendar/core/internal.cjs');
23
7
 
24
8
  // TODO: expose somehow
25
9
  const API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
26
- let eventSourceDef = {
10
+ const eventSourceDef = {
27
11
  parseMeta(refined) {
28
12
  let { googleCalendarId } = refined;
29
13
  if (!googleCalendarId && refined.url) {
@@ -39,14 +23,12 @@ let eventSourceDef = {
39
23
  }
40
24
  return null;
41
25
  },
42
- fetch(arg, onSuccess, onFailure) {
26
+ fetch(arg, successCallback, errorCallback) {
43
27
  let { dateEnv, options } = arg.context;
44
28
  let meta = arg.eventSource.meta;
45
29
  let apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
46
30
  if (!apiKey) {
47
- onFailure({
48
- message: 'Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/',
49
- });
31
+ errorCallback(new Error('Specify a googleCalendarApiKey. See https://fullcalendar.io/docs/google-calendar'));
50
32
  }
51
33
  else {
52
34
  let url = buildUrl(meta);
@@ -54,23 +36,17 @@ let eventSourceDef = {
54
36
  let { extraParams } = meta;
55
37
  let extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
56
38
  let requestParams = buildRequestParams(arg.range, apiKey, extraParamsObj, dateEnv);
57
- common.requestJson('GET', url, requestParams, (body, xhr) => {
39
+ return internal_cjs.requestJson('GET', url, requestParams).then(([body, response]) => {
58
40
  if (body.error) {
59
- onFailure({
60
- message: 'Google Calendar API: ' + body.error.message,
61
- errors: body.error.errors,
62
- xhr,
63
- });
41
+ errorCallback(new index_cjs.JsonRequestError('Google Calendar API: ' + body.error.message, response));
64
42
  }
65
43
  else {
66
- onSuccess({
44
+ successCallback({
67
45
  rawEvents: gcalItemsToRawEventDefs(body.items, requestParams.timeZone),
68
- xhr,
46
+ response,
69
47
  });
70
48
  }
71
- }, (message, xhr) => {
72
- onFailure({ message, xhr });
73
- });
49
+ }, errorCallback);
74
50
  }
75
51
  },
76
52
  };
@@ -107,8 +83,8 @@ function buildRequestParams(range, apiKey, extraParams, dateEnv) {
107
83
  // when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
108
84
  // from the UTC day-start to guarantee we're getting all the events
109
85
  // (start/end will be UTC-coerced dates, so toISOString is okay)
110
- startStr = common.addDays(range.start, -1).toISOString();
111
- endStr = common.addDays(range.end, 1).toISOString();
86
+ startStr = internal_cjs.addDays(range.start, -1).toISOString();
87
+ endStr = internal_cjs.addDays(range.end, 1).toISOString();
112
88
  }
113
89
  params = Object.assign(Object.assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
114
90
  if (dateEnv.timeZone !== 'local') {
@@ -143,10 +119,23 @@ function injectQsComponent(url, component) {
143
119
  // inject it after the querystring but before the fragment
144
120
  return url.replace(/(\?.*?)?(#|$)/, (whole, qs, hash) => (qs ? qs + '&' : '?') + component + hash);
145
121
  }
146
- var main = common.createPlugin({
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',
147
136
  eventSourceDefs: [eventSourceDef],
148
137
  optionRefiners: OPTION_REFINERS,
149
138
  eventSourceRefiners: EVENT_SOURCE_REFINERS,
150
139
  });
151
140
 
152
- exports.default = main;
141
+ exports["default"] = index;
@@ -1,17 +1,10 @@
1
- import * as _fullcalendar_common from '@fullcalendar/common';
2
- import { Identity, Dictionary } from '@fullcalendar/common';
1
+ import { PluginDef } from '@fullcalendar/core';
2
+ import { Identity, Dictionary } from '@fullcalendar/core/internal';
3
3
 
4
4
  declare const OPTION_REFINERS: {
5
5
  googleCalendarApiKey: StringConstructor;
6
6
  };
7
7
 
8
- declare type ExtraOptionRefiners = typeof OPTION_REFINERS;
9
- declare module '@fullcalendar/common' {
10
- interface BaseOptionRefiners extends ExtraOptionRefiners {
11
- }
12
- }
13
-
14
-
15
8
  declare const EVENT_SOURCE_REFINERS: {
16
9
  googleCalendarApiKey: StringConstructor;
17
10
  googleCalendarId: StringConstructor;
@@ -19,14 +12,19 @@ declare const EVENT_SOURCE_REFINERS: {
19
12
  extraParams: Identity<Dictionary | (() => Dictionary)>;
20
13
  };
21
14
 
22
- declare type ExtraEventSourceRefiners = typeof EVENT_SOURCE_REFINERS;
23
- declare module '@fullcalendar/common' {
15
+ type ExtraOptionRefiners = typeof OPTION_REFINERS;
16
+ type ExtraEventSourceRefiners = typeof EVENT_SOURCE_REFINERS;
17
+ declare module '@fullcalendar/core/internal' {
18
+ interface BaseOptionRefiners extends ExtraOptionRefiners {
19
+ }
20
+ }
21
+ declare module '@fullcalendar/core/internal' {
24
22
  interface EventSourceRefiners extends ExtraEventSourceRefiners {
25
23
  }
26
24
  }
25
+ //# sourceMappingURL=augment.d.ts.map
27
26
 
27
+ declare const _default: PluginDef;
28
+ //# sourceMappingURL=index.d.ts.map
28
29
 
29
- declare const _default: _fullcalendar_common.PluginDef;
30
-
31
-
32
- export default _default;
30
+ export { _default as default };
@@ -1,26 +1,14 @@
1
1
  /*!
2
- FullCalendar v6.0.0-beta.1
2
+ FullCalendar Google Calendar Plugin v6.0.0-beta.2
3
3
  Docs & License: https://fullcalendar.io/
4
4
  (c) 2022 Adam Shaw
5
5
  */
6
- var FullCalendarGoogleCalendar = (function (exports, common) {
6
+ FullCalendar.GoogleCalendar = (function (exports, internal, core) {
7
7
  'use strict';
8
8
 
9
- // rename this file to options.ts like other packages?
10
- const OPTION_REFINERS = {
11
- googleCalendarApiKey: String,
12
- };
13
-
14
- const EVENT_SOURCE_REFINERS = {
15
- googleCalendarApiKey: String,
16
- googleCalendarId: String,
17
- googleCalendarApiBase: String,
18
- extraParams: common.identity,
19
- };
20
-
21
9
  // TODO: expose somehow
22
10
  const API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
23
- let eventSourceDef = {
11
+ const eventSourceDef = {
24
12
  parseMeta(refined) {
25
13
  let { googleCalendarId } = refined;
26
14
  if (!googleCalendarId && refined.url) {
@@ -36,14 +24,12 @@ var FullCalendarGoogleCalendar = (function (exports, common) {
36
24
  }
37
25
  return null;
38
26
  },
39
- fetch(arg, onSuccess, onFailure) {
27
+ fetch(arg, successCallback, errorCallback) {
40
28
  let { dateEnv, options } = arg.context;
41
29
  let meta = arg.eventSource.meta;
42
30
  let apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
43
31
  if (!apiKey) {
44
- onFailure({
45
- message: 'Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/',
46
- });
32
+ errorCallback(new Error('Specify a googleCalendarApiKey. See https://fullcalendar.io/docs/google-calendar'));
47
33
  }
48
34
  else {
49
35
  let url = buildUrl(meta);
@@ -51,23 +37,17 @@ var FullCalendarGoogleCalendar = (function (exports, common) {
51
37
  let { extraParams } = meta;
52
38
  let extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
53
39
  let requestParams = buildRequestParams(arg.range, apiKey, extraParamsObj, dateEnv);
54
- common.requestJson('GET', url, requestParams, (body, xhr) => {
40
+ return internal.requestJson('GET', url, requestParams).then(([body, response]) => {
55
41
  if (body.error) {
56
- onFailure({
57
- message: 'Google Calendar API: ' + body.error.message,
58
- errors: body.error.errors,
59
- xhr,
60
- });
42
+ errorCallback(new core.JsonRequestError('Google Calendar API: ' + body.error.message, response));
61
43
  }
62
44
  else {
63
- onSuccess({
45
+ successCallback({
64
46
  rawEvents: gcalItemsToRawEventDefs(body.items, requestParams.timeZone),
65
- xhr,
47
+ response,
66
48
  });
67
49
  }
68
- }, (message, xhr) => {
69
- onFailure({ message, xhr });
70
- });
50
+ }, errorCallback);
71
51
  }
72
52
  },
73
53
  };
@@ -104,8 +84,8 @@ var FullCalendarGoogleCalendar = (function (exports, common) {
104
84
  // when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day
105
85
  // from the UTC day-start to guarantee we're getting all the events
106
86
  // (start/end will be UTC-coerced dates, so toISOString is okay)
107
- startStr = common.addDays(range.start, -1).toISOString();
108
- endStr = common.addDays(range.end, 1).toISOString();
87
+ startStr = internal.addDays(range.start, -1).toISOString();
88
+ endStr = internal.addDays(range.end, 1).toISOString();
109
89
  }
110
90
  params = Object.assign(Object.assign({}, (extraParams || {})), { key: apiKey, timeMin: startStr, timeMax: endStr, singleEvents: true, maxResults: 9999 });
111
91
  if (dateEnv.timeZone !== 'local') {
@@ -140,18 +120,31 @@ var FullCalendarGoogleCalendar = (function (exports, common) {
140
120
  // inject it after the querystring but before the fragment
141
121
  return url.replace(/(\?.*?)?(#|$)/, (whole, qs, hash) => (qs ? qs + '&' : '?') + component + hash);
142
122
  }
143
- var plugin = common.createPlugin({
123
+
124
+ const OPTION_REFINERS = {
125
+ googleCalendarApiKey: String,
126
+ };
127
+
128
+ const EVENT_SOURCE_REFINERS = {
129
+ googleCalendarApiKey: String,
130
+ googleCalendarId: String,
131
+ googleCalendarApiBase: String,
132
+ extraParams: internal.identity,
133
+ };
134
+
135
+ var plugin = core.createPlugin({
136
+ name: '@fullcalendar/google-calendar',
144
137
  eventSourceDefs: [eventSourceDef],
145
138
  optionRefiners: OPTION_REFINERS,
146
139
  eventSourceRefiners: EVENT_SOURCE_REFINERS,
147
140
  });
148
141
 
149
- common.globalPlugins.push(plugin);
142
+ internal.globalPlugins.push(plugin);
150
143
 
151
- exports.default = plugin;
144
+ exports["default"] = plugin;
152
145
 
153
146
  Object.defineProperty(exports, '__esModule', { value: true });
154
147
 
155
148
  return exports;
156
149
 
157
- }({}, FullCalendar));
150
+ })({}, FullCalendar.Internal, FullCalendar);
@@ -0,0 +1,6 @@
1
+ /*!
2
+ FullCalendar Google Calendar Plugin v6.0.0-beta.2
3
+ Docs & License: https://fullcalendar.io/
4
+ (c) 2022 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,t,n,r){let o,l,s;r.canComputeOffset?(l=r.formatIso(e.start),s=r.formatIso(e.end)):(l=a.addDays(e.start,-1).toISOString(),s=a.addDays(e.end,1).toISOString());o=Object.assign(Object.assign({},n||{}),{key:t,timeMin:l,timeMax:s,singleEvents:!0,maxResults:9999}),"local"!==r.timeZone&&(o.timeZone=r.timeZone);return o}(e.range,i,g,o);return a.requestJson("GET",l,c).then(([e,a])=>{var o,l;e.error?r(new t.JsonRequestError("Google Calendar API: "+e.error.message,a)):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:a})},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:a.identity};var l=t.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.Internal,FullCalendar);
@@ -1,25 +1,9 @@
1
- /*!
2
- FullCalendar v6.0.0-beta.1
3
- Docs & License: https://fullcalendar.io/
4
- (c) 2022 Adam Shaw
5
- */
6
- import { identity, createPlugin, requestJson, addDays } from '@fullcalendar/common';
7
-
8
- // rename this file to options.ts like other packages?
9
- const OPTION_REFINERS = {
10
- googleCalendarApiKey: String,
11
- };
12
-
13
- const EVENT_SOURCE_REFINERS = {
14
- googleCalendarApiKey: String,
15
- googleCalendarId: String,
16
- googleCalendarApiBase: String,
17
- extraParams: identity,
18
- };
1
+ import { JsonRequestError, createPlugin } from '@fullcalendar/core/index.js';
2
+ import { requestJson, addDays, identity } from '@fullcalendar/core/internal.js';
19
3
 
20
4
  // TODO: expose somehow
21
5
  const API_BASE = 'https://www.googleapis.com/calendar/v3/calendars';
22
- let eventSourceDef = {
6
+ const eventSourceDef = {
23
7
  parseMeta(refined) {
24
8
  let { googleCalendarId } = refined;
25
9
  if (!googleCalendarId && refined.url) {
@@ -35,14 +19,12 @@ let eventSourceDef = {
35
19
  }
36
20
  return null;
37
21
  },
38
- fetch(arg, onSuccess, onFailure) {
22
+ fetch(arg, successCallback, errorCallback) {
39
23
  let { dateEnv, options } = arg.context;
40
24
  let meta = arg.eventSource.meta;
41
25
  let apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey;
42
26
  if (!apiKey) {
43
- onFailure({
44
- message: 'Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/',
45
- });
27
+ errorCallback(new Error('Specify a googleCalendarApiKey. See https://fullcalendar.io/docs/google-calendar'));
46
28
  }
47
29
  else {
48
30
  let url = buildUrl(meta);
@@ -50,23 +32,17 @@ let eventSourceDef = {
50
32
  let { extraParams } = meta;
51
33
  let extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams;
52
34
  let requestParams = buildRequestParams(arg.range, apiKey, extraParamsObj, dateEnv);
53
- requestJson('GET', url, requestParams, (body, xhr) => {
35
+ return requestJson('GET', url, requestParams).then(([body, response]) => {
54
36
  if (body.error) {
55
- onFailure({
56
- message: 'Google Calendar API: ' + body.error.message,
57
- errors: body.error.errors,
58
- xhr,
59
- });
37
+ errorCallback(new JsonRequestError('Google Calendar API: ' + body.error.message, response));
60
38
  }
61
39
  else {
62
- onSuccess({
40
+ successCallback({
63
41
  rawEvents: gcalItemsToRawEventDefs(body.items, requestParams.timeZone),
64
- xhr,
42
+ response,
65
43
  });
66
44
  }
67
- }, (message, xhr) => {
68
- onFailure({ message, xhr });
69
- });
45
+ }, errorCallback);
70
46
  }
71
47
  },
72
48
  };
@@ -139,11 +115,23 @@ function injectQsComponent(url, component) {
139
115
  // inject it after the querystring but before the fragment
140
116
  return url.replace(/(\?.*?)?(#|$)/, (whole, qs, hash) => (qs ? qs + '&' : '?') + component + hash);
141
117
  }
142
- var main = createPlugin({
118
+
119
+ const OPTION_REFINERS = {
120
+ googleCalendarApiKey: String,
121
+ };
122
+
123
+ const EVENT_SOURCE_REFINERS = {
124
+ googleCalendarApiKey: String,
125
+ googleCalendarId: String,
126
+ googleCalendarApiBase: String,
127
+ extraParams: identity,
128
+ };
129
+
130
+ var index = createPlugin({
131
+ name: '@fullcalendar/google-calendar',
143
132
  eventSourceDefs: [eventSourceDef],
144
133
  optionRefiners: OPTION_REFINERS,
145
134
  eventSourceRefiners: EVENT_SOURCE_REFINERS,
146
135
  });
147
136
 
148
- export default main;
149
- //# sourceMappingURL=main.js.map
137
+ export { index as default };
package/package.json CHANGED
@@ -1,24 +1,19 @@
1
1
  {
2
2
  "name": "@fullcalendar/google-calendar",
3
- "version": "6.0.0-beta.1",
4
- "title": "FullCalendar Google Calendar Plugin",
5
- "description": "Fetch events from a public Google Calendar feed",
6
- "docs": "https://fullcalendar.io/docs/google-calendar",
7
- "dependencies": {
8
- "@fullcalendar/common": "6.0.0-beta.1",
9
- "tslib": "^2.1.0"
10
- },
11
- "main": "main.cjs.js",
12
- "module": "main.js",
13
- "types": "main.d.ts",
14
- "jsdelivr": "main.global.min.js",
15
- "browserGlobal": "FullCalendarGoogleCalendar",
3
+ "version": "6.0.0-beta.2",
4
+ "keywords": [
5
+ "calendar",
6
+ "event",
7
+ "full-sized"
8
+ ],
16
9
  "homepage": "https://fullcalendar.io/",
10
+ "docs": "https://fullcalendar.io/docs/google-calendar",
17
11
  "bugs": "https://fullcalendar.io/reporting-bugs",
18
12
  "repository": {
19
13
  "type": "git",
20
14
  "url": "https://github.com/fullcalendar/fullcalendar.git",
21
- "homepage": "https://github.com/fullcalendar/fullcalendar"
15
+ "homepage": "https://github.com/fullcalendar/fullcalendar",
16
+ "directory": "packages/google-calendar"
22
17
  },
23
18
  "license": "MIT",
24
19
  "author": {
@@ -26,7 +21,27 @@
26
21
  "email": "arshaw@arshaw.com",
27
22
  "url": "http://arshaw.com/"
28
23
  },
29
- "devDependencies": {
30
- "@fullcalendar/core-preact": "6.0.0-beta.1"
24
+ "copyright": "2022 Adam Shaw",
25
+ "type": "module",
26
+ "title": "FullCalendar Google Calendar Plugin",
27
+ "description": "Fetch events from a public Google Calendar feed",
28
+ "peerDependencies": {
29
+ "@fullcalendar/core": "6.0.0-beta.2"
30
+ },
31
+ "main": "./index.cjs",
32
+ "module": "./index.js",
33
+ "types": "./index.d.ts",
34
+ "unpkg": "./index.global.min.js",
35
+ "jsdelvr": "./index.global.min.js",
36
+ "exports": {
37
+ "./package.json": "./package.json",
38
+ "./index.cjs": "./index.cjs",
39
+ "./index.js": "./index.js",
40
+ ".": {
41
+ "require": "./index.cjs",
42
+ "import": "./index.js",
43
+ "types": "./index.d.ts",
44
+ "default": "./index.global.js"
45
+ }
31
46
  }
32
47
  }
@@ -1,6 +0,0 @@
1
- /*!
2
- FullCalendar v6.0.0-beta.1
3
- Docs & License: https://fullcalendar.io/
4
- (c) 2022 Adam Shaw
5
- */
6
- var FullCalendarGoogleCalendar=function(e,a){"use strict";const t={googleCalendarApiKey:String},r={googleCalendarApiKey:String,googleCalendarId:String,googleCalendarApiBase:String,extraParams:a.identity},n="https://www.googleapis.com/calendar/v3/calendars";let o={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,t,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=n);return a+"/"+encodeURIComponent(e.googleCalendarId)+"/events"}(s),{extraParams:d}=s,g="function"==typeof d?d():d,c=function(e,t,r,n){let o,l,s;n.canComputeOffset?(l=n.formatIso(e.start),s=n.formatIso(e.end)):(l=a.addDays(e.start,-1).toISOString(),s=a.addDays(e.end,1).toISOString());o=Object.assign(Object.assign({},r||{}),{key:t,timeMin:l,timeMax:s,singleEvents:!0,maxResults:9999}),"local"!==n.timeZone&&(o.timeZone=n.timeZone);return o}(e.range,i,g,o);a.requestJson("GET",l,c,((e,a)=>{var n,o;e.error?r({message:"Google Calendar API: "+e.error.message,errors:e.error.errors,xhr:a}):t({rawEvents:(n=e.items,o=c.timeZone,n.map((e=>function(e,a){let t=e.htmlLink||null;t&&a&&(t=function(e,a){return e.replace(/(\?.*?)?(#|$)/,((e,t,r)=>(t?t+"&":"?")+a+r))}(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,o)))),xhr:a})}),((e,a)=>{r({message:e,xhr:a})}))}else r({message:"Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/"})}};var l=a.createPlugin({eventSourceDefs:[o],optionRefiners:t,eventSourceRefiners:r});return a.globalPlugins.push(l),e.default=l,Object.defineProperty(e,"__esModule",{value:!0}),e}({},FullCalendar);
package/main.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"main.js","sources":["src/options-refiners.ts","src/event-source-refiners.ts","src/main.ts"],"sourcesContent":["// rename this file to options.ts like other packages?\n\nexport const OPTION_REFINERS = {\n googleCalendarApiKey: String,\n}\n","import { identity, Identity, Dictionary } from '@fullcalendar/common'\n\nexport const EVENT_SOURCE_REFINERS = {\n googleCalendarApiKey: String, // TODO: rename with no prefix?\n googleCalendarId: String,\n googleCalendarApiBase: String,\n extraParams: identity as Identity<Dictionary | (() => Dictionary)>,\n}\n","import { createPlugin, EventSourceDef, addDays, DateEnv, requestJson, Dictionary } from '@fullcalendar/common'\nimport { OPTION_REFINERS } from './options-refiners'\nimport './options-declare'\nimport { EVENT_SOURCE_REFINERS } from './event-source-refiners'\nimport './event-source-declare'\n\n// TODO: expose somehow\nconst API_BASE = 'https://www.googleapis.com/calendar/v3/calendars'\n\ninterface GCalMeta {\n googleCalendarId: string\n googleCalendarApiKey?: string\n googleCalendarApiBase?: string,\n extraParams?: Dictionary | (() => Dictionary)\n}\n\nlet eventSourceDef: EventSourceDef<GCalMeta> = {\n\n parseMeta(refined): GCalMeta | null {\n let { googleCalendarId } = refined\n\n if (!googleCalendarId && refined.url) {\n googleCalendarId = parseGoogleCalendarId(refined.url)\n }\n\n if (googleCalendarId) {\n return {\n googleCalendarId,\n googleCalendarApiKey: refined.googleCalendarApiKey,\n googleCalendarApiBase: refined.googleCalendarApiBase,\n extraParams: refined.extraParams,\n }\n }\n\n return null\n },\n\n fetch(arg, onSuccess, onFailure) {\n let { dateEnv, options } = arg.context\n let meta: GCalMeta = arg.eventSource.meta\n let apiKey = meta.googleCalendarApiKey || options.googleCalendarApiKey\n\n if (!apiKey) {\n onFailure({\n message: 'Specify a googleCalendarApiKey. See http://fullcalendar.io/docs/google_calendar/',\n })\n } else {\n let url = buildUrl(meta)\n\n // TODO: make DRY with json-feed-event-source\n let { extraParams } = meta\n let extraParamsObj = typeof extraParams === 'function' ? extraParams() : extraParams\n\n let requestParams = buildRequestParams(\n arg.range,\n apiKey,\n extraParamsObj,\n dateEnv,\n )\n\n requestJson('GET', url, requestParams, (body, xhr) => {\n if (body.error) {\n onFailure({\n message: 'Google Calendar API: ' + body.error.message,\n errors: body.error.errors,\n xhr,\n })\n } else {\n onSuccess({\n rawEvents: gcalItemsToRawEventDefs(\n body.items,\n requestParams.timeZone,\n ),\n xhr,\n })\n }\n }, (message, xhr) => {\n onFailure({ message, xhr })\n })\n }\n },\n}\n\nfunction parseGoogleCalendarId(url) {\n let match\n\n // detect if the ID was specified as a single string.\n // will match calendars like \"asdf1234@calendar.google.com\" in addition to person email calendars.\n if (/^[^/]+@([^/.]+\\.)*(google|googlemail|gmail)\\.com$/.test(url)) {\n return url\n }\n\n if (\n (match = /^https:\\/\\/www.googleapis.com\\/calendar\\/v3\\/calendars\\/([^/]*)/.exec(url)) ||\n (match = /^https?:\\/\\/www.google.com\\/calendar\\/feeds\\/([^/]*)/.exec(url))\n ) {\n return decodeURIComponent(match[1])\n }\n\n return null\n}\n\nfunction buildUrl(meta) {\n let apiBase = meta.googleCalendarApiBase\n if (!apiBase) {\n apiBase = API_BASE\n }\n return apiBase + '/' + encodeURIComponent(meta.googleCalendarId) + '/events'\n}\n\nfunction buildRequestParams(range, apiKey: string, extraParams: Dictionary, dateEnv: DateEnv) {\n let params\n let startStr\n let endStr\n\n if (dateEnv.canComputeOffset) {\n // strings will naturally have offsets, which GCal needs\n startStr = dateEnv.formatIso(range.start)\n endStr = dateEnv.formatIso(range.end)\n } else {\n // when timezone isn't known, we don't know what the UTC offset should be, so ask for +/- 1 day\n // from the UTC day-start to guarantee we're getting all the events\n // (start/end will be UTC-coerced dates, so toISOString is okay)\n startStr = addDays(range.start, -1).toISOString()\n endStr = addDays(range.end, 1).toISOString()\n }\n\n params = {\n ...(extraParams || {}),\n key: apiKey,\n timeMin: startStr,\n timeMax: endStr,\n singleEvents: true,\n maxResults: 9999,\n }\n\n if (dateEnv.timeZone !== 'local') {\n params.timeZone = dateEnv.timeZone\n }\n\n return params\n}\n\nfunction gcalItemsToRawEventDefs(items, gcalTimezone) {\n return items.map((item) => gcalItemToRawEventDef(item, gcalTimezone))\n}\n\nfunction gcalItemToRawEventDef(item, gcalTimezone) {\n let url = item.htmlLink || null\n\n // make the URLs for each event show times in the correct timezone\n if (url && gcalTimezone) {\n url = injectQsComponent(url, 'ctz=' + gcalTimezone)\n }\n\n return {\n id: item.id,\n title: item.summary,\n start: item.start.dateTime || item.start.date, // try timed. will fall back to all-day\n end: item.end.dateTime || item.end.date, // same\n url,\n location: item.location,\n description: item.description,\n attachments: item.attachments || [],\n extendedProps: (item.extendedProperties || {}).shared || {},\n }\n}\n\n// Injects a string like \"arg=value\" into the querystring of a URL\n// TODO: move to a general util file?\nfunction injectQsComponent(url, component) {\n // inject it after the querystring but before the fragment\n return url.replace(\n /(\\?.*?)?(#|$)/,\n (whole, qs, hash) => (qs ? qs + '&' : '?') + component + hash,\n )\n}\n\nexport default createPlugin({\n eventSourceDefs: [eventSourceDef],\n optionRefiners: OPTION_REFINERS,\n eventSourceRefiners: EVENT_SOURCE_REFINERS,\n})\n"],"names":[],"mappings":";;;;;;;AAAA;AAEO,MAAM,eAAe,GAAG;IAC7B,oBAAoB,EAAE,MAAM;CAC7B;;ACFM,MAAM,qBAAqB,GAAG;IACnC,oBAAoB,EAAE,MAAM;IAC5B,gBAAgB,EAAE,MAAM;IACxB,qBAAqB,EAAE,MAAM;IAC7B,WAAW,EAAE,QAAqD;CACnE;;ACDD;AACA,MAAM,QAAQ,GAAG,kDAAkD,CAAA;AASnE,IAAI,cAAc,GAA6B;IAE7C,SAAS,CAAC,OAAO;QACf,IAAI,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAA;QAElC,IAAI,CAAC,gBAAgB,IAAI,OAAO,CAAC,GAAG,EAAE;YACpC,gBAAgB,GAAG,qBAAqB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;SACtD;QAED,IAAI,gBAAgB,EAAE;YACpB,OAAO;gBACL,gBAAgB;gBAChB,oBAAoB,EAAE,OAAO,CAAC,oBAAoB;gBAClD,qBAAqB,EAAE,OAAO,CAAC,qBAAqB;gBACpD,WAAW,EAAE,OAAO,CAAC,WAAW;aACjC,CAAA;SACF;QAED,OAAO,IAAI,CAAA;KACZ;IAED,KAAK,CAAC,GAAG,EAAE,SAAS,EAAE,SAAS;QAC7B,IAAI,EAAE,OAAO,EAAE,OAAO,EAAE,GAAG,GAAG,CAAC,OAAO,CAAA;QACtC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