@hebcal/icalendar 6.3.5 → 6.3.7
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/icalendar.d.ts +0 -1
- package/dist/icalendar.js +34 -22
- package/dist/pkgVersion.d.ts +1 -1
- package/dist/pkgVersion.js +2 -2
- package/package.json +10 -10
package/dist/icalendar.d.ts
CHANGED
package/dist/icalendar.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
/*! @hebcal/icalendar v6.3.
|
|
1
|
+
/*! @hebcal/icalendar v6.3.7 */
|
|
2
|
+
import { Buffer } from 'node:buffer';
|
|
2
3
|
import { flags } from '@hebcal/core/dist/esm/event';
|
|
3
4
|
import { Locale } from '@hebcal/core/dist/esm/locale';
|
|
4
5
|
import { murmur32HexSync } from 'murmurhash3';
|
|
@@ -56,7 +57,6 @@ function appendTrackingToUrl(url, options) {
|
|
|
56
57
|
const utmCampaign = options.utmCampaign;
|
|
57
58
|
return appendIsraelAndTracking(url, options.il, utmSource, utmMedium, utmCampaign);
|
|
58
59
|
}
|
|
59
|
-
const encoder = new TextEncoder();
|
|
60
60
|
const char74re = /(.{1,74})/g;
|
|
61
61
|
const DAILY_LEARNING = flags.DAILY_LEARNING |
|
|
62
62
|
flags.DAF_YOMI |
|
|
@@ -67,13 +67,27 @@ const DAILY_LEARNING = flags.DAILY_LEARNING |
|
|
|
67
67
|
* Represents an RFC 2445 iCalendar VEVENT
|
|
68
68
|
*/
|
|
69
69
|
class IcalEvent {
|
|
70
|
+
ev;
|
|
71
|
+
options;
|
|
72
|
+
dtstamp;
|
|
73
|
+
sequence;
|
|
74
|
+
timed;
|
|
75
|
+
locationName;
|
|
76
|
+
startDate;
|
|
77
|
+
isoDateOnly;
|
|
78
|
+
dtargs;
|
|
79
|
+
transp;
|
|
80
|
+
busyStatus;
|
|
81
|
+
endDate;
|
|
82
|
+
subj;
|
|
83
|
+
category;
|
|
84
|
+
lines;
|
|
70
85
|
/**
|
|
71
86
|
* Builds an IcalEvent object from a Hebcal Event
|
|
72
87
|
*/
|
|
73
88
|
constructor(ev, options = {}) {
|
|
74
|
-
var _a;
|
|
75
89
|
this.ev = ev;
|
|
76
|
-
const opts =
|
|
90
|
+
const opts = { ...options };
|
|
77
91
|
this.options = opts;
|
|
78
92
|
this.dtstamp = opts.dtstamp || IcalEvent.makeDtstamp(new Date());
|
|
79
93
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
@@ -112,7 +126,7 @@ class IcalEvent {
|
|
|
112
126
|
minute = +minute;
|
|
113
127
|
this.startDate += 'T' + pad2(hour) + pad2(minute) + '00';
|
|
114
128
|
this.endDate = this.startDate;
|
|
115
|
-
if (location
|
|
129
|
+
if (location?.getTzid()) {
|
|
116
130
|
this.dtargs = `;TZID=${location.getTzid()}`;
|
|
117
131
|
}
|
|
118
132
|
}
|
|
@@ -147,7 +161,7 @@ class IcalEvent {
|
|
|
147
161
|
}
|
|
148
162
|
}
|
|
149
163
|
this.subj = subj;
|
|
150
|
-
this.category = ev0.category || CATEGORY[
|
|
164
|
+
this.category = ev0.category || CATEGORY[getEventCategories(ev)?.[0]];
|
|
151
165
|
}
|
|
152
166
|
getAlarm() {
|
|
153
167
|
const ev = this.ev;
|
|
@@ -258,6 +272,9 @@ class IcalEvent {
|
|
|
258
272
|
* fold line to 75 characters
|
|
259
273
|
*/
|
|
260
274
|
static fold(line) {
|
|
275
|
+
if (Buffer.byteLength(line) <= 74) {
|
|
276
|
+
return line;
|
|
277
|
+
}
|
|
261
278
|
let isASCII = true;
|
|
262
279
|
for (let i = 0; i < line.length; i++) {
|
|
263
280
|
if (line.codePointAt(i) > 255) {
|
|
@@ -266,15 +283,11 @@ class IcalEvent {
|
|
|
266
283
|
}
|
|
267
284
|
}
|
|
268
285
|
if (isASCII) {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
}
|
|
286
|
+
// It's longer than 74 octets, and all characters are ASCII, so we
|
|
287
|
+
// use a simple regex to split it into chunks of 74 characters
|
|
272
288
|
const matches = line.match(char74re);
|
|
273
289
|
return matches.join('\r\n ');
|
|
274
290
|
}
|
|
275
|
-
if (encoder.encode(line).length <= 74) {
|
|
276
|
-
return line;
|
|
277
|
-
}
|
|
278
291
|
// iterate unicode character by character, making sure
|
|
279
292
|
// that adding a new character would keep the line <= 75 octets
|
|
280
293
|
const segmenter = new Intl.Segmenter('en', { granularity: 'grapheme' });
|
|
@@ -284,7 +297,7 @@ class IcalEvent {
|
|
|
284
297
|
let current = '';
|
|
285
298
|
let len = 0;
|
|
286
299
|
for (const ch of chars) {
|
|
287
|
-
const octets = ch.codePointAt(0) < 256 ? 1 :
|
|
300
|
+
const octets = ch.codePointAt(0) < 256 ? 1 : Buffer.byteLength(ch);
|
|
288
301
|
const newlen = len + octets;
|
|
289
302
|
if (newlen < 75) {
|
|
290
303
|
current += ch;
|
|
@@ -424,7 +437,7 @@ async function eventsToIcalendar(events, options) {
|
|
|
424
437
|
throw new RangeError('Events can not be empty');
|
|
425
438
|
if (!options)
|
|
426
439
|
throw new TypeError('Invalid options object');
|
|
427
|
-
const opts =
|
|
440
|
+
const opts = { ...options };
|
|
428
441
|
opts.dtstamp = opts.dtstamp || IcalEvent.makeDtstamp(new Date());
|
|
429
442
|
if (!opts.title) {
|
|
430
443
|
opts.title = getCalendarTitle(events, opts);
|
|
@@ -455,7 +468,7 @@ async function getVtimezone(tzid) {
|
|
|
455
468
|
vtimezoneCache.set(tzid, str);
|
|
456
469
|
return str;
|
|
457
470
|
}
|
|
458
|
-
catch
|
|
471
|
+
catch {
|
|
459
472
|
// ignore failure when no timezone definition to read
|
|
460
473
|
return undefined;
|
|
461
474
|
}
|
|
@@ -465,11 +478,7 @@ function makeIcalPreamble(opts) {
|
|
|
465
478
|
const lang = locale.length === 2 ? locale : localeMap[locale] || 'en';
|
|
466
479
|
const uclang = lang.toUpperCase();
|
|
467
480
|
const title = opts.title ? IcalEvent.escape(opts.title) : 'Untitled';
|
|
468
|
-
const caldesc = opts.caldesc
|
|
469
|
-
? IcalEvent.escape(opts.caldesc)
|
|
470
|
-
: opts.yahrzeit
|
|
471
|
-
? 'Yahrzeits + Anniversaries from www.hebcal.com'
|
|
472
|
-
: 'Jewish Holidays from www.hebcal.com';
|
|
481
|
+
const caldesc = opts.caldesc ? IcalEvent.escape(opts.caldesc) : undefined;
|
|
473
482
|
const prodid = opts.prodid ||
|
|
474
483
|
`-//hebcal.com/NONSGML Hebcal Calendar v1${version}//${uclang}`;
|
|
475
484
|
const preamble = [
|
|
@@ -484,7 +493,10 @@ function makeIcalPreamble(opts) {
|
|
|
484
493
|
const publishedTTL = opts.publishedTTL || 'P7D';
|
|
485
494
|
preamble.push(`REFRESH-INTERVAL;VALUE=DURATION:${publishedTTL}`, `X-PUBLISHED-TTL:${publishedTTL}`);
|
|
486
495
|
}
|
|
487
|
-
preamble.push(`X-WR-CALNAME:${title}
|
|
496
|
+
preamble.push(`X-WR-CALNAME:${title}`);
|
|
497
|
+
if (caldesc) {
|
|
498
|
+
preamble.push(`X-WR-CALDESC:${caldesc}`);
|
|
499
|
+
}
|
|
488
500
|
const relcalid = opts.relcalid;
|
|
489
501
|
if (relcalid) {
|
|
490
502
|
preamble.push(`X-WR-RELCALID:${relcalid}`);
|
|
@@ -510,7 +522,7 @@ async function icalEventsToString(icals, options) {
|
|
|
510
522
|
stream.push('\r\n');
|
|
511
523
|
}
|
|
512
524
|
const location = options.location;
|
|
513
|
-
const tzid = location
|
|
525
|
+
const tzid = location?.getTzid();
|
|
514
526
|
if (tzid) {
|
|
515
527
|
stream.push(`X-WR-TIMEZONE;VALUE=TEXT:${tzid}\r\n`);
|
|
516
528
|
const vtz = await getVtimezone(tzid);
|
package/dist/pkgVersion.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const version = "6.3.
|
|
1
|
+
export declare const version = "6.3.7";
|
package/dist/pkgVersion.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hebcal/icalendar",
|
|
3
|
-
"version": "6.3.
|
|
3
|
+
"version": "6.3.7",
|
|
4
4
|
"author": "Michael J. Radwin (https://github.com/mjradwin)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ical",
|
|
@@ -30,9 +30,9 @@
|
|
|
30
30
|
},
|
|
31
31
|
"homepage": "https://hebcal.github.io/api/icalendar/",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@hebcal/core": "^6.0
|
|
34
|
-
"@hebcal/hdate": "^0.
|
|
35
|
-
"@hebcal/rest-api": "^6.4.
|
|
33
|
+
"@hebcal/core": "^6.1.0",
|
|
34
|
+
"@hebcal/hdate": "^0.22.0",
|
|
35
|
+
"@hebcal/rest-api": "^6.4.3",
|
|
36
36
|
"murmurhash3": "^0.5.0",
|
|
37
37
|
"tslib": "^2.8.1"
|
|
38
38
|
},
|
|
@@ -50,13 +50,13 @@
|
|
|
50
50
|
},
|
|
51
51
|
"license": "BSD-2-Clause",
|
|
52
52
|
"devDependencies": {
|
|
53
|
-
"@hebcal/learning": "^6.
|
|
53
|
+
"@hebcal/learning": "^6.7.2",
|
|
54
54
|
"@rollup/plugin-typescript": "^12.3.0",
|
|
55
|
-
"@types/node": "25.0
|
|
55
|
+
"@types/node": "25.6.0",
|
|
56
56
|
"gts": "^7.0.0",
|
|
57
|
-
"rollup": "^4.
|
|
58
|
-
"typedoc": "^0.28.
|
|
59
|
-
"typescript": "^
|
|
60
|
-
"vitest": "^4.
|
|
57
|
+
"rollup": "^4.60.1",
|
|
58
|
+
"typedoc": "^0.28.18",
|
|
59
|
+
"typescript": "^6.0.2",
|
|
60
|
+
"vitest": "^4.1.4"
|
|
61
61
|
}
|
|
62
62
|
}
|