@moltenship/calendar-recurrence 1.0.0-rc.1 → 2.0.0-beta.1
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.d.mts +0 -32
- package/dist/index.mjs +26 -52
- package/package.json +18 -8
package/dist/index.d.mts
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { IcsEvent, IcsExtensionsConfig, IcsIssueCode, IcsRecurrenceRule, IcsWeekdayNumber } from "@moltenship/ics";
|
|
2
2
|
import { CalendarEvent, CalendarEventChange, CalendarEventInterval, CalendarEventPlacement, EventAdapter, EventId, ResourceId } from "@moltenship/calendar-core";
|
|
3
|
-
//#region src/types.d.ts
|
|
4
3
|
/**
|
|
5
4
|
* A point in a series' own time: an `Instant` for timed series, a `PlainDate` for all-day ones and
|
|
6
5
|
* a `PlainDateTime` for floating ones. Occurrence starts, RECURRENCE-ID, EXDATE, RDATE and UNTIL
|
|
@@ -207,8 +206,6 @@ interface RecurrenceRuleExpansion {
|
|
|
207
206
|
*/
|
|
208
207
|
readonly truncated: boolean;
|
|
209
208
|
}
|
|
210
|
-
//#endregion
|
|
211
|
-
//#region src/dates.d.ts
|
|
212
209
|
/** What a date means to a series, which decides how a date of another kind converts. */
|
|
213
210
|
type RecurrenceDateRole = "exception" | "start" | "until";
|
|
214
211
|
interface CoerceRecurrenceDateOptions {
|
|
@@ -226,8 +223,6 @@ interface CoerceRecurrenceDateOptions {
|
|
|
226
223
|
* series; report it as `date-kind-mismatch` and drop only that date.
|
|
227
224
|
*/
|
|
228
225
|
export declare function coerceRecurrenceDate(date: RecurrenceDate, first: CalendarEventInterval, role: RecurrenceDateRole, options?: CoerceRecurrenceDateOptions): RecurrenceDate | undefined;
|
|
229
|
-
//#endregion
|
|
230
|
-
//#region src/errors.d.ts
|
|
231
226
|
/** The `RecurrenceIssue` code a rule error becomes in the series layer. */
|
|
232
227
|
type RecurrenceRuleErrorCode = "invalid-rule" | "invalid-time-zone" | "unsupported-rule";
|
|
233
228
|
/** Why `expandRecurrenceRule` can't expand a rule. */
|
|
@@ -235,8 +230,6 @@ export declare class RecurrenceRuleError extends RangeError {
|
|
|
235
230
|
readonly code: RecurrenceRuleErrorCode;
|
|
236
231
|
constructor(code: RecurrenceRuleErrorCode, message: string);
|
|
237
232
|
}
|
|
238
|
-
//#endregion
|
|
239
|
-
//#region src/occurrence-id.d.ts
|
|
240
233
|
/**
|
|
241
234
|
* The ISO form of an occurrence's original start: `2026-10-28T09:00:00Z` for timed series,
|
|
242
235
|
* `2026-10-28` for all-day ones and `2026-10-28T10:00:00` for floating ones, always in the ISO
|
|
@@ -259,8 +252,6 @@ export declare function parseOccurrenceId(id: EventId): {
|
|
|
259
252
|
readonly recurrenceKey: string;
|
|
260
253
|
readonly seriesId: string;
|
|
261
254
|
} | undefined;
|
|
262
|
-
//#endregion
|
|
263
|
-
//#region src/rule/expand.d.ts
|
|
264
255
|
export declare const DEFAULT_MAX_ITERATIONS = 1e5;
|
|
265
256
|
/**
|
|
266
257
|
* The starts of a rule's occurrences inside `window`, strictly increasing, for every part of
|
|
@@ -294,8 +285,6 @@ export declare const DEFAULT_MAX_ITERATIONS = 1e5;
|
|
|
294
285
|
* `maxIterations` that isn't a positive integer.
|
|
295
286
|
*/
|
|
296
287
|
export declare function expandRecurrenceRule(rule: RecurrenceRule, first: RecurrenceRuleStart, window?: RecurrenceRuleWindow): RecurrenceRuleExpansion;
|
|
297
|
-
//#endregion
|
|
298
|
-
//#region src/rule/text.d.ts
|
|
299
288
|
/** A problem `parseRecurrenceRule` found. Errors leave no rule; warnings keep a best-effort one. */
|
|
300
289
|
interface RecurrenceRuleTextIssue {
|
|
301
290
|
/** The code `@moltenship/ics` reports it under, such as `invalid-value` or `unsupported`. */
|
|
@@ -332,12 +321,8 @@ export declare function formatRecurrenceRule(rule: RecurrenceRule): string;
|
|
|
332
321
|
export declare function recurrenceRuleFromIcs(rule: IcsRecurrenceRule): RecurrenceRuleTextResult;
|
|
333
322
|
/** A rule as `@moltenship/ics` writes it: UNTIL as a DATE, a UTC DATE-TIME or a floating one. */
|
|
334
323
|
export declare function recurrenceRuleToIcs(rule: RecurrenceRule): IcsRecurrenceRule;
|
|
335
|
-
//#endregion
|
|
336
|
-
//#region src/series/canonical-adapter.d.ts
|
|
337
324
|
/** Adapters for `RecurringCalendarEvent`, for applications without their own event type. */
|
|
338
325
|
export declare function createCanonicalRecurrenceAdapter<TData = unknown, TEventId extends EventId = string, TResourceId extends ResourceId = string>(): RecurrenceAdapters<RecurringCalendarEvent<TData, TEventId, TResourceId>, TEventId, TResourceId>;
|
|
339
|
-
//#endregion
|
|
340
|
-
//#region src/series/expander.d.ts
|
|
341
326
|
/**
|
|
342
327
|
* Expands the application's events into what the calendar shows for a range: each series' master
|
|
343
328
|
* becomes its occurrences that overlap the range, overrides replace the occurrences they name, and
|
|
@@ -371,8 +356,6 @@ export declare function createCanonicalRecurrenceAdapter<TData = unknown, TEvent
|
|
|
371
356
|
* zone reports `invalid-time-zone` for each date that needs it.
|
|
372
357
|
*/
|
|
373
358
|
export declare function createOccurrenceExpander<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId>(adapters: RecurrenceAdapters<TEvent, TEventId, TResourceId>, options?: OccurrenceExpanderOptions): OccurrenceExpander<TEvent, TEventId>;
|
|
374
|
-
//#endregion
|
|
375
|
-
//#region src/series/occurrence-adapter.d.ts
|
|
376
359
|
/**
|
|
377
360
|
* Hands occurrences to the calendar as events: their IDs and intervals, and the title, resources,
|
|
378
361
|
* read-only and busy state of the event they show, through `eventAdapter`.
|
|
@@ -383,8 +366,6 @@ export declare function createOccurrenceExpander<TEvent, TEventId extends EventI
|
|
|
383
366
|
* what the expander reuses work by: replace events rather than changing them.
|
|
384
367
|
*/
|
|
385
368
|
export declare function createOccurrenceAdapter<TEvent, TEventId extends EventId, TResourceId extends ResourceId>(eventAdapter: EventAdapter<TEvent, TEventId, TResourceId>): EventAdapter<RecurrenceOccurrence<TEvent, TEventId>, TEventId | string, TResourceId>;
|
|
386
|
-
//#endregion
|
|
387
|
-
//#region src/ics/recurring-events.d.ts
|
|
388
369
|
type IcsRecurrenceIssueCode = "date-kind-mismatch" | "duplicate-event" | "invalid-period" | "unresolved-time-zone" | "unsupported-rule";
|
|
389
370
|
interface IcsRecurrenceIssue<TExtensions extends IcsExtensionsConfig = {}> {
|
|
390
371
|
readonly code: IcsRecurrenceIssueCode;
|
|
@@ -469,8 +450,6 @@ interface IcsRecurringEvents<TExtensions extends IcsExtensionsConfig = {}> {
|
|
|
469
450
|
* Bad data becomes `issues`; only invalid options throw, as a `RangeError`.
|
|
470
451
|
*/
|
|
471
452
|
export declare function recurringEventsFromIcs<TExtensions extends IcsExtensionsConfig = {}>(events: readonly IcsEvent<TExtensions>[], options?: IcsRecurringEventsOptions): IcsRecurringEvents<TExtensions>;
|
|
472
|
-
//#endregion
|
|
473
|
-
//#region src/edits/ordinals.d.ts
|
|
474
453
|
/**
|
|
475
454
|
* How a move rewrites a rule's ordinal weekdays, such as the 2nd Tuesday to the 2nd Wednesday. Each
|
|
476
455
|
* occurrence stays in its month (or year) and becomes the new weekday there, which isn't always a
|
|
@@ -484,8 +463,6 @@ interface RecurrenceOrdinalShift {
|
|
|
484
463
|
/** What the ordinals count within. */
|
|
485
464
|
readonly period: "month" | "year";
|
|
486
465
|
}
|
|
487
|
-
//#endregion
|
|
488
|
-
//#region src/edits/types.d.ts
|
|
489
466
|
/**
|
|
490
467
|
* Which occurrences an edit to one occurrence applies to: `"this"` one, this and the
|
|
491
468
|
* `"following"` ones, or `"all"` of them. The registry's scope dialog declares the same union.
|
|
@@ -684,8 +661,6 @@ interface RecurrenceEditRejection {
|
|
|
684
661
|
readonly type: "rejected";
|
|
685
662
|
}
|
|
686
663
|
type RecurrenceEdit<TEvent, TEventId extends EventId = EventId, TResourceId extends ResourceId = ResourceId> = RecurrenceEventEdit<TEvent, TEventId, TResourceId> | RecurrenceSeriesEdit<TEvent, TEventId, TResourceId> | RecurrenceEditRejection;
|
|
687
|
-
//#endregion
|
|
688
|
-
//#region src/edits/apply.d.ts
|
|
689
664
|
interface ApplyRecurrenceEditOptions<TData, TEventId extends EventId, TResourceId extends ResourceId> {
|
|
690
665
|
/**
|
|
691
666
|
* The ID of an event the edit creates: an override, or the series a `"following"` edit starts
|
|
@@ -702,8 +677,6 @@ type Event<TData, TEventId extends EventId, TResourceId extends ResourceId> = Re
|
|
|
702
677
|
* Applications with their own event type or store write the same steps themselves.
|
|
703
678
|
*/
|
|
704
679
|
export declare function applyRecurrenceEdit<TData, TEventId extends EventId, TResourceId extends ResourceId>(events: readonly Event<TData, TEventId, TResourceId>[], edit: RecurrenceSeriesEdit<Event<TData, TEventId, TResourceId>, TEventId, TResourceId>, options: ApplyRecurrenceEditOptions<TData, TEventId, TResourceId>): Event<TData, TEventId, TResourceId>[];
|
|
705
|
-
//#endregion
|
|
706
|
-
//#region src/edits/overrides.d.ts
|
|
707
680
|
/**
|
|
708
681
|
* What an edit does to one of the series' other overrides, by its `recurrenceId`. Apply it to every
|
|
709
682
|
* override of `edit.seriesId` the application stores, loaded or not; the edited occurrence's own
|
|
@@ -711,11 +684,7 @@ export declare function applyRecurrenceEdit<TData, TEventId extends EventId, TRe
|
|
|
711
684
|
* start and series; its own placement stays.
|
|
712
685
|
*/
|
|
713
686
|
export declare function recurrenceOverrideEdit<TEvent, TEventId extends EventId, TResourceId extends ResourceId>(edit: RecurrenceSeriesEdit<TEvent, TEventId, TResourceId>, recurrenceId: RecurrenceDate): RecurrenceOverrideRekey;
|
|
714
|
-
//#endregion
|
|
715
|
-
//#region src/edits/series.d.ts
|
|
716
687
|
type Change<TEvent, TEventId extends EventId, TResourceId extends ResourceId> = RecurringOccurrenceChange<TEvent, TEventId, TResourceId>;
|
|
717
|
-
//#endregion
|
|
718
|
-
//#region src/edits/resolve.d.ts
|
|
719
688
|
/**
|
|
720
689
|
* Whether a change is to an occurrence of a series, so the application should ask for a scope. A
|
|
721
690
|
* create, or a change to a one-off event, needs none; `resolveRecurrenceEdit` passes it through.
|
|
@@ -782,5 +751,4 @@ export declare function resolveRecurrenceEdit<TEvent, TEventId extends EventId,
|
|
|
782
751
|
* occurrence. Hand them to the scope dialog.
|
|
783
752
|
*/
|
|
784
753
|
export declare function recurrenceEditScopes<TEvent, TEventId extends EventId, TResourceId extends ResourceId>(change: RecurrenceOccurrenceChange<TEvent, TEventId, TResourceId>, adapters: RecurrenceAdapters<TEvent, TEventId, TResourceId>, options?: ResolveRecurrenceEditOptions<TEvent, TEventId>): readonly RecurrenceEditScope[];
|
|
785
|
-
//#endregion
|
|
786
754
|
export type { ApplyRecurrenceEditOptions, CoerceRecurrenceDateOptions, EventRecurrence, IcsRecurrenceIssue, IcsRecurrenceIssueCode, IcsRecurringEvents, IcsRecurringEventsOptions, OccurrenceExpander, OccurrenceExpanderOptions, OccurrenceExpansion, OccurrenceRange, OccurrenceRecurrence, RecurrenceAdapter, RecurrenceAdapters, RecurrenceDate, RecurrenceDateRole, RecurrenceEdit, RecurrenceEditRejection, RecurrenceEditRejectionReason, RecurrenceEditScope, RecurrenceEventEdit, RecurrenceIssue, RecurrenceKeyShift, RecurrenceNewSeries, RecurrenceOccurrence, RecurrenceOccurrenceChange, RecurrenceOrdinalShift, RecurrenceOverride, RecurrenceOverrideRekey, RecurrenceOverrideWrite, RecurrenceOverridesRule, RecurrencePeriod, RecurrenceRule, RecurrenceRuleErrorCode, RecurrenceRuleExpansion, RecurrenceRuleStart, RecurrenceRuleTextIssue, RecurrenceRuleTextResult, RecurrenceRuleWindow, RecurrenceSeriesEdit, RecurrenceSeriesWrite, RecurringCalendarEvent, RecurringOccurrenceChange, ResolveRecurrenceEditOptions };
|
package/dist/index.mjs
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { decodeIcsValue, encodeIcsValue, getEventEnd } from "@moltenship/ics";
|
|
2
2
|
import { createCanonicalEventAdapter } from "@moltenship/calendar-core";
|
|
3
|
-
|
|
3
|
+
// src/internal/dates.ts
|
|
4
4
|
/** Each kind's date type, with its article. */
|
|
5
5
|
const dateTypes = {
|
|
6
6
|
"all-day": "a PlainDate",
|
|
@@ -140,8 +140,7 @@ const weekdays = [
|
|
|
140
140
|
"SA",
|
|
141
141
|
"SU"
|
|
142
142
|
];
|
|
143
|
-
|
|
144
|
-
//#region src/dates.ts
|
|
143
|
+
// src/dates.ts
|
|
145
144
|
function isoDate(date) {
|
|
146
145
|
return date.withCalendar("iso8601");
|
|
147
146
|
}
|
|
@@ -174,8 +173,7 @@ function coerceRecurrenceDate(date, first, role, options = {}) {
|
|
|
174
173
|
if (role === "exception") return isoDate(date);
|
|
175
174
|
if (role === "until") return isoDate(date).toPlainDateTime(Temporal.PlainTime.from("23:59:59.999999999"));
|
|
176
175
|
}
|
|
177
|
-
|
|
178
|
-
//#region src/errors.ts
|
|
176
|
+
// src/errors.ts
|
|
179
177
|
/** Why `expandRecurrenceRule` can't expand a rule. */
|
|
180
178
|
var RecurrenceRuleError = class extends RangeError {
|
|
181
179
|
code;
|
|
@@ -185,8 +183,7 @@ var RecurrenceRuleError = class extends RangeError {
|
|
|
185
183
|
this.code = code;
|
|
186
184
|
}
|
|
187
185
|
};
|
|
188
|
-
|
|
189
|
-
//#region src/occurrence-id.ts
|
|
186
|
+
// src/occurrence-id.ts
|
|
190
187
|
const separator = "::";
|
|
191
188
|
/**
|
|
192
189
|
* The ISO form of an occurrence's original start: `2026-10-28T09:00:00Z` for timed series,
|
|
@@ -233,8 +230,7 @@ function isRecurrenceKey(key) {
|
|
|
233
230
|
return false;
|
|
234
231
|
}
|
|
235
232
|
}
|
|
236
|
-
|
|
237
|
-
//#region src/rule/calendar.ts
|
|
233
|
+
// src/rule/calendar.ts
|
|
238
234
|
const SECONDS_PER_DAY = 86400;
|
|
239
235
|
function floorDiv(dividend, divisor) {
|
|
240
236
|
return Math.floor(dividend / divisor);
|
|
@@ -292,8 +288,7 @@ function toPlainDateTime(wall, nanoseconds = 0) {
|
|
|
292
288
|
const second = wall - days * SECONDS_PER_DAY;
|
|
293
289
|
return new Temporal.PlainDateTime(year, month, day, floorDiv(second, 3600), floorDiv(second % 3600, 60), second % 60, floorDiv(nanoseconds, 1e6), floorDiv(nanoseconds % 1e6, 1e3), nanoseconds % 1e3);
|
|
294
290
|
}
|
|
295
|
-
|
|
296
|
-
//#region src/rule/compile.ts
|
|
291
|
+
// src/rule/compile.ts
|
|
297
292
|
/** FREQ, from the longest period to the shortest. */
|
|
298
293
|
const Frequency = {
|
|
299
294
|
Yearly: 0,
|
|
@@ -505,8 +500,7 @@ function compileRule(rule, start) {
|
|
|
505
500
|
yearDays: byYearDay && new Set(byYearDay)
|
|
506
501
|
};
|
|
507
502
|
}
|
|
508
|
-
|
|
509
|
-
//#region src/rule/candidates.ts
|
|
503
|
+
// src/rule/candidates.ts
|
|
510
504
|
/** `Candidates.next` result for a step that found nothing. */
|
|
511
505
|
const NOTHING = Number.NEGATIVE_INFINITY;
|
|
512
506
|
/** `Candidates.next` result once the calendar runs out. */
|
|
@@ -746,8 +740,7 @@ var Candidates = class {
|
|
|
746
740
|
this.#picked = [...picked].sort((left, right) => left - right);
|
|
747
741
|
}
|
|
748
742
|
};
|
|
749
|
-
|
|
750
|
-
//#region src/rule/clock.ts
|
|
743
|
+
// src/rule/clock.ts
|
|
751
744
|
const MARGIN = 172800;
|
|
752
745
|
/**
|
|
753
746
|
* Resolves wall seconds in one time zone to epoch seconds as RFC 5545 §3.3.5 does, which is
|
|
@@ -804,8 +797,7 @@ function offsetChangeBefore(instant, timeZone) {
|
|
|
804
797
|
const before = previous.subtract({ nanoseconds: 1 });
|
|
805
798
|
return Math.ceil(Math.abs(previous.offsetNanoseconds - before.offsetNanoseconds) / 1e9);
|
|
806
799
|
}
|
|
807
|
-
|
|
808
|
-
//#region src/rule/expand.ts
|
|
800
|
+
// src/rule/expand.ts
|
|
809
801
|
const DEFAULT_MAX_ITERATIONS = 1e5;
|
|
810
802
|
const NANOSECONDS_PER_SECOND = 1000000000n;
|
|
811
803
|
const KINDS = {
|
|
@@ -982,8 +974,7 @@ function expandRecurrenceRule(rule, first, window = {}) {
|
|
|
982
974
|
truncated: false
|
|
983
975
|
};
|
|
984
976
|
}
|
|
985
|
-
|
|
986
|
-
//#region src/rule/text.ts
|
|
977
|
+
// src/rule/text.ts
|
|
987
978
|
/** `RRULE:`, with any parameters, and the space some writers leave after the colon. */
|
|
988
979
|
const RRULE_PREFIX = /^RRULE(?:;[^:]*)?:\s*/i;
|
|
989
980
|
function quote(text) {
|
|
@@ -1074,8 +1065,7 @@ function recurrenceRuleToIcs(rule) {
|
|
|
1074
1065
|
until: recurrenceDateToIcs(until)
|
|
1075
1066
|
};
|
|
1076
1067
|
}
|
|
1077
|
-
|
|
1078
|
-
//#region src/series/canonical-adapter.ts
|
|
1068
|
+
// src/series/canonical-adapter.ts
|
|
1079
1069
|
/** Adapters for `RecurringCalendarEvent`, for applications without their own event type. */
|
|
1080
1070
|
function createCanonicalRecurrenceAdapter() {
|
|
1081
1071
|
return {
|
|
@@ -1086,8 +1076,7 @@ function createCanonicalRecurrenceAdapter() {
|
|
|
1086
1076
|
}
|
|
1087
1077
|
};
|
|
1088
1078
|
}
|
|
1089
|
-
|
|
1090
|
-
//#region src/series/expander.ts
|
|
1079
|
+
// src/series/expander.ts
|
|
1091
1080
|
const rangesPerSeries = 4;
|
|
1092
1081
|
const windowsPerSeries = 8;
|
|
1093
1082
|
/** An instant on an all-day or floating series while `defaultTimeZone` isn't a time zone. */
|
|
@@ -1629,8 +1618,7 @@ function createOccurrenceExpander(adapters, options = {}) {
|
|
|
1629
1618
|
return result;
|
|
1630
1619
|
} };
|
|
1631
1620
|
}
|
|
1632
|
-
|
|
1633
|
-
//#region src/series/occurrence-adapter.ts
|
|
1621
|
+
// src/series/occurrence-adapter.ts
|
|
1634
1622
|
const identities = /* @__PURE__ */ new WeakMap();
|
|
1635
1623
|
const intervalKeys = /* @__PURE__ */ new WeakMap();
|
|
1636
1624
|
let nextIdentity = 0;
|
|
@@ -1685,8 +1673,7 @@ function createOccurrenceAdapter(eventAdapter) {
|
|
|
1685
1673
|
...isReadOnly === void 0 ? {} : { isReadOnly: (occurrence) => isReadOnly(occurrence.event) }
|
|
1686
1674
|
};
|
|
1687
1675
|
}
|
|
1688
|
-
|
|
1689
|
-
//#region src/ics/dates.ts
|
|
1676
|
+
// src/ics/dates.ts
|
|
1690
1677
|
function instantOf(value) {
|
|
1691
1678
|
if (value.kind === "utc") return value.instant;
|
|
1692
1679
|
return value.kind === "zoned" ? value.zoned.toInstant() : void 0;
|
|
@@ -1775,8 +1762,7 @@ function toSeriesPeriod(period, series) {
|
|
|
1775
1762
|
mismatch: "RDATE PERIOD doesn't end after it starts in the series' kind; only its start was kept."
|
|
1776
1763
|
};
|
|
1777
1764
|
}
|
|
1778
|
-
|
|
1779
|
-
//#region src/edits/ordinals.ts
|
|
1765
|
+
// src/edits/ordinals.ts
|
|
1780
1766
|
function position(date, period) {
|
|
1781
1767
|
return period === "month" ? {
|
|
1782
1768
|
index: date.day,
|
|
@@ -1816,8 +1802,7 @@ function mapOrdinal(shift, date) {
|
|
|
1816
1802
|
if (date.dayOfWeek === weekdayNumbers[from.weekday] && ordinalOf(date, shift.period, ordinal < 0) === ordinal) return nthWeekday(date, shift.period, to) ?? null;
|
|
1817
1803
|
}
|
|
1818
1804
|
}
|
|
1819
|
-
|
|
1820
|
-
//#region src/edits/keys.ts
|
|
1805
|
+
// src/edits/keys.ts
|
|
1821
1806
|
/** Reads a stored date in the old series' kind, as the expander does. */
|
|
1822
1807
|
function readKey(shift, date, role) {
|
|
1823
1808
|
return coerceRecurrenceDate(date, shift.first, role, { defaultTimeZone: shift.timeZone });
|
|
@@ -1891,8 +1876,7 @@ function rekeyExtra(shift, extra) {
|
|
|
1891
1876
|
};
|
|
1892
1877
|
return moved;
|
|
1893
1878
|
}
|
|
1894
|
-
|
|
1895
|
-
//#region src/edits/overrides.ts
|
|
1879
|
+
// src/edits/overrides.ts
|
|
1896
1880
|
const keep = { action: "keep" };
|
|
1897
1881
|
/**
|
|
1898
1882
|
* What an edit does to one of the series' other overrides, by its `recurrenceId`. Apply it to every
|
|
@@ -1915,8 +1899,7 @@ function recurrenceOverrideEdit(edit, recurrenceId) {
|
|
|
1915
1899
|
series
|
|
1916
1900
|
};
|
|
1917
1901
|
}
|
|
1918
|
-
|
|
1919
|
-
//#region src/edits/apply.ts
|
|
1902
|
+
// src/edits/apply.ts
|
|
1920
1903
|
/** The event at `placement`, without the fields of its old kind. */
|
|
1921
1904
|
function placed(event, placement) {
|
|
1922
1905
|
const { end: _end, kind: _kind, sourceTimeZone: _zone, start: _start, ...rest } = event;
|
|
@@ -2002,8 +1985,7 @@ function applyRecurrenceEdit(events, edit, options) {
|
|
|
2002
1985
|
}
|
|
2003
1986
|
return [...next, ...created];
|
|
2004
1987
|
}
|
|
2005
|
-
|
|
2006
|
-
//#region src/edits/rule-shift.ts
|
|
1988
|
+
// src/edits/rule-shift.ts
|
|
2007
1989
|
function shiftWeekday(weekday, days) {
|
|
2008
1990
|
return weekdays[((weekdays.indexOf(weekday) + days) % 7 + 7) % 7];
|
|
2009
1991
|
}
|
|
@@ -2156,8 +2138,7 @@ function shiftRule(rule, shift) {
|
|
|
2156
2138
|
const shifted = shiftDays(next, shift);
|
|
2157
2139
|
return typeof shifted === "string" ? { problem: shifted } : shifted;
|
|
2158
2140
|
}
|
|
2159
|
-
|
|
2160
|
-
//#region src/edits/series.ts
|
|
2141
|
+
// src/edits/series.ts
|
|
2161
2142
|
const noIds = /* @__PURE__ */ new Map();
|
|
2162
2143
|
function reject(reason, message) {
|
|
2163
2144
|
return {
|
|
@@ -2478,8 +2459,7 @@ function overrideOf(change, adapters) {
|
|
|
2478
2459
|
eventId: adapters.event.getId(event)
|
|
2479
2460
|
};
|
|
2480
2461
|
}
|
|
2481
|
-
|
|
2482
|
-
//#region src/edits/scope-all.ts
|
|
2462
|
+
// src/edits/scope-all.ts
|
|
2483
2463
|
/**
|
|
2484
2464
|
* `"all"`: the master moves by the edited occurrence's delta from its original start, and its rule,
|
|
2485
2465
|
* EXDATEs, RDATEs, UNTIL and overrides' original starts move with it. A delete removes the series.
|
|
@@ -2603,8 +2583,7 @@ function resolveAll(change, series, adapters, options) {
|
|
|
2603
2583
|
}
|
|
2604
2584
|
};
|
|
2605
2585
|
}
|
|
2606
|
-
|
|
2607
|
-
//#region src/edits/scope-following.ts
|
|
2586
|
+
// src/edits/scope-following.ts
|
|
2608
2587
|
function withoutCount(rule) {
|
|
2609
2588
|
const { count: _count, ...rest } = rule;
|
|
2610
2589
|
return rest;
|
|
@@ -2781,8 +2760,7 @@ function resolveFollowing(change, series, adapters, options) {
|
|
|
2781
2760
|
series: endedSeries
|
|
2782
2761
|
};
|
|
2783
2762
|
}
|
|
2784
|
-
|
|
2785
|
-
//#region src/edits/scope-this.ts
|
|
2763
|
+
// src/edits/scope-this.ts
|
|
2786
2764
|
const keepOthers = {
|
|
2787
2765
|
action: "keep",
|
|
2788
2766
|
series: "current"
|
|
@@ -2870,8 +2848,7 @@ function resolveThis(change, adapters, options) {
|
|
|
2870
2848
|
}
|
|
2871
2849
|
};
|
|
2872
2850
|
}
|
|
2873
|
-
|
|
2874
|
-
//#region src/edits/resolve.ts
|
|
2851
|
+
// src/edits/resolve.ts
|
|
2875
2852
|
const scopes = [
|
|
2876
2853
|
"this",
|
|
2877
2854
|
"following",
|
|
@@ -2978,8 +2955,7 @@ function recurrenceEditScopes(change, adapters, options = {}) {
|
|
|
2978
2955
|
return edit.type === "series" && edit.scope === scope;
|
|
2979
2956
|
});
|
|
2980
2957
|
}
|
|
2981
|
-
|
|
2982
|
-
//#region src/ics/this-and-future.ts
|
|
2958
|
+
// src/ics/this-and-future.ts
|
|
2983
2959
|
/** Only the interval's fields of an event. */
|
|
2984
2960
|
function intervalOf$1(event) {
|
|
2985
2961
|
return event.kind === "timed" ? {
|
|
@@ -3173,8 +3149,7 @@ function applyThisAndFuture(input, ranges, timeZone) {
|
|
|
3173
3149
|
failures
|
|
3174
3150
|
};
|
|
3175
3151
|
}
|
|
3176
|
-
|
|
3177
|
-
//#region src/ics/recurring-events.ts
|
|
3152
|
+
// src/ics/recurring-events.ts
|
|
3178
3153
|
const defaultMinimumDuration = { minutes: 30 };
|
|
3179
3154
|
function minimumDurationOf(input) {
|
|
3180
3155
|
let duration;
|
|
@@ -3516,5 +3491,4 @@ function recurringEventsFromIcs(events, options = {}) {
|
|
|
3516
3491
|
issues: issues.sort((left, right) => left.index - right.index)
|
|
3517
3492
|
};
|
|
3518
3493
|
}
|
|
3519
|
-
//#endregion
|
|
3520
3494
|
export { DEFAULT_MAX_ITERATIONS, RecurrenceRuleError, applyRecurrenceEdit, coerceRecurrenceDate, createCanonicalRecurrenceAdapter, createOccurrenceAdapter, createOccurrenceExpander, expandRecurrenceRule, formatRecurrenceRule, isRecurringChange, occurrenceId, parseOccurrenceId, parseRecurrenceRule, recurrenceEditScopes, recurrenceKey, recurrenceOverrideEdit, recurrenceRuleFromIcs, recurrenceRuleToIcs, recurringEventsFromIcs, resolveRecurrenceEdit };
|
package/package.json
CHANGED
|
@@ -1,7 +1,20 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@moltenship/calendar-recurrence",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "2.0.0-beta.1",
|
|
4
4
|
"description": "Range-bounded recurrence for Moltenship Time: RRULE expansion, exceptions and series edits.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"calendar",
|
|
7
|
+
"event-calendar",
|
|
8
|
+
"exdate",
|
|
9
|
+
"framework-agnostic",
|
|
10
|
+
"icalendar",
|
|
11
|
+
"recurrence",
|
|
12
|
+
"recurring-events",
|
|
13
|
+
"rfc5545",
|
|
14
|
+
"rrule",
|
|
15
|
+
"temporal",
|
|
16
|
+
"typescript"
|
|
17
|
+
],
|
|
5
18
|
"homepage": "https://time.molten.sh/docs/api/recurrence",
|
|
6
19
|
"bugs": {
|
|
7
20
|
"url": "https://github.com/Moltenship/time/issues"
|
|
@@ -28,19 +41,16 @@
|
|
|
28
41
|
"access": "public"
|
|
29
42
|
},
|
|
30
43
|
"dependencies": {
|
|
31
|
-
"@moltenship/calendar-core": "
|
|
32
|
-
"@moltenship/
|
|
33
|
-
"@moltenship/ics": "1.0.0-rc.1"
|
|
44
|
+
"@moltenship/calendar-core": "2.0.0-beta.1",
|
|
45
|
+
"@moltenship/ics": "2.0.0-beta.1"
|
|
34
46
|
},
|
|
35
47
|
"devDependencies": {
|
|
36
48
|
"typescript": "^7.0.2",
|
|
37
|
-
"vite": "npm:@voidzero-dev/vite-plus-core@1.
|
|
38
|
-
"vite-plus": "1.
|
|
49
|
+
"vite": "npm:@voidzero-dev/vite-plus-core@1.4.0",
|
|
50
|
+
"vite-plus": "1.4.0"
|
|
39
51
|
},
|
|
40
52
|
"scripts": {
|
|
41
|
-
"bench": "vp pack && vp test bench",
|
|
42
53
|
"build": "vp pack",
|
|
43
|
-
"check": "vp check",
|
|
44
54
|
"dev": "vp pack --watch",
|
|
45
55
|
"test": "vp test"
|
|
46
56
|
}
|