ical-generator 6.0.0 → 6.0.1-develop.10
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/LICENSE +1 -1
- package/README.md +6 -2
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -4
- package/dist/index.d.ts +4 -4
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +18 -18
- package/src/calendar.ts +2 -10
- package/src/event.ts +3 -3
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c)
|
|
3
|
+
Copyright (c) 2024 Sebastian Pekarek
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated
|
|
6
6
|
documentation files (the "Software"), to deal in the Software without restriction, including without limitation the
|
package/README.md
CHANGED
|
@@ -38,10 +38,14 @@ these breaking changes and how you can adapt your code can be found in our
|
|
|
38
38
|
## ⚡️ Quick Start
|
|
39
39
|
|
|
40
40
|
```javascript
|
|
41
|
-
import ical from 'ical-generator';
|
|
41
|
+
import ical, {ICalCalendarMethod} from 'ical-generator';
|
|
42
42
|
import http from 'node:http';
|
|
43
43
|
|
|
44
44
|
const calendar = ical({name: 'my first iCal'});
|
|
45
|
+
|
|
46
|
+
// A method is required for outlook to display event as an invitation
|
|
47
|
+
calendar.method(ICalCalendarMethod.REQUEST);
|
|
48
|
+
|
|
45
49
|
const startTime = new Date();
|
|
46
50
|
const endTime = new Date();
|
|
47
51
|
endTime.setHours(startTime.getHours()+1);
|
|
@@ -90,7 +94,7 @@ to use a VTimezone generator. Such a function generates a VTimezone entry and re
|
|
|
90
94
|
be used for this:
|
|
91
95
|
|
|
92
96
|
```typescript
|
|
93
|
-
import
|
|
97
|
+
import {ICalCalendar} from 'ical-generator';
|
|
94
98
|
import {getVtimezoneComponent} from '@touch4it/ical-timezones';
|
|
95
99
|
|
|
96
100
|
const cal = new ICalCalendar();
|
package/dist/index.cjs
CHANGED
|
@@ -57,7 +57,7 @@
|
|
|
57
57
|
`),this.data.lastModified&&(t+="LAST-MODIFIED:"+o(this.calendar.timezone(),this.data.lastModified)+`\r
|
|
58
58
|
`),this.data.class&&(t+="CLASS:"+this.data.class.toUpperCase()+`\r
|
|
59
59
|
`),t+=`END:VEVENT\r
|
|
60
|
-
`,t}};var Y=(h=>(h.PUBLISH="PUBLISH",h.REQUEST="REQUEST",h.REPLY="REPLY",h.ADD="ADD",h.CANCEL="CANCEL",h.REFRESH="REFRESH",h.COUNTER="COUNTER",h.DECLINECOUNTER="DECLINECOUNTER",h))(Y||{}),y=class{constructor(t={}){this.data={prodId:"//sebbo.net//ical-generator//EN",method:null,name:null,description:null,timezone:null,source:null,url:null,scale:null,ttl:null,events:[],x:[]},t.prodId!==void 0&&this.prodId(t.prodId),t.method!==void 0&&this.method(t.method),t.name!==void 0&&this.name(t.name),t.description!==void 0&&this.description(t.description),t.timezone!==void 0&&this.timezone(t.timezone),t.source!==void 0&&this.source(t.source),t.url!==void 0&&this.url(t.url),t.scale!==void 0&&this.scale(t.scale),t.ttl!==void 0&&this.ttl(t.ttl),t.events!==void 0&&this.events(t.events),t.x!==void 0&&this.x(t.x)}prodId(t){if(!t)return this.data.prodId;if(typeof t=="string"
|
|
60
|
+
`,t}};var Y=(h=>(h.PUBLISH="PUBLISH",h.REQUEST="REQUEST",h.REPLY="REPLY",h.ADD="ADD",h.CANCEL="CANCEL",h.REFRESH="REFRESH",h.COUNTER="COUNTER",h.DECLINECOUNTER="DECLINECOUNTER",h))(Y||{}),y=class{constructor(t={}){this.data={prodId:"//sebbo.net//ical-generator//EN",method:null,name:null,description:null,timezone:null,source:null,url:null,scale:null,ttl:null,events:[],x:[]},t.prodId!==void 0&&this.prodId(t.prodId),t.method!==void 0&&this.method(t.method),t.name!==void 0&&this.name(t.name),t.description!==void 0&&this.description(t.description),t.timezone!==void 0&&this.timezone(t.timezone),t.source!==void 0&&this.source(t.source),t.url!==void 0&&this.url(t.url),t.scale!==void 0&&this.scale(t.scale),t.ttl!==void 0&&this.ttl(t.ttl),t.events!==void 0&&this.events(t.events),t.x!==void 0&&this.x(t.x)}prodId(t){if(!t)return this.data.prodId;if(typeof t=="string")return this.data.prodId=t,this;if(typeof t!="object")throw new Error("`prodid` needs to be a string or an object!");if(!t.company)throw new Error("`prodid.company` is a mandatory item!");if(!t.product)throw new Error("`prodid.product` is a mandatory item!");let e=(t.language||"EN").toUpperCase();return this.data.prodId="//"+t.company+"//"+t.product+"//"+e,this}method(t){return t===void 0?this.data.method:t?(this.data.method=d(Y,t),this):(this.data.method=null,this)}name(t){return t===void 0?this.data.name:(this.data.name=t?String(t):null,this)}description(t){return t===void 0?this.data.description:(this.data.description=t?String(t):null,this)}timezone(t){var e;return t===void 0?((e=this.data.timezone)==null?void 0:e.name)||null:(t==="UTC"?this.data.timezone=null:typeof t=="string"?this.data.timezone={name:t}:t===null?this.data.timezone=null:this.data.timezone=t,this)}source(t){return t===void 0?this.data.source:(this.data.source=t||null,this)}url(t){return t===void 0?this.data.url:(this.data.url=t||null,this)}scale(t){return t===void 0?this.data.scale:(t===null?this.data.scale=null:this.data.scale=t.toUpperCase(),this)}ttl(t){return t===void 0?this.data.ttl:(W(t)?this.data.ttl=t.asSeconds():t&&t>0?this.data.ttl=t:this.data.ttl=null,this)}createEvent(t){let e=t instanceof D?t:new D(t,this);return this.data.events.push(e),e}events(t){return t?(t.forEach(e=>this.createEvent(e)),this):this.data.events}clear(){return this.data.events=[],this}x(t,e){if(t===void 0)return u(this.data);if(typeof t=="string"&&typeof e=="string")u(this.data,t,e);else if(typeof t=="object")u(this.data,t);else throw new Error("Either key or value is not a string!");return this}toJSON(){return Object.assign({},this.data,{timezone:this.timezone(),events:this.data.events.map(t=>t.toJSON()),x:this.x()})}length(){return this.data.events.length}toString(){var e,n;let t="";return t=`BEGIN:VCALENDAR\r
|
|
61
61
|
VERSION:2.0\r
|
|
62
62
|
`,t+="PRODID:-"+this.data.prodId+`\r
|
|
63
63
|
`,this.data.url&&(t+="URL:"+this.data.url+`\r
|