@hebcal/icalendar 4.15.0 → 4.15.3

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.
Files changed (3) hide show
  1. package/dist/index.js +36 -461
  2. package/dist/index.mjs +27 -432
  3. package/package.json +13 -21
package/dist/index.js CHANGED
@@ -1,460 +1,14 @@
1
- /*! @hebcal/icalendar v4.15.0 */
1
+ /*! @hebcal/icalendar v4.15.3 */
2
2
  'use strict';
3
3
 
4
4
  Object.defineProperty(exports, '__esModule', { value: true });
5
5
 
6
6
  var core = require('@hebcal/core');
7
- var leyn = require('@hebcal/leyning');
7
+ var murmurhash3 = require('murmurhash3');
8
+ var restApi = require('@hebcal/rest-api');
8
9
  var fs = require('fs');
9
10
 
10
- function _interopNamespace(e) {
11
- if (e && e.__esModule) return e;
12
- var n = Object.create(null);
13
- if (e) {
14
- Object.keys(e).forEach(function (k) {
15
- if (k !== 'default') {
16
- var d = Object.getOwnPropertyDescriptor(e, k);
17
- Object.defineProperty(n, k, d.get ? d : {
18
- enumerable: true,
19
- get: function () { return e[k]; }
20
- });
21
- }
22
- });
23
- }
24
- n["default"] = e;
25
- return Object.freeze(n);
26
- }
27
-
28
- var leyn__namespace = /*#__PURE__*/_interopNamespace(leyn);
29
-
30
- var murmurhashJs = {exports: {}};
31
-
32
- var murmurhash3_gc = {exports: {}};
33
-
34
- /**
35
- * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
36
- *
37
- * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
38
- * @see http://github.com/garycourt/murmurhash-js
39
- * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
40
- * @see http://sites.google.com/site/murmurhash/
41
- *
42
- * @param {string} key ASCII only
43
- * @param {number} seed Positive integer only
44
- * @return {number} 32-bit positive integer hash
45
- */
46
-
47
- (function (module) {
48
- function murmurhash3_32_gc(key, seed) {
49
- var remainder, bytes, h1, h1b, c1, c2, k1, i;
50
-
51
- remainder = key.length & 3; // key.length % 4
52
- bytes = key.length - remainder;
53
- h1 = seed;
54
- c1 = 0xcc9e2d51;
55
- c2 = 0x1b873593;
56
- i = 0;
57
-
58
- while (i < bytes) {
59
- k1 =
60
- ((key.charCodeAt(i) & 0xff)) |
61
- ((key.charCodeAt(++i) & 0xff) << 8) |
62
- ((key.charCodeAt(++i) & 0xff) << 16) |
63
- ((key.charCodeAt(++i) & 0xff) << 24);
64
- ++i;
65
-
66
- k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;
67
- k1 = (k1 << 15) | (k1 >>> 17);
68
- k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;
69
-
70
- h1 ^= k1;
71
- h1 = (h1 << 13) | (h1 >>> 19);
72
- h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;
73
- h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));
74
- }
75
-
76
- k1 = 0;
77
-
78
- switch (remainder) {
79
- case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;
80
- case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;
81
- case 1: k1 ^= (key.charCodeAt(i) & 0xff);
82
-
83
- k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
84
- k1 = (k1 << 15) | (k1 >>> 17);
85
- k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;
86
- h1 ^= k1;
87
- }
88
-
89
- h1 ^= key.length;
90
-
91
- h1 ^= h1 >>> 16;
92
- h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
93
- h1 ^= h1 >>> 13;
94
- h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
95
- h1 ^= h1 >>> 16;
96
-
97
- return h1 >>> 0;
98
- }
99
-
100
- {
101
- module.exports = murmurhash3_32_gc;
102
- }
103
- }(murmurhash3_gc));
104
-
105
- var murmurhash2_gc = {exports: {}};
106
-
107
- /**
108
- * JS Implementation of MurmurHash2
109
- *
110
- * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
111
- * @see http://github.com/garycourt/murmurhash-js
112
- * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
113
- * @see http://sites.google.com/site/murmurhash/
114
- *
115
- * @param {string} str ASCII only
116
- * @param {number} seed Positive integer only
117
- * @return {number} 32-bit positive integer hash
118
- */
119
-
120
- (function (module) {
121
- function murmurhash2_32_gc(str, seed) {
122
- var
123
- l = str.length,
124
- h = seed ^ l,
125
- i = 0,
126
- k;
127
-
128
- while (l >= 4) {
129
- k =
130
- ((str.charCodeAt(i) & 0xff)) |
131
- ((str.charCodeAt(++i) & 0xff) << 8) |
132
- ((str.charCodeAt(++i) & 0xff) << 16) |
133
- ((str.charCodeAt(++i) & 0xff) << 24);
134
-
135
- k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
136
- k ^= k >>> 24;
137
- k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
138
-
139
- h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;
140
-
141
- l -= 4;
142
- ++i;
143
- }
144
-
145
- switch (l) {
146
- case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
147
- case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
148
- case 1: h ^= (str.charCodeAt(i) & 0xff);
149
- h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
150
- }
151
-
152
- h ^= h >>> 13;
153
- h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
154
- h ^= h >>> 15;
155
-
156
- return h >>> 0;
157
- }
158
-
159
- {
160
- module.exports = murmurhash2_32_gc;
161
- }
162
- }(murmurhash2_gc));
163
-
164
- var murmur3 = murmurhash3_gc.exports;
165
- var murmur2 = murmurhash2_gc.exports;
166
-
167
- murmurhashJs.exports = murmur3;
168
- var murmur3_1 = murmurhashJs.exports.murmur3 = murmur3;
169
- murmurhashJs.exports.murmur2 = murmur2;
170
-
171
- /*! @hebcal/rest-api v3.12.0 */
172
-
173
- 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"};
174
-
175
- /**
176
- * Helper function to transform a string to make it more usable in a URL or filename.
177
- * Converts to lowercase and replaces non-word characters with hyphen ('-').
178
- * @example
179
- * makeAnchor('Rosh Chodesh Adar II') // 'rosh-chodesh-adar-ii'
180
- * @param {string} s
181
- * @return {string}
182
- */
183
-
184
- function makeAnchor(s) {
185
- return s.toLowerCase().replace(/'/g, '').replace(/[^\w]/g, '-').replace(/-+/g, '-').replace(/^-/g, '').replace(/-$/g, '');
186
- }
187
- /**
188
- * @param {number} number
189
- * @return {string}
190
- */
191
-
192
- function pad2(number) {
193
- if (number < 10) {
194
- return '0' + number;
195
- }
196
-
197
- return String(number);
198
- }
199
- /**
200
- * @param {number} number
201
- * @return {string}
202
- */
203
-
204
- function pad4(number) {
205
- if (number < 0) {
206
- return '-00' + pad4(-number);
207
- } else if (number < 10) {
208
- return '000' + number;
209
- } else if (number < 100) {
210
- return '00' + number;
211
- } else if (number < 1000) {
212
- return '0' + number;
213
- }
214
-
215
- return String(number);
216
- }
217
- /**
218
- * Returns a category and subcategory name
219
- * @param {Event} ev
220
- * @return {string[]}
221
- */
222
-
223
- function getEventCategories(ev) {
224
- const desc = ev.getDesc(); // since these use flags.MINOR_FAST or flags.MAJOR_FAST, check description first
225
-
226
- if (desc === 'Fast begins' || desc === 'Fast ends') {
227
- return ['zmanim', 'fast'];
228
- }
229
-
230
- switch (ev.getFlags()) {
231
- case core.flags.OMER_COUNT:
232
- return ['omer'];
233
-
234
- case core.flags.HEBREW_DATE:
235
- return ['hebdate'];
236
-
237
- case core.flags.PARSHA_HASHAVUA:
238
- return ['parashat'];
239
- // backwards-compat
240
-
241
- case core.flags.DAF_YOMI:
242
- return ['dafyomi'];
243
-
244
- case core.flags.ROSH_CHODESH:
245
- return ['roshchodesh'];
246
-
247
- case core.flags.SPECIAL_SHABBAT:
248
- return ['holiday', 'shabbat'];
249
-
250
- case core.flags.MINOR_FAST:
251
- return ['holiday', 'fast'];
252
-
253
- case core.flags.MAJOR_FAST:
254
- return ['holiday', 'fast', 'major'];
255
-
256
- case core.flags.MODERN_HOLIDAY:
257
- return ['holiday', 'modern'];
258
-
259
- case core.flags.SHABBAT_MEVARCHIM:
260
- return ['mevarchim'];
261
-
262
- case core.flags.MOLAD:
263
- return ['molad'];
264
-
265
- case core.flags.USER_EVENT:
266
- return ['user'];
267
-
268
- case core.flags.MINOR_HOLIDAY:
269
- return ['holiday', 'minor'];
270
-
271
- case core.flags.MISHNA_YOMI:
272
- return ['mishnayomi'];
273
- // fall through to string-based category
274
- }
275
-
276
- if (ev.cholHaMoedDay) {
277
- return ['holiday', 'major', 'cholhamoed'];
278
- }
279
-
280
- switch (desc) {
281
- case 'Havdalah':
282
- return ['havdalah'];
283
-
284
- case 'Candle lighting':
285
- return ['candles'];
286
-
287
- case 'Lag BaOmer':
288
- case 'Leil Selichot':
289
- case 'Pesach Sheni':
290
- case 'Erev Purim':
291
- case 'Purim Katan':
292
- case 'Shushan Purim':
293
- case 'Tu B\'Av':
294
- case 'Tu BiShvat':
295
- case 'Rosh Hashana LaBehemot':
296
- return ['holiday', 'minor'];
297
-
298
- case 'Erev Tish\'a B\'Av':
299
- return ['holiday', 'fast', 'major'];
300
-
301
- default:
302
- return ['holiday', 'major'];
303
- }
304
- }
305
- /**
306
- * Generates a title like "Hebcal 2020 Israel" or "Hebcal May 1993 Providence"
307
- * @param {Event[]} events
308
- * @param {HebrewCalendar.Options} options
309
- * @return {string}
310
- */
311
-
312
- function getCalendarTitle(events, options) {
313
- let title = 'Hebcal';
314
- const location = options.location;
315
-
316
- if (options.yahrzeit) {
317
- title += ' Yahrzeits and Anniversaries';
318
- } else if (location && location.name) {
319
- const comma = location.name.indexOf(',');
320
- const name = comma == -1 ? location.name : location.name.substring(0, comma);
321
- title += ' ' + name;
322
- } else if (options.il) {
323
- title += ' Israel';
324
- } else {
325
- title += ' Diaspora';
326
- }
327
-
328
- if (options.subscribe == '1') {
329
- return title;
330
- }
331
-
332
- if (options.isHebrewYear || events.length == 0) {
333
- title += ' ' + options.year;
334
- } else {
335
- const start = events[0].getDate().greg();
336
- const end = events[events.length - 1].getDate().greg();
337
-
338
- if (start.getFullYear() != end.getFullYear()) {
339
- title += ' ' + start.getFullYear() + '-' + end.getFullYear();
340
- } else if (start.getMonth() == end.getMonth()) {
341
- const monthFormat = new Intl.DateTimeFormat('en-US', {
342
- month: 'long'
343
- });
344
- const startMonth = monthFormat.format(start);
345
- title += ' ' + startMonth + ' ' + start.getFullYear();
346
- } else {
347
- title += ' ' + start.getFullYear();
348
- }
349
- }
350
-
351
- return title;
352
- }
353
- /**
354
- * Returns an English language description of the holiday
355
- * @param {Event} ev
356
- * @param {boolean} [firstSentence=false]
357
- * @return {string}
358
- */
359
-
360
- function getHolidayDescription(ev, firstSentence = false) {
361
- const str = holidayDescription[ev.getDesc()] || holidayDescription[ev.basename()] || '';
362
-
363
- if (firstSentence && str) {
364
- const dot = str.indexOf('.');
365
-
366
- if (dot != -1) {
367
- return str.substring(0, dot);
368
- }
369
- }
370
-
371
- return str;
372
- }
373
- 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;
374
- /**
375
- * Makes mulit-line text that summarizes Torah & Haftarah
376
- * @param {Event} ev
377
- * @param {boolean} il
378
- * @return {string}
379
- */
380
-
381
- function makeTorahMemoText(ev, il) {
382
- const mask = ev.getFlags();
383
-
384
- if (mask & HOLIDAY_IGNORE_MASK$1) {
385
- return '';
386
- }
387
-
388
- const reading = mask & core.flags.PARSHA_HASHAVUA ? leyn__namespace.getLeyningForParshaHaShavua(ev, il) : leyn__namespace.getLeyningForHoliday(ev, il);
389
- let memo = '';
390
-
391
- if (reading && (reading.summary || reading.haftara)) {
392
- if (reading.summary) {
393
- memo += `Torah: ${reading.summary}`;
394
- }
395
-
396
- if (reading.summary && reading.haftara) {
397
- memo += '\n';
398
- }
399
-
400
- if (reading.haftara) {
401
- memo += 'Haftarah: ' + reading.haftara;
402
-
403
- if (reading.reason && reading.reason.haftara) {
404
- memo += ' | ' + reading.reason.haftara;
405
- }
406
- }
407
- }
408
-
409
- if (reading && reading.sephardic) {
410
- memo += '\nHaftarah for Sephardim: ' + reading.sephardic;
411
- }
412
-
413
- return memo;
414
- }
415
- /**
416
- * Appends utm_source and utm_medium parameters to a URL
417
- * @param {string} url
418
- * @param {boolean} il
419
- * @param {string} utmSource
420
- * @param {string} utmMedium
421
- * @param {string} utmCampaign
422
- * @return {string}
423
- */
424
-
425
- function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
426
- if (url.substring(0, 22) !== 'https://www.hebcal.com') {
427
- utmSource = 'hebcal.com';
428
- } else if (il && url.indexOf('?') === -1) {
429
- url += '?i=on';
430
- }
431
-
432
- const sep = url.indexOf('?') === -1 ? '?' : '&';
433
- const utm = `utm_source=${utmSource}&utm_medium=${utmMedium}`;
434
- const campaign = utmCampaign ? `&utm_campaign=${utmCampaign}` : '';
435
- return url + sep + utm + campaign;
436
- }
437
- /**
438
- * @private
439
- * @param {Event} ev
440
- * @return {boolean}
441
- */
442
-
443
- function shouldRenderBrief(ev) {
444
- if (typeof ev.eventTime !== 'undefined') return true;
445
- const mask = ev.getFlags();
446
-
447
- if (mask & core.flags.HEBREW_DATE) {
448
- const hd = ev.getDate();
449
- return hd.getDate() === 1 ? false : true;
450
- } else if (mask & core.flags.DAF_YOMI) {
451
- return true;
452
- } else {
453
- return false;
454
- }
455
- }
456
-
457
- var version="4.15.0";
11
+ var version="4.15.3";
458
12
 
