@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.
Files changed (38) hide show
  1. package/README.md +25 -14
  2. package/dist/admin-gateway.d.ts +19 -0
  3. package/dist/admin-gateway.js +10 -0
  4. package/dist/browser.bundle-MOA3BSWW.js +6 -0
  5. package/dist/browser.bundle-MOA3BSWW.js.map +7 -0
  6. package/dist/chunk-5MRZJQ6J.js +1254 -0
  7. package/dist/chunk-5MRZJQ6J.js.map +7 -0
  8. package/dist/chunk-NMW2EZL2.js +200 -0
  9. package/dist/chunk-NMW2EZL2.js.map +7 -0
  10. package/dist/chunk-T6QHUV5K.js +206 -0
  11. package/dist/chunk-T6QHUV5K.js.map +7 -0
  12. package/dist/chunk-ZIE3JCV6.js +26 -0
  13. package/dist/chunk-ZIE3JCV6.js.map +7 -0
  14. package/dist/cli.js +4 -4
  15. package/dist/client.bundle-YOZJSCGX.js +6 -0
  16. package/dist/client.bundle-YOZJSCGX.js.map +7 -0
  17. package/dist/{document-OSYEGZSQ.js → document-JPNN2BT5.js} +2 -2
  18. package/dist/document-JPNN2BT5.js.map +7 -0
  19. package/dist/index.js +4 -6
  20. package/dist/index.js.map +1 -1
  21. package/dist/{chunk-QQK27AFM.js → page-J3NUKUUA.js} +34 -306
  22. package/dist/page-J3NUKUUA.js.map +7 -0
  23. package/dist/server-Q5XLVMT2.js +17378 -0
  24. package/dist/server-Q5XLVMT2.js.map +7 -0
  25. package/dist/server.d.ts +4 -18
  26. package/dist/server.js +7 -6
  27. package/dist/ui.d.ts +36 -46
  28. package/dist/ui.js +21530 -2526
  29. package/dist/ui.js.map +4 -4
  30. package/package.json +40 -13
  31. package/dist/chunk-5DUELOZW.js +0 -1202
  32. package/dist/chunk-5DUELOZW.js.map +0 -7
  33. package/dist/chunk-5KZ24SHQ.js +0 -26
  34. package/dist/chunk-5KZ24SHQ.js.map +0 -7
  35. package/dist/chunk-JECNH6UB.js +0 -393
  36. package/dist/chunk-JECNH6UB.js.map +0 -7
  37. package/dist/chunk-QQK27AFM.js.map +0 -7
  38. /package/dist/{document-OSYEGZSQ.js.map → admin-gateway.js.map} +0 -0
package/dist/server.d.ts CHANGED
@@ -1,19 +1,5 @@
1
- import { AdminGatewayFactory, NotificationHarness, HarnessOptions, FleetManifest } 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;
1
+ import { NotificationHarness, HarnessOptions, FleetManifest } from './index.js';
2
+ export { ADMIN_BRANDS_URL, AdminGatewayOptions, adminGateway } from './admin-gateway.js';
17
3
 
18
4
  /** Port `mockingbird-notifications serve` listens on when none is given. */
19
5
  declare const DEFAULT_PORT = 8790;
