rrule-rust 2.1.0-alpha.2 → 2.1.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/dist/browser/datetime.js +1 -5
- package/dist/browser/index.js +3 -19
- package/dist/browser/rrule-set.js +17 -21
- package/dist/browser/rrule.js +12 -16
- package/package.json +19 -20
- package/dist/browser/lib/browser.d.ts +0 -1
- package/dist/browser/lib/rrule-rust.wasi-browser.d.ts +0 -6
- package/dist/browser/lib/rrule-rust.wasi.d.cts +0 -1
- package/dist/browser/lib/wasi-worker-browser.d.mts +0 -1
- package/dist/browser/lib/wasi-worker.d.mts +0 -1
package/dist/browser/datetime.js
CHANGED
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DateTime = void 0;
|
|
4
1
|
/**
|
|
5
2
|
* Represents a date and time. Either local or UTC.
|
|
6
3
|
*/
|
|
7
|
-
class DateTime {
|
|
4
|
+
export class DateTime {
|
|
8
5
|
constructor(numeric) {
|
|
9
6
|
this.numeric = numeric;
|
|
10
7
|
}
|
|
@@ -121,4 +118,3 @@ class DateTime {
|
|
|
121
118
|
return this.numeric;
|
|
122
119
|
}
|
|
123
120
|
}
|
|
124
|
-
exports.DateTime = DateTime;
|
package/dist/browser/index.js
CHANGED
|
@@ -1,19 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
-
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
-
};
|
|
16
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
__exportStar(require("./rrule-set"), exports);
|
|
18
|
-
__exportStar(require("./rrule"), exports);
|
|
19
|
-
__exportStar(require("./datetime"), exports);
|
|
1
|
+
export * from './rrule-set';
|
|
2
|
+
export * from './rrule';
|
|
3
|
+
export * from './datetime';
|
|
@@ -1,18 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const _lib_1 = require("@rrule-rust/lib-wasm32-wasi");
|
|
6
|
-
const datetime_1 = require("./datetime");
|
|
7
|
-
class RRuleSet {
|
|
1
|
+
import { RRule } from './rrule';
|
|
2
|
+
import { RRuleSet as Rust } from '@rrule-rust/lib-wasm32-wasi';
|
|
3
|
+
import { DateTime } from './datetime';
|
|
4
|
+
export class RRuleSet {
|
|
8
5
|
constructor(setOrDtstart, tzid) {
|
|
9
|
-
if (!(setOrDtstart instanceof
|
|
6
|
+
if (!(setOrDtstart instanceof DateTime)) {
|
|
10
7
|
if (setOrDtstart?.dtstart) {
|
|
11
8
|
this.dtstart = setOrDtstart?.dtstart;
|
|
12
9
|
}
|
|
13
10
|
else {
|
|
14
11
|
const date = new Date();
|
|
15
|
-
this.dtstart =
|
|
12
|
+
this.dtstart = DateTime.create(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), true);
|
|
16
13
|
}
|
|
17
14
|
this.tzid = setOrDtstart?.tzid ?? 'UTC';
|
|
18
15
|
this.rrules = setOrDtstart?.rrules ?? [];
|
|
@@ -20,7 +17,7 @@ class RRuleSet {
|
|
|
20
17
|
this.exdates = setOrDtstart?.exdates ?? [];
|
|
21
18
|
this.rdates = setOrDtstart?.rdates ?? [];
|
|
22
19
|
}
|
|
23
|
-
else if (setOrDtstart instanceof
|
|
20
|
+
else if (setOrDtstart instanceof DateTime && typeof tzid === 'string') {
|
|
24
21
|
this.dtstart = setOrDtstart;
|
|
25
22
|
this.tzid = tzid;
|
|
26
23
|
this.rrules = [];
|
|
@@ -36,7 +33,7 @@ class RRuleSet {
|
|
|
36
33
|
* Parses a string into an RRuleSet.
|
|
37
34
|
*/
|
|
38
35
|
static parse(str) {
|
|
39
|
-
const rust =
|
|
36
|
+
const rust = Rust.parse(str);
|
|
40
37
|
return this.fromRust(rust);
|
|
41
38
|
}
|
|
42
39
|
/**
|
|
@@ -44,12 +41,12 @@ class RRuleSet {
|
|
|
44
41
|
*/
|
|
45
42
|
static fromRust(rust) {
|
|
46
43
|
const set = new RRuleSet({
|
|
47
|
-
dtstart:
|
|
44
|
+
dtstart: DateTime.fromNumeric(rust.dtstart),
|
|
48
45
|
tzid: rust.tzid ?? undefined,
|
|
49
|
-
rrules: rust.rrules.map((rrule) =>
|
|
50
|
-
exrules: rust.exrules.map((rrule) =>
|
|
51
|
-
exdates: rust.exdates.map((datetime) =>
|
|
52
|
-
rdates: rust.rdates.map((datetime) =>
|
|
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)),
|
|
53
50
|
});
|
|
54
51
|
set.rust = rust;
|
|
55
52
|
return set;
|
|
@@ -122,7 +119,7 @@ class RRuleSet {
|
|
|
122
119
|
all(limit) {
|
|
123
120
|
return this.toRust()
|
|
124
121
|
.all(limit)
|
|
125
|
-
.map((datetime) =>
|
|
122
|
+
.map((datetime) => DateTime.fromNumeric(datetime));
|
|
126
123
|
}
|
|
127
124
|
/**
|
|
128
125
|
* Returns all the occurrences of the rrule between after and before.
|
|
@@ -134,7 +131,7 @@ class RRuleSet {
|
|
|
134
131
|
between(after, before, inclusive) {
|
|
135
132
|
return this.toRust()
|
|
136
133
|
.between(after.toNumeric(), before.toNumeric(), inclusive)
|
|
137
|
-
.map((datetime) =>
|
|
134
|
+
.map((datetime) => DateTime.fromNumeric(datetime));
|
|
138
135
|
}
|
|
139
136
|
/**
|
|
140
137
|
* Sets the RRuleSet from a string.
|
|
@@ -149,7 +146,7 @@ class RRuleSet {
|
|
|
149
146
|
*/
|
|
150
147
|
toRust() {
|
|
151
148
|
if (!this.rust) {
|
|
152
|
-
this.rust = new
|
|
149
|
+
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()));
|
|
153
150
|
}
|
|
154
151
|
return this.rust;
|
|
155
152
|
}
|
|
@@ -182,10 +179,9 @@ class RRuleSet {
|
|
|
182
179
|
}
|
|
183
180
|
return {
|
|
184
181
|
done: false,
|
|
185
|
-
value:
|
|
182
|
+
value: DateTime.fromNumeric(result),
|
|
186
183
|
};
|
|
187
184
|
},
|
|
188
185
|
};
|
|
189
186
|
}
|
|
190
187
|
}
|
|
191
|
-
exports.RRuleSet = RRuleSet;
|
package/dist/browser/rrule.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
const datetime_1 = require("./datetime");
|
|
5
|
-
const _lib_1 = require("@rrule-rust/lib-wasm32-wasi");
|
|
6
|
-
var Frequency;
|
|
1
|
+
import { DateTime } from './datetime';
|
|
2
|
+
import { RRule as Rust } from '@rrule-rust/lib-wasm32-wasi';
|
|
3
|
+
export var Frequency;
|
|
7
4
|
(function (Frequency) {
|
|
8
5
|
Frequency[Frequency["Yearly"] = 0] = "Yearly";
|
|
9
6
|
Frequency[Frequency["Monthly"] = 1] = "Monthly";
|
|
@@ -12,8 +9,8 @@ var Frequency;
|
|
|
12
9
|
Frequency[Frequency["Hourly"] = 4] = "Hourly";
|
|
13
10
|
Frequency[Frequency["Minutely"] = 5] = "Minutely";
|
|
14
11
|
Frequency[Frequency["Secondly"] = 6] = "Secondly";
|
|
15
|
-
})(Frequency || (
|
|
16
|
-
var Month;
|
|
12
|
+
})(Frequency || (Frequency = {}));
|
|
13
|
+
export var Month;
|
|
17
14
|
(function (Month) {
|
|
18
15
|
Month[Month["January"] = 1] = "January";
|
|
19
16
|
Month[Month["February"] = 2] = "February";
|
|
@@ -27,8 +24,8 @@ var Month;
|
|
|
27
24
|
Month[Month["October"] = 10] = "October";
|
|
28
25
|
Month[Month["November"] = 11] = "November";
|
|
29
26
|
Month[Month["December"] = 12] = "December";
|
|
30
|
-
})(Month || (
|
|
31
|
-
var Weekday;
|
|
27
|
+
})(Month || (Month = {}));
|
|
28
|
+
export var Weekday;
|
|
32
29
|
(function (Weekday) {
|
|
33
30
|
Weekday[Weekday["Monday"] = 0] = "Monday";
|
|
34
31
|
Weekday[Weekday["Tuesday"] = 1] = "Tuesday";
|
|
@@ -37,8 +34,8 @@ var Weekday;
|
|
|
37
34
|
Weekday[Weekday["Friday"] = 4] = "Friday";
|
|
38
35
|
Weekday[Weekday["Saturday"] = 5] = "Saturday";
|
|
39
36
|
Weekday[Weekday["Sunday"] = 6] = "Sunday";
|
|
40
|
-
})(Weekday || (
|
|
41
|
-
class RRule {
|
|
37
|
+
})(Weekday || (Weekday = {}));
|
|
38
|
+
export class RRule {
|
|
42
39
|
constructor(rruleOrFrequency = {}) {
|
|
43
40
|
if (typeof rruleOrFrequency === 'object' && rruleOrFrequency !== null) {
|
|
44
41
|
this.frequency = rruleOrFrequency.frequency ?? Frequency.Daily;
|
|
@@ -73,7 +70,7 @@ class RRule {
|
|
|
73
70
|
* Parses a string into an RRule.
|
|
74
71
|
*/
|
|
75
72
|
static parse(str) {
|
|
76
|
-
const rust =
|
|
73
|
+
const rust = Rust.parse(str);
|
|
77
74
|
return this.fromRust(rust);
|
|
78
75
|
}
|
|
79
76
|
/**
|
|
@@ -83,7 +80,7 @@ class RRule {
|
|
|
83
80
|
const rrule = new this({
|
|
84
81
|
frequency: rust.frequency,
|
|
85
82
|
interval: rust.interval ?? undefined,
|
|
86
|
-
until: rust.until === null ? undefined :
|
|
83
|
+
until: rust.until === null ? undefined : DateTime.fromNumeric(rust.until),
|
|
87
84
|
count: rust.count === null ? undefined : rust.count,
|
|
88
85
|
byWeekday: rust.byWeekday,
|
|
89
86
|
byHour: rust.byHour,
|
|
@@ -149,7 +146,7 @@ class RRule {
|
|
|
149
146
|
*/
|
|
150
147
|
toRust() {
|
|
151
148
|
if (!this.rust) {
|
|
152
|
-
this.rust = new
|
|
149
|
+
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);
|
|
153
150
|
}
|
|
154
151
|
return this.rust;
|
|
155
152
|
}
|
|
@@ -172,4 +169,3 @@ class RRule {
|
|
|
172
169
|
};
|
|
173
170
|
}
|
|
174
171
|
}
|
|
175
|
-
exports.RRule = RRule;
|
package/package.json
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rrule-rust",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.3",
|
|
4
4
|
"main": "dist/node/index.js",
|
|
5
|
-
"
|
|
6
|
-
"browser": "dist/node/browser.js",
|
|
5
|
+
"browser": "dist/browser/index.js",
|
|
7
6
|
"keywords": [
|
|
8
7
|
"rrule",
|
|
9
8
|
"icalendar",
|
|
@@ -83,7 +82,7 @@
|
|
|
83
82
|
"build:node": "tsc -p ./tsconfig.build.json --outDir dist/node",
|
|
84
83
|
"postbuild:node": "cpy ./src/lib/* ./dist/node/lib --flat && tsc-alias -p tsconfig.replacer.json --replacer ./node.replacer.js",
|
|
85
84
|
"prebuild:browser": "rimraf ./dist/browser",
|
|
86
|
-
"build:browser": "tsc -p ./tsconfig.
|
|
85
|
+
"build:browser": "tsc -p ./tsconfig.browser.json --outDir dist/browser",
|
|
87
86
|
"postbuild:browser": "cpy ./src/lib/* ./dist/browser/lib --flat && tsc-alias -p tsconfig.replacer.json --replacer ./browser.replacer.js",
|
|
88
87
|
"build": "npm run build:node && npm run build:browser",
|
|
89
88
|
"prepublishOnly": "napi prepublish -t npm",
|
|
@@ -99,21 +98,21 @@
|
|
|
99
98
|
"prepare": "husky && npm run build"
|
|
100
99
|
},
|
|
101
100
|
"optionalDependencies": {
|
|
102
|
-
"@rrule-rust/lib-win32-x64-msvc": "2.1.0-alpha.
|
|
103
|
-
"@rrule-rust/lib-darwin-x64": "2.1.0-alpha.
|
|
104
|
-
"@rrule-rust/lib-linux-x64-gnu": "2.1.0-alpha.
|
|
105
|
-
"@rrule-rust/lib-linux-x64-musl": "2.1.0-alpha.
|
|
106
|
-
"@rrule-rust/lib-linux-arm64-gnu": "2.1.0-alpha.
|
|
107
|
-
"@rrule-rust/lib-win32-ia32-msvc": "2.1.0-alpha.
|
|
108
|
-
"@rrule-rust/lib-linux-arm-gnueabihf": "2.1.0-alpha.
|
|
109
|
-
"@rrule-rust/lib-darwin-arm64": "2.1.0-alpha.
|
|
110
|
-
"@rrule-rust/lib-android-arm64": "2.1.0-alpha.
|
|
111
|
-
"@rrule-rust/lib-freebsd-x64": "2.1.0-alpha.
|
|
112
|
-
"@rrule-rust/lib-linux-arm64-musl": "2.1.0-alpha.
|
|
113
|
-
"@rrule-rust/lib-win32-arm64-msvc": "2.1.0-alpha.
|
|
114
|
-
"@rrule-rust/lib-android-arm-eabi": "2.1.0-alpha.
|
|
115
|
-
"@rrule-rust/lib-linux-ppc64-gnu": "2.1.0-alpha.
|
|
116
|
-
"@rrule-rust/lib-linux-s390x-gnu": "2.1.0-alpha.
|
|
117
|
-
"@rrule-rust/lib-wasm32-wasi": "2.1.0-alpha.
|
|
101
|
+
"@rrule-rust/lib-win32-x64-msvc": "2.1.0-alpha.3",
|
|
102
|
+
"@rrule-rust/lib-darwin-x64": "2.1.0-alpha.3",
|
|
103
|
+
"@rrule-rust/lib-linux-x64-gnu": "2.1.0-alpha.3",
|
|
104
|
+
"@rrule-rust/lib-linux-x64-musl": "2.1.0-alpha.3",
|
|
105
|
+
"@rrule-rust/lib-linux-arm64-gnu": "2.1.0-alpha.3",
|
|
106
|
+
"@rrule-rust/lib-win32-ia32-msvc": "2.1.0-alpha.3",
|
|
107
|
+
"@rrule-rust/lib-linux-arm-gnueabihf": "2.1.0-alpha.3",
|
|
108
|
+
"@rrule-rust/lib-darwin-arm64": "2.1.0-alpha.3",
|
|
109
|
+
"@rrule-rust/lib-android-arm64": "2.1.0-alpha.3",
|
|
110
|
+
"@rrule-rust/lib-freebsd-x64": "2.1.0-alpha.3",
|
|
111
|
+
"@rrule-rust/lib-linux-arm64-musl": "2.1.0-alpha.3",
|
|
112
|
+
"@rrule-rust/lib-win32-arm64-msvc": "2.1.0-alpha.3",
|
|
113
|
+
"@rrule-rust/lib-android-arm-eabi": "2.1.0-alpha.3",
|
|
114
|
+
"@rrule-rust/lib-linux-ppc64-gnu": "2.1.0-alpha.3",
|
|
115
|
+
"@rrule-rust/lib-linux-s390x-gnu": "2.1.0-alpha.3",
|
|
116
|
+
"@rrule-rust/lib-wasm32-wasi": "2.1.0-alpha.3"
|
|
118
117
|
}
|
|
119
118
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|