rrule-rust 3.0.0-alpha.1 → 3.0.0-alpha.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.
- package/README.md +2 -4
- package/dist/browser/datetime.js +120 -0
- package/dist/browser/index.js +3 -0
- package/dist/browser/lib/index.js +1 -0
- package/dist/browser/rrule-set.js +185 -0
- package/dist/browser/rrule.js +169 -0
- package/dist/node/datetime.d.ts +55 -0
- package/dist/node/index.d.ts +3 -0
- package/dist/node/lib/rrule-rust.wasi.cjs +116 -0
- package/dist/node/rrule-set.d.ts +60 -0
- package/dist/node/rrule.d.ts +97 -0
- package/package.json +29 -23
- package/dist/lib/index.d.ts +0 -81
- /package/dist/{datetime.d.ts → browser/datetime.d.ts} +0 -0
- /package/dist/{index.d.ts → browser/index.d.ts} +0 -0
- /package/dist/{rrule-set.d.ts → browser/rrule-set.d.ts} +0 -0
- /package/dist/{rrule.d.ts → browser/rrule.d.ts} +0 -0
- /package/dist/{datetime.js → node/datetime.js} +0 -0
- /package/dist/{index.js → node/index.js} +0 -0
- /package/dist/{lib → node/lib}/index.js +0 -0
- /package/dist/{rrule-set.js → node/rrule-set.js} +0 -0
- /package/dist/{rrule.js → node/rrule.js} +0 -0
package/README.md
CHANGED
|
@@ -16,14 +16,12 @@
|
|
|
16
16
|
npm i rrule-rust
|
|
17
17
|
```
|
|
18
18
|
|
|
19
|
-
If you need a browser-compatible version with WASM support
|
|
19
|
+
If you need a browser-compatible version with WASM support:
|
|
20
20
|
|
|
21
21
|
```
|
|
22
|
-
npm i rrule-rust
|
|
22
|
+
npm i rrule-rust --cpu "wasm32"
|
|
23
23
|
```
|
|
24
24
|
|
|
25
|
-
> The WebAssembly (WASM) version is currently available on the `alpha` channel, as it relies on an alpha release of [napi.rs](https://napi.rs/). Once napi.rs v3 is officially released, WASM support will be included in the main (`latest`) release channel.
|
|
26
|
-
|
|
27
25
|
For more usage examples and advanced scenarios, see the [tests directory](https://github.com/lsndr/rrule-rust/tree/master/tests) in the repository.
|
|
28
26
|
|
|
29
27
|
```typescript
|
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents a date and time. Either local or UTC.
|
|
3
|
+
*/
|
|
4
|
+
export class DateTime {
|
|
5
|
+
constructor(numeric) {
|
|
6
|
+
this.numeric = numeric;
|
|
7
|
+
}
|
|
8
|
+
get year() {
|
|
9
|
+
return Math.floor(this.numeric / 100000000000);
|
|
10
|
+
}
|
|
11
|
+
get month() {
|
|
12
|
+
return Math.floor((this.numeric / 1000000000) % 100);
|
|
13
|
+
}
|
|
14
|
+
get day() {
|
|
15
|
+
return Math.floor((this.numeric / 10000000) % 100);
|
|
16
|
+
}
|
|
17
|
+
get hour() {
|
|
18
|
+
return Math.floor((this.numeric / 100000) % 100);
|
|
19
|
+
}
|
|
20
|
+
get minute() {
|
|
21
|
+
return Math.floor((this.numeric / 1000) % 100);
|
|
22
|
+
}
|
|
23
|
+
get second() {
|
|
24
|
+
return Math.floor((this.numeric / 10) % 100);
|
|
25
|
+
}
|
|
26
|
+
get utc() {
|
|
27
|
+
return this.numeric % 10 == 1;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* Creates a new DateTime object from the given date and time components.
|
|
31
|
+
*/
|
|
32
|
+
static create(year, month, day, hour, minute, second, utc) {
|
|
33
|
+
const numeric = year * 100000000000 +
|
|
34
|
+
month * 1000000000 +
|
|
35
|
+
day * 10000000 +
|
|
36
|
+
hour * 100000 +
|
|
37
|
+
minute * 1000 +
|
|
38
|
+
second * 10 +
|
|
39
|
+
(utc ? 1 : 0);
|
|
40
|
+
return new DateTime(numeric);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* This method is shorthand for `DateTime.create` with `utc` set to `false`.
|
|
44
|
+
*/
|
|
45
|
+
static local(year, month, day, hour, minute, second) {
|
|
46
|
+
return DateTime.create(year, month, day, hour, minute, second, false);
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* This method is shorthand for `DateTime.create` with `utc` set to `true`.
|
|
50
|
+
*/
|
|
51
|
+
static utc(year, month, day, hour, minute, second) {
|
|
52
|
+
return DateTime.create(year, month, day, hour, minute, second, true);
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Creates a new DateTime object from the given plain object.
|
|
56
|
+
*/
|
|
57
|
+
static fromObject(object, options) {
|
|
58
|
+
return DateTime.create(object.year, object.month, object.day, object.hour, object.minute, object.second, !!options?.utc);
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Creates a new DateTime object from provided string representation of a date according to RFC 5545.
|
|
62
|
+
*/
|
|
63
|
+
static fromString(str) {
|
|
64
|
+
const typeError = new TypeError('Invalid date time string');
|
|
65
|
+
if (str.length > 16 || str.length < 15) {
|
|
66
|
+
throw typeError;
|
|
67
|
+
}
|
|
68
|
+
const year = parseInt(str.slice(0, 4));
|
|
69
|
+
const month = parseInt(str.slice(4, 6));
|
|
70
|
+
const day = parseInt(str.slice(6, 8));
|
|
71
|
+
const hour = parseInt(str.slice(9, 11));
|
|
72
|
+
const minute = parseInt(str.slice(11, 13));
|
|
73
|
+
const second = parseInt(str.slice(13, 15));
|
|
74
|
+
const utc = str.endsWith('Z');
|
|
75
|
+
if (isNaN(year) ||
|
|
76
|
+
isNaN(month) ||
|
|
77
|
+
isNaN(day) ||
|
|
78
|
+
isNaN(hour) ||
|
|
79
|
+
isNaN(minute) ||
|
|
80
|
+
isNaN(second)) {
|
|
81
|
+
throw typeError;
|
|
82
|
+
}
|
|
83
|
+
return DateTime.create(year, month, day, hour, minute, second, utc);
|
|
84
|
+
}
|
|
85
|
+
/** @internal */
|
|
86
|
+
static fromNumeric(numeric) {
|
|
87
|
+
return new DateTime(numeric);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Converts DateTime into a plain object.
|
|
91
|
+
*/
|
|
92
|
+
toObject() {
|
|
93
|
+
return {
|
|
94
|
+
year: this.year,
|
|
95
|
+
month: this.month,
|
|
96
|
+
day: this.day,
|
|
97
|
+
hour: this.hour,
|
|
98
|
+
minute: this.minute,
|
|
99
|
+
second: this.second,
|
|
100
|
+
};
|
|
101
|
+
}
|
|
102
|
+
/**
|
|
103
|
+
* Converts DateTime into ISO 8601 string:
|
|
104
|
+
* - `YYYYMMDDTHHMMSSZ` for UTC
|
|
105
|
+
* - `YYYYMMDDTHHMMSS` for local
|
|
106
|
+
*/
|
|
107
|
+
toString() {
|
|
108
|
+
const year = this.year.toString().padStart(4, '0');
|
|
109
|
+
const month = this.month.toString().padStart(2, '0');
|
|
110
|
+
const day = this.day.toString().padStart(2, '0');
|
|
111
|
+
const hour = this.hour.toString().padStart(2, '0');
|
|
112
|
+
const minute = this.minute.toString().padStart(2, '0');
|
|
113
|
+
const second = this.second.toString().padStart(2, '0');
|
|
114
|
+
return `${year}${month}${day}T${hour}${minute}${second}${this.utc ? 'Z' : ''}`;
|
|
115
|
+
}
|
|
116
|
+
/** @internal */
|
|
117
|
+
toNumeric() {
|
|
118
|
+
return this.numeric;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from '@rrule-rust/lib-wasm32-wasi'
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
import { RRule } from './rrule';
|
|
2
|
+
import { RRuleSet as Rust } from './lib';
|
|
3
|
+
import { DateTime } from './datetime';
|
|
4
|
+
export class RRuleSet {
|
|
5
|
+
constructor(setOrDtstart, tzid) {
|
|
6
|
+
if (!(setOrDtstart instanceof DateTime)) {
|
|
7
|
+
if (setOrDtstart?.dtstart) {
|
|
8
|
+
this.dtstart = setOrDtstart?.dtstart;
|
|
9
|
+
}
|
|
10
|
+
else {
|
|
11
|
+
const date = new Date();
|
|
12
|
+
this.dtstart = DateTime.create(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), true);
|
|
13
|
+
}
|
|
14
|
+
this.tzid = setOrDtstart?.tzid ?? 'UTC';
|
|
15
|
+
this.rrules = setOrDtstart?.rrules ?? [];
|
|
16
|
+
this.exrules = setOrDtstart?.exrules ?? [];
|
|
17
|
+
this.exdates = setOrDtstart?.exdates ?? [];
|
|
18
|
+
this.rdates = setOrDtstart?.rdates ?? [];
|
|
19
|
+
}
|
|
20
|
+
else if (setOrDtstart instanceof DateTime && typeof tzid === 'string') {
|
|
21
|
+
this.dtstart = setOrDtstart;
|
|
22
|
+
this.tzid = tzid;
|
|
23
|
+
this.rrules = [];
|
|
24
|
+
this.exrules = [];
|
|
25
|
+
this.exdates = [];
|
|
26
|
+
this.rdates = [];
|
|
27
|
+
}
|
|
28
|
+
else {
|
|
29
|
+
throw new TypeError('Invalid arguments');
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Parses a string into an RRuleSet.
|
|
34
|
+
*/
|
|
35
|
+
static parse(str) {
|
|
36
|
+
const rust = Rust.parse(str);
|
|
37
|
+
return this.fromRust(rust);
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
static fromRust(rust) {
|
|
43
|
+
const set = new RRuleSet({
|
|
44
|
+
dtstart: DateTime.fromNumeric(rust.dtstart),
|
|
45
|
+
tzid: rust.tzid ?? undefined,
|
|
46
|
+
rrules: rust.rrules.map((rrule) => RRule.fromRust(rrule)),
|
|
47
|
+
exrules: rust.exrules.map((rrule) => RRule.fromRust(rrule)),
|
|
48
|
+
exdates: rust.exdates.map((datetime) => DateTime.fromNumeric(datetime)),
|
|
49
|
+
rdates: rust.rdates.map((datetime) => DateTime.fromNumeric(datetime)),
|
|
50
|
+
});
|
|
51
|
+
set.rust = rust;
|
|
52
|
+
return set;
|
|
53
|
+
}
|
|
54
|
+
setDtstart(dtstart) {
|
|
55
|
+
return new RRuleSet({
|
|
56
|
+
...this.toObject(),
|
|
57
|
+
dtstart: dtstart,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
setTzid(tzid) {
|
|
61
|
+
return new RRuleSet({
|
|
62
|
+
...this.toObject(),
|
|
63
|
+
tzid: tzid,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
addRrule(rrule) {
|
|
67
|
+
return new RRuleSet({
|
|
68
|
+
...this.toObject(),
|
|
69
|
+
rrules: [...this.rrules, rrule],
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
setRrules(rrules) {
|
|
73
|
+
return new RRuleSet({
|
|
74
|
+
...this.toObject(),
|
|
75
|
+
rrules: rrules,
|
|
76
|
+
});
|
|
77
|
+
}
|
|
78
|
+
addExrule(rrule) {
|
|
79
|
+
return new RRuleSet({
|
|
80
|
+
...this.toObject(),
|
|
81
|
+
exrules: [...this.exrules, rrule],
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
setExrules(rrules) {
|
|
85
|
+
return new RRuleSet({
|
|
86
|
+
...this.toObject(),
|
|
87
|
+
exrules: rrules,
|
|
88
|
+
});
|
|
89
|
+
}
|
|
90
|
+
addExdate(datetime) {
|
|
91
|
+
return new RRuleSet({
|
|
92
|
+
...this.toObject(),
|
|
93
|
+
exdates: [...this.exdates, datetime],
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
setExdates(datetimes) {
|
|
97
|
+
return new RRuleSet({
|
|
98
|
+
...this.toObject(),
|
|
99
|
+
exdates: datetimes,
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
addRdate(datetime) {
|
|
103
|
+
return new RRuleSet({
|
|
104
|
+
...this.toObject(),
|
|
105
|
+
rdates: [...this.rdates, datetime],
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
setRdates(datetimes) {
|
|
109
|
+
return new RRuleSet({
|
|
110
|
+
...this.toObject(),
|
|
111
|
+
rdates: datetimes,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* Returns all the occurrences of the rrule.
|
|
116
|
+
*
|
|
117
|
+
* @param limit - The maximum number of occurrences to return.
|
|
118
|
+
*/
|
|
119
|
+
all(limit) {
|
|
120
|
+
return this.toRust()
|
|
121
|
+
.all(limit)
|
|
122
|
+
.map((datetime) => DateTime.fromNumeric(datetime));
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Returns all the occurrences of the rrule between after and before.
|
|
126
|
+
*
|
|
127
|
+
* @param after - The lower bound date.
|
|
128
|
+
* @param before - The upper bound date.
|
|
129
|
+
* @param inclusive - Whether to include after and before in the list of occurrences.
|
|
130
|
+
*/
|
|
131
|
+
between(after, before, inclusive) {
|
|
132
|
+
return this.toRust()
|
|
133
|
+
.between(after.toNumeric(), before.toNumeric(), inclusive)
|
|
134
|
+
.map((datetime) => DateTime.fromNumeric(datetime));
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Sets the RRuleSet from a string.
|
|
138
|
+
*
|
|
139
|
+
* @param str - The string to parse.
|
|
140
|
+
*/
|
|
141
|
+
setFromString(str) {
|
|
142
|
+
return RRuleSet.fromRust(this.toRust().setFromString(str));
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
toRust() {
|
|
148
|
+
this.rust ??= new Rust(this.dtstart.toNumeric(), this.tzid, this.rrules.map((rrule) => rrule.toRust()), this.exrules.map((rrule) => rrule.toRust()), this.exdates.map((datetime) => datetime.toNumeric()), this.rdates.map((datetime) => datetime.toNumeric()));
|
|
149
|
+
return this.rust;
|
|
150
|
+
}
|
|
151
|
+
toString() {
|
|
152
|
+
return this.toRust().toString();
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Converts the RRuleSet to a plain object.
|
|
156
|
+
*/
|
|
157
|
+
toObject() {
|
|
158
|
+
return {
|
|
159
|
+
dtstart: this.dtstart,
|
|
160
|
+
tzid: this.tzid,
|
|
161
|
+
rrules: this.rrules,
|
|
162
|
+
exrules: this.exrules,
|
|
163
|
+
exdates: this.exdates,
|
|
164
|
+
rdates: this.rdates,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
[Symbol.iterator]() {
|
|
168
|
+
const iter = this.toRust().iterator();
|
|
169
|
+
return {
|
|
170
|
+
next: () => {
|
|
171
|
+
const result = iter.next();
|
|
172
|
+
if (result === null) {
|
|
173
|
+
return {
|
|
174
|
+
done: true,
|
|
175
|
+
value: undefined,
|
|
176
|
+
};
|
|
177
|
+
}
|
|
178
|
+
return {
|
|
179
|
+
done: false,
|
|
180
|
+
value: DateTime.fromNumeric(result),
|
|
181
|
+
};
|
|
182
|
+
},
|
|
183
|
+
};
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { DateTime } from './datetime';
|
|
2
|
+
import { RRule as Rust } from './lib';
|
|
3
|
+
export var Frequency;
|
|
4
|
+
(function (Frequency) {
|
|
5
|
+
Frequency[Frequency["Yearly"] = 0] = "Yearly";
|
|
6
|
+
Frequency[Frequency["Monthly"] = 1] = "Monthly";
|
|
7
|
+
Frequency[Frequency["Weekly"] = 2] = "Weekly";
|
|
8
|
+
Frequency[Frequency["Daily"] = 3] = "Daily";
|
|
9
|
+
Frequency[Frequency["Hourly"] = 4] = "Hourly";
|
|
10
|
+
Frequency[Frequency["Minutely"] = 5] = "Minutely";
|
|
11
|
+
Frequency[Frequency["Secondly"] = 6] = "Secondly";
|
|
12
|
+
})(Frequency || (Frequency = {}));
|
|
13
|
+
export var Month;
|
|
14
|
+
(function (Month) {
|
|
15
|
+
Month[Month["January"] = 1] = "January";
|
|
16
|
+
Month[Month["February"] = 2] = "February";
|
|
17
|
+
Month[Month["March"] = 3] = "March";
|
|
18
|
+
Month[Month["April"] = 4] = "April";
|
|
19
|
+
Month[Month["May"] = 5] = "May";
|
|
20
|
+
Month[Month["June"] = 6] = "June";
|
|
21
|
+
Month[Month["July"] = 7] = "July";
|
|
22
|
+
Month[Month["August"] = 8] = "August";
|
|
23
|
+
Month[Month["September"] = 9] = "September";
|
|
24
|
+
Month[Month["October"] = 10] = "October";
|
|
25
|
+
Month[Month["November"] = 11] = "November";
|
|
26
|
+
Month[Month["December"] = 12] = "December";
|
|
27
|
+
})(Month || (Month = {}));
|
|
28
|
+
export var Weekday;
|
|
29
|
+
(function (Weekday) {
|
|
30
|
+
Weekday[Weekday["Monday"] = 0] = "Monday";
|
|
31
|
+
Weekday[Weekday["Tuesday"] = 1] = "Tuesday";
|
|
32
|
+
Weekday[Weekday["Wednesday"] = 2] = "Wednesday";
|
|
33
|
+
Weekday[Weekday["Thursday"] = 3] = "Thursday";
|
|
34
|
+
Weekday[Weekday["Friday"] = 4] = "Friday";
|
|
35
|
+
Weekday[Weekday["Saturday"] = 5] = "Saturday";
|
|
36
|
+
Weekday[Weekday["Sunday"] = 6] = "Sunday";
|
|
37
|
+
})(Weekday || (Weekday = {}));
|
|
38
|
+
export class RRule {
|
|
39
|
+
constructor(rruleOrFrequency = {}) {
|
|
40
|
+
if (typeof rruleOrFrequency === 'object' && rruleOrFrequency !== null) {
|
|
41
|
+
this.frequency = rruleOrFrequency.frequency ?? Frequency.Daily;
|
|
42
|
+
this.interval = rruleOrFrequency.interval;
|
|
43
|
+
this.until = rruleOrFrequency.until;
|
|
44
|
+
this.count = rruleOrFrequency.count;
|
|
45
|
+
this.byWeekday = rruleOrFrequency.byWeekday ?? [];
|
|
46
|
+
this.byHour = rruleOrFrequency.byHour ?? [];
|
|
47
|
+
this.byMinute = rruleOrFrequency.byMinute ?? [];
|
|
48
|
+
this.bySecond = rruleOrFrequency.bySecond ?? [];
|
|
49
|
+
this.byMonthday = rruleOrFrequency.byMonthday ?? [];
|
|
50
|
+
this.bySetpos = rruleOrFrequency.bySetpos ?? [];
|
|
51
|
+
this.byMonth = rruleOrFrequency.byMonth ?? [];
|
|
52
|
+
this.byWeekno = rruleOrFrequency.byWeekno ?? [];
|
|
53
|
+
this.byYearday = rruleOrFrequency.byYearday ?? [];
|
|
54
|
+
this.weekstart = rruleOrFrequency.weekstart;
|
|
55
|
+
}
|
|
56
|
+
else {
|
|
57
|
+
this.frequency = rruleOrFrequency;
|
|
58
|
+
this.byWeekday = [];
|
|
59
|
+
this.byHour = [];
|
|
60
|
+
this.byMinute = [];
|
|
61
|
+
this.bySecond = [];
|
|
62
|
+
this.byMonthday = [];
|
|
63
|
+
this.bySetpos = [];
|
|
64
|
+
this.byMonth = [];
|
|
65
|
+
this.byWeekno = [];
|
|
66
|
+
this.byYearday = [];
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Parses a string into an RRule.
|
|
71
|
+
*/
|
|
72
|
+
static parse(str) {
|
|
73
|
+
const rust = Rust.parse(str);
|
|
74
|
+
return this.fromRust(rust);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* @internal
|
|
78
|
+
*/
|
|
79
|
+
static fromRust(rust) {
|
|
80
|
+
const rrule = new this({
|
|
81
|
+
frequency: rust.frequency,
|
|
82
|
+
interval: rust.interval ?? undefined,
|
|
83
|
+
until: rust.until === null ? undefined : DateTime.fromNumeric(rust.until),
|
|
84
|
+
count: rust.count ?? undefined,
|
|
85
|
+
byWeekday: rust.byWeekday,
|
|
86
|
+
byHour: rust.byHour,
|
|
87
|
+
byMinute: rust.byMinute,
|
|
88
|
+
bySecond: rust.bySecond,
|
|
89
|
+
byMonthday: rust.byMonthday,
|
|
90
|
+
bySetpos: rust.bySetpos,
|
|
91
|
+
byMonth: rust.byMonth,
|
|
92
|
+
byWeekno: rust.byWeekno,
|
|
93
|
+
byYearday: rust.byYearday,
|
|
94
|
+
weekstart: rust.weekstart ?? undefined,
|
|
95
|
+
});
|
|
96
|
+
rrule.rust = rust;
|
|
97
|
+
return rrule;
|
|
98
|
+
}
|
|
99
|
+
setFrequency(frequency) {
|
|
100
|
+
return new RRule({ ...this.toObject(), frequency });
|
|
101
|
+
}
|
|
102
|
+
setInterval(interval) {
|
|
103
|
+
return new RRule({ ...this.toObject(), interval });
|
|
104
|
+
}
|
|
105
|
+
setCount(count) {
|
|
106
|
+
return new RRule({ ...this.toObject(), count });
|
|
107
|
+
}
|
|
108
|
+
setByWeekday(weekdays) {
|
|
109
|
+
return new RRule({ ...this.toObject(), byWeekday: weekdays });
|
|
110
|
+
}
|
|
111
|
+
setByHour(hours) {
|
|
112
|
+
return new RRule({ ...this.toObject(), byHour: hours });
|
|
113
|
+
}
|
|
114
|
+
setByMinute(minutes) {
|
|
115
|
+
return new RRule({ ...this.toObject(), byMinute: minutes });
|
|
116
|
+
}
|
|
117
|
+
setBySecond(seconds) {
|
|
118
|
+
return new RRule({ ...this.toObject(), bySecond: seconds });
|
|
119
|
+
}
|
|
120
|
+
setByMonthday(days) {
|
|
121
|
+
return new RRule({ ...this.toObject(), byMonthday: days });
|
|
122
|
+
}
|
|
123
|
+
setBySetpos(poses) {
|
|
124
|
+
return new RRule({ ...this.toObject(), bySetpos: poses });
|
|
125
|
+
}
|
|
126
|
+
setByMonth(months) {
|
|
127
|
+
return new RRule({ ...this.toObject(), byMonth: months });
|
|
128
|
+
}
|
|
129
|
+
setByWeekno(weekNumbers) {
|
|
130
|
+
return new RRule({ ...this.toObject(), byWeekno: weekNumbers });
|
|
131
|
+
}
|
|
132
|
+
setByYearday(days) {
|
|
133
|
+
return new RRule({ ...this.toObject(), byYearday: days });
|
|
134
|
+
}
|
|
135
|
+
setWeekstart(day) {
|
|
136
|
+
return new RRule({ ...this.toObject(), weekstart: day });
|
|
137
|
+
}
|
|
138
|
+
setUntil(datetime) {
|
|
139
|
+
return new RRule({ ...this.toObject(), until: datetime });
|
|
140
|
+
}
|
|
141
|
+
toString() {
|
|
142
|
+
return this.toRust().toString();
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* @internal
|
|
146
|
+
*/
|
|
147
|
+
toRust() {
|
|
148
|
+
this.rust ??= new Rust(this.frequency, this.interval, this.count, this.weekstart, this.until?.toNumeric(), this.byWeekday, this.byHour, this.byMinute, this.bySecond, this.byMonthday, this.bySetpos, this.byMonth, this.byWeekno, this.byYearday);
|
|
149
|
+
return this.rust;
|
|
150
|
+
}
|
|
151
|
+
toObject() {
|
|
152
|
+
return {
|
|
153
|
+
frequency: this.frequency,
|
|
154
|
+
interval: this.interval,
|
|
155
|
+
count: this.count,
|
|
156
|
+
byWeekday: this.byWeekday,
|
|
157
|
+
byHour: this.byHour,
|
|
158
|
+
byMinute: this.byMinute,
|
|
159
|
+
bySecond: this.bySecond,
|
|
160
|
+
byMonthday: this.byMonthday,
|
|
161
|
+
bySetpos: this.bySetpos,
|
|
162
|
+
byMonth: this.byMonth,
|
|
163
|
+
byWeekno: this.byWeekno,
|
|
164
|
+
byYearday: this.byYearday,
|
|
165
|
+
weekstart: this.weekstart,
|
|
166
|
+
until: this.until,
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
}
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
export interface DateTimeLike {
|
|
2
|
+
readonly year: number;
|
|
3
|
+
readonly month: number;
|
|
4
|
+
readonly day: number;
|
|
5
|
+
readonly hour: number;
|
|
6
|
+
readonly minute: number;
|
|
7
|
+
readonly second: number;
|
|
8
|
+
}
|
|
9
|
+
export interface FromObjectOptions {
|
|
10
|
+
utc?: boolean;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Represents a date and time. Either local or UTC.
|
|
14
|
+
*/
|
|
15
|
+
export declare class DateTime implements DateTimeLike {
|
|
16
|
+
private readonly numeric;
|
|
17
|
+
private constructor();
|
|
18
|
+
get year(): number;
|
|
19
|
+
get month(): number;
|
|
20
|
+
get day(): number;
|
|
21
|
+
get hour(): number;
|
|
22
|
+
get minute(): number;
|
|
23
|
+
get second(): number;
|
|
24
|
+
get utc(): boolean;
|
|
25
|
+
/**
|
|
26
|
+
* Creates a new DateTime object from the given date and time components.
|
|
27
|
+
*/
|
|
28
|
+
static create(year: number, month: number, day: number, hour: number, minute: number, second: number, utc: boolean): DateTime;
|
|
29
|
+
/**
|
|
30
|
+
* This method is shorthand for `DateTime.create` with `utc` set to `false`.
|
|
31
|
+
*/
|
|
32
|
+
static local(year: number, month: number, day: number, hour: number, minute: number, second: number): DateTime;
|
|
33
|
+
/**
|
|
34
|
+
* This method is shorthand for `DateTime.create` with `utc` set to `true`.
|
|
35
|
+
*/
|
|
36
|
+
static utc(year: number, month: number, day: number, hour: number, minute: number, second: number): DateTime;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a new DateTime object from the given plain object.
|
|
39
|
+
*/
|
|
40
|
+
static fromObject(object: DateTimeLike, options?: FromObjectOptions): DateTime;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a new DateTime object from provided string representation of a date according to RFC 5545.
|
|
43
|
+
*/
|
|
44
|
+
static fromString(str: string): DateTime;
|
|
45
|
+
/**
|
|
46
|
+
* Converts DateTime into a plain object.
|
|
47
|
+
*/
|
|
48
|
+
toObject(): DateTimeLike;
|
|
49
|
+
/**
|
|
50
|
+
* Converts DateTime into ISO 8601 string:
|
|
51
|
+
* - `YYYYMMDDTHHMMSSZ` for UTC
|
|
52
|
+
* - `YYYYMMDDTHHMMSS` for local
|
|
53
|
+
*/
|
|
54
|
+
toString(): string;
|
|
55
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* eslint-disable */
|
|
2
|
+
/* prettier-ignore */
|
|
3
|
+
|
|
4
|
+
/* auto-generated by NAPI-RS */
|
|
5
|
+
|
|
6
|
+
const __nodeFs = require('node:fs')
|
|
7
|
+
const __nodePath = require('node:path')
|
|
8
|
+
const { WASI: __nodeWASI } = require('node:wasi')
|
|
9
|
+
const { Worker } = require('node:worker_threads')
|
|
10
|
+
|
|
11
|
+
const {
|
|
12
|
+
createOnMessage: __wasmCreateOnMessageForFsProxy,
|
|
13
|
+
getDefaultContext: __emnapiGetDefaultContext,
|
|
14
|
+
instantiateNapiModuleSync: __emnapiInstantiateNapiModuleSync,
|
|
15
|
+
} = require('@napi-rs/wasm-runtime')
|
|
16
|
+
|
|
17
|
+
const __rootDir = __nodePath.parse(process.cwd()).root
|
|
18
|
+
|
|
19
|
+
const __wasi = new __nodeWASI({
|
|
20
|
+
version: 'preview1',
|
|
21
|
+
env: process.env,
|
|
22
|
+
preopens: {
|
|
23
|
+
[__rootDir]: __rootDir,
|
|
24
|
+
}
|
|
25
|
+
})
|
|
26
|
+
|
|
27
|
+
const __emnapiContext = __emnapiGetDefaultContext()
|
|
28
|
+
|
|
29
|
+
const __sharedMemory = new WebAssembly.Memory({
|
|
30
|
+
initial: 4000,
|
|
31
|
+
maximum: 65536,
|
|
32
|
+
shared: true,
|
|
33
|
+
})
|
|
34
|
+
|
|
35
|
+
let __wasmFilePath = __nodePath.join(__dirname, 'rrule-rust.wasm32-wasi.wasm')
|
|
36
|
+
const __wasmDebugFilePath = __nodePath.join(__dirname, 'rrule-rust.wasm32-wasi.debug.wasm')
|
|
37
|
+
|
|
38
|
+
if (__nodeFs.existsSync(__wasmDebugFilePath)) {
|
|
39
|
+
__wasmFilePath = __wasmDebugFilePath
|
|
40
|
+
} else if (!__nodeFs.existsSync(__wasmFilePath)) {
|
|
41
|
+
try {
|
|
42
|
+
__wasmFilePath = __nodePath.resolve('@rrule-rust/lib-wasm32-wasi')
|
|
43
|
+
} catch {
|
|
44
|
+
throw new Error('Cannot find rrule-rust.wasm32-wasi.wasm file, and @rrule-rust/lib-wasm32-wasi package is not installed.')
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const { instance: __napiInstance, module: __wasiModule, napiModule: __napiModule } = __emnapiInstantiateNapiModuleSync(__nodeFs.readFileSync(__wasmFilePath), {
|
|
49
|
+
context: __emnapiContext,
|
|
50
|
+
asyncWorkPoolSize: (function() {
|
|
51
|
+
const threadsSizeFromEnv = Number(process.env.NAPI_RS_ASYNC_WORK_POOL_SIZE ?? process.env.UV_THREADPOOL_SIZE)
|
|
52
|
+
// NaN > 0 is false
|
|
53
|
+
if (threadsSizeFromEnv > 0) {
|
|
54
|
+
return threadsSizeFromEnv
|
|
55
|
+
} else {
|
|
56
|
+
return 4
|
|
57
|
+
}
|
|
58
|
+
})(),
|
|
59
|
+
reuseWorker: true,
|
|
60
|
+
wasi: __wasi,
|
|
61
|
+
onCreateWorker() {
|
|
62
|
+
const worker = new Worker(__nodePath.join(__dirname, 'wasi-worker.mjs'), {
|
|
63
|
+
env: process.env,
|
|
64
|
+
})
|
|
65
|
+
worker.onmessage = ({ data }) => {
|
|
66
|
+
__wasmCreateOnMessageForFsProxy(__nodeFs)(data)
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// The main thread of Node.js waits for all the active handles before exiting.
|
|
70
|
+
// But Rust threads are never waited without `thread::join`.
|
|
71
|
+
// So here we hack the code of Node.js to prevent the workers from being referenced (active).
|
|
72
|
+
// According to https://github.com/nodejs/node/blob/19e0d472728c79d418b74bddff588bea70a403d0/lib/internal/worker.js#L415,
|
|
73
|
+
// a worker is consist of two handles: kPublicPort and kHandle.
|
|
74
|
+
{
|
|
75
|
+
const kPublicPort = Object.getOwnPropertySymbols(worker).find(s =>
|
|
76
|
+
s.toString().includes("kPublicPort")
|
|
77
|
+
);
|
|
78
|
+
if (kPublicPort) {
|
|
79
|
+
worker[kPublicPort].ref = () => {};
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const kHandle = Object.getOwnPropertySymbols(worker).find(s =>
|
|
83
|
+
s.toString().includes("kHandle")
|
|
84
|
+
);
|
|
85
|
+
if (kHandle) {
|
|
86
|
+
worker[kHandle].ref = () => {};
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
worker.unref();
|
|
90
|
+
}
|
|
91
|
+
return worker
|
|
92
|
+
},
|
|
93
|
+
overwriteImports(importObject) {
|
|
94
|
+
importObject.env = {
|
|
95
|
+
...importObject.env,
|
|
96
|
+
...importObject.napi,
|
|
97
|
+
...importObject.emnapi,
|
|
98
|
+
memory: __sharedMemory,
|
|
99
|
+
}
|
|
100
|
+
return importObject
|
|
101
|
+
},
|
|
102
|
+
beforeInit({ instance }) {
|
|
103
|
+
for (const name of Object.keys(instance.exports)) {
|
|
104
|
+
if (name.startsWith('__napi_register__')) {
|
|
105
|
+
instance.exports[name]()
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
},
|
|
109
|
+
})
|
|
110
|
+
module.exports = __napiModule.exports
|
|
111
|
+
module.exports.RRule = __napiModule.exports.RRule
|
|
112
|
+
module.exports.RRuleSet = __napiModule.exports.RRuleSet
|
|
113
|
+
module.exports.RRuleSetIterator = __napiModule.exports.RRuleSetIterator
|
|
114
|
+
module.exports.Frequency = __napiModule.exports.Frequency
|
|
115
|
+
module.exports.Month = __napiModule.exports.Month
|
|
116
|
+
module.exports.Weekday = __napiModule.exports.Weekday
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { RRule } from './rrule';
|
|
2
|
+
import { DateTime } from './datetime';
|
|
3
|
+
export interface RRuleSetLike {
|
|
4
|
+
readonly dtstart: DateTime;
|
|
5
|
+
readonly tzid?: string;
|
|
6
|
+
readonly rrules: readonly RRule[];
|
|
7
|
+
readonly exrules: readonly RRule[];
|
|
8
|
+
readonly exdates: readonly DateTime[];
|
|
9
|
+
readonly rdates: readonly DateTime[];
|
|
10
|
+
}
|
|
11
|
+
export declare class RRuleSet implements Iterable<DateTime> {
|
|
12
|
+
readonly dtstart: DateTime;
|
|
13
|
+
readonly tzid: string;
|
|
14
|
+
readonly rrules: readonly RRule[];
|
|
15
|
+
readonly exrules: readonly RRule[];
|
|
16
|
+
readonly exdates: readonly DateTime[];
|
|
17
|
+
readonly rdates: readonly DateTime[];
|
|
18
|
+
constructor(dtstart: DateTime, tzid?: string);
|
|
19
|
+
constructor(options: Partial<RRuleSetLike>);
|
|
20
|
+
/**
|
|
21
|
+
* Parses a string into an RRuleSet.
|
|
22
|
+
*/
|
|
23
|
+
static parse(str: string): RRuleSet;
|
|
24
|
+
setDtstart(dtstart: DateTime): RRuleSet;
|
|
25
|
+
setTzid(tzid: string): RRuleSet;
|
|
26
|
+
addRrule(rrule: RRule): RRuleSet;
|
|
27
|
+
setRrules(rrules: readonly RRule[]): RRuleSet;
|
|
28
|
+
addExrule(rrule: RRule): RRuleSet;
|
|
29
|
+
setExrules(rrules: readonly RRule[]): RRuleSet;
|
|
30
|
+
addExdate(datetime: DateTime): RRuleSet;
|
|
31
|
+
setExdates(datetimes: readonly DateTime[]): RRuleSet;
|
|
32
|
+
addRdate(datetime: DateTime): RRuleSet;
|
|
33
|
+
setRdates(datetimes: readonly DateTime[]): RRuleSet;
|
|
34
|
+
/**
|
|
35
|
+
* Returns all the occurrences of the rrule.
|
|
36
|
+
*
|
|
37
|
+
* @param limit - The maximum number of occurrences to return.
|
|
38
|
+
*/
|
|
39
|
+
all(limit?: number): DateTime[];
|
|
40
|
+
/**
|
|
41
|
+
* Returns all the occurrences of the rrule between after and before.
|
|
42
|
+
*
|
|
43
|
+
* @param after - The lower bound date.
|
|
44
|
+
* @param before - The upper bound date.
|
|
45
|
+
* @param inclusive - Whether to include after and before in the list of occurrences.
|
|
46
|
+
*/
|
|
47
|
+
between(after: DateTime, before: DateTime, inclusive?: boolean): DateTime[];
|
|
48
|
+
/**
|
|
49
|
+
* Sets the RRuleSet from a string.
|
|
50
|
+
*
|
|
51
|
+
* @param str - The string to parse.
|
|
52
|
+
*/
|
|
53
|
+
setFromString(str: string): RRuleSet;
|
|
54
|
+
toString(): string;
|
|
55
|
+
/**
|
|
56
|
+
* Converts the RRuleSet to a plain object.
|
|
57
|
+
*/
|
|
58
|
+
toObject(): RRuleSetLike;
|
|
59
|
+
[Symbol.iterator](): Iterator<DateTime, any, any>;
|
|
60
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { DateTime } from './datetime';
|
|
2
|
+
export interface NWeekday {
|
|
3
|
+
/**
|
|
4
|
+
* If set, this represents the nth occurrence of the weekday.
|
|
5
|
+
* Otherwise it represents every occurrence of the weekday.
|
|
6
|
+
*
|
|
7
|
+
* A negative value represents nth occurrence from the end.
|
|
8
|
+
*/
|
|
9
|
+
n?: number;
|
|
10
|
+
weekday: Weekday;
|
|
11
|
+
}
|
|
12
|
+
export declare enum Frequency {
|
|
13
|
+
Yearly = 0,
|
|
14
|
+
Monthly = 1,
|
|
15
|
+
Weekly = 2,
|
|
16
|
+
Daily = 3,
|
|
17
|
+
Hourly = 4,
|
|
18
|
+
Minutely = 5,
|
|
19
|
+
Secondly = 6
|
|
20
|
+
}
|
|
21
|
+
export declare enum Month {
|
|
22
|
+
January = 1,
|
|
23
|
+
February = 2,
|
|
24
|
+
March = 3,
|
|
25
|
+
April = 4,
|
|
26
|
+
May = 5,
|
|
27
|
+
June = 6,
|
|
28
|
+
July = 7,
|
|
29
|
+
August = 8,
|
|
30
|
+
September = 9,
|
|
31
|
+
October = 10,
|
|
32
|
+
November = 11,
|
|
33
|
+
December = 12
|
|
34
|
+
}
|
|
35
|
+
export declare enum Weekday {
|
|
36
|
+
Monday = 0,
|
|
37
|
+
Tuesday = 1,
|
|
38
|
+
Wednesday = 2,
|
|
39
|
+
Thursday = 3,
|
|
40
|
+
Friday = 4,
|
|
41
|
+
Saturday = 5,
|
|
42
|
+
Sunday = 6
|
|
43
|
+
}
|
|
44
|
+
export interface RRuleLike {
|
|
45
|
+
readonly frequency: Frequency;
|
|
46
|
+
readonly interval?: number;
|
|
47
|
+
readonly count?: number;
|
|
48
|
+
readonly until?: DateTime;
|
|
49
|
+
readonly byWeekday: readonly (NWeekday | Weekday)[];
|
|
50
|
+
readonly byHour: readonly number[];
|
|
51
|
+
readonly byMinute: readonly number[];
|
|
52
|
+
readonly bySecond: readonly number[];
|
|
53
|
+
readonly byMonthday: readonly number[];
|
|
54
|
+
readonly bySetpos: readonly number[];
|
|
55
|
+
readonly byMonth: readonly Month[];
|
|
56
|
+
readonly byWeekno: readonly number[];
|
|
57
|
+
readonly byYearday: readonly number[];
|
|
58
|
+
readonly weekstart?: Weekday;
|
|
59
|
+
}
|
|
60
|
+
export declare class RRule {
|
|
61
|
+
readonly frequency: Frequency;
|
|
62
|
+
readonly interval?: number;
|
|
63
|
+
readonly until?: DateTime;
|
|
64
|
+
readonly count?: number;
|
|
65
|
+
readonly byWeekday: readonly (NWeekday | Weekday)[];
|
|
66
|
+
readonly byHour: readonly number[];
|
|
67
|
+
readonly byMinute: readonly number[];
|
|
68
|
+
readonly bySecond: readonly number[];
|
|
69
|
+
readonly byMonthday: readonly number[];
|
|
70
|
+
readonly bySetpos: readonly number[];
|
|
71
|
+
readonly byMonth: readonly Month[];
|
|
72
|
+
readonly byWeekno: readonly number[];
|
|
73
|
+
readonly byYearday: readonly number[];
|
|
74
|
+
readonly weekstart?: Weekday;
|
|
75
|
+
constructor(frequency: Frequency);
|
|
76
|
+
constructor(rrule?: Partial<RRuleLike>);
|
|
77
|
+
/**
|
|
78
|
+
* Parses a string into an RRule.
|
|
79
|
+
*/
|
|
80
|
+
static parse(str: string): RRule;
|
|
81
|
+
setFrequency(frequency: Frequency): RRule;
|
|
82
|
+
setInterval(interval: number): RRule;
|
|
83
|
+
setCount(count: number): RRule;
|
|
84
|
+
setByWeekday(weekdays: readonly (NWeekday | Weekday)[]): RRule;
|
|
85
|
+
setByHour(hours: readonly number[]): RRule;
|
|
86
|
+
setByMinute(minutes: readonly number[]): RRule;
|
|
87
|
+
setBySecond(seconds: readonly number[]): RRule;
|
|
88
|
+
setByMonthday(days: readonly number[]): RRule;
|
|
89
|
+
setBySetpos(poses: readonly number[]): RRule;
|
|
90
|
+
setByMonth(months: readonly Month[]): RRule;
|
|
91
|
+
setByWeekno(weekNumbers: readonly number[]): RRule;
|
|
92
|
+
setByYearday(days: readonly number[]): RRule;
|
|
93
|
+
setWeekstart(day: Weekday): RRule;
|
|
94
|
+
setUntil(datetime: DateTime): RRule;
|
|
95
|
+
toString(): string;
|
|
96
|
+
toObject(): RRuleLike;
|
|
97
|
+
}
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrule-rust",
|
|
3
|
-
"version": "3.0.0-alpha.
|
|
4
|
-
"main": "dist/index.js",
|
|
5
|
-
"
|
|
3
|
+
"version": "3.0.0-alpha.3",
|
|
4
|
+
"main": "dist/node/index.js",
|
|
5
|
+
"browser": "dist/browser/index.js",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"rrule",
|
|
8
8
|
"icalendar",
|
|
9
9
|
"rust",
|
|
10
|
+
"wasm",
|
|
10
11
|
"rs"
|
|
11
12
|
],
|
|
12
|
-
"description": "RRule implementation for Node.js written in Rust",
|
|
13
|
+
"description": "RRule implementation for browsers and Node.js written in Rust",
|
|
13
14
|
"repository": "lsndr/rrule-rust",
|
|
14
15
|
"author": {
|
|
15
16
|
"name": "lsndr",
|
|
@@ -32,11 +33,13 @@
|
|
|
32
33
|
"x86_64-unknown-freebsd",
|
|
33
34
|
"aarch64-unknown-linux-musl",
|
|
34
35
|
"aarch64-pc-windows-msvc",
|
|
35
|
-
"armv7-linux-androideabi"
|
|
36
|
+
"armv7-linux-androideabi",
|
|
37
|
+
"wasm32-wasip1-threads"
|
|
36
38
|
]
|
|
37
39
|
},
|
|
38
40
|
"license": "MIT",
|
|
39
41
|
"devDependencies": {
|
|
42
|
+
"@atao60/fse-cli": "^0.1.9",
|
|
40
43
|
"@commitlint/cli": "^19.3.0",
|
|
41
44
|
"@commitlint/config-conventional": "^19.2.2",
|
|
42
45
|
"@eslint-community/eslint-plugin-eslint-comments": "^4.5.0",
|
|
@@ -49,7 +52,6 @@
|
|
|
49
52
|
"@types/node": "^22.1.0",
|
|
50
53
|
"benny": "^3.7.1",
|
|
51
54
|
"conventional-changelog-conventionalcommits": "^7.0.2",
|
|
52
|
-
"cpy-cli": "^5.0.0",
|
|
53
55
|
"cross-env": "^7.0.3",
|
|
54
56
|
"eslint": "^9.27.0",
|
|
55
57
|
"eslint-config-prettier": "^10.1.5",
|
|
@@ -72,12 +74,15 @@
|
|
|
72
74
|
"node": ">= 10"
|
|
73
75
|
},
|
|
74
76
|
"scripts": {
|
|
75
|
-
"artifacts": "napi artifacts",
|
|
77
|
+
"artifacts": "napi artifacts --build-output-dir src/lib",
|
|
76
78
|
"build:lib": "napi build --no-const-enum --platform --release --output-dir src/lib",
|
|
77
|
-
"prebuild": "
|
|
78
|
-
"build": "
|
|
79
|
+
"prebuild": "fse remove --quiet ./dist",
|
|
80
|
+
"build": "npm run build:lib && npm run build:node && npm run build:browser",
|
|
81
|
+
"prebuild:node": "fse remove --quiet ./dist/node",
|
|
82
|
+
"build:node": "tsc -p ./tsconfig.node.json && fse copy --quiet ./src/lib/index.js ./dist/node/lib/index.js && fse copy --quiet ./src/lib/rrule-rust.wasi.cjs ./dist/node/lib/rrule-rust.wasi.cjs",
|
|
83
|
+
"prebuild:browser": "fse remove --quiet ./dist/browser",
|
|
84
|
+
"build:browser": "tsc -p ./tsconfig.browser.json && fse copy --quiet ./src/lib/browser.js ./dist/browser/lib/index.js",
|
|
79
85
|
"build:tests": "tsc -p ./tsconfig.test.json",
|
|
80
|
-
"postbuild": "cpy ./src/lib/* ./dist/lib --flat",
|
|
81
86
|
"test": "cross-env TZ=Europe/Moscow jest --testPathIgnorePatterns=\\.e2e\\.spec\\.ts",
|
|
82
87
|
"test:e2e": "jest --testMatch='**/*.e2e.spec.ts' --runInBand",
|
|
83
88
|
"universal": "napi universal",
|
|
@@ -91,18 +96,19 @@
|
|
|
91
96
|
"prepublishOnly": "npm run build && napi prepublish -t npm"
|
|
92
97
|
},
|
|
93
98
|
"optionalDependencies": {
|
|
94
|
-
"@rrule-rust/lib-win32-x64-msvc": "3.0.0-alpha.
|
|
95
|
-
"@rrule-rust/lib-darwin-x64": "3.0.0-alpha.
|
|
96
|
-
"@rrule-rust/lib-linux-x64-gnu": "3.0.0-alpha.
|
|
97
|
-
"@rrule-rust/lib-linux-x64-musl": "3.0.0-alpha.
|
|
98
|
-
"@rrule-rust/lib-linux-arm64-gnu": "3.0.0-alpha.
|
|
99
|
-
"@rrule-rust/lib-win32-ia32-msvc": "3.0.0-alpha.
|
|
100
|
-
"@rrule-rust/lib-linux-arm-gnueabihf": "3.0.0-alpha.
|
|
101
|
-
"@rrule-rust/lib-darwin-arm64": "3.0.0-alpha.
|
|
102
|
-
"@rrule-rust/lib-android-arm64": "3.0.0-alpha.
|
|
103
|
-
"@rrule-rust/lib-freebsd-x64": "3.0.0-alpha.
|
|
104
|
-
"@rrule-rust/lib-linux-arm64-musl": "3.0.0-alpha.
|
|
105
|
-
"@rrule-rust/lib-win32-arm64-msvc": "3.0.0-alpha.
|
|
106
|
-
"@rrule-rust/lib-android-arm-eabi": "3.0.0-alpha.
|
|
99
|
+
"@rrule-rust/lib-win32-x64-msvc": "3.0.0-alpha.3",
|
|
100
|
+
"@rrule-rust/lib-darwin-x64": "3.0.0-alpha.3",
|
|
101
|
+
"@rrule-rust/lib-linux-x64-gnu": "3.0.0-alpha.3",
|
|
102
|
+
"@rrule-rust/lib-linux-x64-musl": "3.0.0-alpha.3",
|
|
103
|
+
"@rrule-rust/lib-linux-arm64-gnu": "3.0.0-alpha.3",
|
|
104
|
+
"@rrule-rust/lib-win32-ia32-msvc": "3.0.0-alpha.3",
|
|
105
|
+
"@rrule-rust/lib-linux-arm-gnueabihf": "3.0.0-alpha.3",
|
|
106
|
+
"@rrule-rust/lib-darwin-arm64": "3.0.0-alpha.3",
|
|
107
|
+
"@rrule-rust/lib-android-arm64": "3.0.0-alpha.3",
|
|
108
|
+
"@rrule-rust/lib-freebsd-x64": "3.0.0-alpha.3",
|
|
109
|
+
"@rrule-rust/lib-linux-arm64-musl": "3.0.0-alpha.3",
|
|
110
|
+
"@rrule-rust/lib-win32-arm64-msvc": "3.0.0-alpha.3",
|
|
111
|
+
"@rrule-rust/lib-android-arm-eabi": "3.0.0-alpha.3",
|
|
112
|
+
"@rrule-rust/lib-wasm32-wasi": "3.0.0-alpha.3"
|
|
107
113
|
}
|
|
108
114
|
}
|
package/dist/lib/index.d.ts
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
/* auto-generated by NAPI-RS */
|
|
2
|
-
/* eslint-disable */
|
|
3
|
-
export declare class RRule {
|
|
4
|
-
constructor(frequency: Frequency, interval?: number | undefined | null, count?: number | undefined | null, weekstart?: Weekday | undefined | null, until?: number | undefined | null, byWeekday?: (readonly (NWeekday | Weekday)[]) | undefined | null, byHour?: (readonly number[]) | undefined | null, byMinute?: (readonly number[]) | undefined | null, bySecond?: (readonly number[]) | undefined | null, byMonthday?: (readonly number[]) | undefined | null, bySetpos?: (readonly number[]) | undefined | null, byMonth?: (readonly number[]) | undefined | null, byWeekno?: (readonly number[]) | undefined | null, byYearday?: (readonly number[]) | undefined | null)
|
|
5
|
-
static parse(str: string): RRule
|
|
6
|
-
get frequency(): Frequency
|
|
7
|
-
get interval(): number | null
|
|
8
|
-
get count(): number | null
|
|
9
|
-
get byWeekday(): NWeekday[]
|
|
10
|
-
get byHour(): Array<number>
|
|
11
|
-
get byMinute(): Array<number>
|
|
12
|
-
get bySecond(): Array<number>
|
|
13
|
-
get byMonthday(): Array<number>
|
|
14
|
-
get bySetpos(): Array<number>
|
|
15
|
-
get byMonth(): Month[]
|
|
16
|
-
get byWeekno(): Array<number>
|
|
17
|
-
get byYearday(): Array<number>
|
|
18
|
-
get weekstart(): Weekday | null
|
|
19
|
-
get until(): number | null
|
|
20
|
-
toString(): string
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
export declare class RRuleSet {
|
|
24
|
-
constructor(dtstart: number, tzid?: string | undefined | null, rrules?: (readonly RRule[]) | undefined | null, exrules?: (readonly RRule[]) | undefined | null, exdates?: (readonly number[]) | undefined | null, rdates?: (readonly number[]) | undefined | null)
|
|
25
|
-
get tzid(): string | null
|
|
26
|
-
get dtstart(): number
|
|
27
|
-
get rrules(): RRule[]
|
|
28
|
-
get exrules(): RRule[]
|
|
29
|
-
get exdates(): number[]
|
|
30
|
-
get rdates(): number[]
|
|
31
|
-
static parse(str: string): RRuleSet
|
|
32
|
-
all(limit?: number | undefined | null): number[]
|
|
33
|
-
between(afterDatetime: number, beforeDatetime: number, inclusive?: boolean | undefined | null): number[]
|
|
34
|
-
setFromString(str: string): this
|
|
35
|
-
toString(): string
|
|
36
|
-
iterator(): RRuleSetIterator
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
export declare class RRuleSetIterator {
|
|
40
|
-
next(): number | null
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
export declare enum Frequency {
|
|
44
|
-
Yearly = 0,
|
|
45
|
-
Monthly = 1,
|
|
46
|
-
Weekly = 2,
|
|
47
|
-
Daily = 3,
|
|
48
|
-
Hourly = 4,
|
|
49
|
-
Minutely = 5,
|
|
50
|
-
Secondly = 6
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
export declare enum Month {
|
|
54
|
-
January = 1,
|
|
55
|
-
February = 2,
|
|
56
|
-
March = 3,
|
|
57
|
-
April = 4,
|
|
58
|
-
May = 5,
|
|
59
|
-
June = 6,
|
|
60
|
-
July = 7,
|
|
61
|
-
August = 8,
|
|
62
|
-
September = 9,
|
|
63
|
-
October = 10,
|
|
64
|
-
November = 11,
|
|
65
|
-
December = 12
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
export interface NWeekday {
|
|
69
|
-
n?: number
|
|
70
|
-
weekday: Weekday
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export declare enum Weekday {
|
|
74
|
-
Monday = 0,
|
|
75
|
-
Tuesday = 1,
|
|
76
|
-
Wednesday = 2,
|
|
77
|
-
Thursday = 3,
|
|
78
|
-
Friday = 4,
|
|
79
|
-
Saturday = 5,
|
|
80
|
-
Sunday = 6
|
|
81
|
-
}
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|