@hebcal/icalendar 4.21.0 → 4.22.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +32 -30
- package/dist/index.mjs +32 -30
- package/package.json +12 -16
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
/*! @hebcal/icalendar v4.
|
|
1
|
+
/*! @hebcal/icalendar v4.22.0 */
|
|
2
2
|
'use strict';
|
|
3
3
|
|
|
4
4
|
var core = require('@hebcal/core');
|
|
@@ -6,7 +6,7 @@ var murmurhash3 = require('murmurhash3');
|
|
|
6
6
|
var restApi = require('@hebcal/rest-api');
|
|
7
7
|
var fs = require('fs');
|
|
8
8
|
|
|
9
|
-
const version="4.
|
|
9
|
+
const version="4.22.0";
|
|
10
10
|
|
|
11
11
|
const VTIMEZONE = {};
|
|
12
12
|
const CATEGORY = {
|
|
@@ -43,7 +43,7 @@ function addOptional(arr, key, val) {
|
|
|
43
43
|
/**
|
|
44
44
|
* @private
|
|
45
45
|
* @param {string} url
|
|
46
|
-
* @param {
|
|
46
|
+
* @param {CalOptions} options
|
|
47
47
|
* @return {string}
|
|
48
48
|
*/
|
|
49
49
|
function appendTrackingToUrl(url, options) {
|
|
@@ -65,7 +65,7 @@ class IcalEvent {
|
|
|
65
65
|
/**
|
|
66
66
|
* Builds an IcalEvent object from a Hebcal Event
|
|
67
67
|
* @param {Event} ev
|
|
68
|
-
* @param {
|
|
68
|
+
* @param {CalOptions} options
|
|
69
69
|
*/
|
|
70
70
|
constructor(ev, options = {}) {
|
|
71
71
|
this.ev = ev;
|
|
@@ -90,7 +90,7 @@ class IcalEvent {
|
|
|
90
90
|
this.locationName = core.Locale.gettext('Nach Yomi');
|
|
91
91
|
} else if (mask & core.flags.MISHNA_YOMI) {
|
|
92
92
|
this.locationName = core.Locale.gettext('Mishna Yomi');
|
|
93
|
-
} else if (timed && options.location
|
|
93
|
+
} else if (timed && options.location?.name) {
|
|
94
94
|
const comma = options.location.name.indexOf(',');
|
|
95
95
|
this.locationName = comma == -1 ? options.location.name : options.location.name.substring(0, comma);
|
|
96
96
|
}
|
|
@@ -105,7 +105,7 @@ class IcalEvent {
|
|
|
105
105
|
minute = +minute;
|
|
106
106
|
this.startDate += 'T' + restApi.pad2(hour) + restApi.pad2(minute) + '00';
|
|
107
107
|
this.endDate = this.startDate;
|
|
108
|
-
if (options.location
|
|
108
|
+
if (options.location?.tzid) {
|
|
109
109
|
this.dtargs = `;TZID=${options.location.tzid}`;
|
|
110
110
|
}
|
|
111
111
|
} else {
|
|
@@ -317,7 +317,7 @@ class IcalEvent {
|
|
|
317
317
|
/**
|
|
318
318
|
* Transforms a single Event into a VEVENT string
|
|
319
319
|
* @param {Event} ev
|
|
320
|
-
* @param {
|
|
320
|
+
* @param {CalOptions} options
|
|
321
321
|
* @return {string} multi-line result, delimited by \r\n
|
|
322
322
|
*/
|
|
323
323
|
function eventToIcal(ev, options) {
|
|
@@ -354,17 +354,17 @@ function makeTorahMemo(ev, il) {
|
|
|
354
354
|
/**
|
|
355
355
|
* @private
|
|
356
356
|
* @param {Event} e
|
|
357
|
-
* @param {
|
|
357
|
+
* @param {CalOptions} options
|
|
358
358
|
* @return {string}
|
|
359
359
|
*/
|
|
360
360
|
function createMemo(e, options) {
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
e.memo = e.memo.replace(/\n/g, '\\n');
|
|
361
|
+
let memo = e.memo;
|
|
362
|
+
if (typeof memo === 'string' && memo.length && memo.indexOf('\n') !== -1) {
|
|
363
|
+
memo = memo.replace(/\n/g, '\\n');
|
|
365
364
|
}
|
|
366
|
-
|
|
367
|
-
|
|
365
|
+
const desc = e.getDesc();
|
|
366
|
+
if (desc === 'Havdalah' || desc === 'Candle lighting') {
|
|
367
|
+
return memo || '';
|
|
368
368
|
}
|
|
369
369
|
const mask = e.getFlags();
|
|
370
370
|
if (mask & core.flags.OMER_COUNT) {
|
|
@@ -373,30 +373,32 @@ function createMemo(e, options) {
|
|
|
373
373
|
}
|
|
374
374
|
const url = appendTrackingToUrl(e.url(), options);
|
|
375
375
|
const torahMemo = makeTorahMemo(e, options.il);
|
|
376
|
-
if (
|
|
377
|
-
|
|
378
|
-
} else {
|
|
379
|
-
let memo = e.memo || restApi.getHolidayDescription(e);
|
|
380
|
-
if (!memo && typeof e.linkedEvent !== 'undefined') {
|
|
376
|
+
if (!memo) {
|
|
377
|
+
if (typeof e.linkedEvent !== 'undefined') {
|
|
381
378
|
memo = e.linkedEvent.render(options.locale);
|
|
379
|
+
} else {
|
|
380
|
+
memo = restApi.getHolidayDescription(e);
|
|
382
381
|
}
|
|
383
|
-
|
|
384
|
-
|
|
382
|
+
}
|
|
383
|
+
if (torahMemo) {
|
|
384
|
+
if (memo.length) {
|
|
385
|
+
memo += '\\n\\n';
|
|
385
386
|
}
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
memo +=
|
|
387
|
+
memo += torahMemo;
|
|
388
|
+
}
|
|
389
|
+
if (url) {
|
|
390
|
+
if (memo.length) {
|
|
391
|
+
memo += '\\n\\n';
|
|
391
392
|
}
|
|
392
|
-
|
|
393
|
+
memo += url;
|
|
393
394
|
}
|
|
395
|
+
return memo;
|
|
394
396
|
}
|
|
395
397
|
|
|
396
398
|
/**
|
|
397
399
|
* Generates an RFC 2445 iCalendar string from an array of events
|
|
398
400
|
* @param {Event[]} events
|
|
399
|
-
* @param {
|
|
401
|
+
* @param {CalOptions} options
|
|
400
402
|
* @return {Promise<string>}
|
|
401
403
|
*/
|
|
402
404
|
async function eventsToIcalendar(events, options) {
|
|
@@ -414,7 +416,7 @@ async function eventsToIcalendar(events, options) {
|
|
|
414
416
|
/**
|
|
415
417
|
* Generates an RFC 2445 iCalendar string from an array of IcalEvents
|
|
416
418
|
* @param {IcalEvent[]} icals
|
|
417
|
-
* @param {
|
|
419
|
+
* @param {CalOptions} options
|
|
418
420
|
* @return {Promise<string>}
|
|
419
421
|
*/
|
|
420
422
|
async function icalEventsToString(icals, options) {
|
|
@@ -444,7 +446,7 @@ async function icalEventsToString(icals, options) {
|
|
|
444
446
|
stream.push(`X-APPLE-CALENDAR-COLOR:${opts.calendarColor}\r\n`);
|
|
445
447
|
}
|
|
446
448
|
const location = opts.location;
|
|
447
|
-
if (location
|
|
449
|
+
if (location?.tzid) {
|
|
448
450
|
const tzid = location.tzid;
|
|
449
451
|
stream.push(`X-WR-TIMEZONE;VALUE=TEXT:${tzid}\r\n`);
|
|
450
452
|
if (VTIMEZONE[tzid]) {
|
package/dist/index.mjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
/*! @hebcal/icalendar v4.
|
|
1
|
+
/*! @hebcal/icalendar v4.22.0 */
|
|
2
2
|
import { flags, Locale, greg } from '@hebcal/core';
|
|
3
3
|
import { murmur32HexSync } from 'murmurhash3';
|
|
4
4
|
import { shouldRenderBrief, pad2, getEventCategories, makeAnchor, pad4, getHolidayDescription, getCalendarTitle, appendIsraelAndTracking, makeTorahMemoText } from '@hebcal/rest-api';
|
|
5
5
|
import { promises } from 'fs';
|
|
6
6
|
|
|
7
|
-
const version="4.
|
|
7
|
+
const version="4.22.0";
|
|
8
8
|
|
|
9
9
|
const VTIMEZONE = {};
|
|
10
10
|
const CATEGORY = {
|
|
@@ -41,7 +41,7 @@ function addOptional(arr, key, val) {
|
|
|
41
41
|
/**
|
|
42
42
|
* @private
|
|
43
43
|
* @param {string} url
|
|
44
|
-
* @param {
|
|
44
|
+
* @param {CalOptions} options
|
|
45
45
|
* @return {string}
|
|
46
46
|
*/
|
|
47
47
|
function appendTrackingToUrl(url, options) {
|
|
@@ -63,7 +63,7 @@ class IcalEvent {
|
|
|
63
63
|
/**
|
|
64
64
|
* Builds an IcalEvent object from a Hebcal Event
|
|
65
65
|
* @param {Event} ev
|
|
66
|
-
* @param {
|
|
66
|
+
* @param {CalOptions} options
|
|
67
67
|
*/
|
|
68
68
|
constructor(ev, options = {}) {
|
|
69
69
|
this.ev = ev;
|
|
@@ -88,7 +88,7 @@ class IcalEvent {
|
|
|
88
88
|
this.locationName = Locale.gettext('Nach Yomi');
|
|
89
89
|
} else if (mask & flags.MISHNA_YOMI) {
|
|
90
90
|
this.locationName = Locale.gettext('Mishna Yomi');
|
|
91
|
-
} else if (timed && options.location
|
|
91
|
+
} else if (timed && options.location?.name) {
|
|
92
92
|
const comma = options.location.name.indexOf(',');
|
|
93
93
|
this.locationName = comma == -1 ? options.location.name : options.location.name.substring(0, comma);
|
|
94
94
|
}
|
|
@@ -103,7 +103,7 @@ class IcalEvent {
|
|
|
103
103
|
minute = +minute;
|
|
104
104
|
this.startDate += 'T' + pad2(hour) + pad2(minute) + '00';
|
|
105
105
|
this.endDate = this.startDate;
|
|
106
|
-
if (options.location
|
|
106
|
+
if (options.location?.tzid) {
|
|
107
107
|
this.dtargs = `;TZID=${options.location.tzid}`;
|
|
108
108
|
}
|
|
109
109
|
} else {
|
|
@@ -315,7 +315,7 @@ class IcalEvent {
|
|
|
315
315
|
/**
|
|
316
316
|
* Transforms a single Event into a VEVENT string
|
|
317
317
|
* @param {Event} ev
|
|
318
|
-
* @param {
|
|
318
|
+
* @param {CalOptions} options
|
|
319
319
|
* @return {string} multi-line result, delimited by \r\n
|
|
320
320
|
*/
|
|
321
321
|
function eventToIcal(ev, options) {
|
|
@@ -352,17 +352,17 @@ function makeTorahMemo(ev, il) {
|
|
|
352
352
|
/**
|
|
353
353
|
* @private
|
|
354
354
|
* @param {Event} e
|
|
355
|
-
* @param {
|
|
355
|
+
* @param {CalOptions} options
|
|
356
356
|
* @return {string}
|
|
357
357
|
*/
|
|
358
358
|
function createMemo(e, options) {
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
e.memo = e.memo.replace(/\n/g, '\\n');
|
|
359
|
+
let memo = e.memo;
|
|
360
|
+
if (typeof memo === 'string' && memo.length && memo.indexOf('\n') !== -1) {
|
|
361
|
+
memo = memo.replace(/\n/g, '\\n');
|
|
363
362
|
}
|
|
364
|
-
|
|
365
|
-
|
|
363
|
+
const desc = e.getDesc();
|
|
364
|
+
if (desc === 'Havdalah' || desc === 'Candle lighting') {
|
|
365
|
+
return memo || '';
|
|
366
366
|
}
|
|
367
367
|
const mask = e.getFlags();
|
|
368
368
|
if (mask & flags.OMER_COUNT) {
|
|
@@ -371,30 +371,32 @@ function createMemo(e, options) {
|
|
|
371
371
|
}
|
|
372
372
|
const url = appendTrackingToUrl(e.url(), options);
|
|
373
373
|
const torahMemo = makeTorahMemo(e, options.il);
|
|
374
|
-
if (
|
|
375
|
-
|
|
376
|
-
} else {
|
|
377
|
-
let memo = e.memo || getHolidayDescription(e);
|
|
378
|
-
if (!memo && typeof e.linkedEvent !== 'undefined') {
|
|
374
|
+
if (!memo) {
|
|
375
|
+
if (typeof e.linkedEvent !== 'undefined') {
|
|
379
376
|
memo = e.linkedEvent.render(options.locale);
|
|
377
|
+
} else {
|
|
378
|
+
memo = getHolidayDescription(e);
|
|
380
379
|
}
|
|
381
|
-
|
|
382
|
-
|
|
380
|
+
}
|
|
381
|
+
if (torahMemo) {
|
|
382
|
+
if (memo.length) {
|
|
383
|
+
memo += '\\n\\n';
|
|
383
384
|
}
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
memo +=
|
|
385
|
+
memo += torahMemo;
|
|
386
|
+
}
|
|
387
|
+
if (url) {
|
|
388
|
+
if (memo.length) {
|
|
389
|
+
memo += '\\n\\n';
|
|
389
390
|
}
|
|
390
|
-
|
|
391
|
+
memo += url;
|
|
391
392
|
}
|
|
393
|
+
return memo;
|
|
392
394
|
}
|
|
393
395
|
|
|
394
396
|
/**
|
|
395
397
|
* Generates an RFC 2445 iCalendar string from an array of events
|
|
396
398
|
* @param {Event[]} events
|
|
397
|
-
* @param {
|
|
399
|
+
* @param {CalOptions} options
|
|
398
400
|
* @return {Promise<string>}
|
|
399
401
|
*/
|
|
400
402
|
async function eventsToIcalendar(events, options) {
|
|
@@ -412,7 +414,7 @@ async function eventsToIcalendar(events, options) {
|
|
|
412
414
|
/**
|
|
413
415
|
* Generates an RFC 2445 iCalendar string from an array of IcalEvents
|
|
414
416
|
* @param {IcalEvent[]} icals
|
|
415
|
-
* @param {
|
|
417
|
+
* @param {CalOptions} options
|
|
416
418
|
* @return {Promise<string>}
|
|
417
419
|
*/
|
|
418
420
|
async function icalEventsToString(icals, options) {
|
|
@@ -442,7 +444,7 @@ async function icalEventsToString(icals, options) {
|
|
|
442
444
|
stream.push(`X-APPLE-CALENDAR-COLOR:${opts.calendarColor}\r\n`);
|
|
443
445
|
}
|
|
444
446
|
const location = opts.location;
|
|
445
|
-
if (location
|
|
447
|
+
if (location?.tzid) {
|
|
446
448
|
const tzid = location.tzid;
|
|
447
449
|
stream.push(`X-WR-TIMEZONE;VALUE=TEXT:${tzid}\r\n`);
|
|
448
450
|
if (VTIMEZONE[tzid]) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hebcal/icalendar",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.22.0",
|
|
4
4
|
"author": "Michael J. Radwin (https://github.com/mjradwin)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ical",
|
|
@@ -11,10 +11,6 @@
|
|
|
11
11
|
"description": "Jewish holidays and Hebrew calendar as iCalendar RFC 2445",
|
|
12
12
|
"main": "dist/index.js",
|
|
13
13
|
"module": "dist/index.mjs",
|
|
14
|
-
"exports": {
|
|
15
|
-
"import": "./dist/index.mjs",
|
|
16
|
-
"require": "./dist/index.js"
|
|
17
|
-
},
|
|
18
14
|
"typings": "icalendar.d.ts",
|
|
19
15
|
"files": [
|
|
20
16
|
"dist",
|
|
@@ -28,8 +24,8 @@
|
|
|
28
24
|
"url": "https://github.com/hebcal/hebcal-icalendar/issues"
|
|
29
25
|
},
|
|
30
26
|
"dependencies": {
|
|
31
|
-
"@hebcal/core": "^4.
|
|
32
|
-
"@hebcal/rest-api": "^4.5.
|
|
27
|
+
"@hebcal/core": "^4.4.1",
|
|
28
|
+
"@hebcal/rest-api": "^4.5.7",
|
|
33
29
|
"murmurhash3": "^0.5.0"
|
|
34
30
|
},
|
|
35
31
|
"scripts": {
|
|
@@ -46,18 +42,18 @@
|
|
|
46
42
|
]
|
|
47
43
|
},
|
|
48
44
|
"devDependencies": {
|
|
49
|
-
"@babel/core": "^7.
|
|
50
|
-
"@babel/preset-env": "^7.
|
|
51
|
-
"@babel/register": "^7.22.
|
|
52
|
-
"@hebcal/learning": "^1.
|
|
53
|
-
"@rollup/plugin-babel": "^6.0.
|
|
54
|
-
"@rollup/plugin-commonjs": "^25.0.
|
|
55
|
-
"@rollup/plugin-json": "^6.0.
|
|
45
|
+
"@babel/core": "^7.23.2",
|
|
46
|
+
"@babel/preset-env": "^7.23.2",
|
|
47
|
+
"@babel/register": "^7.22.15",
|
|
48
|
+
"@hebcal/learning": "^1.5.2",
|
|
49
|
+
"@rollup/plugin-babel": "^6.0.4",
|
|
50
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
51
|
+
"@rollup/plugin-json": "^6.0.1",
|
|
56
52
|
"ava": "^5.3.1",
|
|
57
|
-
"eslint": "^8.
|
|
53
|
+
"eslint": "^8.51.0",
|
|
58
54
|
"eslint-config-google": "^0.14.0",
|
|
59
55
|
"jsdoc": "^4.0.2",
|
|
60
56
|
"jsdoc-to-markdown": "^8.0.0",
|
|
61
|
-
"rollup": "^
|
|
57
|
+
"rollup": "^4.1.4"
|
|
62
58
|
}
|
|
63
59
|
}
|