@hebcal/icalendar 4.20.0 → 4.21.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/icalendar v4.20.0 */
1
+ /*! @hebcal/icalendar v4.21.0 */
2
2
  'use strict';
3
3
 
4
4
  var core = require('@hebcal/core');
@@ -6,7 +6,7 @@ var murmurhash3 = require('murmurhash3');
6
6
  var restApi = require('@hebcal/rest-api');
7
7
  var fs = require('fs');
8
8
 
9
- const version="4.20.0";
9
+ const version="4.21.0";
10
10
 
11
11
  const VTIMEZONE = {};
12
12
  const CATEGORY = {
@@ -71,6 +71,11 @@ class IcalEvent {
71
71
  this.ev = ev;
72
72
  this.options = options;
73
73
  this.dtstamp = options.dtstamp || IcalEvent.makeDtstamp(new Date());
74
+ if (typeof ev.sequence === 'number') {
75
+ this.sequence = ev.sequence;
76
+ } else if (typeof options.sequence === 'number') {
77
+ this.sequence = options.sequence;
78
+ }
74
79
  const timed = this.timed = Boolean(ev.eventTime);
75
80
  const locale = options.locale;
76
81
  let subj = restApi.shouldRenderBrief(ev) ? ev.renderBrief(locale) : ev.render(locale);
@@ -183,8 +188,11 @@ class IcalEvent {
183
188
  */
184
189
  getLongLines() {
185
190
  if (this.lines) return this.lines;
186
- const categoryLine = this.category ? `CATEGORIES:${this.category}` : [];
191
+ const categoryLine = this.category ? [`CATEGORIES:${this.category}`] : [];
187
192
  const uid = this.ev.uid || this.getUid();
193
+ if (this.sequence) {
194
+ categoryLine.unshift(`SEQUENCE:${this.sequence}`);
195
+ }
188
196
  const arr = this.lines = ['BEGIN:VEVENT', `DTSTAMP:${this.dtstamp}`].concat(categoryLine).concat([`SUMMARY:${this.subj}`, `DTSTART${this.dtargs}:${this.startDate}`, `DTEND${this.dtargs}:${this.endDate}`, `UID:${uid}`, `TRANSP:${this.transp}`, `X-MICROSOFT-CDO-BUSYSTATUS:${this.busyStatus}`]);
189
197
  if (!this.timed) {
190
198
  arr.push('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE');
@@ -389,7 +397,7 @@ function createMemo(e, options) {
389
397
  * Generates an RFC 2445 iCalendar string from an array of events
390
398
  * @param {Event[]} events
391
399
  * @param {HebrewCalendar.Options} options
392
- * @return {string}
400
+ * @return {Promise<string>}
393
401
  */
394
402
  async function eventsToIcalendar(events, options) {
395
403
  if (!events.length) throw new RangeError('Events can not be empty');
@@ -407,7 +415,7 @@ async function eventsToIcalendar(events, options) {
407
415
  * Generates an RFC 2445 iCalendar string from an array of IcalEvents
408
416
  * @param {IcalEvent[]} icals
409
417
  * @param {HebrewCalendar.Options} options
410
- * @return {string}
418
+ * @return {Promise<string>}
411
419
  */
412
420
  async function icalEventsToString(icals, options) {
413
421
  const stream = [];
@@ -416,9 +424,14 @@ async function icalEventsToString(icals, options) {
416
424
  opts.dtstamp = opts.dtstamp || IcalEvent.makeDtstamp(new Date());
417
425
  const title = opts.title ? IcalEvent.escape(opts.title) : 'Untitled';
418
426
  const caldesc = opts.caldesc ? IcalEvent.escape(opts.caldesc) : opts.yahrzeit ? 'Yahrzeits + Anniversaries from www.hebcal.com' : 'Jewish Holidays from www.hebcal.com';
419
- const publishedTTL = opts.publishedTTL || 'PT7D';
420
427
  const prodid = opts.prodid || `-//hebcal.com/NONSGML Hebcal Calendar v1${version}//${uclang}`;
421
- const preamble = ['BEGIN:VCALENDAR', 'VERSION:2.0', `PRODID:${prodid}`, 'CALSCALE:GREGORIAN', 'METHOD:PUBLISH', 'X-LOTUS-CHARSET:UTF-8', `X-PUBLISHED-TTL:${publishedTTL}`, `X-WR-CALNAME:${title}`, `X-WR-CALDESC:${caldesc}`];
428
+ const preamble = ['BEGIN:VCALENDAR', 'VERSION:2.0', `PRODID:${prodid}`, 'CALSCALE:GREGORIAN', 'METHOD:PUBLISH', 'X-LOTUS-CHARSET:UTF-8'];
429
+ if (opts.publishedTTL !== false) {
430
+ const publishedTTL = opts.publishedTTL || 'PT7D';
431
+ preamble.push(`X-PUBLISHED-TTL:${publishedTTL}`);
432
+ }
433
+ preamble.push(`X-WR-CALNAME:${title}`);
434
+ preamble.push(`X-WR-CALDESC:${caldesc}`);
422
435
  for (const line of preamble.map(IcalEvent.fold)) {
423
436
  stream.push(line);
424
437
  stream.push('\r\n');
package/dist/index.mjs CHANGED
@@ -1,10 +1,10 @@
1
- /*! @hebcal/icalendar v4.20.0 */
1
+ /*! @hebcal/icalendar v4.21.0 */
2
2
  import { flags, Locale, greg } from '@hebcal/core';
3
3
  import { murmur32HexSync } from 'murmurhash3';
4
4
  import { shouldRenderBrief, pad2, getEventCategories, makeAnchor, pad4, getHolidayDescription, getCalendarTitle, appendIsraelAndTracking, makeTorahMemoText } from '@hebcal/rest-api';
5
5
  import { promises } from 'fs';
6
6
 
7
- const version="4.20.0";
7
+ const version="4.21.0";
8
8
 
9
9
  const VTIMEZONE = {};
10
10
  const CATEGORY = {
@@ -69,6 +69,11 @@ class IcalEvent {
69
69
  this.ev = ev;
70
70
  this.options = options;
71
71
  this.dtstamp = options.dtstamp || IcalEvent.makeDtstamp(new Date());
72
+ if (typeof ev.sequence === 'number') {
73
+ this.sequence = ev.sequence;
74
+ } else if (typeof options.sequence === 'number') {
75
+ this.sequence = options.sequence;
76
+ }
72
77
  const timed = this.timed = Boolean(ev.eventTime);
73
78
  const locale = options.locale;
74
79
  let subj = shouldRenderBrief(ev) ? ev.renderBrief(locale) : ev.render(locale);
@@ -181,8 +186,11 @@ class IcalEvent {
181
186
  */
182
187
  getLongLines() {
183
188
  if (this.lines) return this.lines;
184
- const categoryLine = this.category ? `CATEGORIES:${this.category}` : [];
189
+ const categoryLine = this.category ? [`CATEGORIES:${this.category}`] : [];
185
190
  const uid = this.ev.uid || this.getUid();
191
+ if (this.sequence) {
192
+ categoryLine.unshift(`SEQUENCE:${this.sequence}`);
193
+ }
186
194
  const arr = this.lines = ['BEGIN:VEVENT', `DTSTAMP:${this.dtstamp}`].concat(categoryLine).concat([`SUMMARY:${this.subj}`, `DTSTART${this.dtargs}:${this.startDate}`, `DTEND${this.dtargs}:${this.endDate}`, `UID:${uid}`, `TRANSP:${this.transp}`, `X-MICROSOFT-CDO-BUSYSTATUS:${this.busyStatus}`]);
187
195
  if (!this.timed) {
188
196
  arr.push('X-MICROSOFT-CDO-ALLDAYEVENT:TRUE');
@@ -387,7 +395,7 @@ function createMemo(e, options) {
387
395
  * Generates an RFC 2445 iCalendar string from an array of events
388
396
  * @param {Event[]} events
389
397
  * @param {HebrewCalendar.Options} options
390
- * @return {string}
398
+ * @return {Promise<string>}
391
399
  */
392
400
  async function eventsToIcalendar(events, options) {
393
401
  if (!events.length) throw new RangeError('Events can not be empty');
@@ -405,7 +413,7 @@ async function eventsToIcalendar(events, options) {
405
413
  * Generates an RFC 2445 iCalendar string from an array of IcalEvents
406
414
  * @param {IcalEvent[]} icals
407
415
  * @param {HebrewCalendar.Options} options
408
- * @return {string}
416
+ * @return {Promise<string>}
409
417
  */
410
418
  async function icalEventsToString(icals, options) {
411
419
  const stream = [];
@@ -414,9 +422,14 @@ async function icalEventsToString(icals, options) {
414
422
  opts.dtstamp = opts.dtstamp || IcalEvent.makeDtstamp(new Date());
415
423
  const title = opts.title ? IcalEvent.escape(opts.title) : 'Untitled';
416
424
  const caldesc = opts.caldesc ? IcalEvent.escape(opts.caldesc) : opts.yahrzeit ? 'Yahrzeits + Anniversaries from www.hebcal.com' : 'Jewish Holidays from www.hebcal.com';
417
- const publishedTTL = opts.publishedTTL || 'PT7D';
418
425
  const prodid = opts.prodid || `-//hebcal.com/NONSGML Hebcal Calendar v1${version}//${uclang}`;
419
- const preamble = ['BEGIN:VCALENDAR', 'VERSION:2.0', `PRODID:${prodid}`, 'CALSCALE:GREGORIAN', 'METHOD:PUBLISH', 'X-LOTUS-CHARSET:UTF-8', `X-PUBLISHED-TTL:${publishedTTL}`, `X-WR-CALNAME:${title}`, `X-WR-CALDESC:${caldesc}`];
426
+ const preamble = ['BEGIN:VCALENDAR', 'VERSION:2.0', `PRODID:${prodid}`, 'CALSCALE:GREGORIAN', 'METHOD:PUBLISH', 'X-LOTUS-CHARSET:UTF-8'];
427
+ if (opts.publishedTTL !== false) {
428
+ const publishedTTL = opts.publishedTTL || 'PT7D';
429
+ preamble.push(`X-PUBLISHED-TTL:${publishedTTL}`);
430
+ }
431
+ preamble.push(`X-WR-CALNAME:${title}`);
432
+ preamble.push(`X-WR-CALDESC:${caldesc}`);
420
433
  for (const line of preamble.map(IcalEvent.fold)) {
421
434
  stream.push(line);
422
435
  stream.push('\r\n');
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/icalendar",
3
- "version": "4.20.0",
3
+ "version": "4.21.0",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "ical",
@@ -28,8 +28,8 @@
28
28
  "url": "https://github.com/hebcal/hebcal-icalendar/issues"
29
29
  },
30
30
  "dependencies": {
31
- "@hebcal/core": "^4.0.0",
32
- "@hebcal/rest-api": "^4.5.0",
31
+ "@hebcal/core": "^4.1.1",
32
+ "@hebcal/rest-api": "^4.5.1",
33
33
  "murmurhash3": "^0.5.0"
34
34
  },
35
35
  "scripts": {
@@ -46,18 +46,18 @@
46
46
  ]
47
47
  },
48
48
  "devDependencies": {
49
- "@babel/core": "^7.21.5",
50
- "@babel/preset-env": "^7.21.5",
51
- "@babel/register": "^7.21.0",
52
- "@hebcal/learning": "^1.1.2",
49
+ "@babel/core": "^7.22.5",
50
+ "@babel/preset-env": "^7.22.5",
51
+ "@babel/register": "^7.22.5",
52
+ "@hebcal/learning": "^1.4.0",
53
53
  "@rollup/plugin-babel": "^6.0.3",
54
- "@rollup/plugin-commonjs": "^24.1.0",
54
+ "@rollup/plugin-commonjs": "^25.0.2",
55
55
  "@rollup/plugin-json": "^6.0.0",
56
- "ava": "^5.2.0",
57
- "eslint": "^8.39.0",
56
+ "ava": "^5.3.1",
57
+ "eslint": "^8.44.0",
58
58
  "eslint-config-google": "^0.14.0",
59
59
  "jsdoc": "^4.0.2",
60
60
  "jsdoc-to-markdown": "^8.0.0",
61
- "rollup": "^3.21.0"
61
+ "rollup": "^3.26.0"
62
62
  }
63
63
  }