@domicile-desktop/sdk 1.0.0 → 2.2.0

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.
@@ -0,0 +1,58 @@
1
+ // Touchpad gestures of three fingers or more, which the shell claims from the
2
+ // window under the pointer, and touchscreen fingers in from a display's edge.
3
+ // Two touchpad fingers stay the page's. See docs/architecture/GESTURES.md.
4
+ import { hostEvent, on } from "./subscribe";
5
+ export const gestures = (host) => ({
6
+ grab: (gesture) => {
7
+ host.grabGesture(gesture);
8
+ },
9
+ on: on({
10
+ gesture: (listener) => hostEvent(host, "gesture", (event) => {
11
+ const gesture = gestureOf(event);
12
+ if (gesture !== undefined) {
13
+ listener(gesture);
14
+ }
15
+ }),
16
+ }),
17
+ ungrab: (gesture) => {
18
+ host.ungrabGesture(gesture);
19
+ },
20
+ });
21
+ const KINDS = new Map([
22
+ ["edge", "edge"],
23
+ ["hold", "hold"],
24
+ ["pinch", "pinch"],
25
+ ["swipe", "swipe"],
26
+ ]);
27
+ const EDGES = new Map([
28
+ ["bottom", "bottom"],
29
+ ["left", "left"],
30
+ ["right", "right"],
31
+ ["top", "top"],
32
+ ]);
33
+ const PHASES = new Map([
34
+ ["begin", "begin"],
35
+ ["end", "end"],
36
+ ["update", "update"],
37
+ ]);
38
+ /** The event as a {@link Gesture}, or `undefined` for a kind, phase or edge this SDK predates. */
39
+ const gestureOf = (event) => {
40
+ const kind = KINDS.get(event.kind);
41
+ const phase = PHASES.get(event.phase);
42
+ const edge = EDGES.get(event.edge);
43
+ return kind === undefined ||
44
+ phase === undefined ||
45
+ (kind === "edge" && edge === undefined)
46
+ ? undefined
47
+ : {
48
+ canceled: event.canceled,
49
+ dx: event.dx,
50
+ dy: event.dy,
51
+ edge,
52
+ fingers: event.fingers,
53
+ kind,
54
+ phase,
55
+ rotation: event.rotation,
56
+ scale: event.scale,
57
+ };
58
+ };
@@ -23,11 +23,15 @@ export const notifications = (host) => {
23
23
  },
24
24
  };
25
25
  };
