@hebcal/icalendar 6.2.1 → 6.3.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/index.js CHANGED
@@ -1,4 +1,4 @@
1
- /*! @hebcal/icalendar v6.2.1 */
1
+ /*! @hebcal/icalendar v6.3.1 */
2
2
  import { flags, Locale, greg } from '@hebcal/core';
3
3
  import { murmur32HexSync } from 'murmurhash3';
4
4
  import { pad2, pad4 } from '@hebcal/hdate';
@@ -7,7 +7,7 @@ import { makeAnchor } from '@hebcal/rest-api/dist/esm/makeAnchor';
7
7
  import { promises } from 'fs';
8
8
 
9
9
  // DO NOT EDIT THIS AUTO-GENERATED FILE!
10
- const version = '6.2.1';
10
+ const version = '6.3.1';
11
11
 
12
12
  const vtimezoneCache = new Map();
13
13
  const CATEGORY = {
@@ -74,35 +74,37 @@ class IcalEvent {
74
74
  const opts = Object.assign({}, options);
75
75
  this.options = opts;
76
76
  this.dtstamp = opts.dtstamp || IcalEvent.makeDtstamp(new Date());
77
- if (typeof ev.sequence === 'number') {
78
- this.sequence = ev.sequence;
77
+ const ev0 = ev;
78
+ if (typeof ev0.sequence === 'number') {
79
+ this.sequence = ev0.sequence;
79
80
  }
80
81
  else if (typeof opts.sequence === 'number') {
81
82
  this.sequence = opts.sequence;
82
83
  }
83
- const timed = (this.timed = Boolean(ev.eventTime));
84
+ const timed = (this.timed = Boolean(ev0.eventTime));
84
85
  const locale = opts.locale;
85
86
  const location = opts.location;
86
87
  let subj = shouldRenderBrief(ev)
87
88
  ? ev.renderBrief(locale)
88
89
  : ev.render(locale);
89
90
  const mask = ev.getFlags();
90
- if (ev.locationName) {
91
- this.locationName = ev.locationName;
91
+ if (ev0.locationName) {
92
+ this.locationName = ev0.locationName;
92
93
  }
93
94
  else if (timed && location) {
94
95
  this.locationName = location.getShortName();
95
96
  }
96
- else if (mask & DAILY_LEARNING && ev.category) {
97
- this.locationName = Locale.gettext(ev.category, locale);
97
+ else if (mask & DAILY_LEARNING && ev0.category) {
98
+ this.locationName = Locale.gettext(ev0.category, locale);
98
99
  }
99
- const date = IcalEvent.formatYYYYMMDD(ev.getDate().greg());
100
+ const hd = ev.getDate();
101
+ const date = IcalEvent.formatYYYYMMDD(hd.greg());
100
102
  this.startDate = this.isoDateOnly = date;
101
103
  this.dtargs = '';
102
104
  this.transp = 'TRANSPARENT';
103
105
  this.busyStatus = 'FREE';
104
106
  if (timed) {
105
- let [hour, minute] = ev.eventTimeStr.split(':');
107
+ let [hour, minute] = ev0.eventTimeStr.split(':');
106
108
  hour = +hour;
107
109
  minute = +minute;
108
110
  this.startDate += 'T' + pad2(hour) + pad2(minute) + '00';
@@ -112,7 +114,7 @@ class IcalEvent {
112
114
  }
113
115
  }
114
116
  else {
115
- this.endDate = IcalEvent.formatYYYYMMDD(ev.getDate().next().greg());
117
+ this.endDate = IcalEvent.formatYYYYMMDD(hd.next().greg());
116
118
  // for all-day untimed, use DTEND;VALUE=DATE intsead of DURATION:P1D.
117
119
  // It's more compatible with everthing except ancient versions of
118
120
  // Lotus Notes circa 2004
@@ -142,8 +144,7 @@ class IcalEvent {
142
144
  }
143
145
  }
144
146
  this.subj = subj;
145
- this.category =
146
- ev.category || CATEGORY[(_a = getEventCategories(ev)) === null || _a === void 0 ? void 0 : _a[0]];
147
+ this.category = ev0.category || CATEGORY[(_a = getEventCategories(ev)) === null || _a === void 0 ? void 0 : _a[0]];
147
148
  }
148
149
  getAlarm() {
149
150
  const ev = this.ev;
@@ -172,13 +173,14 @@ class IcalEvent {
172
173
  return null;
173
174
  }
174
175
  getUid() {
175
- if (this.ev.uid) {
176
- return this.ev.uid;
176
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
177
+ let uid = this.ev.uid;
178
+ if (uid) {
179
+ return uid;
177
180
  }
178
- const options = this.options;
179
181
  const digest = murmur32HexSync(this.ev.getDesc());
180
- let uid = `hebcal-${this.isoDateOnly}-${digest}`;
181
- const loc = options.location;
182
+ uid = `hebcal-${this.isoDateOnly}-${digest}`;
183
+ const loc = this.options.location;
182
184
  if (this.timed && loc) {
183
185
  if (loc.getGeoId()) {
184
186
  uid += `-${loc.getGeoId()}`;
@@ -423,6 +425,15 @@ async function eventsToIcalendar(events, options) {
423
425
  const icals = events.map(ev => new IcalEvent(ev, opts));
424
426
  return icalEventsToString(icals, opts);
425
427
  }
428
+ const localeMap = {
429
+ 'he-x-NoNikud': 'he',
430
+ 'he-x-nonikud': 'he',
431
+ h: 'he',
432
+ a: 'en',
433
+ s: 'en',
434
+ ashkenazi: 'en',
435
+ ashkenazi_romanian: 'ro',
436
+ };
426
437
  /**
427
438
  * Generates an RFC 2445 iCalendar string from an array of IcalEvents
428
439
  */
@@ -433,7 +444,8 @@ async function icalEventsToString(icals, options) {
433
444
  throw new TypeError('Invalid options object');
434
445
  const stream = [];
435
446
  const locale = options.locale || 'en';
436
- const uclang = locale.toUpperCase();
447
+ const lang = locale.length === 2 ? locale : localeMap[locale] || 'en';
448
+ const uclang = lang.toUpperCase();
437
449
  const opts = Object.assign({}, options);
438
450
  opts.dtstamp = opts.dtstamp || IcalEvent.makeDtstamp(new Date());
439
451
  const title = opts.title ? IcalEvent.escape(opts.title) : 'Untitled';
@@ -453,7 +465,8 @@ async function icalEventsToString(icals, options) {
453
465
  'X-LOTUS-CHARSET:UTF-8',
454
466
  ];
455
467
  if (opts.publishedTTL !== false) {
456
- const publishedTTL = opts.publishedTTL || 'PT7D';
468
+ const publishedTTL = opts.publishedTTL || 'P7D';
469
+ preamble.push(`REFRESH-INTERVAL;VALUE=DURATION:${publishedTTL}`);
457
470
  preamble.push(`X-PUBLISHED-TTL:${publishedTTL}`);
458
471
  }
459
472
  preamble.push(`X-WR-CALNAME:${title}`);
@@ -1 +1 @@
1
- export declare const version = "6.2.1";
1
+ export declare const version = "6.3.1";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/icalendar",
3
- "version": "6.2.1",
3
+ "version": "6.3.1",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "ical",
@@ -30,9 +30,9 @@
30
30
  },
31
31
  "homepage": "https://hebcal.github.io/api/icalendar/",
32
32
  "dependencies": {
33
- "@hebcal/core": "^6.0.0",
34
- "@hebcal/hdate": "^0.21.0",
35
- "@hebcal/rest-api": "^6.2.0",
33
+ "@hebcal/core": "^6.0.5",
34
+ "@hebcal/hdate": "^0.21.1",
35
+ "@hebcal/rest-api": "^6.3.0",
36
36
  "murmurhash3": "^0.5.0",
37
37
  "tslib": "^2.8.1"
38
38
  },
@@ -53,12 +53,11 @@
53
53
  "devDependencies": {
54
54
  "@hebcal/learning": "^6.6.0",
55
55
  "@rollup/plugin-typescript": "^12.3.0",
56
- "@types/jest": "^30.0.0",
57
- "@types/node": "24.9.1",
56
+ "@types/node": "24.9.2",
58
57
  "gts": "^5.3.1",
59
58
  "rollup": "^4.52.5",
60
59
  "typedoc": "^0.28.14",
61
60
  "typescript": "^5.9.3",
62
- "vitest": "^4.0.3"
61
+ "vitest": "^4.0.6"
63
62
  }
64
63
  }