@@ -39,5 +25,5 @@ type NotificationServer = {
39
25
  declare const manifestFile: (path: string) => () => Promise<FleetManifest>;
40
26
  declare const createServer: (options?: NotificationServerOptions) => Promise<NotificationServer>;
41
27
 
42
- export { ADMIN_BRANDS_URL, DEFAULT_PORT, adminGateway, createServer, manifestFile };
43
- export type { AdminGatewayOptions, NotificationServer, NotificationServerOptions };
28
+ export { DEFAULT_PORT, createServer, manifestFile };
29
+ export type { NotificationServer, NotificationServerOptions };
package/dist/server.js CHANGED
@@ -1,13 +1,14 @@
1
1
  import {
2
- ADMIN_BRANDS_URL,
3
2
  DEFAULT_PORT,
4
- adminGateway,
5
3
  createServer,
6
4
  manifestFile
7
- } from "./chunk-JECNH6UB.js";
8
- import "./chunk-5DUELOZW.js";
9
- import "./chunk-QQK27AFM.js";
10
- import "./chunk-5KZ24SHQ.js";
5
+ } from "./chunk-T6QHUV5K.js";
6
+ import "./chunk-5MRZJQ6J.js";
7
+ import {
8
+ ADMIN_BRANDS_URL,
9
+ adminGateway
10
+ } from "./chunk-NMW2EZL2.js";
11
+ import "./chunk-ZIE3JCV6.js";
11
12
  export {
12
13
  ADMIN_BRANDS_URL,
13
14
  DEFAULT_PORT,
package/dist/ui.d.ts CHANGED
@@ -1,10 +1,5 @@
1
+ import { Channel, Notification, SourceStatus, NotificationHarness } from './index.js';
1
2
  export { T as TEST_IDS, a as TestId, s as selectors } from './types-B--Ql-Jg.js';
2
- import { Notification, Channel, SourceStatus, NotificationHarness } from './index.js';
3
-
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
3
 
9
4
  /**
10
5
  * The channel tab bar's rules, kept free of the DOM so they are unit-tested directly.
@@ -13,21 +8,19 @@ declare const STYLES: string;
13
8
  * Narrow (or with `layout: "tabs"`), there is no "All": exactly one device shows at a time.
14
9
  */
15
10
 
11
+ type ChannelTab = Channel | "all";
16
12
  type DeviceLayout = "auto" | "tabs" | "grid";
17
13
 
18
14
  /**
19
- * The harness UI. Plain DOM: each device re-renders from `state` when the harness reports a change.
20
- *
21
- * `createApp` mounts it on any element. Live, it reads a harness through `fetch` (a Fetch handler
22
- * for an in-process harness, or HTTP); otherwise it draws the notifications it is given, which is
23
- * how the Storybook catalog shows every state.
24
- *
25
- * Every element a test might look for has a `data-testid` from `../testids.ts`, and every element
26
- * that shows a notification carries its id, channel, service, recipient, sender and status as
27
- * `data-*` attributes. Every gesture (swipe, long press) also has a click or key equivalent.
15
+ * The public types of `@crvouga/mockingbird-notifications/ui`. Framework-free on purpose: the UI is
16
+ * React and HeroUI inside, but an embedder only ever passes plain options and gets plain handles,
17
+ * so its own type checker needs neither React's types nor HeroUI's.
28
18
  */
29
19
 
30
20
  type MotionPreference = "auto" | "full" | "reduce";
21
+ type View = "devices" | "timeline";
22
+ type PushSkin = "auto" | "ios" | "android";
23
+ type Tapback = "heart" | "like" | "dislike" | "laugh" | "emphasize" | "question";
31
24
  type AppOptions = {
32
25
  /** Read a harness and follow its event stream. Default true. */
33
26
  live?: boolean;
@@ -42,7 +35,7 @@ type AppOptions = {
42
35
  syncUrl?: boolean;
43
36
  /** Keep read state in `localStorage`. Default: same as `live`. */
44
37
  storage?: boolean;
45
- /** Play alert sounds (and vibrate) on arrivals. Default false; the top bar toggles it. */
38
+ /** Play alert sounds (and vibrate) on arrivals. Default false; the toolbar toggles it. */
46
39
  sound?: boolean;
47
40
  /** Animations. `auto` follows the viewer's reduced-motion setting. Default `auto`. */
48
41
  motion?: MotionPreference;
@@ -58,7 +51,7 @@ type AppOptions = {
58
51
  layout?: DeviceLayout;
59
52
  /** Show the channel tabs (`All | Text | Push | Email | Chat`). Default true; with `false`, `auto` never collapses. */
60
53
  tabs?: boolean;
61
- /** Show the top bar (namespace, filter, view tabs, sound, emulator status). Default true. */
54
+ /** Show the toolbar (namespace, filter, view switch, sound, emulator status). Default true. */
62
55
  chrome?: boolean;
63
56
  /**
64
57
  * Draw the devices at this fraction of their full size (a phone is 362 by 760px), from 0.5 to 1,
@@ -112,6 +105,8 @@ type AppOptions = {
112
105
  to?: string | null;
113
106
  };
114
107
  toast?: string | null;
108
+ /** Narrow screens: the toolbar's extra controls are open. */
109
+ menu?: boolean;
115
110
  local?: {
116
111
  dismissed?: string[];
117
112
  pinned?: string[];
@@ -142,43 +137,35 @@ type AppHandle = {
142
137
  /** Stop streams and timers, remove listeners and empty the host. */
143
138
  destroy(): void;
144
139
  };
145
- type View = "devices" | "timeline";
146
- type PushSkin = "auto" | "ios" | "android";
147
- type Tapback = "heart" | "like" | "dislike" | "laugh" | "emphasize" | "question";
148
- declare function createApp(root: HTMLElement, options?: AppOptions): AppHandle;
149
-
150
140
  type MountOptions = Omit<AppOptions, "fetch"> & {
151
141
  /** An in-process harness (anything with a Fetch handler). Omit it to read `baseUrl` over HTTP. */
152
142
  harness?: Pick<NotificationHarness, "fetch">;
153
143
  /** Any Fetch-compatible transport to the harness API. Ignored when `harness` is given. */
154
144
  fetch?: NonNullable<AppOptions["fetch"]>;
155
- /** Add the stylesheet to the host's document or shadow root. Default true. */
145
+ /**
146
+ * Add the stylesheets (Mockingbird's, and the device skins) to the host's document or shadow
147
+ * root. Default true. Pass false when the page already has them.
148
+ */
156
149
  injectStyles?: boolean;
157
150
  };
158
- /**
159
- * Mount the live harness UI inside `host`. It fills the element and scrolls inside it
160
- * (`embedded`), and leaves the page URL alone unless `syncUrl` is set.
161
- */
162
- declare const mountNotifications: (host: HTMLElement, options?: MountOptions) => AppHandle;
163
-
164
151
  /** Returns nothing, a dispose function, or a promise of either. */
165
- type Mount = (panel: HTMLElement) => unknown;
152
+ type DashboardMount = (panel: HTMLElement) => unknown;
166
153
  type DashboardTab = {
167
154
  /** Unique; also the `?tab=` value. `emulators` and `notifications` are taken. */
168
155
  id: string;
169
156
  label: string;
170
157
  /** Draw the tab into `panel`, the first time it is shown. May return a dispose function. */
171
- mount: Mount;
158
+ mount: DashboardMount;
172
159
  };
173
160
  type DashboardOptions = {
174
- /** Shown at the start of the tab bar. Omit it for a bar of tabs only. */
161
+ /** The product name in the top bar. Default "Notifications". */
175
162
  title?: string;
176
163
  /** The embedder's own tabs, shown first. */
177
164
  tabs?: DashboardTab[];
178
165
  /** The emulator admin dashboard. `mount` may be async (for example, to load a script first). */
179
166
  emulators?: {
180
167
  label?: string;
181
- mount: Mount;
168
+ mount: DashboardMount;
182
169
  };
183
170
  /** The notifications UI: what `mountNotifications` takes, plus a tab label. */
184
171
  notifications?: MountOptions & {
@@ -189,7 +176,7 @@ type DashboardOptions = {
189
176
  /** Read `?tab=` from the page URL and keep it current. Default false. */
190
177
  syncUrl?: boolean;
191
178
  onTabChange?: (id: string) => void;
192
- /** Tab bar colors. `auto` follows the viewer's color scheme. Default `dark`, like the notifications UI. */
179
+ /** Light or dark. `auto` (the default) follows the viewer's color scheme. */
193
180
  theme?: "dark" | "light" | "auto";
194
181
  /** Add the stylesheets to the host's document or shadow root. Default true. */
195
182
  injectStyles?: boolean;
@@ -201,25 +188,28 @@ type DashboardHandle = {
201
188
  active(): string;
202
189
  /** Tab ids, in bar order. */
203
190
  tabs(): string[];
204
- /** An empty element at the end of the tab bar, for a status or a link. */
191
+ /** An empty element in the top bar's actions, for a status or a link. */
205
192
  aside: HTMLElement;
206
193
  /** The notifications UI, when the dashboard has one. */
207
194
  notifications?: AppHandle;
208
195
  /** Dispose every mounted tab, remove listeners and empty the host. */
209
196
  destroy(): void;
210
197
  };
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
198
 
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. */
199
+ /** Mount the live harness UI inside `host`; it fills the element and scrolls inside it. */
200
+ declare const mountNotifications: (host: HTMLElement, options?: MountOptions) => AppHandle;
201
+ /** A tab bar (Emulators, Notifications, your own tabs) in the Mockingbird shell, inside `host`. */
202
+ declare const mountDashboard: (host: HTMLElement, options: DashboardOptions) => DashboardHandle;
203
+ /** The UI without the style injection and embedded defaults of `mountNotifications`. */
204
+ declare const createApp: (host: HTMLElement, options?: AppOptions) => AppHandle;
205
+ /** The device skins' stylesheet (pair it with `MOCKINGBIRD_CSS` from `@crvouga/mockingbird-ui/styles`). */
206
+ declare const STYLES: string;
207
+ /** The class on the UI root, which every rule in `STYLES` is scoped to. */
208
+ declare const ROOT_CLASS: string;
209
+ /** What the dashboard adds to Mockingbird's stylesheet: the device skins. */
222
210
  declare const DASHBOARD_STYLES: string;
211
+ /** The class on the dashboard's host element. */
212
+ declare const DASHBOARD_ROOT_CLASS: string;
223
213
 
224
214
  export { DASHBOARD_ROOT_CLASS, DASHBOARD_STYLES, ROOT_CLASS, STYLES, createApp, mountDashboard, mountNotifications };
225
- export type { AppHandle, AppOptions, DashboardHandle, DashboardOptions, DashboardTab, MotionPreference, MountOptions, PushSkin, View };
215
+ export type { AppHandle, AppOptions, ChannelTab, DashboardHandle, DashboardOptions, DashboardTab, DeviceLayout, MotionPreference, MountOptions, PushSkin, View };