@crvouga/mockingbird-notifications 0.1.0 → 0.2.1
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/README.md +96 -17
- package/dist/{chunk-QE3TRUI6.js → chunk-3HF2NSFV.js} +280 -10
- package/dist/chunk-3HF2NSFV.js.map +7 -0
- package/dist/{chunk-LM7R7AR7.js → chunk-FBJ2DRHH.js} +58 -6
- package/dist/chunk-FBJ2DRHH.js.map +7 -0
- package/dist/chunk-GHIEYY5B.js +1177 -0
- package/dist/chunk-GHIEYY5B.js.map +7 -0
- package/dist/chunk-SNOESDNW.js +400 -0
- package/dist/chunk-SNOESDNW.js.map +7 -0
- package/dist/cli.js +12 -4
- package/dist/cli.js.map +2 -2
- package/dist/index.d.ts +6 -361
- package/dist/index.js +9 -6
- package/dist/index.js.map +2 -2
- package/dist/server.d.ts +19 -153
- package/dist/server.js +7 -3
- package/dist/types-C4yF6DQp.d.ts +244 -0
- package/dist/types-CU0LKNyA.d.ts +238 -0
- package/dist/ui.d.ts +96 -316
- package/dist/ui.js +808 -133
- package/dist/ui.js.map +4 -4
- package/package.json +14 -10
- package/dist/chunk-GRGR3QZM.js +0 -1066
- package/dist/chunk-GRGR3QZM.js.map +0 -7
- package/dist/chunk-JQ6KPT2C.js +0 -202
- package/dist/chunk-JQ6KPT2C.js.map +0 -7
- package/dist/chunk-LM7R7AR7.js.map +0 -7
- package/dist/chunk-QE3TRUI6.js.map +0 -7
package/dist/ui.d.ts
CHANGED
|
@@ -1,108 +1,19 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
/** Emulators the harness knows how to read. */
|
|
4
|
-
type ServiceKind = "twilio" | "resend" | "fcm" | "ses" | "sns" | "customerio" | "mailosaur";
|
|
5
|
-
type Address = {
|
|
6
|
-
name: string | null;
|
|
7
|
-
address: string;
|
|
8
|
-
};
|
|
9
|
-
type SmsContent = {
|
|
10
|
-
body: string;
|
|
11
|
-
/** One-time code the sender included (Twilio Verify), when known. */
|
|
12
|
-
code: string | null;
|
|
13
|
-
media: string[];
|
|
14
|
-
};
|
|
15
|
-
type EmailAttachment = {
|
|
16
|
-
filename: string;
|
|
17
|
-
contentType: string | null;
|
|
18
|
-
size: number | null;
|
|
19
|
-
};
|
|
20
|
-
type EmailContent = {
|
|
21
|
-
subject: string;
|
|
22
|
-
html: string | null;
|
|
23
|
-
text: string | null;
|
|
24
|
-
cc: string[];
|
|
25
|
-
bcc: string[];
|
|
26
|
-
replyTo: string[];
|
|
27
|
-
attachments: EmailAttachment[];
|
|
28
|
-
headers: Record<string, string>;
|
|
29
|
-
};
|
|
30
|
-
type PushPlatform = "android" | "ios" | "web" | "unknown";
|
|
31
|
-
type PushContent = {
|
|
32
|
-
title: string | null;
|
|
33
|
-
body: string | null;
|
|
34
|
-
imageUrl: string | null;
|
|
35
|
-
/** The app the notification belongs to (the FCM project, for example). */
|
|
36
|
-
app: string;
|
|
37
|
-
platform: PushPlatform;
|
|
38
|
-
data: Record<string, string>;
|
|
39
|
-
badge: number | null;
|
|
40
|
-
sound: string | null;
|
|
41
|
-
};
|
|
42
|
-
/** One message as a recipient would receive it, normalized across emulators. */
|
|
43
|
-
type Notification = {
|
|
44
|
-
/** Stable across polls: `<service entry>:<namespace>:<provider id>`. */
|
|
45
|
-
id: string;
|
|
46
|
-
/** The provider's own id (Twilio SID, Resend id, FCM message name, …). */
|
|
47
|
-
providerId: string;
|
|
48
|
-
channel: Channel;
|
|
49
|
-
/** The fleet entry name (`twilio`, or an alias such as `push`). */
|
|
50
|
-
source: string;
|
|
51
|
-
service: ServiceKind;
|
|
52
|
-
namespace: string;
|
|
53
|
-
/** Phone number, email address, or push registration token. */
|
|
54
|
-
to: string;
|
|
55
|
-
from: Address;
|
|
56
|
-
/** ISO-8601, on the emulator's clock. */
|
|
57
|
-
createdAt: string;
|
|
58
|
-
/** Short plain-text preview. */
|
|
59
|
-
preview: string;
|
|
60
|
-
/** Provider delivery state when it reports one (`queued`, `delivered`, `suppressed`, …). */
|
|
61
|
-
status: string | null;
|
|
62
|
-
sms: SmsContent | null;
|
|
63
|
-
email: EmailContent | null;
|
|
64
|
-
push: PushContent | null;
|
|
65
|
-
/** The record exactly as the emulator reported it. */
|
|
66
|
-
raw: unknown;
|
|
67
|
-
};
|
|
68
|
-
type NotificationFilter = {
|
|
69
|
-
channel?: Channel | undefined;
|
|
70
|
-
service?: ServiceKind | undefined;
|
|
71
|
-
source?: string | undefined;
|
|
72
|
-
namespace?: string | undefined;
|
|
73
|
-
/** Exact recipient (case-insensitive for email). */
|
|
74
|
-
to?: string | undefined;
|
|
75
|
-
/** Case-insensitive text search across sender, subject, title and body. */
|
|
76
|
-
contains?: string | undefined;
|
|
77
|
-
/** Only notifications created at or after this instant (ISO-8601 or epoch ms). */
|
|
78
|
-
since?: string | number | undefined;
|
|
79
|
-
};
|
|
80
|
-
type SourceStatus = {
|
|
81
|
-
name: string;
|
|
82
|
-
service: ServiceKind | null;
|
|
83
|
-
url: string;
|
|
84
|
-
ok: boolean;
|
|
85
|
-
error: string | null;
|
|
86
|
-
count: number;
|
|
87
|
-
lastSyncAt: string | null;
|
|
88
|
-
};
|
|
1
|
+
export { T as TEST_IDS, a as TestId, s as selectors } from './types-C4yF6DQp.js';
|
|
2
|
+
import { Notification, Channel, SourceStatus, NotificationHarness } from './index.js';
|
|
89
3
|
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
sources(): SourceStatus[];
|
|
104
|
-
close(): void;
|
|
105
|
-
};
|
|
4
|
+
/** The class on the UI root. Every rule below is scoped to it. */
|
|
5
|
+
declare const ROOT_CLASS = "mb-notifications";
|
|
6
|
+
/** The stylesheet, every rule scoped to `.mb-notifications`. */
|
|
7
|
+
declare const STYLES: string;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The channel tab bar's rules, kept free of the DOM so they are unit-tested directly.
|
|
11
|
+
*
|
|
12
|
+
* Wide, the bar is `All | Text | Push | Email | Chat` and "All" lays every device side by side.
|
|
13
|
+
* Narrow (or with `layout: "tabs"`), there is no "All": exactly one device shows at a time.
|
|
14
|
+
*/
|
|
15
|
+
|
|
16
|
+
type DeviceLayout = "auto" | "tabs" | "grid";
|
|
106
17
|
|
|
107
18
|
/**
|
|
108
19
|
* The harness UI. Plain DOM: each device re-renders from `state` when the harness reports a change.
|
|
@@ -137,10 +48,23 @@ type AppOptions = {
|
|
|
137
48
|
motion?: MotionPreference;
|
|
138
49
|
/** Fill the host element and scroll inside it, for a tab or panel in another app. */
|
|
139
50
|
embedded?: boolean;
|
|
140
|
-
/** Which devices to show. Default all
|
|
51
|
+
/** Which devices to show. Default all of them: `sms`, `push`, `email` and `chat`. */
|
|
141
52
|
channels?: Channel[];
|
|
53
|
+
/**
|
|
54
|
+
* How the devices share the space. `auto` (default) lays them side by side and switches to one
|
|
55
|
+
* device at a time, picked with the channel tabs, when the host element is narrower than 800px.
|
|
56
|
+
* `tabs` always shows one device; `grid` never collapses.
|
|
57
|
+
*/
|
|
58
|
+
layout?: DeviceLayout;
|
|
59
|
+
/** Show the channel tabs (`All | Text | Push | Email | Chat`). Default true; with `false`, `auto` never collapses. */
|
|
60
|
+
tabs?: boolean;
|
|
142
61
|
/** Show the top bar (namespace, filter, view tabs, sound, emulator status). Default true. */
|
|
143
62
|
chrome?: boolean;
|
|
63
|
+
/**
|
|
64
|
+
* Draw the devices at this fraction of their full size (a phone is 362 by 760px), from 0.5 to 1,
|
|
65
|
+
* for a host with less room than the full-size devices need. Default 1.
|
|
66
|
+
*/
|
|
67
|
+
scale?: number;
|
|
144
68
|
/** Called with each batch of new notifications. */
|
|
145
69
|
onArrive?: (added: Notification[]) => void;
|
|
146
70
|
/** Fixed notifications to draw when not live. */
|
|
@@ -184,6 +108,9 @@ type AppOptions = {
|
|
|
184
108
|
to?: string | null;
|
|
185
109
|
open?: string | null;
|
|
186
110
|
};
|
|
111
|
+
chat?: {
|
|
112
|
+
to?: string | null;
|
|
113
|
+
};
|
|
187
114
|
toast?: string | null;
|
|
188
115
|
local?: {
|
|
189
116
|
dismissed?: string[];
|
|
@@ -210,6 +137,8 @@ type AppHandle = {
|
|
|
210
137
|
}): void;
|
|
211
138
|
setNamespace(namespace: string): void;
|
|
212
139
|
setSound(on: boolean): void;
|
|
140
|
+
/** Change the `scale` the devices are drawn at. */
|
|
141
|
+
setScale(scale: number): void;
|
|
213
142
|
/** Stop streams and timers, remove listeners and empty the host. */
|
|
214
143
|
destroy(): void;
|
|
215
144
|
};
|
|
@@ -218,215 +147,6 @@ type PushSkin = "auto" | "ios" | "android";
|
|
|
218
147
|
type Tapback = "heart" | "like" | "dislike" | "laugh" | "emphasize" | "question";
|
|
219
148
|
declare function createApp(root: HTMLElement, options?: AppOptions): AppHandle;
|
|
220
149
|
|
|
221
|
-
/** The class on the UI root. Every rule below is scoped to it. */
|
|
222
|
-
declare const ROOT_CLASS = "mb-notifications";
|
|
223
|
-
/** The stylesheet, every rule scoped to `.mb-notifications`. */
|
|
224
|
-
declare const STYLES: string;
|
|
225
|
-
|
|
226
|
-
/**
|
|
227
|
-
* Every `data-testid` the harness UI renders, and selector helpers for browser tests.
|
|
228
|
-
*
|
|
229
|
-
* Elements that show one notification also carry its fields as attributes, so a test can narrow by
|
|
230
|
-
* what it knows instead of by position:
|
|
231
|
-
*
|
|
232
|
-
* data-notification-id data-channel data-service data-source data-to data-from
|
|
233
|
-
* data-status data-created-at data-unread ("true" | "false")
|
|
234
|
-
*
|
|
235
|
-
* The UI root (`TEST_IDS.app`) reports its state the same way: `data-ready` ("true" once the first
|
|
236
|
-
* read finished), `data-view`, `data-namespace`, `data-count`, `data-version`, `data-connected`,
|
|
237
|
-
* `data-sound` and `data-motion`.
|
|
238
|
-
*
|
|
239
|
-
* This module has no dependencies, so Playwright, Cypress or WebdriverIO specs can import it.
|
|
240
|
-
*/
|
|
241
|
-
declare const TEST_IDS: {
|
|
242
|
-
/** The UI root. */
|
|
243
|
-
readonly app: "notifications-app";
|
|
244
|
-
readonly topbar: "topbar";
|
|
245
|
-
/** `<select>` of namespaces. */
|
|
246
|
-
readonly namespace: "namespace";
|
|
247
|
-
/** Filter `<input>` (recipient, sender, text). */
|
|
248
|
-
readonly search: "search";
|
|
249
|
-
/** View tabs; `aria-pressed="true"` on the active one. */
|
|
250
|
-
readonly viewDevices: "view-devices";
|
|
251
|
-
readonly viewTimeline: "view-timeline";
|
|
252
|
-
/** "Follow new" checkbox. */
|
|
253
|
-
readonly follow: "follow";
|
|
254
|
-
/** Sound on/off button; `aria-pressed`. */
|
|
255
|
-
readonly sound: "sound-toggle";
|
|
256
|
-
/** Live stream indicator; `data-state="live" | "reconnecting"`. */
|
|
257
|
-
readonly connection: "connection";
|
|
258
|
-
/** One pill per emulator; `data-name`, `data-service`, `data-ok`, `data-count`. */
|
|
259
|
-
readonly source: "source";
|
|
260
|
-
/** Discovery or emulator errors, or the "no emulators" hint; `data-kind="error" | "empty"`. */
|
|
261
|
-
readonly notice: "notice";
|
|
262
|
-
/** Bottom-left message after an action, e.g. "Conversation archived." */
|
|
263
|
-
readonly toast: "toast";
|
|
264
|
-
readonly toastUndo: "toast-undo";
|
|
265
|
-
/** The phone; `data-screen="threads" | "conversation"`, `data-recipient`, `data-thread`. */
|
|
266
|
-
readonly smsDevice: "sms-device";
|
|
267
|
-
/** Phone number `<select>`; option values are E.164 numbers. */
|
|
268
|
-
readonly smsRecipient: "sms-recipient";
|
|
269
|
-
/** Unread SMS badge next to the column title (absent when 0). */
|
|
270
|
-
readonly smsUnreadCount: "sms-unread-count";
|
|
271
|
-
/** One conversation in the list; `data-from` (the sender address), `data-unread`, `data-pinned`, `data-muted`. */
|
|
272
|
-
readonly smsThread: "sms-thread";
|
|
273
|
-
readonly smsThreadName: "sms-thread-name";
|
|
274
|
-
readonly smsThreadPreview: "sms-thread-preview";
|
|
275
|
-
readonly smsThreadTime: "sms-thread-time";
|
|
276
|
-
readonly smsThreadUnread: "sms-thread-unread";
|
|
277
|
-
/** Swipe actions behind a thread (also reachable with the keyboard: focus the thread, press Delete). */
|
|
278
|
-
readonly smsThreadDelete: "sms-thread-delete";
|
|
279
|
-
readonly smsThreadMute: "sms-thread-mute";
|
|
280
|
-
readonly smsThreadPin: "sms-thread-pin";
|
|
281
|
-
readonly smsThreadToggleUnread: "sms-thread-toggle-unread";
|
|
282
|
-
/** Shown when the phone has no messages. */
|
|
283
|
-
readonly smsEmpty: "sms-empty";
|
|
284
|
-
/** An open conversation; `data-from`. */
|
|
285
|
-
readonly smsConversation: "sms-conversation";
|
|
286
|
-
readonly smsConversationTitle: "sms-conversation-title";
|
|
287
|
-
readonly smsBack: "sms-back";
|
|
288
|
-
/** One message; carries the notification attributes plus `data-code` when it holds a one-time code. */
|
|
289
|
-
readonly smsBubble: "sms-bubble";
|
|
290
|
-
readonly smsBubbleMedia: "sms-bubble-media";
|
|
291
|
-
/** The time revealed by swiping the conversation left. */
|
|
292
|
-
readonly smsBubbleTime: "sms-bubble-time";
|
|
293
|
-
/** A reaction added with the long-press menu; `data-tapback`. */
|
|
294
|
-
readonly smsTapback: "sms-tapback";
|
|
295
|
-
/** Centered date stamp between messages. */
|
|
296
|
-
readonly smsTimestamp: "sms-timestamp";
|
|
297
|
-
/** One-time code suggestion above the keyboard; `data-code`. */
|
|
298
|
-
readonly smsCode: "sms-code";
|
|
299
|
-
/** Long-press menu on a bubble. */
|
|
300
|
-
readonly smsMenu: "sms-menu";
|
|
301
|
-
readonly smsMenuCopy: "sms-menu-copy";
|
|
302
|
-
/** One tapback in the menu; `data-tapback="heart" | "like" | "dislike" | "laugh" | "emphasize" | "question"`. */
|
|
303
|
-
readonly smsMenuTapback: "sms-menu-tapback";
|
|
304
|
-
/** The phone; `data-skin="ios" | "android"`, `data-recipient`, `data-platform`. */
|
|
305
|
-
readonly pushDevice: "push-device";
|
|
306
|
-
/** Device token `<select>`. */
|
|
307
|
-
readonly pushRecipient: "push-recipient";
|
|
308
|
-
/** Skin buttons; `data-value`, `aria-pressed`. */
|
|
309
|
-
readonly pushSkin: "push-skin";
|
|
310
|
-
readonly pushUnreadCount: "push-unread-count";
|
|
311
|
-
/** One notification; notification attributes plus `data-expanded`, `data-platform`, `data-app`, `data-stacked`. */
|
|
312
|
-
readonly pushNotification: "push-notification";
|
|
313
|
-
readonly pushNotificationApp: "push-notification-app";
|
|
314
|
-
readonly pushNotificationTitle: "push-notification-title";
|
|
315
|
-
readonly pushNotificationBody: "push-notification-body";
|
|
316
|
-
readonly pushNotificationTime: "push-notification-time";
|
|
317
|
-
readonly pushNotificationImage: "push-notification-image";
|
|
318
|
-
/** The `data` payload, shown when expanded. */
|
|
319
|
-
readonly pushNotificationData: "push-notification-data";
|
|
320
|
-
/** Service, status, badge and sound, shown when expanded. */
|
|
321
|
-
readonly pushNotificationMeta: "push-notification-meta";
|
|
322
|
-
/** iOS: a group of notifications from one app; `data-app`, `data-count`, `data-open`. */
|
|
323
|
-
readonly pushGroup: "push-group";
|
|
324
|
-
/** iOS: "N more notifications" under a collapsed group (click to open it); `data-count`. */
|
|
325
|
-
readonly pushGroupMore: "push-group-more";
|
|
326
|
-
/** iOS: "Show less" on an open group. */
|
|
327
|
-
readonly pushGroupCollapse: "push-group-collapse";
|
|
328
|
-
/** iOS: swipe-left actions. */
|
|
329
|
-
readonly pushClear: "push-clear";
|
|
330
|
-
readonly pushOptions: "push-options";
|
|
331
|
-
/** iOS long-press preview; Android long-press settings. */
|
|
332
|
-
readonly pushPreview: "push-preview";
|
|
333
|
-
readonly pushSettings: "push-settings";
|
|
334
|
-
/** Android "Clear all". */
|
|
335
|
-
readonly pushClearAll: "push-clear-all";
|
|
336
|
-
readonly pushEmpty: "push-empty";
|
|
337
|
-
/** The browser window; `data-screen="inbox" | "message"`, `data-recipient`. */
|
|
338
|
-
readonly emailDevice: "email-device";
|
|
339
|
-
/** Mailbox `<select>`; option values are lower-case addresses. */
|
|
340
|
-
readonly emailRecipient: "email-recipient";
|
|
341
|
-
readonly emailUnreadCount: "email-unread-count";
|
|
342
|
-
/** One inbox row; notification attributes plus `data-starred`. */
|
|
343
|
-
readonly emailRow: "email-row";
|
|
344
|
-
readonly emailRowFrom: "email-row-from";
|
|
345
|
-
readonly emailRowSubject: "email-row-subject";
|
|
346
|
-
readonly emailRowSnippet: "email-row-snippet";
|
|
347
|
-
readonly emailRowDate: "email-row-date";
|
|
348
|
-
readonly emailRowService: "email-row-service";
|
|
349
|
-
readonly emailRowAttachment: "email-row-attachment";
|
|
350
|
-
readonly emailRowStar: "email-row-star";
|
|
351
|
-
/** Hover actions on a row. */
|
|
352
|
-
readonly emailRowArchive: "email-row-archive";
|
|
353
|
-
readonly emailRowDelete: "email-row-delete";
|
|
354
|
-
readonly emailRowToggleRead: "email-row-toggle-read";
|
|
355
|
-
readonly emailRefresh: "email-refresh";
|
|
356
|
-
readonly emailEmpty: "email-empty";
|
|
357
|
-
/** The open message; notification attributes. */
|
|
358
|
-
readonly emailOpen: "email-open";
|
|
359
|
-
readonly emailBack: "email-back";
|
|
360
|
-
readonly emailArchive: "email-archive";
|
|
361
|
-
readonly emailDelete: "email-delete";
|
|
362
|
-
readonly emailMarkUnread: "email-mark-unread";
|
|
363
|
-
readonly emailSubject: "email-subject";
|
|
364
|
-
readonly emailFromName: "email-from-name";
|
|
365
|
-
readonly emailFromAddress: "email-from-address";
|
|
366
|
-
/** "to me, …" line; click to toggle the details. */
|
|
367
|
-
readonly emailTo: "email-to";
|
|
368
|
-
readonly emailDate: "email-date";
|
|
369
|
-
readonly emailDetails: "email-details";
|
|
370
|
-
/** One row of the details; `data-field="from" | "to" | "cc" | "bcc" | "reply-to" | "date" | "subject" | "mailed-by" | "message-id"`. */
|
|
371
|
-
readonly emailDetail: "email-detail";
|
|
372
|
-
/** The HTML body `<iframe>` (same origin: use `frameLocator`). */
|
|
373
|
-
readonly emailBody: "email-body";
|
|
374
|
-
/** The plain-text body when there is no HTML. */
|
|
375
|
-
readonly emailText: "email-text";
|
|
376
|
-
readonly emailAttachments: "email-attachments";
|
|
377
|
-
/** One attachment; `data-filename`, `data-content-type`, `data-size`. */
|
|
378
|
-
readonly emailAttachment: "email-attachment";
|
|
379
|
-
readonly timeline: "timeline";
|
|
380
|
-
/** One row; notification attributes. Click it to inspect. */
|
|
381
|
-
readonly timelineRow: "timeline-row";
|
|
382
|
-
readonly timelineEmpty: "timeline-empty";
|
|
383
|
-
/** The JSON inspector; notification attributes. Opened by clicking a timeline row or double-clicking any notification. */
|
|
384
|
-
readonly inspector: "inspector";
|
|
385
|
-
readonly inspectorTitle: "inspector-title";
|
|
386
|
-
readonly inspectorClose: "inspector-close";
|
|
387
|
-
readonly inspectorShowOnDevice: "inspector-show-on-device";
|
|
388
|
-
/** One normalized field; `data-field`. */
|
|
389
|
-
readonly inspectorField: "inspector-field";
|
|
390
|
-
/** The full record, normalized fields plus `raw`, as JSON text. */
|
|
391
|
-
readonly inspectorJson: "inspector-json";
|
|
392
|
-
};
|
|
393
|
-
type TestId = (typeof TEST_IDS)[keyof typeof TEST_IDS];
|
|
394
|
-
/** CSS selectors for the harness UI. Each one works with `page.locator()` or `querySelector`. */
|
|
395
|
-
declare const selectors: {
|
|
396
|
-
/** `[data-testid="…"]` */
|
|
397
|
-
testId: (id: TestId) => string;
|
|
398
|
-
/** The ready UI root: wait for this before asserting. */
|
|
399
|
-
ready: () => string;
|
|
400
|
-
/** Any element showing this notification (bubble, thread, card, row, open email, timeline row). */
|
|
401
|
-
notification: (id: string) => string;
|
|
402
|
-
/** A message bubble, optionally from one sender. */
|
|
403
|
-
smsBubble: (filter?: {
|
|
404
|
-
from?: string;
|
|
405
|
-
id?: string;
|
|
406
|
-
}) => string;
|
|
407
|
-
/** A conversation in the Messages list. */
|
|
408
|
-
smsThread: (from: string) => string;
|
|
409
|
-
/** A push notification card, optionally by id. */
|
|
410
|
-
pushNotification: (id?: string) => string;
|
|
411
|
-
/** An inbox row, optionally by id. */
|
|
412
|
-
emailRow: (id?: string) => string;
|
|
413
|
-
/** A timeline row, optionally by id. */
|
|
414
|
-
timelineRow: (id?: string) => string;
|
|
415
|
-
};
|
|
416
|
-
|
|
417
|
-
/**
|
|
418
|
-
* The harness UI as a component, for an app that wants its notifications on a tab or panel of its
|
|
419
|
-
* own page: in the browser, against an in-process harness, with no server and no network.
|
|
420
|
-
*
|
|
421
|
-
* const harness = createNotificationHarness({ services: { twilio, resend, fcm } })
|
|
422
|
-
* const ui = mountNotifications(panel, { harness })
|
|
423
|
-
* await ui.ready
|
|
424
|
-
* ui.destroy()
|
|
425
|
-
*
|
|
426
|
-
* Every rule of the stylesheet is scoped to the UI root (`.mb-notifications`), so it can sit next
|
|
427
|
-
* to the host app's own styles.
|
|
428
|
-
*/
|
|
429
|
-
|
|
430
150
|
type MountOptions = Omit<AppOptions, "fetch"> & {
|
|
431
151
|
/** An in-process harness (anything with a Fetch handler). Omit it to read `baseUrl` over HTTP. */
|
|
432
152
|
harness?: Pick<NotificationHarness, "fetch">;
|
|
@@ -441,5 +161,65 @@ type MountOptions = Omit<AppOptions, "fetch"> & {
|
|
|
441
161
|
*/
|
|
442
162
|
declare const mountNotifications: (host: HTMLElement, options?: MountOptions) => AppHandle;
|
|
443
163
|
|
|
444
|
-
|
|
445
|
-
|
|
164
|
+
/** Returns nothing, a dispose function, or a promise of either. */
|
|
165
|
+
type Mount = (panel: HTMLElement) => unknown;
|
|
166
|
+
type DashboardTab = {
|
|
167
|
+
/** Unique; also the `?tab=` value. `emulators` and `notifications` are taken. */
|
|
168
|
+
id: string;
|
|
169
|
+
label: string;
|
|
170
|
+
/** Draw the tab into `panel`, the first time it is shown. May return a dispose function. */
|
|
171
|
+
mount: Mount;
|
|
172
|
+
};
|
|
173
|
+
type DashboardOptions = {
|
|
174
|
+
/** Shown at the start of the tab bar. Omit it for a bar of tabs only. */
|
|
175
|
+
title?: string;
|
|
176
|
+
/** The embedder's own tabs, shown first. */
|
|
177
|
+
tabs?: DashboardTab[];
|
|
178
|
+
/** The emulator admin dashboard. `mount` may be async (for example, to load a script first). */
|
|
179
|
+
emulators?: {
|
|
180
|
+
label?: string;
|
|
181
|
+
mount: Mount;
|
|
182
|
+
};
|
|
183
|
+
/** The notifications UI: what `mountNotifications` takes, plus a tab label. */
|
|
184
|
+
notifications?: MountOptions & {
|
|
185
|
+
label?: string;
|
|
186
|
+
};
|
|
187
|
+
/** The tab to open. `?tab=` wins over it when `syncUrl` is set. Default: the first tab. */
|
|
188
|
+
initialTab?: string;
|
|
189
|
+
/** Read `?tab=` from the page URL and keep it current. Default false. */
|
|
190
|
+
syncUrl?: boolean;
|
|
191
|
+
onTabChange?: (id: string) => void;
|
|
192
|
+
/** Tab bar colors. `auto` follows the viewer's color scheme. Default `dark`, like the notifications UI. */
|
|
193
|
+
theme?: "dark" | "light" | "auto";
|
|
194
|
+
/** Add the stylesheets to the host's document or shadow root. Default true. */
|
|
195
|
+
injectStyles?: boolean;
|
|
196
|
+
};
|
|
197
|
+
type DashboardHandle = {
|
|
198
|
+
/** Open a tab by id. Unknown ids are ignored. */
|
|
199
|
+
show(id: string): void;
|
|
200
|
+
/** The id of the open tab. */
|
|
201
|
+
active(): string;
|
|
202
|
+
/** Tab ids, in bar order. */
|
|
203
|
+
tabs(): string[];
|
|
204
|
+
/** An empty element at the end of the tab bar, for a status or a link. */
|
|
205
|
+
aside: HTMLElement;
|
|
206
|
+
/** The notifications UI, when the dashboard has one. */
|
|
207
|
+
notifications?: AppHandle;
|
|
208
|
+
/** Dispose every mounted tab, remove listeners and empty the host. */
|
|
209
|
+
destroy(): void;
|
|
210
|
+
};
|
|
211
|
+
/**
|
|
212
|
+
* Mount the dashboard inside `host`, which it fills: give the host a height. Tabs are, in order,
|
|
213
|
+
* the embedder's `tabs`, Emulators, Notifications. A tab is drawn the first time it is shown and
|
|
214
|
+
* stays mounted afterwards, so switching away keeps its state. The Notifications tab counts what
|
|
215
|
+
* arrives while another tab is open.
|
|
216
|
+
*/
|
|
217
|
+
declare const mountDashboard: (host: HTMLElement, options: DashboardOptions) => DashboardHandle;
|
|
218
|
+
|
|
219
|
+
/** The class on the dashboard root. Every rule below is scoped to it. */
|
|
220
|
+
declare const DASHBOARD_ROOT_CLASS = "mb-dashboard";
|
|
221
|
+
/** The dashboard shell's stylesheet: the tab bar and its panels, nothing inside them. */
|
|
222
|
+
declare const DASHBOARD_STYLES: string;
|
|
223
|
+
|
|
224
|
+
export { DASHBOARD_ROOT_CLASS, DASHBOARD_STYLES, ROOT_CLASS, STYLES, createApp, mountDashboard, mountNotifications };
|
|
225
|
+
export type { AppHandle, AppOptions, DashboardHandle, DashboardOptions, DashboardTab, MotionPreference, MountOptions, PushSkin, View };
|