@zukhruf/sqlite-notify 0.0.0-stage → 0.8.20
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/LICENSE +21 -0
- package/README.md +286 -2
- package/dist/columns.d.ts +10 -0
- package/dist/columns.d.ts.map +1 -0
- package/dist/columns.js +26 -0
- package/dist/columns.js.map +1 -0
- package/dist/disposed-error.d.ts +5 -0
- package/dist/disposed-error.d.ts.map +1 -0
- package/dist/disposed-error.js +8 -0
- package/dist/disposed-error.js.map +1 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +6 -0
- package/dist/index.js.map +1 -0
- package/dist/limits.d.ts +3 -0
- package/dist/limits.d.ts.map +1 -0
- package/dist/limits.js +16 -0
- package/dist/limits.js.map +1 -0
- package/dist/listening.d.ts +46 -0
- package/dist/listening.d.ts.map +1 -0
- package/dist/listening.js +259 -0
- package/dist/listening.js.map +1 -0
- package/dist/notifications.d.ts +43 -0
- package/dist/notifications.d.ts.map +1 -0
- package/dist/notifications.js +240 -0
- package/dist/notifications.js.map +1 -0
- package/dist/queue-full-error.d.ts +7 -0
- package/dist/queue-full-error.d.ts.map +1 -0
- package/dist/queue-full-error.js +10 -0
- package/dist/queue-full-error.js.map +1 -0
- package/dist/release.d.ts +8 -0
- package/dist/release.d.ts.map +1 -0
- package/dist/release.js +27 -0
- package/dist/release.js.map +1 -0
- package/dist/removal-check.d.ts +15 -0
- package/dist/removal-check.d.ts.map +1 -0
- package/dist/removal-check.js +45 -0
- package/dist/removal-check.js.map +1 -0
- package/dist/schema.d.ts +4 -0
- package/dist/schema.d.ts.map +1 -0
- package/dist/schema.js +40 -0
- package/dist/schema.js.map +1 -0
- package/dist/steps.d.ts +6 -0
- package/dist/steps.d.ts.map +1 -0
- package/dist/steps.js +23 -0
- package/dist/steps.js.map +1 -0
- package/dist/tables.d.ts +6 -0
- package/dist/tables.d.ts.map +1 -0
- package/dist/tables.js +57 -0
- package/dist/tables.js.map +1 -0
- package/dist/wakes.d.ts +24 -0
- package/dist/wakes.d.ts.map +1 -0
- package/dist/wakes.js +176 -0
- package/dist/wakes.js.map +1 -0
- package/package.json +52 -4
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 ezzabuzaid
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,3 +1,287 @@
|
|
|
1
|
-
#
|
|
1
|
+
# @zukhruf/sqlite-notify
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The code follows this paper. Windows is not run.
|
|
4
|
+
|
|
5
|
+
Open:
|
|
6
|
+
|
|
7
|
+
- A socket file with no row. A listener that is killed after it served its socket and before its registration committed leaves a file that no row names. Nobody removes it. A sweep of the socket folder at the start of a listener could remove it, but a sweep can meet a socket that is bound and not yet listening.
|
|
8
|
+
- No test proves two rules that depend only on timing: the owed wake (research 20e R3), and a dispose while a hung listener's socket buffer is full. Their code is in `src/wakes.ts`.
|
|
9
|
+
- One interface for this package and for Postgres. Ticket 11 says the pool uses one interface for the notify on one computer and for `LISTEN` / `NOTIFY` across computers. That interface can live here, in the pool, or in a package of its own.
|
|
10
|
+
|
|
11
|
+
Postgres has `LISTEN` and `NOTIFY`. A session listens on a channel. Another session sends a notification with a payload, in a transaction. When that transaction commits, each listening session gets the notification. SQLite has nothing like it: a commit in one program does not tell another program. This package gives `LISTEN` and `NOTIFY` for one SQLite file, among the programs of one computer.
|
|
12
|
+
|
|
13
|
+
A notification is a row in a table of the same file, written in the sender's own transaction. Postgres calls this table the notification queue. After the commit, the sender writes a wake to each listening program, over a socket that the listener serves. The wake says only "read the queue". Each listener also checks the file every second, so a lost wake costs at most one second.
|
|
14
|
+
|
|
15
|
+
The words in these documents have one meaning each. See the glossary in [CONTEXT.md](./CONTEXT.md). The research and the tickets named here are in the pool map, `.scratch/one-pool-for-the-computer/` at the workspace root, which git does not track.
|
|
16
|
+
|
|
17
|
+
## Use it
|
|
18
|
+
|
|
19
|
+
This project is an experiment. It uses `node:sqlite`, and [`@zukhruf/pipes`](../../pipes/README.md) on `node:net`.
|
|
20
|
+
|
|
21
|
+
```sh
|
|
22
|
+
npm install @zukhruf/sqlite-notify
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
```ts
|
|
26
|
+
import { mkdtempDisposable } from 'node:fs/promises';
|
|
27
|
+
import { tmpdir } from 'node:os';
|
|
28
|
+
import { join } from 'node:path';
|
|
29
|
+
|
|
30
|
+
import { type Notification, Notifications } from '@zukhruf/sqlite-notify';
|
|
31
|
+
import { WriteAheadLog, open } from '@zukhruf/sqlite-open';
|
|
32
|
+
import { transaction } from '@zukhruf/sqlite-transaction';
|
|
33
|
+
|
|
34
|
+
await using scratch = await mkdtempDisposable(join(tmpdir(), 'notify-'));
|
|
35
|
+
const path = join(scratch.path, 'app.sqlite');
|
|
36
|
+
|
|
37
|
+
// The listener. In real use it is another program on the same file.
|
|
38
|
+
await using listener = new Notifications({ path, clock: globalThis });
|
|
39
|
+
listener.on('error', (error) => console.error(error));
|
|
40
|
+
const heard = Promise.withResolvers<Notification>();
|
|
41
|
+
listener.on('notification', heard.resolve);
|
|
42
|
+
await listener.listen('jobs');
|
|
43
|
+
|
|
44
|
+
// The sender writes a job and its notification in one transaction.
|
|
45
|
+
using database = open(path, {
|
|
46
|
+
journal: new WriteAheadLog({ synchronous: 'full' }),
|
|
47
|
+
});
|
|
48
|
+
await using sender = new Notifications({ database, clock: globalThis });
|
|
49
|
+
sender.on('error', (error) => console.error(error));
|
|
50
|
+
database.exec('CREATE TABLE jobs (name TEXT NOT NULL) STRICT');
|
|
51
|
+
transaction(
|
|
52
|
+
database,
|
|
53
|
+
() => {
|
|
54
|
+
database.prepare('INSERT INTO jobs VALUES (?)').run('email');
|
|
55
|
+
sender.notify('jobs', 'email');
|
|
56
|
+
},
|
|
57
|
+
{ mode: 'immediate' },
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const notification = await heard.promise;
|
|
61
|
+
console.log(notification.channel, notification.payload);
|
|
62
|
+
console.log(notification.processId === process.pid);
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
Output:
|
|
66
|
+
|
|
67
|
+
```
|
|
68
|
+
jobs email
|
|
69
|
+
true
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
## The API
|
|
73
|
+
|
|
74
|
+
```ts
|
|
75
|
+
import type { EventEmitter } from 'node:events';
|
|
76
|
+
import type { DatabaseSync } from 'node:sqlite';
|
|
77
|
+
|
|
78
|
+
import type { Clock } from '@zukhruf/async';
|
|
79
|
+
|
|
80
|
+
export class Notifications
|
|
81
|
+
extends EventEmitter<{ notification: [Notification]; error: [unknown] }>
|
|
82
|
+
implements AsyncDisposable
|
|
83
|
+
{
|
|
84
|
+
constructor(options: NotificationsOptions);
|
|
85
|
+
listen(channel: string): Promise<void>;
|
|
86
|
+
unlisten(channel: string): Promise<void>;
|
|
87
|
+
notify(channel: string, payload?: string): void;
|
|
88
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export type NotificationsOptions = FileOptions | ConnectionOptions;
|
|
92
|
+
|
|
93
|
+
export interface FileOptions {
|
|
94
|
+
path: string;
|
|
95
|
+
database?: never;
|
|
96
|
+
clock: Clock;
|
|
97
|
+
maxQueuedNotifications?: number;
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
export interface ConnectionOptions {
|
|
101
|
+
database: DatabaseSync;
|
|
102
|
+
path?: never;
|
|
103
|
+
clock: Clock;
|
|
104
|
+
maxQueuedNotifications?: number;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
/** The `Notification` of `pg` (node-postgres): the same fields and types. */
|
|
108
|
+
export interface Notification {
|
|
109
|
+
processId: number;
|
|
110
|
+
channel: string;
|
|
111
|
+
payload: string;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export class QueueFullError extends Error {
|
|
115
|
+
readonly code: '54000';
|
|
116
|
+
}
|
|
117
|
+
|
|
118
|
+
export class DisposedError extends Error {}
|
|
119
|
+
|
|
120
|
+
export {
|
|
121
|
+
DeniedError,
|
|
122
|
+
MissingError,
|
|
123
|
+
UnavailableError,
|
|
124
|
+
} from '@zukhruf/sqlite-open';
|
|
125
|
+
export { UnsafeFolderError } from '@zukhruf/pipes';
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## The rules
|
|
129
|
+
|
|
130
|
+
- `new Notifications({ path })` owns its connection to the file. It opens it with `open(path, { journal: new WriteAheadLog({ synchronous: 'full' }) })` of `@zukhruf/sqlite-open`, as `@zukhruf/sqlite-queue` does, and closes it at dispose.
|
|
131
|
+
- `new Notifications({ database })` sends on a `DatabaseSync` that the caller opened. The caller closes it. A database in memory has no file that another program can open, so the constructor throws a `TypeError`.
|
|
132
|
+
- The constructor makes the tables, if they are missing, on the sending connection. On a file that a later release made, it changes nothing. See [The tables](#the-tables).
|
|
133
|
+
- `clock` is required. The backstop waits on it. Give `globalThis` in production, and a fake clock in a test ([`@zukhruf/async`](../../async/README.md#run-a-wait-on-a-clock)).
|
|
134
|
+
- `notify(channel, payload)` is synchronous. When the sending connection is in a transaction, it inserts the row in that transaction. When it is not, it inserts the row in a `BEGIN IMMEDIATE` transaction of its own. `payload` is `''` when you give none, as in Postgres.
|
|
135
|
+
- The wakes go out on the next microtask. A transaction of the family is synchronous ("`work` must be synchronous", [`@zukhruf/sqlite-transaction`](../transaction/README.md)), so by then the transaction has committed or rolled back. After a rollback, the wake finds no row, and the listener gives nothing to its caller. [ADR 0004](./docs/adr/0004-the-wake-goes-out-after-the-synchronous-transaction.md) tells why.
|
|
136
|
+
- A transaction that stays open across an `await` breaks the rule above. Its wake then comes before its commit and finds nothing. The backstop finds the row up to one second later.
|
|
137
|
+
- `listen(channel)` resolves when the registration has committed. Each notification that commits after that comes to `notification`. A notification that committed before it does not come. Read the state that you need after `listen` resolves, then rely on the notifications. This is Postgres's rule for the start.
|
|
138
|
+
- `unlisten(channel)` stops the notifications of that channel at once. The last `unlisten` removes the listener's row, closes its socket and closes the listener's own connection. The next `listen` is a first `listen` again: it gets a new listener id and a new socket. `listen` and `unlisten` of a channel that is already in that state do nothing, as in Postgres. There is no `UNLISTEN *`: dispose ends every channel.
|
|
139
|
+
- Each listening `Notifications` serves its own socket: a Unix socket on macOS and Linux, a named pipe on Windows. Nothing serves for a program that only sends. [ADR 0003](./docs/adr/0003-no-hub-each-listener-serves-its-own-socket.md) tells why.
|
|
140
|
+
- The listener reads the queue on its own connection to the file, outside any transaction. It opens that connection at the first `listen` and never sets its journal.
|
|
141
|
+
- Each second, the listener reads `PRAGMA data_version` on its own connection, and reads the queue when it changed. This is the backstop. It finds a row whose wake was lost. The backstop also writes the listener's position, with a busy timeout of 0: `node:sqlite` is synchronous, so a write that waits for the lock would stop the event loop of the listener. A write that finds the file busy fails at once, and the next backstop tries again.
|
|
142
|
+
- A dead listener is one whose address gave `ECONNREFUSED` (a socket file that a killed listener left) or `ENOENT` (no file) to a connect, or closed the sender's connection. The sender's next transaction removes its rows. When that transaction is the sender's own, the sender then removes its socket file; on Windows there is no file to remove. A removal in the caller's transaction commits or rolls back with it, and `node:sqlite` does not tell when that transaction ends. On the next microtask the caller's transaction has ended, so the sender reads whether the rows are still there: rows gone, it removes the socket file; rows still there, the caller rolled back, and the next `notify` removes them again ([ADR 0010](./docs/adr/0010-the-trim-wakes-the-laggard-and-a-dead-listener-is-forgotten-once-its-rows-are-gone.md)). Another connect error goes to `error`, and the next send connects again.
|
|
143
|
+
- At its trim, a sender also wakes the laggards: the listeners at the lowest position, when it is below the highest id, whatever their channels. Postgres's `SignalBackends` wakes the listeners that are far behind for the same reason: the tail can then move. A live laggard reads. A dead one refuses the connect, and the sender removes its rows. A hung one accepts the connect and keeps its row, as in Postgres (C10). See [ADR 0010](./docs/adr/0010-the-trim-wakes-the-laggard-and-a-dead-listener-is-forgotten-once-its-rows-are-gone.md).
|
|
144
|
+
- A sender that listens on the channel gets its own notification, as in Postgres. `processId` is the `process.pid` of the sending program. Compare it with `process.pid` to drop your own. Two instances in one program have the same `processId`.
|
|
145
|
+
- Notifications come in the order of their commits. Inside one transaction, they come in the order of the `notify` calls.
|
|
146
|
+
- A listener for `error` is necessary. A failure that no caller awaits, for example a failed read after a wake, goes to the `error` event. With no listener, `EventEmitter` throws. A `notification` listener that throws sends its error to `error`, and the next notifications of the read still come.
|
|
147
|
+
- Dispose with `await using`, or call `[Symbol.asyncDispose]()`. It writes the wakes that are due, ends the connections to other listeners, removes this listener's rows, closes its socket and closes the connections that it opened.
|
|
148
|
+
- A notification is durable. It survives the crash of its sender and of any other program, because it is a row of the file. Postgres loses its queue in a crash of the server.
|
|
149
|
+
- A program never opens, reads, copies or watches the database file with `fs`. On POSIX, the close of any descriptor of a file drops every SQLite lock that the program holds on it ([`@zukhruf/fs`](../../fs/README.md)).
|
|
150
|
+
- Windows is not proven. The named pipe is the one of `@zukhruf/pipes`. Its proof is backlog #4340, and nothing waits for it.
|
|
151
|
+
|
|
152
|
+
## The contract
|
|
153
|
+
|
|
154
|
+
The 13 lines of Postgres's contract (research 19 §1), and how this package keeps each one.
|
|
155
|
+
|
|
156
|
+
| # | Postgres | Here |
|
|
157
|
+
| --- | --------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
158
|
+
| C1 | Each session that listens on the channel gets it, in any program. | The same, for each program of the computer, and of the same user, on the same file. |
|
|
159
|
+
| C2 | Only at commit. A rollback sends nothing. | The same. The row rolls back with the transaction, and a wake that finds no row gives nothing ([ADR 0004](./docs/adr/0004-the-wake-goes-out-after-the-synchronous-transaction.md)). |
|
|
160
|
+
| C3 | Only sessions that listen at that moment. | The same. A channel delivers only rows above the highest id at the commit of its `listen`. |
|
|
161
|
+
| C4 | A listener in a transaction gets it after the transaction. | The same. Notifications come on the event loop, and a transaction of the family never spans a turn of it. |
|
|
162
|
+
| C5 | The channel, the sender's process id and the payload. | The same fields, as `pg` gives them. `processId` is the sending program's `process.pid`. |
|
|
163
|
+
| C6 | The payload is shorter than 8000 bytes. | The same, in UTF-8 bytes. |
|
|
164
|
+
| C7 | Identical notifications of one transaction are delivered once. | **Not given.** Each `notify` is one notification ([ADR 0006](./docs/adr/0006-identical-notifications-of-one-transaction-are-not-folded.md)). |
|
|
165
|
+
| C8 | The order of the sends, then the order of the commits. | The same. The ids are in commit order. |
|
|
166
|
+
| C9 | A sender that listens hears itself. | The same. |
|
|
167
|
+
| C10 | A full queue fails the sender at commit. | The same effect: `notify` throws `QueueFullError`, so its transaction does not commit ([ADR 0005](./docs/adr/0005-a-row-stays-until-each-listener-read-it.md)). |
|
|
168
|
+
| C11 | A session that ends loses its registrations. | The same. Dispose removes them. A crashed listener's row stays until the next trim of a sender, on any channel, finds it dead. |
|
|
169
|
+
| C12 | A crash of the server loses the queue. | **Stronger.** The queue is a table of the file, and a crash loses no committed notification. |
|
|
170
|
+
| C13 | Commit the `LISTEN`, then read the state, then rely on notifications. | The same. `listen` resolves after its commit. |
|
|
171
|
+
|
|
172
|
+
## What each call does
|
|
173
|
+
|
|
174
|
+
| Call or event | Rows | Socket | Wakes |
|
|
175
|
+
| ------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
176
|
+
| `new Notifications(options)` | Reads the recorded release with no lock. Makes the missing tables on the sending connection, and records this release, unless the file records a later release, or this release and fits. | None. | None. |
|
|
177
|
+
| The first `listen(channel)` | Opens the listener's own connection. One `BEGIN IMMEDIATE` transaction inserts the listener row with its address, reads the highest id as its position, and inserts the channel row. | Makes the socket folder if it is missing, and serves a new socket in it. | None. The backstop starts. |
|
|
178
|
+
| A later `listen(channel)` | One `BEGIN IMMEDIATE` transaction inserts the channel row and reads the highest id. | None. | None. |
|
|
179
|
+
| `notify(channel, payload)` | In the current transaction, or in its own: removes the rows of the listeners that this sender found dead, fails when the queue is full, inserts the row, reads the addresses on the channel, and trims at most 10,000 rows at most once a second. A trim also reads the laggards. | None. | On the next microtask: one wake to each address read, and to each laggard. It connects to an address the first time, and keeps the connection. |
|
|
180
|
+
| A wake comes in | Reads the rows above the listener's last id on its own connection, outside a transaction, and emits the rows of its channels. | None. | None. |
|
|
181
|
+
| Each second (the backstop) | Reads `PRAGMA data_version`, and reads the queue when it changed. Writes the listener's position when it moved; the write has a busy timeout of 0, and a write that finds the file busy waits for the next second. | None. | None. |
|
|
182
|
+
| A refused connect, or a `close` | `ECONNREFUSED` or `ENOENT` at the connect, or a `close`: the sender's next transaction removes that listener's rows. A removal in the caller's transaction is done again in each `notify`, until a read on the next microtask finds the rows gone. | The sender removes that socket file once the removal of the row has committed; on Windows there is none. | That address gets no more wakes. |
|
|
183
|
+
| A wake while one is in flight | None. | None. | The connection owes one wake, and writes it when the first one is flushed. A second wake while one is owed adds nothing. |
|
|
184
|
+
| `unlisten(channel)` | Removes the channel row. The last one also removes the listener row, and closes the listener's connection. | The last one closes the socket, which removes its file. | None. |
|
|
185
|
+
| `[Symbol.asyncDispose]()` | Removes this listener's rows. | Closes its socket and ends its connections to other listeners. | Writes the wakes that are due first. |
|
|
186
|
+
|
|
187
|
+
## The tables
|
|
188
|
+
|
|
189
|
+
The tables are a `Declaration` of [`@zukhruf/sqlite-drift`](../drift) with `rows: 'keep'`, as in `@zukhruf/sqlite-queue`. A new release changes a `CREATE` statement, and the constructor rebuilds the table and keeps its rows. No release writes a migration.
|
|
190
|
+
|
|
191
|
+
- The file records the version of the release that last applied the tables, in `zukhruf_notify_version`. The version comes from the `package.json` of the package: no person keeps a number ([ADR 0009](./docs/adr/0009-the-file-records-the-release-that-made-its-tables-and-an-older-release-leaves-them-alone.md)).
|
|
192
|
+
- A release that constructs on a file of a later release changes nothing. A column that a release adds must be nullable or have a default, so that an older release can write the row.
|
|
193
|
+
- A file that records a later release, or records this release and fits, takes no write lock at construction.
|
|
194
|
+
|
|
195
|
+
```sql
|
|
196
|
+
CREATE TABLE zukhruf_notify_queue (
|
|
197
|
+
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
198
|
+
channel TEXT NOT NULL,
|
|
199
|
+
payload TEXT NOT NULL,
|
|
200
|
+
process_id INTEGER NOT NULL
|
|
201
|
+
) STRICT;
|
|
202
|
+
|
|
203
|
+
CREATE TABLE zukhruf_notify_listener (
|
|
204
|
+
id TEXT PRIMARY KEY,
|
|
205
|
+
address TEXT NOT NULL UNIQUE,
|
|
206
|
+
position INTEGER NOT NULL,
|
|
207
|
+
process_id INTEGER NOT NULL
|
|
208
|
+
) STRICT;
|
|
209
|
+
|
|
210
|
+
CREATE INDEX zukhruf_notify_listener_position ON zukhruf_notify_listener (position);
|
|
211
|
+
|
|
212
|
+
CREATE TABLE zukhruf_notify_channel (
|
|
213
|
+
channel TEXT NOT NULL,
|
|
214
|
+
listener TEXT NOT NULL,
|
|
215
|
+
PRIMARY KEY (channel, listener)
|
|
216
|
+
) STRICT, WITHOUT ROWID;
|
|
217
|
+
|
|
218
|
+
CREATE TABLE zukhruf_notify_version (
|
|
219
|
+
singleton INTEGER PRIMARY KEY CHECK (singleton = 1),
|
|
220
|
+
version TEXT NOT NULL
|
|
221
|
+
) STRICT;
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
- `AUTOINCREMENT` is required. A plain `INTEGER PRIMARY KEY` gives the ids of trimmed rows again, and a listener whose last id is higher never reads the new rows (research 20b T2).
|
|
225
|
+
- The highest id is the `seq` of the queue in `sqlite_sequence`, so it stays right when the trim removed every row.
|
|
226
|
+
- The names start with `zukhruf_notify_`, as pg-boss's tables start with `pgboss_` and Solid Cable's with `solid_cable_`. SQLite keeps names that start with `sqlite_` for itself.
|
|
227
|
+
- No foreign key: a caller's connection can have `foreign_keys` off. The package removes the channel rows of a listener in the same transaction as its listener row.
|
|
228
|
+
|
|
229
|
+
## The socket folder
|
|
230
|
+
|
|
231
|
+
[`@zukhruf/pipes`](../../pipes/README.md) gives the socket address. Each listener gets `new PipeEndpoint(<listener id>, { prefix: 'zukhruf-sqlite-notify' })`, and the listener id is 16 random bytes in hex. The package gives:
|
|
232
|
+
|
|
233
|
+
- On macOS and Linux, the socket `/tmp/zukhruf-sqlite-notify-<uid>/<listener id>`. `<uid>` is `process.getuid()`. The path is at most 70 bytes, under the limit of 103 bytes on macOS and 107 on Linux.
|
|
234
|
+
- The folder, made with mode `0700`. When it exists, it must be a folder, not a link, owned by this user, with no access for its group or others. Otherwise `listen` throws the `UnsafeFolderError` of `@zukhruf/pipes`. tmux has the same rule for `/tmp/tmux-<uid>` ([ADR 0007](./docs/adr/0007-the-socket-folder-is-short-and-belongs-to-one-user.md)).
|
|
235
|
+
- On Windows, the named pipe `\\.\pipe\zukhruf-sqlite-notify-<listener id>`. Windows removes a pipe when its program exits.
|
|
236
|
+
- The listen, and the removal of the socket file when the socket closes.
|
|
237
|
+
|
|
238
|
+
What stays in this package:
|
|
239
|
+
|
|
240
|
+
- The listener id, and the address in the listener row: `endpoint.address.path`. A sender connects to the address that it read, with `new PipeAddress(address).connect()`.
|
|
241
|
+
- Another user cannot connect to a socket that Node makes with the default mode (research 20a P5). Pools are per user, so this is the rule, not a limit.
|
|
242
|
+
- A listener's socket file stays after a crash. The sender that finds the address dead removes the file once the removal of the row has committed.
|
|
243
|
+
|
|
244
|
+
## Errors
|
|
245
|
+
|
|
246
|
+
| Error | When |
|
|
247
|
+
| ------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
248
|
+
| `UnavailableError` | The file is missing, or the system denies access to it. It is the class of `@zukhruf/sqlite-open`, which opens the connections: a `MissingError` or a `DeniedError` when the system says which. `cause` is the error of SQLite. |
|
|
249
|
+
| `QueueFullError` | `notify` finds `maxQueuedNotifications` rows that a listener has not read. Its message and `code` are Postgres's: `too many notifications in the NOTIFY queue`, `54000`. The transaction of the call does not commit. |
|
|
250
|
+
| `UnsafeFolderError` | `listen` finds a socket folder that is not a folder, is a link, belongs to another user, or gives access to its group or others. `path` is the folder. It is the class of `@zukhruf/pipes`, which makes the folder. |
|
|
251
|
+
| `RangeError` | A channel or a payload that Postgres refuses, with Postgres's message: `channel name cannot be empty`, `channel name too long` (64 bytes or more), `payload string too long` (8000 bytes or more). |
|
|
252
|
+
| `DisposedError` | `listen`, `unlisten` or `notify` after dispose. .NET throws `ObjectDisposedException` for a call on a disposed object. A second dispose resolves. |
|
|
253
|
+
| `TypeError` | `database` is a database in memory. |
|
|
254
|
+
| The error of SQLite | All other failures, for example `database is locked` when the busy timeout ends. |
|
|
255
|
+
|
|
256
|
+
The package throws its own errors. A host that needs its own error translates at its boundary, and keeps the error of the package as `cause`.
|
|
257
|
+
|
|
258
|
+
## Who uses it
|
|
259
|
+
|
|
260
|
+
| Consumer | How | Record |
|
|
261
|
+
| ----------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------- |
|
|
262
|
+
| `@zukhruf/sqlite-queue` | `useListenNotify` across instances. A send wakes the workers of each `SqliteJobQueue` on the same file, as a `pg_notify` wakes each pg-boss listener on the schema. The poll of pg-boss stays as the backstop. The README line that states the divergence goes. | backlog #4334 |
|
|
263
|
+
| `@zukhruf/pool` | Two channels for each pool: "a new job" (the owner listens, the payload is the revision of the job) and "an output" (each sending host listens, the payload is the job id). | map tickets 11 and 20 |
|
|
264
|
+
|
|
265
|
+
## The same concepts in other systems
|
|
266
|
+
|
|
267
|
+
| System | What it does |
|
|
268
|
+
| ---------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
269
|
+
| [Postgres `LISTEN` / `NOTIFY`](https://www.postgresql.org/docs/18/sql-notify.html) | The contract that this package copies. The sender writes a shared queue before its commit, and signals each listening session after it (`src/backend/commands/async.c`). |
|
|
270
|
+
| [`pg`](https://node-postgres.com/) (node-postgres) | Gives a notification as a `notification` event of its `Client`, with `processId`, `channel` and `payload`. This package gives the same event and the same fields. |
|
|
271
|
+
| [honker](https://github.com/russellromney/honker) | `notify` is an insert into a table, in the sender's transaction. One native thread polls `PRAGMA data_version` every 1 ms. The caller trims the table. |
|
|
272
|
+
| [Rails Solid Cable](https://github.com/rails/solid_cable) | A message is a row. A listener polls for rows above its last id every 0.1 s. A job trims rows after one day. |
|
|
273
|
+
| Android Room `enableMultiInstanceInvalidation` | Tells the other processes of an app which tables changed, through a service that each process connects to. |
|
|
274
|
+
| Apple Core Data remote change notifications | Posts a notification for each write to a SQLite store, also a write by another process. |
|
|
275
|
+
| SQLite `PRAGMA data_version` | Changes when another connection commits. The backstop reads it. |
|
|
276
|
+
|
|
277
|
+
## Documentation
|
|
278
|
+
|
|
279
|
+
- [0001 Postgres's LISTEN and NOTIFY on one SQLite file](./docs/adr/0001-postgres-listen-and-notify-on-one-sqlite-file.md)
|
|
280
|
+
- [0002 The queue is the truth and the wake is a hint](./docs/adr/0002-the-queue-is-the-truth-and-the-wake-is-a-hint.md)
|
|
281
|
+
- [0003 No hub: each listener serves its own socket](./docs/adr/0003-no-hub-each-listener-serves-its-own-socket.md)
|
|
282
|
+
- [0004 The wake goes out after the synchronous transaction](./docs/adr/0004-the-wake-goes-out-after-the-synchronous-transaction.md)
|
|
283
|
+
- [0005 A row stays until each listener read it](./docs/adr/0005-a-row-stays-until-each-listener-read-it.md)
|
|
284
|
+
- [0006 Identical notifications of one transaction are not folded](./docs/adr/0006-identical-notifications-of-one-transaction-are-not-folded.md)
|
|
285
|
+
- [0007 The socket folder is short and belongs to one user](./docs/adr/0007-the-socket-folder-is-short-and-belongs-to-one-user.md)
|
|
286
|
+
- [0008 The socket address is the third place, so its extraction comes first](./docs/adr/0008-the-socket-address-is-the-third-place-so-its-extraction-comes-first.md)
|
|
287
|
+
- [0010 The trim wakes the laggard, and a dead listener is forgotten once its rows are gone](./docs/adr/0010-the-trim-wakes-the-laggard-and-a-dead-listener-is-forgotten-once-its-rows-are-gone.md)
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { SQLOutputValue } from 'node:sqlite';
|
|
2
|
+
type Row = Record<string, SQLOutputValue> | undefined;
|
|
3
|
+
/** The column of the row as text; the package's own tables declare it TEXT NOT NULL. */
|
|
4
|
+
export declare function text(row: Row, column: string): string;
|
|
5
|
+
/** The column of the row as an integer, or null for a NULL. */
|
|
6
|
+
export declare function integerOrNull(row: Row, column: string): number | null;
|
|
7
|
+
/** The column of the row as an integer. */
|
|
8
|
+
export declare function integer(row: Row, column: string): number;
|
|
9
|
+
export {};
|
|
10
|
+
//# sourceMappingURL=columns.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columns.d.ts","sourceRoot":"","sources":["../src/columns.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,KAAK,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,GAAG,SAAS,CAAC;AAEtD,wFAAwF;AACxF,wBAAgB,IAAI,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAKrD;AAED,+DAA+D;AAC/D,wBAAgB,aAAa,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAQrE;AAED,2CAA2C;AAC3C,wBAAgB,OAAO,CAAC,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,GAAG,MAAM,CAKxD"}
|
package/dist/columns.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/** The column of the row as text; the package's own tables declare it TEXT NOT NULL. */
|
|
2
|
+
export function text(row, column) {
|
|
3
|
+
const value = row?.[column];
|
|
4
|
+
if (typeof value !== 'string')
|
|
5
|
+
throw new TypeError(`The column ${column} is not text: ${String(value)}`);
|
|
6
|
+
return value;
|
|
7
|
+
}
|
|
8
|
+
/** The column of the row as an integer, or null for a NULL. */
|
|
9
|
+
export function integerOrNull(row, column) {
|
|
10
|
+
const value = row?.[column];
|
|
11
|
+
if (value === null)
|
|
12
|
+
return null;
|
|
13
|
+
if (typeof value === 'number')
|
|
14
|
+
return value;
|
|
15
|
+
if (typeof value === 'bigint')
|
|
16
|
+
return Number(value);
|
|
17
|
+
throw new TypeError(`The column ${column} is not an integer: ${String(value)}`);
|
|
18
|
+
}
|
|
19
|
+
/** The column of the row as an integer. */
|
|
20
|
+
export function integer(row, column) {
|
|
21
|
+
const value = integerOrNull(row, column);
|
|
22
|
+
if (value === null)
|
|
23
|
+
throw new TypeError(`The column ${column} is NULL, not an integer`);
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=columns.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"columns.js","sourceRoot":"","sources":["../src/columns.ts"],"names":[],"mappings":"AAIA,wFAAwF;AACxF,MAAM,UAAU,IAAI,CAAC,GAAQ,EAAE,MAAc;IAC3C,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,OAAO,KAAK,KAAK,QAAQ;QAC3B,MAAM,IAAI,SAAS,CAAC,cAAc,MAAM,iBAAiB,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;IAC5E,OAAO,KAAK,CAAC;AACf,CAAC;AAED,+DAA+D;AAC/D,MAAM,UAAU,aAAa,CAAC,GAAQ,EAAE,MAAc;IACpD,MAAM,KAAK,GAAG,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC;IAC5B,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,IAAI,CAAC;IAChC,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,KAAK,CAAC;IAC5C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC;IACpD,MAAM,IAAI,SAAS,CACjB,cAAc,MAAM,uBAAuB,MAAM,CAAC,KAAK,CAAC,EAAE,CAC3D,CAAC;AACJ,CAAC;AAED,2CAA2C;AAC3C,MAAM,UAAU,OAAO,CAAC,GAAQ,EAAE,MAAc;IAC9C,MAAM,KAAK,GAAG,aAAa,CAAC,GAAG,EAAE,MAAM,CAAC,CAAC;IACzC,IAAI,KAAK,KAAK,IAAI;QAChB,MAAM,IAAI,SAAS,CAAC,cAAc,MAAM,0BAA0B,CAAC,CAAC;IACtE,OAAO,KAAK,CAAC;AACf,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disposed-error.d.ts","sourceRoot":"","sources":["../src/disposed-error.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,qBAAa,aAAc,SAAQ,KAAK;;CAOvC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** A call of `listen`, `unlisten` or `notify` after dispose. .NET's ObjectDisposedException. */
|
|
2
|
+
export class DisposedError extends Error {
|
|
3
|
+
constructor() {
|
|
4
|
+
super('The notifications are disposed: they listen and send no more. Make a new Notifications.');
|
|
5
|
+
this.name = 'DisposedError';
|
|
6
|
+
}
|
|
7
|
+
}
|
|
8
|
+
//# sourceMappingURL=disposed-error.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"disposed-error.js","sourceRoot":"","sources":["../src/disposed-error.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,MAAM,OAAO,aAAc,SAAQ,KAAK;IACtC;QACE,KAAK,CACH,yFAAyF,CAC1F,CAAC;QACF,IAAI,CAAC,IAAI,GAAG,eAAe,CAAC;IAC9B,CAAC;CACF"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { type ConnectionOptions, type FileOptions, type Notification, Notifications, type NotificationsOptions, } from './notifications.ts';
|
|
2
|
+
export { DisposedError } from './disposed-error.ts';
|
|
3
|
+
export { QueueFullError } from './queue-full-error.ts';
|
|
4
|
+
export { DeniedError, MissingError, UnavailableError, } from '@zukhruf/sqlite-open';
|
|
5
|
+
export { UnsafeFolderError } from '@zukhruf/pipes';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,aAAa,EACb,KAAK,oBAAoB,GAC1B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,WAAW,EACX,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { Notifications, } from "./notifications.js";
|
|
2
|
+
export { DisposedError } from "./disposed-error.js";
|
|
3
|
+
export { QueueFullError } from "./queue-full-error.js";
|
|
4
|
+
export { DeniedError, MissingError, UnavailableError, } from '@zukhruf/sqlite-open';
|
|
5
|
+
export { UnsafeFolderError } from '@zukhruf/pipes';
|
|
6
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAIL,aAAa,GAEd,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EACL,WAAW,EACX,YAAY,EACZ,gBAAgB,GACjB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,iBAAiB,EAAE,MAAM,gBAAgB,CAAC"}
|
package/dist/limits.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.d.ts","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAMA,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAIlD;AAED,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI,CAGlD"}
|
package/dist/limits.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
// Postgres's limits and messages (async.c:600-622): a channel is a name of
|
|
2
|
+
// fewer than NAMEDATALEN (64) bytes, and a payload is shorter than
|
|
3
|
+
// NOTIFY_PAYLOAD_MAX_LENGTH (8000) bytes.
|
|
4
|
+
const NAMEDATALEN = 64;
|
|
5
|
+
const NOTIFY_PAYLOAD_MAX_LENGTH = 8000;
|
|
6
|
+
export function checkChannel(channel) {
|
|
7
|
+
if (channel === '')
|
|
8
|
+
throw new RangeError('channel name cannot be empty');
|
|
9
|
+
if (Buffer.byteLength(channel) >= NAMEDATALEN)
|
|
10
|
+
throw new RangeError('channel name too long');
|
|
11
|
+
}
|
|
12
|
+
export function checkPayload(payload) {
|
|
13
|
+
if (Buffer.byteLength(payload) >= NOTIFY_PAYLOAD_MAX_LENGTH)
|
|
14
|
+
throw new RangeError('payload string too long');
|
|
15
|
+
}
|
|
16
|
+
//# sourceMappingURL=limits.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"limits.js","sourceRoot":"","sources":["../src/limits.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAC3E,mEAAmE;AACnE,0CAA0C;AAC1C,MAAM,WAAW,GAAG,EAAE,CAAC;AACvB,MAAM,yBAAyB,GAAG,IAAI,CAAC;AAEvC,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI,OAAO,KAAK,EAAE;QAAE,MAAM,IAAI,UAAU,CAAC,8BAA8B,CAAC,CAAC;IACzE,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,WAAW;QAC3C,MAAM,IAAI,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAClD,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,OAAe;IAC1C,IAAI,MAAM,CAAC,UAAU,CAAC,OAAO,CAAC,IAAI,yBAAyB;QACzD,MAAM,IAAI,UAAU,CAAC,yBAAyB,CAAC,CAAC;AACpD,CAAC"}
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
import { type Clock } from '@zukhruf/async';
|
|
2
|
+
/** One row of the notification queue, as the listener reads it. */
|
|
3
|
+
export interface QueuedNotification {
|
|
4
|
+
readonly id: number;
|
|
5
|
+
readonly channel: string;
|
|
6
|
+
readonly payload: string;
|
|
7
|
+
readonly processId: number;
|
|
8
|
+
}
|
|
9
|
+
export interface ListeningOptions {
|
|
10
|
+
readonly path: string;
|
|
11
|
+
readonly clock: Clock;
|
|
12
|
+
/** Gets each row of a channel that this listener listens on, in id order. */
|
|
13
|
+
readonly deliver: (notification: QueuedNotification) => void;
|
|
14
|
+
/** Gets a failure that no caller awaits. */
|
|
15
|
+
readonly fail: (error: unknown) => void;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* A listener from its registration to its last unlisten: its own connection
|
|
19
|
+
* to the file, its socket, its row and the backstop. Each first `listen`
|
|
20
|
+
* makes a new one, with a new listener id and a new socket.
|
|
21
|
+
*/
|
|
22
|
+
export declare class Listening {
|
|
23
|
+
#private;
|
|
24
|
+
/** 16 random bytes in hex: the name of the socket and the key of the row. */
|
|
25
|
+
readonly id: string;
|
|
26
|
+
private constructor();
|
|
27
|
+
/**
|
|
28
|
+
* The registration: opens the listener's own connection, serves a new
|
|
29
|
+
* socket, and in one BEGIN IMMEDIATE transaction inserts the listener row
|
|
30
|
+
* with its address and the highest id as its position, and the channel row.
|
|
31
|
+
*/
|
|
32
|
+
static register(channel: string, options: ListeningOptions): Promise<Listening>;
|
|
33
|
+
/** A later listen: one BEGIN IMMEDIATE transaction inserts the channel row and reads the highest id. */
|
|
34
|
+
add(channel: string): void;
|
|
35
|
+
/** Removes the channel row; the last one ends the listener. Resolves `true` when the listener ended. */
|
|
36
|
+
remove(channel: string): Promise<boolean>;
|
|
37
|
+
/** Removes this listener's rows, closes its socket, and closes its connection. */
|
|
38
|
+
end(): Promise<void>;
|
|
39
|
+
/**
|
|
40
|
+
* Reads the rows above the last id on the listener's own connection,
|
|
41
|
+
* outside a transaction, with one statement read to the end (research 20b
|
|
42
|
+
* T4), and delivers the rows of its channels.
|
|
43
|
+
*/
|
|
44
|
+
read(): void;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=listening.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"listening.d.ts","sourceRoot":"","sources":["../src/listening.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,KAAK,KAAK,EAAS,MAAM,gBAAgB,CAAC;AAQnD,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;CAC5B;AAED,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,6EAA6E;IAC7E,QAAQ,CAAC,OAAO,EAAE,CAAC,YAAY,EAAE,kBAAkB,KAAK,IAAI,CAAC;IAC7D,4CAA4C;IAC5C,QAAQ,CAAC,IAAI,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,IAAI,CAAC;CACzC;AA0BD;;;;GAIG;AACH,qBAAa,SAAS;;IACpB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IAgBpB,OAAO;IAyBP;;;;OAIG;WACU,QAAQ,CACnB,OAAO,EAAE,MAAM,EACf,OAAO,EAAE,gBAAgB,GACxB,OAAO,CAAC,SAAS,CAAC;IA2CrB,wGAAwG;IACxG,GAAG,CAAC,OAAO,EAAE,MAAM,GAAG,IAAI;IAa1B,wGAAwG;IAClG,MAAM,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAe/C,kFAAkF;IAC5E,GAAG,IAAI,OAAO,CAAC,IAAI,CAAC;IA0B1B;;;;OAIG;IACH,IAAI,IAAI,IAAI;CA8Eb"}
|