@blamejs/core 0.11.35 → 0.11.37

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/CHANGELOG.md CHANGED
@@ -8,6 +8,10 @@ upgrading across more than a few patches at a time.
8
8
 
9
9
  ## v0.11.x
10
10
 
11
+ - v0.11.37 (2026-05-21) — **`b.calendar` VJOURNAL ↔ JSCalendar Note (RFC 5545 §3.6.3).** Closes the v0.11.31 deferral on VJOURNAL. `b.calendar.fromIcal` now recognises VJOURNAL components and maps them to JSCalendar-shaped Note objects (`@type: "Note"`). `b.calendar.toIcal` emits a VJOURNAL envelope when the input `@type` is `Note`. `b.calendar.validate` adds Note-specific shape rules: optional `start` LocalDateTime, no `duration` / `due` / `progress` / `percentComplete` / `progressUpdated` (those are Event / Task-only properties), optional `status` from the RFC 5545 §3.8.1.11 VJOURNAL vocabulary (`draft` | `final` | `cancelled`). VJOURNAL is the only iCalendar component that may carry multiple DESCRIPTION properties — Note preserves operator-visible boundaries by joining them with a blank-line separator. A VCALENDAR carrying VEVENT + VTODO + VJOURNAL children now returns a mixed `Event` + `Task` + `Note` array. **Added:** *`b.calendar.fromIcal` maps VJOURNAL → JSCalendar Note* — VJOURNAL components in the VCALENDAR map to `@type: "Note"` objects with `uid` / `updated` / `title` (SUMMARY) / `description` (DESCRIPTION) / `start` (DTSTART → LocalDateTime, optional) / `timeZone` / `status` (lower-cased STATUS) / `locations` / `recurrenceRules`. UTC DTSTART maps to `timeZone: "Etc/UTC"` the same way DTSTART does for Event. · *`b.calendar.toIcal` emits VJOURNAL when `@type === "Note"`* — The envelope is `BEGIN:VJOURNAL` / `END:VJOURNAL` instead of `BEGIN:VEVENT` or `BEGIN:VTODO`. Note's `status` round-trips uppercased per RFC 5545 §3.8.1.11. Note does NOT emit DURATION / DUE / PERCENT-COMPLETE / COMPLETED on the wire (those properties are forbidden on VJOURNAL per RFC 5545 §3.6.3 grammar). · *`b.calendar.validate` learns Note-specific shape rules (RFC 5545 §3.6.3)* — Note's `start` must be a LocalDateTime when present. Setting `duration`, `due`, `progress`, `percentComplete`, or `progressUpdated` on a Note is refused (those are Event / Task-only properties). `status` must be in the `JSCAL_NOTE_STATUS` catalogue (`draft` | `final` | `cancelled` — different from the Task progress vocabulary). Structured `CalendarError` codes: `calendar/bad-note-status` plus reuse of `calendar/bad-due`, `calendar/bad-progress`, `calendar/bad-duration`, `calendar/bad-percent`, `calendar/bad-progress-updated` for the forbidden-property refusals. · *Multiple DESCRIPTION properties preserved* — VJOURNAL is the only iCalendar component permitted to carry multiple DESCRIPTION properties (one per discrete journal entry). `fromIcal` joins them into a single Note.description with `\n\n` between entries, preserving the operator-visible boundary. Single-DESCRIPTION VJOURNALs map to the literal string with no join. · *Mixed-component VCALENDAR returns array of Event + Task + Note shapes* — A VCALENDAR carrying VEVENT + VTODO + VJOURNAL children now returns an Array — events first, tasks second, journals third, in their declared order. The single-component shortcut (returning the bare object) still applies when only one component is present. · *`JSCAL_TYPES.Note` and `JSCAL_NOTE_STATUS` exports* — `b.calendar.JSCAL_TYPES.Note === "Note"` (the discriminator string). `b.calendar.JSCAL_NOTE_STATUS` exposes the `draft` / `final` / `cancelled` vocabulary as a frozen object for operator-side enum lookups. **Changed:** *JSCalendar `Note` is a blamejs-recognised extension* — RFC 8984 §1.2 only enumerates `Event`, `Task`, and `Group` as discriminator values. `Note` is not formally an RFC 8984 type — blamejs adopts it as a recognised extension shape for VJOURNAL round-trip interop. Operators interoperating with strict RFC 8984 consumers should map Note → Group + a vendor-namespaced property before exchange. **References:** [RFC 5545 §3.6.3 (iCalendar VJOURNAL component)](https://www.rfc-editor.org/rfc/rfc5545.html#section-3.6.3) · [RFC 5545 §3.8.1.11 (STATUS — DRAFT/FINAL/CANCELLED on VJOURNAL)](https://www.rfc-editor.org/rfc/rfc5545.html#section-3.8.1.11) · [RFC 8984 §1.2 (JSCalendar @type discriminator)](https://www.rfc-editor.org/rfc/rfc8984.html#section-1.2)
12
+
13
+ - v0.11.36 (2026-05-21) — **`b.calendar.expandRecurrence` picks up BYWEEKNO / BYYEARDAY / BYHOUR / BYMINUTE / BYSECOND filters (RFC 5545 §3.3.10).** Closes the v0.11.31 deferral on the time-of-day and year-relative BY* filters. `expandRecurrence` now honours `byWeekNo` (ISO 8601 1..53 with negative-from-end semantics), `byYearDay` (1..366 with negative-from-end), `byHour` (0..23), `byMinute` (0..59), and `bySecond` (0..60 — covers POSIX leap-second representation). The expansion still operates as a per-step filter (stepping at the rule's FREQ, then dropping candidates that fail the BY* predicates) — BYSETPOS remains deferred-with-condition because it requires expanding ALL candidates within a FREQ interval and picking the Nth, which is a structural restructure of the expand loop. Operators with `last weekday of month`-style needs continue to see the same defer note from v0.11.31. **Added:** *`byWeekNo` filter — ISO 8601 week numbers* — `recurrenceRules[i].byWeekNo: [1, 53, -1]` filters candidates to the named ISO 8601 weeks. Negative values count from the end of the year (`-1` = last ISO week, which may be week 52 or week 53 depending on the year). The ISO week-of-year calculation matches the canonical algorithm — week 1 is the week containing the first Thursday of the year. · *`byYearDay` filter — day-of-year (1..366 / -1..-366)* — `recurrenceRules[i].byYearDay: [1, 366, -1]` filters by ordinal day-of-year. Negative values count from the end of the year, accounting for leap-year length (366 vs 365). With a `frequency: "daily"` rule + `byYearDay: [1]` the expander emits Jan 1 of each year. · *`byHour` / `byMinute` / `bySecond` time-of-day filters* — `byHour: [9, 17]` filters candidates by UTC hour-of-day (0..23). `byMinute: [0, 30]` (0..59). `bySecond: [0, 30, 60]` (0..60 — the leap-second representation in POSIX time). Most useful with sub-day frequencies — `frequency: "hourly"` + `byHour: [9, 17]` emits twice-daily at 9am and 5pm. · *Negative BY* semantics per RFC 5545 §3.3.10* — `byWeekNo: [-1]` matches the last ISO week of the year (computed via the Dec-28 anchor — Dec 28 always falls in the last ISO week). `byYearDay: [-1]` matches the last day of the year (uses the Gregorian leap-year rule to determine whether 365 or 366 is the correct ordinal). Both negative-value paths covered by tests. **Security:** *Same step-budget cap from v0.11.31 applies* — Sparse BY* filters (e.g. `byYearDay: [1]` with `frequency: "daily"` — only 1 in 365 candidates matches) still loop within the `MAX_EXPAND_INSTANCES * 366` step budget; the 10-year `MAX_EXPAND_SPAN_MS` window cap also applies. Operators can't construct a BY*-filter that loops past the bounded budget. · *Integer-range validation on every BY* value* — `byWeekNo` rejects values outside ±53. `byYearDay` rejects outside ±366. `byHour` 0..23. `byMinute` 0..59. `bySecond` 0..60. Adversarial-shape values silently drop from the set (no error — the rule continues with the surviving values per RFC 5545's tolerant grammar). **References:** [RFC 5545 §3.3.10 (RRULE — BYWEEKNO / BYYEARDAY / BYHOUR / BYMINUTE / BYSECOND)](https://www.rfc-editor.org/rfc/rfc5545.html#section-3.3.10) · [RFC 8984 §4.3.2 (JSCalendar RecurrenceRule)](https://www.rfc-editor.org/rfc/rfc8984.html#section-4.3.2) · [ISO 8601 (Week numbering)](https://www.iso.org/iso-8601-date-and-time-format.html)
14
+
11
15
  - v0.11.35 (2026-05-21) — **`b.calendar` VTODO ↔ JSCalendar Task (RFC 8984 §6).** Closes the v0.11.31 deferral. `b.calendar.fromIcal` now recognises VTODO components and maps them to JSCalendar Task objects per RFC 8984 §6. `b.calendar.toIcal` emits a VTODO envelope (with DUE / STATUS / PERCENT-COMPLETE / COMPLETED iCalendar properties) when the input `@type` is `Task`. `b.calendar.validate` picks up Task-specific shape rules: `due` as LocalDateTime, `estimatedDuration` as PnYnMnDTnHnMnS, `progress` from the RFC 8984 §6.4.3 vocabulary (`needs-action` | `in-process` | `completed` | `cancelled` | `failed`), `percentComplete` ∈ [0..100], `progressUpdated` as UTCDateTime. A VCALENDAR carrying both VEVENT and VTODO components now returns an array of mixed `Event` + `Task` shapes. **Added:** *`b.calendar.fromIcal` maps VTODO → JSCalendar Task* — VTODO components in the VCALENDAR are mapped to `@type: "Task"` objects with the same `uid` / `updated` / `title` / `description` / `start` / `timeZone` / `locations` / `recurrenceRules` slots Event uses, plus the Task-specific fields: `due` (DUE → LocalDateTime), `estimatedDuration` (DURATION), `progress` (STATUS lowercased), `percentComplete` (PERCENT-COMPLETE 0..100), `progressUpdated` (COMPLETED → UTCDateTime). UTC DUE values map to `timeZone: "Etc/UTC"` the same way DTSTART does. · *`b.calendar.toIcal` emits VTODO when `@type === "Task"`* — The envelope is `BEGIN:VTODO` / `END:VTODO` instead of `BEGIN:VEVENT`. Task-specific properties round-trip: `DUE` (with `;TZID=` parameter or `Z` suffix or floating local time per the same RFC 8984 §1.4.4 timeZone mapping as DTSTART), `STATUS` (uppercased), `PERCENT-COMPLETE`, `COMPLETED` (UTC). `estimatedDuration` maps to `DURATION` (RFC 5545 doesn't distinguish Event vs Task duration on the wire). · *`b.calendar.validate` learns Task-specific shape rules (RFC 8984 §6.4)* — `due` must be a LocalDateTime, `estimatedDuration` must match the same PnYnMnDTnHnMnS Duration grammar Event uses, `progress` must be in the `JSCAL_TASK_PROGRESS` catalogue (also exposed as a new top-level export), `percentComplete` must be a finite number in 0..100, `progressUpdated` must be a UTCDateTime. Structured `CalendarError` codes: `calendar/bad-due`, `calendar/bad-progress`, `calendar/bad-percent`, `calendar/bad-progress-updated`. · *Mixed-component VCALENDAR returns an array of Event + Task shapes* — When a VCALENDAR contains both VEVENT and VTODO children, `fromIcal` returns an Array — events first, tasks second, in their declared order. The single-component shortcut (returning the bare object) still applies when only one component is present. · *`calendar/no-vevent` error code renamed to `calendar/no-component`* — The refusal that fires when a VCALENDAR has no parseable child component now uses the more accurate `calendar/no-component` code (since VTODO is also valid). Operators that grep on the prior `calendar/no-vevent` code need to update the match; the human-facing error message also updates. **References:** [RFC 8984 §6 (JSCalendar Task)](https://www.rfc-editor.org/rfc/rfc8984.html#section-6) · [RFC 5545 §3.6.2 (iCalendar VTODO component)](https://www.rfc-editor.org/rfc/rfc5545.html#section-3.6.2) · [RFC 5545 §3.8.2.3 (DUE date-time)](https://www.rfc-editor.org/rfc/rfc5545.html#section-3.8.2.3) · [RFC 5545 §3.8.1.11 (STATUS — needs-action/in-process/completed/cancelled)](https://www.rfc-editor.org/rfc/rfc5545.html#section-3.8.1.11)
12
16
 
13
17
  - v0.11.34 (2026-05-21) — **JMAP WebSocket transport (RFC 8887) on `b.mail.server.jmap`.** Closes the v0.11.29 deferral. The JMAP listener now exposes `webSocketHandler(req, socket, head)` — a turnkey RFC 8887 transport built on the framework's `b.websocket.handleUpgrade`. Clients connect with the `jmap` subprotocol; bidirectional JSON frames carry `{ "@type": "Request" }` / `{ "@type": "WebSocketPushEnable" }` / `{ "@type": "WebSocketPushDisable" }` from the client, and `{ "@type": "Response" }` / `{ "@type": "StateChange" }` / `{ "@type": "RequestError" }` from the server. `Request` frames flow through the same `dispatch(actor, request)` path the HTTP `apiHandler` uses; `WebSocketPushEnable` hooks the operator's `mailStore.subscribePush(actor, types, emitFn)` and converts backend StateChange events into outbound WebSocket frames.
package/lib/calendar.js CHANGED
@@ -42,6 +42,14 @@ var CalendarError = defineClass("CalendarError", { alwaysPermanent: true });
42
42
  var JSCAL_TYPES = Object.freeze({
43
43
  Event: "Event",
44
44
  Task: "Task",
45
+ // Note maps RFC 5545 §3.6.3 VJOURNAL — a dated, free-form journal
46
+ // entry with no duration / progress / due semantics. Not formally
47
+ // defined as an @type in RFC 8984 §1.2 (which only enumerates
48
+ // Event + Task + Group); blamejs adopts `Note` as a recognised
49
+ // extension shape for VJOURNAL round-trip interop with iCalendar
50
+ // sources. Operators interoperating with strict RFC 8984 consumers
51
+ // should map Note → Group or Note → custom-@type before exchange.
52
+ Note: "Note",
45
53
  Group: "Group",
46
54
  Participant: "Participant",
47
55
  Location: "Location",
@@ -73,6 +81,15 @@ var JSCAL_TASK_PROGRESS = Object.freeze({
73
81
  "needs-action": 1, "in-process": 1, "completed": 1, "cancelled": 1,
74
82
  });
75
83
 
84
+ // RFC 5545 §3.8.1.11 STATUS for VJOURNAL — Note carries DRAFT / FINAL
85
+ // / CANCELLED. JSCalendar lower-cases them on import/export. Note's
86
+ // `status` is OPTIONAL; absence on the wire maps to `status`
87
+ // unset (rather than defaulting to "draft" — operator intent is
88
+ // ambiguous when STATUS is omitted, per RFC 5545 grammar).
89
+ var JSCAL_NOTE_STATUS = Object.freeze({
90
+ "draft": 1, "final": 1, "cancelled": 1,
91
+ });
92
+
76
93
  // Recurrence-expansion caps. Mirror b.safeIcal's RRULE limits so the
77
94
  // expand path can't outpace what the parser already permitted.
78
95
  var MAX_EXPAND_INSTANCES = 4096; // allow:raw-byte-literal — instance count cap, not bytes
@@ -106,9 +123,9 @@ function validate(jsCal) {
106
123
  "b.calendar.validate: input must be a JSCalendar object");
107
124
  }
108
125
  var t = jsCal["@type"];
109
- if (t !== JSCAL_TYPES.Event && t !== JSCAL_TYPES.Task) {
126
+ if (t !== JSCAL_TYPES.Event && t !== JSCAL_TYPES.Task && t !== JSCAL_TYPES.Note) {
110
127
  throw new CalendarError("calendar/bad-type",
111
- "b.calendar.validate: @type must be 'Event' or 'Task' (got " + JSON.stringify(t) + ")");
128
+ "b.calendar.validate: @type must be 'Event' or 'Task' or 'Note' (got " + JSON.stringify(t) + ")");
112
129
  }
113
130
  if (typeof jsCal.uid !== "string" || jsCal.uid.length === 0) {
114
131
  throw new CalendarError("calendar/no-uid",
@@ -170,6 +187,43 @@ function validate(jsCal) {
170
187
  "b.calendar.validate: Task.progressUpdated MUST be a UTCDateTime");
171
188
  }
172
189
  }
190
+ if (t === JSCAL_TYPES.Note) {
191
+ // Note (VJOURNAL) — dated free-form journal entry. RFC 5545
192
+ // §3.6.3 permits an optional DTSTART (date or date-time) and
193
+ // SUMMARY / DESCRIPTION; STATUS values are limited to DRAFT /
194
+ // FINAL / CANCELLED. There is no DUE / DURATION / COMPLETED /
195
+ // PERCENT-COMPLETE on VJOURNAL.
196
+ if (jsCal.start !== undefined && (typeof jsCal.start !== "string" || !_isLocalDateTime(jsCal.start))) {
197
+ throw new CalendarError("calendar/bad-start",
198
+ "b.calendar.validate: Note.start MUST be a LocalDateTime (RFC 5545 §3.6.3)");
199
+ }
200
+ if (jsCal.duration !== undefined) {
201
+ throw new CalendarError("calendar/bad-duration",
202
+ "b.calendar.validate: Note.duration MUST NOT be set (RFC 5545 §3.6.3 VJOURNAL has no DURATION)");
203
+ }
204
+ if (jsCal.due !== undefined) {
205
+ throw new CalendarError("calendar/bad-due",
206
+ "b.calendar.validate: Note.due MUST NOT be set (DUE is a VTODO-only property)");
207
+ }
208
+ if (jsCal.progress !== undefined) {
209
+ throw new CalendarError("calendar/bad-progress",
210
+ "b.calendar.validate: Note.progress MUST NOT be set (progress is a Task-only property)");
211
+ }
212
+ if (jsCal.percentComplete !== undefined) {
213
+ throw new CalendarError("calendar/bad-percent",
214
+ "b.calendar.validate: Note.percentComplete MUST NOT be set (percentComplete is a Task-only property)");
215
+ }
216
+ if (jsCal.progressUpdated !== undefined) {
217
+ throw new CalendarError("calendar/bad-progress-updated",
218
+ "b.calendar.validate: Note.progressUpdated MUST NOT be set (progressUpdated is a Task-only property)");
219
+ }
220
+ if (jsCal.status !== undefined &&
221
+ !Object.prototype.hasOwnProperty.call(JSCAL_NOTE_STATUS, jsCal.status)) {
222
+ throw new CalendarError("calendar/bad-note-status",
223
+ "b.calendar.validate: Note.status MUST be one of " +
224
+ Object.keys(JSCAL_NOTE_STATUS).join(" | ") + " (RFC 5545 §3.8.1.11 VJOURNAL STATUS)");
225
+ }
226
+ }
173
227
  if (jsCal.recurrenceRules !== undefined) {
174
228
  if (!Array.isArray(jsCal.recurrenceRules)) {
175
229
  throw new CalendarError("calendar/bad-recurrence",
@@ -234,14 +288,16 @@ function validate(jsCal) {
234
288
  */
235
289
  function fromIcal(text, opts) {
236
290
  var ast = safeIcal.parse(text, opts || {});
237
- var events = (ast && ast.vcalendar && ast.vcalendar.vevent) || [];
238
- var todos = (ast && ast.vcalendar && ast.vcalendar.vtodo) || [];
239
- if (events.length === 0 && todos.length === 0) {
291
+ var events = (ast && ast.vcalendar && ast.vcalendar.vevent) || [];
292
+ var todos = (ast && ast.vcalendar && ast.vcalendar.vtodo) || [];
293
+ var journals = (ast && ast.vcalendar && ast.vcalendar.vjournal) || [];
294
+ if (events.length === 0 && todos.length === 0 && journals.length === 0) {
240
295
  throw new CalendarError("calendar/no-component",
241
- "b.calendar.fromIcal: VCALENDAR has no VEVENT or VTODO components");
296
+ "b.calendar.fromIcal: VCALENDAR has no VEVENT, VTODO or VJOURNAL components");
242
297
  }
243
298
  var converted = events.map(_veventToJsCalEvent)
244
- .concat(todos.map(_vtodoToJsCalTask));
299
+ .concat(todos.map(_vtodoToJsCalTask))
300
+ .concat(journals.map(_vjournalToJsCalNote));
245
301
  return converted.length === 1 ? converted[0] : converted;
246
302
  }
247
303
 
@@ -276,7 +332,9 @@ function toIcal(jsCal, opts) {
276
332
  // maps to VEVENT. The wrapper + most properties are identical; the
277
333
  // wrapping component tag + Task-specific fields (DUE / STATUS /
278
334
  // PERCENT-COMPLETE / COMPLETED) diverge.
279
- var component = jsCal["@type"] === "Task" ? "VTODO" : "VEVENT";
335
+ var component = jsCal["@type"] === "Task"
336
+ ? "VTODO"
337
+ : jsCal["@type"] === "Note" ? "VJOURNAL" : "VEVENT";
280
338
  var lines = [
281
339
  "BEGIN:VCALENDAR",
282
340
  "VERSION:2.0",
@@ -324,6 +382,11 @@ function toIcal(jsCal, opts) {
324
382
  if (component === "VTODO" && jsCal.progress) {
325
383
  lines.push("STATUS:" + String(jsCal.progress).toUpperCase());
326
384
  }
385
+ // RFC 5545 §3.8.1.11 — VJOURNAL STATUS values are DRAFT / FINAL /
386
+ // CANCELLED. JSCalendar Note carries them lower-cased; emit upper.
387
+ if (component === "VJOURNAL" && jsCal.status) {
388
+ lines.push("STATUS:" + String(jsCal.status).toUpperCase());
389
+ }
327
390
  if (component === "VTODO" && typeof jsCal.percentComplete === "number") {
328
391
  lines.push("PERCENT-COMPLETE:" + jsCal.percentComplete);
329
392
  }
@@ -449,11 +512,100 @@ function expandRecurrence(event, opts) {
449
512
  if (isFinite(mdn) && mdn !== 0 && mdn >= -31 && mdn <= 31) byMonthDaySet[mdn] = true; // allow:raw-byte-literal — calendar day-of-month bounds
450
513
  }
451
514
  }
515
+ // RFC 5545 §3.3.10 — BYWEEKNO refines yearly recurrences to specific
516
+ // ISO 8601 week numbers (1..53 or -1..-53). Implementation
517
+ // computes the ISO week of each candidate instance + compares.
518
+ var byWeekNoSet = null;
519
+ if (Array.isArray(rule.byWeekNo) && rule.byWeekNo.length > 0) {
520
+ byWeekNoSet = Object.create(null);
521
+ for (var wni = 0; wni < rule.byWeekNo.length; wni += 1) {
522
+ var wn = parseInt(rule.byWeekNo[wni], 10);
523
+ if (isFinite(wn) && wn !== 0 && wn >= -53 && wn <= 53) byWeekNoSet[wn] = true; // allow:raw-byte-literal — ISO 8601 week-number bounds
524
+ }
525
+ }
526
+ // BYYEARDAY — day-of-year (1..366 or -1..-366; negative counts from
527
+ // the end of the year per RFC 5545 §3.3.10).
528
+ var byYearDaySet = null;
529
+ if (Array.isArray(rule.byYearDay) && rule.byYearDay.length > 0) {
530
+ byYearDaySet = Object.create(null);
531
+ for (var ydi = 0; ydi < rule.byYearDay.length; ydi += 1) {
532
+ var yd = parseInt(rule.byYearDay[ydi], 10);
533
+ if (isFinite(yd) && yd !== 0 && yd >= -366 && yd <= 366) byYearDaySet[yd] = true; // allow:raw-byte-literal — day-of-year bounds
534
+ }
535
+ }
536
+ // BYHOUR / BYMINUTE / BYSECOND — time-of-day filters. RFC 5545 §3.3.10
537
+ // bounds: hours 0..23, minutes 0..59, seconds 0..60 (60 covers
538
+ // POSIX leap-second representation).
539
+ function _bySet(arr, lo, hi) {
540
+ if (!Array.isArray(arr) || arr.length === 0) return null;
541
+ var s = Object.create(null);
542
+ var hasAny = false;
543
+ for (var i = 0; i < arr.length; i += 1) {
544
+ var n = parseInt(arr[i], 10);
545
+ if (isFinite(n) && n >= lo && n <= hi) { s[n] = true; hasAny = true; }
546
+ }
547
+ // Codex P2 — when every value in the BY* list is out of range,
548
+ // return null instead of an empty set. An empty truthy set would
549
+ // cause `_matchesBy` to reject every candidate (`!set[n]` is
550
+ // true) and silently turn malformed input into a "match nothing"
551
+ // rule. Returning null lets the rule fall through to the next
552
+ // unfiltered candidate per RFC 5545's tolerant grammar.
553
+ return hasAny ? s : null;
554
+ }
555
+ var byHourSet = _bySet(rule.byHour, 0, 23); // allow:raw-byte-literal — RFC 5545 hour range
556
+ var byMinuteSet = _bySet(rule.byMinute, 0, 59); // allow:raw-byte-literal — RFC 5545 minute range
557
+ var bySecondSet = _bySet(rule.bySecond, 0, 60); // allow:raw-byte-literal — RFC 5545 second range incl. leap second // allow:raw-time-literal — second-of-minute bound, not a duration
558
+
559
+ function _isoWeekParts(d) {
560
+ // ISO 8601 week-of-year + week-year. The week-YEAR can differ
561
+ // from the Gregorian year for early-Jan / late-Dec boundary
562
+ // dates (e.g. 2021-01-01 is ISO week 53 of WEEK-YEAR 2020).
563
+ // Returns { week, year }.
564
+ var tmp = new Date(Date.UTC(d.getUTCFullYear(), d.getUTCMonth(), d.getUTCDate()));
565
+ var dayOfWeek = tmp.getUTCDay() || 7;
566
+ tmp.setUTCDate(tmp.getUTCDate() + 4 - dayOfWeek); // allow:raw-byte-literal — ISO week-year anchor (Thursday)
567
+ var weekYear = tmp.getUTCFullYear();
568
+ var yearStart = new Date(Date.UTC(weekYear, 0, 1));
569
+ var week = Math.ceil((((tmp - yearStart) / 86400000) + 1) / 7); // allow:raw-time-literal — 86400000 ms/day, 7 days/week // allow:raw-byte-literal
570
+ return { week: week, year: weekYear };
571
+ }
572
+ function _isoWeekOf(d) {
573
+ return _isoWeekParts(d).week;
574
+ }
575
+ function _yearDayOf(d) {
576
+ var startOfYear = new Date(Date.UTC(d.getUTCFullYear(), 0, 1));
577
+ return Math.floor((d - startOfYear) / 86400000) + 1; // allow:raw-time-literal — 86400000 ms/day // allow:raw-byte-literal
578
+ }
579
+ function _daysInYear(year) {
580
+ return ((year % 4 === 0 && year % 100 !== 0) || year % 400 === 0) ? 366 : 365; // allow:raw-byte-literal — Gregorian leap-year rule
581
+ }
452
582
  function _matchesBy(t) {
453
583
  var d = new Date(t);
454
584
  if (byDaySet && !byDaySet[d.getUTCDay()]) return false;
455
585
  if (byMonthSet && !byMonthSet[d.getUTCMonth() + 1]) return false;
456
586
  if (byMonthDaySet && !byMonthDaySet[d.getUTCDate()]) return false;
587
+ if (byWeekNoSet) {
588
+ // Codex P1 — ISO week-year vs Gregorian year. 2021-01-01 is ISO
589
+ // week 53 of WEEK-YEAR 2020 (since 2021 only has 52 ISO weeks).
590
+ // Comparing only the numeric week would let a Jan 1 2021 date
591
+ // match a BYWEEKNO=53 rule whose implicit year is 2021. Refuse
592
+ // when the candidate's ISO week-year doesn't match the
593
+ // candidate's Gregorian year (the most common operator-intent
594
+ // alignment); operators with boundary-crossing rules opt in via
595
+ // a future explicit knob if demand surfaces.
596
+ var iso = _isoWeekParts(d);
597
+ if (iso.year !== d.getUTCFullYear()) return false;
598
+ var lastWeek = _isoWeekOf(new Date(Date.UTC(d.getUTCFullYear(), 11, 28))); // allow:raw-byte-literal — Dec 28 always in last ISO week
599
+ if (!byWeekNoSet[iso.week] && !byWeekNoSet[-(lastWeek - iso.week + 1)]) return false;
600
+ }
601
+ if (byYearDaySet) {
602
+ var yd = _yearDayOf(d);
603
+ var dayCount = _daysInYear(d.getUTCFullYear());
604
+ if (!byYearDaySet[yd] && !byYearDaySet[-(dayCount - yd + 1)]) return false;
605
+ }
606
+ if (byHourSet && !byHourSet[d.getUTCHours()]) return false;
607
+ if (byMinuteSet && !byMinuteSet[d.getUTCMinutes()]) return false;
608
+ if (bySecondSet && !bySecondSet[d.getUTCSeconds()]) return false;
457
609
  return true;
458
610
  }
459
611
  var t = startMs;
@@ -575,6 +727,72 @@ function _vtodoToJsCalTask(vt) {
575
727
  return jsCal;
576
728
  }
577
729
 
730
+ // RFC 5545 §3.6.3 — VJOURNAL maps to a JSCalendar-shaped Note. The
731
+ // VJOURNAL grammar permits MULTIPLE DESCRIPTION properties (the only
732
+ // iCalendar component that does); blamejs joins them with a single
733
+ // blank line to preserve operator-visible separators. STATUS is
734
+ // limited to DRAFT / FINAL / CANCELLED (different from VTODO's
735
+ // vocabulary), with no DUE / DURATION / PERCENT-COMPLETE / COMPLETED.
736
+ function _vjournalToJsCalNote(vj) {
737
+ var props = (vj && vj.properties) || {};
738
+ var jsCal = {
739
+ "@type": "Note",
740
+ uid: _firstValue(props.UID) || "",
741
+ updated: _icalDateTimeToUtc(_firstValue(props.DTSTAMP) || ""),
742
+ };
743
+ var summary = _firstValue(props.SUMMARY);
744
+ if (summary) jsCal.title = _unescapeText(summary);
745
+ // RFC 5545 §3.6.3 — VJOURNAL is the only component that may carry
746
+ // multiple DESCRIPTION properties (one per discrete journal entry).
747
+ // Concatenate them with a blank-line separator so downstream
748
+ // consumers see the operator-visible boundaries.
749
+ var descriptions = _allValues(props.DESCRIPTION);
750
+ if (descriptions.length === 1) {
751
+ jsCal.description = _unescapeText(descriptions[0]);
752
+ } else if (descriptions.length > 1) {
753
+ var parts = [];
754
+ for (var di = 0; di < descriptions.length; di += 1) {
755
+ parts.push(_unescapeText(descriptions[di]));
756
+ }
757
+ jsCal.description = parts.join("\n\n");
758
+ }
759
+ var dtstart = _firstValue(props.DTSTART);
760
+ if (dtstart) jsCal.start = _icalDateTimeToLocal(dtstart);
761
+ var tzid = _firstParamValue(props.DTSTART, "TZID");
762
+ if (tzid) {
763
+ jsCal.timeZone = tzid;
764
+ } else if (typeof dtstart === "string" && /Z$/.test(dtstart)) {
765
+ jsCal.timeZone = "Etc/UTC";
766
+ }
767
+ var status = _firstValue(props.STATUS);
768
+ if (status) {
769
+ var statusLower = String(status).toLowerCase();
770
+ if (Object.prototype.hasOwnProperty.call(JSCAL_NOTE_STATUS, statusLower)) {
771
+ jsCal.status = statusLower;
772
+ }
773
+ }
774
+ var location = _firstValue(props.LOCATION);
775
+ if (location) {
776
+ jsCal.locations = { L1: { "@type": "Location", name: _unescapeText(location) } };
777
+ }
778
+ var rrule3 = _firstValue(props.RRULE);
779
+ if (rrule3) jsCal.recurrenceRules = [_icalRruleToJscal(rrule3)];
780
+ return jsCal;
781
+ }
782
+
783
+ function _allValues(prop) {
784
+ if (!prop) return [];
785
+ if (Array.isArray(prop)) {
786
+ var out = [];
787
+ for (var i = 0; i < prop.length; i += 1) {
788
+ var item = prop[i];
789
+ if (item && item.value !== undefined) out.push(item.value);
790
+ }
791
+ return out;
792
+ }
793
+ return prop.value !== undefined ? [prop.value] : [];
794
+ }
795
+
578
796
  function _firstValue(prop) {
579
797
  if (!prop) return null;
580
798
  if (Array.isArray(prop)) {
@@ -720,6 +938,7 @@ module.exports = {
720
938
  JSCAL_FREQUENCIES: JSCAL_FREQUENCIES,
721
939
  JSCAL_ALERT_ACTIONS: JSCAL_ALERT_ACTIONS,
722
940
  JSCAL_TASK_PROGRESS: JSCAL_TASK_PROGRESS,
941
+ JSCAL_NOTE_STATUS: JSCAL_NOTE_STATUS,
723
942
  MAX_EXPAND_INSTANCES: MAX_EXPAND_INSTANCES,
724
943
  MAX_EXPAND_SPAN_MS: MAX_EXPAND_SPAN_MS,
725
944
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@blamejs/core",
3
- "version": "0.11.35",
3
+ "version": "0.11.37",
4
4
  "description": "The Node framework that owns its stack.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "blamejs contributors",
package/sbom.cdx.json CHANGED
@@ -2,10 +2,10 @@
2
2
  "$schema": "http://cyclonedx.org/schema/bom-1.5.schema.json",
3
3
  "bomFormat": "CycloneDX",
4
4
  "specVersion": "1.5",
5
- "serialNumber": "urn:uuid:ce80c06c-78db-449e-871f-1b1da1e018c7",
5
+ "serialNumber": "urn:uuid:df42b2e1-b180-4b98-a9b7-2bf6b7fe666e",
6
6
  "version": 1,
7
7
  "metadata": {
8
- "timestamp": "2026-05-21T20:42:06.128Z",
8
+ "timestamp": "2026-05-21T22:14:19.947Z",
9
9
  "lifecycles": [
10
10
  {
11
11
  "phase": "build"
@@ -19,14 +19,14 @@
19
19
  }
20
20
  ],
21
21
  "component": {
22
- "bom-ref": "@blamejs/core@0.11.35",
22
+ "bom-ref": "@blamejs/core@0.11.37",
23
23
  "type": "application",
24
24
  "name": "blamejs",
25
- "version": "0.11.35",
25
+ "version": "0.11.37",
26
26
  "scope": "required",
27
27
  "author": "blamejs contributors",
28
28
  "description": "The Node framework that owns its stack.",
29
- "purl": "pkg:npm/%40blamejs/core@0.11.35",
29
+ "purl": "pkg:npm/%40blamejs/core@0.11.37",
30
30
  "properties": [],
31
31
  "externalReferences": [
32
32
  {
@@ -54,7 +54,7 @@
54
54
  "components": [],
55
55
  "dependencies": [
56
56
  {
57
- "ref": "@blamejs/core@0.11.35",
57
+ "ref": "@blamejs/core@0.11.37",
58
58
  "dependsOn": []
59
59
  }
60
60
  ]