26
- /** The engine sends `""` for no icon and a negative timeout for none asked. */
26
+ /**
27
+ * The engine sends `""` for no icon or browser window, and a negative timeout
28
+ * for none asked.
29
+ */
27
30
  const notificationOf = (item) => ({
28
31
  actions: item.actions.map(({ key, label }) => ({ key, label })),
29
32
  appName: item.appName,
30
33
  body: item.body,
34
+ browserWindow: item.browserWindow === "" ? undefined : item.browserWindow,
31
35
  clickable: item.clickable,
32
36
  icon: item.icon === "" ? undefined : item.icon,
33
37
  id: item.id,
@@ -85,12 +85,14 @@ export type System = {
85
85
  */
86
86
  setWindowStates: (appId: string, states: readonly WindowState[]) => Promise<Result<"set", SystemError>>;
87
87
  /**
88
- * Draw every monitor as if its white were a light of `kelvin`, 1000 to
89
- * 6500, as a night light does; 6500 draws colors as they are. Lasts until
90
- * the shell sets another, across reloads. Changes nothing on a nested
91
- * desktop. Allowed while the desktop is locked.
88
+ * Draw `display` (a display's `name`), or every monitor when it is left
89
+ * out, as if its white were a light of `kelvin`, 1000 to 6500, as a
90
+ * night light does; 6500 draws colors as they are. Every monitor's replaces
91
+ * each one's. Lasts until the shell sets another, across reloads. Changes
92
+ * nothing on a nested desktop, nor on a monitor a night-light app such as
93
+ * gammastep holds. Allowed while the desktop is locked.
92
94
  */
93
- setColorTemperature: (kelvin: number) => Promise<Result<"set", SystemError>>;
95
+ setColorTemperature: (kelvin: number, display?: string) => Promise<Result<"set", SystemError>>;
94
96
  /**
95
97
  * Hear each maximize and fullscreen request a client makes. The compositor
96
98
  * grants none; grant one with {@link System.setWindowStates}. Allowed while
@@ -80,9 +80,13 @@ export const system = (host) => {
80
80
  screenRecord: () => oneShot(calls, { call: "screen_record" }, (reply) => reply.kind === "saved" ? reply.path : unexpected(reply)),
81
81
  screenshot: () => oneShot(calls, { call: "screenshot" }, (reply) => keptOf(reply)),
82
82
  selectKeymap: (choice) => oneShot(calls, { call: "select_keymap", keymap: wireKeymapChoice(choice) }, (reply) => (reply.kind === "set" ? "set" : unexpected(reply))),
83
- setColorTemperature: (kelvin) => oneShot(calls,
84
- // The compositor reads a whole number.
85
- { call: "set_color_temperature", kelvin: Math.round(kelvin) }, (reply) => (reply.kind === "set" ? "set" : unexpected(reply))),
83
+ setColorTemperature: (kelvin, display) => oneShot(calls, {
84
+ call: "set_color_temperature",
85
+ // Left out for every monitor.
86
+ ...(display === undefined ? {} : { display }),
87
+ // The compositor reads a whole number.
88
+ kelvin: Math.round(kelvin),
89
+ }, (reply) => (reply.kind === "set" ? "set" : unexpected(reply))),
86
90
  setWindowStates: (appId, states) => oneShot(calls, {
87
91
  app_id: appId,
88
92
  call: "set_window_states",
@@ -87,6 +87,17 @@ export type DomicileFileSearch = {
87
87
  */
88
88
  readonly indexing: boolean;
89
89
  };
90
+ export type DomicileGestureEventInit = EventInit & {
91
+ kind?: string;
92
+ phase?: string;
93
+ fingers?: number;
94
+ dx?: number;
95
+ dy?: number;
96
+ scale?: number;
97
+ rotation?: number;
98
+ canceled?: boolean;
99
+ edge?: string;
100
+ };
90
101
  export type DomicileShortcutEventInit = EventInit & {
91
102
  chord?: string;
92
103
  keycode?: number;
@@ -363,6 +374,40 @@ export type DomicileExtensionPopupEvent = Event & {
363
374
  */
364
375
  readonly popup: string;
365
376
  };
377
+ /**
378
+ * A phase of a gesture claimed with grabGesture().
379
+ *
380
+ * Its own type, like DomicileShortcutEvent: a gesture belongs to no window.
381
+ */
382
+ export type DomicileGestureEvent = Event & {
383
+ /**
384
+ * `swipe`, `pinch` or `hold` on a touchpad, or `edge`: one touchscreen
385
+ * finger in from a display's edge.
386
+ */
387
+ readonly kind: string;
388
+ /** `begin`, `update` or `end`. */
389
+ readonly phase: string;
390
+ readonly fingers: number;
391
+ /**
392
+ * This update's motion, in the touchpad's accelerated pointer units, or an
393
+ * edge swipe's in the display's pixels.
394
+ */
395
+ readonly dx: number;
396
+ readonly dy: number;
397
+ /**
398
+ * A pinch's scale relative to its begin, and this update's rotation in
399
+ * degrees clockwise.
400
+ */
401
+ readonly scale: number;
402
+ readonly rotation: number;
403
+ /** On an end: the gesture was abandoned rather than finished. */
404
+ readonly canceled: boolean;
405
+ /**
406
+ * An edge swipe's: the side it came in from, `left`, `right`, `top` or
407
+ * `bottom`. Empty for every other kind.
408
+ */
409
+ readonly edge: string;
410
+ };
366
411
  /** Every event `DomicileHost` fires, by name. */
367
412
  export type DomicileHostEventMap = {
368
413
  /** A grabbed shortcut fired, as a DomicileShortcutEvent. */
@@ -372,6 +417,8 @@ export type DomicileHostEventMap = {
372
417
  * modifiers did, wherever the keyboard is. As a DomicileShortcutEvent.
373
418
  */
374
419
  shortcutrelease: DomicileShortcutEvent;
420
+ /** A phase of a grabbed gesture, as a DomicileGestureEvent. */
421
+ gesture: DomicileGestureEvent;
375
422
  /**
376
423
  * A client asked for the keyboard, as a DomicileAppEvent naming it; nothing
377
424
  * has moved. The shell answers by calling focusApp(), or does not, which
@@ -641,6 +688,25 @@ export type DomicileHost = {
641
688
  * page is its key, not a `shortcut`.
642
689
  */
643
690
  ungrabShortcut(chord: string): void;
691
+ /**
692
+ * Route a touchpad gesture to the page rather than to the window under the
693
+ * pointer, in sway's grammar without the direction: `swipe:3`, `pinch:4`,
694
+ * `hold`. A count left out is any of three fingers or more; two are the
695
+ * page's, for its scrolling, zoom and history. Or a touchscreen finger in
696
+ * from a display's edge: `edge:left`, `right`, `top` or `bottom`, or `edge`
697
+ * for any. Each phase comes back as a `gesture` event. Counted, like
698
+ * grabShortcut(). While the window with the keyboard holds a shortcuts
699
+ * inhibitor, a grabbed gesture fires nothing.
700
+ *
701
+ * Throws a SyntaxError for a gesture written wrong, or of fewer than three
702
+ * fingers.
703
+ */
704
+ grabGesture(gesture: string): void;
705
+ /**
706
+ * Answer one grabGesture() of that name. A gesture not grabbed is a no-op.
707
+ * Throws a SyntaxError for a gesture written wrong.
708
+ */
709
+ ungrabGesture(gesture: string): void;
644
710
  /**
645
711
  * Click an extension's action, popup or not: the extension is granted
646
712
  * activeTab on the active tab, as a toolbar click grants it in Chrome. Then
@@ -888,6 +954,11 @@ export type DomicileNotification = {
888
954
  * the compositor's clock.
889
955
  */
890
956
  readonly time: number;
957
+ /**
958
+ * The id of the browser window whose page sent it, as
959
+ * DomicileBrowserWindow.id names it, or empty for anything else.
960
+ */
961
+ readonly browserWindow: string;
891
962
  };
892
963
  /**
893
964
  * One button of a notification.
@@ -0,0 +1,48 @@
1
+ import type { Gesture, GestureEdge, GestureKind } from "./desktop/gestures";
2
+ export type GestureDirection = "clockwise" | "counterclockwise" | "down" | "inward" | "left" | "outward" | "right" | "up";
3
+ /** A parsed gesture binding. */
4
+ export type GestureBinding = {
5
+ readonly kind: GestureKind;
6
+ /** `undefined` for any count of three or more. */
7
+ readonly fingers: number | undefined;
8
+ /** Every direction the gesture must have gone; none for any. */
9
+ readonly directions: ReadonlySet<GestureDirection>;
10
+ /** An edge swipe's side; `undefined` for any side, and for other kinds. */
11
+ readonly edge: GestureEdge | undefined;
12
+ };
13
+ /** A gesture that ended without being canceled, and where it went. */
14
+ export type FinishedGesture = {
15
+ readonly kind: GestureKind;
16
+ readonly fingers: number;
17
+ readonly directions: ReadonlySet<GestureDirection>;
18
+ readonly edge: GestureEdge | undefined;
19
+ };
20
+ /** Whether `written` names a gesture rather than a chord. */
21
+ export declare const isGesture: (written: string) => boolean;
22
+ /** `written` parsed. Throws on a binding written wrong. */
23
+ export declare const parseGesture: (written: string) => GestureBinding;
24
+ /** `written` in its one spelling, directions in a fixed order. */
25
+ export declare const spelledGesture: (written: string) => string;
26
+ /**
27
+ * What `binding` asks the engine for: its kind, and its count or edge if it
28
+ * has one.
29
+ */
30
+ export declare const grabOf: ({ kind, fingers, edge }: GestureBinding) => string;
31
+ /**
32
+ * Follows one gesture at a time through its phases; `feed` returns it once
33
+ * it ends without being canceled.
34
+ *
35
+ * A swipe went its larger axis's way, and also its smaller one's when that
36
+ * moved at least half as far, so `swipe:3:up+left` is a diagonal. A pinch
37
+ * went inward or outward by its last scale, and clockwise or
38
+ * counterclockwise by its summed rotation.
39
+ */
40
+ export declare const gestureTracker: () => {
41
+ feed: (gesture: Gesture) => FinishedGesture | undefined;
42
+ };
43
+ /**
44
+ * The binding of `bindings` that best fits `finished`, of those whose kind,
45
+ * count, edge and every direction it matches: a count or an edge over none,
46
+ * then more directions over fewer.
47
+ */
48
+ export declare const bestGesture: <T>(bindings: Iterable<readonly [GestureBinding, T]>, finished: FinishedGesture) => T | undefined;
@@ -0,0 +1,164 @@
1
+ // Touchpad gestures as bindings, in sway's `bindgesture` grammar:
2
+ // `<kind>[:<fingers>][:<direction>[+<direction>...]]`, such as `swipe:3:left`
3
+ // or `pinch:4:inward`. A touchscreen finger in from a display's edge is
4
+ // `edge[:<side>]`, such as `edge:left`, and always comes in. They sit beside
5
+ // chords in a shell's keybindings and share its modes. See
6
+ // docs/architecture/GESTURES.md.
7
+ /** The fewest fingers the engine hands the shell; two are the page's. */
8
+ const FEWEST_FINGERS = 3;
9
+ /** Directions in a spelled binding's order, by the kinds that have them. */
10
+ const DIRECTIONS = {
11
+ edge: [],
12
+ hold: [],
13
+ pinch: ["inward", "outward", "clockwise", "counterclockwise"],
14
+ swipe: ["up", "down", "left", "right"],
15
+ };
16
+ const KINDS = new Map([
17
+ ["edge", "edge"],
18
+ ["hold", "hold"],
19
+ ["pinch", "pinch"],
20
+ ["swipe", "swipe"],
21
+ ]);
22
+ const EDGES = ["left", "right", "top", "bottom"];
23
+ /** Whether `written` names a gesture rather than a chord. */
24
+ export const isGesture = (written) => /^(?:edge|hold|pinch|swipe)(?::|$)/.test(written);
25
+ /** `edge` or `edge:<side>`, after the kind. */
26
+ const parseEdge = (sides, fail) => {
27
+ if (sides.length > 1) {
28
+ fail("has more than one side; an edge swipe comes in from one");
29
+ }
30
+ const side = sides[0];
31
+ return {
32
+ directions: new Set(),
33
+ edge: side === undefined
34
+ ? undefined
35
+ : (EDGES.find((known) => known === side) ??
36
+ fail(`comes in from ${JSON.stringify(side)}; an edge is ${EDGES.join(", ")}`)),
37
+ fingers: undefined,
38
+ kind: "edge",
39
+ };
40
+ };
41
+ /** `written` parsed. Throws on a binding written wrong. */
42
+ export const parseGesture = (written) => {
43
+ const fail = (why) => {
44
+ throw new Error(`domicile: gesture ${JSON.stringify(written)} ${why}`);
45
+ };
46
+ const [name = "", ...rest] = written.split(":");
47
+ const kind = KINDS.get(name) ?? fail("is not a swipe, pinch, hold or edge");
48
+ if (kind === "edge") {
49
+ return parseEdge(rest, fail);
50
+ }
51
+ const [count, directions] = /^\d+$/.test(rest[0] ?? "")
52
+ ? [Number(rest[0]), rest.slice(1)]
53
+ : [undefined, rest];
54
+ if (count !== undefined && count < FEWEST_FINGERS) {
55
+ fail(`has ${count} fingers; two are the window's, so the shell's gestures take ${FEWEST_FINGERS} or more`);
56
+ }
57
+ if (directions.length > 1) {
58
+ fail("has more than one direction part; join directions with `+`");
59
+ }
60
+ const allowed = DIRECTIONS[kind];
61
+ const went = (directions[0]?.split("+") ?? []).map((direction) => allowed.find((known) => known === direction) ??
62
+ fail(allowed.length === 0
63
+ ? `has a direction, which a ${kind} does not`
64
+ : `goes ${JSON.stringify(direction)}; a ${kind} goes ${allowed.join(", ")}`));
65
+ if (new Set(went).size !== went.length) {
66
+ fail("names a direction twice");
67
+ }
68
+ return { directions: new Set(went), edge: undefined, fingers: count, kind };
69
+ };
70
+ /** `written` in its one spelling, directions in a fixed order. */
71
+ export const spelledGesture = (written) => {
72
+ const { kind, fingers, directions, edge } = parseGesture(written);
73
+ const went = DIRECTIONS[kind].filter((direction) => directions.has(direction));
74
+ return [kind, fingers ?? edge, went.length === 0 ? undefined : went.join("+")]
75
+ .filter((part) => part !== undefined)
76
+ .join(":");
77
+ };
78
+ /**
79
+ * What `binding` asks the engine for: its kind, and its count or edge if it
80
+ * has one.
81
+ */
82
+ export const grabOf = ({ kind, fingers, edge }) => {
83
+ const part = fingers ?? edge;
84
+ return part === undefined ? kind : `${kind}:${part}`;
85
+ };
86
+ /**
87
+ * Follows one gesture at a time through its phases; `feed` returns it once
88
+ * it ends without being canceled.
89
+ *
90
+ * A swipe went its larger axis's way, and also its smaller one's when that
91
+ * moved at least half as far, so `swipe:3:up+left` is a diagonal. A pinch
92
+ * went inward or outward by its last scale, and clockwise or
93
+ * counterclockwise by its summed rotation.
94
+ */
95
+ export const gestureTracker = () => {
96
+ let sum = { dx: 0, dy: 0, rotation: 0, scale: 1 };
97
+ return {
98
+ feed: (gesture) => {
99
+ if (gesture.phase === "begin") {
100
+ sum = { dx: 0, dy: 0, rotation: 0, scale: 1 };
101
+ }
102
+ else if (gesture.phase === "update") {
103
+ sum = {
104
+ dx: sum.dx + gesture.dx,
105
+ dy: sum.dy + gesture.dy,
106
+ rotation: sum.rotation + gesture.rotation,
107
+ scale: gesture.scale,
108
+ };
109
+ }
110
+ else if (!gesture.canceled) {
111
+ return {
112
+ directions: directionsOf(gesture.kind, sum),
113
+ edge: gesture.edge,
114
+ fingers: gesture.fingers,
115
+ kind: gesture.kind,
116
+ };
117
+ }
118
+ return undefined;
119
+ },
120
+ };
121
+ };
122
+ const directionsOf = (kind, { dx, dy, rotation, scale, }) => {
123
+ switch (kind) {
124
+ case "edge":
125
+ case "hold": {
126
+ return new Set();
127
+ }
128
+ case "pinch": {
129
+ const went = [
130
+ [scale < 1, "inward"],
131
+ [scale > 1, "outward"],
132
+ [rotation > 0, "clockwise"],
133
+ [rotation < 0, "counterclockwise"],
134
+ ];
135
+ return new Set(went.filter(([did]) => did).map(([, way]) => way));
136
+ }
137
+ case "swipe": {
138
+ const horizontal = dx < 0 ? "left" : "right";
139
+ const vertical = dy < 0 ? "up" : "down";
140
+ const [major, minor, majorWay, minorWay] = Math.abs(dx) >= Math.abs(dy)
141
+ ? [Math.abs(dx), Math.abs(dy), horizontal, vertical]
142
+ : [Math.abs(dy), Math.abs(dx), vertical, horizontal];
143
+ const went = [
144
+ [major > 0, majorWay],
145
+ [minor > 0 && minor * 2 >= major, minorWay],
146
+ ];
147
+ return new Set(went.filter(([did]) => did).map(([, way]) => way));
148
+ }
149
+ }
150
+ };
151
+ /**
152
+ * The binding of `bindings` that best fits `finished`, of those whose kind,
153
+ * count, edge and every direction it matches: a count or an edge over none,
154
+ * then more directions over fewer.
155
+ */
156
+ export const bestGesture = (bindings, finished) => [...bindings]
157
+ .filter(([{ kind, fingers, directions, edge }]) => kind === finished.kind &&
158
+ (fingers === undefined || fingers === finished.fingers) &&
159
+ (edge === undefined || edge === finished.edge) &&
160
+ [...directions].every((direction) => finished.directions.has(direction)))
161
+ .sort(([a], [b]) => Number(b.fingers !== undefined || b.edge !== undefined) -
162
+ Number(a.fingers !== undefined || a.edge !== undefined) ||
163
+ b.directions.size - a.directions.size)
164
+ .at(0)?.[1];
@@ -50,6 +50,11 @@ export type Notification = {
50
50
  timeoutMs: number | undefined;
51
51
  /** When it arrived or was last replaced, in milliseconds since the epoch. */
52
52
  time: number;
53
+ /**
54
+ * The id of the browser window whose page sent it, as `browserWindows`
55
+ * lists it, or `undefined` for anything else.
56
+ */
57
+ browserWindow: string | undefined;
53
58
  };
54
59
  /** The action key for a press on a {@link Notification.clickable} body. */
55
60
  export declare const DEFAULT_NOTIFICATION_ACTION = "default";
@@ -1,5 +1,9 @@
1
1
  import type { KeyAction } from "./key-action";
2
- /** One mode's bindings, from chord (`Meta+Shift+l`) to action. */
2
+ /**
3
+ * One mode's bindings, from chord (`Meta+Shift+l`), touchpad gesture
4
+ * (`swipe:3:left`) or touchscreen edge swipe (`edge:left`, see
5
+ * `gesture-binding.ts`) to action.
6
+ */
3
7
  export type ModeKeybindings = Readonly<Record<string, KeyAction>>;
4
8
  /** A shell's keybindings: the `default` mode plus other modes by name. */
5
9
  export type ShellKeybindings = {
@@ -8,7 +12,7 @@ export type ShellKeybindings = {
8
12
  /** Other modes, by name. */
9
13
  readonly modes?: Readonly<Record<string, ModeKeybindings>>;
10
14
  };
11
- /** Each mode's bindings, by chord in its one spelling. */
15
+ /** Each mode's bindings, by chord or gesture in its one spelling. */
12
16
  export type KeybindingsByMode = ReadonlyMap<string, ReadonlyMap<string, KeyAction>>;
13
17
  /**
14
18
  * Files `own` by mode and spelled chord.
@@ -18,8 +22,8 @@ export type KeybindingsByMode = ReadonlyMap<string, ReadonlyMap<string, KeyActio
18
22
  */
19
23
  export declare const ownKeybindings: (own: ShellKeybindings) => KeybindingsByMode;
20
24
  /**
21
- * Every chord `own` binds in any mode, once each, in its one spelling. Throws
22
- * as {@link ownKeybindings} does.
25
+ * Every chord `own` binds in any mode, once each, in its one spelling, and no
26
+ * gestures. Throws as {@link ownKeybindings} does.
23
27
  */
24
28
  export declare const ownedChords: (own: ShellKeybindings) => readonly string[];
25
29
  /** `written` in its one spelling: modifiers in {@link ORDER}, then the keysym. */
@@ -4,6 +4,7 @@
4
4
  // keysym's key (`grabShortcut`). One spelling makes `Shift+Meta+l` and
5
5
  // `Meta+Shift+l` one grab, and lets a `shortcut` event's `chord` find its
6
6
  // binding. See `docs/architecture/KEYBINDINGS.md`.
7
+ import { isGesture, spelledGesture } from "./gesture-binding";
7
8
  /** Modifier order in a spelled chord. */
8
9
  const ORDER = ["Ctrl", "Alt", "Shift", "Meta"];
9
10
  /**
@@ -35,17 +36,18 @@ export const ownKeybindings = (own) => {
35
36
  return new Map([["default", own.keybindings ?? {}], ...Object.entries(modes)].map(([mode, bindings]) => [mode, filed(bindings)]));
36
37
  };
37
38
  /**
38
- * Every chord `own` binds in any mode, once each, in its one spelling. Throws
39
- * as {@link ownKeybindings} does.
39
+ * Every chord `own` binds in any mode, once each, in its one spelling, and no
40
+ * gestures. Throws as {@link ownKeybindings} does.
40
41
  */
41
42
  export const ownedChords = (own) => [
42
- ...new Set([...ownKeybindings(own).values()].flatMap((byChord) => [...byChord.keys()])),
43
+ ...new Set([...ownKeybindings(own).values()].flatMap((byChord) => [...byChord.keys()].filter((chord) => !isGesture(chord)))),
43
44
  ];
44
45
  /** One mode's bindings by chord. Throws on two spellings of one chord. */
45
46
  const filed = (bindings) => Object.entries(bindings).reduce((by, [written, action]) => {
46
- const chord = spelled(written);
47
+ const gesture = isGesture(written);
48
+ const chord = gesture ? spelledGesture(written) : spelled(written);
47
49
  if (by.has(chord)) {
48
- throw new Error(`domicile: chord ${JSON.stringify(written)} is ${chord}, which this mode already binds`);
50
+ throw new Error(`domicile: ${gesture ? "gesture" : "chord"} ${JSON.stringify(written)} is ${chord}, which this mode already binds`);
49
51
  }
50
52
  return by.set(chord, action);
51
53
  }, new Map());