459
13
  const VTIMEZONE = {};
460
14
  const CATEGORY = {
@@ -501,7 +55,29 @@ function appendTrackingToUrl(url, options) {
501
55
  const utmSource = options.utmSource || 'js';
502
56
  const utmMedium = options.utmMedium || 'icalendar';
503
57
  const utmCampaign = options.utmCampaign;
504
- return appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
58
+ const u = new URL(url);
59
+
60
+ if (utmCampaign && utmCampaign.startsWith('ical-') && u.host === 'www.hebcal.com') {
61
+ u.host = 'hebcal.com';
62
+ const path = u.pathname;
63
+
64
+ if (path.startsWith('/holidays/')) {
65
+ u.pathname = '/h/' + path.substring(10);
66
+ } else if (path.startsWith('/sedrot/')) {
67
+ u.pathname = '/s/' + path.substring(8);
68
+ } else {
69
+ return restApi.appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
70
+ }
71
+
72
+ if (options.il) {
73
+ u.searchParams.set('i', 'on');
74
+ }
75
+
76
+ u.searchParams.set('uc', utmCampaign);
77
+ return u.toString();
78
+ }
79
+
80
+ return restApi.appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
505
81
  }
506
82
 
507
83
  const encoder = new TextEncoder();
@@ -522,7 +98,7 @@ class IcalEvent {
522
98
  this.dtstamp = options.dtstamp || IcalEvent.makeDtstamp(new Date());
523
99
  const timed = this.timed = Boolean(ev.eventTime);
524
100
  const locale = options.locale;
525
- let subj = shouldRenderBrief(ev) ? ev.renderBrief(locale) : ev.render(locale);
101
+ let subj = restApi.shouldRenderBrief(ev) ? ev.renderBrief(locale) : ev.render(locale);
526
102
  const mask = ev.getFlags();
527
103
 
528
104
  if (ev.locationName) {
@@ -546,7 +122,7 @@ class IcalEvent {
546
122
  let [hour, minute] = ev.eventTimeStr.split(':');
547
123
  hour = +hour;
548
124
  minute = +minute;
549
- this.startDate += 'T' + pad2(hour) + pad2(minute) + '00';
125
+ this.startDate += 'T' + restApi.pad2(hour) + restApi.pad2(minute) + '00';
550
126
  this.endDate = this.startDate;
551
127
 
552
128
  if (options.location && options.location.tzid) {
@@ -597,24 +173,23 @@ class IcalEvent {
597
173
  this.alarm = '-P0DT0H10M0S'; // ten minutes
598
174
  }
599
175
 
600
- this.category = ev.category || CATEGORY[getEventCategories(ev)[0]];
176
+ this.category = ev.category || CATEGORY[restApi.getEventCategories(ev)[0]];
601
177
  }
602
178
  /**
603
- * @private
604
179
  * @return {string}
605
180
  */
606
181
 
607
182
 
608
183
  getUid() {
609
184
  const options = this.options;
610
- const digest = murmur3_1(this.ev.getDesc()).toString(16);
185
+ const digest = murmurhash3.murmur32HexSync(this.ev.getDesc());
611
186
  let uid = `hebcal-${this.startDate}-${digest}`;
612
187
 
613
188
  if (this.timed && options.location) {
614
189
  if (options.location.geoid) {
615
190
  uid += `-${options.location.geoid}`;
616
191
  } else if (options.location.name) {
617
- uid += '-' + makeAnchor(options.location.name);
192
+ uid += '-' + restApi.makeAnchor(options.location.name);
618
193
  }
619
194
  }
620
195
 
@@ -751,7 +326,7 @@ class IcalEvent {
751
326
 
752
327
 
753
328
  static formatYYYYMMDD(dt) {
754
- return pad4(dt.getFullYear()) + pad2(dt.getMonth() + 1) + pad2(dt.getDate());
329
+ return restApi.pad4(dt.getFullYear()) + restApi.pad2(dt.getMonth() + 1) + restApi.pad2(dt.getDate());
755
330
  }
756
331
  /**
757
332
  * Returns UTC string for iCalendar
@@ -808,7 +383,7 @@ function makeTorahMemo(ev, il) {
808
383
  return memo;
809
384
  }
810
385
 
811
- memo = makeTorahMemoText(ev, il).replace(/\n/g, '\\n');
386
+ memo = restApi.makeTorahMemoText(ev, il).replace(/\n/g, '\\n');
812
387
  torahMemoCache.set(key, memo);
813
388
  return memo;
814
389
  }
@@ -840,7 +415,7 @@ function createMemo(e, options) {
840
415
  if (mask & core.flags.PARSHA_HASHAVUA) {
841
416
  return torahMemo + '\\n\\n' + url;
842
417
  } else {
843
- let memo = e.memo || getHolidayDescription(e);
418
+ let memo = e.memo || restApi.getHolidayDescription(e);
844
419
 
845
420
  if (!memo && typeof e.linkedEvent !== 'undefined') {
846
421
  memo = e.linkedEvent.render(options.locale);
@@ -876,7 +451,7 @@ async function eventsToIcalendar(events, options) {
876
451
  opts.dtstamp = opts.dtstamp || IcalEvent.makeDtstamp(new Date());
877
452
 
878
453
  if (!opts.title) {
879
- opts.title = getCalendarTitle(events, opts);
454
+ opts.title = restApi.getCalendarTitle(events, opts);
880
455
  }
881
456
 
882
457
  const icals = events.map(ev => new IcalEvent(ev, opts));
package/dist/index.mjs CHANGED
@@ -1,436 +1,10 @@
1
- /*! @hebcal/icalendar v4.15.0 */
1
+ /*! @hebcal/icalendar v4.15.3 */
2
2
  import { flags, Locale } from '@hebcal/core';
3
- import * as leyn from '@hebcal/leyning';
3
+ import { murmur32HexSync } from 'murmurhash3';
4
+ import { shouldRenderBrief, pad2, getEventCategories, makeAnchor, pad4, getHolidayDescription, getCalendarTitle, appendIsraelAndTracking, makeTorahMemoText } from '@hebcal/rest-api';
4
5
  import { promises } from 'fs';
5
6
 
6
- var murmurhashJs = {exports: {}};
7
-
8
- var murmurhash3_gc = {exports: {}};
9
-
10
- /**
11
- * JS Implementation of MurmurHash3 (r136) (as of May 20, 2011)
12
- *
13
- * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
14
- * @see http://github.com/garycourt/murmurhash-js
15
- * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
16
- * @see http://sites.google.com/site/murmurhash/
17
- *
18
- * @param {string} key ASCII only
19
- * @param {number} seed Positive integer only
20
- * @return {number} 32-bit positive integer hash
21
- */
22
-
23
- (function (module) {
24
- function murmurhash3_32_gc(key, seed) {
25
- var remainder, bytes, h1, h1b, c1, c2, k1, i;
26
-
27
- remainder = key.length & 3; // key.length % 4
28
- bytes = key.length - remainder;
29
- h1 = seed;
30
- c1 = 0xcc9e2d51;
31
- c2 = 0x1b873593;
32
- i = 0;
33
-
34
- while (i < bytes) {
35
- k1 =
36
- ((key.charCodeAt(i) & 0xff)) |
37
- ((key.charCodeAt(++i) & 0xff) << 8) |
38
- ((key.charCodeAt(++i) & 0xff) << 16) |
39
- ((key.charCodeAt(++i) & 0xff) << 24);
40
- ++i;
41
-
42
- k1 = ((((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16))) & 0xffffffff;
43
- k1 = (k1 << 15) | (k1 >>> 17);
44
- k1 = ((((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16))) & 0xffffffff;
45
-
46
- h1 ^= k1;
47
- h1 = (h1 << 13) | (h1 >>> 19);
48
- h1b = ((((h1 & 0xffff) * 5) + ((((h1 >>> 16) * 5) & 0xffff) << 16))) & 0xffffffff;
49
- h1 = (((h1b & 0xffff) + 0x6b64) + ((((h1b >>> 16) + 0xe654) & 0xffff) << 16));
50
- }
51
-
52
- k1 = 0;
53
-
54
- switch (remainder) {
55
- case 3: k1 ^= (key.charCodeAt(i + 2) & 0xff) << 16;
56
- case 2: k1 ^= (key.charCodeAt(i + 1) & 0xff) << 8;
57
- case 1: k1 ^= (key.charCodeAt(i) & 0xff);
58
-
59
- k1 = (((k1 & 0xffff) * c1) + ((((k1 >>> 16) * c1) & 0xffff) << 16)) & 0xffffffff;
60
- k1 = (k1 << 15) | (k1 >>> 17);
61
- k1 = (((k1 & 0xffff) * c2) + ((((k1 >>> 16) * c2) & 0xffff) << 16)) & 0xffffffff;
62
- h1 ^= k1;
63
- }
64
-
65
- h1 ^= key.length;
66
-
67
- h1 ^= h1 >>> 16;
68
- h1 = (((h1 & 0xffff) * 0x85ebca6b) + ((((h1 >>> 16) * 0x85ebca6b) & 0xffff) << 16)) & 0xffffffff;
69
- h1 ^= h1 >>> 13;
70
- h1 = ((((h1 & 0xffff) * 0xc2b2ae35) + ((((h1 >>> 16) * 0xc2b2ae35) & 0xffff) << 16))) & 0xffffffff;
71
- h1 ^= h1 >>> 16;
72
-
73
- return h1 >>> 0;
74
- }
75
-
76
- {
77
- module.exports = murmurhash3_32_gc;
78
- }
79
- }(murmurhash3_gc));
80
-
81
- var murmurhash2_gc = {exports: {}};
82
-
83
- /**
84
- * JS Implementation of MurmurHash2
85
- *
86
- * @author <a href="mailto:gary.court@gmail.com">Gary Court</a>
87
- * @see http://github.com/garycourt/murmurhash-js
88
- * @author <a href="mailto:aappleby@gmail.com">Austin Appleby</a>
89
- * @see http://sites.google.com/site/murmurhash/
90
- *
91
- * @param {string} str ASCII only
92
- * @param {number} seed Positive integer only
93
- * @return {number} 32-bit positive integer hash
94
- */
95
-
96
- (function (module) {
97
- function murmurhash2_32_gc(str, seed) {
98
- var
99
- l = str.length,
100
- h = seed ^ l,
101
- i = 0,
102
- k;
103
-
104
- while (l >= 4) {
105
- k =
106
- ((str.charCodeAt(i) & 0xff)) |
107
- ((str.charCodeAt(++i) & 0xff) << 8) |
108
- ((str.charCodeAt(++i) & 0xff) << 16) |
109
- ((str.charCodeAt(++i) & 0xff) << 24);
110
-
111
- k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
112
- k ^= k >>> 24;
113
- k = (((k & 0xffff) * 0x5bd1e995) + ((((k >>> 16) * 0x5bd1e995) & 0xffff) << 16));
114
-
115
- h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16)) ^ k;
116
-
117
- l -= 4;
118
- ++i;
119
- }
120
-
121
- switch (l) {
122
- case 3: h ^= (str.charCodeAt(i + 2) & 0xff) << 16;
123
- case 2: h ^= (str.charCodeAt(i + 1) & 0xff) << 8;
124
- case 1: h ^= (str.charCodeAt(i) & 0xff);
125
- h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
126
- }
127
-
128
- h ^= h >>> 13;
129
- h = (((h & 0xffff) * 0x5bd1e995) + ((((h >>> 16) * 0x5bd1e995) & 0xffff) << 16));
130
- h ^= h >>> 15;
131
-
132
- return h >>> 0;
133
- }
134
-
135
- {
136
- module.exports = murmurhash2_32_gc;
137
- }
138
- }(murmurhash2_gc));
139
-
140
- var murmur3 = murmurhash3_gc.exports;
141
- var murmur2 = murmurhash2_gc.exports;
142
-
143
- murmurhashJs.exports = murmur3;
144
- var murmur3_1 = murmurhashJs.exports.murmur3 = murmur3;
145
- murmurhashJs.exports.murmur2 = murmur2;
146
-
147
- /*! @hebcal/rest-api v3.12.0 */
148
-
149
- 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"};
150
-
151
- /**
152
- * Helper function to transform a string to make it more usable in a URL or filename.
153
- * Converts to lowercase and replaces non-word characters with hyphen ('-').
154
- * @example
155
- * makeAnchor('Rosh Chodesh Adar II') // 'rosh-chodesh-adar-ii'
156
- * @param {string} s
157
- * @return {string}
158
- */
159
-
160
- function makeAnchor(s) {
161
- return s.toLowerCase().replace(/'/g, '').replace(/[^\w]/g, '-').replace(/-+/g, '-').replace(/^-/g, '').replace(/-$/g, '');
162
- }
163
- /**
164
- * @param {number} number
165
- * @return {string}
166
- */
167
-
168
- function pad2(number) {
169
- if (number < 10) {
170
- return '0' + number;
171
- }
172
-
173
- return String(number);
174
- }
175
- /**
176
- * @param {number} number
177
- * @return {string}
178
- */
179
-
180
- function pad4(number) {
181
- if (number < 0) {
182
- return '-00' + pad4(-number);
183
- } else if (number < 10) {
184
- return '000' + number;
185
- } else if (number < 100) {
186
- return '00' + number;
187
- } else if (number < 1000) {
188
- return '0' + number;
189
- }
190
-
191
- return String(number);
192
- }
193
- /**
194
- * Returns a category and subcategory name
195
- * @param {Event} ev
196
- * @return {string[]}
197
- */
198
-
199
- function getEventCategories(ev) {
200
- const desc = ev.getDesc(); // since these use flags.MINOR_FAST or flags.MAJOR_FAST, check description first
201
-
202
- if (desc === 'Fast begins' || desc === 'Fast ends') {
203
- return ['zmanim', 'fast'];
204
- }
205
-
206
- switch (ev.getFlags()) {
207
- case flags.OMER_COUNT:
208
- return ['omer'];
209
-
210
- case flags.HEBREW_DATE:
211
- return ['hebdate'];
212
-
213
- case flags.PARSHA_HASHAVUA:
214
- return ['parashat'];
215
- // backwards-compat
216
-
217
- case flags.DAF_YOMI:
218
- return ['dafyomi'];
219
-
220
- case flags.ROSH_CHODESH:
221
- return ['roshchodesh'];
222
-
223
- case flags.SPECIAL_SHABBAT:
224
- return ['holiday', 'shabbat'];
225
-
226
- case flags.MINOR_FAST:
227
- return ['holiday', 'fast'];
228
-
229
- case flags.MAJOR_FAST:
230
- return ['holiday', 'fast', 'major'];
231
-
232
- case flags.MODERN_HOLIDAY:
233
- return ['holiday', 'modern'];
234
-
235
- case flags.SHABBAT_MEVARCHIM:
236
- return ['mevarchim'];
237
-
238
- case flags.MOLAD:
239
- return ['molad'];
240
-
241
- case flags.USER_EVENT:
242
- return ['user'];
243
-
244
- case flags.MINOR_HOLIDAY:
245
- return ['holiday', 'minor'];
246
-
247
- case flags.MISHNA_YOMI:
248
- return ['mishnayomi'];
249
- // fall through to string-based category
250
- }
251
-
252
- if (ev.cholHaMoedDay) {
253
- return ['holiday', 'major', 'cholhamoed'];
254
- }
255
-
256
- switch (desc) {
257
- case 'Havdalah':
258
- return ['havdalah'];
259
-
260
- case 'Candle lighting':
261
- return ['candles'];
262
-
263
- case 'Lag BaOmer':
264
- case 'Leil Selichot':
265
- case 'Pesach Sheni':
266
- case 'Erev Purim':
267
- case 'Purim Katan':
268
- case 'Shushan Purim':
269
- case 'Tu B\'Av':
270
- case 'Tu BiShvat':
271
- case 'Rosh Hashana LaBehemot':
272
- return ['holiday', 'minor'];
273
-
274
- case 'Erev Tish\'a B\'Av':
275
- return ['holiday', 'fast', 'major'];
276
-
277
- default:
278
- return ['holiday', 'major'];
279
- }
280
- }
281
- /**
282
- * Generates a title like "Hebcal 2020 Israel" or "Hebcal May 1993 Providence"
283
- * @param {Event[]} events
284
- * @param {HebrewCalendar.Options} options
285
- * @return {string}
286
- */
287
-
288
- function getCalendarTitle(events, options) {
289
- let title = 'Hebcal';
290
- const location = options.location;
291
-
292
- if (options.yahrzeit) {
293
- title += ' Yahrzeits and Anniversaries';
294
- } else if (location && location.name) {
295
- const comma = location.name.indexOf(',');
296
- const name = comma == -1 ? location.name : location.name.substring(0, comma);
297
- title += ' ' + name;
298
- } else if (options.il) {
299
- title += ' Israel';
300
- } else {
301
- title += ' Diaspora';
302
- }
303
-
304
- if (options.subscribe == '1') {
305
- return title;
306
- }
307
-
308
- if (options.isHebrewYear || events.length == 0) {
309
- title += ' ' + options.year;
310
- } else {
311
- const start = events[0].getDate().greg();
312
- const end = events[events.length - 1].getDate().greg();
313
-
314
- if (start.getFullYear() != end.getFullYear()) {
315
- title += ' ' + start.getFullYear() + '-' + end.getFullYear();
316
- } else if (start.getMonth() == end.getMonth()) {
317
- const monthFormat = new Intl.DateTimeFormat('en-US', {
318
- month: 'long'
319
- });
320
- const startMonth = monthFormat.format(start);
321
- title += ' ' + startMonth + ' ' + start.getFullYear();
322
- } else {
323
- title += ' ' + start.getFullYear();
324
- }
325
- }
326
-
327
- return title;
328
- }
329
- /**
330
- * Returns an English language description of the holiday
331
- * @param {Event} ev
332
- * @param {boolean} [firstSentence=false]
333
- * @return {string}
334
- */
335
-
336
- function getHolidayDescription(ev, firstSentence = false) {
337
- const str = holidayDescription[ev.getDesc()] || holidayDescription[ev.basename()] || '';
338
-
339
- if (firstSentence && str) {
340
- const dot = str.indexOf('.');
341
-
342
- if (dot != -1) {
343
- return str.substring(0, dot);
344
- }
345
- }
346
-
347
- return str;
348
- }
349
- const HOLIDAY_IGNORE_MASK$1 = flags.DAF_YOMI | flags.OMER_COUNT | flags.SHABBAT_MEVARCHIM | flags.MOLAD | flags.USER_EVENT | flags.HEBREW_DATE;
350
- /**
351
- * Makes mulit-line text that summarizes Torah & Haftarah
352
- * @param {Event} ev
353
- * @param {boolean} il
354
- * @return {string}
355
- */
356
-
357
- function makeTorahMemoText(ev, il) {
358
- const mask = ev.getFlags();
359
-
360
- if (mask & HOLIDAY_IGNORE_MASK$1) {
361
- return '';
362
- }
363
-
364
- const reading = mask & flags.PARSHA_HASHAVUA ? leyn.getLeyningForParshaHaShavua(ev, il) : leyn.getLeyningForHoliday(ev, il);
365
- let memo = '';
366
-
367
- if (reading && (reading.summary || reading.haftara)) {
368
- if (reading.summary) {
369
- memo += `Torah: ${reading.summary}`;
370
- }
371
-
372
- if (reading.summary && reading.haftara) {
373
- memo += '\n';
374
- }
375
-
376
- if (reading.haftara) {
377
- memo += 'Haftarah: ' + reading.haftara;
378
-
379
- if (reading.reason && reading.reason.haftara) {
380
- memo += ' | ' + reading.reason.haftara;
381
- }
382
- }
383
- }
384
-
385
- if (reading && reading.sephardic) {
386
- memo += '\nHaftarah for Sephardim: ' + reading.sephardic;
387
- }
388
-
389
- return memo;
390
- }
391
- /**
392
- * Appends utm_source and utm_medium parameters to a URL
393
- * @param {string} url
394
- * @param {boolean} il
395
- * @param {string} utmSource
396
- * @param {string} utmMedium
397
- * @param {string} utmCampaign
398
- * @return {string}
399
- */
400
-
401
- function appendIsraelAndTracking(url, il, utmSource, utmMedium, utmCampaign) {
402
- if (url.substring(0, 22) !== 'https://www.hebcal.com') {
403
- utmSource = 'hebcal.com';
404
- } else if (il && url.indexOf('?') === -1) {
405
- url += '?i=on';
406
- }
407
-
408
- const sep = url.indexOf('?') === -1 ? '?' : '&';
409
- const utm = `utm_source=${utmSource}&utm_medium=${utmMedium}`;
410
- const campaign = utmCampaign ? `&utm_campaign=${utmCampaign}` : '';
411
- return url + sep + utm + campaign;
412
- }
413
- /**
414
- * @private
415
- * @param {Event} ev
416
- * @return {boolean}
417
- */
418
-
419
- function shouldRenderBrief(ev) {
420
- if (typeof ev.eventTime !== 'undefined') return true;
421
- const mask = ev.getFlags();
422
-
423
- if (mask & flags.HEBREW_DATE) {
424
- const hd = ev.getDate();
425
- return hd.getDate() === 1 ? false : true;
426
- } else if (mask & flags.DAF_YOMI) {
427
- return true;
428
- } else {
429
- return false;
430
- }
431
- }
432
-
433
- var version="4.15.0";
7
+ var version="4.15.3";
434
8
 
435
9
  const VTIMEZONE = {};
436
10
  const CATEGORY = {
@@ -477,6 +51,28 @@ function appendTrackingToUrl(url, options) {
477
51
  const utmSource = options.utmSource || 'js';
478
52
  const utmMedium = options.utmMedium || 'icalendar';
479
53
  const utmCampaign = options.utmCampaign;
54
+ const u = new URL(url);
55
+
56
+ if (utmCampaign && utmCampaign.startsWith('ical-') && u.host === 'www.hebcal.com') {
57
+ u.host = 'hebcal.com';
58
+ const path = u.pathname;
59
+
60
+ if (path.startsWith('/holidays/')) {
61
+ u.pathname = '/h/' + path.substring(10);
62
+ } else if (path.startsWith('/sedrot/')) {
63
+ u.pathname = '/s/' + path.substring(8);
64
+ } else {
65
+ return appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
66
+ }
67
+
68
+ if (options.il) {
69
+ u.searchParams.set('i', 'on');
70
+ }
71
+
72
+ u.searchParams.set('uc', utmCampaign);
73
+ return u.toString();
74
+ }
75
+
480
76
  return appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
481
77
  }
482
78
 
@@ -576,14 +172,13 @@ class IcalEvent {
576
172
  this.category = ev.category || CATEGORY[getEventCategories(ev)[0]];
577
173
  }
578
174
  /**
579
- * @private
580
175
  * @return {string}
581
176
  */
582
177
 
583
178
 
584
179
  getUid() {
585
180
  const options = this.options;
586
- const digest = murmur3_1(this.ev.getDesc()).toString(16);
181
+ const digest = murmur32HexSync(this.ev.getDesc());
587
182
  let uid = `hebcal-${this.startDate}-${digest}`;
588
183
 
589
184
  if (this.timed && options.location) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hebcal/icalendar",
3
- "version": "4.15.0",
3
+ "version": "4.15.3",
4
4
  "author": "Michael J. Radwin (https://github.com/mjradwin)",
5
5
  "keywords": [
6
6
  "ical",
@@ -24,8 +24,9 @@
24
24
  "url": "https://github.com/hebcal/hebcal-icalendar/issues"
25
25
  },
26
26
  "dependencies": {
27
- "@hebcal/core": "^3.33.1",
28
- "@hebcal/rest-api": "^3.12.0"
27
+ "@hebcal/core": "^3.33.3",
28
+ "@hebcal/rest-api": "^3.12.0",
29
+ "murmurhash3": "^0.5.0"
29
30
  },
30
31
  "scripts": {
31
32
  "build": "rollup -c",
@@ -43,31 +44,22 @@
43
44
  "@babel/register",
44
45
  "regenerator-runtime/runtime"
45
46
  ],
46
- "babel": {
47
- "testOptions": {
48
- "presets": [
49
- "@babel/env"
50
- ]
51
- }
52
- },
53
47
  "inherit": true,
54
48
  "verbose": true
55
49
  },
56
50
  "devDependencies": {
57
- "@ava/babel": "^2.0.0",
58
- "@babel/core": "^7.16.10",
51
+ "@babel/core": "^7.17.5",
59
52
  "@babel/preset-env": "^7.16.11",
60
- "@babel/register": "^7.16.9",
61
- "@rollup/plugin-babel": "^5.3.0",
62
- "@rollup/plugin-commonjs": "^21.0.1",
53
+ "@babel/register": "^7.17.0",
54
+ "@rollup/plugin-babel": "^5.3.1",
55
+ "@rollup/plugin-commonjs": "^21.0.2",
63
56
  "@rollup/plugin-json": "^4.1.0",
64
57
  "@rollup/plugin-node-resolve": "^13.1.3",
65
- "ava": "^3.15.0",
66
- "eslint": "^8.7.0",
58
+ "ava": "^4.0.1",
59
+ "eslint": "^8.10.0",
67
60
  "eslint-config-google": "^0.14.0",
68
- "jsdoc": "^3.6.7",
69
- "jsdoc-to-markdown": "^7.1.0",
70
- "murmurhash-js": "^1.0.0",
71
- "rollup": "^2.64.0"
61
+ "jsdoc": "^3.6.10",
62
+ "jsdoc-to-markdown": "^7.1.1",
63
+ "rollup": "^2.68.0"
72
64
  }
73
65
  }