ical-generator 3.6.2-develop.4 → 4.0.0-develop.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/dist/calendar.js DELETED
@@ -1,417 +0,0 @@
1
- 'use strict';
2
- var __importDefault = (this && this.__importDefault) || function (mod) {
3
- return (mod && mod.__esModule) ? mod : { "default": mod };
4
- };
5
- Object.defineProperty(exports, "__esModule", { value: true });
6
- exports.ICalCalendarMethod = void 0;
7
- const tools_1 = require("./tools");
8
- const event_1 = __importDefault(require("./event"));
9
- const fs_1 = require("fs");
10
- var ICalCalendarMethod;
11
- (function (ICalCalendarMethod) {
12
- ICalCalendarMethod["PUBLISH"] = "PUBLISH";
13
- ICalCalendarMethod["REQUEST"] = "REQUEST";
14
- ICalCalendarMethod["REPLY"] = "REPLY";
15
- ICalCalendarMethod["ADD"] = "ADD";
16
- ICalCalendarMethod["CANCEL"] = "CANCEL";
17
- ICalCalendarMethod["REFRESH"] = "REFRESH";
18
- ICalCalendarMethod["COUNTER"] = "COUNTER";
19
- ICalCalendarMethod["DECLINECOUNTER"] = "DECLINECOUNTER";
20
- })(ICalCalendarMethod = exports.ICalCalendarMethod || (exports.ICalCalendarMethod = {}));
21
- /**
22
- * Usually you get an `ICalCalendar` object like this:
23
- * ```javascript
24
- * import ical from 'ical-generator';
25
- * const calendar = ical();
26
- * ```
27
- *
28
- * But you can also use the constructor directly like this:
29
- * ```javascript
30
- * import {ICalCalendar} from 'ical-generator';
31
- * const calendar = new ICalCalendar();
32
- * ```
33
- */
34
- class ICalCalendar {
35
- /**
36
- * You can pass options to setup your calendar or use setters to do this.
37
- *
38
- * ```javascript
39
- * * import ical from 'ical-generator';
40
- *
41
- * // or use require:
42
- * // const ical = require('ical-generator');
43
- *
44
- *
45
- * const cal = ical({name: 'my first iCal'});
46
- *
47
- * // is the same as
48
- *
49
- * const cal = ical().name('my first iCal');
50
- *
51
- * // is the same as
52
- *
53
- * const cal = ical();
54
- * cal.name('sebbo.net');
55
- * ```
56
- *
57
- * @param data Calendar data
58
- */
59
- constructor(data = {}) {
60
- this.data = {
61
- prodId: '//sebbo.net//ical-generator//EN',
62
- method: null,
63
- name: null,
64
- description: null,
65
- timezone: null,
66
- source: null,
67
- url: null,
68
- scale: null,
69
- ttl: null,
70
- events: [],
71
- x: []
72
- };
73
- data.prodId !== undefined && this.prodId(data.prodId);
74
- data.method !== undefined && this.method(data.method);
75
- data.name !== undefined && this.name(data.name);
76
- data.description !== undefined && this.description(data.description);
77
- data.timezone !== undefined && this.timezone(data.timezone);
78
- data.source !== undefined && this.source(data.source);
79
- data.url !== undefined && this.url(data.url);
80
- data.scale !== undefined && this.scale(data.scale);
81
- data.ttl !== undefined && this.ttl(data.ttl);
82
- data.events !== undefined && this.events(data.events);
83
- data.x !== undefined && this.x(data.x);
84
- }
85
- prodId(prodId) {
86
- if (!prodId) {
87
- return this.data.prodId;
88
- }
89
- const prodIdRegEx = /^\/\/(.+)\/\/(.+)\/\/([A-Z]{1,4})$/;
90
- if (typeof prodId === 'string' && prodIdRegEx.test(prodId)) {
91
- this.data.prodId = prodId;
92
- return this;
93
- }
94
- if (typeof prodId === 'string') {
95
- throw new Error('`prodId` isn\'t formated correctly. See https://sebbo2002.github.io/ical-generator/develop/reference/' +
96
- 'classes/ICalCalendar.html#prodId');
97
- }
98
- if (typeof prodId !== 'object') {
99
- throw new Error('`prodid` needs to be a valid formed string or an object!');
100
- }
101
- if (!prodId.company) {
102
- throw new Error('`prodid.company` is a mandatory item!');
103
- }
104
- if (!prodId.product) {
105
- throw new Error('`prodid.product` is a mandatory item!');
106
- }
107
- const language = (prodId.language || 'EN').toUpperCase();
108
- this.data.prodId = '//' + prodId.company + '//' + prodId.product + '//' + language;
109
- return this;
110
- }
111
- method(method) {
112
- if (method === undefined) {
113
- return this.data.method;
114
- }
115
- if (!method) {
116
- this.data.method = null;
117
- return this;
118
- }
119
- this.data.method = (0, tools_1.checkEnum)(ICalCalendarMethod, method);
120
- return this;
121
- }
122
- name(name) {
123
- if (name === undefined) {
124
- return this.data.name;
125
- }
126
- this.data.name = name ? String(name) : null;
127
- return this;
128
- }
129
- description(description) {
130
- if (description === undefined) {
131
- return this.data.description;
132
- }
133
- this.data.description = description ? String(description) : null;
134
- return this;
135
- }
136
- timezone(timezone) {
137
- var _a;
138
- if (timezone === undefined) {
139
- return ((_a = this.data.timezone) === null || _a === void 0 ? void 0 : _a.name) || null;
140
- }
141
- if (timezone === 'UTC') {
142
- this.data.timezone = null;
143
- }
144
- else if (typeof timezone === 'string') {
145
- this.data.timezone = { name: timezone };
146
- }
147
- else if (timezone === null) {
148
- this.data.timezone = null;
149
- }
150
- else {
151
- this.data.timezone = timezone;
152
- }
153
- return this;
154
- }
155
- source(source) {
156
- if (source === undefined) {
157
- return this.data.source;
158
- }
159
- this.data.source = source || null;
160
- return this;
161
- }
162
- url(url) {
163
- if (url === undefined) {
164
- return this.data.url;
165
- }
166
- this.data.url = url || null;
167
- return this;
168
- }
169
- scale(scale) {
170
- if (scale === undefined) {
171
- return this.data.scale;
172
- }
173
- if (scale === null) {
174
- this.data.scale = null;
175
- }
176
- else {
177
- this.data.scale = scale.toUpperCase();
178
- }
179
- return this;
180
- }
181
- ttl(ttl) {
182
- if (ttl === undefined) {
183
- return this.data.ttl;
184
- }
185
- if ((0, tools_1.isMomentDuration)(ttl)) {
186
- this.data.ttl = ttl.asSeconds();
187
- }
188
- else if (ttl && ttl > 0) {
189
- this.data.ttl = ttl;
190
- }
191
- else {
192
- this.data.ttl = null;
193
- }
194
- return this;
195
- }
196
- /**
197
- * Creates a new [[`ICalEvent`]] and returns it. Use options to prefill the event's attributes.
198
- * Calling this method without options will create an empty event.
199
- *
200
- * ```javascript
201
- * import ical from 'ical-generator';
202
- *
203
- * // or use require:
204
- * // const ical = require('ical-generator');
205
- *
206
- * const cal = ical();
207
- * const event = cal.createEvent({summary: 'My Event'});
208
- *
209
- * // overwrite event summary
210
- * event.summary('Your Event');
211
- * ```
212
- *
213
- * @since 0.2.0
214
- */
215
- createEvent(data) {
216
- const event = data instanceof event_1.default ? data : new event_1.default(data, this);
217
- this.data.events.push(event);
218
- return event;
219
- }
220
- events(events) {
221
- if (!events) {
222
- return this.data.events;
223
- }
224
- events.forEach((e) => this.createEvent(e));
225
- return this;
226
- }
227
- /**
228
- * Remove all events from the calendar without
229
- * touching any other data like name or prodId.
230
- *
231
- * @since 2.0.0-develop.1
232
- */
233
- clear() {
234
- this.data.events = [];
235
- return this;
236
- }
237
- save(path, cb) {
238
- if (cb) {
239
- (0, fs_1.writeFile)(path, this.toString(), cb);
240
- return this;
241
- }
242
- return fs_1.promises.writeFile(path, this.toString());
243
- }
244
- /**
245
- * Save Calendar to disk synchronously using
246
- * [fs.writeFileSync](http://nodejs.org/api/fs.html#fs_fs_writefilesync_filename_data_options).
247
- * Only works in node.js environments.
248
- *
249
- * ```javascript
250
- * calendar.saveSync('./calendar.ical');
251
- * ```
252
- */
253
- saveSync(path) {
254
- (0, fs_1.writeFileSync)(path, this.toString());
255
- return this;
256
- }
257
- /**
258
- * Send calendar to the user when using HTTP using the passed `ServerResponse` object.
259
- * Use second parameter `filename` to change the filename, which defaults to `'calendar.ics'`.
260
- *
261
- * @param response HTTP Response object which is used to send the calendar
262
- * @param [filename = 'calendar.ics'] Filename of the calendar file
263
- */
264
- serve(response, filename = 'calendar.ics') {
265
- response.writeHead(200, {
266
- 'Content-Type': 'text/calendar; charset=utf-8',
267
- 'Content-Disposition': `attachment; filename="${filename}"`
268
- });
269
- response.end(this.toString());
270
- return this;
271
- }
272
- /**
273
- * Generates a blob to use for downloads or to generate a download URL.
274
- * Only supported in browsers supporting the Blob API.
275
- *
276
- * Unfortunately, because node.js has no Blob implementation (they have Buffer
277
- * instead), this method is currently untested. Sorry Dave…
278
- *
279
- * @since 1.9.0
280
- */
281
- toBlob() {
282
- return new Blob([this.toString()], { type: 'text/calendar' });
283
- }
284
- /**
285
- * Returns a URL to download the ical file. Uses the Blob object internally,
286
- * so it's only supported in browsers supporting the Blob API.
287
- *
288
- * Unfortunately, because node.js has no Blob implementation (they have Buffer
289
- * instead), this can't be tested right now. Sorry Dave…
290
- *
291
- * @since 1.9.0
292
- */
293
- toURL() {
294
- return URL.createObjectURL(this.toBlob());
295
- }
296
- x(keyOrArray, value) {
297
- if (keyOrArray === undefined) {
298
- return (0, tools_1.addOrGetCustomAttributes)(this.data);
299
- }
300
- if (typeof keyOrArray === 'string' && typeof value === 'string') {
301
- (0, tools_1.addOrGetCustomAttributes)(this.data, keyOrArray, value);
302
- }
303
- else if (typeof keyOrArray === 'object') {
304
- (0, tools_1.addOrGetCustomAttributes)(this.data, keyOrArray);
305
- }
306
- else {
307
- throw new Error('Either key or value is not a string!');
308
- }
309
- return this;
310
- }
311
- /**
312
- * Return a shallow copy of the calendar's options for JSON stringification.
313
- * Third party objects like moment.js values or RRule objects are stringified
314
- * as well. Can be used for persistence.
315
- *
316
- * ```javascript
317
- * const cal = ical();
318
- * const json = JSON.stringify(cal);
319
- *
320
- * // later: restore calendar data
321
- * cal = ical(JSON.parse(json));
322
- * ```
323
- *
324
- * @since 0.2.4
325
- */
326
- toJSON() {
327
- return Object.assign({}, this.data, {
328
- timezone: this.timezone(),
329
- events: this.data.events.map(event => event.toJSON()),
330
- x: this.x()
331
- });
332
- }
333
- /**
334
- * Get the number of events added to your calendar
335
- */
336
- length() {
337
- return this.data.events.length;
338
- }
339
- /**
340
- * Return generated calendar as a string.
341
- *
342
- * ```javascript
343
- * const cal = ical();
344
- * console.log(cal.toString()); // → BEGIN:VCALENDAR…
345
- * ```
346
- */
347
- toString() {
348
- var _a, _b;
349
- let g = '';
350
- // VCALENDAR and VERSION
351
- g = 'BEGIN:VCALENDAR\r\nVERSION:2.0\r\n';
352
- // PRODID
353
- g += 'PRODID:-' + this.data.prodId + '\r\n';
354
- // URL
355
- if (this.data.url) {
356
- g += 'URL:' + this.data.url + '\r\n';
357
- }
358
- // SOURCE
359
- if (this.data.source) {
360
- g += 'SOURCE;VALUE=URI:' + this.data.source + '\r\n';
361
- }
362
- // CALSCALE
363
- if (this.data.scale) {
364
- g += 'CALSCALE:' + this.data.scale + '\r\n';
365
- }
366
- // METHOD
367
- if (this.data.method) {
368
- g += 'METHOD:' + this.data.method + '\r\n';
369
- }
370
- // NAME
371
- if (this.data.name) {
372
- g += 'NAME:' + this.data.name + '\r\n';
373
- g += 'X-WR-CALNAME:' + this.data.name + '\r\n';
374
- }
375
- // Description
376
- if (this.data.description) {
377
- g += 'X-WR-CALDESC:' + this.data.description + '\r\n';
378
- }
379
- // Timezone
380
- if ((_a = this.data.timezone) === null || _a === void 0 ? void 0 : _a.generator) {
381
- const timezones = [...new Set([
382
- this.timezone(),
383
- ...this.data.events.map(event => event.timezone())
384
- ])].filter(tz => tz !== null && !tz.startsWith('/'));
385
- timezones.forEach(tz => {
386
- var _a;
387
- if (!((_a = this.data.timezone) === null || _a === void 0 ? void 0 : _a.generator)) {
388
- return;
389
- }
390
- const s = this.data.timezone.generator(tz);
391
- if (!s) {
392
- return;
393
- }
394
- g += s.replace(/\r\n/g, '\n')
395
- .replace(/\n/g, '\r\n')
396
- .trim() + '\r\n';
397
- });
398
- }
399
- if ((_b = this.data.timezone) === null || _b === void 0 ? void 0 : _b.name) {
400
- g += 'TIMEZONE-ID:' + this.data.timezone.name + '\r\n';
401
- g += 'X-WR-TIMEZONE:' + this.data.timezone.name + '\r\n';
402
- }
403
- // TTL
404
- if (this.data.ttl) {
405
- g += 'REFRESH-INTERVAL;VALUE=DURATION:' + (0, tools_1.toDurationString)(this.data.ttl) + '\r\n';
406
- g += 'X-PUBLISHED-TTL:' + (0, tools_1.toDurationString)(this.data.ttl) + '\r\n';
407
- }
408
- // Events
409
- this.data.events.forEach(event => g += event.toString());
410
- // CUSTOM X ATTRIBUTES
411
- g += (0, tools_1.generateCustomAttributes)(this.data);
412
- g += 'END:VCALENDAR';
413
- return (0, tools_1.foldLines)(g);
414
- }
415
- }
416
- exports.default = ICalCalendar;
417
- //#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AAI,eAAe,CAAC;QAErB,OAAO,IAAA,iBAAS,EAAC,CAAC,CAAC,CAAC;IACxB,CAAC;CACJ;AAtwBD,+BAswBC"}
@@ -1,57 +0,0 @@
1
- export interface ICalCategoryData {
2
- name?: string | null;
3
- }
4
- export interface ICalCategoryInternalData {
5
- name: string | null;
6
- }
7
- /**
8
- * Usually you get an `ICalCategory` object like this:
9
- *
10
- * ```javascript
11
- * import ical from 'ical-generator';
12
- * const calendar = ical();
13
- * const event = calendar.createEvent();
14
- * const category = event.createCategory();
15
- * ```
16
- *
17
- * You can also use the [[`ICalCategory`]] object directly:
18
- *
19
- * ```javascript
20
- * import ical, {ICalCategory} from 'ical-generator';
21
- * const category = new ICalCategory();
22
- * event.categories([category]);
23
- * ```
24
- */
25
- export default class ICalCategory {
26
- private readonly data;
27
- /**
28
- * Constructor of [[`ICalCategory`]].
29
- * @param data Category Data
30
- */
31
- constructor(data: ICalCategoryData);
32
- /**
33
- * Get the category name
34
- * @since 0.3.0
35
- */
36
- name(): string | null;
37
- /**
38
- * Set the category name
39
- * @since 0.3.0
40
- */
41
- name(name: string | null): this;
42
- /**
43
- * Return a shallow copy of the category's options for JSON stringification.
44
- * Can be used for persistence.
45
- *
46
- * @since 0.2.4
47
- */
48
- toJSON(): ICalCategoryInternalData;
49
- /**
50
- * Return generated category name as a string.
51
- *
52
- * ```javascript
53
- * console.log(category.toString());
54
- * ```
55
- */
56
- toString(): string;
57
- }
package/dist/category.js DELETED
@@ -1,65 +0,0 @@
1
- 'use strict';
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tools_1 = require("./tools");
4
- /**
5
- * Usually you get an `ICalCategory` object like this:
6
- *
7
- * ```javascript
8
- * import ical from 'ical-generator';
9
- * const calendar = ical();
10
- * const event = calendar.createEvent();
11
- * const category = event.createCategory();
12
- * ```
13
- *
14
- * You can also use the [[`ICalCategory`]] object directly:
15
- *
16
- * ```javascript
17
- * import ical, {ICalCategory} from 'ical-generator';
18
- * const category = new ICalCategory();
19
- * event.categories([category]);
20
- * ```
21
- */
22
- class ICalCategory {
23
- /**
24
- * Constructor of [[`ICalCategory`]].
25
- * @param data Category Data
26
- */
27
- constructor(data) {
28
- this.data = {
29
- name: null
30
- };
31
- data.name !== undefined && this.name(data.name);
32
- }
33
- name(name) {
34
- if (name === undefined) {
35
- return this.data.name;
36
- }
37
- this.data.name = name || null;
38
- return this;
39
- }
40
- /**
41
- * Return a shallow copy of the category's options for JSON stringification.
42
- * Can be used for persistence.
43
- *
44
- * @since 0.2.4
45
- */
46
- toJSON() {
47
- return Object.assign({}, this.data);
48
- }
49
- /**
50
- * Return generated category name as a string.
51
- *
52
- * ```javascript
53
- * console.log(category.toString());
54
- * ```
55
- */
56
- toString() {
57
- // CN / Name
58
- if (!this.data.name) {
59
- throw new Error('No value for `name` in ICalCategory given!');
60
- }
61
- return (0, tools_1.escape)(this.data.name, false);
62
- }
63
- }
64
- exports.default = ICalCategory;
65
- //# sourceMappingURL=category.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"category.js","sourceRoot":"","sources":["../src/category.ts"],"names":[],"mappings":"AAAA,YAAY,CAAC;;AAGb,mCAA+B;AAY/B;;;;;;;;;;;;;;;;;GAiBG;AACH,MAAqB,YAAY;IAG7B;;;OAGG;IACH,YAAY,IAAsB;QAC9B,IAAI,CAAC,IAAI,GAAG;YACR,IAAI,EAAE,IAAI;SACb,CAAC;QAEF,IAAI,CAAC,IAAI,KAAK,SAAS,IAAI,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;IAcD,IAAI,CAAC,IAAoB;QACrB,IAAI,IAAI,KAAK,SAAS,EAAE;YACpB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC;SACzB;QAED,IAAI,CAAC,IAAI,CAAC,IAAI,GAAG,IAAI,IAAI,IAAI,CAAC;QAC9B,OAAO,IAAI,CAAC;IAChB,CAAC;IAGD;;;;;OAKG;IACH,MAAM;QACF,OAAO,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;IAGD;;;;;;OAMG;IACH,QAAQ;QAEJ,YAAY;QACZ,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,4CAA4C,CAAC,CAAC;SACjE;QAED,OAAO,IAAA,cAAM,EAAC,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACzC,CAAC;CACJ;AAhED,+BAgEC"}