@flowtty/core 1.0.0-alpha.13 → 1.0.0-alpha.14

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.
@@ -81,6 +81,26 @@ interface Backend {
81
81
  * and degrade gracefully when absent.
82
82
  */
83
83
  printStatic?(lines: string[]): void;
84
+ /**
85
+ * Ring the terminal bell (BEL). The one attention-getter every terminal has:
86
+ * a sound, a flash, a marked tab — whatever the person configured. Backends
87
+ * that can write to a terminal implement it and rate-limit it (flowtty's TTY
88
+ * backends: at most one per second); headless ones omit it.
89
+ *
90
+ * Never called from inside `draw()`, and the bytes go out as one write, so a
91
+ * bell between two frames leaves a frame-diffing backend's baseline valid.
92
+ */
93
+ bell?(): void;
94
+ /**
95
+ * Post a desktop notification through the terminal — what an app reaches for
96
+ * when the person is looking at another window. `title` is the line the
97
+ * notification leads with; `body` the optional rest.
98
+ *
99
+ * Which escape sequence carries it is the backend's business (see
100
+ * docs/terminal.md), as is sanitizing the text: an embedded ESC or BEL would
101
+ * end the sequence early. Backends with no terminal to write to omit this.
102
+ */
103
+ notify?(title: string, body?: string): void;
84
104
  /**
85
105
  * Whether this backend owns the entire render area — i.e. components can
86
106
  * use the full `size()` for layout and overlay larger panels (Menu cascade,
package/dist/index.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { C as BorderStyle, E as GridChars, S as BorderChars, T as GRID_CHARS, a as ScrollMetrics, s as TextRun, t as BoxProps, w as DEFAULT_BORDER_STYLE } from "./host-DnKJiaQh.js";
2
2
  import { a as NAMED_COLORS, i as Color, n as Cell, o as NamedColor, r as Style, t as Buffer } from "./cells-C-GthybI.js";
3
- import { a as NamedKey, i as NAMED_KEYS, n as Key, r as KeyName, t as Backend } from "./backend-DPFtzaxG.js";
3
+ import { a as NamedKey, i as NAMED_KEYS, n as Key, r as KeyName, t as Backend } from "./backend-BV7OrooZ.js";
4
4
  //#region src/warnings.d.ts
5
5
  /** Warnings noted since the last call; clears the list. */
6
6
  export declare function takeWarnings(): string[];
@@ -1,10 +1,17 @@
1
1
  import { t as Buffer } from "../cells-C-GthybI.js";
2
- import { n as Key, t as Backend } from "../backend-DPFtzaxG.js";
2
+ import { n as Key, t as Backend } from "../backend-BV7OrooZ.js";
3
3
  //#region src/testing/test-backend.d.ts
4
4
  export declare class TestBackend implements Backend {
5
5
  private readonly cols;
6
6
  private readonly rows;
7
7
  frames: string[];
8
+ /** How many times the app rang the bell. Nothing is written anywhere. */
9
+ bells: number;
10
+ /** Every notification the app posted, in order — `body` absent when it was. */
11
+ notifications: {
12
+ title: string;
13
+ body?: string;
14
+ }[];
8
15
  private buffers;
9
16
  private readonly subscribers;
10
17
  constructor(cols?: number, rows?: number);
@@ -28,6 +35,12 @@ export declare class TestBackend implements Backend {
28
35
  type(text: string): void;
29
36
  /** Deliver `text` as ONE 'paste' key — what a TTY backend emits for a bracketed paste. */
30
37
  paste(text: string): void;
38
+ /** Count a bell instead of writing one. */
39
+ bell(): void;
40
+ /** Record a notification instead of posting one. The text is kept exactly as
41
+ * the app passed it — sanitizing is a TTY backend's job, and a test wants to
42
+ * see what the app asked for. */
43
+ notify(title: string, body?: string): void;
31
44
  /** Deliver one mouse-wheel step at cell (x, y) — what a TTY backend with `mouse` on emits. */
32
45
  wheel(direction: "up" | "down", x?: number, y?: number): void;
33
46
  dispose(): void;
@@ -21,6 +21,10 @@ var TestBackend = class {
21
21
  cols;
22
22
  rows;
23
23
  frames = [];
24
+ /** How many times the app rang the bell. Nothing is written anywhere. */
25
+ bells = 0;
26
+ /** Every notification the app posted, in order — `body` absent when it was. */
27
+ notifications = [];
24
28
  buffers = [];
25
29
  subscribers = /* @__PURE__ */ new Set();
26
30
  constructor(cols = 40, rows = 10) {
@@ -82,6 +86,19 @@ var TestBackend = class {
82
86
  text: text.replace(/\r\n?/g, "\n")
83
87
  });
84
88
  }
89
+ /** Count a bell instead of writing one. */
90
+ bell() {
91
+ this.bells += 1;
92
+ }
93
+ /** Record a notification instead of posting one. The text is kept exactly as
94
+ * the app passed it — sanitizing is a TTY backend's job, and a test wants to
95
+ * see what the app asked for. */
96
+ notify(title, body) {
97
+ this.notifications.push(body === void 0 ? { title } : {
98
+ title,
99
+ body
100
+ });
101
+ }
85
102
  /** Deliver one mouse-wheel step at cell (x, y) — what a TTY backend with `mouse` on emits. */
86
103
  wheel(direction, x = 0, y = 0) {
87
104
  this.press({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@flowtty/core",
3
- "version": "1.0.0-alpha.13",
3
+ "version": "1.0.0-alpha.14",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "repository": {