@eifi1/ui-kit 0.45.0 → 0.46.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 (228) hide show
  1. package/README.md +23 -12
  2. package/dist/admin/admin-area-labels.d.ts +9 -0
  3. package/dist/admin/admin-area-labels.js +5 -1
  4. package/dist/admin/admin-area-labels.js.map +1 -1
  5. package/dist/admin/admin-overview.d.ts +16 -1
  6. package/dist/admin/admin-overview.js +12 -1
  7. package/dist/admin/admin-overview.js.map +1 -1
  8. package/dist/admin/mail-test-card.d.ts +3 -2
  9. package/dist/admin/mail-test-card.js +3 -1
  10. package/dist/admin/mail-test-card.js.map +1 -1
  11. package/dist/components/appearance-labels.d.ts +10 -0
  12. package/dist/components/appearance-labels.js +6 -1
  13. package/dist/components/appearance-labels.js.map +1 -1
  14. package/dist/components/data-table-column-settings.js +2 -2
  15. package/dist/components/data-table-column-settings.js.map +1 -1
  16. package/dist/components/data-table-head.js +2 -2
  17. package/dist/components/data-table-head.js.map +1 -1
  18. package/dist/components/data-table-row-actions.d.ts +18 -2
  19. package/dist/components/data-table-row-actions.js +86 -2
  20. package/dist/components/data-table-row-actions.js.map +1 -1
  21. package/dist/components/data-table-shared.js +9 -2
  22. package/dist/components/data-table-shared.js.map +1 -1
  23. package/dist/components/data-table.d.ts +43 -2
  24. package/dist/components/data-table.js +9 -4
  25. package/dist/components/data-table.js.map +1 -1
  26. package/dist/components/date-format-setting.d.ts +29 -0
  27. package/dist/components/date-format-setting.js +36 -0
  28. package/dist/components/date-format-setting.js.map +1 -0
  29. package/dist/components/swipeable-row.d.ts +8 -0
  30. package/dist/components/swipeable-row.js.map +1 -1
  31. package/dist/components/tabs.d.ts +3 -2
  32. package/dist/components/tabs.js +1 -1
  33. package/dist/components/tabs.js.map +1 -1
  34. package/dist/components/translation-review-editor.js +1 -0
  35. package/dist/components/translation-review-editor.js.map +1 -1
  36. package/dist/components/translation-review-labels.d.ts +5 -0
  37. package/dist/components/translation-review-labels.js +2 -0
  38. package/dist/components/translation-review-labels.js.map +1 -1
  39. package/dist/components/translation-review.d.ts +18 -8
  40. package/dist/components/translation-review.js +64 -7
  41. package/dist/components/translation-review.js.map +1 -1
  42. package/dist/components/write-lock-labels.js +2 -1
  43. package/dist/components/write-lock-labels.js.map +1 -1
  44. package/dist/components/write-lock.d.ts +33 -3
  45. package/dist/components/write-lock.js +9 -0
  46. package/dist/components/write-lock.js.map +1 -1
  47. package/dist/data-table.d.ts +1 -1
  48. package/dist/data-table.js.map +1 -1
  49. package/dist/eslint/index.js +1 -1
  50. package/dist/feedback/feedback-row-detail.d.ts +4 -2
  51. package/dist/feedback/feedback-row-detail.js +17 -26
  52. package/dist/feedback/feedback-row-detail.js.map +1 -1
  53. package/dist/feedback/feedback-swipe.d.ts +18 -0
  54. package/dist/feedback/feedback-swipe.js +10 -1
  55. package/dist/feedback/feedback-swipe.js.map +1 -1
  56. package/dist/i18n/german.js +41 -5
  57. package/dist/i18n/german.js.map +1 -1
  58. package/dist/i18n/kit-labels.d.ts +12 -1
  59. package/dist/i18n/kit-labels.js +8 -2
  60. package/dist/i18n/kit-labels.js.map +1 -1
  61. package/dist/i18n/locales/en.js +40 -6
  62. package/dist/i18n/locales/en.js.map +2 -2
  63. package/dist/i18n/locales/es.js +41 -5
  64. package/dist/i18n/locales/es.js.map +1 -1
  65. package/dist/i18n/locales/fr.js +41 -5
  66. package/dist/i18n/locales/fr.js.map +1 -1
  67. package/dist/i18n/locales/hu.js +41 -5
  68. package/dist/i18n/locales/hu.js.map +1 -1
  69. package/dist/i18n/locales/it.js +41 -5
  70. package/dist/i18n/locales/it.js.map +1 -1
  71. package/dist/i18n/locales/zh.js +41 -5
  72. package/dist/i18n/locales/zh.js.map +1 -1
  73. package/dist/i18n/review.js +3 -1
  74. package/dist/i18n/review.js.map +1 -1
  75. package/dist/index.d.ts +15 -2
  76. package/dist/index.js +35 -0
  77. package/dist/index.js.map +1 -1
  78. package/dist/lib/date-format.d.ts +81 -0
  79. package/dist/lib/date-format.js +56 -0
  80. package/dist/lib/date-format.js.map +1 -0
  81. package/dist/lib/format.d.ts +3 -0
  82. package/dist/lib/format.js +5 -4
  83. package/dist/lib/format.js.map +1 -1
  84. package/dist/notifications/device-zone-report.d.ts +27 -0
  85. package/dist/notifications/device-zone-report.js +24 -0
  86. package/dist/notifications/device-zone-report.js.map +1 -0
  87. package/dist/notifications/feedback-notification-types-labels.d.ts +7 -1
  88. package/dist/notifications/feedback-notification-types-labels.js +4 -1
  89. package/dist/notifications/feedback-notification-types-labels.js.map +1 -1
  90. package/dist/notifications/feedback-notification-types.d.ts +11 -5
  91. package/dist/notifications/feedback-notification-types.js +2 -1
  92. package/dist/notifications/feedback-notification-types.js.map +1 -1
  93. package/dist/notifications/notification-bell.d.ts +33 -0
  94. package/dist/notifications/notification-bell.js +74 -0
  95. package/dist/notifications/notification-bell.js.map +1 -0
  96. package/dist/notifications/notification-inbox.d.ts +77 -0
  97. package/dist/notifications/notification-inbox.js +206 -0
  98. package/dist/notifications/notification-inbox.js.map +1 -0
  99. package/dist/notifications/notification-types-setting.d.ts +6 -4
  100. package/dist/notifications/notification-types-setting.js +103 -45
  101. package/dist/notifications/notification-types-setting.js.map +1 -1
  102. package/dist/notifications/notification-types.d.ts +19 -7
  103. package/dist/notifications/notifications-labels.d.ts +41 -7
  104. package/dist/notifications/notifications-labels.js +18 -1
  105. package/dist/notifications/notifications-labels.js.map +1 -1
  106. package/dist/notifications/push-devices-setting.d.ts +20 -3
  107. package/dist/notifications/push-devices-setting.js +93 -33
  108. package/dist/notifications/push-devices-setting.js.map +1 -1
  109. package/dist/notifications/push-worker.d.ts +108 -0
  110. package/dist/notifications/push-worker.js +62 -0
  111. package/dist/notifications/push-worker.js.map +1 -0
  112. package/dist/notifications/quiet-hours-setting.d.ts +29 -17
  113. package/dist/notifications/quiet-hours-setting.js +9 -41
  114. package/dist/notifications/quiet-hours-setting.js.map +1 -1
  115. package/dist/notifications/time-zone-select.d.ts +5 -2
  116. package/dist/notifications/time-zone-select.js.map +1 -1
  117. package/dist/notifications/use-push-device.d.ts +4 -17
  118. package/dist/notifications/use-push-device.js +7 -15
  119. package/dist/notifications/use-push-device.js.map +1 -1
  120. package/dist/offline/local-first.d.ts +33 -0
  121. package/dist/offline/local-first.js +39 -0
  122. package/dist/offline/local-first.js.map +1 -0
  123. package/dist/offline/query-persistence.d.ts +26 -1
  124. package/dist/offline/query-persistence.js +27 -23
  125. package/dist/offline/query-persistence.js.map +1 -1
  126. package/dist/offline/service-worker-updates.d.ts +46 -0
  127. package/dist/offline/service-worker-updates.js +39 -0
  128. package/dist/offline/service-worker-updates.js.map +1 -0
  129. package/dist/offline.d.ts +5 -2
  130. package/dist/offline.js +11 -2
  131. package/dist/offline.js.map +1 -1
  132. package/dist/push-worker.d.ts +2 -0
  133. package/dist/push-worker.js +14 -0
  134. package/dist/push-worker.js.map +1 -0
  135. package/dist/shell/account-menu-text-size.d.ts +33 -0
  136. package/dist/shell/account-menu-text-size.js +51 -0
  137. package/dist/shell/account-menu-text-size.js.map +1 -0
  138. package/dist/shell/top-bar-actions.d.ts +6 -2
  139. package/dist/shell/top-bar-actions.js +1 -0
  140. package/dist/shell/top-bar-actions.js.map +1 -1
  141. package/dist/shell.d.ts +2 -0
  142. package/dist/shell.js +2 -0
  143. package/dist/shell.js.map +1 -1
  144. package/dist/sync/db.d.ts +76 -0
  145. package/dist/sync/db.js +24 -0
  146. package/dist/sync/db.js.map +1 -0
  147. package/dist/sync/engine.d.ts +124 -0
  148. package/dist/sync/engine.js +474 -0
  149. package/dist/sync/engine.js.map +1 -0
  150. package/dist/sync/hooks.d.ts +30 -0
  151. package/dist/sync/hooks.js +67 -0
  152. package/dist/sync/hooks.js.map +1 -0
  153. package/dist/sync/testing.d.ts +28 -0
  154. package/dist/sync/testing.js +41 -0
  155. package/dist/sync/testing.js.map +1 -0
  156. package/dist/sync/wire.d.ts +50 -0
  157. package/dist/sync/wire.js +2 -0
  158. package/dist/sync/wire.js.map +1 -0
  159. package/dist/sync.d.ts +7 -0
  160. package/dist/sync.js +22 -0
  161. package/dist/sync.js.map +1 -0
  162. package/dist/tour/tour-labels.js +1 -0
  163. package/dist/tour/tour-labels.js.map +1 -1
  164. package/dist/tour/tour.d.ts +30 -0
  165. package/dist/tour/tour.js +50 -6
  166. package/dist/tour/tour.js.map +1 -1
  167. package/package.json +19 -1
  168. package/src/admin/admin-area-labels.ts +13 -0
  169. package/src/admin/admin-overview.tsx +37 -2
  170. package/src/admin/mail-test-card.tsx +7 -3
  171. package/src/components/appearance-labels.ts +16 -0
  172. package/src/components/data-table-column-settings.tsx +2 -2
  173. package/src/components/data-table-head.tsx +2 -2
  174. package/src/components/data-table-row-actions.tsx +118 -2
  175. package/src/components/data-table-shared.tsx +21 -2
  176. package/src/components/data-table.tsx +51 -6
  177. package/src/components/date-format-setting.tsx +64 -0
  178. package/src/components/swipeable-row.tsx +8 -0
  179. package/src/components/tabs.tsx +4 -3
  180. package/src/components/translation-review-editor.tsx +2 -0
  181. package/src/components/translation-review-labels.ts +7 -0
  182. package/src/components/translation-review.tsx +102 -14
  183. package/src/components/write-lock-labels.ts +1 -0
  184. package/src/components/write-lock.tsx +36 -3
  185. package/src/data-table.ts +1 -0
  186. package/src/feedback/feedback-row-detail.tsx +18 -23
  187. package/src/feedback/feedback-swipe.tsx +28 -1
  188. package/src/i18n/german.ts +44 -4
  189. package/src/i18n/kit-labels.tsx +18 -1
  190. package/src/i18n/locales/en.ts +1 -0
  191. package/src/i18n/locales/es.ts +44 -4
  192. package/src/i18n/locales/fr.ts +44 -4
  193. package/src/i18n/locales/hu.ts +44 -4
  194. package/src/i18n/locales/it.ts +44 -4
  195. package/src/i18n/locales/zh.ts +44 -2
  196. package/src/i18n/review.ts +3 -1
  197. package/src/index.ts +42 -0
  198. package/src/lib/date-format.ts +151 -0
  199. package/src/lib/format.ts +10 -4
  200. package/src/notifications/device-zone-report.ts +54 -0
  201. package/src/notifications/feedback-notification-types-labels.ts +10 -1
  202. package/src/notifications/feedback-notification-types.ts +12 -5
  203. package/src/notifications/notification-bell.tsx +116 -0
  204. package/src/notifications/notification-inbox.tsx +304 -0
  205. package/src/notifications/notification-types-setting.tsx +151 -55
  206. package/src/notifications/notification-types.ts +20 -8
  207. package/src/notifications/notifications-labels.ts +69 -11
  208. package/src/notifications/push-devices-setting.tsx +123 -34
  209. package/src/notifications/push-worker.ts +160 -0
  210. package/src/notifications/quiet-hours-setting.tsx +41 -58
  211. package/src/notifications/time-zone-select.tsx +5 -2
  212. package/src/notifications/use-push-device.ts +20 -33
  213. package/src/offline/local-first.ts +76 -0
  214. package/src/offline/query-persistence.ts +57 -24
  215. package/src/offline/service-worker-updates.ts +81 -0
  216. package/src/offline.ts +7 -1
  217. package/src/push-worker.ts +25 -0
  218. package/src/shell/account-menu-text-size.tsx +77 -0
  219. package/src/shell/top-bar-actions.tsx +6 -1
  220. package/src/shell.ts +3 -0
  221. package/src/sync/db.ts +103 -0
  222. package/src/sync/engine.ts +699 -0
  223. package/src/sync/hooks.ts +93 -0
  224. package/src/sync/testing.ts +73 -0
  225. package/src/sync/wire.ts +61 -0
  226. package/src/sync.ts +29 -0
  227. package/src/tour/tour-labels.ts +1 -0
  228. package/src/tour/tour.tsx +100 -7
