@hebcal/icalendar 4.15.1 → 4.15.4

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,320 +1,14 @@
1
- /*! @hebcal/icalendar v4.15.1 */
1
+ /*! @hebcal/icalendar v4.15.4 */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var core = require('@hebcal/core');
7
7
  var murmurhash3 = require('murmurhash3');
8
- var leyn = require('@hebcal/leyning');
8
+ var restApi = require('@hebcal/rest-api');
9
9
  var fs = require('fs');
10
10
 
11
- function _interopNamespace(e) {
12
- if (e && e.__esModule) return e;
13
- var n = Object.create(null);
14
- if (e) {
15
- Object.keys(e).forEach(function (k) {
16
- if (k !== 'default') {
17
- var d = Object.getOwnPropertyDescriptor(e, k);
18
- Object.defineProperty(n, k, d.get ? d : {
19
- enumerable: true,
20
- get: function () { return e[k]; }
21
- });
22
- }
23
- });
24
- }
25
- n["default"] = e;
26
- return Object.freeze(n);
27
- }
28
-
29
- var leyn__namespace = /*#__PURE__*/_interopNamespace(leyn);
30
-
31
- /*! @hebcal/rest-api v3.12.0 */
32
-
33
- var Chanukah="Hanukkah, the Jewish festival of rededication. Also known as the Festival of Lights";var Pesach="Passover, the Feast of Unleavened Bread. Also called Chag HaMatzot (the Festival of Matzah), it commemorates the Exodus and freedom of the Israelites from ancient Egypt";var Purim="Celebration of Jewish deliverance as told by Megilat Esther. It commemorates a time when the Jewish people living in Persia were saved from extermination";var Shavuot="Festival of Weeks. Commemorates the giving of the Torah at Mount Sinai";var Sigd="Ethiopian Jewish holiday occurring 50 days after Yom Kippur";var Sukkot="Feast of Booths";var holidayDescription = {"Asara B'Tevet":"Fast commemorating the siege of Jerusalem",Chanukah:Chanukah,"Days of the Omer":"7 weeks from the second night of Pesach to the day before Shavuot","Lag BaOmer":"33rd day of counting the Omer","Leil Selichot":"Prayers for forgiveness in preparation for the High Holidays","Pesach Sheni":"Second Passover, one month after Passover",Pesach:Pesach,"Purim Katan":"Minor Purim celebration during Adar I on leap years",Purim:Purim,"Rosh Chodesh Nisan":"Start of month of Nisan on the Hebrew calendar. נִיסָן (transliterated Nisan or Nissan) is the 1st month of the Hebrew year, has 30 days, and corresponds to March or April on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Iyyar":"Start of month of Iyyar on the Hebrew calendar. אִיָיר (transliterated Iyyar or Iyar) is the 2nd month of the Hebrew year, has 29 days, and corresponds to April or May on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Sivan":"Start of month of Sivan on the Hebrew calendar. Sivan (סִיוָן) is the 3rd month of the Hebrew year, has 30 days, and corresponds to May or June on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Tamuz":"Start of month of Tamuz on the Hebrew calendar. תַּמּוּז (transliterated Tamuz or Tammuz) is the 4th month of the Hebrew year, has 29 days, and corresponds to June or July on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Av":"Start of month of Av on the Hebrew calendar. Av (אָב) is the 5th month of the Hebrew year, has 30 days, and corresponds to July or August on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Elul":"Start of month of Elul on the Hebrew calendar. Elul (אֱלוּל) is the 6th month of the Hebrew year, has 29 days, and corresponds to August or September on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Cheshvan":"Start of month of Cheshvan on the Hebrew calendar. חֶשְׁוָן (transliterated Cheshvan or Heshvan) is the 8th month of the Hebrew year, has 29 or 30 days, and corresponds to October or November on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Kislev":"Start of month of Kislev on the Hebrew calendar. Kislev (כִּסְלֵו) is the 9th month of the Hebrew year, has 30 or 29 days, and corresponds to November or December on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Tevet":"Start of month of Tevet on the Hebrew calendar. Tevet (טֵבֵת) is the 10th month of the Hebrew year, has 29 days, and corresponds to December or January on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Sh'vat":"Start of month of Sh'vat on the Hebrew calendar. שְׁבָט (transliterated Sh'vat or Shevat) is the 11th month of the Hebrew year, has 30 days, and corresponds to January or February on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Adar":"Start of month of Adar on the Hebrew calendar. Adar (אַדָר) is the 12th month of the Hebrew year, has 29 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Adar I":"Start of month of Adar I (on leap years) on the Hebrew calendar. Adar I (אַדָר א׳) is the 12th month of the Hebrew year, occurs only on leap years, has 30 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Adar II":"Start of month of Adar II (on leap years) on the Hebrew calendar. Adar II (אַדָר ב׳), sometimes \"Adar Bet\" or \"Adar Sheni\", is the 13th month of the Hebrew year, has 29 days, occurs only on leap years, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Hashana":"The Jewish New Year. Also spelled Rosh Hashanah","Rosh Hashana LaBehemot":"New Year for Tithing Animals","Shabbat Chazon":"Shabbat before Tish'a B'Av (Shabbat of Prophecy/Shabbat of Vision)","Shabbat HaChodesh":"Shabbat before Rosh Chodesh Nissan","Shabbat HaGadol":"Shabbat before Pesach","Shabbat Machar Chodesh":"When Shabbat falls the day before Rosh Chodesh","Shabbat Nachamu":"Shabbat after Tish'a B'Av (Shabbat of Consolation). The first of seven Shabbatot leading up to Rosh Hashanah. Named after the Haftarah (from Isaiah 40) which begins with the verse נַחֲמוּ נַחֲמוּ, עַמִּי (\"Comfort, oh comfort my people\")","Shabbat Parah":"Shabbat of the Red Heifer","Shabbat Rosh Chodesh":"When Shabbat falls on Rosh Chodesh","Shabbat Shekalim":"Shabbat before Rosh Chodesh Adar","Shabbat Shirah":"Shabbat of Song","Shabbat Shuva":"Shabbat that falls between Rosh Hashanah and Yom Kippur (Shabbat of Returning)","Shabbat Zachor":"Shabbat before Purim",Shavuot:Shavuot,"Shmini Atzeret":"Eighth Day of Assembly","Shushan Purim":"Purim celebrated in Jerusalem and walled cities",Sigd:Sigd,"Simchat Torah":"Day of Celebrating the Torah",Sukkot:Sukkot,"Ta'anit Bechorot":"Fast of the First Born","Ta'anit Esther":"Fast of Esther","Tish'a B'Av":"The Ninth of Av. Fast commemorating the destruction of the two Temples","Tu B'Av":"Minor Jewish holiday of love. Observed on the 15th day of the Hebrew month of Av","Tu BiShvat":"New Year for Trees","Tzom Gedaliah":"Fast of the Seventh Month. Commemorates the assassination of the Jewish governor of Judah","Tzom Tammuz":"Fast commemorating breaching of the walls of Jerusalem before the destruction of the Second Temple","Yom HaAliyah":"Recognizes Aliyah, immigration to the Jewish State of Israel","Yom HaAliyah School Observance":"Aliyah Day observed in Israeli schools","Yom HaAtzma'ut":"Israeli Independence Day. Commemorates the declaration of independence of Israel in 1948. Note that Hebcal displays modern holidays like Yom HaAtzma'ut according to the Israeli schedule. Although Yom HaAtzma'ut is normally observed on the 5th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaZikaron, which always precedes it) would conflict with Shabbat","Yom HaShoah":"Holocaust Memorial Day","Yom HaZikaron":"Israeli Memorial Day. Note that Hebcal displays modern holidays like Yom HaZikaron according to the Israeli schedule. Although Yom Hazikaron is normally observed on the 4th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaAtzma'ut, which always follows it) would conflict with Shabbat","Yom Kippur":"Day of Atonement","Yom Yerushalayim":"Jerusalem Day. Commemorates the re-unification of Jerusalem in 1967"};
34
-
35
- /**
36
- * Helper function to transform a string to make it more usable in a URL or filename.
37
- * Converts to lowercase and replaces non-word characters with hyphen ('-').
38
- * @example
39
- * makeAnchor('Rosh Chodesh Adar II') // 'rosh-chodesh-adar-ii'
40
- * @param {string} s
41
- * @return {string}
42
- */
43
-
44
- function makeAnchor(s) {
45
- return s.toLowerCase().replace(/'/g, '').replace(/[^\w]/g, '-').replace(/-+/g, '-').replace(/^-/g, '').replace(/-$/g, '');
46
- }
47
- /**
48
- * @param {number} number
49
- * @return {string}
50
- */
51
-
52
- function pad2(number) {
53
- if (number < 10) {
54
- return '0' + number;
55
- }
56
-
57
- return String(number);
58
- }
59
- /**
60
- * @param {number} number
61
- * @return {string}
62
- */
63
-
64
- function pad4(number) {
65
- if (number < 0) {
66
- return '-00' + pad4(-number);
67
- } else if (number < 10) {
68
- return '000' + number;
69
- } else if (number < 100) {
70
- return '00' + number;
71
- } else if (number < 1000) {
72
- return '0' + number;
73
- }
74
-
75
- return String(number);
76
- }
77
- /**
78
- * Returns a category and subcategory name
79
- * @param {Event} ev
80
- * @return {string[]}
81
- */
82
-
83
- function getEventCategories(ev) {
84
- const desc = ev.getDesc(); // since these use flags.MINOR_FAST or flags.MAJOR_FAST, check description first
85
-
86
- if (desc === 'Fast begins' || desc === 'Fast ends') {
87
- return ['zmanim', 'fast'];
88
- }
89
-
90
- switch (ev.getFlags()) {
91
- case core.flags.OMER_COUNT:
92
- return ['omer'];
93
-
94
- case core.flags.HEBREW_DATE:
95
- return ['hebdate'];
96
-
97
- case core.flags.PARSHA_HASHAVUA:
98
- return ['parashat'];
99
- // backwards-compat
100
-
101
- case core.flags.DAF_YOMI:
102
- return ['dafyomi'];
103
-
104
- case core.flags.ROSH_CHODESH:
105
- return ['roshchodesh'];
106
-
107
- case core.flags.SPECIAL_SHABBAT:
108
- return ['holiday', 'shabbat'];
109
-
110
- case core.flags.MINOR_FAST:
111
- return ['holiday', 'fast'];
112
-
113
- case core.flags.MAJOR_FAST:
114
- return ['holiday', 'fast', 'major'];
115
-
116
- case core.flags.MODERN_HOLIDAY:
117
- return ['holiday', 'modern'];
118
-
119
- case core.flags.SHABBAT_MEVARCHIM:
120
- return ['mevarchim'];
121
-
122
- case core.flags.MOLAD:
123
- return ['molad'];
124
-
125
- case core.flags.USER_EVENT:
126
- return ['user'];
127
-
128
- case core.flags.MINOR_HOLIDAY:
129
- return ['holiday', 'minor'];
130
-
131
- case core.flags.MISHNA_YOMI:
132
- return ['mishnayomi'];
133
- // fall through to string-based category
134
- }
135
-
136
- if (ev.cholHaMoedDay) {
137
- return ['holiday', 'major', 'cholhamoed'];
138
- }
139
-
140
- switch (desc) {
141
- case 'Havdalah':
142
- return ['havdalah'];
143
-
144
- case 'Candle lighting':
145
- return ['candles'];
146
-
147
- case 'Lag BaOmer':
148
- case 'Leil Selichot':
149
- case 'Pesach Sheni':
150
- case 'Erev Purim':
151
- case 'Purim Katan':
152
- case 'Shushan Purim':
153
- case 'Tu B\'Av':
154
- case 'Tu BiShvat':
155
- case 'Rosh Hashana LaBehemot':
156
- return ['holiday', 'minor'];
157
-
158
- case 'Erev Tish\'a B\'Av':
159
- return ['holiday', 'fast', 'major'];
160
-
161
- default:
162
- return ['holiday', 'major'];
163
- }
164
- }
165
- /**
166
- * Generates a title like "Hebcal 2020 Israel" or "Hebcal May 1993 Providence"
167
- * @param {Event[]} events
168
- * @param {HebrewCalendar.Options} options
169
- * @return {string}
170
- */
171
-
172
- function getCalendarTitle(events, options) {
173
- let title = 'Hebcal';
174
- const location = options.location;
175
-
176
- if (options.yahrzeit) {
177
- title += ' Yahrzeits and Anniversaries';
178
- } else if (location && location.name) {
179
- const comma = location.name.indexOf(',');
180
- const name = comma == -1 ? location.name : location.name.substring(0, comma);
181
- title += ' ' + name;
182
- } else if (options.il) {
183
- title += ' Israel';
184
- } else {
185
- title += ' Diaspora';
186
- }
187
-
188
- if (options.subscribe == '1') {
189
- return title;
190
- }
191
-
192
- if (options.isHebrewYear || events.length == 0) {
193
- title += ' ' + options.year;
194
- } else {
195
- const start = events[0].getDate().greg();
196
- const end = events[events.length - 1].getDate().greg();
197
-
198
- if (start.getFullYear() != end.getFullYear()) {
199
- title += ' ' + start.getFullYear() + '-' + end.getFullYear();
200
- } else if (start.getMonth() == end.getMonth()) {
201
- const monthFormat = new Intl.DateTimeFormat('en-US', {
202
- month: 'long'
203
- });
204
- const startMonth = monthFormat.format(start);
205
- title += ' ' + startMonth + ' ' + start.getFullYear();
206
- } else {
207
- title += ' ' + start.getFullYear();
208
- }
209
- }
210
-
211
- return title;
212
- }
213
- /**
214
- * Returns an English language description of the holiday
215
- * @param {Event} ev
216
- * @param {boolean} [firstSentence=false]
217
- * @return {string}
218
- */
219
-
220
- function getHolidayDescription(ev, firstSentence = false) {
221
- const str = holidayDescription[ev.getDesc()] || holidayDescription[ev.basename()] || '';
222
-
223
- if (firstSentence && str) {
224
- const dot = str.indexOf('.');
225
-
226
- if (dot != -1) {
227
- return str.substring(0, dot);
228
- }
229
- }
230
-
231
- return str;
232
- }
233
- const HOLIDAY_IGNORE_MASK$1 = core.flags.DAF_YOMI | core.flags.OMER_COUNT | core.flags.SHABBAT_MEVARCHIM | core.flags.MOLAD | core.flags.USER_EVENT | core.flags.HEBREW_DATE;
234
- /**
235
- * Makes mulit-line text that summarizes Torah & Haftarah
236
- * @param {Event} ev
237
- * @param {boolean} il
238
- * @return {string}
239
- */
240
-
241
- function makeTorahMemoText(ev, il) {
242
- const mask = ev.getFlags();
243
-
244
- if (mask & HOLIDAY_IGNORE_MASK$1) {
245
- return '';
246
- }
247
-
248
- const reading = mask & core.flags.PARSHA_HASHAVUA ? leyn__namespace.getLeyningForParshaHaShavua(ev, il) : leyn__namespace.getLeyningForHoliday(ev, il);
249
- let memo = '';
250
-
251
- if (reading && (reading.summary || reading.haftara)) {
252
- if (reading.summary) {
253
- memo += `Torah: ${reading.summary}`;
254
- }
255
-
256
- if (reading.summary && reading.haftara) {
257
- memo += '\n';
258
- }
259
-
260
- if (reading.haftara) {
261
- memo += 'Haftarah: ' + reading.haftara;
262
-
263
- if (reading.reason && reading.reason.haftara) {
264
- memo += ' | ' + reading.reason.haftara;
265
- }
266
- }
267
- }
268
-
269
- if (reading && reading.sephardic) {
270
- memo += '\nHaftarah for Sephardim: ' + reading.sephardic;
271
- }
272
-
273
- return memo;
274
- }
275
- /**
276
- * Appends utm_source and utm_medium parameters to a URL
277
- * @param {string} url
278
- * @param {boolean} il
279
- * @param {string} utmSource
280
- * @param {string} utmMedium
281
- * @param {string} utmCampaign
282
- * @return {string}
283
- */
284
-
285
- function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
286
- if (url.substring(0, 22) !== 'https://www.hebcal.com') {
287
- utmSource = 'hebcal.com';
288
- } else if (il && url.indexOf('?') === -1) {
289
- url += '?i=on';
290
- }
291
-
292
- const sep = url.indexOf('?') === -1 ? '?' : '&';
293
- const utm = `utm_source=${utmSource}&utm_medium=${utmMedium}`;
294
- const campaign = utmCampaign ? `&utm_campaign=${utmCampaign}` : '';
295
- return url + sep + utm + campaign;
296
- }
297
- /**
298
- * @private
299
- * @param {Event} ev
300
- * @return {boolean}
301
- */
302
-
303
- function shouldRenderBrief(ev) {
304
- if (typeof ev.eventTime !== 'undefined') return true;
305
- const mask = ev.getFlags();
306
-
307
- if (mask & core.flags.HEBREW_DATE) {
308
- const hd = ev.getDate();
309
- return hd.getDate() === 1 ? false : true;
310
- } else if (mask & core.flags.DAF_YOMI) {
311
- return true;
312
- } else {
313
- return false;
314
- }
315
- }
316
-
317
- var version="4.15.1";
11
+ var version="4.15.4";
318
12
 
