@crvouga/mockingbird-notifications 0.2.1 → 0.4.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,393 @@
1
+ import {
2
+ createNotificationHarness
3
+ } from "./chunk-5DUELOZW.js";
4
+ import {
5
+ adminClientScript,
6
+ adminClientSource
7
+ } from "./chunk-5KZ24SHQ.js";
8
+
9
+ // src/server.ts
10
+ import { readFile } from "node:fs/promises";
11
+
12
+ // ../adapters/node/dist/serve.js
13
+ import { createServer } from "node:http";
14
+ import { Readable } from "node:stream";
15
+ var serve = async (api, options = {}) => {
16
+ const maxBytes = options.maxBodyBytes ?? 16 * 1024 * 1024;
17
+ const timeoutMs = options.requestTimeoutMs ?? 3e4;
18
+ if (!Number.isSafeInteger(maxBytes) || maxBytes < 0 || !Number.isSafeInteger(timeoutMs) || timeoutMs < 1)
19
+ throw new Error("invalid request limits");
20
+ const server = createServer(async (req, res) => {
21
+ const aborted = new AbortController();
22
+ let reader;
23
+ let timer;
24
+ const abort = () => {
25
+ aborted.abort();
26
+ void reader?.cancel().catch(() => {
27
+ });
28
+ };
29
+ const fail = (status, message) => {
30
+ if (!res.headersSent && !res.destroyed) {
31
+ res.writeHead(status, { "content-type": "application/json", connection: "close" });
32
+ res.end(JSON.stringify({ error: { type: "mockingbird_transport", message } }));
33
+ }
34
+ abort();
35
+ };
36
+ req.once("aborted", abort);
37
+ res.once("close", abort);
38
+ res.once("error", abort);
39
+ try {
40
+ const address = server.address();
41
+ const port = typeof address === "object" && address !== null ? address.port : 80;
42
+ const url = new URL((req.url ?? "/").replace(/^\/+/, "/"), `http://${req.headers.host ?? `localhost:${port}`}`);
43
+ const headers = new Headers();
44
+ for (const [name, value] of Object.entries(req.headers)) {
45
+ if (Array.isArray(value))
46
+ for (const item of value)
47
+ headers.append(name, item);
48
+ else if (value !== void 0)
49
+ headers.set(name, value);
50
+ }
51
+ const init = {
52
+ method: req.method ?? "GET",
53
+ headers,
54
+ signal: aborted.signal
55
+ };
56
+ if (init.method !== "GET" && init.method !== "HEAD") {
57
+ if (Number(req.headers["content-length"]) > maxBytes) {
58
+ fail(413, "request body exceeds byte limit");
59
+ return;
60
+ }
61
+ let bytes = 0;
62
+ const source = Readable.toWeb(req);
63
+ init.body = source.pipeThrough(new TransformStream({
64
+ transform(chunk, controller) {
65
+ bytes += chunk.byteLength;
66
+ if (bytes > maxBytes) {
67
+ fail(413, "request body exceeds byte limit");
68
+ controller.error(new Error("request body exceeds byte limit"));
69
+ } else
70
+ controller.enqueue(chunk);
71
+ }
72
+ }));
73
+ init.duplex = "half";
74
+ timer = setTimeout(() => fail(408, "request body timed out"), timeoutMs);
75
+ req.once("end", () => clearTimeout(timer));
76
+ }
77
+ const response = await api.fetch(new Request(url, init));
78
+ if (aborted.signal.aborted || res.destroyed) {
79
+ await response.body?.cancel();
80
+ return;
81
+ }
82
+ const output = Object.fromEntries(response.headers);
83
+ const cookies = response.headers.getSetCookie();
84
+ if (cookies.length)
85
+ output["set-cookie"] = cookies;
86
+ res.writeHead(response.status, output);
87
+ if (!response.body) {
88
+ res.end();
89
+ return;
90
+ }
91
+ res.flushHeaders();
92
+ reader = response.body.getReader();
93
+ for (; ; ) {
94
+ const { done, value } = await reader.read();
95
+ if (done || aborted.signal.aborted)
96
+ break;
97
+ if (!res.write(value)) {
98
+ await new Promise((resolve) => {
99
+ const finish = () => {
100
+ res.off("drain", finish);
101
+ res.off("close", finish);
102
+ res.off("error", finish);
103
+ resolve();
104
+ };
105
+ res.once("drain", finish);
106
+ res.once("close", finish);
107
+ res.once("error", finish);
108
+ if (res.destroyed || aborted.signal.aborted)
109
+ finish();
110
+ });
111
+ }
112
+ }
113
+ if (!aborted.signal.aborted)
114
+ res.end();
115
+ } catch (error) {
116
+ if (error.code === "MOCKINGBIRD_DROP")
117
+ req.socket.destroy();
118
+ else if (!aborted.signal.aborted && !res.destroyed) {
119
+ if (res.headersSent)
120
+ res.destroy();
121
+ else {
122
+ res.writeHead(500, { "content-type": "application/json" });
123
+ res.end(JSON.stringify({
124
+ error: {
125
+ type: "mockingbird_internal",
126
+ message: error instanceof Error ? error.message : String(error)
127
+ }
128
+ }));
129
+ }
130
+ }
131
+ } finally {
132
+ clearTimeout(timer);
133
+ reader?.releaseLock();
134
+ req.off("aborted", abort);
135
+ res.off("close", abort);
136
+ res.off("error", abort);
137
+ if (!req.complete)
138
+ req.resume();
139
+ }
140
+ });
141
+ server.requestTimeout = timeoutMs;
142
+ await new Promise((resolve, reject) => {
143
+ server.once("error", reject);
144
+ server.listen(options.port ?? 0, options.host, resolve);
145
+ });
146
+ return server;
147
+ };
148
+
149
+ // ../adapters/node/dist/listen.js
150
+ var listen = async (api, options = {}) => {
151
+ const host = options.host ?? "127.0.0.1";
152
+ const server = await serve(api, {
153
+ port: options.port ?? 0,
154
+ host,
155
+ ...options.maxBodyBytes !== void 0 ? { maxBodyBytes: options.maxBodyBytes } : {}
156
+ });
157
+ const address = server.address();
158
+ const port = typeof address === "object" && address !== null ? address.port : options.port ?? 0;
159
+ const shown = host.includes(":") ? `[${host}]` : host;
160
+ return {
161
+ url: `http://${shown}:${port}`,
162
+ port,
163
+ host,
164
+ server,
165
+ close: () => new Promise((resolve, reject) => {
166
+ server.close((error) => {
167
+ if (error && error.code !== "ERR_SERVER_NOT_RUNNING")
168
+ reject(error);
169
+ else
170
+ resolve();
171
+ });
172
+ server.closeAllConnections?.();
173
+ })
174
+ };
175
+ };
176
+
177
+ // ../admin-ui/dist/compose.js
178
+ var composeAdminRoutes = (apis, options) => {
179
+ if (apis.length === 0)
180
+ throw new RangeError("composeAdminApis needs at least one admin API");
181
+ const ids = /* @__PURE__ */ new Set();
182
+ for (const api of apis) {
183
+ if (!/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/.test(api.id))
184
+ throw new RangeError(`invalid admin API id ${JSON.stringify(api.id)}`);
185
+ if (ids.has(api.id))
186
+ throw new RangeError(`duplicate admin API id ${api.id}`);
187
+ ids.add(api.id);
188
+ }
189
+ const prefix = `/${(options.prefix ?? "/__admin").replace(/^\/+|\/+$/g, "")}`;
190
+ const first = apis[0];
191
+ const config = {
192
+ service: first.service,
193
+ adminPrefix: `${prefix}/apis/${first.id}`,
194
+ adminKeyHeader: first.adminKeyHeader,
195
+ standardRoutes: first.standardRoutes,
196
+ brandsUrl: options.brandsUrl,
197
+ apis: apis.map(({ fetch: _fetch, ...api }) => ({
198
+ ...api,
199
+ adminPrefix: `${prefix}/apis/${api.id}`
200
+ }))
201
+ };
202
+ return {
203
+ config,
204
+ prefix,
205
+ async fetch(request) {
206
+ const url = new URL(request.url);
207
+ const root = `${prefix}/apis/`;
208
+ if (!url.pathname.startsWith(root))
209
+ return new Response("Not found", { status: 404 });
210
+ const rest = url.pathname.slice(root.length);
211
+ const slash = rest.indexOf("/");
212
+ const id = slash < 0 ? rest : rest.slice(0, slash);
213
+ const api = apis.find((candidate) => candidate.id === id);
214
+ if (!api)
215
+ return new Response("Not found", { status: 404 });
216
+ url.pathname = `${api.adminPrefix.replace(/\/$/, "")}${slash < 0 ? "" : rest.slice(slash)}`;
217
+ return api.fetch(new Request(url, request));
218
+ }
219
+ };
220
+ };
221
+
222
+ // ../admin-ui/dist/index.js
223
+ var escapeHtml = (value) => value.replace(/[&<>"']/g, (char) => ({ "&": "&amp;", "<": "&lt;", ">": "&gt;", '"': "&quot;", "'": "&#39;" })[char] ?? char);
224
+ var composeAdminApis = (apis, options) => {
225
+ const { config, prefix, fetch: forward } = composeAdminRoutes(apis, options);
226
+ const title = escapeHtml(options.title ?? "Mockingbird");
227
+ const document = `<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width,initial-scale=1"><meta name="color-scheme" content="light dark"><title>${title} admin</title><style>html,body{margin:0;min-height:100%}#admin-root{min-height:100%}</style></head><body><main id="admin-root" data-mockingbird-admin data-admin-ui-library="antd" data-service="${title}"><noscript>Enable JavaScript to use administration.</noscript></main>${adminClientSource(config)}</body></html>`;
228
+ return {
229
+ config,
230
+ async fetch(request) {
231
+ const url = new URL(request.url);
232
+ if (request.method === "GET" && (url.pathname === `${prefix}/ui` || url.pathname === `${prefix}/ui/`))
233
+ return new Response(document, {
234
+ headers: { "content-type": "text/html; charset=utf-8", "cache-control": "no-store" }
235
+ });
236
+ return forward(request);
237
+ }
238
+ };
239
+ };
240
+
241
+ // src/admin-gateway.ts
242
+ var ADMIN_BRANDS_URL = "https://mockingbird.chrisvouga.dev/brands.json";
243
+ var PREFIX = "/admin";
244
+ var KEY_HEADER = "x-mockingbird-admin-key";
245
+ var HOP_HEADERS = [
246
+ "connection",
247
+ "content-encoding",
248
+ "content-length",
249
+ "host",
250
+ "keep-alive",
251
+ "transfer-encoding"
252
+ ];
253
+ var script;
254
+ var adminScript = () => {
255
+ script ??= adminClientScript();
256
+ return script;
257
+ };
258
+ var idFor = (name, taken) => {
259
+ const base = name.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 56) || "emulator";
260
+ let id = base;
261
+ for (let n = 2; taken.has(id); n++) id = `${base}-${n}`;
262
+ taken.add(id);
263
+ return id;
264
+ };
265
+ var failure = (status, message) => new Response(JSON.stringify({ error: { type: "mockingbird_notifications", message } }), {
266
+ status,
267
+ headers: { "content-type": "application/json; charset=utf-8" }
268
+ });
269
+ var adminGateway = (options = {}) => (context) => {
270
+ const brandsUrl = options.brandsUrl ?? ADMIN_BRANDS_URL;
271
+ const forward = (target) => async (request) => {
272
+ const from = new URL(request.url);
273
+ const headers = new Headers(request.headers);
274
+ for (const name of HOP_HEADERS) headers.delete(name);
275
+ headers.delete("accept-encoding");
276
+ if (!headers.has(KEY_HEADER))
277
+ for (const [name, value] of Object.entries(context.headers(target.name)))
278
+ headers.set(name, value);
279
+ const hasBody = request.method !== "GET" && request.method !== "HEAD";
280
+ try {
281
+ const response = await target.fetch(
282
+ new Request(new URL(`${from.pathname}${from.search}`, target.adminUrl), {
283
+ method: request.method,
284
+ headers,
285
+ ...hasBody ? { body: await request.arrayBuffer() } : {},
286
+ signal: request.signal
287
+ })
288
+ );
289
+ const out = new Headers(response.headers);
290
+ for (const name of HOP_HEADERS) out.delete(name);
291
+ return new Response(response.body, {
292
+ status: response.status,
293
+ statusText: response.statusText,
294
+ headers: out
295
+ });
296
+ } catch (error) {
297
+ return failure(
298
+ 502,
299
+ `${target.name} is unreachable at ${target.adminUrl}: ${error instanceof Error ? error.message : String(error)}`
300
+ );
301
+ }
302
+ };
303
+ let composed = null;
304
+ const compose = async () => {
305
+ const targets = await context.targets();
306
+ if (targets.length === 0) return null;
307
+ const key = targets.map((t) => `${t.name}\0${t.target}\0${t.adminUrl}`).join("\n");
308
+ if (composed?.key === key) return composed;
309
+ const taken = /* @__PURE__ */ new Set();
310
+ const apis = targets.map(
311
+ (target) => ({
312
+ id: idFor(target.name, taken),
313
+ label: target.name === target.target ? target.name : `${target.name} (${target.target})`,
314
+ service: target.target,
315
+ adminPrefix: new URL(target.adminUrl).pathname.replace(/\/+$/, ""),
316
+ adminKeyHeader: KEY_HEADER,
317
+ standardRoutes: [],
318
+ fetch: forward(target)
319
+ })
320
+ );
321
+ const first = apis[0];
322
+ const routes = composeAdminApis(apis, { brandsUrl, prefix: PREFIX, title: context.title });
323
+ composed = {
324
+ key,
325
+ config: {
326
+ service: first.service,
327
+ adminPrefix: `${PREFIX}/apis/${first.id}`,
328
+ adminKeyHeader: KEY_HEADER,
329
+ standardRoutes: [],
330
+ brandsUrl,
331
+ apis: apis.map(({ fetch: _fetch, ...api }) => ({
332
+ ...api,
333
+ adminPrefix: `${PREFIX}/apis/${api.id}`
334
+ }))
335
+ },
336
+ fetch: (request) => routes.fetch(request)
337
+ };
338
+ return composed;
339
+ };
340
+ return {
341
+ config: async () => (await compose())?.config ?? null,
342
+ async fetch(request) {
343
+ const path = new URL(request.url).pathname;
344
+ if (path === `${PREFIX}/ui.js`) {
345
+ if (request.method !== "GET" && request.method !== "HEAD")
346
+ return failure(405, "method not allowed");
347
+ return new Response(adminScript(), {
348
+ headers: {
349
+ "content-type": "text/javascript; charset=utf-8",
350
+ "cache-control": "no-store"
351
+ }
352
+ });
353
+ }
354
+ const current = await compose();
355
+ if (!current) return failure(404, "the harness knows no emulators");
356
+ return current.fetch(request);
357
+ }
358
+ };
359
+ };
360
+
361
+ // src/server.ts
362
+ var DEFAULT_PORT = 8790;
363
+ var manifestFile = (path) => async () => JSON.parse(await readFile(path, "utf8"));
364
+ var createServer2 = async (options = {}) => {
365
+ const { port, host, manifest, ...rest } = options;
366
+ const harness = createNotificationHarness({
367
+ admin: adminGateway(),
368
+ ...rest,
369
+ ...manifest === void 0 ? {} : { manifest: typeof manifest === "string" ? manifestFile(manifest) : manifest }
370
+ });
371
+ const listening = await listen(harness, {
372
+ port: port ?? 0,
373
+ ...host !== void 0 ? { host } : {}
374
+ });
375
+ return {
376
+ url: listening.url,
377
+ port: listening.port,
378
+ harness,
379
+ close: async () => {
380
+ harness.close();
381
+ await listening.close();
382
+ }
383
+ };
384
+ };
385
+
386
+ export {
387
+ ADMIN_BRANDS_URL,
388
+ adminGateway,
389
+ DEFAULT_PORT,
390
+ manifestFile,
391
+ createServer2 as createServer
392
+ };
393
+ //# sourceMappingURL=chunk-JECNH6UB.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/server.ts", "../../adapters/node/src/serve.ts", "../../adapters/node/src/listen.ts", "../../admin-ui/src/compose.ts", "../../admin-ui/src/index.ts", "../src/admin-gateway.ts"],
4
+ "sourcesContent": ["/// <reference types=\"node\" />\nimport { readFile } from \"node:fs/promises\"\nimport { listen } from \"@crvouga/mockingbird-adapter-node\"\nimport { adminGateway } from \"./admin-gateway.js\"\nimport type { FleetManifest } from \"./discovery.js\"\nimport {\n createNotificationHarness,\n type HarnessOptions,\n type NotificationHarness,\n} from \"./harness.js\"\n\nexport { ADMIN_BRANDS_URL, type AdminGatewayOptions, adminGateway } from \"./admin-gateway.js\"\n\n/** Port `mockingbird-notifications serve` listens on when none is given. */\nexport const DEFAULT_PORT = 8790\n\n/**\n * `admin` defaults to `adminGateway()` here: the page gets an Emulators tab with every emulator's\n * admin dashboard. Pass `admin: false` for the notifications UI alone.\n */\nexport type NotificationServerOptions = Omit<HarnessOptions, \"manifest\"> & {\n /** A fleet ready manifest object, or the path of the fleet's `--ready-file` (re-read every sync). */\n manifest?: HarnessOptions[\"manifest\"] | string\n /** Default `0`: the OS picks a free port. */\n port?: number\n /** Default `127.0.0.1`. */\n host?: string\n}\n\nexport type NotificationServer = {\n url: string\n port: number\n harness: NotificationHarness\n close(): Promise<void>\n}\n\n/** A manifest loader that re-reads the fleet's ready file, so a restarted fleet is picked up. */\nexport const manifestFile = (path: string) => async (): Promise<FleetManifest> =>\n JSON.parse(await readFile(path, \"utf8\")) as FleetManifest\n\nexport const createServer = async (\n options: NotificationServerOptions = {},\n): Promise<NotificationServer> => {\n const { port, host, manifest, ...rest } = options\n const harness = createNotificationHarness({\n admin: adminGateway(),\n ...rest,\n ...(manifest === undefined\n ? {}\n : { manifest: typeof manifest === \"string\" ? manifestFile(manifest) : manifest }),\n })\n const listening = await listen(harness, {\n port: port ?? 0,\n ...(host !== undefined ? { host } : {}),\n })\n return {\n url: listening.url,\n port: listening.port,\n harness,\n close: async () => {\n harness.close()\n await listening.close()\n },\n }\n}\n", "import { createServer, type Server } from \"node:http\"\nimport { Readable } from \"node:stream\"\nimport type { FetchAPI } from \"@crvouga/mockingbird-core\"\n\n/** Limits apply incrementally, including chunked uploads. Bodies reach fetch as a stream. */\nexport type NodeServeOptions = {\n port?: number\n host?: string\n maxBodyBytes?: number\n requestTimeoutMs?: number\n}\n\n/** Serve a FetchAPI with bounded streaming uploads and disconnect-aware response backpressure. */\nexport const serve = async (api: FetchAPI, options: NodeServeOptions = {}): Promise<Server> => {\n const maxBytes = options.maxBodyBytes ?? 16 * 1024 * 1024\n const timeoutMs = options.requestTimeoutMs ?? 30_000\n if (\n !Number.isSafeInteger(maxBytes) ||\n maxBytes < 0 ||\n !Number.isSafeInteger(timeoutMs) ||\n timeoutMs < 1\n )\n throw new Error(\"invalid request limits\")\n const server = createServer(async (req, res) => {\n const aborted = new AbortController()\n let reader: ReadableStreamDefaultReader<Uint8Array> | undefined\n let timer: ReturnType<typeof setTimeout> | undefined\n const abort = () => {\n aborted.abort()\n void reader?.cancel().catch(() => {})\n }\n const fail = (status: number, message: string) => {\n if (!res.headersSent && !res.destroyed) {\n res.writeHead(status, { \"content-type\": \"application/json\", connection: \"close\" })\n res.end(JSON.stringify({ error: { type: \"mockingbird_transport\", message } }))\n }\n abort()\n }\n req.once(\"aborted\", abort)\n res.once(\"close\", abort)\n res.once(\"error\", abort)\n try {\n const address = server.address()\n const port = typeof address === \"object\" && address !== null ? address.port : 80\n const url = new URL(\n (req.url ?? \"/\").replace(/^\\/+/, \"/\"),\n `http://${req.headers.host ?? `localhost:${port}`}`,\n )\n const headers = new Headers()\n for (const [name, value] of Object.entries(req.headers)) {\n if (Array.isArray(value)) for (const item of value) headers.append(name, item)\n else if (value !== undefined) headers.set(name, value)\n }\n const init: RequestInit & { duplex?: \"half\" } = {\n method: req.method ?? \"GET\",\n headers,\n signal: aborted.signal,\n }\n if (init.method !== \"GET\" && init.method !== \"HEAD\") {\n if (Number(req.headers[\"content-length\"]) > maxBytes) {\n fail(413, \"request body exceeds byte limit\")\n return\n }\n let bytes = 0\n const source = Readable.toWeb(req) as unknown as ReadableStream<Uint8Array>\n init.body = source.pipeThrough(\n new TransformStream<Uint8Array, Uint8Array>({\n transform(chunk, controller) {\n bytes += chunk.byteLength\n if (bytes > maxBytes) {\n fail(413, \"request body exceeds byte limit\")\n controller.error(new Error(\"request body exceeds byte limit\"))\n } else controller.enqueue(chunk)\n },\n }),\n )\n init.duplex = \"half\"\n timer = setTimeout(() => fail(408, \"request body timed out\"), timeoutMs)\n req.once(\"end\", () => clearTimeout(timer))\n }\n const response = await api.fetch(new Request(url, init))\n if (aborted.signal.aborted || res.destroyed) {\n await response.body?.cancel()\n return\n }\n const output: Record<string, string | string[]> = Object.fromEntries(response.headers)\n const cookies = response.headers.getSetCookie()\n if (cookies.length) output[\"set-cookie\"] = cookies\n res.writeHead(response.status, output)\n if (!response.body) {\n res.end()\n return\n }\n res.flushHeaders()\n reader = response.body.getReader()\n for (;;) {\n const { done, value } = await reader.read()\n if (done || aborted.signal.aborted) break\n if (!res.write(value)) {\n await new Promise<void>((resolve) => {\n const finish = () => {\n res.off(\"drain\", finish)\n res.off(\"close\", finish)\n res.off(\"error\", finish)\n resolve()\n }\n res.once(\"drain\", finish)\n res.once(\"close\", finish)\n res.once(\"error\", finish)\n if (res.destroyed || aborted.signal.aborted) finish()\n })\n }\n }\n if (!aborted.signal.aborted) res.end()\n } catch (error) {\n if ((error as { code?: string }).code === \"MOCKINGBIRD_DROP\") req.socket.destroy()\n else if (!aborted.signal.aborted && !res.destroyed) {\n if (res.headersSent) res.destroy()\n else {\n res.writeHead(500, { \"content-type\": \"application/json\" })\n res.end(\n JSON.stringify({\n error: {\n type: \"mockingbird_internal\",\n message: error instanceof Error ? error.message : String(error),\n },\n }),\n )\n }\n }\n } finally {\n clearTimeout(timer)\n reader?.releaseLock()\n req.off(\"aborted\", abort)\n res.off(\"close\", abort)\n res.off(\"error\", abort)\n if (!req.complete) req.resume()\n }\n })\n server.requestTimeout = timeoutMs\n await new Promise<void>((resolve, reject) => {\n server.once(\"error\", reject)\n server.listen(options.port ?? 0, options.host, resolve)\n })\n return server\n}\n", "import type { Server } from \"node:http\"\nimport type { FetchAPI } from \"@crvouga/mockingbird-core\"\nimport { serve } from \"./serve.js\"\n\nexport type ListenOptions = {\n /** Default `0`: the OS picks a free port. */\n port?: number\n /** Default `127.0.0.1`: a mock should not be reachable off the machine by accident. */\n host?: string\n /** Largest request body accepted. Default 16 MiB. */\n maxBodyBytes?: number\n}\n\n/** A running server, with the address it actually bound. */\nexport type Listening = {\n url: string\n port: number\n host: string\n server: Server\n close(): Promise<void>\n}\n\nexport const listen = async (api: FetchAPI, options: ListenOptions = {}): Promise<Listening> => {\n const host = options.host ?? \"127.0.0.1\"\n const server = await serve(api, {\n port: options.port ?? 0,\n host,\n ...(options.maxBodyBytes !== undefined ? { maxBodyBytes: options.maxBodyBytes } : {}),\n })\n const address = server.address()\n const port = typeof address === \"object\" && address !== null ? address.port : (options.port ?? 0)\n const shown = host.includes(\":\") ? `[${host}]` : host\n return {\n url: `http://${shown}:${port}`,\n port,\n host,\n server,\n close: () =>\n new Promise<void>((resolve, reject) => {\n // Stop accepting first, then drop keep-alive sockets so close() can finish.\n server.close((error) => {\n if (error && (error as { code?: string }).code !== \"ERR_SERVER_NOT_RUNNING\") reject(error)\n else resolve()\n })\n server.closeAllConnections?.()\n }),\n }\n}\n", "import type { AdminApiConfig, AdminConfig } from \"./model.js\"\n\nexport type ComposableAdminApi = AdminApiConfig & {\n fetch(request: Request): Promise<Response>\n}\n\nexport type ComposedAdminRoutes = {\n /** What the shared UI mounts with: one entry per API, each behind `<prefix>/apis/<id>`. */\n config: AdminConfig\n /** The normalised mount prefix, `/__admin` by default. */\n prefix: string\n /** Forwards `<prefix>/apis/<id>/\u2026` to that API unchanged. Everything else is a 404. */\n fetch(request: Request): Promise<Response>\n}\n\n/**\n * The routing half of `composeAdminApis`: the UI config and the forwarding fetch, without the\n * HTML document. This module never imports the prebuilt browser bundle, so a page that mounts\n * the UI from `@crvouga/mockingbird-admin-ui/browser` does not also carry it as a string.\n */\nexport const composeAdminRoutes = (\n apis: readonly ComposableAdminApi[],\n options: { brandsUrl: string; prefix?: string },\n): ComposedAdminRoutes => {\n if (apis.length === 0) throw new RangeError(\"composeAdminApis needs at least one admin API\")\n const ids = new Set<string>()\n for (const api of apis) {\n if (!/^[a-z0-9](?:[a-z0-9-]{0,62}[a-z0-9])?$/.test(api.id))\n throw new RangeError(`invalid admin API id ${JSON.stringify(api.id)}`)\n if (ids.has(api.id)) throw new RangeError(`duplicate admin API id ${api.id}`)\n ids.add(api.id)\n }\n const prefix = `/${(options.prefix ?? \"/__admin\").replace(/^\\/+|\\/+$/g, \"\")}`\n const first = apis[0] as ComposableAdminApi\n const config: AdminConfig = {\n service: first.service,\n adminPrefix: `${prefix}/apis/${first.id}`,\n adminKeyHeader: first.adminKeyHeader,\n standardRoutes: first.standardRoutes,\n brandsUrl: options.brandsUrl,\n apis: apis.map(({ fetch: _fetch, ...api }) => ({\n ...api,\n adminPrefix: `${prefix}/apis/${api.id}`,\n })),\n }\n return {\n config,\n prefix,\n async fetch(request) {\n const url = new URL(request.url)\n const root = `${prefix}/apis/`\n if (!url.pathname.startsWith(root)) return new Response(\"Not found\", { status: 404 })\n const rest = url.pathname.slice(root.length)\n const slash = rest.indexOf(\"/\")\n const id = slash < 0 ? rest : rest.slice(0, slash)\n const api = apis.find((candidate) => candidate.id === id)\n if (!api) return new Response(\"Not found\", { status: 404 })\n url.pathname = `${api.adminPrefix.replace(/\\/$/, \"\")}${slash < 0 ? \"\" : rest.slice(slash)}`\n return api.fetch(new Request(url, request))\n },\n }\n}\n", "import { type ComposableAdminApi, composeAdminRoutes } from \"./compose.js\"\nimport { adminClientSource } from \"./document.js\"\nimport type { AdminConfig } from \"./model.js\"\n\nexport type { ComposableAdminApi, ComposedAdminRoutes } from \"./compose.js\"\nexport { composeAdminRoutes } from \"./compose.js\"\nexport { adminClientScript, adminClientSource, membersClientSource } from \"./document.js\"\nexport type { AdminApiConfig, AdminConfig, MembersConfig } from \"./model.js\"\n\nconst escapeHtml = (value: string): string =>\n value.replace(\n /[&<>\"']/g,\n (char) =>\n ({ \"&\": \"&amp;\", \"<\": \"&lt;\", \">\": \"&gt;\", '\"': \"&quot;\", \"'\": \"&#39;\" })[char] ?? char,\n )\n\n/**\n * Compose independent admin APIs behind one fetch handler and one UI. The shell is only a\n * facade: every data/control request is forwarded unchanged to the selected API.\n */\nexport const composeAdminApis = (\n apis: readonly ComposableAdminApi[],\n options: { brandsUrl: string; prefix?: string; title?: string },\n): { config: AdminConfig; fetch(request: Request): Promise<Response> } => {\n const { config, prefix, fetch: forward } = composeAdminRoutes(apis, options)\n const title = escapeHtml(options.title ?? \"Mockingbird\")\n const document = `<!DOCTYPE html><html lang=\"en\"><head><meta charset=\"utf-8\"><meta name=\"viewport\" content=\"width=device-width,initial-scale=1\"><meta name=\"color-scheme\" content=\"light dark\"><title>${title} admin</title><style>html,body{margin:0;min-height:100%}#admin-root{min-height:100%}</style></head><body><main id=\"admin-root\" data-mockingbird-admin data-admin-ui-library=\"antd\" data-service=\"${title}\"><noscript>Enable JavaScript to use administration.</noscript></main>${adminClientSource(config)}</body></html>`\n return {\n config,\n async fetch(request) {\n const url = new URL(request.url)\n if (\n request.method === \"GET\" &&\n (url.pathname === `${prefix}/ui` || url.pathname === `${prefix}/ui/`)\n )\n return new Response(document, {\n headers: { \"content-type\": \"text/html; charset=utf-8\", \"cache-control\": \"no-store\" },\n })\n return forward(request)\n },\n }\n}\n", "/**\n * The admin gateway: every emulator's admin API and the shared admin UI, on the harness's own\n * origin. The browser then needs one port and no CORS, however many emulators the fleet runs.\n *\n * /admin/ui.js the admin UI (defines `MockingbirdAdmin.mount(host, config)`)\n * /admin/ui the admin UI as a page of its own\n * /admin/apis/<name>/\u2026 that emulator's admin API, forwarded unchanged\n *\n * This module carries the prebuilt admin UI (about 1.3 MB), which is why the harness takes it as an\n * option instead of importing it: an app that embeds the harness in a browser does not pay for it.\n */\nimport {\n type AdminConfig,\n adminClientScript,\n type ComposableAdminApi,\n composeAdminApis,\n} from \"@crvouga/mockingbird-admin-ui\"\nimport type { AdminTarget } from \"./discovery.js\"\nimport type { AdminGatewayFactory } from \"./harness.js\"\n\n/** Where the admin UI reads each vendor's logo and links from, as every emulator's own admin does. */\nexport const ADMIN_BRANDS_URL = \"https://mockingbird.chrisvouga.dev/brands.json\"\n\nconst PREFIX = \"/admin\"\nconst KEY_HEADER = \"x-mockingbird-admin-key\"\n/** Describe one hop, not the resource: never forwarded in either direction. */\nconst HOP_HEADERS = [\n \"connection\",\n \"content-encoding\",\n \"content-length\",\n \"host\",\n \"keep-alive\",\n \"transfer-encoding\",\n]\n\nlet script: string | undefined\n/** The admin UI bundle as a script file: it defines `MockingbirdAdmin` and mounts nothing. */\nconst adminScript = (): string => {\n script ??= adminClientScript()\n return script\n}\n\n/** Admin API ids are DNS-label shaped; emulator names from `services` can be anything. */\nconst idFor = (name: string, taken: Set<string>): string => {\n const base =\n name\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"-\")\n .replace(/^-+|-+$/g, \"\")\n .slice(0, 56) || \"emulator\"\n let id = base\n for (let n = 2; taken.has(id); n++) id = `${base}-${n}`\n taken.add(id)\n return id\n}\n\nconst failure = (status: number, message: string) =>\n new Response(JSON.stringify({ error: { type: \"mockingbird_notifications\", message } }), {\n status,\n headers: { \"content-type\": \"application/json; charset=utf-8\" },\n })\n\nexport type AdminGatewayOptions = {\n /** Default {@link ADMIN_BRANDS_URL}. */\n brandsUrl?: string\n}\n\n/**\n * Pass the result as the harness's `admin` option. `createServer` does so by default.\n *\n * A request that carries no admin key gets the harness's own (`adminKey` / `adminKeys`), so the\n * page works against a locked fleet without the viewer typing the key. Anyone who can reach the\n * harness can then change emulator state: keep it on a loopback or otherwise private address.\n */\nexport const adminGateway =\n (options: AdminGatewayOptions = {}): AdminGatewayFactory =>\n (context) => {\n const brandsUrl = options.brandsUrl ?? ADMIN_BRANDS_URL\n\n const forward =\n (target: AdminTarget) =>\n async (request: Request): Promise<Response> => {\n const from = new URL(request.url)\n const headers = new Headers(request.headers)\n for (const name of HOP_HEADERS) headers.delete(name)\n headers.delete(\"accept-encoding\")\n if (!headers.has(KEY_HEADER))\n for (const [name, value] of Object.entries(context.headers(target.name)))\n headers.set(name, value)\n const hasBody = request.method !== \"GET\" && request.method !== \"HEAD\"\n try {\n const response = await target.fetch(\n new Request(new URL(`${from.pathname}${from.search}`, target.adminUrl), {\n method: request.method,\n headers,\n ...(hasBody ? { body: await request.arrayBuffer() } : {}),\n signal: request.signal,\n }),\n )\n const out = new Headers(response.headers)\n for (const name of HOP_HEADERS) out.delete(name)\n return new Response(response.body, {\n status: response.status,\n statusText: response.statusText,\n headers: out,\n })\n } catch (error) {\n return failure(\n 502,\n `${target.name} is unreachable at ${target.adminUrl}: ${error instanceof Error ? error.message : String(error)}`,\n )\n }\n }\n\n type Composed = {\n key: string\n config: AdminConfig\n fetch(request: Request): Promise<Response>\n }\n let composed: Composed | null = null\n const compose = async (): Promise<Composed | null> => {\n const targets = await context.targets()\n if (targets.length === 0) return null\n const key = targets.map((t) => `${t.name}\\u0000${t.target}\\u0000${t.adminUrl}`).join(\"\\n\")\n if (composed?.key === key) return composed\n const taken = new Set<string>()\n const apis = targets.map(\n (target): ComposableAdminApi => ({\n id: idFor(target.name, taken),\n label: target.name === target.target ? target.name : `${target.name} (${target.target})`,\n service: target.target,\n adminPrefix: new URL(target.adminUrl).pathname.replace(/\\/+$/, \"\"),\n adminKeyHeader: KEY_HEADER,\n standardRoutes: [],\n fetch: forward(target),\n }),\n )\n const first = apis[0] as ComposableAdminApi\n const routes = composeAdminApis(apis, { brandsUrl, prefix: PREFIX, title: context.title })\n composed = {\n key,\n config: {\n service: first.service,\n adminPrefix: `${PREFIX}/apis/${first.id}`,\n adminKeyHeader: KEY_HEADER,\n standardRoutes: [],\n brandsUrl,\n apis: apis.map(({ fetch: _fetch, ...api }) => ({\n ...api,\n adminPrefix: `${PREFIX}/apis/${api.id}`,\n })),\n },\n fetch: (request) => routes.fetch(request),\n }\n return composed\n }\n\n return {\n config: async () => (await compose())?.config ?? null,\n async fetch(request) {\n const path = new URL(request.url).pathname\n if (path === `${PREFIX}/ui.js`) {\n if (request.method !== \"GET\" && request.method !== \"HEAD\")\n return failure(405, \"method not allowed\")\n return new Response(adminScript(), {\n headers: {\n \"content-type\": \"text/javascript; charset=utf-8\",\n \"cache-control\": \"no-store\",\n },\n })\n }\n const current = await compose()\n if (!current) return failure(404, \"the harness knows no emulators\")\n return current.fetch(request)\n },\n }\n }\n"],
5
+ "mapp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,IAAI,SAAS,YAAY,GAAG;AAAA,UACjC,SAAS;AAAA,YACP,gBAAgB;AAAA,YAChB,iBAAiB;AAAA,UACnB;AAAA,QACF,CAAC;AAAA,MACH;AACA,YAAM,UAAU,MAAM,QAAQ;AAC9B,UAAI,CAAC,QAAS,QAAO,QAAQ,KAAK,gCAAgC;AAClE,aAAO,QAAQ,MAAM,OAAO;AAAA,IAC9B;AAAA,EACF;AACF;;;ALlKK,IAAM,eAAe;AAuBrB,IAAM,eAAe,CAAC,SAAiB,YAC5C,KAAK,MAAM,MAAM,SAAS,MAAM,MAAM,CAAC;AAElC,IAAMA,gBAAe,OAC1B,UAAqC,CAAC,MACN;AAChC,QAAM,EAAE,MAAM,MAAM,UAAU,GAAG,KAAK,IAAI;AAC1C,QAAM,UAAU,0BAA0B;AAAA,IACxC,OAAO,aAAa;AAAA,IACpB,GAAG;AAAA,IACH,GAAI,aAAa,SACb,CAAC,IACD,EAAE,UAAU,OAAO,aAAa,WAAW,aAAa,QAAQ,IAAI,SAAS;AAAA,EACnF,CAAC;AACD,QAAM,YAAY,MAAM,OAAO,SAAS;AAAA,IACtC,MAAM,QAAQ;AAAA,IACd,GAAI,SAAS,SAAY,EAAE,KAAK,IAAI,CAAC;AAAA,EACvC,CAAC;AACD,SAAO;AAAA,IACL,KAAK,UAAU;AAAA,IACf,MAAM,UAAU;AAAA,IAChB;AAAA,IACA,OAAO,YAAY;AACjB,cAAQ,MAAM;AACd,YAAM,UAAU,MAAM;AAAA,IACxB;AAAA,EACF;AACF;",
6
+ "names": ["createServer"]
7
+ }
@@ -6,6 +6,8 @@ var TEST_IDS = {
6
6
  topbar: "topbar",
7
7
  /** `<select>` of namespaces. */
8
8
  namespace: "namespace",
9
+ /** Narrow screens: shows or hides the rest of the top bar; `aria-expanded`. */
10
+ menu: "topbar-menu",
9
11
  /** Filter `<input>` (recipient, sender, text). */
10
12
  search: "search",
11
13
  /** View tabs; `aria-pressed="true"` on the active one. */
@@ -232,4 +234,4 @@ export {
232
234
  TEST_IDS,
233
235
  selectors
234
236
  };
235
- //# sourceMappingURL=chunk-FBJ2DRHH.js.map
237
+ //# sourceMappingURL=chunk-OR6VYHWA.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../src/testids.ts"],
4
+ "sourcesContent": ["/**\n * Every `data-testid` the harness UI renders, and selector helpers for browser tests.\n *\n * Elements that show one notification also carry its fields as attributes, so a test can narrow by\n * what it knows instead of by position:\n *\n * data-notification-id data-channel data-service data-source data-to data-from\n * data-status data-created-at data-unread (\"true\" | \"false\")\n * data-via (\"whatsapp\", only on WhatsApp messages)\n *\n * The UI root (`TEST_IDS.app`) reports its state the same way: `data-ready` (\"true\" once the first\n * read finished), `data-view`, `data-namespace`, `data-count`, `data-version`, `data-connected`,\n * `data-sound`, `data-motion`, `data-layout` (\"grid\" = devices side by side, \"tabs\" = one device at\n * a time), `data-size` (\"phone\" = a one-row top bar and the open device filling the screen, else\n * \"wide\") and `data-tab` (the selected channel tab: \"all\", \"sms\", \"push\", \"email\" or \"chat\").\n *\n * This module has no dependencies, so Playwright, Cypress or WebdriverIO specs can import it.\n */\nexport const TEST_IDS = {\n /** The UI root. */\n app: \"notifications-app\",\n\n // \u2500\u2500 Top bar \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n topbar: \"topbar\",\n /** `<select>` of namespaces. */\n namespace: \"namespace\",\n /** Narrow screens: shows or hides the rest of the top bar; `aria-expanded`. */\n menu: \"topbar-menu\",\n /** Filter `<input>` (recipient, sender, text). */\n search: \"search\",\n /** View tabs; `aria-pressed=\"true\"` on the active one. */\n viewDevices: \"view-devices\",\n viewTimeline: \"view-timeline\",\n /** \"Follow new\" checkbox. */\n follow: \"follow\",\n /** Sound on/off button; `aria-pressed`. */\n sound: \"sound-toggle\",\n /** Live stream indicator; `data-state=\"live\" | \"reconnecting\"`. */\n connection: \"connection\",\n /** One pill per emulator; `data-name`, `data-service`, `data-ok`, `data-count`. */\n source: \"source\",\n /** Discovery or emulator errors, or the \"no emulators\" hint; `data-kind=\"error\" | \"empty\"`. */\n notice: \"notice\",\n /** Bottom-left message after an action, e.g. \"Conversation archived.\" */\n toast: \"toast\",\n toastUndo: \"toast-undo\",\n\n // \u2500\u2500 Channel tabs \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n /** The `role=\"tablist\"` that switches between devices; `data-layout=\"grid\" | \"tabs\"`. */\n channelTabs: \"channel-tabs\",\n /** One `role=\"tab\"`; `data-value=\"all\" | \"sms\" | \"push\" | \"email\" | \"chat\"`, `aria-selected`, `data-unread` (a count). */\n channelTab: \"channel-tab\",\n /** Unread badge on a tab whose device is not showing its newest arrivals (absent when 0). */\n channelTabUnread: \"channel-tab-unread\",\n\n // \u2500\u2500 SMS: Messages \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n /** The phone; `data-screen=\"threads\" | \"conversation\"`, `data-recipient`, `data-thread`, and `data-via=\"whatsapp\"` while a WhatsApp chat is open. */\n smsDevice: \"sms-device\",\n /** Phone number `<select>`; option values are E.164 numbers. */\n smsRecipient: \"sms-recipient\",\n /** Unread SMS badge next to the column title (absent when 0). */\n smsUnreadCount: \"sms-unread-count\",\n /** One conversation in the list; `data-from` (the sender address), `data-unread`, `data-pinned`, `data-muted`, `data-via`. */\n smsThread: \"sms-thread\",\n smsThreadName: \"sms-thread-name\",\n smsThreadPreview: \"sms-thread-preview\",\n smsThreadTime: \"sms-thread-time\",\n smsThreadUnread: \"sms-thread-unread\",\n /** \"WhatsApp\" label on a WhatsApp conversation in the list. */\n smsThreadVia: \"sms-thread-via\",\n /** Swipe actions behind a thread (also reachable with the keyboard: focus the thread, press Delete). */\n smsThreadDelete: \"sms-thread-delete\",\n smsThreadMute: \"sms-thread-mute\",\n smsThreadPin: \"sms-thread-pin\",\n smsThreadToggleUnread: \"sms-thread-toggle-unread\",\n /** Shown when the phone has no messages. */\n smsEmpty: \"sms-empty\",\n /** An open conversation; `data-from`, `data-via=\"sms\" | \"whatsapp\"`. */\n smsConversation: \"sms-conversation\",\n smsConversationTitle: \"sms-conversation-title\",\n smsBack: \"sms-back\",\n /** One message; carries the notification attributes plus `data-code` when it holds a one-time code. */\n smsBubble: \"sms-bubble\",\n smsBubbleMedia: \"sms-bubble-media\",\n /** The time revealed by swiping the conversation left. */\n smsBubbleTime: \"sms-bubble-time\",\n /** A reaction added with the long-press menu; `data-tapback`. */\n smsTapback: \"sms-tapback\",\n /** Centered date stamp between messages. */\n smsTimestamp: \"sms-timestamp\",\n /** One-time code suggestion above the keyboard; `data-code`. */\n smsCode: \"sms-code\",\n /** Long-press menu on a bubble. */\n smsMenu: \"sms-menu\",\n smsMenuCopy: \"sms-menu-copy\",\n /** One tapback in the menu; `data-tapback=\"heart\" | \"like\" | \"dislike\" | \"laugh\" | \"emphasize\" | \"question\"`. */\n smsMenuTapback: \"sms-menu-tapback\",\n\n // \u2500\u2500 Push: lock screen (iOS) / shade (Android) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n /** The phone; `data-skin=\"ios\" | \"android\"`, `data-recipient`, `data-platform`. */\n pushDevice: \"push-device\",\n /** Device token `<select>`. */\n pushRecipient: \"push-recipient\",\n /** Skin buttons; `data-value`, `aria-pressed`. */\n pushSkin: \"push-skin\",\n pushUnreadCount: \"push-unread-count\",\n /** One notification; notification attributes plus `data-expanded`, `data-platform`, `data-app`, `data-stacked`. */\n pushNotification: \"push-notification\",\n pushNotificationApp: \"push-notification-app\",\n pushNotificationTitle: \"push-notification-title\",\n pushNotificationBody: \"push-notification-body\",\n pushNotificationTime: \"push-notification-time\",\n pushNotificationImage: \"push-notification-image\",\n /** The `data` payload, shown when expanded. */\n pushNotificationData: \"push-notification-data\",\n /** Service, status, badge and sound, shown when expanded. */\n pushNotificationMeta: \"push-notification-meta\",\n /** iOS: a group of notifications from one app; `data-app`, `data-count`, `data-open`. */\n pushGroup: \"push-group\",\n /** iOS: \"N more notifications\" under a collapsed group (click to open it); `data-count`. */\n pushGroupMore: \"push-group-more\",\n /** iOS: \"Show less\" on an open group. */\n pushGroupCollapse: \"push-group-collapse\",\n /** iOS: swipe-left actions. */\n pushClear: \"push-clear\",\n pushOptions: \"push-options\",\n /** iOS long-press preview; Android long-press settings. */\n pushPreview: \"push-preview\",\n pushSettings: \"push-settings\",\n /** Android \"Clear all\". */\n pushClearAll: \"push-clear-all\",\n pushEmpty: \"push-empty\",\n\n // \u2500\u2500 Email: web mail \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n /** The browser window; `data-screen=\"inbox\" | \"message\"`, `data-recipient`. */\n emailDevice: \"email-device\",\n /** Mailbox `<select>`; option values are lower-case addresses. */\n emailRecipient: \"email-recipient\",\n emailUnreadCount: \"email-unread-count\",\n /** One inbox row; notification attributes plus `data-starred`. */\n emailRow: \"email-row\",\n emailRowFrom: \"email-row-from\",\n emailRowSubject: \"email-row-subject\",\n emailRowSnippet: \"email-row-snippet\",\n emailRowDate: \"email-row-date\",\n emailRowService: \"email-row-service\",\n emailRowAttachment: \"email-row-attachment\",\n emailRowStar: \"email-row-star\",\n /** Hover actions on a row. */\n emailRowArchive: \"email-row-archive\",\n emailRowDelete: \"email-row-delete\",\n emailRowToggleRead: \"email-row-toggle-read\",\n emailRefresh: \"email-refresh\",\n emailEmpty: \"email-empty\",\n /** The open message; notification attributes. */\n emailOpen: \"email-open\",\n emailBack: \"email-back\",\n emailArchive: \"email-archive\",\n emailDelete: \"email-delete\",\n emailMarkUnread: \"email-mark-unread\",\n emailSubject: \"email-subject\",\n emailFromName: \"email-from-name\",\n emailFromAddress: \"email-from-address\",\n /** \"to me, \u2026\" line; click to toggle the details. */\n emailTo: \"email-to\",\n emailDate: \"email-date\",\n emailDetails: \"email-details\",\n /** One row of the details; `data-field=\"from\" | \"to\" | \"cc\" | \"bcc\" | \"reply-to\" | \"date\" | \"subject\" | \"mailed-by\" | \"message-id\"`. */\n emailDetail: \"email-detail\",\n /** The HTML body `<iframe>` (same origin: use `frameLocator`). */\n emailBody: \"email-body\",\n /** The plain-text body when there is no HTML. */\n emailText: \"email-text\",\n emailAttachments: \"email-attachments\",\n /** One attachment; `data-filename`, `data-content-type`, `data-size`. */\n emailAttachment: \"email-attachment\",\n\n // \u2500\u2500 Chat: team chat window \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n /** The chat window; `data-recipient` (the open channel), `data-workspace`. */\n chatDevice: \"chat-device\",\n /** Channel `<select>`; option values are channel names (`#alerts`) or webhook paths. */\n chatRecipient: \"chat-recipient\",\n chatUnreadCount: \"chat-unread-count\",\n chatWorkspace: \"chat-workspace\",\n /** One channel in the sidebar; `data-to`, `data-unread` (a count), `aria-current`. */\n chatChannel: \"chat-channel\",\n /** The open channel's name in the header. */\n chatTitle: \"chat-title\",\n /** One message; notification attributes plus `data-method`, `data-ephemeral`, `data-thread`. */\n chatMessage: \"chat-message\",\n chatMessageAuthor: \"chat-message-author\",\n chatMessageTime: \"chat-message-time\",\n /** The message text, with mrkdwn formatting applied. */\n chatMessageText: \"chat-message-text\",\n /** Block Kit blocks; each block inside carries `data-block=\"<type>\"`. */\n chatMessageBlocks: \"chat-message-blocks\",\n /** Legacy attachments; each one inside carries `data-color`. */\n chatMessageAttachments: \"chat-message-attachments\",\n /** One reaction; `data-name`, `data-count`. */\n chatMessageReaction: \"chat-message-reaction\",\n chatEmpty: \"chat-empty\",\n\n // \u2500\u2500 Timeline + inspector \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n timeline: \"timeline\",\n /** One row; notification attributes. Click it to inspect. */\n timelineRow: \"timeline-row\",\n timelineEmpty: \"timeline-empty\",\n /** The JSON inspector; notification attributes. Opened by clicking a timeline row or double-clicking any notification. */\n inspector: \"inspector\",\n inspectorTitle: \"inspector-title\",\n inspectorClose: \"inspector-close\",\n inspectorShowOnDevice: \"inspector-show-on-device\",\n /** One normalized field; `data-field`. */\n inspectorField: \"inspector-field\",\n /** The full record, normalized fields plus `raw`, as JSON text. */\n inspectorJson: \"inspector-json\",\n\n // \u2500\u2500 Dashboard (mountDashboard) \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n /** The dashboard root; `data-tab` is the open tab's id. */\n dashboard: \"dashboard\",\n /** One tab button; `data-tab` (`emulators`, `notifications`, or an embedder's id), `aria-selected`. */\n dashboardTab: \"dashboard-tab\",\n /** One tab's panel; `data-tab`. Hidden unless its tab is open. */\n dashboardPanel: \"dashboard-panel\",\n /** Notifications that arrived while another tab was open; `data-count`. Hidden at 0. */\n dashboardBadge: \"dashboard-badge\",\n} as const\n\nexport type TestId = (typeof TEST_IDS)[keyof typeof TEST_IDS]\n\nconst attr = (value: string) => JSON.stringify(value)\n\n/** CSS selectors for the harness UI. Each one works with `page.locator()` or `querySelector`. */\nexport const selectors = {\n /** `[data-testid=\"\u2026\"]` */\n testId: (id: TestId) => `[data-testid=${attr(id)}]`,\n /** The ready UI root: wait for this before asserting. */\n ready: () => `[data-testid=${attr(TEST_IDS.app)}][data-ready=\"true\"]`,\n /** Any element showing this notification (bubble, thread, card, row, open email, timeline row). */\n notification: (id: string) => `[data-notification-id=${attr(id)}]`,\n /** A message bubble, optionally from one sender. */\n smsBubble: (filter: { from?: string; id?: string } = {}) =>\n `[data-testid=${attr(TEST_IDS.smsBubble)}]${filter.from ? `[data-from=${attr(filter.from)}]` : \"\"}${filter.id ? `[data-notification-id=${attr(filter.id)}]` : \"\"}`,\n /** A conversation in the Messages list. */\n smsThread: (from: string) => `[data-testid=${attr(TEST_IDS.smsThread)}][data-from=${attr(from)}]`,\n /** A channel tab: `\"all\"`, `\"sms\"`, `\"push\"`, `\"email\"` or `\"chat\"`. */\n channelTab: (value: \"all\" | \"sms\" | \"push\" | \"email\" | \"chat\") =>\n `[data-testid=${attr(TEST_IDS.channelTab)}][data-value=${attr(value)}]`,\n /** A chat message, optionally by id. */\n chatMessage: (id?: string) =>\n `[data-testid=${attr(TEST_IDS.chatMessage)}]${id ? `[data-notification-id=${attr(id)}]` : \"\"}`,\n /** A channel in the chat sidebar. */\n chatChannel: (to: string) => `[data-testid=${attr(TEST_IDS.chatChannel)}][data-to=${attr(to)}]`,\n /** A push notification card, optionally by id. */\n pushNotification: (id?: string) =>\n `[data-testid=${attr(TEST_IDS.pushNotification)}]${id ? `[data-notification-id=${attr(id)}]` : \"\"}`,\n /** An inbox row, optionally by id. */\n emailRow: (id?: string) =>\n `[data-testid=${attr(TEST_IDS.emailRow)}]${id ? `[data-notification-id=${attr(id)}]` : \"\"}`,\n /** A timeline row, optionally by id. */\n timelineRow: (id?: string) =>\n `[data-testid=${attr(TEST_IDS.timelineRow)}]${id ? `[data-notification-id=${attr(id)}]` : \"\"}`,\n /** A dashboard tab button by tab id (`emulators`, `notifications`, \u2026). */\n dashboardTab: (id: string) =>\n `[data-testid=${attr(TEST_IDS.dashboardTab)}][data-tab=${attr(id)}]`,\n /** A dashboard tab's panel by tab id. */\n dashboardPanel: (id: string) =>\n `[data-testid=${attr(TEST_IDS.dashboardPanel)}][data-tab=${attr(id)}]`,\n}\n"],
5
+ "mappings": ";AAkBO,IAAM,WAAW;AAAA;AAAA,EAEtB,KAAK;AAAA;AAAA,EAGL,QAAQ;AAAA;AAAA,EAER,WAAW;AAAA;AAAA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