@@ -23,8 +23,13 @@ export interface NotificationsLabels {
23
23
  typesTitle: string;
24
24
  /** The line under it. */
25
25
  typesDescription: string;
26
- /** The e-mail switch under a type that offers mail. */
26
+ /** @deprecated 0.46 — the card's channels are columns now (`channelEmail`); removed in 0.47. Unused,
27
+ * kept so an app's override still type-checks. */
27
28
  byEmail: string;
29
+ /** 0.46 (§10.2): the channel columns' headings, and each switch's name. */
30
+ channelApp: string;
31
+ channelPush: string;
32
+ channelEmail: string;
28
33
  /** Under every e-mail switch while the account's address is unverified (decision 16):
29
34
  * no notification mail goes to an unverified address. */
30
35
  emailUnverified: string;
@@ -38,8 +43,12 @@ export interface NotificationsLabels {
38
43
  typesEmpty: string;
39
44
  quietTitle: string;
40
45
  /** The line under the title; `inbox`: the app keeps an inbox, which a held push still
41
- * reaches. */
42
- quietDescription: (inbox: boolean) => string;
46
+ * reaches; `held` (0.46, §10.4): the app queues a held push and sends it when the
47
+ * window ends, instead of dropping it. */
48
+ quietDescription: (inbox: boolean, held?: boolean) => string;
49
+ /** 0.46 (§10.3, automatic only): the card names the account's zone, read-only, given
50
+ * the zone as `zoneName` writes it ("Europe / Zurich"); it follows the device last used. */
51
+ quietZone: (zone: string) => string;
43
52
  /** The start time's label. */
44
53
  quietFrom: string;
45
54
  /** The end time's label. */
@@ -48,12 +57,13 @@ export interface NotificationsLabels {
48
57
  quietIncomplete: string;
49
58
  /** The zone picker's label. */
50
59
  timeZone: string;
51
- /** Given the device's zone, as the picker names it, when it differs from the one the
52
- * server applies. */
60
+ /** @deprecated 0.46 — the zone is automatic (§10.3), the card offers no device zone; removed in 0.47.
61
+ * Unused, kept so an app's override still type-checks. */
53
62
  deviceZone: (zone: string) => string;
54
- /** The button that takes the device's zone. */
63
+ /** @deprecated 0.46 — the zone is automatic (§10.3), nothing to take; removed in 0.47. Unused, kept
64
+ * so an app's override still type-checks. */
55
65
  useDeviceZone: string;
56
- /** The zone picker's region headings. */
66
+ /** The zone's region headings, in the picker and in a zone's name ("Europe / Zurich"). */
57
67
  regions: NotificationRegionLabels;
58
68
  pushTitle: string;
59
69
  pushDescription: string;
@@ -110,6 +120,30 @@ export interface NotificationsLabels {
110
120
  removeItem: (device: string) => string;
111
121
  /** The question the row asks before it removes. */
112
122
  removePrompt: string;
123
+ /** 0.46 (§10.2): the disclosure on a device's row listing the types with push on. */
124
+ deviceTypes: string;
125
+ /** The line inside it. */
126
+ deviceTypesDescription: string;
127
+ /** No type has push on for the account. */
128
+ deviceTypesEmpty: string;
129
+ /** The inbox's heading (keksdose's "Inbox"). */
130
+ inboxTitle: string;
131
+ inboxLoading: string;
132
+ /** Nothing in the inbox. */
133
+ inboxEmpty: string;
134
+ markAllRead: string;
135
+ /** The header's clear button, and the confirm's answer. */
136
+ clearAll: string;
137
+ /** The question asked before the inbox is cleared. */
138
+ clearPrompt: string;
139
+ /** The row that loads the next page. */
140
+ showMore: string;
141
+ /** The bell's name. */
142
+ bellLabel: string;
143
+ /** Read after the bell's name, given the unread count (≥ 1). */
144
+ bellUnread: (count: number) => string;
145
+ /** The bell panel's link to the app's inbox. */
146
+ allNotifications: string;
113
147
  unsubscribeTitle: string;
114
148
  /** Given the type's name in the app's words. */
115
149
  unsubscribeAbout: (type: string) => string;
@@ -3,6 +3,9 @@ const DEFAULT_NOTIFICATIONS_LABELS = {
3
3
  typesTitle: "Notify me about",
4
4
  typesDescription: "Choose what you hear about, and how.",
5
5
  byEmail: "By e-mail",
6
+ channelApp: "In the app",
7
+ channelPush: "Push",
8
+ channelEmail: "E-mail",
6
9
  emailUnverified: "Confirm your address to receive these.",
7
10
  digestCadence: "Frequency",
8
11
  digestWeekly: "Weekly",
@@ -10,7 +13,8 @@ const DEFAULT_NOTIFICATIONS_LABELS = {
10
13
  typesLoading: "Loading notification settings\u2026",
11
14
  typesEmpty: "There are no notifications for this account.",
12
15
  quietTitle: "Quiet hours",
13
- quietDescription: (inbox) => inbox ? "No push notifications during this window. They still reach your inbox." : "No push notifications during this window.",
16
+ quietDescription: (inbox, held) => held ? inbox ? "Push notifications wait during this window and arrive when it ends. They reach your inbox at once." : "Push notifications wait during this window and arrive when it ends." : inbox ? "No push notifications during this window. They still reach your inbox." : "No push notifications during this window.",
17
+ quietZone: (zone) => `In your time zone (${zone}), which follows the device you last used.`,
14
18
  quietFrom: "From",
15
19
  quietUntil: "Until",
16
20
  quietIncomplete: "Set both a start and an end time. Quiet hours take effect once both are set.",
@@ -64,6 +68,19 @@ const DEFAULT_NOTIFICATIONS_LABELS = {
64
68
  remove: "Remove",
65
69
  removeItem: (device) => `Remove ${device}`,
66
70
  removePrompt: "Stop sending notifications to this device?",
71
+ deviceTypes: "Types on this device",
72
+ deviceTypesDescription: "Turn a type off to mute it on this device only.",
73
+ deviceTypesEmpty: "No type has push notifications turned on.",
74
+ inboxTitle: "Inbox",
75
+ inboxLoading: "Loading notifications\u2026",
76
+ inboxEmpty: "You\u2019re all caught up.",
77
+ markAllRead: "Mark all as read",
78
+ clearAll: "Clear all",
79
+ clearPrompt: "Delete all notifications from your inbox?",
80
+ showMore: "Show more",
81
+ bellLabel: "Notifications",
82
+ bellUnread: (count) => `${count} unread`,
83
+ allNotifications: "All notifications",
67
84
  unsubscribeTitle: "E-mail notifications",
68
85
  unsubscribeAbout: (type) => `You get e-mails about: ${type}.`,
69
86
  unsubscribeGeneric: "You get notification e-mails.",
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/notifications/notifications-labels.ts"],"sourcesContent":["// The words of the notification cards (docs/notifications-harmonization.md §4.2), in a\n// module with no component code: the English catalogue (src/i18n/defaults.ts) imports\n// them without the components, so `en` loads as one chunk like the other languages\n// (0.34, KS U8). The cards read it through `useKitLabels(\"notifications\", …)`.\n\n/** The ten IANA regions `Intl` lists zones under — keksdose's `tz_region_*` — in the\n * kit's words. A region a runtime adds later keeps its IANA name. */\nexport interface NotificationRegionLabels {\n Africa: string;\n America: string;\n Antarctica: string;\n Arctic: string;\n Asia: string;\n Atlantic: string;\n Australia: string;\n Europe: string;\n Indian: string;\n Pacific: string;\n}\n\n/**\n * Every string the notification parts render — the `notifications` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`: the types card,\n * quiet hours and the zone picker, this device's push, the device list, and the\n * unsubscribe page. Cancel is `common.cancel`.\n */\nexport interface NotificationsLabels {\n /* ── The types card ─────────────────────────────────────────────────── */\n /** The types card's title. */\n typesTitle: string;\n /** The line under it. */\n typesDescription: string;\n /** The e-mail switch under a type that offers mail. */\n byEmail: string;\n /** Under every e-mail switch while the account's address is unverified (decision 16):\n * no notification mail goes to an unverified address. */\n emailUnverified: string;\n /** The digest's cadence select. */\n digestCadence: string;\n digestWeekly: string;\n digestMonthly: string;\n /** While the settings load. */\n typesLoading: string;\n /** The server answered no types for this account. */\n typesEmpty: string;\n\n /* ── Quiet hours ────────────────────────────────────────────────────── */\n quietTitle: string;\n /** The line under the title; `inbox`: the app keeps an inbox, which a held push still\n * reaches. */\n quietDescription: (inbox: boolean) => string;\n /** The start time's label. */\n quietFrom: string;\n /** The end time's label. */\n quietUntil: string;\n /** One time set, the other not: quiet hours fail open until both are. */\n quietIncomplete: string;\n /** The zone picker's label. */\n timeZone: string;\n /** Given the device's zone, as the picker names it, when it differs from the one the\n * server applies. */\n deviceZone: (zone: string) => string;\n /** The button that takes the device's zone. */\n useDeviceZone: string;\n /** The zone picker's region headings. */\n regions: NotificationRegionLabels;\n\n /* ── This device ────────────────────────────────────────────────────── */\n pushTitle: string;\n pushDescription: string;\n /** The browser has no push. */\n unsupported: string;\n /** iOS outside the installed app, given the app's name. */\n iosInstall: (app: string) => string;\n /** The server has no VAPID keys. */\n notConfigured: string;\n /** The browser's permission is denied. */\n blocked: string;\n /** This device gets notifications for the signed-in account. */\n on: string;\n off: string;\n /** This browser's subscription belongs to another account. */\n otherAccount: string;\n enable: string;\n disable: string;\n sendTest: string;\n /** Turning on did not finish (the permission prompt dismissed, a refusal). */\n enableFailed: string;\n /** No service worker, or one that is not ready in 10 s. */\n noServiceWorker: string;\n /** The browser's push service did not answer in 15 s. */\n pushTimeout: string;\n /** Given how many devices the push service accepted the test for (≥ 1). */\n testSent: (count: number) => string;\n /** The test reached no device. */\n testNone: string;\n testFailed: string;\n /** The explainer before the browser's one permission prompt. */\n explainerTitle: string;\n explainerBody: (app: string) => string;\n explainerHint: string;\n explainerContinue: string;\n\n /* ── The device list ────────────────────────────────────────────────── */\n devicesTitle: string;\n devicesDescription: string;\n devicesLoading: string;\n devicesEmpty: string;\n /** A device whose user agent says nothing the kit recognises. */\n unknownDevice: string;\n /** The chip on this browser's row. */\n thisDevice: string;\n /** Given the registration date, formatted. */\n added: (date: string) => string;\n /** Given the last accepted delivery, formatted. */\n lastDelivery: (date: string) => string;\n noDelivery: string;\n /** Given the failed deliveries in a row (≥ 1). */\n failures: (count: number) => string;\n /** A row's button, visible text — and the confirm's answer. */\n remove: string;\n /** The same button's accessible name, given the device: it starts with `remove`. */\n removeItem: (device: string) => string;\n /** The question the row asks before it removes. */\n removePrompt: string;\n\n /* ── The unsubscribe page ───────────────────────────────────────────── */\n unsubscribeTitle: string;\n /** Given the type's name in the app's words. */\n unsubscribeAbout: (type: string) => string;\n /** No type name to give. */\n unsubscribeGeneric: string;\n stopThese: string;\n stopAll: (app: string) => string;\n stoppedThese: string;\n stoppedAll: (app: string) => string;\n /** Account mail is not a notification, and keeps coming. */\n accountMail: string;\n turnBackOn: string;\n openSettings: string;\n /** A token the server refused, or one that does not parse. */\n invalidLink: string;\n\n /* ── Every card ─────────────────────────────────────────────────────── */\n /** A request failed, and the app had no words of its own. */\n failed: string;\n}\n\nexport const DEFAULT_NOTIFICATIONS_LABELS: NotificationsLabels = {\n typesTitle: \"Notify me about\",\n typesDescription: \"Choose what you hear about, and how.\",\n byEmail: \"By e-mail\",\n emailUnverified: \"Confirm your address to receive these.\",\n digestCadence: \"Frequency\",\n digestWeekly: \"Weekly\",\n digestMonthly: \"Monthly\",\n typesLoading: \"Loading notification settings…\",\n typesEmpty: \"There are no notifications for this account.\",\n\n quietTitle: \"Quiet hours\",\n quietDescription: (inbox) =>\n inbox\n ? \"No push notifications during this window. They still reach your inbox.\"\n : \"No push notifications during this window.\",\n quietFrom: \"From\",\n quietUntil: \"Until\",\n quietIncomplete: \"Set both a start and an end time. Quiet hours take effect once both are set.\",\n timeZone: \"Time zone\",\n deviceZone: (zone) => `This device is in ${zone}.`,\n useDeviceZone: \"Use it\",\n regions: {\n Africa: \"Africa\",\n America: \"Americas\",\n Antarctica: \"Antarctica\",\n Arctic: \"Arctic\",\n Asia: \"Asia\",\n Atlantic: \"Atlantic\",\n Australia: \"Australia\",\n Europe: \"Europe\",\n Indian: \"Indian Ocean\",\n Pacific: \"Pacific\",\n },\n\n pushTitle: \"Push notifications\",\n pushDescription: \"Notifications on this device, also while the app is closed.\",\n unsupported: \"This browser doesn’t support push notifications.\",\n iosInstall: (app) =>\n `On iPhone or iPad, add ${app} to your Home Screen first: iOS delivers notifications only to the installed app.`,\n notConfigured: \"Push notifications aren’t set up on this server.\",\n blocked: \"Notifications are blocked in this browser’s settings.\",\n on: \"Notifications are on for this device.\",\n off: \"Notifications are off for this device.\",\n otherAccount:\n \"This browser gets notifications for another account. Turn them on here to get them for the account you’re signed in with.\",\n enable: \"Turn on notifications\",\n disable: \"Turn off\",\n sendTest: \"Send a test\",\n enableFailed: \"Couldn’t turn on notifications.\",\n noServiceWorker: \"Couldn’t reach the app’s service worker. Reload the page and try again.\",\n pushTimeout: \"The browser’s push service didn’t answer. Check your connection and try again.\",\n testSent: (count) => (count === 1 ? \"Test sent to 1 device\" : `Test sent to ${count} devices`),\n testNone: \"No device accepted the test. Turn notifications on for this device first.\",\n testFailed: \"Couldn’t send a test notification.\",\n explainerTitle: \"Turn on notifications?\",\n explainerBody: (app) =>\n `${app} sends a notification only for the kinds you choose, and you can turn them off at any time.`,\n explainerHint: \"Your browser asks for permission next.\",\n explainerContinue: \"Continue\",\n\n devicesTitle: \"Notification devices\",\n devicesDescription: \"Every device that gets push notifications for your account. Remove any you no longer use.\",\n devicesLoading: \"Loading devices…\",\n devicesEmpty: \"No device gets notifications yet.\",\n unknownDevice: \"Unknown device\",\n thisDevice: \"This device\",\n added: (date) => `Added ${date}`,\n lastDelivery: (date) => `Last delivery ${date}`,\n noDelivery: \"No delivery yet\",\n failures: (count) =>\n count === 1 ? \"1 failed delivery in a row\" : `${count} failed deliveries in a row`,\n remove: \"Remove\",\n removeItem: (device) => `Remove ${device}`,\n removePrompt: \"Stop sending notifications to this device?\",\n\n unsubscribeTitle: \"E-mail notifications\",\n unsubscribeAbout: (type) => `You get e-mails about: ${type}.`,\n unsubscribeGeneric: \"You get notification e-mails.\",\n stopThese: \"Stop these e-mails\",\n stopAll: (app) => `Stop all notification e-mails from ${app}`,\n stoppedThese: \"Done. You won’t get these e-mails any more.\",\n stoppedAll: (app) => `Done. You won’t get notification e-mails from ${app} any more.`,\n accountMail: \"E-mails about your account still come.\",\n turnBackOn: \"You can turn them back on at any time in Settings.\",\n openSettings: \"Open Settings\",\n invalidLink: \"This link doesn’t work any more. You can turn e-mails off in Settings instead.\",\n\n failed: \"That didn’t work. Please try again.\",\n};\n"],"mappings":";AAoJO,MAAM,+BAAoD;AAAA,EAC/D,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AAAA,EAEZ,YAAY;AAAA,EACZ,kBAAkB,CAAC,UACjB,QACI,2EACA;AAAA,EACN,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,YAAY,CAAC,SAAS,qBAAqB,IAAI;AAAA,EAC/C,eAAe;AAAA,EACf,SAAS;AAAA,IACP,QAAQ;AAAA,IACR,SAAS;AAAA,IACT,YAAY;AAAA,IACZ,QAAQ;AAAA,IACR,MAAM;AAAA,IACN,UAAU;AAAA,IACV,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,QAAQ;AAAA,IACR,SAAS;AAAA,EACX;AAAA,EAEA,WAAW;AAAA,EACX,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,YAAY,CAAC,QACX,0BAA0B,GAAG;AAAA,EAC/B,eAAe;AAAA,EACf,SAAS;AAAA,EACT,IAAI;AAAA,EACJ,KAAK;AAAA,EACL,cACE;AAAA,EACF,QAAQ;AAAA,EACR,SAAS;AAAA,EACT,UAAU;AAAA,EACV,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,aAAa;AAAA,EACb,UAAU,CAAC,UAAW,UAAU,IAAI,0BAA0B,gBAAgB,KAAK;AAAA,EACnF,UAAU;AAAA,EACV,YAAY;AAAA,EACZ,gBAAgB;AAAA,EAChB,eAAe,CAAC,QACd,GAAG,GAAG;AAAA,EACR,eAAe;AAAA,EACf,mBAAmB;AAAA,EAEnB,cAAc;AAAA,EACd,oBAAoB;AAAA,EACpB,gBAAgB;AAAA,EAChB,cAAc;AAAA,EACd,eAAe;AAAA,EACf,YAAY;AAAA,EACZ,OAAO,CAAC,SAAS,SAAS,IAAI;AAAA,EAC9B,cAAc,CAAC,SAAS,iBAAiB,IAAI;AAAA,EAC7C,YAAY;AAAA,EACZ,UAAU,CAAC,UACT,UAAU,IAAI,+BAA+B,GAAG,KAAK;AAAA,EACvD,QAAQ;AAAA,EACR,YAAY,CAAC,WAAW,UAAU,MAAM;AAAA,EACxC,cAAc;AAAA,EAEd,kBAAkB;AAAA,EAClB,kBAAkB,CAAC,SAAS,0BAA0B,IAAI;AAAA,EAC1D,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,SAAS,CAAC,QAAQ,sCAAsC,GAAG;AAAA,EAC3D,cAAc;AAAA,EACd,YAAY,CAAC,QAAQ,sDAAiD,GAAG;AAAA,EACzE,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EAEb,QAAQ;AACV;","names":[]}
1
+ {"version":3,"sources":["../../src/notifications/notifications-labels.ts"],"sourcesContent":["// The words of the notification cards (docs/notifications-harmonization.md §4.2), in a\n// module with no component code: the English catalogue (src/i18n/defaults.ts) imports\n// them without the components, so `en` loads as one chunk like the other languages\n// (0.34, KS U8). The cards read it through `useKitLabels(\"notifications\", …)`.\n\n/** The ten IANA regions `Intl` lists zones under — keksdose's `tz_region_*` — in the\n * kit's words. A region a runtime adds later keeps its IANA name. */\nexport interface NotificationRegionLabels {\n Africa: string;\n America: string;\n Antarctica: string;\n Arctic: string;\n Asia: string;\n Atlantic: string;\n Australia: string;\n Europe: string;\n Indian: string;\n Pacific: string;\n}\n\n/**\n * Every string the notification parts render — the `notifications` namespace of\n * `<UiKitProvider labels>`, overridable per instance through `labels`: the types card,\n * quiet hours and the zone picker, this device's push, the device list, and the\n * unsubscribe page. Cancel is `common.cancel`.\n */\nexport interface NotificationsLabels {\n /* ── The types card ─────────────────────────────────────────────────── */\n /** The types card's title. */\n typesTitle: string;\n /** The line under it. */\n typesDescription: string;\n /** @deprecated 0.46 — the card's channels are columns now (`channelEmail`); removed in 0.47. Unused,\n * kept so an app's override still type-checks. */\n byEmail: string;\n /** 0.46 (§10.2): the channel columns' headings, and each switch's name. */\n channelApp: string;\n channelPush: string;\n channelEmail: string;\n /** Under every e-mail switch while the account's address is unverified (decision 16):\n * no notification mail goes to an unverified address. */\n emailUnverified: string;\n /** The digest's cadence select. */\n digestCadence: string;\n digestWeekly: string;\n digestMonthly: string;\n /** While the settings load. */\n typesLoading: string;\n /** The server answered no types for this account. */\n typesEmpty: string;\n\n /* ── Quiet hours ────────────────────────────────────────────────────── */\n quietTitle: string;\n /** The line under the title; `inbox`: the app keeps an inbox, which a held push still\n * reaches; `held` (0.46, §10.4): the app queues a held push and sends it when the\n * window ends, instead of dropping it. */\n quietDescription: (inbox: boolean, held?: boolean) => string;\n /** 0.46 (§10.3, automatic only): the card names the account's zone, read-only, given\n * the zone as `zoneName` writes it (\"Europe / Zurich\"); it follows the device last used. */\n quietZone: (zone: string) => string;\n /** The start time's label. */\n quietFrom: string;\n /** The end time's label. */\n quietUntil: string;\n /** One time set, the other not: quiet hours fail open until both are. */\n quietIncomplete: string;\n /** The zone picker's label. */\n timeZone: string;\n /** @deprecated 0.46 — the zone is automatic (§10.3), the card offers no device zone; removed in 0.47.\n * Unused, kept so an app's override still type-checks. */\n deviceZone: (zone: string) => string;\n /** @deprecated 0.46 — the zone is automatic (§10.3), nothing to take; removed in 0.47. Unused, kept\n * so an app's override still type-checks. */\n useDeviceZone: string;\n /** The zone's region headings, in the picker and in a zone's name (\"Europe / Zurich\"). */\n regions: NotificationRegionLabels;\n\n /* ── This device ────────────────────────────────────────────────────── */\n pushTitle: string;\n pushDescription: string;\n /** The browser has no push. */\n unsupported: string;\n /** iOS outside the installed app, given the app's name. */\n iosInstall: (app: string) => string;\n /** The server has no VAPID keys. */\n notConfigured: string;\n /** The browser's permission is denied. */\n blocked: string;\n /** This device gets notifications for the signed-in account. */\n on: string;\n off: string;\n /** This browser's subscription belongs to another account. */\n otherAccount: string;\n enable: string;\n disable: string;\n sendTest: string;\n /** Turning on did not finish (the permission prompt dismissed, a refusal). */\n enableFailed: string;\n /** No service worker, or one that is not ready in 10 s. */\n noServiceWorker: string;\n /** The browser's push service did not answer in 15 s. */\n pushTimeout: string;\n /** Given how many devices the push service accepted the test for (≥ 1). */\n testSent: (count: number) => string;\n /** The test reached no device. */\n testNone: string;\n testFailed: string;\n /** The explainer before the browser's one permission prompt. */\n explainerTitle: string;\n explainerBody: (app: string) => string;\n explainerHint: string;\n explainerContinue: string;\n\n /* ── The device list ────────────────────────────────────────────────── */\n devicesTitle: string;\n devicesDescription: string;\n devicesLoading: string;\n devicesEmpty: string;\n /** A device whose user agent says nothing the kit recognises. */\n unknownDevice: string;\n /** The chip on this browser's row. */\n thisDevice: string;\n /** Given the registration date, formatted. */\n added: (date: string) => string;\n /** Given the last accepted delivery, formatted. */\n lastDelivery: (date: string) => string;\n noDelivery: string;\n /** Given the failed deliveries in a row (≥ 1). */\n failures: (count: number) => string;\n /** A row's button, visible text — and the confirm's answer. */\n remove: string;\n /** The same button's accessible name, given the device: it starts with `remove`. */\n removeItem: (device: string) => string;\n /** The question the row asks before it removes. */\n removePrompt: string;\n /** 0.46 (§10.2): the disclosure on a device's row listing the types with push on. */\n deviceTypes: string;\n /** The line inside it. */\n deviceTypesDescription: string;\n /** No type has push on for the account. */\n deviceTypesEmpty: string;\n\n /* ── The inbox and the bell (0.46, §10.1) ───────────────────────────── */\n /** The inbox's heading (keksdose's \"Inbox\"). */\n inboxTitle: string;\n inboxLoading: string;\n /** Nothing in the inbox. */\n inboxEmpty: string;\n markAllRead: string;\n /** The header's clear button, and the confirm's answer. */\n clearAll: string;\n /** The question asked before the inbox is cleared. */\n clearPrompt: string;\n /** The row that loads the next page. */\n showMore: string;\n /** The bell's name. */\n bellLabel: string;\n /** Read after the bell's name, given the unread count (≥ 1). */\n bellUnread: (count: number) => string;\n /** The bell panel's link to the app's inbox. */\n allNotifications: string;\n\n /* ── The unsubscribe page ───────────────────────────────────────────── */\n unsubscribeTitle: string;\n /** Given the type's name in the app's words. */\n unsubscribeAbout: (type: string) => string;\n /** No type name to give. */\n unsubscribeGeneric: string;\n stopThese: string;\n stopAll: (app: string) => string;\n stoppedThese: string;\n stoppedAll: (app: string) => string;\n /** Account mail is not a notification, and keeps coming. */\n accountMail: string;\n turnBackOn: string;\n openSettings: string;\n /** A token the server refused, or one that does not parse. */\n invalidLink: string;\n\n /* ── Every card ─────────────────────────────────────────────────────── */\n /** A request failed, and the app had no words of its own. */\n failed: string;\n}\n\nexport const DEFAULT_NOTIFICATIONS_LABELS: NotificationsLabels = {\n typesTitle: \"Notify me about\",\n typesDescription: \"Choose what you hear about, and how.\",\n byEmail: \"By e-mail\",\n channelApp: \"In the app\",\n channelPush: \"Push\",\n channelEmail: \"E-mail\",\n emailUnverified: \"Confirm your address to receive these.\",\n digestCadence: \"Frequency\",\n digestWeekly: \"Weekly\",\n digestMonthly: \"Monthly\",\n typesLoading: \"Loading notification settings…\",\n typesEmpty: \"There are no notifications for this account.\",\n\n quietTitle: \"Quiet hours\",\n quietDescription: (inbox, held) =>\n held\n ? inbox\n ? \"Push notifications wait during this window and arrive when it ends. They reach your inbox at once.\"\n : \"Push notifications wait during this window and arrive when it ends.\"\n : inbox\n ? \"No push notifications during this window. They still reach your inbox.\"\n : \"No push notifications during this window.\",\n quietZone: (zone) => `In your time zone (${zone}), which follows the device you last used.`,\n quietFrom: \"From\",\n quietUntil: \"Until\",\n quietIncomplete: \"Set both a start and an end time. Quiet hours take effect once both are set.\",\n timeZone: \"Time zone\",\n deviceZone: (zone) => `This device is in ${zone}.`,\n useDeviceZone: \"Use it\",\n regions: {\n Africa: \"Africa\",\n America: \"Americas\",\n Antarctica: \"Antarctica\",\n Arctic: \"Arctic\",\n Asia: \"Asia\",\n Atlantic: \"Atlantic\",\n Australia: \"Australia\",\n Europe: \"Europe\",\n Indian: \"Indian Ocean\",\n Pacific: \"Pacific\",\n },\n\n pushTitle: \"Push notifications\",\n pushDescription: \"Notifications on this device, also while the app is closed.\",\n unsupported: \"This browser doesn’t support push notifications.\",\n iosInstall: (app) =>\n `On iPhone or iPad, add ${app} to your Home Screen first: iOS delivers notifications only to the installed app.`,\n notConfigured: \"Push notifications aren’t set up on this server.\",\n blocked: \"Notifications are blocked in this browser’s settings.\",\n on: \"Notifications are on for this device.\",\n off: \"Notifications are off for this device.\",\n otherAccount:\n \"This browser gets notifications for another account. Turn them on here to get them for the account you’re signed in with.\",\n enable: \"Turn on notifications\",\n disable: \"Turn off\",\n sendTest: \"Send a test\",\n enableFailed: \"Couldn’t turn on notifications.\",\n noServiceWorker: \"Couldn’t reach the app’s service worker. Reload the page and try again.\",\n pushTimeout: \"The browser’s push service didn’t answer. Check your connection and try again.\",\n testSent: (count) => (count === 1 ? \"Test sent to 1 device\" : `Test sent to ${count} devices`),\n testNone: \"No device accepted the test. Turn notifications on for this device first.\",\n testFailed: \"Couldn’t send a test notification.\",\n explainerTitle: \"Turn on notifications?\",\n explainerBody: (app) =>\n `${app} sends a notification only for the kinds you choose, and you can turn them off at any time.`,\n explainerHint: \"Your browser asks for permission next.\",\n explainerContinue: \"Continue\",\n\n devicesTitle: \"Notification devices\",\n devicesDescription: \"Every device that gets push notifications for your account. Remove any you no longer use.\",\n devicesLoading: \"Loading devices…\",\n devicesEmpty: \"No device gets notifications yet.\",\n unknownDevice: \"Unknown device\",\n thisDevice: \"This device\",\n added: (date) => `Added ${date}`,\n lastDelivery: (date) => `Last delivery ${date}`,\n noDelivery: \"No delivery yet\",\n failures: (count) =>\n count === 1 ? \"1 failed delivery in a row\" : `${count} failed deliveries in a row`,\n remove: \"Remove\",\n removeItem: (device) => `Remove ${device}`,\n removePrompt: \"Stop sending notifications to this device?\",\n deviceTypes: \"Types on this device\",\n deviceTypesDescription: \"Turn a type off to mute it on this device only.\",\n deviceTypesEmpty: \"No type has push notifications turned on.\",\n\n inboxTitle: \"Inbox\",\n inboxLoading: \"Loading notifications…\",\n inboxEmpty: \"You’re all caught up.\",\n markAllRead: \"Mark all as read\",\n clearAll: \"Clear all\",\n clearPrompt: \"Delete all notifications from your inbox?\",\n showMore: \"Show more\",\n bellLabel: \"Notifications\",\n bellUnread: (count) => `${count} unread`,\n allNotifications: \"All notifications\",\n\n unsubscribeTitle: \"E-mail notifications\",\n unsubscribeAbout: (type) => `You get e-mails about: ${type}.`,\n unsubscribeGeneric: \"You get notification e-mails.\",\n stopThese: \"Stop these e-mails\",\n stopAll: (app) => `Stop all notification e-mails from ${app}`,\n stoppedThese: \"Done. You won’t get these e-mails any more.\",\n stoppedAll: (app) => `Done. You won’t get notification e-mails from ${app} any more.`,\n accountMail: \"E-mails about your account still come.\",\n turnBackOn: \"You can turn them back on at any time in Settings.\",\n openSettings: \"Open Settings\",\n invalidLink: \"This link doesn’t work any more. You can turn e-mails off in Settings instead.\",\n\n failed: \"That didn’t work. Please try again.\",\n};\n"],"mappings":";AAwLO,MAAM,+BAAoD;AAAA,EAC/D,YAAY;AAAA,EACZ,kBAAkB;AAAA,EAClB,SAAS;AAAA,EACT,YAAY;AAAA,EACZ,aAAa;AAAA,EACb,cAAc;AAAA,EACd,iBAAiB;AAAA,EACjB,eAAe;AAAA,EACf,cAAc;AAAA,EACd,eAAe;AAAA,EACf,cAAc;AAAA,EACd,YAAY;AAAA,EAEZ,YAAY;AAAA,EACZ,kBAAkB,CAAC,OAAO,SACxB,OACI,QACE,uGACA,wEACF,QACE,2EACA;AAAA,EACR,WAAW,CAAC,SAAS,sBAAsB,IAAI;AAAA,EAC/C,WAAW;AAAA,EACX,YAAY;AAAA,EACZ,iBAAiB;AAAA,EACjB,UAAU;AAAA,EACV,YAAY,CAAC,SAAS,q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,aAAa;AAAA,EACb,UAAU;AAAA,EACV,WAAW;AAAA,EACX,YAAY,CAAC,UAAU,GAAG,KAAK;AAAA,EAC/B,kBAAkB;AAAA,EAElB,kBAAkB;AAAA,EAClB,kBAAkB,CAAC,SAAS,0BAA0B,IAAI;AAAA,EAC1D,oBAAoB;AAAA,EACpB,WAAW;AAAA,EACX,SAAS,CAAC,QAAQ,sCAAsC,GAAG;AAAA,EAC3D,cAAc;AAAA,EACd,YAAY,CAAC,QAAQ,sDAAiD,GAAG;AAAA,EACzE,aAAa;AAAA,EACb,YAAY;AAAA,EACZ,cAAc;AAAA,EACd,aAAa;AAAA,EAEb,QAAQ;AACV;","names":[]}
@@ -1,7 +1,7 @@
1
1
  import type { ComponentPropsWithRef, ReactNode } from "react";
2
2
  import { type LabelOverride } from "../i18n/kit-labels.js";
3
3
  import type { NotificationsLabels } from "./notifications-labels.js";
4
- import type { PushDeviceItem } from "./notification-types.js";
4
+ import type { NotificationTypeEntry, NotificationTypesValue, PushDeviceItem } from "./notification-types.js";
5
5
  /**
6
6
  * A name for a stored user agent: "Chrome · Android", "Firefox · Windows" (keksdose
7
7
  * `push-devices-card.tsx:19-45`). Best effort: an agent it does not recognise comes back
@@ -25,6 +25,17 @@ export interface PushDevicesSettingProps<Id extends string | number = string> ex
25
25
  locale?: string;
26
26
  /** The app's own words for a failed removal, or `undefined` for the kit's `failed`. */
27
27
  describeError?: (error: unknown) => ReactNode | undefined;
28
+ /**
29
+ * 0.46 (§10.2): "Types on this device" on each row — a switch per type whose account
30
+ * `push` is on, all on until the device mutes one. Save the device's WHOLE list:
31
+ * `PATCH /notifications/devices/{id} {"muted_types": [...]}`; refresh `devices` once it
32
+ * resolves. Left out, no row has the disclosure.
33
+ */
34
+ onMutedTypesChange?: (id: Id, mutedTypes: string[]) => Promise<unknown> | void;
35
+ /** The app's words for its types (the types card's `types`), for the disclosure. */
36
+ types?: readonly NotificationTypeEntry[];
37
+ /** The settings `GET`'s `types` (the types card's `value`): which types have push on. */
38
+ typeSwitches?: NotificationTypesValue;
28
39
  labels?: LabelOverride<NotificationsLabels>;
29
40
  }
30
41
  /**
@@ -39,6 +50,12 @@ export interface PushDevicesSettingProps<Id extends string | number = string> ex
39
50
  * `PUSH_SUBSCRIPTION_CHANGED` (keksdose `push-devices-card.tsx:83-97`), so the push card
40
51
  * stops saying "on".
41
52
  *
42
- * Under a write lock Remove is a `commit` control exempt from billing.
53
+ * **"Types on this device"** (0.46, §10.2, with `onMutedTypesChange`): a disclosure under
54
+ * each row with a switch per type the account gets by push; turning one off mutes it on
55
+ * that device only — a device can mute types, never add them. Each flip saves the
56
+ * device's whole `muted_types` list.
57
+ *
58
+ * Under a write lock Remove and the type switches are `commit` controls exempt from
59
+ * billing.
43
60
  */
44
- export declare function PushDevicesSetting<Id extends string | number = string>({ devices, loading, currentEndpoint, onRemove, formatDate: formatDateProp, locale: localeProp, describeError, labels: labelsProp, className, ...rest }: PushDevicesSettingProps<Id>): import("react").JSX.Element;
61
+ export declare function PushDevicesSetting<Id extends string | number = string>({ devices, loading, currentEndpoint, onRemove, formatDate: formatDateProp, locale: localeProp, describeError, onMutedTypesChange, types, typeSwitches, labels: labelsProp, className, ...rest }: PushDevicesSettingProps<Id>): import("react").JSX.Element;
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import { jsx, jsxs } from "react/jsx-runtime";
2
+ import { Fragment, jsx, jsxs } from "react/jsx-runtime";
3
3
  import { useEffect, useRef, useState } from "react";
4
4
  import { MonitorSmartphone } from "lucide-react";
5
5
  import { useKitLabels, useKitLocale } from "../i18n/kit-labels.js";
@@ -9,12 +9,14 @@ import { formatDate } from "../lib/format.js";
9
9
  import { Button } from "../components/button.js";
10
10
  import { Card } from "../components/card.js";
11
11
  import { Chip } from "../components/chip.js";
12
+ import { Disclosure } from "../components/disclosure.js";
12
13
  import { Skeleton } from "../components/skeleton.js";
14
+ import { Switch } from "../components/switch.js";
13
15
  import { COMMIT_EXCEPT_BILLING } from "../components/write-lock.js";
14
16
  import { CARD_DESCRIPTION_CLASS } from "../settings/settings-card-classes.js";
15
17
  import { SettingsCardTitle } from "../settings/settings-heading.js";
16
18
  import { settle, useMounted } from "../account/account-parts.js";
17
- import { describeFailure, FailureLine, useNotificationsLabels } from "./notification-parts.js";
19
+ import { describeFailure, FailureLine, useNotificationsLabels, useWriteOverlay } from "./notification-parts.js";
18
20
  import { notifyPushSubscriptionChanged } from "./use-push-device.js";
19
21
  function describeUserAgent(ua) {
20
22
  if (!ua) return null;
@@ -40,11 +42,15 @@ function PushDevicesSetting({
40
42
  formatDate: formatDateProp,
41
43
  locale: localeProp,
42
44
  describeError,
45
+ onMutedTypesChange,
46
+ types,
47
+ typeSwitches,
43
48
  labels: labelsProp,
44
49
  className,
45
50
  ...rest
46
51
  }) {
47
52
  const labels = useNotificationsLabels(labelsProp);
53
+ const mutedOverlay = useWriteOverlay(devices);
48
54
  const common = useKitLabels("common", DEFAULT_COMMON_LABELS);
49
55
  const locale = useKitLocale(localeProp);
50
56
  const [asking, setAsking] = useState(null);
@@ -72,6 +78,55 @@ function PushDevicesSetting({
72
78
  setFailure(describeFailure(describeError?.(error), labels.failed));
73
79
  });
74
80
  };
81
+ const pushTypes = (types ?? []).filter((entry) => typeSwitches?.[entry.id]?.push === true);
82
+ const mutedOf = (device) => mutedOverlay.get(String(device.id)) ?? // Ids the registry dropped (no longer in the settings answer) are ignored.
83
+ (device.muted_types ?? []).filter((id) => !typeSwitches || id in typeSwitches);
84
+ const setMuted = (device, id, on) => {
85
+ const key = String(device.id);
86
+ if (!onMutedTypesChange || mutedOverlay.pending(key)) return;
87
+ const current = mutedOf(device);
88
+ const next = on ? current.filter((muted) => muted !== id) : [...current.filter((muted) => muted !== id), id];
89
+ setFailure(null);
90
+ mutedOverlay.set(key, next);
91
+ settle(() => onMutedTypesChange(device.id, next)).then(
92
+ () => {
93
+ if (mounted.current) mutedOverlay.settle(key, true);
94
+ },
95
+ (error) => {
96
+ if (!mounted.current) return;
97
+ mutedOverlay.settle(key, false);
98
+ setFailure(describeFailure(describeError?.(error), labels.failed));
99
+ }
100
+ );
101
+ };
102
+ const typesOf = (device, name) => {
103
+ if (!onMutedTypesChange) return null;
104
+ const muted = mutedOf(device);
105
+ return /* @__PURE__ */ jsx(
106
+ Disclosure,
107
+ {
108
+ variant: "bare",
109
+ title: labels.deviceTypes,
110
+ triggerProps: { "aria-label": `${labels.deviceTypes}: ${name}` },
111
+ className: "text-sm",
112
+ "data-device-types": "",
113
+ children: /* @__PURE__ */ jsx("div", { className: "space-y-2 pt-1 ps-6", children: pushTypes.length === 0 ? /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.deviceTypesEmpty }) : /* @__PURE__ */ jsxs(Fragment, { children: [
114
+ /* @__PURE__ */ jsx("p", { className: CARD_DESCRIPTION_CLASS, children: labels.deviceTypesDescription }),
115
+ pushTypes.map((entry) => /* @__PURE__ */ jsx(
116
+ Switch,
117
+ {
118
+ size: "sm",
119
+ label: entry.label,
120
+ checked: !muted.includes(entry.id),
121
+ commit: COMMIT_EXCEPT_BILLING,
122
+ onCheckedChange: (on) => setMuted(device, entry.id, on)
123
+ },
124
+ entry.id
125
+ ))
126
+ ] }) })
127
+ }
128
+ );
129
+ };
75
130
  let body;
76
131
  if (loading || devices === void 0) {
77
132
  body = /* @__PURE__ */ jsx(Skeleton, { lines: 2, label: labels.devicesLoading });
@@ -93,7 +148,8 @@ function PushDevicesSetting({
93
148
  onCancel: () => setAsking(null),
94
149
  onConfirm: () => remove(device),
95
150
  labels,
96
- cancelLabel: common.cancel
151
+ cancelLabel: common.cancel,
152
+ types: typesOf(device, describeUserAgent(device.user_agent) ?? labels.unknownDevice)
97
153
  },
98
154
  device.id
99
155
  )) });
@@ -120,7 +176,8 @@ function DeviceRow({
120
176
  onCancel,
121
177
  onConfirm,
122
178
  labels,
123
- cancelLabel
179
+ cancelLabel,
180
+ types
124
181
  }) {
125
182
  const cancelRef = useRef(null);
126
183
  const removeRef = useRef(null);
@@ -163,37 +220,40 @@ function DeviceRow({
163
220
  ] })
164
221
  ] });
