@crvouga/mockingbird-notifications 0.12.0 → 0.14.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.
- package/README.md +25 -14
- package/dist/admin-gateway.d.ts +19 -0
- package/dist/admin-gateway.js +10 -0
- package/dist/browser.bundle-MOA3BSWW.js +6 -0
- package/dist/browser.bundle-MOA3BSWW.js.map +7 -0
- package/dist/chunk-5MRZJQ6J.js +1254 -0
- package/dist/chunk-5MRZJQ6J.js.map +7 -0
- package/dist/chunk-NMW2EZL2.js +200 -0
- package/dist/chunk-NMW2EZL2.js.map +7 -0
- package/dist/chunk-T6QHUV5K.js +206 -0
- package/dist/chunk-T6QHUV5K.js.map +7 -0
- package/dist/chunk-ZIE3JCV6.js +26 -0
- package/dist/chunk-ZIE3JCV6.js.map +7 -0
- package/dist/cli.js +4 -4
- package/dist/client.bundle-YOZJSCGX.js +6 -0
- package/dist/client.bundle-YOZJSCGX.js.map +7 -0
- package/dist/{document-OSYEGZSQ.js → document-JPNN2BT5.js} +2 -2
- package/dist/document-JPNN2BT5.js.map +7 -0
- package/dist/index.js +4 -6
- package/dist/index.js.map +1 -1
- package/dist/{chunk-QQK27AFM.js → page-J3NUKUUA.js} +34 -306
- package/dist/page-J3NUKUUA.js.map +7 -0
- package/dist/server-Q5XLVMT2.js +17378 -0
- package/dist/server-Q5XLVMT2.js.map +7 -0
- package/dist/server.d.ts +4 -18
- package/dist/server.js +7 -6
- package/dist/ui.d.ts +36 -46
- package/dist/ui.js +21530 -2526
- package/dist/ui.js.map +4 -4
- package/package.json +40 -13
- package/dist/chunk-5DUELOZW.js +0 -1202
- package/dist/chunk-5DUELOZW.js.map +0 -7
- package/dist/chunk-5KZ24SHQ.js +0 -26
- package/dist/chunk-5KZ24SHQ.js.map +0 -7
- package/dist/chunk-JECNH6UB.js +0 -393
- package/dist/chunk-JECNH6UB.js.map +0 -7
- package/dist/chunk-QQK27AFM.js.map +0 -7
- /package/dist/{document-OSYEGZSQ.js.map → admin-gateway.js.map} +0 -0
package/README.md
CHANGED
|
@@ -91,12 +91,15 @@ the tab); a harness you serve yourself takes `admin: adminGateway()` from `./ser
|
|
|
91
91
|
|
|
92
92
|
## The UI
|
|
93
93
|
|
|
94
|
-
`/` shows four devices side by side
|
|
94
|
+
`/` shows four devices side by side, in the same Mockingbird UI as the admin and Fleet Cloud
|
|
95
|
+
(React and HeroUI, light or dark): a header with the **Live** status and the **Devices** and
|
|
96
|
+
**Timeline** switch, then the filter, the **Namespace** select, **Follow new**, **Sound** and a
|
|
97
|
+
status chip per emulator. Each device has a recipient picker (phone number, push token,
|
|
95
98
|
mailbox, chat channel) that follows the newest arrival unless **Follow new** is off. The **Timeline** tab lists
|
|
96
99
|
everything in one table; double-click any message, or click a timeline row, to inspect the
|
|
97
100
|
normalized record and the emulator's raw one. Read state is kept per browser.
|
|
98
101
|
|
|
99
|
-
The **channel tabs** under the
|
|
102
|
+
The **channel tabs** under the header (`All | Text | Push | Email | Chat`) pick one device or all of them. A tab whose device is not on screen counts what arrived there. When the harness has less than 800px to itself (a phone, a side panel, a narrow embed) there is no room for two devices, so it shows one at a time and the tabs switch between them; this follows the width of the element the UI is mounted on, not the window. Every device has the same header above it, so the frames always line up along the top.
|
|
100
103
|
|
|
101
104
|
Links open one device for a screenshot, for example in a Playwright test:
|
|
102
105
|
|
|
@@ -127,7 +130,7 @@ The devices behave like the real apps, in a generic style with no vendor marks:
|
|
|
127
130
|
Every gesture also works with a click or the keyboard. Dismissing, archiving or deleting only hides
|
|
128
131
|
the message in this browser; the harness keeps every record, and a reload brings it back.
|
|
129
132
|
|
|
130
|
-
**Sound** (off by default; the
|
|
133
|
+
**Sound** (off by default; the **Sound** toggle turns it on, and so does `?sound=1`): new
|
|
131
134
|
arrivals play a synthesized chime in each platform's style, and phones vibrate where the browser
|
|
132
135
|
allows. **Motion:** arrivals, swipes, stacks and screen changes are animated. A viewer's
|
|
133
136
|
reduced-motion setting turns animation off, and so does the `motion: "reduce"` option.
|
|
@@ -185,7 +188,7 @@ test("the sign-in code is offered above the keyboard", async ({ page }) => {
|
|
|
185
188
|
|
|
186
189
|
| Device | Main test ids | State attributes |
|
|
187
190
|
| --- | --- | --- |
|
|
188
|
-
|
|
|
191
|
+
| Header and filters | `namespace`, `search`, `view-devices`, `view-timeline`, `follow`, `sound-toggle`, `connection`, `source`, `notice`, `toast`, `toast-undo` | `source`: `data-name`, `data-service`, `data-ok`, `data-count`. `connection`: `data-state`. |
|
|
189
192
|
| Channel tabs | `channel-tabs`, `channel-tab`, `channel-tab-unread` | Root: `data-layout` (`grid` or `tabs`), `data-tab` (`all`, `sms`, `push`, `email`, `chat`). `channel-tab`: `data-value`, `aria-selected`, `data-unread`. |
|
|
190
193
|
| Messages | `sms-device`, `sms-recipient`, `sms-thread` (`-name`, `-preview`, `-time`, `-unread`), `sms-conversation`, `sms-back`, `sms-bubble`, `sms-code`, `sms-menu`, `sms-menu-tapback`, `sms-tapback`, `sms-empty` | `sms-device`: `data-screen` (`threads` or `conversation`), `data-recipient`, `data-thread`. `sms-thread`: `data-pinned`, `data-muted`. |
|
|
191
194
|
| Push | `push-device`, `push-recipient`, `push-skin`, `push-group`, `push-group-more`, `push-notification` (`-title`, `-body`, `-app`, `-time`, `-image`, `-data`, `-meta`), `push-clear`, `push-options`, `push-preview`, `push-settings`, `push-clear-all`, `push-empty` | `push-device`: `data-skin` (`ios` or `android`), `data-platform`. `push-notification`: `data-expanded`, `data-app`, `data-stacked`. |
|
|
@@ -224,15 +227,17 @@ await ui.ready
|
|
|
224
227
|
ui.destroy()
|
|
225
228
|
```
|
|
226
229
|
|
|
227
|
-
|
|
228
|
-
|
|
230
|
+
The UI is React and HeroUI inside, prebuilt into this package, so your app needs neither. It adds
|
|
231
|
+
Mockingbird's stylesheet (`@crvouga/mockingbird-ui/styles`) and the device skins (`STYLES`, scoped to
|
|
232
|
+
`.mb-notifications`) once to the document, or to the shadow root that holds `panel`; pass
|
|
233
|
+
`injectStyles: false` to serve them yourself. Options: `harness`, or `fetch` and `baseUrl` for a harness on
|
|
229
234
|
another origin; `channels` (which devices to show); `layout` (`auto`, `tabs` or `grid`) and `tabs` (show the
|
|
230
|
-
channel tabs); `chrome` (show the
|
|
235
|
+
channel tabs); `chrome` (show the header and filters); `scale` (draw the devices smaller, `0.5` to `1`); `sound`; `motion`
|
|
231
236
|
(`auto`, `full` or `reduce`); `onArrive`; and `syncUrl`, which reads and writes `?view=`-style
|
|
232
237
|
links on the page. The [lab ordering example](https://github.com/crvouga/mockingbird/tree/main/packages/examples/medical-testing)
|
|
233
238
|
mounts it as its Notifications tab.
|
|
234
239
|
|
|
235
|
-
`mountDashboard` puts
|
|
240
|
+
`mountDashboard` puts the Mockingbird shell and tabs over that UI and an emulators panel you draw:
|
|
236
241
|
|
|
237
242
|
```ts
|
|
238
243
|
import { createNotificationHarness } from "@crvouga/mockingbird-notifications"
|
|
@@ -256,10 +261,10 @@ dashboard.show("notifications")
|
|
|
256
261
|
|
|
257
262
|
Tabs are your own `tabs` (`{ id, label, mount }`), then Emulators, then Notifications. A tab is
|
|
258
263
|
drawn the first time it is shown and stays mounted; the Notifications tab counts what arrives while
|
|
259
|
-
another is open. Other options: `initialTab`, `onTabChange`, `theme` (`
|
|
260
|
-
`injectStyles`. The handle has `show(id)`, `active()`,
|
|
261
|
-
`destroy()`. Give the element a height.
|
|
262
|
-
under a strict Content-Security-Policy.
|
|
264
|
+
another is open. Other options: `initialTab`, `onTabChange`, `theme` (`auto`, the default, follows
|
|
265
|
+
the viewer; `light` or `dark` pins one) and `injectStyles`. The handle has `show(id)`, `active()`,
|
|
266
|
+
`tabs()`, `aside`, `notifications` and `destroy()`. Give the element a height. It adds no inline
|
|
267
|
+
script, so it runs under a strict Content-Security-Policy.
|
|
263
268
|
|
|
264
269
|
## Usage
|
|
265
270
|
|
|
@@ -355,8 +360,8 @@ forwards to Mailosaur (`--forward-to-inbox`), the Mailosaur copy is hidden so th
|
|
|
355
360
|
| `CHANNELS` | value | Every channel, in device order: `sms`, `push`, `email`, `chat`. |
|
|
356
361
|
| `TEST_IDS`, `selectors` | values | Every `data-testid` the UI renders, and CSS selector builders for browser tests. Also exported from `./ui`. |
|
|
357
362
|
| `mountNotifications` (`./ui`) | function | `(element, {harness, …})` → `{ready, show, setNamespace, setSound, render, destroy}`. Mounts the UI on an element. |
|
|
358
|
-
| `mountDashboard` (`./ui`) | function | `(element, {emulators, notifications, tabs, …})` → `{show, active, tabs, aside, notifications, destroy}`.
|
|
359
|
-
| `createApp`, `STYLES`, `ROOT_CLASS` (`./ui`) | browser | The UI without the style injection and embedded defaults,
|
|
363
|
+
| `mountDashboard` (`./ui`) | function | `(element, {emulators, notifications, tabs, …})` → `{show, active, tabs, aside, notifications, destroy}`. The Mockingbird shell and tabs over an emulators panel and the notifications UI. Also `DASHBOARD_STYLES` and `DASHBOARD_ROOT_CLASS`. |
|
|
364
|
+
| `createApp`, `STYLES`, `ROOT_CLASS` (`./ui`) | browser | The UI without the style injection and embedded defaults, the device skins' scoped stylesheet (pair it with `MOCKINGBIRD_CSS`), and its root class. |
|
|
360
365
|
| `createServer`, `manifestFile`, `DEFAULT_PORT` (`./server`) | Node | Serve the harness over `node:http`; `manifestFile(path)` re-reads a fleet ready file. Port 8790. |
|
|
361
366
|
| `adminGateway` (`./server`) | Node | The harness's `admin` option: fronts every emulator's admin API and admin UI under `/admin/`. `createServer` passes it by default. |
|
|
362
367
|
|
|
@@ -382,3 +387,9 @@ bun run --cwd packages/notifications dev # a fleet of every messaging emu
|
|
|
382
387
|
bun run --cwd packages/notifications e2e # the browser tests (bunx playwright install chromium first)
|
|
383
388
|
bun run --cwd packages/notifications storybook # every UI state, from fixtures
|
|
384
389
|
```
|
|
390
|
+
|
|
391
|
+
Portable hosts can import `adminGateway` from `@crvouga/mockingbird-notifications/admin-gateway`
|
|
392
|
+
and pass it as `createNotificationHarness({admin: adminGateway(), services, ...})`. This serves
|
|
393
|
+
the existing aggregate admin UI alongside notifications without importing Node's server entry.
|
|
394
|
+
Anyone reaching this gateway can use its configured admin keys; mount it only inside the host's
|
|
395
|
+
intended control boundary.
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { AdminGatewayFactory } from './index.js';
|
|
2
|
+
|
|
3
|
+
/** Where the admin UI reads each vendor's logo and links from, as every emulator's own admin does. */
|
|
4
|
+
declare const ADMIN_BRANDS_URL = "https://mockingbird.chrisvouga.dev/brands.json";
|
|
5
|
+
type AdminGatewayOptions = {
|
|
6
|
+
/** Default {@link ADMIN_BRANDS_URL}. */
|
|
7
|
+
brandsUrl?: string;
|
|
8
|
+
};
|
|
9
|
+
/**
|
|
10
|
+
* Pass the result as the harness's `admin` option. `createServer` does so by default.
|
|
11
|
+
*
|
|
12
|
+
* A request that carries no admin key gets the harness's own (`adminKey` / `adminKeys`), so the
|
|
13
|
+
* page works against a locked fleet without the viewer typing the key. Anyone who can reach the
|
|
14
|
+
* harness can then change emulator state: keep it on a loopback or otherwise private address.
|
|
15
|
+
*/
|
|
16
|
+
declare const adminGateway: (options?: AdminGatewayOptions) => AdminGatewayFactory;
|
|
17
|
+
|
|
18
|
+
export { ADMIN_BRANDS_URL, adminGateway };
|
|
19
|
+
export type { AdminGatewayOptions };
|