mirror of
https://github.com/priyanshujain/margin-calendar.git
synced 2026-10-02 11:07:04 +00:00
Tauri 2, React 19 and zustand on the front, Rust behind. Rust owns auth, all HTTP to Google, the SQLite store, the sync loop, recurrence expansion and timezone maths. TypeScript owns rendering and never talks to Google, which keeps the content security policy locked to ipc:. Week, day and agenda views, and no month view: it would be a second layout engine, and the fit and fold logic that makes a day fit the window without scrolling is the whole point of the app. Runs on macOS, Linux, Android and iOS. Desktop catches Google's OAuth redirect on a loopback port. A phone cannot, and Google rejects loopback for mobile client types anyway, so it redirects to a custom URI scheme and needs its own public OAuth clients, which docs/mobile.md covers. Refresh tokens are sealed with XChaCha20-Poly1305 in the app data directory on every platform, with no OS credential store in the picture. On a phone the chrome becomes a top bar and a bottom tab bar, overlays become sheets, hover affordances become taps, and dragging out an event waits for a long press. Navigation moves one day at a time everywhere, a swipe included.
52 lines
1.9 KiB
TypeScript
52 lines
1.9 KiB
TypeScript
// The table's own invariants. Two bindings on one combo in one context would silently shadow each
|
|
// other, and a group the sheet does not render would silently hide a key, so both are asserted
|
|
// here rather than discovered later.
|
|
//
|
|
// This imports the table alone. `commands.ts` reaches for localStorage and Tauri the moment it is
|
|
// loaded, which is why `bindingLabel` takes the lookup as an argument.
|
|
|
|
import { describe, expect, it } from "vitest";
|
|
import { BINDINGS, GROUPS, bindingLabel, keyLabel, normalizeCombo } from "./bindings";
|
|
|
|
describe("the binding table", () => {
|
|
it("never binds one combo twice in the same context", () => {
|
|
const seen = new Set<string>();
|
|
for (const binding of BINDINGS) {
|
|
for (const key of binding.keys) {
|
|
const slot = `${binding.context}:${normalizeCombo(key)}`;
|
|
expect(seen.has(slot), `${slot} is bound twice`).toBe(false);
|
|
seen.add(slot);
|
|
}
|
|
}
|
|
});
|
|
|
|
it("puts every binding in a group the sheet renders", () => {
|
|
for (const binding of BINDINGS) expect(GROUPS).toContain(binding.group);
|
|
});
|
|
|
|
it("can name every binding, including the ones it does not own", () => {
|
|
for (const binding of BINDINGS) {
|
|
expect(bindingLabel(binding, (id) => `command ${id}`)).not.toBe("");
|
|
}
|
|
});
|
|
|
|
it("documents Escape without claiming to handle it", () => {
|
|
const escape = BINDINGS.find((b) => b.keys.includes("Escape"));
|
|
expect(escape?.command).toBeNull();
|
|
});
|
|
|
|
it("reads a combo the same way the dispatcher builds one", () => {
|
|
expect(normalizeCombo("Cmd+K")).toBe("cmd+k");
|
|
expect(normalizeCombo("cmd+k")).toBe("cmd+k");
|
|
expect(normalizeCombo("H")).toBe("H");
|
|
expect(normalizeCombo("/")).toBe("/");
|
|
});
|
|
|
|
it("prints a shifted letter as a shifted letter", () => {
|
|
expect(keyLabel("H")).toBe("⇧H");
|
|
expect(keyLabel("h")).toBe("h");
|
|
expect(keyLabel("Enter")).toBe("↩");
|
|
expect(keyLabel("Escape")).toBe("⎋");
|
|
});
|
|
});
|