165
222
  }
166
- return /* @__PURE__ */ jsxs("li", { ...row, className: "flex items-center gap-3 py-2", children: [
167
- /* @__PURE__ */ jsx(MonitorSmartphone, { "aria-hidden": true, className: "size-4 shrink-0 text-muted" }),
168
- /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
169
- /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
170
- /* @__PURE__ */ jsx("span", { className: "min-w-0 break-words text-sm font-medium", children: name }),
171
- current && /* @__PURE__ */ jsx(Chip, { size: "sm", tone: "brand", children: labels.thisDevice })
172
- ] }),
173
- /* @__PURE__ */ jsxs("div", { className: CARD_DESCRIPTION_CLASS, children: [
174
- labels.added(added),
175
- " \xB7 ",
176
- lastDelivery ? labels.lastDelivery(lastDelivery) : labels.noDelivery
223
+ return /* @__PURE__ */ jsxs("li", { ...row, className: "space-y-1 py-2", children: [
224
+ /* @__PURE__ */ jsxs("div", { className: "flex items-center gap-3", children: [
225
+ /* @__PURE__ */ jsx(MonitorSmartphone, { "aria-hidden": true, className: "size-4 shrink-0 text-muted" }),
226
+ /* @__PURE__ */ jsxs("div", { className: "min-w-0 flex-1", children: [
227
+ /* @__PURE__ */ jsxs("div", { className: "flex flex-wrap items-center gap-x-2 gap-y-1", children: [
228
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 break-words text-sm font-medium", children: name }),
229
+ current && /* @__PURE__ */ jsx(Chip, { size: "sm", tone: "brand", children: labels.thisDevice })
230
+ ] }),
231
+ /* @__PURE__ */ jsxs("div", { className: CARD_DESCRIPTION_CLASS, children: [
232
+ labels.added(added),
233
+ " \xB7 ",
234
+ lastDelivery ? labels.lastDelivery(lastDelivery) : labels.noDelivery
235
+ ] }),
236
+ device.failure_count > 0 && /* @__PURE__ */ jsx("div", { className: "text-xs text-warning", children: labels.failures(device.failure_count) })
177
237
  ] }),
178
- device.failure_count > 0 && /* @__PURE__ */ jsx("div", { className: "text-xs text-warning", children: labels.failures(device.failure_count) })
238
+ /* @__PURE__ */ jsx(
239
+ Button,
240
+ {
241
+ ref: removeRef,
242
+ type: "button",
243
+ size: "sm",
244
+ variant: "ghost",
245
+ commit: COMMIT_EXCEPT_BILLING,
246
+ disabled: blocked,
247
+ "aria-label": labels.removeItem(name),
248
+ onClick: () => {
249
+ setReturning(false);
250
+ onAsk();
251
+ },
252
+ children: labels.remove
253
+ }
254
+ )
179
255
  ] }),
180
- /* @__PURE__ */ jsx(
181
- Button,
182
- {
183
- ref: removeRef,
184
- type: "button",
185
- size: "sm",
186
- variant: "ghost",
187
- commit: COMMIT_EXCEPT_BILLING,
188
- disabled: blocked,
189
- "aria-label": labels.removeItem(name),
190
- onClick: () => {
191
- setReturning(false);
192
- onAsk();
193
- },
194
- children: labels.remove
195
- }
196
- )
256
+ types
197
257
  ] });
198
258
  }
199
259
  export {
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/notifications/push-devices-setting.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, KeyboardEvent, ReactNode } from \"react\";\nimport { MonitorSmartphone } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { formatDate } from \"../lib/format\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { Chip } from \"../components/chip\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport type { PushDeviceItem } from \"./notification-types\";\nimport { notifyPushSubscriptionChanged } from \"./use-push-device\";\n\n/**\n * A name for a stored user agent: \"Chrome · Android\", \"Firefox · Windows\" (keksdose\n * `push-devices-card.tsx:19-45`). Best effort: an agent it does not recognise comes back\n * as it is, cut at 60 characters so a token soup cannot blow up the row; `null` for none.\n * The order matters — Edge and Opera say \"Chrome\" too, and Chrome says \"Safari\".\n */\nexport function describeUserAgent(ua: string | null): string | null {\n if (!ua) return null;\n const browser = /edg(?:e|a|ios)?\\//i.test(ua)\n ? \"Edge\"\n : /opr\\/|opera/i.test(ua)\n ? \"Opera\"\n : /firefox|fxios/i.test(ua)\n ? \"Firefox\"\n : /chrome|crios/i.test(ua)\n ? \"Chrome\"\n : /safari/i.test(ua)\n ? \"Safari\"\n : null;\n const os = /windows/i.test(ua)\n ? \"Windows\"\n : /android/i.test(ua)\n ? \"Android\"\n : /iphone|ipad|ipod/i.test(ua)\n ? \"iOS\"\n : /mac os x|macintosh/i.test(ua)\n ? \"macOS\"\n : /linux/i.test(ua)\n ? \"Linux\"\n : null;\n if (!browser && !os) return ua.length > 60 ? `${ua.slice(0, 60)}…` : ua;\n return [browser, os].filter(Boolean).join(\" · \");\n}\n\nexport interface PushDevicesSettingProps<Id extends string | number = string>\n extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** `GET /notifications/devices`, oldest first; `undefined` while the first load runs. */\n devices: readonly PushDeviceItem<Id>[] | undefined;\n loading?: boolean;\n /** This browser's endpoint (`usePushDevice().currentEndpoint`): its row says \"This\n * device\", and removing it also unsubscribes the browser. */\n currentEndpoint?: string | null;\n /** `DELETE /notifications/devices/{id}`. Asked first; refresh `devices` once it\n * resolves. */\n onRemove: (id: Id) => Promise<unknown> | void;\n /** The dates' text. Default: the provider's locale, medium date. */\n formatDate?: (date: Date) => string;\n /** Overrides the provider's locale for the default format. */\n locale?: string;\n /** The app's own words for a failed removal, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown) => ReactNode | undefined;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** Tear down this browser's subscription after its server row went: otherwise the\n * browser still holds one, and the push card would say \"on\" for a device nothing can\n * reach. Best effort — the row is already gone. */\nasync function unsubscribeThisBrowser(): Promise<void> {\n try {\n const registration = await navigator.serviceWorker?.getRegistration();\n const subscription = await registration?.pushManager.getSubscription();\n await subscription?.unsubscribe();\n } catch {\n /* the server row is gone either way */\n }\n notifyPushSubscriptionChanged();\n}\n\n/**\n * Every device that gets push for the account (docs/notifications-harmonization.md §3.5,\n * §4.2) — keksdose's devices card: the browser and system read from the stored user\n * agent, \"This device\" on this browser's row, when it was added and last delivered to,\n * the failures in a row in the warning tone, and \"Remove\".\n *\n * **Remove asks first, in the row**, as `PasskeysSetting` does: the card must work in an\n * app without a `ConfirmProvider`, and the question belongs beside the device it names.\n * Focus moves to Cancel. **Removing this device** also unsubscribes the browser and fires\n * `PUSH_SUBSCRIPTION_CHANGED` (keksdose `push-devices-card.tsx:83-97`), so the push card\n * stops saying \"on\".\n *\n * Under a write lock Remove is a `commit` control exempt from billing.\n */\nexport function PushDevicesSetting<Id extends string | number = string>({\n devices,\n loading,\n currentEndpoint,\n onRemove,\n formatDate: formatDateProp,\n locale: localeProp,\n describeError,\n labels: labelsProp,\n className,\n ...rest\n}: PushDevicesSettingProps<Id>) {\n const labels = useNotificationsLabels(labelsProp);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const locale = useKitLocale(localeProp);\n const [asking, setAsking] = useState<Id | null>(null);\n const [busyId, setBusyId] = useState<Id | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n\n const dateText = (iso: string): string => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return iso;\n return formatDateProp ? formatDateProp(date) : formatDate(date, \"medium\", { locale });\n };\n\n const remove = (device: PushDeviceItem<Id>) => {\n if (busyId !== null) return;\n setBusyId(device.id);\n setFailure(null);\n const isThis = Boolean(currentEndpoint) && device.endpoint === currentEndpoint;\n settle(() => onRemove(device.id))\n .then(async () => {\n if (isThis) await unsubscribeThisBrowser();\n if (!mounted.current) return;\n setBusyId(null);\n setAsking(null);\n })\n .catch((error: unknown) => {\n if (!mounted.current) return;\n setBusyId(null);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n });\n };\n\n let body: ReactNode;\n if (loading || devices === undefined) {\n body = <Skeleton lines={2} label={labels.devicesLoading} />;\n } else if (devices.length === 0) {\n body = <p className={CARD_DESCRIPTION_CLASS}>{labels.devicesEmpty}</p>;\n } else {\n body = (\n <ul aria-label={labels.devicesTitle} className=\"divide-y divide-subtle\">\n {devices.map((device) => (\n <DeviceRow\n key={device.id}\n device={device}\n name={describeUserAgent(device.user_agent) ?? labels.unknownDevice}\n current={Boolean(currentEndpoint) && device.endpoint === currentEndpoint}\n added={dateText(device.created_at)}\n lastDelivery={device.last_success_at ? dateText(device.last_success_at) : null}\n asking={asking === device.id}\n busy={busyId === device.id}\n blocked={busyId !== null && busyId !== device.id}\n onAsk={() => setAsking(device.id)}\n onCancel={() => setAsking(null)}\n onConfirm={() => remove(device)}\n labels={labels}\n cancelLabel={common.cancel}\n />\n ))}\n </ul>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.devicesTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.devicesDescription}</div>\n </div>\n {body}\n <FailureLine>{failure}</FailureLine>\n </Card>\n );\n}\n\nfunction DeviceRow<Id extends string | number>({\n device,\n name,\n current,\n added,\n lastDelivery,\n asking,\n busy,\n blocked,\n onAsk,\n onCancel,\n onConfirm,\n labels,\n cancelLabel,\n}: {\n device: PushDeviceItem<Id>;\n name: string;\n current: boolean;\n added: string;\n lastDelivery: string | null;\n asking: boolean;\n busy: boolean;\n blocked: boolean;\n onAsk: () => void;\n onCancel: () => void;\n onConfirm: () => void;\n labels: NotificationsLabels;\n cancelLabel: string;\n}) {\n const cancelRef = useRef<HTMLButtonElement>(null);\n const removeRef = useRef<HTMLButtonElement>(null);\n // Which way the confirm closed: back to Remove, so focus does not fall to <body>.\n const [returning, setReturning] = useState(false);\n useEffect(() => {\n if (asking) cancelRef.current?.focus();\n else if (returning) removeRef.current?.focus();\n }, [asking, returning]);\n\n const leave = () => {\n setReturning(true);\n onCancel();\n };\n const escapeLeaves = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n leave();\n }\n };\n\n const row = { \"data-push-device-id\": String(device.id), \"data-current\": current || undefined };\n\n if (asking) {\n return (\n <li {...row} className=\"space-y-2 py-2\">\n <p role=\"alert\" className=\"text-sm\">\n {labels.removePrompt}\n </p>\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"danger\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={busy}\n aria-label={labels.removeItem(name)}\n onClick={onConfirm}\n onKeyDown={escapeLeaves}\n >\n {labels.remove}\n </Button>\n <Button ref={cancelRef} type=\"button\" size=\"sm\" variant=\"ghost\" onClick={leave} onKeyDown={escapeLeaves}>\n {cancelLabel}\n </Button>\n </div>\n </li>\n );\n }\n\n return (\n <li {...row} className=\"flex items-center gap-3 py-2\">\n <MonitorSmartphone aria-hidden className=\"size-4 shrink-0 text-muted\" />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n <span className=\"min-w-0 break-words text-sm font-medium\">{name}</span>\n {current && (\n <Chip size=\"sm\" tone=\"brand\">\n {labels.thisDevice}\n </Chip>\n )}\n </div>\n <div className={CARD_DESCRIPTION_CLASS}>\n {labels.added(added)}\n {\" · \"}\n {lastDelivery ? labels.lastDelivery(lastDelivery) : labels.noDelivery}\n </div>\n {device.failure_count > 0 && <div className=\"text-xs text-warning\">{labels.failures(device.failure_count)}</div>}\n </div>\n <Button\n ref={removeRef}\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit={COMMIT_EXCEPT_BILLING}\n disabled={blocked}\n aria-label={labels.removeItem(name)}\n onClick={() => {\n setReturning(false);\n onAsk();\n }}\n >\n {labels.remove}\n </Button>\n </li>\n );\n}\n"],"mappings":";AAsJW,cA8BL,YA9BK;AAtJX,SAAS,WAAW,QAAQ,gBAAgB;AAE5C,SAAS,yBAAyB;AAElC,SAAS,cAAc,oBAAwC;AAC/D,SAAS,6BAA6B;AACtC,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,gBAAgB;AACzB,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AAClC,SAAS,QAAQ,kBAAkB;AACnC,SAAS,iBAAiB,aAAa,8BAA8B;AAGrE,SAAS,qCAAqC;AAQvC,SAAS,kBAAkB,IAAkC;AAClE,MAAI,CAAC,GAAI,QAAO;AAChB,QAAM,UAAU,qBAAqB,KAAK,EAAE,IACxC,SACA,eAAe,KAAK,EAAE,IACpB,UACA,iBAAiB,KAAK,EAAE,IACtB,YACA,gBAAgB,KAAK,EAAE,IACrB,WACA,UAAU,KAAK,EAAE,IACf,WACA;AACZ,QAAM,KAAK,WAAW,KAAK,EAAE,IACzB,YACA,WAAW,KAAK,EAAE,IAChB,YACA,oBAAoB,KAAK,EAAE,IACzB,QACA,sBAAsB,KAAK,EAAE,IAC3B,UACA,SAAS,KAAK,EAAE,IACd,UACA;AACZ,MAAI,CAAC,WAAW,CAAC,GAAI,QAAO,GAAG,SAAS,KAAK,GAAG,GAAG,MAAM,GAAG,EAAE,CAAC,WAAM;AACrE,SAAO,CAAC,SAAS,EAAE,EAAE,OAAO,OAAO,EAAE,KAAK,QAAK;AACjD;AAyBA,eAAe,yBAAwC;AACrD,MAAI;AACF,UAAM,eAAe,MAAM,UAAU,eAAe,gBAAgB;AACpE,UAAM,eAAe,MAAM,cAAc,YAAY,gBAAgB;AACrE,UAAM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AAK,WAAU,2CAA2C,gBAAK;AAAA,QAC/D,WACC,oBAAC,QAAK,MAAK,MAAK,MAAK,SAClB,iBAAO,YACV;AAAA,SAEJ;AAAA,MACA,qBAAC,SAAI,WAAW,wBACb;AAAA,eAAO,MAAM,KAAK;AAAA,QAClB;AAAA,QACA,eAAe,OAAO,aAAa,YAAY,IAAI,OAAO;AAAA,SAC7D;AAAA,MACC,OAAO,gBAAgB,KAAK,oBAAC,SAAI,WAAU,wBAAwB,iBAAO,SAAS,OAAO,aAAa,GAAE;AAAA,OAC5G;AAAA,IACA;AAAA,MAAC;AAAA;AAAA,QACC,KAAK;AAAA,QACL,MAAK;AAAA,QACL,MAAK;AAAA,QACL,SAAQ;AAAA,QACR,QAAQ;AAAA,QACR,UAAU;AAAA,QACV,cAAY,OAAO,WAAW,IAAI;AAAA,QAClC,SAAS,MAAM;AACb,uBAAa,KAAK;AAClB,gBAAM;AAAA,QACR;AAAA,QAEC,iBAAO;AAAA;AAAA,IACV;AAAA,KACF;AAEJ;","names":[]}
1
+ {"version":3,"sources":["../../src/notifications/push-devices-setting.tsx"],"sourcesContent":["import { useEffect, useRef, useState } from \"react\";\nimport type { ComponentPropsWithRef, KeyboardEvent, ReactNode } from \"react\";\nimport { MonitorSmartphone } from \"lucide-react\";\n\nimport { useKitLabels, useKitLocale, type LabelOverride } from \"../i18n/kit-labels\";\nimport { DEFAULT_COMMON_LABELS } from \"../i18n/shared-labels\";\nimport { cn } from \"../lib/cn\";\nimport { formatDate } from \"../lib/format\";\nimport { Button } from \"../components/button\";\nimport { Card } from \"../components/card\";\nimport { Chip } from \"../components/chip\";\nimport { Disclosure } from \"../components/disclosure\";\nimport { Skeleton } from \"../components/skeleton\";\nimport { Switch } from \"../components/switch\";\nimport { COMMIT_EXCEPT_BILLING } from \"../components/write-lock\";\nimport { CARD_DESCRIPTION_CLASS } from \"../settings/settings-card-classes\";\nimport { SettingsCardTitle } from \"../settings/settings-heading\";\nimport { settle, useMounted } from \"../account/account-parts\";\nimport { describeFailure, FailureLine, useNotificationsLabels, useWriteOverlay } from \"./notification-parts\";\nimport type { NotificationsLabels } from \"./notifications-labels\";\nimport type { NotificationTypeEntry, NotificationTypesValue, PushDeviceItem } from \"./notification-types\";\nimport { notifyPushSubscriptionChanged } from \"./use-push-device\";\n\n/**\n * A name for a stored user agent: \"Chrome · Android\", \"Firefox · Windows\" (keksdose\n * `push-devices-card.tsx:19-45`). Best effort: an agent it does not recognise comes back\n * as it is, cut at 60 characters so a token soup cannot blow up the row; `null` for none.\n * The order matters — Edge and Opera say \"Chrome\" too, and Chrome says \"Safari\".\n */\nexport function describeUserAgent(ua: string | null): string | null {\n if (!ua) return null;\n const browser = /edg(?:e|a|ios)?\\//i.test(ua)\n ? \"Edge\"\n : /opr\\/|opera/i.test(ua)\n ? \"Opera\"\n : /firefox|fxios/i.test(ua)\n ? \"Firefox\"\n : /chrome|crios/i.test(ua)\n ? \"Chrome\"\n : /safari/i.test(ua)\n ? \"Safari\"\n : null;\n const os = /windows/i.test(ua)\n ? \"Windows\"\n : /android/i.test(ua)\n ? \"Android\"\n : /iphone|ipad|ipod/i.test(ua)\n ? \"iOS\"\n : /mac os x|macintosh/i.test(ua)\n ? \"macOS\"\n : /linux/i.test(ua)\n ? \"Linux\"\n : null;\n if (!browser && !os) return ua.length > 60 ? `${ua.slice(0, 60)}…` : ua;\n return [browser, os].filter(Boolean).join(\" · \");\n}\n\nexport interface PushDevicesSettingProps<Id extends string | number = string>\n extends Omit<ComponentPropsWithRef<\"div\">, \"children\"> {\n /** `GET /notifications/devices`, oldest first; `undefined` while the first load runs. */\n devices: readonly PushDeviceItem<Id>[] | undefined;\n loading?: boolean;\n /** This browser's endpoint (`usePushDevice().currentEndpoint`): its row says \"This\n * device\", and removing it also unsubscribes the browser. */\n currentEndpoint?: string | null;\n /** `DELETE /notifications/devices/{id}`. Asked first; refresh `devices` once it\n * resolves. */\n onRemove: (id: Id) => Promise<unknown> | void;\n /** The dates' text. Default: the provider's locale, medium date. */\n formatDate?: (date: Date) => string;\n /** Overrides the provider's locale for the default format. */\n locale?: string;\n /** The app's own words for a failed removal, or `undefined` for the kit's `failed`. */\n describeError?: (error: unknown) => ReactNode | undefined;\n /**\n * 0.46 (§10.2): \"Types on this device\" on each row — a switch per type whose account\n * `push` is on, all on until the device mutes one. Save the device's WHOLE list:\n * `PATCH /notifications/devices/{id} {\"muted_types\": [...]}`; refresh `devices` once it\n * resolves. Left out, no row has the disclosure.\n */\n onMutedTypesChange?: (id: Id, mutedTypes: string[]) => Promise<unknown> | void;\n /** The app's words for its types (the types card's `types`), for the disclosure. */\n types?: readonly NotificationTypeEntry[];\n /** The settings `GET`'s `types` (the types card's `value`): which types have push on. */\n typeSwitches?: NotificationTypesValue;\n labels?: LabelOverride<NotificationsLabels>;\n}\n\n/** Tear down this browser's subscription after its server row went: otherwise the\n * browser still holds one, and the push card would say \"on\" for a device nothing can\n * reach. Best effort — the row is already gone. */\nasync function unsubscribeThisBrowser(): Promise<void> {\n try {\n const registration = await navigator.serviceWorker?.getRegistration();\n const subscription = await registration?.pushManager.getSubscription();\n await subscription?.unsubscribe();\n } catch {\n /* the server row is gone either way */\n }\n notifyPushSubscriptionChanged();\n}\n\n/**\n * Every device that gets push for the account (docs/notifications-harmonization.md §3.5,\n * §4.2) — keksdose's devices card: the browser and system read from the stored user\n * agent, \"This device\" on this browser's row, when it was added and last delivered to,\n * the failures in a row in the warning tone, and \"Remove\".\n *\n * **Remove asks first, in the row**, as `PasskeysSetting` does: the card must work in an\n * app without a `ConfirmProvider`, and the question belongs beside the device it names.\n * Focus moves to Cancel. **Removing this device** also unsubscribes the browser and fires\n * `PUSH_SUBSCRIPTION_CHANGED` (keksdose `push-devices-card.tsx:83-97`), so the push card\n * stops saying \"on\".\n *\n * **\"Types on this device\"** (0.46, §10.2, with `onMutedTypesChange`): a disclosure under\n * each row with a switch per type the account gets by push; turning one off mutes it on\n * that device only — a device can mute types, never add them. Each flip saves the\n * device's whole `muted_types` list.\n *\n * Under a write lock Remove and the type switches are `commit` controls exempt from\n * billing.\n */\nexport function PushDevicesSetting<Id extends string | number = string>({\n devices,\n loading,\n currentEndpoint,\n onRemove,\n formatDate: formatDateProp,\n locale: localeProp,\n describeError,\n onMutedTypesChange,\n types,\n typeSwitches,\n labels: labelsProp,\n className,\n ...rest\n}: PushDevicesSettingProps<Id>) {\n const labels = useNotificationsLabels(labelsProp);\n const mutedOverlay = useWriteOverlay<string[]>(devices);\n const common = useKitLabels(\"common\", DEFAULT_COMMON_LABELS);\n const locale = useKitLocale(localeProp);\n const [asking, setAsking] = useState<Id | null>(null);\n const [busyId, setBusyId] = useState<Id | null>(null);\n const [failure, setFailure] = useState<ReactNode>(null);\n const mounted = useMounted();\n\n const dateText = (iso: string): string => {\n const date = new Date(iso);\n if (Number.isNaN(date.getTime())) return iso;\n return formatDateProp ? formatDateProp(date) : formatDate(date, \"medium\", { locale });\n };\n\n const remove = (device: PushDeviceItem<Id>) => {\n if (busyId !== null) return;\n setBusyId(device.id);\n setFailure(null);\n const isThis = Boolean(currentEndpoint) && device.endpoint === currentEndpoint;\n settle(() => onRemove(device.id))\n .then(async () => {\n if (isThis) await unsubscribeThisBrowser();\n if (!mounted.current) return;\n setBusyId(null);\n setAsking(null);\n })\n .catch((error: unknown) => {\n if (!mounted.current) return;\n setBusyId(null);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n });\n };\n\n // The types a device can mute: those the account gets by push, in the app's order.\n const pushTypes = (types ?? []).filter((entry) => typeSwitches?.[entry.id]?.push === true);\n const mutedOf = (device: PushDeviceItem<Id>): string[] =>\n mutedOverlay.get(String(device.id)) ??\n // Ids the registry dropped (no longer in the settings answer) are ignored.\n (device.muted_types ?? []).filter((id) => !typeSwitches || id in typeSwitches);\n const setMuted = (device: PushDeviceItem<Id>, id: string, on: boolean) => {\n const key = String(device.id);\n if (!onMutedTypesChange || mutedOverlay.pending(key)) return;\n const current = mutedOf(device);\n const next = on ? current.filter((muted) => muted !== id) : [...current.filter((muted) => muted !== id), id];\n setFailure(null);\n mutedOverlay.set(key, next);\n settle(() => onMutedTypesChange(device.id, next)).then(\n () => {\n if (mounted.current) mutedOverlay.settle(key, true);\n },\n (error: unknown) => {\n if (!mounted.current) return;\n mutedOverlay.settle(key, false);\n setFailure(describeFailure(describeError?.(error), labels.failed));\n },\n );\n };\n const typesOf = (device: PushDeviceItem<Id>, name: string): ReactNode => {\n if (!onMutedTypesChange) return null;\n const muted = mutedOf(device);\n return (\n <Disclosure\n variant=\"bare\"\n title={labels.deviceTypes}\n // Every row has one: the name says whose (it starts with the visible words).\n triggerProps={{ \"aria-label\": `${labels.deviceTypes}: ${name}` }}\n className=\"text-sm\"\n data-device-types=\"\"\n >\n <div className=\"space-y-2 pt-1 ps-6\">\n {pushTypes.length === 0 ? (\n <p className={CARD_DESCRIPTION_CLASS}>{labels.deviceTypesEmpty}</p>\n ) : (\n <>\n <p className={CARD_DESCRIPTION_CLASS}>{labels.deviceTypesDescription}</p>\n {pushTypes.map((entry) => (\n <Switch\n key={entry.id}\n size=\"sm\"\n label={entry.label}\n checked={!muted.includes(entry.id)}\n commit={COMMIT_EXCEPT_BILLING}\n onCheckedChange={(on) => setMuted(device, entry.id, on)}\n />\n ))}\n </>\n )}\n </div>\n </Disclosure>\n );\n };\n\n let body: ReactNode;\n if (loading || devices === undefined) {\n body = <Skeleton lines={2} label={labels.devicesLoading} />;\n } else if (devices.length === 0) {\n body = <p className={CARD_DESCRIPTION_CLASS}>{labels.devicesEmpty}</p>;\n } else {\n body = (\n <ul aria-label={labels.devicesTitle} className=\"divide-y divide-subtle\">\n {devices.map((device) => (\n <DeviceRow\n key={device.id}\n device={device}\n name={describeUserAgent(device.user_agent) ?? labels.unknownDevice}\n current={Boolean(currentEndpoint) && device.endpoint === currentEndpoint}\n added={dateText(device.created_at)}\n lastDelivery={device.last_success_at ? dateText(device.last_success_at) : null}\n asking={asking === device.id}\n busy={busyId === device.id}\n blocked={busyId !== null && busyId !== device.id}\n onAsk={() => setAsking(device.id)}\n onCancel={() => setAsking(null)}\n onConfirm={() => remove(device)}\n labels={labels}\n cancelLabel={common.cancel}\n types={typesOf(device, describeUserAgent(device.user_agent) ?? labels.unknownDevice)}\n />\n ))}\n </ul>\n );\n }\n\n return (\n <Card {...rest} className={cn(\"p-4 space-y-3\", className)}>\n <div>\n <SettingsCardTitle>{labels.devicesTitle}</SettingsCardTitle>\n <div className={CARD_DESCRIPTION_CLASS}>{labels.devicesDescription}</div>\n </div>\n {body}\n <FailureLine>{failure}</FailureLine>\n </Card>\n );\n}\n\nfunction DeviceRow<Id extends string | number>({\n device,\n name,\n current,\n added,\n lastDelivery,\n asking,\n busy,\n blocked,\n onAsk,\n onCancel,\n onConfirm,\n labels,\n cancelLabel,\n types,\n}: {\n device: PushDeviceItem<Id>;\n name: string;\n current: boolean;\n added: string;\n lastDelivery: string | null;\n asking: boolean;\n busy: boolean;\n blocked: boolean;\n onAsk: () => void;\n onCancel: () => void;\n onConfirm: () => void;\n labels: NotificationsLabels;\n cancelLabel: string;\n /** \"Types on this device\", under the row (0.46). */\n types: ReactNode;\n}) {\n const cancelRef = useRef<HTMLButtonElement>(null);\n const removeRef = useRef<HTMLButtonElement>(null);\n // Which way the confirm closed: back to Remove, so focus does not fall to <body>.\n const [returning, setReturning] = useState(false);\n useEffect(() => {\n if (asking) cancelRef.current?.focus();\n else if (returning) removeRef.current?.focus();\n }, [asking, returning]);\n\n const leave = () => {\n setReturning(true);\n onCancel();\n };\n const escapeLeaves = (event: KeyboardEvent<HTMLButtonElement>) => {\n if (event.key === \"Escape\") {\n event.preventDefault();\n event.stopPropagation();\n leave();\n }\n };\n\n const row = { \"data-push-device-id\": String(device.id), \"data-current\": current || undefined };\n\n if (asking) {\n return (\n <li {...row} className=\"space-y-2 py-2\">\n <p role=\"alert\" className=\"text-sm\">\n {labels.removePrompt}\n </p>\n <div className=\"flex flex-wrap gap-2\">\n <Button\n type=\"button\"\n size=\"sm\"\n variant=\"danger\"\n commit={COMMIT_EXCEPT_BILLING}\n pending={busy}\n aria-label={labels.removeItem(name)}\n onClick={onConfirm}\n onKeyDown={escapeLeaves}\n >\n {labels.remove}\n </Button>\n <Button ref={cancelRef} type=\"button\" size=\"sm\" variant=\"ghost\" onClick={leave} onKeyDown={escapeLeaves}>\n {cancelLabel}\n </Button>\n </div>\n </li>\n );\n }\n\n return (\n <li {...row} className=\"space-y-1 py-2\">\n <div className=\"flex items-center gap-3\">\n <MonitorSmartphone aria-hidden className=\"size-4 shrink-0 text-muted\" />\n <div className=\"min-w-0 flex-1\">\n <div className=\"flex flex-wrap items-center gap-x-2 gap-y-1\">\n <span className=\"min-w-0 break-words text-sm font-medium\">{name}</span>\n {current && (\n <Chip size=\"sm\" tone=\"brand\">\n {labels.thisDevice}\n </Chip>\n )}\n </div>\n <div className={CARD_DESCRIPTION_CLASS}>\n {labels.added(added)}\n {\" · \"}\n {lastDelivery ? labels.lastDelivery(lastDelivery) : labels.noDelivery}\n </div>\n {device.failure_count > 0 && <div className=\"text-xs text-warning\">{labels.failures(device.failure_count)}</div>}\n </div>\n <Button\n ref={removeRef}\n type=\"button\"\n size=\"sm\"\n variant=\"ghost\"\n commit={COMMIT_EXCEPT_BILLING}\n disabled={blocked}\n aria-label={labels.removeItem(name)}\n onClick={() => {\n setReturning(false);\n onAsk();\n }}\n >\n {labels.remove}\n </Button>\n </div>\n {types}\n </li>\n );\n}\n"],"mappings":";AAiNY,SAEA,UAFA,KAEA,YAFA;AAjNZ,SAAS,WAAW,QAAQ,gBAAgB;AAE5C,SAAS,yBAAyB;AAElC,SAAS,cAAc,oBAAwC;AAC/D,SAAS,6BAA6B;AACtC,SAAS,UAAU;AACnB,SAAS,kBAAkB;AAC3B,SAAS,cAAc;AACvB,SAAS,YAAY;AACrB,SAAS,YAAY;AACrB,SAAS,kBAAkB;AAC3B,SAAS,gBAAgB;AACzB,SAAS,cAAc;AACvB,SAAS,6BAA6B;AACtC,SAAS,8BAA8B;AACvC,SAAS,yBAAyB;AA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AAA,yBAAC,SAAI,WAAU,2BACb;AAAA,0BAAC,qBAAkB,eAAW,MAAC,WAAU,8BAA6B;AAAA,MACtE,qBAAC,SAAI,WAAU,kBACb;AAAA,6BAAC,SAAI,WAAU,+CACb;AAAA,8BAAC,UAAK,WAAU,2CAA2C,gBAAK;AAAA,UAC/D,WACC,oBAAC,QAAK,MAAK,MAAK,MAAK,SAClB,iBAAO,YACV;AAAA,WAEJ;AAAA,QACA,qBAAC,SAAI,WAAW,wBACb;AAAA,iBAAO,MAAM,KAAK;AAAA,UAClB;AAAA,UACA,eAAe,OAAO,aAAa,YAAY,IAAI,OAAO;AAAA,WAC7D;AAAA,QACC,OAAO,gBAAgB,KAAK,oBAAC,SAAI,WAAU,wBAAwB,iBAAO,SAAS,OAAO,aAAa,GAAE;AAAA,SAC5G;AAAA,MACA;AAAA,QAAC;AAAA;AAAA,UACC,KAAK;AAAA,UACL,MAAK;AAAA,UACL,MAAK;AAAA,UACL,SAAQ;AAAA,UACR,QAAQ;AAAA,UACR,UAAU;AAAA,UACV,cAAY,OAAO,WAAW,IAAI;AAAA,UAClC,SAAS,MAAM;AACb,yBAAa,KAAK;AAClB,kBAAM;AAAA,UACR;AAAA,UAEC,iBAAO;AAAA;AAAA,MACV;AAAA,OACF;AAAA,IACC;AAAA,KACH;AAEJ;","names":[]}
@@ -0,0 +1,108 @@
1
+ /**
2
+ * The service worker's half of Web Push that the kit can own (0.46,
3
+ * docs/notifications-harmonization.md NT:1028): re-registering a subscription the
4
+ * browser ROTATED. A push service may replace a subscription (expiry, a key rotation, a
5
+ * browser update) and fires `pushsubscriptionchange` in the worker; until 0.46 the
6
+ * server kept sending to the old endpoint, got 410, deleted the device, and the person
7
+ * had to turn push on again without knowing why.
8
+ *
9
+ * {@link handlePushSubscriptionChange} listens for the event in the app's worker and
10
+ * calls the app's `replace` — `POST /notifications/devices/replace` (server-kit
11
+ * `PushReplaceIn`): the OLD endpoint and the old subscription's `auth` secret, which only
12
+ * this browser and the server hold, prove the device without a session (a worker has no
13
+ * `Authorization` header to send), and the server moves that row to the new endpoint in
14
+ * place — same account, same device. Open pages are told with a
15
+ * {@link PUSH_SUBSCRIPTION_CHANGED} message, and every mounted `usePushDevice` re-reads.
16
+ *
17
+ * Dependency-free (no React), so an app's worker bundle takes only this file — through
18
+ * the worker-safe subpath `@eifi1/ui-kit/push-worker` (0.46, §10.6 rule 5), not the main
19
+ * barrel, which reaches React and the components:
20
+ *
21
+ * // sw.ts
22
+ * import { handlePushSubscriptionChange } from "@eifi1/ui-kit/push-worker";
23
+ * handlePushSubscriptionChange(self, {
24
+ * pushKey: () => fetch("/api/notifications/push-key").then((r) => r.json()).then((b) => b.key),
25
+ * replace: (body) => fetch("/api/notifications/devices/replace", {
26
+ * method: "POST", headers: { "Content-Type": "application/json" }, body: JSON.stringify(body),
27
+ * }).then((r) => { if (!r.ok) throw new Error(String(r.status)); }),
28
+ * });
29
+ */
30
+ /** What `register` sends: `POST /notifications/devices` (§3.5). */
31
+ export interface PushSubscriptionInput {
32
+ endpoint: string;
33
+ keys: {
34
+ p256dh: string;
35
+ auth: string;
36
+ };
37
+ user_agent: string | null;
38
+ }
39
+ /** What `replace` sends: `POST /notifications/devices/replace` (server-kit
40
+ * `PushReplaceIn`). The endpoint never goes in a URL. */
41
+ export interface PushReplaceInput {
42
+ /** The rotated-away subscription's endpoint. */
43
+ old_endpoint: string;
44
+ /** Its `keys.auth` as registered — the proof that this browser held it. */
45
+ old_auth: string;
46
+ /** The browser's new subscription. */
47
+ subscription: PushSubscriptionInput;
48
+ }
49
+ /** The message a worker posts to its pages after a rotation, and the window event the
50
+ * hooks re-read on — the same name. */
51
+ export declare const PUSH_SUBSCRIPTION_CHANGED = "eifi1:push-subscription-changed";
52
+ /** A VAPID public key (base64url) as the bytes `PushManager.subscribe` wants. */
53
+ export declare function keyBytes(key: string): Uint8Array<ArrayBuffer>;
54
+ /** A subscription's register body, or `null` when the browser handed back an incomplete
55
+ * one. */
56
+ export declare function pushSubscriptionInput(subscription: PushSubscription): PushSubscriptionInput | null;
57
+ /** The `pushsubscriptionchange` event as the worker receives it (not in TypeScript's
58
+ * DOM lib). Either subscription may be missing: Chrome often hands neither. */
59
+ export interface PushSubscriptionChangeEventLike {
60
+ readonly oldSubscription?: PushSubscription | null;
61
+ readonly newSubscription?: PushSubscription | null;
62
+ waitUntil?: (promise: Promise<unknown>) => void;
63
+ }
64
+ export interface PushSubscriptionChangeOptions {
65
+ /** `GET /notifications/push-key` → its `key` — asked only when the browser handed no
66
+ * new subscription and the old one does not carry its key. `""`: push is off. */
67
+ pushKey: () => Promise<string>;
68
+ /** `POST /notifications/devices/replace`. A rejection is the outcome `"failed"`. */
69
+ replace: (input: PushReplaceInput) => Promise<unknown>;
70
+ }
71
+ /**
72
+ * What a rotation came to: `"replaced"` — the server moved the device; `"no_previous"` —
73
+ * the browser named no old subscription (or one without its keys), so there is nothing
74
+ * to prove the device with and the page shows push as off; `"push_off"` — the server has
75
+ * no key; `"incomplete"` — the new subscription has no keys; `"failed"` — `replace` (or
76
+ * the browser's subscribe) threw.
77
+ */
78
+ export type PushResubscribeOutcome = "replaced" | "no_previous" | "push_off" | "incomplete" | "failed";
79
+ /**
80
+ * Re-register after `pushsubscriptionchange`: the browser's new subscription — or, when
81
+ * it handed none, the one it holds now, or a fresh one under the old subscription's key
82
+ * (else `pushKey()`) — sent to `replace` with the old endpoint and its `auth`.
83
+ */
84
+ export declare function resubscribeAfterChange(event: PushSubscriptionChangeEventLike, pushManager: PushManager, options: PushSubscriptionChangeOptions): Promise<PushResubscribeOutcome>;
85
+ /** The parts of a `ServiceWorkerGlobalScope` this needs. */
86
+ export interface PushWorkerScope {
87
+ addEventListener: (type: "pushsubscriptionchange", listener: (event: PushSubscriptionChangeEventLike) => void) => void;
88
+ registration: {
89
+ pushManager: PushManager;
90
+ };
91
+ clients?: {
92
+ matchAll: (options?: {
93
+ type?: "window";
94
+ includeUncontrolled?: boolean;
95
+ }) => Promise<readonly {
96
+ postMessage: (message: unknown) => void;
97
+ }[]>;
98
+ };
99
+ }
100
+ /**
101
+ * Listen for `pushsubscriptionchange` in the app's service worker (`self`) and
102
+ * re-register through {@link resubscribeAfterChange}, holding the worker alive until it
103
+ * is done (`waitUntil`). Then every open page gets `{ type: PUSH_SUBSCRIPTION_CHANGED,
104
+ * outcome }`; `usePushDevice` re-reads on it. `onOutcome` is for the app's own logging.
105
+ */
106
+ export declare function handlePushSubscriptionChange(scope: PushWorkerScope, options: PushSubscriptionChangeOptions & {
107
+ onOutcome?: (outcome: PushResubscribeOutcome) => void;
108
+ }): void;