319
13
  const VTIMEZONE = {};
320
14
  const CATEGORY = {
@@ -361,7 +55,7 @@ function appendTrackingToUrl(url, options) {
361
55
  const utmSource = options.utmSource || 'js';
362
56
  const utmMedium = options.utmMedium || 'icalendar';
363
57
  const utmCampaign = options.utmCampaign;
364
- return appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
58
+ return restApi.appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
365
59
  }
366
60
 
367
61
  const encoder = new TextEncoder();
@@ -382,7 +76,7 @@ class IcalEvent {
382
76
  this.dtstamp = options.dtstamp || IcalEvent.makeDtstamp(new Date());
383
77
  const timed = this.timed = Boolean(ev.eventTime);
384
78
  const locale = options.locale;
385
- let subj = shouldRenderBrief(ev) ? ev.renderBrief(locale) : ev.render(locale);
79
+ let subj = restApi.shouldRenderBrief(ev) ? ev.renderBrief(locale) : ev.render(locale);
386
80
  const mask = ev.getFlags();
387
81
 
388
82
  if (ev.locationName) {
@@ -406,7 +100,7 @@ class IcalEvent {
406
100
  let [hour, minute] = ev.eventTimeStr.split(':');
407
101
  hour = +hour;
408
102
  minute = +minute;
409
- this.startDate += 'T' + pad2(hour) + pad2(minute) + '00';
103
+ this.startDate += 'T' + restApi.pad2(hour) + restApi.pad2(minute) + '00';
410
104
  this.endDate = this.startDate;
411
105
 
412
106
  if (options.location && options.location.tzid) {
@@ -457,7 +151,7 @@ class IcalEvent {
457
151
  this.alarm = '-P0DT0H10M0S'; // ten minutes
458
152
  }
459
153
 
460
- this.category = ev.category || CATEGORY[getEventCategories(ev)[0]];
154
+ this.category = ev.category || CATEGORY[restApi.getEventCategories(ev)[0]];
461
155
  }
462
156
  /**
463
157
  * @return {string}
@@ -473,7 +167,7 @@ class IcalEvent {
473
167
  if (options.location.geoid) {
474
168
  uid += `-${options.location.geoid}`;
475
169
  } else if (options.location.name) {
476
- uid += '-' + makeAnchor(options.location.name);
170
+ uid += '-' + restApi.makeAnchor(options.location.name);
477
171
  }
478
172
  }
479
173
 
@@ -610,7 +304,7 @@ class IcalEvent {
610
304
 
611
305
 
612
306
  static formatYYYYMMDD(dt) {
613
- return pad4(dt.getFullYear()) + pad2(dt.getMonth() + 1) + pad2(dt.getDate());
307
+ return restApi.pad4(dt.getFullYear()) + restApi.pad2(dt.getMonth() + 1) + restApi.pad2(dt.getDate());
614
308
  }
615
309
  /**
616
310
  * Returns UTC string for iCalendar
@@ -667,7 +361,7 @@ function makeTorahMemo(ev, il) {
667
361
  return memo;
668
362
  }
669
363
 
670
- memo = makeTorahMemoText(ev, il).replace(/\n/g, '\\n');
364
+ memo = restApi.makeTorahMemoText(ev, il).replace(/\n/g, '\\n');
671
365
  torahMemoCache.set(key, memo);
672
366
  return memo;
673
367
  }
@@ -699,7 +393,7 @@ function createMemo(e, options) {
699
393
  if (mask & core.flags.PARSHA_HASHAVUA) {
700
394
  return torahMemo + '\\n\\n' + url;
701
395
  } else {
702
- let memo = e.memo || getHolidayDescription(e);
396
+ let memo = e.memo || restApi.getHolidayDescription(e);
703
397
 
704
398
  if (!memo && typeof e.linkedEvent !== 'undefined') {
705
399
  memo = e.linkedEvent.render(options.locale);
@@ -735,7 +429,7 @@ async function eventsToIcalendar(events, options) {
735
429
  opts.dtstamp = opts.dtstamp || IcalEvent.makeDtstamp(new Date());
736
430
 
737
431
  if (!opts.title) {
738
- opts.title = getCalendarTitle(events, opts);
432
+ opts.title = restApi.getCalendarTitle(events, opts);
739
433
  }
740
434
 
741
435
  const icals = events.map(ev => new IcalEvent(ev, opts));
package/dist/index.mjs CHANGED
@@ -1,296 +1,10 @@
1
- /*! @hebcal/icalendar v4.15.1 */
1
+ /*! @hebcal/icalendar v4.15.4 */
2
2
  import { flags, Locale } from '@hebcal/core';
3
3
  import { murmur32HexSync } from 'murmurhash3';
4
- import * as leyn from '@hebcal/leyning';
4
+ import { shouldRenderBrief, pad2, getEventCategories, makeAnchor, pad4, getHolidayDescription, getCalendarTitle, appendIsraelAndTracking, makeTorahMemoText } from '@hebcal/rest-api';
5
5
  import { promises } from 'fs';
6
6
 
7
- /*! @hebcal/rest-api v3.12.0 */
8
-
9
- var Chanukah="Hanukkah, the Jewish festival of rededication. Also known as the Festival of Lights";var Pesach="Passover, the Feast of Unleavened Bread. Also called Chag HaMatzot (the Festival of Matzah), it commemorates the Exodus and freedom of the Israelites from ancient Egypt";var Purim="Celebration of Jewish deliverance as told by Megilat Esther. It commemorates a time when the Jewish people living in Persia were saved from extermination";var Shavuot="Festival of Weeks. Commemorates the giving of the Torah at Mount Sinai";var Sigd="Ethiopian Jewish holiday occurring 50 days after Yom Kippur";var Sukkot="Feast of Booths";var holidayDescription = {"Asara B'Tevet":"Fast commemorating the siege of Jerusalem",Chanukah:Chanukah,"Days of the Omer":"7 weeks from the second night of Pesach to the day before Shavuot","Lag BaOmer":"33rd day of counting the Omer","Leil Selichot":"Prayers for forgiveness in preparation for the High Holidays","Pesach Sheni":"Second Passover, one month after Passover",Pesach:Pesach,"Purim Katan":"Minor Purim celebration during Adar I on leap years",Purim:Purim,"Rosh Chodesh Nisan":"Start of month of Nisan on the Hebrew calendar. נִיסָן (transliterated Nisan or Nissan) is the 1st month of the Hebrew year, has 30 days, and corresponds to March or April on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Iyyar":"Start of month of Iyyar on the Hebrew calendar. אִיָיר (transliterated Iyyar or Iyar) is the 2nd month of the Hebrew year, has 29 days, and corresponds to April or May on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Sivan":"Start of month of Sivan on the Hebrew calendar. Sivan (סִיוָן) is the 3rd month of the Hebrew year, has 30 days, and corresponds to May or June on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Tamuz":"Start of month of Tamuz on the Hebrew calendar. תַּמּוּז (transliterated Tamuz or Tammuz) is the 4th month of the Hebrew year, has 29 days, and corresponds to June or July on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Av":"Start of month of Av on the Hebrew calendar. Av (אָב) is the 5th month of the Hebrew year, has 30 days, and corresponds to July or August on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Elul":"Start of month of Elul on the Hebrew calendar. Elul (אֱלוּל) is the 6th month of the Hebrew year, has 29 days, and corresponds to August or September on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Cheshvan":"Start of month of Cheshvan on the Hebrew calendar. חֶשְׁוָן (transliterated Cheshvan or Heshvan) is the 8th month of the Hebrew year, has 29 or 30 days, and corresponds to October or November on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Kislev":"Start of month of Kislev on the Hebrew calendar. Kislev (כִּסְלֵו) is the 9th month of the Hebrew year, has 30 or 29 days, and corresponds to November or December on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Tevet":"Start of month of Tevet on the Hebrew calendar. Tevet (טֵבֵת) is the 10th month of the Hebrew year, has 29 days, and corresponds to December or January on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Sh'vat":"Start of month of Sh'vat on the Hebrew calendar. שְׁבָט (transliterated Sh'vat or Shevat) is the 11th month of the Hebrew year, has 30 days, and corresponds to January or February on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Adar":"Start of month of Adar on the Hebrew calendar. Adar (אַדָר) is the 12th month of the Hebrew year, has 29 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Adar I":"Start of month of Adar I (on leap years) on the Hebrew calendar. Adar I (אַדָר א׳) is the 12th month of the Hebrew year, occurs only on leap years, has 30 days, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Chodesh Adar II":"Start of month of Adar II (on leap years) on the Hebrew calendar. Adar II (אַדָר ב׳), sometimes \"Adar Bet\" or \"Adar Sheni\", is the 13th month of the Hebrew year, has 29 days, occurs only on leap years, and corresponds to February or March on the Gregorian calendar. רֹאשׁ חוֹדֶשׁ, transliterated Rosh Chodesh or Rosh Hodesh, is a minor holiday that occurs at the beginning of every month in the Hebrew calendar. It is marked by the birth of a new moon","Rosh Hashana":"The Jewish New Year. Also spelled Rosh Hashanah","Rosh Hashana LaBehemot":"New Year for Tithing Animals","Shabbat Chazon":"Shabbat before Tish'a B'Av (Shabbat of Prophecy/Shabbat of Vision)","Shabbat HaChodesh":"Shabbat before Rosh Chodesh Nissan","Shabbat HaGadol":"Shabbat before Pesach","Shabbat Machar Chodesh":"When Shabbat falls the day before Rosh Chodesh","Shabbat Nachamu":"Shabbat after Tish'a B'Av (Shabbat of Consolation). The first of seven Shabbatot leading up to Rosh Hashanah. Named after the Haftarah (from Isaiah 40) which begins with the verse נַחֲמוּ נַחֲמוּ, עַמִּי (\"Comfort, oh comfort my people\")","Shabbat Parah":"Shabbat of the Red Heifer","Shabbat Rosh Chodesh":"When Shabbat falls on Rosh Chodesh","Shabbat Shekalim":"Shabbat before Rosh Chodesh Adar","Shabbat Shirah":"Shabbat of Song","Shabbat Shuva":"Shabbat that falls between Rosh Hashanah and Yom Kippur (Shabbat of Returning)","Shabbat Zachor":"Shabbat before Purim",Shavuot:Shavuot,"Shmini Atzeret":"Eighth Day of Assembly","Shushan Purim":"Purim celebrated in Jerusalem and walled cities",Sigd:Sigd,"Simchat Torah":"Day of Celebrating the Torah",Sukkot:Sukkot,"Ta'anit Bechorot":"Fast of the First Born","Ta'anit Esther":"Fast of Esther","Tish'a B'Av":"The Ninth of Av. Fast commemorating the destruction of the two Temples","Tu B'Av":"Minor Jewish holiday of love. Observed on the 15th day of the Hebrew month of Av","Tu BiShvat":"New Year for Trees","Tzom Gedaliah":"Fast of the Seventh Month. Commemorates the assassination of the Jewish governor of Judah","Tzom Tammuz":"Fast commemorating breaching of the walls of Jerusalem before the destruction of the Second Temple","Yom HaAliyah":"Recognizes Aliyah, immigration to the Jewish State of Israel","Yom HaAliyah School Observance":"Aliyah Day observed in Israeli schools","Yom HaAtzma'ut":"Israeli Independence Day. Commemorates the declaration of independence of Israel in 1948. Note that Hebcal displays modern holidays like Yom HaAtzma'ut according to the Israeli schedule. Although Yom HaAtzma'ut is normally observed on the 5th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaZikaron, which always precedes it) would conflict with Shabbat","Yom HaShoah":"Holocaust Memorial Day","Yom HaZikaron":"Israeli Memorial Day. Note that Hebcal displays modern holidays like Yom HaZikaron according to the Israeli schedule. Although Yom Hazikaron is normally observed on the 4th of Iyyar, it may be moved earlier or postponed if observance of the holiday (or Yom HaAtzma'ut, which always follows it) would conflict with Shabbat","Yom Kippur":"Day of Atonement","Yom Yerushalayim":"Jerusalem Day. Commemorates the re-unification of Jerusalem in 1967"};
10
-
11
- /**
12
- * Helper function to transform a string to make it more usable in a URL or filename.
13
- * Converts to lowercase and replaces non-word characters with hyphen ('-').
14
- * @example
15
- * makeAnchor('Rosh Chodesh Adar II') // 'rosh-chodesh-adar-ii'
16
- * @param {string} s
17
- * @return {string}
18
- */
19
-
20
- function makeAnchor(s) {
21
- return s.toLowerCase().replace(/'/g, '').replace(/[^\w]/g, '-').replace(/-+/g, '-').replace(/^-/g, '').replace(/-$/g, '');
22
- }
23
- /**
24
- * @param {number} number
25
- * @return {string}
26
- */
27
-
28
- function pad2(number) {
29
- if (number < 10) {
30
- return '0' + number;
31
- }
32
-
33
- return String(number);
34
- }
35
- /**
36
- * @param {number} number
37
- * @return {string}
38
- */
39
-
40
- function pad4(number) {
41
- if (number < 0) {
42
- return '-00' + pad4(-number);
43
- } else if (number < 10) {
44
- return '000' + number;
45
- } else if (number < 100) {
46
- return '00' + number;
47
- } else if (number < 1000) {
48
- return '0' + number;
49
- }
50
-
51
- return String(number);
52
- }
53
- /**
54
- * Returns a category and subcategory name
55
- * @param {Event} ev
56
- * @return {string[]}
57
- */
58
-
59
- function getEventCategories(ev) {
60
- const desc = ev.getDesc(); // since these use flags.MINOR_FAST or flags.MAJOR_FAST, check description first
61
-
62
- if (desc === 'Fast begins' || desc === 'Fast ends') {
63
- return ['zmanim', 'fast'];
64
- }
65
-
66
- switch (ev.getFlags()) {
67
- case flags.OMER_COUNT:
68
- return ['omer'];
69
-
70
- case flags.HEBREW_DATE:
71
- return ['hebdate'];
72
-
73
- case flags.PARSHA_HASHAVUA:
74
- return ['parashat'];
75
- // backwards-compat
76
-
77
- case flags.DAF_YOMI:
78
- return ['dafyomi'];
79
-
80
- case flags.ROSH_CHODESH:
81
- return ['roshchodesh'];
82
-
83
- case flags.SPECIAL_SHABBAT:
84
- return ['holiday', 'shabbat'];
85
-
86
- case flags.MINOR_FAST:
87
- return ['holiday', 'fast'];
88
-
89
- case flags.MAJOR_FAST:
90
- return ['holiday', 'fast', 'major'];
91
-
92
- case flags.MODERN_HOLIDAY:
93
- return ['holiday', 'modern'];
94
-
95
- case flags.SHABBAT_MEVARCHIM:
96
- return ['mevarchim'];
97
-
98
- case flags.MOLAD:
99
- return ['molad'];
100
-
101
- case flags.USER_EVENT:
102
- return ['user'];
103
-
104
- case flags.MINOR_HOLIDAY:
105
- return ['holiday', 'minor'];
106
-
107
- case flags.MISHNA_YOMI:
108
- return ['mishnayomi'];
109
- // fall through to string-based category
110
- }
111
-
112
- if (ev.cholHaMoedDay) {
113
- return ['holiday', 'major', 'cholhamoed'];
114
- }
115
-
116
- switch (desc) {
117
- case 'Havdalah':
118
- return ['havdalah'];
119
-
120
- case 'Candle lighting':
121
- return ['candles'];
122
-
123
- case 'Lag BaOmer':
124
- case 'Leil Selichot':
125
- case 'Pesach Sheni':
126
- case 'Erev Purim':
127
- case 'Purim Katan':
128
- case 'Shushan Purim':
129
- case 'Tu B\'Av':
130
- case 'Tu BiShvat':
131
- case 'Rosh Hashana LaBehemot':
132
- return ['holiday', 'minor'];
133
-
134
- case 'Erev Tish\'a B\'Av':
135
- return ['holiday', 'fast', 'major'];
136
-
137
- default:
138
- return ['holiday', 'major'];
139
- }
140
- }
141
- /**
142
- * Generates a title like "Hebcal 2020 Israel" or "Hebcal May 1993 Providence"
143
- * @param {Event[]} events
144
- * @param {HebrewCalendar.Options} options
145
- * @return {string}
146
- */
147
-
148
- function getCalendarTitle(events, options) {
149
- let title = 'Hebcal';
150
- const location = options.location;
151
-
152
- if (options.yahrzeit) {
153
- title += ' Yahrzeits and Anniversaries';
154
- } else if (location && location.name) {
155
- const comma = location.name.indexOf(',');
156
- const name = comma == -1 ? location.name : location.name.substring(0, comma);
157
- title += ' ' + name;
158
- } else if (options.il) {
159
- title += ' Israel';
160
- } else {
161
- title += ' Diaspora';
162
- }
163
-
164
- if (options.subscribe == '1') {
165
- return title;
166
- }
167
-
168
- if (options.isHebrewYear || events.length == 0) {
169
- title += ' ' + options.year;
170
- } else {
171
- const start = events[0].getDate().greg();
172
- const end = events[events.length - 1].getDate().greg();
173
-
174
- if (start.getFullYear() != end.getFullYear()) {
175
- title += ' ' + start.getFullYear() + '-' + end.getFullYear();
176
- } else if (start.getMonth() == end.getMonth()) {
177
- const monthFormat = new Intl.DateTimeFormat('en-US', {
178
- month: 'long'
179
- });
180
- const startMonth = monthFormat.format(start);
181
- title += ' ' + startMonth + ' ' + start.getFullYear();
182
- } else {
183
- title += ' ' + start.getFullYear();
184
- }
185
- }
186
-
187
- return title;
188
- }
189
- /**
190
- * Returns an English language description of the holiday
191
- * @param {Event} ev
192
- * @param {boolean} [firstSentence=false]
193
- * @return {string}
194
- */
195
-
196
- function getHolidayDescription(ev, firstSentence = false) {
197
- const str = holidayDescription[ev.getDesc()] || holidayDescription[ev.basename()] || '';
198
-
199
- if (firstSentence && str) {
200
- const dot = str.indexOf('.');
201
-
202
- if (dot != -1) {
203
- return str.substring(0, dot);
204
- }
205
- }
206
-
207
- return str;
208
- }
209
- const HOLIDAY_IGNORE_MASK$1 = flags.DAF_YOMI | flags.OMER_COUNT | flags.SHABBAT_MEVARCHIM | flags.MOLAD | flags.USER_EVENT | flags.HEBREW_DATE;
210
- /**
211
- * Makes mulit-line text that summarizes Torah & Haftarah
212
- * @param {Event} ev
213
- * @param {boolean} il
214
- * @return {string}
215
- */
216
-
217
- function makeTorahMemoText(ev, il) {
218
- const mask = ev.getFlags();
219
-
220
- if (mask & HOLIDAY_IGNORE_MASK$1) {
221
- return '';
222
- }
223
-
224
- const reading = mask & flags.PARSHA_HASHAVUA ? leyn.getLeyningForParshaHaShavua(ev, il) : leyn.getLeyningForHoliday(ev, il);
225
- let memo = '';
226
-
227
- if (reading && (reading.summary || reading.haftara)) {
228
- if (reading.summary) {
229
- memo += `Torah: ${reading.summary}`;
230
- }
231
-
232
- if (reading.summary && reading.haftara) {
233
- memo += '\n';
234
- }
235
-
236
- if (reading.haftara) {
237
- memo += 'Haftarah: ' + reading.haftara;
238
-
239
- if (reading.reason && reading.reason.haftara) {
240
- memo += ' | ' + reading.reason.haftara;
241
- }
242
- }
243
- }
244
-
245
- if (reading && reading.sephardic) {
246
- memo += '\nHaftarah for Sephardim: ' + reading.sephardic;
247
- }
248
-
249
- return memo;
250
- }
251
- /**
252
- * Appends utm_source and utm_medium parameters to a URL
253
- * @param {string} url
254
- * @param {boolean} il
255
- * @param {string} utmSource
256
- * @param {string} utmMedium
257
- * @param {string} utmCampaign
258
- * @return {string}
259
- */
260
-
261
- function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
262
- if (url.substring(0, 22) !== 'https://www.hebcal.com') {
263
- utmSource = 'hebcal.com';
264
- } else if (il && url.indexOf('?') === -1) {
265
- url += '?i=on';
266
- }
267
-
268
- const sep = url.indexOf('?') === -1 ? '?' : '&';
269
- const utm = `utm_source=${utmSource}&utm_medium=${utmMedium}`;
270
- const campaign = utmCampaign ? `&utm_campaign=${utmCampaign}` : '';
271
- return url + sep + utm + campaign;
272
- }
273
- /**
274
- * @private
275
- * @param {Event} ev
276
- * @return {boolean}
277
- */
278
-
279
- function shouldRenderBrief(ev) {
280
- if (typeof ev.eventTime !== 'undefined') return true;
281
- const mask = ev.getFlags();
282
-
283
- if (mask & flags.HEBREW_DATE) {
284
- const hd = ev.getDate();
285
- return hd.getDate() === 1 ? false : true;
286
- } else if (mask & flags.DAF_YOMI) {
287
- return true;
288
- } else {
289
- return false;
290
- }
291
- }
292
-
293
- var version="4.15.1";
7
+ var version="4.15.4";
294
8
 
295
9
  const VTIMEZONE = {};
296
10
  const CATEGORY = {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/icalendar",
3
- "version": "4.15.1",
3
+ "version": "4.15.4",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "ical",
@@ -24,8 +24,8 @@
24
24
  "url": "https://github.com/hebcal/hebcal-icalendar/issues"
25
25
  },
26
26
  "dependencies": {
27
- "@hebcal/core": "^3.33.2",
28
- "@hebcal/rest-api": "^3.12.0",
27
+ "@hebcal/core": "^3.33.3",
28
+ "@hebcal/rest-api": "^3.13.0",
29
29
  "murmurhash3": "^0.5.0"
30
30
  },
31
31
  "scripts": {
@@ -48,18 +48,18 @@
48
48
  "verbose": true
49
49
  },
50
50
  "devDependencies": {
51
- "@babel/core": "^7.17.3",
51
+ "@babel/core": "^7.17.5",
52
52
  "@babel/preset-env": "^7.16.11",
53
53
  "@babel/register": "^7.17.0",
54
- "@rollup/plugin-babel": "^5.3.0",
55
- "@rollup/plugin-commonjs": "^21.0.1",
54
+ "@rollup/plugin-babel": "^5.3.1",
55
+ "@rollup/plugin-commonjs": "^21.0.2",
56
56
  "@rollup/plugin-json": "^4.1.0",
57
57
  "@rollup/plugin-node-resolve": "^13.1.3",
58
- "ava": "^4.0.1",
59
- "eslint": "^8.9.0",
58
+ "ava": "^4.1.0",
59
+ "eslint": "^8.10.0",
60
60
  "eslint-config-google": "^0.14.0",
61
61
  "jsdoc": "^3.6.10",
62
62
  "jsdoc-to-markdown": "^7.1.1",
63
- "rollup": "^2.67.2"
63
+ "rollup": "^2.70.0"
64
64
  }
65
65
  }