@bobfrankston/rmfmail 1.2.6 → 1.2.7

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.
@@ -59,6 +59,7 @@ __export(api_client_exports, {
59
59
  getOutboxStatus: () => getOutboxStatus,
60
60
  getPrimaryAccount: () => getPrimaryAccount,
61
61
  getPriorityLists: () => getPriorityLists,
62
+ getReminderSound: () => getReminderSound,
62
63
  getSettings: () => getSettings,
63
64
  getSyncPending: () => getSyncPending,
64
65
  getTasks: () => getTasks,
@@ -576,6 +577,9 @@ function getThreadMessages(accountId, threadId) {
576
577
  function readJsoncFile(name) {
577
578
  return ipc().readJsoncFile?.(name);
578
579
  }
580
+ function getReminderSound() {
581
+ return ipc().getReminderSound?.();
582
+ }
579
583
  function writeJsoncFile(name, content) {
580
584
  return ipc().writeJsoncFile?.(name, content);
581
585
  }
@@ -5380,6 +5384,68 @@ function alog(tag, data) {
5380
5384
  } catch {
5381
5385
  }
5382
5386
  }
5387
+ async function playReminderSound() {
5388
+ const now = Date.now();
5389
+ if (now - _lastSoundAt < 2e3)
5390
+ return;
5391
+ _lastSoundAt = now;
5392
+ try {
5393
+ if (_soundCache === null) {
5394
+ const r = await getReminderSound().catch(() => ({}));
5395
+ if (r?.mute)
5396
+ _soundCache = { mute: true };
5397
+ else if (r?.dataBase64) {
5398
+ const bin = atob(r.dataBase64);
5399
+ const bytes = new Uint8Array(bin.length);
5400
+ for (let i = 0; i < bin.length; i++)
5401
+ bytes[i] = bin.charCodeAt(i);
5402
+ _soundCache = { url: URL.createObjectURL(new Blob([bytes], { type: r.mime || "audio/mpeg" })) };
5403
+ } else
5404
+ _soundCache = {};
5405
+ }
5406
+ if (_soundCache.mute)
5407
+ return;
5408
+ if (_soundCache.url) {
5409
+ const a = new Audio(_soundCache.url);
5410
+ a.play().catch(() => playChime());
5411
+ return;
5412
+ }
5413
+ playChime();
5414
+ } catch {
5415
+ try {
5416
+ playChime();
5417
+ } catch {
5418
+ }
5419
+ }
5420
+ }
5421
+ function playChime() {
5422
+ const Ctx = window.AudioContext || window.webkitAudioContext;
5423
+ if (!Ctx)
5424
+ return;
5425
+ const ctx = new Ctx();
5426
+ const t0 = ctx.currentTime;
5427
+ const tone = (freq, start, dur) => {
5428
+ const o = ctx.createOscillator();
5429
+ const g = ctx.createGain();
5430
+ o.type = "sine";
5431
+ o.frequency.value = freq;
5432
+ g.gain.setValueAtTime(1e-4, t0 + start);
5433
+ g.gain.linearRampToValueAtTime(0.22, t0 + start + 0.02);
5434
+ g.gain.exponentialRampToValueAtTime(1e-4, t0 + start + dur);
5435
+ o.connect(g);
5436
+ g.connect(ctx.destination);
5437
+ o.start(t0 + start);
5438
+ o.stop(t0 + start + dur + 0.05);
5439
+ };
5440
+ tone(880, 0, 0.35);
5441
+ tone(1174.66, 0.16, 0.42);
5442
+ setTimeout(() => {
5443
+ try {
5444
+ ctx.close();
5445
+ } catch {
5446
+ }
5447
+ }, 1300);
5448
+ }
5383
5449
  function loadDismissed() {
5384
5450
  try {
5385
5451
  return JSON.parse(localStorage.getItem(DISMISSED_KEY) || "{}");
@@ -5657,6 +5723,7 @@ async function firePopupForItem(item) {
5657
5723
  });
5658
5724
  <\/script>
5659
5725
  </body></html>`;
5726
+ void playReminderSound();
5660
5727
  const title = item.kind === "calendar" ? "Calendar reminder" : "Task reminder";
5661
5728
  const hasHost = !!window.mailxapi?.showReminderPopup;
5662
5729
  let r;
@@ -5809,7 +5876,7 @@ function startAlarmPoller() {
5809
5876
  });
5810
5877
  });
5811
5878
  }
5812
- var DISMISSED_KEY, SNOOZED_KEY, LOOKBACK_MS, LOOKAHEAD_MS, POLL_INTERVAL_MS, firedThisSession, openPopups;
5879
+ var DISMISSED_KEY, SNOOZED_KEY, LOOKBACK_MS, LOOKAHEAD_MS, POLL_INTERVAL_MS, _soundCache, _lastSoundAt, firedThisSession, openPopups;
5813
5880
  var init_alarms = __esm({
5814
5881
  "client/components/alarms.js"() {
5815
5882
  "use strict";
@@ -5819,6 +5886,8 @@ var init_alarms = __esm({
5819
5886
  LOOKBACK_MS = 60 * 60 * 1e3;
5820
5887
  LOOKAHEAD_MS = 2 * 60 * 60 * 1e3;
5821
5888
  POLL_INTERVAL_MS = 3e4;
5889
+ _soundCache = null;
5890
+ _lastSoundAt = 0;
5822
5891
  firedThisSession = /* @__PURE__ */ new Set();
5823
5892
  openPopups = /* @__PURE__ */ new Set();
5824
5893
  }