@wcstack/notification 1.15.0 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.ja.md +100 -1
- package/README.md +98 -1
- package/dist/index.d.ts +7 -2
- package/dist/index.esm.js +57 -0
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +1 -1
- package/dist/index.esm.min.js.map +1 -1
- package/package.json +1 -1
package/README.ja.md
CHANGED
|
@@ -8,7 +8,7 @@ Notifications API をリアクティブな state と state 駆動のコマンド
|
|
|
8
8
|
`@wcstack/state` と組み合わせると、`<wcs-notify>` はパス契約で直接バインドできます:
|
|
9
9
|
|
|
10
10
|
- **command サーフェス**: `request`, `notify`, `close`, `closeAll`
|
|
11
|
-
- **input サーフェス**: `notice`(reactive な表示), `mode`, `body`, `icon`, `badge`, `tag`, `lang`, `dir`, `require-interaction`, `silent`, `renotify`
|
|
11
|
+
- **input サーフェス**: `notice`(reactive な表示), `mode`, `body`, `icon`, `badge`, `tag`, `lang`, `dir`, `require-interaction`, `silent`, `renotify`, `manual`
|
|
12
12
|
- **output state サーフェス**: `permission`, `granted`, `denied`, `prompt`, `unsupported`, `error`, `clicked`, `closed`, `shown`
|
|
13
13
|
|
|
14
14
|
`@wcstack/notification` は [CSBC](https://github.com/csbc-dev/arch/blob/main/README.md)(Core / Shell / Binding Contract)アーキテクチャに従います:
|
|
@@ -90,6 +90,10 @@ npm install @wcstack/notification
|
|
|
90
90
|
|
|
91
91
|
### 4. クリックを読む
|
|
92
92
|
|
|
93
|
+
```html
|
|
94
|
+
<wcs-notify data-wcs="command.notify: $command.notify; eventToken.clicked: opened"></wcs-notify>
|
|
95
|
+
```
|
|
96
|
+
|
|
93
97
|
`clicked` / `closed` / `shown` は `{ tag, data, action }` を運びます。`tag` は通知の識別子(あなたの `options.tag`、省略時は生成された `wcs-<n>`)、`data` は `options.data` に渡した値、`action` は Service Worker のアクションボタン id(コンストラクタ経路では常に `""`)です。
|
|
94
98
|
|
|
95
99
|
完全なデモは `examples/state-notification-chat` を参照。
|
|
@@ -152,13 +156,108 @@ wireNotificationClicks();
|
|
|
152
156
|
| `close(tag)` | `tag` の通知を閉じる。 |
|
|
153
157
|
| `closeAll()` | この要素が表示した全通知を閉じる。 |
|
|
154
158
|
|
|
159
|
+
## `:state()` による CSS スタイリング
|
|
160
|
+
|
|
161
|
+
`<wcs-notify>` は 5 つの boolean 出力ステートを
|
|
162
|
+
[`ElementInternals` の `CustomStateSet`](https://developer.mozilla.org/ja/docs/Web/API/CustomStateSet)
|
|
163
|
+
に反映します。そのため `data-wcs` バインディングやクラスの手動トグルなしに、CSS の
|
|
164
|
+
`:state()` 疑似クラスで直接スタイリングできます。
|
|
165
|
+
|
|
166
|
+
| ステート | on になる条件 |
|
|
167
|
+
|----------|----------------|
|
|
168
|
+
| `granted` | `wcs-notify:permission-change` が `"granted"` で発火 |
|
|
169
|
+
| `denied` | `wcs-notify:permission-change` が `"denied"` で発火 |
|
|
170
|
+
| `prompt` | `wcs-notify:permission-change` が `"prompt"` で発火 |
|
|
171
|
+
| `unsupported` | `wcs-notify:permission-change` が `"unsupported"` で発火 |
|
|
172
|
+
| `error` | `wcs-notify:error` が非 `null` の detail で発火(`null` でクリア) |
|
|
173
|
+
|
|
174
|
+
`granted` / `denied` / `prompt` / `unsupported` は**相互排他群**です:
|
|
175
|
+
`permission-change` イベント 1 回につき 4 つのうち 1 つだけが on になり、
|
|
176
|
+
残り 3 つは同じパスで off にクリアされます。
|
|
177
|
+
|
|
178
|
+
```css
|
|
179
|
+
wcs-notify:state(denied) ~ .fallback { display: block; }
|
|
180
|
+
wcs-notify:state(unsupported) ~ .fallback { display: block; }
|
|
181
|
+
|
|
182
|
+
form:has(wcs-notify:state(error)) .banner { display: block; }
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
属性やクラスと異なり `:state()` は要素の外部から書き込めないため、この出力ステートが
|
|
186
|
+
入力と混同される心配がありません。
|
|
187
|
+
|
|
188
|
+
**対応ブラウザ**(新構文 `:state(x)`): Chrome/Edge 125+、Safari 17.4+、Firefox 126+。
|
|
189
|
+
非対応の環境ではステートが一切 set されないだけです — `:state()` セレクタがマッチしなく
|
|
190
|
+
なりますが、`<wcs-notify>` 自体は通常どおり動作し続けます(graceful degradation・never-throw)。
|
|
191
|
+
|
|
192
|
+
**SSR:** `:state()` は HTML にシリアライズできないため、サーバーレンダリングされた
|
|
193
|
+
マークアップの初期ペイントにはこれらのステートは乗りません(`@wcstack/server` は無改変)。
|
|
194
|
+
ハイドレーション前の見た目を制御したい場合は、代わりに `wcs-notify:not(:defined)` と組み合わせてください。
|
|
195
|
+
|
|
196
|
+
### デバッグ
|
|
197
|
+
|
|
198
|
+
カスタムステートは DevTools の Elements パネルには表示されず、`attachInternals()`
|
|
199
|
+
は同一要素に 2 回呼べないため、コンソールから直接覗く手段がありません。そのための
|
|
200
|
+
デバッグ専用の補助を 2 つ用意しています:
|
|
201
|
+
|
|
202
|
+
- `el.debugStates` — 現在 on になっているステート名の**スナップショット**配列
|
|
203
|
+
(例: `["granted"]`)。`wc-bindable` の一部ではなく(バインド対象ではない)、
|
|
204
|
+
形状も契約として保証されません — デバッグ用途にのみ使ってください。
|
|
205
|
+
- `debug-states` 属性(opt-in・既定 OFF)は、ステート変化を要素の
|
|
206
|
+
`data-wcs-state-granted` / `data-wcs-state-denied` /
|
|
207
|
+
`data-wcs-state-prompt` / `data-wcs-state-unsupported` /
|
|
208
|
+
`data-wcs-state-error` 属性にミラーします。
|
|
209
|
+
Elements パネルを開いておけば、トグルのたびにハイライトされます:
|
|
210
|
+
|
|
211
|
+
```html
|
|
212
|
+
<wcs-notify debug-states></wcs-notify>
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
**CSS は `data-wcs-state-*` ではなく `:state()` に書いてください。** ミラーされた
|
|
216
|
+
属性は、DevTools を開いた状態でステート変化を可視化するためだけのものであり、
|
|
217
|
+
スタイリング用の正式なフックではありません。
|
|
218
|
+
|
|
155
219
|
## 注意・制限
|
|
156
220
|
|
|
157
221
|
- **通知はページより長生きする。** `<wcs-notify>` の切断(または Core の `dispose()`)は購読を解除しますが、開いている通知は**閉じません** —— 通知はページの終了後も残ることが意図です。閉じるには `close` / `closeAll` を使ってください。
|
|
222
|
+
- **`mode` は接続時に固定される。** バックエンドは要素の接続時(`observe(mode)`)に一度だけ選択され、`mode` の `observedAttributes` エントリはありません。接続済みの要素で `mode` 属性を変更しても、要素を再接続(削除して再挿入)するまで効果はありません。
|
|
223
|
+
- **SW バックエンドは `close` を中継しない。** `@wcstack/notification/sw` ヘルパは `notificationclick` のみを配線し、`notificationclose` は配線しません。そのため `sw` バックエンドでは `closed` / `wcs-notify:close` は発火しません(close 用のワーカー越え中継がない)。`clicked` はクリック中継で動作しますが、`closed` は constructor バックエンド限定の信号です。
|
|
158
224
|
- **Push API はスコープ外。** 本パッケージは Notifications API(ローカル通知)をラップします。サーバ起点の Push は別の関心事です。
|
|
159
225
|
- **サイレント失敗(zero-log)。** wcstack のゼロ依存哲学に沿い、`<wcs-notify>` は決してログ出力も throw もしません。API 不在 → `permission = "unsupported"`、未許可や表示失敗 → `error` プロパティ。`error` / `permission` をバインドして反応してください。
|
|
160
226
|
- **SSR(`@wcstack/server`)。** `static hasConnectedCallbackPromise = true` を宣言し `connectedCallbackPromise` を公開するため、サーバレンダラは接続時の権限プローブが解決するまで待ってからスナップショットします。
|
|
161
227
|
|
|
228
|
+
## 設定
|
|
229
|
+
|
|
230
|
+
`<wcs-notify>` はクリック **autoTrigger** を同梱しており、**既定で有効**です。有効な場合、最初に接続した `<wcs-notify>` が document レベルの `click` リスナーを 1 つ設置します。トリガ属性(`data-notifytarget="<id>"`)を持つ要素をクリックすると、その `id` の `<wcs-notify>` の `notify()` が呼ばれます:
|
|
231
|
+
|
|
232
|
+
```html
|
|
233
|
+
<wcs-notify id="app-notify"></wcs-notify>
|
|
234
|
+
<button data-notifytarget="app-notify" data-notifybody="新着メッセージが1件あります">
|
|
235
|
+
通知する
|
|
236
|
+
</button>
|
|
237
|
+
```
|
|
238
|
+
|
|
239
|
+
- タイトルは `data-notifytitle` があればそれ、無ければトリガ要素の trim 済み `textContent`。body は任意の `data-notifybody`。
|
|
240
|
+
- **document 全域**のクリックリスナーが既定で設置されるため、ショートカットを使わないなら無効化してください。設定は `bootstrapNotification(userConfig?)`(要素登録と設定適用を 1 回で行う)で適用し、`getConfig()` で実効設定(deep-frozen)を読み取れます:
|
|
241
|
+
|
|
242
|
+
```js
|
|
243
|
+
import { bootstrapNotification, getConfig } from "@wcstack/notification";
|
|
244
|
+
|
|
245
|
+
// <wcs-notify> を登録しつつ document クリックリスナーを無効化:
|
|
246
|
+
bootstrapNotification({ autoTrigger: false });
|
|
247
|
+
// あるいはトリガ属性名を変更:
|
|
248
|
+
bootstrapNotification({ triggerAttribute: "data-notify" });
|
|
249
|
+
|
|
250
|
+
getConfig(); // deep-frozen の実効設定を読む
|
|
251
|
+
```
|
|
252
|
+
|
|
253
|
+
| 設定キー | 型 | 既定 | 説明 |
|
|
254
|
+
| ------------------ | --------- | ------------------- | ------------------------------------------------------------------ |
|
|
255
|
+
| `autoTrigger` | `boolean` | `true` | `data-notifytarget` 用の document レベルクリックリスナーを設置。 |
|
|
256
|
+
| `triggerAttribute` | `string` | `data-notifytarget` | クリック要素が `<wcs-notify>` を id で指すのに使う属性。 |
|
|
257
|
+
| `tagNames.notify` | `string` | `wcs-notify` | 登録するカスタム要素タグ名。 |
|
|
258
|
+
|
|
259
|
+
`bootstrapNotification()` は要素が接続される**前に**呼ぶと変更が反映されます。
|
|
260
|
+
|
|
162
261
|
## ヘッドレス利用(`NotificationCore`)
|
|
163
262
|
|
|
164
263
|
Core は DOM 依存が無く、`@wc-bindable/core` の `bind()` と直接使えます:
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@ It is an **async primitive node** that turns the Notifications API into reactive
|
|
|
8
8
|
With `@wcstack/state`, `<wcs-notify>` can be bound directly through path contracts:
|
|
9
9
|
|
|
10
10
|
- **command surface**: `request`, `notify`, `close`, `closeAll`
|
|
11
|
-
- **input surface**: `notice` (reactive show), `mode`, `body`, `icon`, `badge`, `tag`, `lang`, `dir`, `require-interaction`, `silent`, `renotify`
|
|
11
|
+
- **input surface**: `notice` (reactive show), `mode`, `body`, `icon`, `badge`, `tag`, `lang`, `dir`, `require-interaction`, `silent`, `renotify`, `manual`
|
|
12
12
|
- **output state surface**: `permission`, `granted`, `denied`, `prompt`, `unsupported`, `error`, `clicked`, `closed`, `shown`
|
|
13
13
|
|
|
14
14
|
`@wcstack/notification` follows the [CSBC](https://github.com/csbc-dev/arch/blob/main/README.md) (Core / Shell / Binding Contract) architecture:
|
|
@@ -156,13 +156,110 @@ It relays each click over `BroadcastChannel("wcs-notify")` (primary) and `client
|
|
|
156
156
|
| `close(tag)` | Dismiss the notification(s) with `tag`. |
|
|
157
157
|
| `closeAll()` | Dismiss every notification this element has shown. |
|
|
158
158
|
|
|
159
|
+
## CSS styling with `:state()`
|
|
160
|
+
|
|
161
|
+
`<wcs-notify>` reflects five boolean output states onto its
|
|
162
|
+
[`ElementInternals` `CustomStateSet`](https://developer.mozilla.org/en-US/docs/Web/API/CustomStateSet),
|
|
163
|
+
so you can style it directly from CSS with the `:state()` pseudo-class — no
|
|
164
|
+
`data-wcs` binding or extra class toggling required.
|
|
165
|
+
|
|
166
|
+
| State | On when |
|
|
167
|
+
|-------|---------|
|
|
168
|
+
| `granted` | `wcs-notify:permission-change` fires with `"granted"` |
|
|
169
|
+
| `denied` | `wcs-notify:permission-change` fires with `"denied"` |
|
|
170
|
+
| `prompt` | `wcs-notify:permission-change` fires with `"prompt"` |
|
|
171
|
+
| `unsupported` | `wcs-notify:permission-change` fires with `"unsupported"` |
|
|
172
|
+
| `error` | `wcs-notify:error` fires with a non-`null` detail (cleared on `null`) |
|
|
173
|
+
|
|
174
|
+
`granted` / `denied` / `prompt` / `unsupported` are a **mutually exclusive
|
|
175
|
+
group**: each `permission-change` event sets exactly one of the four and
|
|
176
|
+
clears the other three in the same pass.
|
|
177
|
+
|
|
178
|
+
```css
|
|
179
|
+
wcs-notify:state(denied) ~ .fallback { display: block; }
|
|
180
|
+
wcs-notify:state(unsupported) ~ .fallback { display: block; }
|
|
181
|
+
|
|
182
|
+
form:has(wcs-notify:state(error)) .banner { display: block; }
|
|
183
|
+
```
|
|
184
|
+
|
|
185
|
+
Unlike attributes or classes, `:state()` cannot be written from outside the
|
|
186
|
+
element, so there is no risk of confusing this output state with an input.
|
|
187
|
+
|
|
188
|
+
**Browser support** (`:state(x)` syntax): Chrome/Edge 125+, Safari 17.4+,
|
|
189
|
+
Firefox 126+. In older browsers the states are simply never set — `:state()`
|
|
190
|
+
selectors never match, but `<wcs-notify>` itself keeps working normally
|
|
191
|
+
(graceful degradation, never-throw).
|
|
192
|
+
|
|
193
|
+
**SSR**: `:state()` cannot be serialized into HTML, so server-rendered markup
|
|
194
|
+
never carries these states on first paint (`@wcstack/server` is unaffected).
|
|
195
|
+
If you need to style the pre-hydration gap, pair your rule with
|
|
196
|
+
`wcs-notify:not(:defined)` instead.
|
|
197
|
+
|
|
198
|
+
### Debugging
|
|
199
|
+
|
|
200
|
+
Custom states are invisible in DevTools' Elements panel and `attachInternals()`
|
|
201
|
+
cannot be called twice, so there is no console way to inspect them directly.
|
|
202
|
+
Two debug-only aids are provided for that:
|
|
203
|
+
|
|
204
|
+
- `el.debugStates` — a **snapshot** array of the currently-on state names
|
|
205
|
+
(e.g. `["granted"]`). It is not part of `wc-bindable` (not a bind target)
|
|
206
|
+
and its shape is not a guaranteed contract — use it for debugging only.
|
|
207
|
+
- The `debug-states` attribute (opt-in, default off) mirrors state changes
|
|
208
|
+
onto `data-wcs-state-granted` / `data-wcs-state-denied` /
|
|
209
|
+
`data-wcs-state-prompt` / `data-wcs-state-unsupported` /
|
|
210
|
+
`data-wcs-state-error` attributes on the element, so the Elements panel
|
|
211
|
+
highlights them as they toggle:
|
|
212
|
+
|
|
213
|
+
```html
|
|
214
|
+
<wcs-notify debug-states></wcs-notify>
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
**Write your CSS against `:state()`, not `data-wcs-state-*`.** The mirrored
|
|
218
|
+
attributes exist purely to make state changes visible while debugging with
|
|
219
|
+
DevTools open; they are not a supported styling hook.
|
|
220
|
+
|
|
159
221
|
## Notes & limitations
|
|
160
222
|
|
|
161
223
|
- **Notifications outlive the page.** Disconnecting `<wcs-notify>` (or calling `dispose()` on the Core) detaches its subscriptions but does **not** close open notifications — a notification is meant to persist past the page. Use `close` / `closeAll` to dismiss.
|
|
224
|
+
- **`mode` is fixed at connect time.** The backend is chosen once, when the element connects (`observe(mode)`); there is no `observedAttributes` entry for `mode`. Changing the `mode` attribute on an already-connected element has no effect until you re-connect it (remove and re-insert).
|
|
225
|
+
- **The SW backend does not relay `close`.** The `@wcstack/notification/sw` helper wires `notificationclick` only, not `notificationclose`. So under the `sw` backend `closed` / `wcs-notify:close` never fires (there is no cross-worker relay for close). `clicked` still works via the click relay; `closed` is a constructor-backend-only signal.
|
|
162
226
|
- **Push API is out of scope.** This package wraps the Notifications API (local notifications). Server-initiated Push is a separate concern.
|
|
163
227
|
- **Silent failure handling (zero-log).** Consistent with wcstack's zero-dependency philosophy, `<wcs-notify>` never logs or throws. A missing API → `permission = "unsupported"`; a not-granted permission or a show failure → the `error` property. Bind `error` / `permission` to react.
|
|
164
228
|
- **SSR (`@wcstack/server`).** Declares `static hasConnectedCallbackPromise = true` and exposes `connectedCallbackPromise`, so the server renderer waits for the connect-time permission probe before snapshotting.
|
|
165
229
|
|
|
230
|
+
## Configuration
|
|
231
|
+
|
|
232
|
+
`<wcs-notify>` ships a **click autoTrigger** that is **enabled by default**. When enabled, the first `<wcs-notify>` to connect installs a single document-level `click` listener. A click on any element carrying the trigger attribute (`data-notifytarget="<id>"`) calls `notify()` on the `<wcs-notify>` with that `id`:
|
|
233
|
+
|
|
234
|
+
```html
|
|
235
|
+
<wcs-notify id="app-notify"></wcs-notify>
|
|
236
|
+
<button data-notifytarget="app-notify" data-notifybody="You have 1 new message">
|
|
237
|
+
Notify me
|
|
238
|
+
</button>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
- The title is `data-notifytitle` if present, otherwise the trigger element's trimmed `textContent`; the body is the optional `data-notifybody`.
|
|
242
|
+
- Because it is a **document-wide** click listener installed by default, disable it if you do not use the shortcut. Configuration is applied through `bootstrapNotification(userConfig?)` (which registers the element and applies the config in one call); `getConfig()` reads back the effective, deep-frozen config:
|
|
243
|
+
|
|
244
|
+
```js
|
|
245
|
+
import { bootstrapNotification, getConfig } from "@wcstack/notification";
|
|
246
|
+
|
|
247
|
+
// Register <wcs-notify> and opt out of the document click listener:
|
|
248
|
+
bootstrapNotification({ autoTrigger: false });
|
|
249
|
+
// Or rename the trigger attribute:
|
|
250
|
+
bootstrapNotification({ triggerAttribute: "data-notify" });
|
|
251
|
+
|
|
252
|
+
getConfig(); // read the (deep-frozen) effective config
|
|
253
|
+
```
|
|
254
|
+
|
|
255
|
+
| Config key | Type | Default | Description |
|
|
256
|
+
| ------------------ | --------- | ------------------- | ----------------------------------------------------------------- |
|
|
257
|
+
| `autoTrigger` | `boolean` | `true` | Install the document-level click listener for `data-notifytarget`. |
|
|
258
|
+
| `triggerAttribute` | `string` | `data-notifytarget` | Attribute a clickable element uses to target a `<wcs-notify>` by id. |
|
|
259
|
+
| `tagNames.notify` | `string` | `wcs-notify` | Custom-element tag name to register. |
|
|
260
|
+
|
|
261
|
+
Call `setConfig()` / `bootstrapNotification()` **before** the elements connect for the change to take effect.
|
|
262
|
+
|
|
166
263
|
## Headless usage (`NotificationCore`)
|
|
167
264
|
|
|
168
265
|
The Core has no DOM dependency and can be used directly with `bind()` from `@wc-bindable/core`:
|
package/dist/index.d.ts
CHANGED
|
@@ -51,8 +51,9 @@ type NotificationPermissionRaw = "default" | "granted" | "denied";
|
|
|
51
51
|
* Which API actually shows the notification.
|
|
52
52
|
* - `"constructor"` — `new Notification(title, options)` (desktop only).
|
|
53
53
|
* - `"sw"` — `ServiceWorkerRegistration.showNotification()` (required on mobile/Android Chrome).
|
|
54
|
-
* - `"auto"` —
|
|
55
|
-
*
|
|
54
|
+
* - `"auto"` — always try the `Notification` constructor first (no registration
|
|
55
|
+
* pre-check), and fall back to the SW backend only if the constructor throws a
|
|
56
|
+
* `TypeError` (e.g. on mobile, where `new Notification()` is illegal).
|
|
56
57
|
*/
|
|
57
58
|
type NotifyBackend = "auto" | "sw" | "constructor";
|
|
58
59
|
/**
|
|
@@ -285,7 +286,11 @@ declare class WcsNotify extends HTMLElement {
|
|
|
285
286
|
private _core;
|
|
286
287
|
private _notice;
|
|
287
288
|
private _connectedCallbackPromise;
|
|
289
|
+
private _internals;
|
|
288
290
|
constructor();
|
|
291
|
+
get debugStates(): string[];
|
|
292
|
+
private _initInternals;
|
|
293
|
+
private _wireStates;
|
|
289
294
|
get mode(): NotifyBackend;
|
|
290
295
|
set mode(value: NotifyBackend);
|
|
291
296
|
get body(): string;
|
package/dist/index.esm.js
CHANGED
|
@@ -610,9 +610,66 @@ class WcsNotify extends HTMLElement {
|
|
|
610
610
|
_core;
|
|
611
611
|
_notice = "";
|
|
612
612
|
_connectedCallbackPromise = Promise.resolve();
|
|
613
|
+
_internals = null;
|
|
613
614
|
constructor() {
|
|
614
615
|
super();
|
|
615
616
|
this._core = new NotificationCore(this);
|
|
617
|
+
this._internals = this._initInternals();
|
|
618
|
+
this._wireStates({
|
|
619
|
+
"wcs-notify:permission-change": (d) => ({
|
|
620
|
+
granted: d === "granted", denied: d === "denied",
|
|
621
|
+
prompt: d === "prompt", unsupported: d === "unsupported",
|
|
622
|
+
}),
|
|
623
|
+
"wcs-notify:error": (d) => ({ error: d != null }),
|
|
624
|
+
});
|
|
625
|
+
}
|
|
626
|
+
// CSS state reflection (:state()) — debug-only snapshot getter. NOT part of
|
|
627
|
+
// wc-bindable (not a bind target); see README "CSS styling with :state()".
|
|
628
|
+
// MUST NOT return the live CustomStateSet (that would let callers write
|
|
629
|
+
// states from outside, defeating the point of :state() being read-only).
|
|
630
|
+
get debugStates() {
|
|
631
|
+
return this._internals ? [...this._internals.states] : [];
|
|
632
|
+
}
|
|
633
|
+
_initInternals() {
|
|
634
|
+
// never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent
|
|
635
|
+
// in happy-dom / older environments, and pre-125 Chromium rejects
|
|
636
|
+
// non-dashed state names from states.add() (probed and discarded here).
|
|
637
|
+
// Either case silently disables reflection — the component still works,
|
|
638
|
+
// it just doesn't expose :state() selectors.
|
|
639
|
+
try {
|
|
640
|
+
if (typeof this.attachInternals !== "function")
|
|
641
|
+
return null;
|
|
642
|
+
const internals = this.attachInternals();
|
|
643
|
+
internals.states.add("wcs-probe");
|
|
644
|
+
internals.states.delete("wcs-probe");
|
|
645
|
+
return internals;
|
|
646
|
+
}
|
|
647
|
+
catch {
|
|
648
|
+
return null;
|
|
649
|
+
}
|
|
650
|
+
}
|
|
651
|
+
_wireStates(map) {
|
|
652
|
+
if (this._internals === null)
|
|
653
|
+
return;
|
|
654
|
+
const states = this._internals.states;
|
|
655
|
+
for (const [event, toStates] of Object.entries(map)) {
|
|
656
|
+
this.addEventListener(event, (e) => {
|
|
657
|
+
const debug = this.hasAttribute("debug-states");
|
|
658
|
+
for (const [name, on] of Object.entries(toStates(e.detail))) {
|
|
659
|
+
try {
|
|
660
|
+
if (on) {
|
|
661
|
+
states.add(name);
|
|
662
|
+
}
|
|
663
|
+
else {
|
|
664
|
+
states.delete(name);
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
catch { /* never-throw */ }
|
|
668
|
+
if (debug)
|
|
669
|
+
this.toggleAttribute(`data-wcs-state-${name}`, on);
|
|
670
|
+
}
|
|
671
|
+
});
|
|
672
|
+
}
|
|
616
673
|
}
|
|
617
674
|
// --- Attribute accessors ---
|
|
618
675
|
get mode() {
|
package/dist/index.esm.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/NotificationCore.ts","../src/autoTrigger.ts","../src/components/Notify.ts","../src/registerComponents.ts","../src/bootstrapNotification.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n notify: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-notifytarget\",\n tagNames: {\n notify: \"wcs-notify\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\n// Internal, mutable live config used by the components/autoTrigger (they read it\n// at call time so setConfig() takes effect without re-import). Typed as the\n// readonly IConfig at the export boundary — the `as IConfig` is a compile-time\n// view only and does NOT freeze the object, so this export must stay\n// package-internal (it is not re-exported from exports.ts). Public consumers get\n// the deep-frozen clone from getConfig() instead.\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, NotifyBackend, NotifyOptions, NotificationPermissionRaw,\n PermissionStateOrUnsupported, WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\n\n// Wrapper stored in a notification's `data` so the Service Worker side (a\n// separate global scope with no access to this instance) can recover the\n// identity and the caller's payload. The constructor backend uses the same\n// wrapper for uniformity, and both paths unwrap it before emitting.\ninterface WcsNotifyData {\n __wcsId: string;\n payload: unknown;\n}\n\n// Message shape posted by `wireNotificationClicks()` (src/sw.ts) over both\n// BroadcastChannel and clients.postMessage. `id` is unique per click\n// (`tag#seq`), so the two transports delivering the *same* click de-dup, while\n// two genuine clicks on the same `tag` do not.\ninterface WcsNotifyInbound {\n __wcsNotify: true;\n id: string;\n tag: string;\n data: unknown;\n action: string;\n}\n\n/**\n * Headless desktop-notification primitive. A thin, framework-agnostic wrapper\n * around the Notifications API exposed through the wc-bindable protocol.\n *\n * Unlike `@wcstack/permission` (a read-only monitor — the Permissions API has no\n * `request()`), the Notifications API *does* expose `Notification.requestPermission()`,\n * so this node is self-contained: it both **requests/monitors** the permission and\n * **shows** notifications. It is the first @wcstack node where the command-token\n * (show: `notify`) and event-token (`click` / `close` / `show`) directions both\n * live in one tag.\n *\n * - **request()** asks for the `notifications` permission (`Notification.requestPermission`).\n * - **notify(title, options)** shows a notification and returns its identifying tag\n * (a caller `options.tag`, or a generated `wcs-<n>`). It picks a backend per\n * `mode`: the `Notification` constructor (desktop) or\n * `ServiceWorkerRegistration.showNotification()` (mobile). `\"auto\"` prefers the\n * constructor and falls back to the SW on a `TypeError`.\n * - **close(tag) / closeAll()** dismiss notifications by tag / all.\n * - Clicks flow back as the `wcs-notify:click` event: directly via the\n * Notification's `onclick` (constructor), or via the SW helper's\n * BroadcastChannel/postMessage relay (SW). `permission` mirrors the live grant.\n *\n * Failures never throw: they surface through `error` (and the `unsupported`\n * permission state) so they flow into the declarative state.\n */\nexport class NotificationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"permission\", event: \"wcs-notify:permission-change\" },\n { name: \"granted\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n { name: \"error\", event: \"wcs-notify:error\" },\n { name: \"clicked\", event: \"wcs-notify:click\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"closed\", event: \"wcs-notify:close\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"shown\", event: \"wcs-notify:show\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"notify\" },\n { name: \"close\" },\n { name: \"closeAll\" },\n ],\n };\n\n private _target: EventTarget;\n private _mode: NotifyBackend = \"auto\";\n\n private _permission: PermissionStateOrUnsupported = \"prompt\";\n private _error: WcsNotifyErrorDetail | null = null;\n private _lastClick: WcsNotifyClickDetail | null = null;\n private _lastClose: WcsNotifyClickDetail | null = null;\n private _lastShow: WcsNotifyClickDetail | null = null;\n\n // Live PermissionStatus (when the Permissions API can query `notifications`),\n // kept so its `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n // True once a permission subscription has been (or is being) established; reset\n // by dispose(). Guards observe() so a reconnect re-queries while a redundant\n // observe() on a live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current lifecycle. Bumped by every observe() and by\n // dispose(). In-flight async work (permission query, SW show, inbound click)\n // captures it and bails if stale, so a query/click that resolves after a\n // disconnect — or after a rapid disconnect→reconnect — never mutates state or\n // dispatches on a torn-down element.\n private _gen: number = 0;\n\n // Resolves once the connect-time permission probe settles. The Shell exposes\n // this as connectedCallbackPromise so SSR can await it before snapshotting.\n private _ready: Promise<void> = Promise.resolve();\n\n // Counter for auto-assigned tags when the caller omits one.\n private _idSeq: number = 0;\n\n // Notifications created via the constructor backend, by tag, so close()/closeAll()\n // can dismiss them. The SW backend has no handle (showNotification returns void),\n // so its tags are tracked separately and closed via registration.getNotifications().\n private _constructed: Map<string, Notification> = new Map();\n private _swTags: Set<string> = new Set();\n\n // Click subscription handles (SW relay).\n private _channel: BroadcastChannel | null = null;\n private _serviceWorker: ServiceWorkerContainer | null = null;\n private _clicksSubscribed: boolean = false;\n // Per-click ids already handled, to de-dup the two relay transports. FIFO-capped\n // so a long session does not leak; the two transports always arrive in the same\n // tick, so a small cap is ample.\n private _seenIds: string[] = [];\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get permission(): PermissionStateOrUnsupported {\n return this._permission;\n }\n\n get granted(): boolean {\n return this._permission === \"granted\";\n }\n\n get denied(): boolean {\n return this._permission === \"denied\";\n }\n\n get prompt(): boolean {\n return this._permission === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._permission === \"unsupported\";\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._error;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._lastClick;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._lastClose;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._lastShow;\n }\n\n /** Resolves once the current (or initial) permission probe settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPermission(state: PermissionStateOrUnsupported): void {\n if (this._permission === state) return;\n this._permission = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:permission-change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsNotifyErrorDetail | null): void {\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _emit(kind: \"click\" | \"close\" | \"show\", detail: WcsNotifyClickDetail): void {\n if (kind === \"click\") this._lastClick = detail;\n else if (kind === \"close\") this._lastClose = detail;\n else this._lastShow = detail;\n this._target.dispatchEvent(new CustomEvent(`wcs-notify:${kind}`, {\n detail,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing the `notifications` permission and subscribing to Service\n * Worker click relays. `mode` selects the show backend (default `\"auto\"`).\n * Idempotent while already subscribed: it only updates the stored mode; to\n * restart, dispose() first. Returns a promise that resolves once the first\n * permission probe settles, for SSR.\n *\n * Headless callers must call observe() to begin; the Shell calls it from\n * connectedCallback once the element's attributes resolve.\n */\n observe(mode: NotifyBackend = \"auto\"): Promise<void> {\n this._mode = mode;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n this._subscribeClicks();\n }\n return this._ready;\n }\n\n /**\n * Ask the user for the `notifications` permission. Resolves to the resulting\n * (normalized) permission state. Never throws: an unavailable API resolves to\n * `\"unsupported\"`.\n */\n async request(): Promise<PermissionStateOrUnsupported> {\n const api = this._api();\n if (!api || typeof api.requestPermission !== \"function\") {\n this._setPermission(\"unsupported\");\n return this._permission;\n }\n try {\n const result = await api.requestPermission();\n this._setPermission(this._normalize(result));\n } catch {\n // Some legacy engines may reject; keep the current state rather than throw.\n }\n return this._permission;\n }\n\n /**\n * Show a notification. Returns the identifying tag (the caller's `options.tag`,\n * or a generated `wcs-<n>` when omitted). Never throws: when the API is\n * unavailable or the permission is not granted it surfaces an `error` and\n * returns an empty string.\n */\n notify(title: string, options: NotifyOptions = {}): string {\n if (!this._api()) {\n this._setError(this._err(\"unsupported\", \"Notifications API is not available in this environment.\"));\n return \"\";\n }\n if (this._permission !== \"granted\") {\n this._setError(this._err(\"not-granted\", \"Notification permission is not granted; call request() first.\"));\n return \"\";\n }\n if (typeof title !== \"string\") {\n this._setError(this._err(\"invalid-title\", \"notify() requires a string title.\"));\n return \"\";\n }\n\n const tag = (typeof options.tag === \"string\" && options.tag !== \"\") ? options.tag : this._nextId();\n const payload = options.data;\n const data: WcsNotifyData = { __wcsId: tag, payload };\n const backendOptions: NotifyOptions = { ...options, tag, data };\n\n this._setError(null);\n this._show(title, backendOptions, tag, payload);\n return tag;\n }\n\n /** Dismiss the notification(s) with `tag` across both backends. */\n close(tag?: string): void {\n if (typeof tag !== \"string\" || tag === \"\") return;\n const n = this._constructed.get(tag);\n if (n) {\n n.close();\n this._constructed.delete(tag);\n }\n if (this._swTags.has(tag)) {\n this._closeSw(tag);\n this._swTags.delete(tag);\n }\n }\n\n /**\n * Dismiss every notification this instance has shown. Scoped to this instance's\n * own tags on both backends — the SW path closes each tracked tag individually\n * rather than enumerating the whole origin, so it never dismisses notifications\n * shown by another `<wcs-notify>` or by an unrelated code path.\n */\n closeAll(): void {\n for (const n of this._constructed.values()) {\n n.close();\n }\n this._constructed.clear();\n for (const tag of this._swTags) {\n this._closeSw(tag);\n }\n this._swTags.clear();\n }\n\n /**\n * Detach permission and click subscriptions. Open notifications are intentionally\n * **left on screen** (a notification outlives the page that posted it — that is\n * the point); use close()/closeAll() to dismiss. Call from the Shell's\n * disconnectedCallback. A later observe() resumes.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n this._clicksSubscribed = false;\n this._gen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n if (this._channel) {\n this._channel.removeEventListener(\"message\", this._onInbound);\n this._channel.close();\n this._channel = null;\n }\n if (this._serviceWorker) {\n this._serviceWorker.removeEventListener(\"message\", this._onInbound);\n this._serviceWorker = null;\n }\n }\n\n // --- Internal: permission ---\n\n private _initPermission(): Promise<void> {\n const api = this._api();\n if (!api) {\n this._setPermission(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no permission\n // listener to tear down, so a reconnect simply re-probes (idempotent — the\n // same-value guard suppresses any redundant dispatch and no listener is ever\n // attached). _subscribeClicks() is re-entered too, but its own\n // _clicksSubscribed guard short-circuits the second pass, so no transport is\n // double-subscribed. Mirrors @wcstack/permission's unsupported path.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n // Prefer the Permissions API: it provides a live `change` event. Fall back to\n // the static `Notification.permission` when it is absent or rejects the\n // `notifications` descriptor.\n if (typeof navigator !== \"undefined\" && navigator.permissions && typeof navigator.permissions.query === \"function\") {\n const gen = ++this._gen;\n return navigator.permissions.query({ name: \"notifications\" }).then(\n (status) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._gen) return;\n // Permissions API rejected the `notifications` descriptor — fall back to\n // the static `Notification.permission` (api is in scope and non-null here).\n this._setPermission(this._normalize(api.permission));\n },\n );\n }\n // No Permissions API: read the static permission once (no live change events).\n this._setPermission(this._normalize(api.permission));\n return Promise.resolve();\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n };\n\n // Normalize the Notifications API's `\"default\"` to `\"prompt\"` so this node shares\n // the four-value surface of @wcstack/permission. The Permissions API already\n // reports `\"prompt\"`, so it passes through unchanged.\n private _normalize(raw: NotificationPermissionRaw | string): PermissionStateOrUnsupported {\n if (raw === \"default\") return \"prompt\";\n if (raw === \"granted\" || raw === \"denied\" || raw === \"prompt\") return raw;\n return \"prompt\";\n }\n\n // --- Internal: showing ---\n\n private _show(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n if (this._mode === \"sw\") {\n this._showViaSw(title, options, tag, payload);\n return;\n }\n const handled = this._showViaConstructor(title, options, tag, payload);\n if (handled) return;\n // Constructor threw TypeError (e.g. mobile, where `new Notification` is illegal).\n if (this._mode === \"auto\") {\n this._showViaSw(title, options, tag, payload);\n } else {\n this._setError(this._err(\"show-failed\", \"new Notification() is not usable here and mode=\\\"constructor\\\" disallows the Service Worker fallback.\"));\n }\n }\n\n // Returns false only when the constructor threw a TypeError (the signal to fall\n // back to the SW backend); true when it showed or surfaced a non-TypeError error.\n private _showViaConstructor(title: string, options: NotifyOptions, tag: string, payload: unknown): boolean {\n const api = this._api()!;\n const gen = this._gen;\n let n: Notification;\n try {\n n = new api(title, options as NotificationOptions);\n } catch (e) {\n if (e instanceof TypeError) return false;\n this._setError(this._err(\"show-failed\", \"Failed to create the notification.\"));\n return true;\n }\n this._constructed.set(tag, n);\n n.onshow = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n };\n n.onclick = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"click\", { tag, data: payload, action: \"\" });\n };\n n.onclose = (): void => {\n this._constructed.delete(tag);\n if (gen !== this._gen) return;\n this._emit(\"close\", { tag, data: payload, action: \"\" });\n };\n n.onerror = (): void => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"The notification failed to display.\"));\n };\n return true;\n }\n\n private _showViaSw(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) {\n this._setError(this._err(\"no-service-worker\", \"Service Worker is required to show this notification but is unavailable.\"));\n return;\n }\n const gen = this._gen;\n this._swTags.add(tag);\n // A notification deliberately outlives the page (see § dispose), so we do NOT\n // bail before showNotification on a stale gen — a notify() issued while\n // connected still shows. The stale-gen guards only suppress dispatching the\n // observable `show` / `error` back onto a torn-down element.\n sw.ready\n .then((registration) => registration.showNotification(title, options as NotificationOptions))\n .then(() => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n })\n .catch(() => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"ServiceWorkerRegistration.showNotification() failed.\"));\n });\n }\n\n // Close the SW notification(s) carrying `tag`. Always scoped to a single tag —\n // both callers (close / closeAll) iterate their own tracked tags, so the whole\n // origin is never enumerated.\n private _closeSw(tag: string): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) return;\n sw.ready.then((registration) => {\n return registration.getNotifications({ tag }).then((list) => {\n for (const n of list) n.close();\n });\n }).catch(() => {\n // Closing is best-effort; a failure to enumerate is not surfaced.\n });\n }\n\n // --- Internal: click relay (SW) ---\n\n private _subscribeClicks(): void {\n if (this._clicksSubscribed) return;\n this._clicksSubscribed = true;\n if (typeof BroadcastChannel === \"function\") {\n this._channel = new BroadcastChannel(\"wcs-notify\");\n this._channel.addEventListener(\"message\", this._onInbound);\n }\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (sw) {\n this._serviceWorker = sw;\n sw.addEventListener(\"message\", this._onInbound);\n }\n }\n\n private _onInbound = (event: Event): void => {\n const msg = (event as MessageEvent).data as WcsNotifyInbound | undefined;\n if (!msg || msg.__wcsNotify !== true) return;\n if (this._isDuplicate(msg.id)) return;\n this._emit(\"click\", { tag: msg.tag, data: this._unwrap(msg.data), action: msg.action });\n };\n\n private _isDuplicate(id: string): boolean {\n if (this._seenIds.includes(id)) return true;\n this._seenIds.push(id);\n if (this._seenIds.length > 50) this._seenIds.shift();\n return false;\n }\n\n private _unwrap(raw: unknown): unknown {\n if (raw !== null && typeof raw === \"object\" && \"__wcsId\" in raw) {\n return (raw as WcsNotifyData).payload;\n }\n return raw;\n }\n\n // --- Internal: misc ---\n\n // Resolve the global `Notification` constructor at call time (not cached) so\n // tests can install/remove it and so unsupported environments report correctly.\n private _api(): (typeof Notification) | undefined {\n const g = globalThis as unknown as { Notification?: typeof Notification };\n return typeof g.Notification === \"function\" ? g.Notification : undefined;\n }\n\n private _nextId(): string {\n return `wcs-${++this._idSeq}`;\n }\n\n private _err(error: string, message: string): WcsNotifyErrorDetail {\n return { error, message };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsNotify } from \"./components/Notify.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n // A misconfigured triggerAttribute (e.g. one with a space) makes the attribute\n // selector invalid and closest() throw SyntaxError; guard so a bad config\n // disables only this shortcut rather than killing every document click handler.\n let triggerElement: Element | null;\n try {\n triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n } catch {\n return;\n }\n if (!triggerElement) return;\n\n const notifyId = triggerElement.getAttribute(config.triggerAttribute);\n if (!notifyId) return;\n\n // Resolve the registered constructor at call time instead of importing Notify as\n // a value, avoiding a components/Notify.ts ⇄ autoTrigger.ts cycle\n // (Notify.connectedCallback() calls registerAutoTrigger()). instanceof against\n // the customElements registry keeps the same identity guarantee.\n const NotifyCtor = customElements.get(config.tagNames.notify);\n const notifyElement = document.getElementById(notifyId);\n if (!NotifyCtor || !(notifyElement instanceof NotifyCtor)) return;\n\n // The title comes from the trigger element: an explicit `data-notifytitle`\n // attribute wins, otherwise the element's trimmed text content. The body is an\n // optional `data-notifybody`. This keeps the click-driven shortcut declarative\n // without inventing a payload channel.\n const explicit = triggerElement.getAttribute(\"data-notifytitle\");\n // `Element.textContent` is spec-guaranteed non-null (only Document / DocumentType\n // nodes return null, never an Element), so the cast is sound and lets us avoid an\n // unreachable `?? \"\"` branch. `triggerElement` is always an Element here.\n const title = explicit !== null ? explicit : (triggerElement.textContent as string).trim();\n const body = triggerElement.getAttribute(\"data-notifybody\");\n\n (notifyElement as WcsNotify).notify(title, body !== null ? { body } : undefined);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, NotifyBackend, NotifyOptions, PermissionStateOrUnsupported,\n WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { NotificationCore } from \"../core/NotificationCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n/**\n * `<wcs-notify>` — declarative desktop notifications. Wraps NotificationCore and\n * exposes both directions in one tag:\n *\n * - **`notice`** (reactive input): writing a *changed* value shows a notification,\n * suppressing same-value writes so it fires only when the bound source actually\n * changes. The imperative `notify` command instead shows on demand (even the\n * same text again). See `docs/notification-tag-design.md` § 2.\n * - **`request` / `notify` / `close` / `closeAll`** commands (state → element).\n * - per-notification options (`body` / `icon` / `badge` / `tag` / `lang` / `dir` /\n * `require-interaction` / `silent` / `renotify`) as mirrored attributes.\n * - `mode` selects the show backend (`auto` / `sw` / `constructor`).\n * - the Core's observable surface (permission / granted / … / error / clicked /\n * closed / shown) via delegated getters; clicked/closed/shown carry the\n * `{ tag, data, action }` payload for event-token wiring.\n */\nexport class WcsNotify extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...NotificationCore.wcBindable,\n // Shell-level settable surface. `notice` is a momentary reactive command-property\n // with no mirrored attribute (it carries dynamic text, not declarative config),\n // mirroring <wcs-speak>'s `say`. The rest mirror their HTML attributes idempotently.\n inputs: [\n { name: \"notice\" },\n { name: \"mode\", attribute: \"mode\" },\n { name: \"body\", attribute: \"body\" },\n { name: \"icon\", attribute: \"icon\" },\n { name: \"badge\", attribute: \"badge\" },\n { name: \"tag\", attribute: \"tag\" },\n { name: \"lang\", attribute: \"lang\" },\n { name: \"dir\", attribute: \"dir\" },\n { name: \"requireInteraction\", attribute: \"require-interaction\" },\n { name: \"silent\", attribute: \"silent\" },\n { name: \"renotify\", attribute: \"renotify\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n commands: NotificationCore.wcBindable.commands,\n };\n\n private _core: NotificationCore;\n private _notice: string = \"\";\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new NotificationCore(this);\n }\n\n // --- Attribute accessors ---\n\n get mode(): NotifyBackend {\n const m = this.getAttribute(\"mode\");\n return (m === \"sw\" || m === \"constructor\") ? m : \"auto\";\n }\n\n set mode(value: NotifyBackend) {\n this.setAttribute(\"mode\", value);\n }\n\n get body(): string {\n return this.getAttribute(\"body\") ?? \"\";\n }\n\n set body(value: string | null) {\n this._reflect(\"body\", value);\n }\n\n get icon(): string {\n return this.getAttribute(\"icon\") ?? \"\";\n }\n\n set icon(value: string | null) {\n this._reflect(\"icon\", value);\n }\n\n get badge(): string {\n return this.getAttribute(\"badge\") ?? \"\";\n }\n\n set badge(value: string | null) {\n this._reflect(\"badge\", value);\n }\n\n get tag(): string {\n return this.getAttribute(\"tag\") ?? \"\";\n }\n\n set tag(value: string | null) {\n this._reflect(\"tag\", value);\n }\n\n // NOTE: `lang` and `dir` intentionally repurpose the standard HTMLElement IDL\n // attributes as per-notification options (forwarded to NotificationOptions).\n // This element is always display:none, so overriding their normal rendering\n // semantics has no visual effect — but be aware the values mean \"the\n // notification's language/direction\", not the host element's.\n get lang(): string {\n return this.getAttribute(\"lang\") ?? \"\";\n }\n\n set lang(value: string | null) {\n this._reflect(\"lang\", value);\n }\n\n get dir(): string {\n return this.getAttribute(\"dir\") ?? \"\";\n }\n\n set dir(value: string | null) {\n this._reflect(\"dir\", value);\n }\n\n get requireInteraction(): boolean {\n return this.hasAttribute(\"require-interaction\");\n }\n\n set requireInteraction(value: boolean) {\n this._reflectBool(\"require-interaction\", value);\n }\n\n get silent(): boolean {\n return this.hasAttribute(\"silent\");\n }\n\n set silent(value: boolean) {\n this._reflectBool(\"silent\", value);\n }\n\n get renotify(): boolean {\n return this.hasAttribute(\"renotify\");\n }\n\n set renotify(value: boolean) {\n this._reflectBool(\"renotify\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n this._reflectBool(\"manual\", value);\n }\n\n // --- Reactive command-property ---\n\n get notice(): string {\n return this._notice;\n }\n\n set notice(value: string | null) {\n // Reactive: writing a new value shows it. `manual` mutes the path entirely\n // (the imperative `notify` command still works). A conforming binder never\n // delivers `undefined` (it skips the write), but a direct assignment can, so\n // normalize null/undefined to a no-op.\n if (value == null) return;\n if (this.manual) return;\n const v = String(value);\n // Same-value guard: only show when the bound source actually changes. To show\n // the same text again on demand, use the `notify` command instead. (This is\n // the only spam guard the package provides — see docs § 2-c; debounce is the\n // caller's job via a filter, e.g. `notice@x|debounce(1000)`.)\n if (v === this._notice) return;\n this._notice = v;\n this.notify(v);\n }\n\n // --- Core delegated getters ---\n\n get permission(): PermissionStateOrUnsupported {\n return this._core.permission;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._core.error;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._core.clicked;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._core.closed;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._core.shown;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<PermissionStateOrUnsupported> {\n return this._core.request();\n }\n\n notify(title: string, options?: NotifyOptions): string {\n // Explicit options (from a command-token emit) win per-key over the attribute\n // defaults, so `notify.emit(title, { body })` still picks up the element's icon.\n return this._core.notify(title, { ...this._options(), ...(options ?? {}) });\n }\n\n close(tag?: string): void {\n this._core.close(tag);\n }\n\n closeAll(): void {\n this._core.closeAll();\n }\n\n // --- Internal ---\n\n private _reflect(name: string, value: string | null): void {\n if (value == null) {\n this.removeAttribute(name);\n } else {\n this.setAttribute(name, String(value));\n }\n }\n\n private _reflectBool(name: string, value: boolean): void {\n if (value) {\n this.setAttribute(name, \"\");\n } else {\n this.removeAttribute(name);\n }\n }\n\n private _options(): NotifyOptions {\n const o: NotifyOptions = {};\n if (this.body !== \"\") o.body = this.body;\n if (this.icon !== \"\") o.icon = this.icon;\n if (this.badge !== \"\") o.badge = this.badge;\n if (this.tag !== \"\") o.tag = this.tag;\n if (this.lang !== \"\") o.lang = this.lang;\n if (this.dir === \"auto\" || this.dir === \"ltr\" || this.dir === \"rtl\") o.dir = this.dir;\n if (this.requireInteraction) o.requireInteraction = true;\n if (this.silent) o.silent = true;\n if (this.renotify) o.renotify = true;\n return o;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Begin observing permission and subscribing to SW click relays (or revive\n // after a reconnect). The returned promise is held as connectedCallbackPromise\n // for SSR.\n this._connectedCallbackPromise = this._core.observe(this.mode);\n }\n\n disconnectedCallback(): void {\n // Detach subscriptions. Open notifications are left on screen (see Core docs);\n // call close()/closeAll() to dismiss.\n this._core.dispose();\n }\n}\n","import { WcsNotify } from \"./components/Notify.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.notify)) {\n customElements.define(config.tagNames.notify, WcsNotify);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNotification(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAUA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,mBAAmB;AACrC,IAAA,QAAQ,EAAE;AACR,QAAA,MAAM,EAAE,YAAY;AACrB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE;AAClC,QAAA,UAAU,CAAE,GAA+B,CAAC,GAAG,CAAC,CAAC;IACnD;AACA,IAAA,OAAO,GAAG;AACZ;AAEA,SAAS,SAAS,CAAI,GAAM,EAAA;AAC1B,IAAA,IAAI,GAAG,KAAK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C,IAAI,CAAC;IAChE;IAEA,oBAAoB,GAAA;;;AAGlB,QAAA,IAAI,CAAC,KAAK,CAAC,OAAO,EAAE;IACtB;;;SC5Rc,kBAAkB,GAAA;AAChC,IAAA,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE;QAC/C,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAC1D;AACF;;ACHM,SAAU,qBAAqB,CAAC,UAA4B,EAAA;IAChE,IAAI,UAAU,EAAE;QACd,SAAS,CAAC,UAAU,CAAC;IACvB;AACA,IAAA,kBAAkB,EAAE;AACtB;;;;"}
|
|
1
|
+
{"version":3,"file":"index.esm.js","sources":["../src/config.ts","../src/core/NotificationCore.ts","../src/autoTrigger.ts","../src/components/Notify.ts","../src/registerComponents.ts","../src/bootstrapNotification.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n notify: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-notifytarget\",\n tagNames: {\n notify: \"wcs-notify\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\n// Internal, mutable live config used by the components/autoTrigger (they read it\n// at call time so setConfig() takes effect without re-import). Typed as the\n// readonly IConfig at the export boundary — the `as IConfig` is a compile-time\n// view only and does NOT freeze the object, so this export must stay\n// package-internal (it is not re-exported from exports.ts). Public consumers get\n// the deep-frozen clone from getConfig() instead.\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, NotifyBackend, NotifyOptions, NotificationPermissionRaw,\n PermissionStateOrUnsupported, WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\n\n// Wrapper stored in a notification's `data` so the Service Worker side (a\n// separate global scope with no access to this instance) can recover the\n// identity and the caller's payload. The constructor backend uses the same\n// wrapper for uniformity, and both paths unwrap it before emitting.\ninterface WcsNotifyData {\n __wcsId: string;\n payload: unknown;\n}\n\n// Message shape posted by `wireNotificationClicks()` (src/sw.ts) over both\n// BroadcastChannel and clients.postMessage. `id` is unique per click\n// (`tag#seq`), so the two transports delivering the *same* click de-dup, while\n// two genuine clicks on the same `tag` do not.\ninterface WcsNotifyInbound {\n __wcsNotify: true;\n id: string;\n tag: string;\n data: unknown;\n action: string;\n}\n\n/**\n * Headless desktop-notification primitive. A thin, framework-agnostic wrapper\n * around the Notifications API exposed through the wc-bindable protocol.\n *\n * Unlike `@wcstack/permission` (a read-only monitor — the Permissions API has no\n * `request()`), the Notifications API *does* expose `Notification.requestPermission()`,\n * so this node is self-contained: it both **requests/monitors** the permission and\n * **shows** notifications. It is the first @wcstack node where the command-token\n * (show: `notify`) and event-token (`click` / `close` / `show`) directions both\n * live in one tag.\n *\n * - **request()** asks for the `notifications` permission (`Notification.requestPermission`).\n * - **notify(title, options)** shows a notification and returns its identifying tag\n * (a caller `options.tag`, or a generated `wcs-<n>`). It picks a backend per\n * `mode`: the `Notification` constructor (desktop) or\n * `ServiceWorkerRegistration.showNotification()` (mobile). `\"auto\"` prefers the\n * constructor and falls back to the SW on a `TypeError`.\n * - **close(tag) / closeAll()** dismiss notifications by tag / all.\n * - Clicks flow back as the `wcs-notify:click` event: directly via the\n * Notification's `onclick` (constructor), or via the SW helper's\n * BroadcastChannel/postMessage relay (SW). `permission` mirrors the live grant.\n *\n * Failures never throw: they surface through `error` (and the `unsupported`\n * permission state) so they flow into the declarative state.\n */\nexport class NotificationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"permission\", event: \"wcs-notify:permission-change\" },\n { name: \"granted\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n { name: \"error\", event: \"wcs-notify:error\" },\n { name: \"clicked\", event: \"wcs-notify:click\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"closed\", event: \"wcs-notify:close\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"shown\", event: \"wcs-notify:show\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"notify\" },\n { name: \"close\" },\n { name: \"closeAll\" },\n ],\n };\n\n private _target: EventTarget;\n private _mode: NotifyBackend = \"auto\";\n\n private _permission: PermissionStateOrUnsupported = \"prompt\";\n private _error: WcsNotifyErrorDetail | null = null;\n private _lastClick: WcsNotifyClickDetail | null = null;\n private _lastClose: WcsNotifyClickDetail | null = null;\n private _lastShow: WcsNotifyClickDetail | null = null;\n\n // Live PermissionStatus (when the Permissions API can query `notifications`),\n // kept so its `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n // True once a permission subscription has been (or is being) established; reset\n // by dispose(). Guards observe() so a reconnect re-queries while a redundant\n // observe() on a live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current lifecycle. Bumped by every observe() and by\n // dispose(). In-flight async work (permission query, SW show, inbound click)\n // captures it and bails if stale, so a query/click that resolves after a\n // disconnect — or after a rapid disconnect→reconnect — never mutates state or\n // dispatches on a torn-down element.\n private _gen: number = 0;\n\n // Resolves once the connect-time permission probe settles. The Shell exposes\n // this as connectedCallbackPromise so SSR can await it before snapshotting.\n private _ready: Promise<void> = Promise.resolve();\n\n // Counter for auto-assigned tags when the caller omits one.\n private _idSeq: number = 0;\n\n // Notifications created via the constructor backend, by tag, so close()/closeAll()\n // can dismiss them. The SW backend has no handle (showNotification returns void),\n // so its tags are tracked separately and closed via registration.getNotifications().\n private _constructed: Map<string, Notification> = new Map();\n private _swTags: Set<string> = new Set();\n\n // Click subscription handles (SW relay).\n private _channel: BroadcastChannel | null = null;\n private _serviceWorker: ServiceWorkerContainer | null = null;\n private _clicksSubscribed: boolean = false;\n // Per-click ids already handled, to de-dup the two relay transports. FIFO-capped\n // so a long session does not leak; the two transports always arrive in the same\n // tick, so a small cap is ample.\n private _seenIds: string[] = [];\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get permission(): PermissionStateOrUnsupported {\n return this._permission;\n }\n\n get granted(): boolean {\n return this._permission === \"granted\";\n }\n\n get denied(): boolean {\n return this._permission === \"denied\";\n }\n\n get prompt(): boolean {\n return this._permission === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._permission === \"unsupported\";\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._error;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._lastClick;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._lastClose;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._lastShow;\n }\n\n /** Resolves once the current (or initial) permission probe settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPermission(state: PermissionStateOrUnsupported): void {\n if (this._permission === state) return;\n this._permission = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:permission-change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsNotifyErrorDetail | null): void {\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _emit(kind: \"click\" | \"close\" | \"show\", detail: WcsNotifyClickDetail): void {\n if (kind === \"click\") this._lastClick = detail;\n else if (kind === \"close\") this._lastClose = detail;\n else this._lastShow = detail;\n this._target.dispatchEvent(new CustomEvent(`wcs-notify:${kind}`, {\n detail,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing the `notifications` permission and subscribing to Service\n * Worker click relays. `mode` selects the show backend (default `\"auto\"`).\n * Idempotent while already subscribed: it only updates the stored mode; to\n * restart, dispose() first. Returns a promise that resolves once the first\n * permission probe settles, for SSR.\n *\n * Headless callers must call observe() to begin; the Shell calls it from\n * connectedCallback once the element's attributes resolve.\n */\n observe(mode: NotifyBackend = \"auto\"): Promise<void> {\n this._mode = mode;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n this._subscribeClicks();\n }\n return this._ready;\n }\n\n /**\n * Ask the user for the `notifications` permission. Resolves to the resulting\n * (normalized) permission state. Never throws: an unavailable API resolves to\n * `\"unsupported\"`.\n */\n async request(): Promise<PermissionStateOrUnsupported> {\n const api = this._api();\n if (!api || typeof api.requestPermission !== \"function\") {\n this._setPermission(\"unsupported\");\n return this._permission;\n }\n try {\n const result = await api.requestPermission();\n this._setPermission(this._normalize(result));\n } catch {\n // Some legacy engines may reject; keep the current state rather than throw.\n }\n return this._permission;\n }\n\n /**\n * Show a notification. Returns the identifying tag (the caller's `options.tag`,\n * or a generated `wcs-<n>` when omitted). Never throws: when the API is\n * unavailable or the permission is not granted it surfaces an `error` and\n * returns an empty string.\n */\n notify(title: string, options: NotifyOptions = {}): string {\n if (!this._api()) {\n this._setError(this._err(\"unsupported\", \"Notifications API is not available in this environment.\"));\n return \"\";\n }\n if (this._permission !== \"granted\") {\n this._setError(this._err(\"not-granted\", \"Notification permission is not granted; call request() first.\"));\n return \"\";\n }\n if (typeof title !== \"string\") {\n this._setError(this._err(\"invalid-title\", \"notify() requires a string title.\"));\n return \"\";\n }\n\n const tag = (typeof options.tag === \"string\" && options.tag !== \"\") ? options.tag : this._nextId();\n const payload = options.data;\n const data: WcsNotifyData = { __wcsId: tag, payload };\n const backendOptions: NotifyOptions = { ...options, tag, data };\n\n this._setError(null);\n this._show(title, backendOptions, tag, payload);\n return tag;\n }\n\n /** Dismiss the notification(s) with `tag` across both backends. */\n close(tag?: string): void {\n if (typeof tag !== \"string\" || tag === \"\") return;\n const n = this._constructed.get(tag);\n if (n) {\n n.close();\n this._constructed.delete(tag);\n }\n if (this._swTags.has(tag)) {\n this._closeSw(tag);\n this._swTags.delete(tag);\n }\n }\n\n /**\n * Dismiss every notification this instance has shown. Scoped to this instance's\n * own tags on both backends — the SW path closes each tracked tag individually\n * rather than enumerating the whole origin, so it never dismisses notifications\n * shown by another `<wcs-notify>` or by an unrelated code path.\n */\n closeAll(): void {\n for (const n of this._constructed.values()) {\n n.close();\n }\n this._constructed.clear();\n for (const tag of this._swTags) {\n this._closeSw(tag);\n }\n this._swTags.clear();\n }\n\n /**\n * Detach permission and click subscriptions. Open notifications are intentionally\n * **left on screen** (a notification outlives the page that posted it — that is\n * the point); use close()/closeAll() to dismiss. Call from the Shell's\n * disconnectedCallback. A later observe() resumes.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n this._clicksSubscribed = false;\n this._gen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n if (this._channel) {\n this._channel.removeEventListener(\"message\", this._onInbound);\n this._channel.close();\n this._channel = null;\n }\n if (this._serviceWorker) {\n this._serviceWorker.removeEventListener(\"message\", this._onInbound);\n this._serviceWorker = null;\n }\n }\n\n // --- Internal: permission ---\n\n private _initPermission(): Promise<void> {\n const api = this._api();\n if (!api) {\n this._setPermission(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no permission\n // listener to tear down, so a reconnect simply re-probes (idempotent — the\n // same-value guard suppresses any redundant dispatch and no listener is ever\n // attached). _subscribeClicks() is re-entered too, but its own\n // _clicksSubscribed guard short-circuits the second pass, so no transport is\n // double-subscribed. Mirrors @wcstack/permission's unsupported path.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n // Prefer the Permissions API: it provides a live `change` event. Fall back to\n // the static `Notification.permission` when it is absent or rejects the\n // `notifications` descriptor.\n if (typeof navigator !== \"undefined\" && navigator.permissions && typeof navigator.permissions.query === \"function\") {\n const gen = ++this._gen;\n return navigator.permissions.query({ name: \"notifications\" }).then(\n (status) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._gen) return;\n // Permissions API rejected the `notifications` descriptor — fall back to\n // the static `Notification.permission` (api is in scope and non-null here).\n this._setPermission(this._normalize(api.permission));\n },\n );\n }\n // No Permissions API: read the static permission once (no live change events).\n this._setPermission(this._normalize(api.permission));\n return Promise.resolve();\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n };\n\n // Normalize the Notifications API's `\"default\"` to `\"prompt\"` so this node shares\n // the four-value surface of @wcstack/permission. The Permissions API already\n // reports `\"prompt\"`, so it passes through unchanged.\n private _normalize(raw: NotificationPermissionRaw | string): PermissionStateOrUnsupported {\n if (raw === \"default\") return \"prompt\";\n if (raw === \"granted\" || raw === \"denied\" || raw === \"prompt\") return raw;\n return \"prompt\";\n }\n\n // --- Internal: showing ---\n\n private _show(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n if (this._mode === \"sw\") {\n this._showViaSw(title, options, tag, payload);\n return;\n }\n const handled = this._showViaConstructor(title, options, tag, payload);\n if (handled) return;\n // Constructor threw TypeError (e.g. mobile, where `new Notification` is illegal).\n if (this._mode === \"auto\") {\n this._showViaSw(title, options, tag, payload);\n } else {\n this._setError(this._err(\"show-failed\", \"new Notification() is not usable here and mode=\\\"constructor\\\" disallows the Service Worker fallback.\"));\n }\n }\n\n // Returns false only when the constructor threw a TypeError (the signal to fall\n // back to the SW backend); true when it showed or surfaced a non-TypeError error.\n private _showViaConstructor(title: string, options: NotifyOptions, tag: string, payload: unknown): boolean {\n const api = this._api()!;\n const gen = this._gen;\n let n: Notification;\n try {\n n = new api(title, options as NotificationOptions);\n } catch (e) {\n if (e instanceof TypeError) return false;\n this._setError(this._err(\"show-failed\", \"Failed to create the notification.\"));\n return true;\n }\n this._constructed.set(tag, n);\n n.onshow = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n };\n n.onclick = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"click\", { tag, data: payload, action: \"\" });\n };\n n.onclose = (): void => {\n this._constructed.delete(tag);\n if (gen !== this._gen) return;\n this._emit(\"close\", { tag, data: payload, action: \"\" });\n };\n n.onerror = (): void => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"The notification failed to display.\"));\n };\n return true;\n }\n\n private _showViaSw(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) {\n this._setError(this._err(\"no-service-worker\", \"Service Worker is required to show this notification but is unavailable.\"));\n return;\n }\n const gen = this._gen;\n this._swTags.add(tag);\n // A notification deliberately outlives the page (see § dispose), so we do NOT\n // bail before showNotification on a stale gen — a notify() issued while\n // connected still shows. The stale-gen guards only suppress dispatching the\n // observable `show` / `error` back onto a torn-down element.\n sw.ready\n .then((registration) => registration.showNotification(title, options as NotificationOptions))\n .then(() => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n })\n .catch(() => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"ServiceWorkerRegistration.showNotification() failed.\"));\n });\n }\n\n // Close the SW notification(s) carrying `tag`. Always scoped to a single tag —\n // both callers (close / closeAll) iterate their own tracked tags, so the whole\n // origin is never enumerated.\n private _closeSw(tag: string): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) return;\n sw.ready.then((registration) => {\n return registration.getNotifications({ tag }).then((list) => {\n for (const n of list) n.close();\n });\n }).catch(() => {\n // Closing is best-effort; a failure to enumerate is not surfaced.\n });\n }\n\n // --- Internal: click relay (SW) ---\n\n private _subscribeClicks(): void {\n if (this._clicksSubscribed) return;\n this._clicksSubscribed = true;\n if (typeof BroadcastChannel === \"function\") {\n this._channel = new BroadcastChannel(\"wcs-notify\");\n this._channel.addEventListener(\"message\", this._onInbound);\n }\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (sw) {\n this._serviceWorker = sw;\n sw.addEventListener(\"message\", this._onInbound);\n }\n }\n\n private _onInbound = (event: Event): void => {\n const msg = (event as MessageEvent).data as WcsNotifyInbound | undefined;\n if (!msg || msg.__wcsNotify !== true) return;\n if (this._isDuplicate(msg.id)) return;\n this._emit(\"click\", { tag: msg.tag, data: this._unwrap(msg.data), action: msg.action });\n };\n\n private _isDuplicate(id: string): boolean {\n if (this._seenIds.includes(id)) return true;\n this._seenIds.push(id);\n if (this._seenIds.length > 50) this._seenIds.shift();\n return false;\n }\n\n private _unwrap(raw: unknown): unknown {\n if (raw !== null && typeof raw === \"object\" && \"__wcsId\" in raw) {\n return (raw as WcsNotifyData).payload;\n }\n return raw;\n }\n\n // --- Internal: misc ---\n\n // Resolve the global `Notification` constructor at call time (not cached) so\n // tests can install/remove it and so unsupported environments report correctly.\n private _api(): (typeof Notification) | undefined {\n const g = globalThis as unknown as { Notification?: typeof Notification };\n return typeof g.Notification === \"function\" ? g.Notification : undefined;\n }\n\n private _nextId(): string {\n return `wcs-${++this._idSeq}`;\n }\n\n private _err(error: string, message: string): WcsNotifyErrorDetail {\n return { error, message };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsNotify } from \"./components/Notify.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n // A misconfigured triggerAttribute (e.g. one with a space) makes the attribute\n // selector invalid and closest() throw SyntaxError; guard so a bad config\n // disables only this shortcut rather than killing every document click handler.\n let triggerElement: Element | null;\n try {\n triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n } catch {\n return;\n }\n if (!triggerElement) return;\n\n const notifyId = triggerElement.getAttribute(config.triggerAttribute);\n if (!notifyId) return;\n\n // Resolve the registered constructor at call time instead of importing Notify as\n // a value, avoiding a components/Notify.ts ⇄ autoTrigger.ts cycle\n // (Notify.connectedCallback() calls registerAutoTrigger()). instanceof against\n // the customElements registry keeps the same identity guarantee.\n const NotifyCtor = customElements.get(config.tagNames.notify);\n const notifyElement = document.getElementById(notifyId);\n if (!NotifyCtor || !(notifyElement instanceof NotifyCtor)) return;\n\n // The title comes from the trigger element: an explicit `data-notifytitle`\n // attribute wins, otherwise the element's trimmed text content. The body is an\n // optional `data-notifybody`. This keeps the click-driven shortcut declarative\n // without inventing a payload channel.\n const explicit = triggerElement.getAttribute(\"data-notifytitle\");\n // `Element.textContent` is spec-guaranteed non-null (only Document / DocumentType\n // nodes return null, never an Element), so the cast is sound and lets us avoid an\n // unreachable `?? \"\"` branch. `triggerElement` is always an Element here.\n const title = explicit !== null ? explicit : (triggerElement.textContent as string).trim();\n const body = triggerElement.getAttribute(\"data-notifybody\");\n\n (notifyElement as WcsNotify).notify(title, body !== null ? { body } : undefined);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, NotifyBackend, NotifyOptions, PermissionStateOrUnsupported,\n WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { NotificationCore } from \"../core/NotificationCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n/**\n * `<wcs-notify>` — declarative desktop notifications. Wraps NotificationCore and\n * exposes both directions in one tag:\n *\n * - **`notice`** (reactive input): writing a *changed* value shows a notification,\n * suppressing same-value writes so it fires only when the bound source actually\n * changes. The imperative `notify` command instead shows on demand (even the\n * same text again). See `docs/notification-tag-design.md` § 2.\n * - **`request` / `notify` / `close` / `closeAll`** commands (state → element).\n * - per-notification options (`body` / `icon` / `badge` / `tag` / `lang` / `dir` /\n * `require-interaction` / `silent` / `renotify`) as mirrored attributes.\n * - `mode` selects the show backend (`auto` / `sw` / `constructor`).\n * - the Core's observable surface (permission / granted / … / error / clicked /\n * closed / shown) via delegated getters; clicked/closed/shown carry the\n * `{ tag, data, action }` payload for event-token wiring.\n */\nexport class WcsNotify extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...NotificationCore.wcBindable,\n // Shell-level settable surface. `notice` is a momentary reactive command-property\n // with no mirrored attribute (it carries dynamic text, not declarative config),\n // mirroring <wcs-speak>'s `say`. The rest mirror their HTML attributes idempotently.\n inputs: [\n { name: \"notice\" },\n { name: \"mode\", attribute: \"mode\" },\n { name: \"body\", attribute: \"body\" },\n { name: \"icon\", attribute: \"icon\" },\n { name: \"badge\", attribute: \"badge\" },\n { name: \"tag\", attribute: \"tag\" },\n { name: \"lang\", attribute: \"lang\" },\n { name: \"dir\", attribute: \"dir\" },\n { name: \"requireInteraction\", attribute: \"require-interaction\" },\n { name: \"silent\", attribute: \"silent\" },\n { name: \"renotify\", attribute: \"renotify\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n commands: NotificationCore.wcBindable.commands,\n };\n\n private _core: NotificationCore;\n private _notice: string = \"\";\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NotificationCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-notify:permission-change\": (d) => ({\n granted: d === \"granted\", denied: d === \"denied\",\n prompt: d === \"prompt\", unsupported: d === \"unsupported\",\n }),\n \"wcs-notify:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get mode(): NotifyBackend {\n const m = this.getAttribute(\"mode\");\n return (m === \"sw\" || m === \"constructor\") ? m : \"auto\";\n }\n\n set mode(value: NotifyBackend) {\n this.setAttribute(\"mode\", value);\n }\n\n get body(): string {\n return this.getAttribute(\"body\") ?? \"\";\n }\n\n set body(value: string | null) {\n this._reflect(\"body\", value);\n }\n\n get icon(): string {\n return this.getAttribute(\"icon\") ?? \"\";\n }\n\n set icon(value: string | null) {\n this._reflect(\"icon\", value);\n }\n\n get badge(): string {\n return this.getAttribute(\"badge\") ?? \"\";\n }\n\n set badge(value: string | null) {\n this._reflect(\"badge\", value);\n }\n\n get tag(): string {\n return this.getAttribute(\"tag\") ?? \"\";\n }\n\n set tag(value: string | null) {\n this._reflect(\"tag\", value);\n }\n\n // NOTE: `lang` and `dir` intentionally repurpose the standard HTMLElement IDL\n // attributes as per-notification options (forwarded to NotificationOptions).\n // This element is always display:none, so overriding their normal rendering\n // semantics has no visual effect — but be aware the values mean \"the\n // notification's language/direction\", not the host element's.\n get lang(): string {\n return this.getAttribute(\"lang\") ?? \"\";\n }\n\n set lang(value: string | null) {\n this._reflect(\"lang\", value);\n }\n\n get dir(): string {\n return this.getAttribute(\"dir\") ?? \"\";\n }\n\n set dir(value: string | null) {\n this._reflect(\"dir\", value);\n }\n\n get requireInteraction(): boolean {\n return this.hasAttribute(\"require-interaction\");\n }\n\n set requireInteraction(value: boolean) {\n this._reflectBool(\"require-interaction\", value);\n }\n\n get silent(): boolean {\n return this.hasAttribute(\"silent\");\n }\n\n set silent(value: boolean) {\n this._reflectBool(\"silent\", value);\n }\n\n get renotify(): boolean {\n return this.hasAttribute(\"renotify\");\n }\n\n set renotify(value: boolean) {\n this._reflectBool(\"renotify\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n this._reflectBool(\"manual\", value);\n }\n\n // --- Reactive command-property ---\n\n get notice(): string {\n return this._notice;\n }\n\n set notice(value: string | null) {\n // Reactive: writing a new value shows it. `manual` mutes the path entirely\n // (the imperative `notify` command still works). A conforming binder never\n // delivers `undefined` (it skips the write), but a direct assignment can, so\n // normalize null/undefined to a no-op.\n if (value == null) return;\n if (this.manual) return;\n const v = String(value);\n // Same-value guard: only show when the bound source actually changes. To show\n // the same text again on demand, use the `notify` command instead. (This is\n // the only spam guard the package provides — see docs § 2-c; debounce is the\n // caller's job via a filter, e.g. `notice@x|debounce(1000)`.)\n if (v === this._notice) return;\n this._notice = v;\n this.notify(v);\n }\n\n // --- Core delegated getters ---\n\n get permission(): PermissionStateOrUnsupported {\n return this._core.permission;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._core.error;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._core.clicked;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._core.closed;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._core.shown;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<PermissionStateOrUnsupported> {\n return this._core.request();\n }\n\n notify(title: string, options?: NotifyOptions): string {\n // Explicit options (from a command-token emit) win per-key over the attribute\n // defaults, so `notify.emit(title, { body })` still picks up the element's icon.\n return this._core.notify(title, { ...this._options(), ...(options ?? {}) });\n }\n\n close(tag?: string): void {\n this._core.close(tag);\n }\n\n closeAll(): void {\n this._core.closeAll();\n }\n\n // --- Internal ---\n\n private _reflect(name: string, value: string | null): void {\n if (value == null) {\n this.removeAttribute(name);\n } else {\n this.setAttribute(name, String(value));\n }\n }\n\n private _reflectBool(name: string, value: boolean): void {\n if (value) {\n this.setAttribute(name, \"\");\n } else {\n this.removeAttribute(name);\n }\n }\n\n private _options(): NotifyOptions {\n const o: NotifyOptions = {};\n if (this.body !== \"\") o.body = this.body;\n if (this.icon !== \"\") o.icon = this.icon;\n if (this.badge !== \"\") o.badge = this.badge;\n if (this.tag !== \"\") o.tag = this.tag;\n if (this.lang !== \"\") o.lang = this.lang;\n if (this.dir === \"auto\" || this.dir === \"ltr\" || this.dir === \"rtl\") o.dir = this.dir;\n if (this.requireInteraction) o.requireInteraction = true;\n if (this.silent) o.silent = true;\n if (this.renotify) o.renotify = true;\n return o;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Begin observing permission and subscribing to SW click relays (or revive\n // after a reconnect). The returned promise is held as connectedCallbackPromise\n // for SSR.\n this._connectedCallbackPromise = this._core.observe(this.mode);\n }\n\n disconnectedCallback(): void {\n // Detach subscriptions. Open notifications are left on screen (see Core docs);\n // call close()/closeAll() to dismiss.\n this._core.dispose();\n }\n}\n","import { WcsNotify } from \"./components/Notify.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.notify)) {\n customElements.define(config.tagNames.notify, WcsNotify);\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNotification(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n"],"names":[],"mappings":"AAUA,MAAM,OAAO,GAAoB;AAC/B,IAAA,WAAW,EAAE,IAAI;AACjB,IAAA,gBAAgB,EAAE,mBAAmB;AACrC,IAAA,QAAQ,EAAE;AACR,QAAA,MAAM,EAAE,YAAY;AACrB,KAAA;CACF;AAED,SAAS,UAAU,CAAI,GAAM,EAAA;AAC3B,IAAA,IAAI,GAAG,KAAK,IAAI,IAAI,OAAO,GAAG,KAAK,QAAQ;AAAE,QAAA,OAAO,GAAG;AACvD,IAAA,MAAM,CAAC,MAAM,CAAC,GAAG,CAAC;IAClB,KAAK,MAAM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B,EAAE;AACtB;;;;"}
|
package/dist/index.esm.min.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
const t={autoTrigger:!0,triggerAttribute:"data-notifytarget",tagNames:{notify:"wcs-notify"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const i of Object.keys(t))e(t[i]);return t}function i(t){if(null===t||"object"!=typeof t)return t;const e={};for(const s of Object.keys(t))e[s]=i(t[s]);return e}let s=null;const r=t;function n(){return s||(s=e(i(t))),s}class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"permission",event:"wcs-notify:permission-change"},{name:"granted",event:"wcs-notify:permission-change",getter:t=>"granted"===t.detail},{name:"denied",event:"wcs-notify:permission-change",getter:t=>"denied"===t.detail},{name:"prompt",event:"wcs-notify:permission-change",getter:t=>"prompt"===t.detail},{name:"unsupported",event:"wcs-notify:permission-change",getter:t=>"unsupported"===t.detail},{name:"error",event:"wcs-notify:error"},{name:"clicked",event:"wcs-notify:click",getter:t=>t.detail},{name:"closed",event:"wcs-notify:close",getter:t=>t.detail},{name:"shown",event:"wcs-notify:show",getter:t=>t.detail}],commands:[{name:"request",async:!0},{name:"notify"},{name:"close"},{name:"closeAll"}]};_target;_mode="auto";_permission="prompt";_error=null;_lastClick=null;_lastClose=null;_lastShow=null;_permissionStatus=null;_permissionSubscribed=!1;_gen=0;_ready=Promise.resolve();_idSeq=0;_constructed=new Map;_swTags=new Set;_channel=null;_serviceWorker=null;_clicksSubscribed=!1;_seenIds=[];constructor(t){super(),this._target=t??this}get permission(){return this._permission}get granted(){return"granted"===this._permission}get denied(){return"denied"===this._permission}get prompt(){return"prompt"===this._permission}get unsupported(){return"unsupported"===this._permission}get error(){return this._error}get clicked(){return this._lastClick}get closed(){return this._lastClose}get shown(){return this._lastShow}get ready(){return this._ready}_setPermission(t){this._permission!==t&&(this._permission=t,this._target.dispatchEvent(new CustomEvent("wcs-notify:permission-change",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._target.dispatchEvent(new CustomEvent("wcs-notify:error",{detail:t,bubbles:!0})))}_emit(t,e){"click"===t?this._lastClick=e:"close"===t?this._lastClose=e:this._lastShow=e,this._target.dispatchEvent(new CustomEvent(`wcs-notify:${t}`,{detail:e,bubbles:!0}))}observe(t="auto"){return this._mode=t,this._permissionSubscribed||(this._ready=this._initPermission(),this._subscribeClicks()),this._ready}async request(){const t=this._api();if(!t||"function"!=typeof t.requestPermission)return this._setPermission("unsupported"),this._permission;try{const e=await t.requestPermission();this._setPermission(this._normalize(e))}catch{}return this._permission}notify(t,e={}){if(!this._api())return this._setError(this._err("unsupported","Notifications API is not available in this environment.")),"";if("granted"!==this._permission)return this._setError(this._err("not-granted","Notification permission is not granted; call request() first.")),"";if("string"!=typeof t)return this._setError(this._err("invalid-title","notify() requires a string title.")),"";const i="string"==typeof e.tag&&""!==e.tag?e.tag:this._nextId(),s=e.data,r={__wcsId:i,payload:s},n={...e,tag:i,data:r};return this._setError(null),this._show(t,n,i,s),i}close(t){if("string"!=typeof t||""===t)return;const e=this._constructed.get(t);e&&(e.close(),this._constructed.delete(t)),this._swTags.has(t)&&(this._closeSw(t),this._swTags.delete(t))}closeAll(){for(const t of this._constructed.values())t.close();this._constructed.clear();for(const t of this._swTags)this._closeSw(t);this._swTags.clear()}dispose(){this._permissionSubscribed=!1,this._clicksSubscribed=!1,this._gen++,this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null),this._channel&&(this._channel.removeEventListener("message",this._onInbound),this._channel.close(),this._channel=null),this._serviceWorker&&(this._serviceWorker.removeEventListener("message",this._onInbound),this._serviceWorker=null)}_initPermission(){const t=this._api();if(!t)return this._setPermission("unsupported"),Promise.resolve();if(this._permissionSubscribed=!0,"undefined"!=typeof navigator&&navigator.permissions&&"function"==typeof navigator.permissions.query){const e=++this._gen;return navigator.permissions.query({name:"notifications"}).then(t=>{e===this._gen&&(this._permissionStatus=t,this._setPermission(this._normalize(t.state)),t.addEventListener("change",this._onPermissionChange))},()=>{e===this._gen&&this._setPermission(this._normalize(t.permission))})}return this._setPermission(this._normalize(t.permission)),Promise.resolve()}_onPermissionChange=t=>{const e=t.target;this._setPermission(this._normalize(e.state))};_normalize(t){return"default"===t?"prompt":"granted"===t||"denied"===t||"prompt"===t?t:"prompt"}_show(t,e,i,s){if("sw"===this._mode)return void this._showViaSw(t,e,i,s);this._showViaConstructor(t,e,i,s)||("auto"===this._mode?this._showViaSw(t,e,i,s):this._setError(this._err("show-failed",'new Notification() is not usable here and mode="constructor" disallows the Service Worker fallback.')))}_showViaConstructor(t,e,i,s){const r=this._api(),n=this._gen;let o;try{o=new r(t,e)}catch(t){return!(t instanceof TypeError)&&(this._setError(this._err("show-failed","Failed to create the notification.")),!0)}return this._constructed.set(i,o),o.onshow=()=>{n===this._gen&&this._emit("show",{tag:i,data:s,action:""})},o.onclick=()=>{n===this._gen&&this._emit("click",{tag:i,data:s,action:""})},o.onclose=()=>{this._constructed.delete(i),n===this._gen&&this._emit("close",{tag:i,data:s,action:""})},o.onerror=()=>{n===this._gen&&this._setError(this._err("show-failed","The notification failed to display."))},!0}_showViaSw(t,e,i,s){const r=navigator.serviceWorker;if(!r)return void this._setError(this._err("no-service-worker","Service Worker is required to show this notification but is unavailable."));const n=this._gen;this._swTags.add(i),r.ready.then(i=>i.showNotification(t,e)).then(()=>{n===this._gen&&this._emit("show",{tag:i,data:s,action:""})}).catch(()=>{n===this._gen&&this._setError(this._err("show-failed","ServiceWorkerRegistration.showNotification() failed."))})}_closeSw(t){const e=navigator.serviceWorker;e&&e.ready.then(e=>e.getNotifications({tag:t}).then(t=>{for(const e of t)e.close()})).catch(()=>{})}_subscribeClicks(){if(this._clicksSubscribed)return;this._clicksSubscribed=!0,"function"==typeof BroadcastChannel&&(this._channel=new BroadcastChannel("wcs-notify"),this._channel.addEventListener("message",this._onInbound));const t=navigator.serviceWorker;t&&(this._serviceWorker=t,t.addEventListener("message",this._onInbound))}_onInbound=t=>{const e=t.data;e&&!0===e.__wcsNotify&&(this._isDuplicate(e.id)||this._emit("click",{tag:e.tag,data:this._unwrap(e.data),action:e.action}))};_isDuplicate(t){return!!this._seenIds.includes(t)||(this._seenIds.push(t),this._seenIds.length>50&&this._seenIds.shift(),!1)}_unwrap(t){return null!==t&&"object"==typeof t&&"__wcsId"in t?t.payload:t}_api(){const t=globalThis;return"function"==typeof t.Notification?t.Notification:void 0}_nextId(){return"wcs-"+ ++this._idSeq}_err(t,e){return{error:t,message:e}}}let a=!1;function c(t){const e=t.target;if(!(e instanceof Element))return;let i;try{i=e.closest(`[${r.triggerAttribute}]`)}catch{return}if(!i)return;const s=i.getAttribute(r.triggerAttribute);if(!s)return;const n=customElements.get(r.tagNames.notify),o=document.getElementById(s);if(!(n&&o instanceof n))return;const a=i.getAttribute("data-notifytitle"),c=null!==a?a:i.textContent.trim(),h=i.getAttribute("data-notifybody");o.notify(c,null!==h?{body:h}:void 0)}class h extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...o.wcBindable,inputs:[{name:"notice"},{name:"mode",attribute:"mode"},{name:"body",attribute:"body"},{name:"icon",attribute:"icon"},{name:"badge",attribute:"badge"},{name:"tag",attribute:"tag"},{name:"lang",attribute:"lang"},{name:"dir",attribute:"dir"},{name:"requireInteraction",attribute:"require-interaction"},{name:"silent",attribute:"silent"},{name:"renotify",attribute:"renotify"},{name:"manual",attribute:"manual"}],commands:o.wcBindable.commands};_core;_notice="";_connectedCallbackPromise=Promise.resolve();constructor(){super(),this._core=new o(this)}get mode(){const t=this.getAttribute("mode");return"sw"===t||"constructor"===t?t:"auto"}set mode(t){this.setAttribute("mode",t)}get body(){return this.getAttribute("body")??""}set body(t){this._reflect("body",t)}get icon(){return this.getAttribute("icon")??""}set icon(t){this._reflect("icon",t)}get badge(){return this.getAttribute("badge")??""}set badge(t){this._reflect("badge",t)}get tag(){return this.getAttribute("tag")??""}set tag(t){this._reflect("tag",t)}get lang(){return this.getAttribute("lang")??""}set lang(t){this._reflect("lang",t)}get dir(){return this.getAttribute("dir")??""}set dir(t){this._reflect("dir",t)}get requireInteraction(){return this.hasAttribute("require-interaction")}set requireInteraction(t){this._reflectBool("require-interaction",t)}get silent(){return this.hasAttribute("silent")}set silent(t){this._reflectBool("silent",t)}get renotify(){return this.hasAttribute("renotify")}set renotify(t){this._reflectBool("renotify",t)}get manual(){return this.hasAttribute("manual")}set manual(t){this._reflectBool("manual",t)}get notice(){return this._notice}set notice(t){if(null==t)return;if(this.manual)return;const e=String(t);e!==this._notice&&(this._notice=e,this.notify(e))}get permission(){return this._core.permission}get granted(){return this._core.granted}get denied(){return this._core.denied}get prompt(){return this._core.prompt}get unsupported(){return this._core.unsupported}get error(){return this._core.error}get clicked(){return this._core.clicked}get closed(){return this._core.closed}get shown(){return this._core.shown}get connectedCallbackPromise(){return this._connectedCallbackPromise}request(){return this._core.request()}notify(t,e){return this._core.notify(t,{...this._options(),...e??{}})}close(t){this._core.close(t)}closeAll(){this._core.closeAll()}_reflect(t,e){null==e?this.removeAttribute(t):this.setAttribute(t,String(e))}_reflectBool(t,e){e?this.setAttribute(t,""):this.removeAttribute(t)}_options(){const t={};return""!==this.body&&(t.body=this.body),""!==this.icon&&(t.icon=this.icon),""!==this.badge&&(t.badge=this.badge),""!==this.tag&&(t.tag=this.tag),""!==this.lang&&(t.lang=this.lang),"auto"!==this.dir&&"ltr"!==this.dir&&"rtl"!==this.dir||(t.dir=this.dir),this.requireInteraction&&(t.requireInteraction=!0),this.silent&&(t.silent=!0),this.renotify&&(t.renotify=!0),t}connectedCallback(){this.style.display="none",r.autoTrigger&&(a||(a=!0,document.addEventListener("click",c))),this._connectedCallbackPromise=this._core.observe(this.mode)}disconnectedCallback(){this._core.dispose()}}function l(e){var i;e&&("boolean"==typeof(i=e).autoTrigger&&(t.autoTrigger=i.autoTrigger),"string"==typeof i.triggerAttribute&&(t.triggerAttribute=i.triggerAttribute),i.tagNames&&Object.assign(t.tagNames,i.tagNames),s=null),customElements.get(r.tagNames.notify)||customElements.define(r.tagNames.notify,h)}export{o as NotificationCore,h as WcsNotify,l as bootstrapNotification,n as getConfig};
|
|
1
|
+
const t={autoTrigger:!0,triggerAttribute:"data-notifytarget",tagNames:{notify:"wcs-notify"}};function e(t){if(null===t||"object"!=typeof t)return t;Object.freeze(t);for(const i of Object.keys(t))e(t[i]);return t}function i(t){if(null===t||"object"!=typeof t)return t;const e={};for(const s of Object.keys(t))e[s]=i(t[s]);return e}let s=null;const r=t;function n(){return s||(s=e(i(t))),s}class o extends EventTarget{static wcBindable={protocol:"wc-bindable",version:1,properties:[{name:"permission",event:"wcs-notify:permission-change"},{name:"granted",event:"wcs-notify:permission-change",getter:t=>"granted"===t.detail},{name:"denied",event:"wcs-notify:permission-change",getter:t=>"denied"===t.detail},{name:"prompt",event:"wcs-notify:permission-change",getter:t=>"prompt"===t.detail},{name:"unsupported",event:"wcs-notify:permission-change",getter:t=>"unsupported"===t.detail},{name:"error",event:"wcs-notify:error"},{name:"clicked",event:"wcs-notify:click",getter:t=>t.detail},{name:"closed",event:"wcs-notify:close",getter:t=>t.detail},{name:"shown",event:"wcs-notify:show",getter:t=>t.detail}],commands:[{name:"request",async:!0},{name:"notify"},{name:"close"},{name:"closeAll"}]};_target;_mode="auto";_permission="prompt";_error=null;_lastClick=null;_lastClose=null;_lastShow=null;_permissionStatus=null;_permissionSubscribed=!1;_gen=0;_ready=Promise.resolve();_idSeq=0;_constructed=new Map;_swTags=new Set;_channel=null;_serviceWorker=null;_clicksSubscribed=!1;_seenIds=[];constructor(t){super(),this._target=t??this}get permission(){return this._permission}get granted(){return"granted"===this._permission}get denied(){return"denied"===this._permission}get prompt(){return"prompt"===this._permission}get unsupported(){return"unsupported"===this._permission}get error(){return this._error}get clicked(){return this._lastClick}get closed(){return this._lastClose}get shown(){return this._lastShow}get ready(){return this._ready}_setPermission(t){this._permission!==t&&(this._permission=t,this._target.dispatchEvent(new CustomEvent("wcs-notify:permission-change",{detail:t,bubbles:!0})))}_setError(t){this._error!==t&&(this._error=t,this._target.dispatchEvent(new CustomEvent("wcs-notify:error",{detail:t,bubbles:!0})))}_emit(t,e){"click"===t?this._lastClick=e:"close"===t?this._lastClose=e:this._lastShow=e,this._target.dispatchEvent(new CustomEvent(`wcs-notify:${t}`,{detail:e,bubbles:!0}))}observe(t="auto"){return this._mode=t,this._permissionSubscribed||(this._ready=this._initPermission(),this._subscribeClicks()),this._ready}async request(){const t=this._api();if(!t||"function"!=typeof t.requestPermission)return this._setPermission("unsupported"),this._permission;try{const e=await t.requestPermission();this._setPermission(this._normalize(e))}catch{}return this._permission}notify(t,e={}){if(!this._api())return this._setError(this._err("unsupported","Notifications API is not available in this environment.")),"";if("granted"!==this._permission)return this._setError(this._err("not-granted","Notification permission is not granted; call request() first.")),"";if("string"!=typeof t)return this._setError(this._err("invalid-title","notify() requires a string title.")),"";const i="string"==typeof e.tag&&""!==e.tag?e.tag:this._nextId(),s=e.data,r={__wcsId:i,payload:s},n={...e,tag:i,data:r};return this._setError(null),this._show(t,n,i,s),i}close(t){if("string"!=typeof t||""===t)return;const e=this._constructed.get(t);e&&(e.close(),this._constructed.delete(t)),this._swTags.has(t)&&(this._closeSw(t),this._swTags.delete(t))}closeAll(){for(const t of this._constructed.values())t.close();this._constructed.clear();for(const t of this._swTags)this._closeSw(t);this._swTags.clear()}dispose(){this._permissionSubscribed=!1,this._clicksSubscribed=!1,this._gen++,this._permissionStatus&&(this._permissionStatus.removeEventListener("change",this._onPermissionChange),this._permissionStatus=null),this._channel&&(this._channel.removeEventListener("message",this._onInbound),this._channel.close(),this._channel=null),this._serviceWorker&&(this._serviceWorker.removeEventListener("message",this._onInbound),this._serviceWorker=null)}_initPermission(){const t=this._api();if(!t)return this._setPermission("unsupported"),Promise.resolve();if(this._permissionSubscribed=!0,"undefined"!=typeof navigator&&navigator.permissions&&"function"==typeof navigator.permissions.query){const e=++this._gen;return navigator.permissions.query({name:"notifications"}).then(t=>{e===this._gen&&(this._permissionStatus=t,this._setPermission(this._normalize(t.state)),t.addEventListener("change",this._onPermissionChange))},()=>{e===this._gen&&this._setPermission(this._normalize(t.permission))})}return this._setPermission(this._normalize(t.permission)),Promise.resolve()}_onPermissionChange=t=>{const e=t.target;this._setPermission(this._normalize(e.state))};_normalize(t){return"default"===t?"prompt":"granted"===t||"denied"===t||"prompt"===t?t:"prompt"}_show(t,e,i,s){if("sw"===this._mode)return void this._showViaSw(t,e,i,s);this._showViaConstructor(t,e,i,s)||("auto"===this._mode?this._showViaSw(t,e,i,s):this._setError(this._err("show-failed",'new Notification() is not usable here and mode="constructor" disallows the Service Worker fallback.')))}_showViaConstructor(t,e,i,s){const r=this._api(),n=this._gen;let o;try{o=new r(t,e)}catch(t){return!(t instanceof TypeError)&&(this._setError(this._err("show-failed","Failed to create the notification.")),!0)}return this._constructed.set(i,o),o.onshow=()=>{n===this._gen&&this._emit("show",{tag:i,data:s,action:""})},o.onclick=()=>{n===this._gen&&this._emit("click",{tag:i,data:s,action:""})},o.onclose=()=>{this._constructed.delete(i),n===this._gen&&this._emit("close",{tag:i,data:s,action:""})},o.onerror=()=>{n===this._gen&&this._setError(this._err("show-failed","The notification failed to display."))},!0}_showViaSw(t,e,i,s){const r=navigator.serviceWorker;if(!r)return void this._setError(this._err("no-service-worker","Service Worker is required to show this notification but is unavailable."));const n=this._gen;this._swTags.add(i),r.ready.then(i=>i.showNotification(t,e)).then(()=>{n===this._gen&&this._emit("show",{tag:i,data:s,action:""})}).catch(()=>{n===this._gen&&this._setError(this._err("show-failed","ServiceWorkerRegistration.showNotification() failed."))})}_closeSw(t){const e=navigator.serviceWorker;e&&e.ready.then(e=>e.getNotifications({tag:t}).then(t=>{for(const e of t)e.close()})).catch(()=>{})}_subscribeClicks(){if(this._clicksSubscribed)return;this._clicksSubscribed=!0,"function"==typeof BroadcastChannel&&(this._channel=new BroadcastChannel("wcs-notify"),this._channel.addEventListener("message",this._onInbound));const t=navigator.serviceWorker;t&&(this._serviceWorker=t,t.addEventListener("message",this._onInbound))}_onInbound=t=>{const e=t.data;e&&!0===e.__wcsNotify&&(this._isDuplicate(e.id)||this._emit("click",{tag:e.tag,data:this._unwrap(e.data),action:e.action}))};_isDuplicate(t){return!!this._seenIds.includes(t)||(this._seenIds.push(t),this._seenIds.length>50&&this._seenIds.shift(),!1)}_unwrap(t){return null!==t&&"object"==typeof t&&"__wcsId"in t?t.payload:t}_api(){const t=globalThis;return"function"==typeof t.Notification?t.Notification:void 0}_nextId(){return"wcs-"+ ++this._idSeq}_err(t,e){return{error:t,message:e}}}let a=!1;function c(t){const e=t.target;if(!(e instanceof Element))return;let i;try{i=e.closest(`[${r.triggerAttribute}]`)}catch{return}if(!i)return;const s=i.getAttribute(r.triggerAttribute);if(!s)return;const n=customElements.get(r.tagNames.notify),o=document.getElementById(s);if(!(n&&o instanceof n))return;const a=i.getAttribute("data-notifytitle"),c=null!==a?a:i.textContent.trim(),h=i.getAttribute("data-notifybody");o.notify(c,null!==h?{body:h}:void 0)}class h extends HTMLElement{static hasConnectedCallbackPromise=!0;static wcBindable={...o.wcBindable,inputs:[{name:"notice"},{name:"mode",attribute:"mode"},{name:"body",attribute:"body"},{name:"icon",attribute:"icon"},{name:"badge",attribute:"badge"},{name:"tag",attribute:"tag"},{name:"lang",attribute:"lang"},{name:"dir",attribute:"dir"},{name:"requireInteraction",attribute:"require-interaction"},{name:"silent",attribute:"silent"},{name:"renotify",attribute:"renotify"},{name:"manual",attribute:"manual"}],commands:o.wcBindable.commands};_core;_notice="";_connectedCallbackPromise=Promise.resolve();_internals=null;constructor(){super(),this._core=new o(this),this._internals=this._initInternals(),this._wireStates({"wcs-notify:permission-change":t=>({granted:"granted"===t,denied:"denied"===t,prompt:"prompt"===t,unsupported:"unsupported"===t}),"wcs-notify:error":t=>({error:null!=t})})}get debugStates(){return this._internals?[...this._internals.states]:[]}_initInternals(){try{if("function"!=typeof this.attachInternals)return null;const t=this.attachInternals();return t.states.add("wcs-probe"),t.states.delete("wcs-probe"),t}catch{return null}}_wireStates(t){if(null===this._internals)return;const e=this._internals.states;for(const[i,s]of Object.entries(t))this.addEventListener(i,t=>{const i=this.hasAttribute("debug-states");for(const[r,n]of Object.entries(s(t.detail))){try{n?e.add(r):e.delete(r)}catch{}i&&this.toggleAttribute(`data-wcs-state-${r}`,n)}})}get mode(){const t=this.getAttribute("mode");return"sw"===t||"constructor"===t?t:"auto"}set mode(t){this.setAttribute("mode",t)}get body(){return this.getAttribute("body")??""}set body(t){this._reflect("body",t)}get icon(){return this.getAttribute("icon")??""}set icon(t){this._reflect("icon",t)}get badge(){return this.getAttribute("badge")??""}set badge(t){this._reflect("badge",t)}get tag(){return this.getAttribute("tag")??""}set tag(t){this._reflect("tag",t)}get lang(){return this.getAttribute("lang")??""}set lang(t){this._reflect("lang",t)}get dir(){return this.getAttribute("dir")??""}set dir(t){this._reflect("dir",t)}get requireInteraction(){return this.hasAttribute("require-interaction")}set requireInteraction(t){this._reflectBool("require-interaction",t)}get silent(){return this.hasAttribute("silent")}set silent(t){this._reflectBool("silent",t)}get renotify(){return this.hasAttribute("renotify")}set renotify(t){this._reflectBool("renotify",t)}get manual(){return this.hasAttribute("manual")}set manual(t){this._reflectBool("manual",t)}get notice(){return this._notice}set notice(t){if(null==t)return;if(this.manual)return;const e=String(t);e!==this._notice&&(this._notice=e,this.notify(e))}get permission(){return this._core.permission}get granted(){return this._core.granted}get denied(){return this._core.denied}get prompt(){return this._core.prompt}get unsupported(){return this._core.unsupported}get error(){return this._core.error}get clicked(){return this._core.clicked}get closed(){return this._core.closed}get shown(){return this._core.shown}get connectedCallbackPromise(){return this._connectedCallbackPromise}request(){return this._core.request()}notify(t,e){return this._core.notify(t,{...this._options(),...e??{}})}close(t){this._core.close(t)}closeAll(){this._core.closeAll()}_reflect(t,e){null==e?this.removeAttribute(t):this.setAttribute(t,String(e))}_reflectBool(t,e){e?this.setAttribute(t,""):this.removeAttribute(t)}_options(){const t={};return""!==this.body&&(t.body=this.body),""!==this.icon&&(t.icon=this.icon),""!==this.badge&&(t.badge=this.badge),""!==this.tag&&(t.tag=this.tag),""!==this.lang&&(t.lang=this.lang),"auto"!==this.dir&&"ltr"!==this.dir&&"rtl"!==this.dir||(t.dir=this.dir),this.requireInteraction&&(t.requireInteraction=!0),this.silent&&(t.silent=!0),this.renotify&&(t.renotify=!0),t}connectedCallback(){this.style.display="none",r.autoTrigger&&(a||(a=!0,document.addEventListener("click",c))),this._connectedCallbackPromise=this._core.observe(this.mode)}disconnectedCallback(){this._core.dispose()}}function l(e){var i;e&&("boolean"==typeof(i=e).autoTrigger&&(t.autoTrigger=i.autoTrigger),"string"==typeof i.triggerAttribute&&(t.triggerAttribute=i.triggerAttribute),i.tagNames&&Object.assign(t.tagNames,i.tagNames),s=null),customElements.get(r.tagNames.notify)||customElements.define(r.tagNames.notify,h)}export{o as NotificationCore,h as WcsNotify,l as bootstrapNotification,n as getConfig};
|
|
2
2
|
//# sourceMappingURL=index.esm.min.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/NotificationCore.ts","../src/autoTrigger.ts","../src/components/Notify.ts","../src/bootstrapNotification.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n notify: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-notifytarget\",\n tagNames: {\n notify: \"wcs-notify\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\n// Internal, mutable live config used by the components/autoTrigger (they read it\n// at call time so setConfig() takes effect without re-import). Typed as the\n// readonly IConfig at the export boundary — the `as IConfig` is a compile-time\n// view only and does NOT freeze the object, so this export must stay\n// package-internal (it is not re-exported from exports.ts). Public consumers get\n// the deep-frozen clone from getConfig() instead.\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, NotifyBackend, NotifyOptions, NotificationPermissionRaw,\n PermissionStateOrUnsupported, WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\n\n// Wrapper stored in a notification's `data` so the Service Worker side (a\n// separate global scope with no access to this instance) can recover the\n// identity and the caller's payload. The constructor backend uses the same\n// wrapper for uniformity, and both paths unwrap it before emitting.\ninterface WcsNotifyData {\n __wcsId: string;\n payload: unknown;\n}\n\n// Message shape posted by `wireNotificationClicks()` (src/sw.ts) over both\n// BroadcastChannel and clients.postMessage. `id` is unique per click\n// (`tag#seq`), so the two transports delivering the *same* click de-dup, while\n// two genuine clicks on the same `tag` do not.\ninterface WcsNotifyInbound {\n __wcsNotify: true;\n id: string;\n tag: string;\n data: unknown;\n action: string;\n}\n\n/**\n * Headless desktop-notification primitive. A thin, framework-agnostic wrapper\n * around the Notifications API exposed through the wc-bindable protocol.\n *\n * Unlike `@wcstack/permission` (a read-only monitor — the Permissions API has no\n * `request()`), the Notifications API *does* expose `Notification.requestPermission()`,\n * so this node is self-contained: it both **requests/monitors** the permission and\n * **shows** notifications. It is the first @wcstack node where the command-token\n * (show: `notify`) and event-token (`click` / `close` / `show`) directions both\n * live in one tag.\n *\n * - **request()** asks for the `notifications` permission (`Notification.requestPermission`).\n * - **notify(title, options)** shows a notification and returns its identifying tag\n * (a caller `options.tag`, or a generated `wcs-<n>`). It picks a backend per\n * `mode`: the `Notification` constructor (desktop) or\n * `ServiceWorkerRegistration.showNotification()` (mobile). `\"auto\"` prefers the\n * constructor and falls back to the SW on a `TypeError`.\n * - **close(tag) / closeAll()** dismiss notifications by tag / all.\n * - Clicks flow back as the `wcs-notify:click` event: directly via the\n * Notification's `onclick` (constructor), or via the SW helper's\n * BroadcastChannel/postMessage relay (SW). `permission` mirrors the live grant.\n *\n * Failures never throw: they surface through `error` (and the `unsupported`\n * permission state) so they flow into the declarative state.\n */\nexport class NotificationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"permission\", event: \"wcs-notify:permission-change\" },\n { name: \"granted\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n { name: \"error\", event: \"wcs-notify:error\" },\n { name: \"clicked\", event: \"wcs-notify:click\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"closed\", event: \"wcs-notify:close\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"shown\", event: \"wcs-notify:show\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"notify\" },\n { name: \"close\" },\n { name: \"closeAll\" },\n ],\n };\n\n private _target: EventTarget;\n private _mode: NotifyBackend = \"auto\";\n\n private _permission: PermissionStateOrUnsupported = \"prompt\";\n private _error: WcsNotifyErrorDetail | null = null;\n private _lastClick: WcsNotifyClickDetail | null = null;\n private _lastClose: WcsNotifyClickDetail | null = null;\n private _lastShow: WcsNotifyClickDetail | null = null;\n\n // Live PermissionStatus (when the Permissions API can query `notifications`),\n // kept so its `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n // True once a permission subscription has been (or is being) established; reset\n // by dispose(). Guards observe() so a reconnect re-queries while a redundant\n // observe() on a live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current lifecycle. Bumped by every observe() and by\n // dispose(). In-flight async work (permission query, SW show, inbound click)\n // captures it and bails if stale, so a query/click that resolves after a\n // disconnect — or after a rapid disconnect→reconnect — never mutates state or\n // dispatches on a torn-down element.\n private _gen: number = 0;\n\n // Resolves once the connect-time permission probe settles. The Shell exposes\n // this as connectedCallbackPromise so SSR can await it before snapshotting.\n private _ready: Promise<void> = Promise.resolve();\n\n // Counter for auto-assigned tags when the caller omits one.\n private _idSeq: number = 0;\n\n // Notifications created via the constructor backend, by tag, so close()/closeAll()\n // can dismiss them. The SW backend has no handle (showNotification returns void),\n // so its tags are tracked separately and closed via registration.getNotifications().\n private _constructed: Map<string, Notification> = new Map();\n private _swTags: Set<string> = new Set();\n\n // Click subscription handles (SW relay).\n private _channel: BroadcastChannel | null = null;\n private _serviceWorker: ServiceWorkerContainer | null = null;\n private _clicksSubscribed: boolean = false;\n // Per-click ids already handled, to de-dup the two relay transports. FIFO-capped\n // so a long session does not leak; the two transports always arrive in the same\n // tick, so a small cap is ample.\n private _seenIds: string[] = [];\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get permission(): PermissionStateOrUnsupported {\n return this._permission;\n }\n\n get granted(): boolean {\n return this._permission === \"granted\";\n }\n\n get denied(): boolean {\n return this._permission === \"denied\";\n }\n\n get prompt(): boolean {\n return this._permission === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._permission === \"unsupported\";\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._error;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._lastClick;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._lastClose;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._lastShow;\n }\n\n /** Resolves once the current (or initial) permission probe settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPermission(state: PermissionStateOrUnsupported): void {\n if (this._permission === state) return;\n this._permission = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:permission-change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsNotifyErrorDetail | null): void {\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _emit(kind: \"click\" | \"close\" | \"show\", detail: WcsNotifyClickDetail): void {\n if (kind === \"click\") this._lastClick = detail;\n else if (kind === \"close\") this._lastClose = detail;\n else this._lastShow = detail;\n this._target.dispatchEvent(new CustomEvent(`wcs-notify:${kind}`, {\n detail,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing the `notifications` permission and subscribing to Service\n * Worker click relays. `mode` selects the show backend (default `\"auto\"`).\n * Idempotent while already subscribed: it only updates the stored mode; to\n * restart, dispose() first. Returns a promise that resolves once the first\n * permission probe settles, for SSR.\n *\n * Headless callers must call observe() to begin; the Shell calls it from\n * connectedCallback once the element's attributes resolve.\n */\n observe(mode: NotifyBackend = \"auto\"): Promise<void> {\n this._mode = mode;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n this._subscribeClicks();\n }\n return this._ready;\n }\n\n /**\n * Ask the user for the `notifications` permission. Resolves to the resulting\n * (normalized) permission state. Never throws: an unavailable API resolves to\n * `\"unsupported\"`.\n */\n async request(): Promise<PermissionStateOrUnsupported> {\n const api = this._api();\n if (!api || typeof api.requestPermission !== \"function\") {\n this._setPermission(\"unsupported\");\n return this._permission;\n }\n try {\n const result = await api.requestPermission();\n this._setPermission(this._normalize(result));\n } catch {\n // Some legacy engines may reject; keep the current state rather than throw.\n }\n return this._permission;\n }\n\n /**\n * Show a notification. Returns the identifying tag (the caller's `options.tag`,\n * or a generated `wcs-<n>` when omitted). Never throws: when the API is\n * unavailable or the permission is not granted it surfaces an `error` and\n * returns an empty string.\n */\n notify(title: string, options: NotifyOptions = {}): string {\n if (!this._api()) {\n this._setError(this._err(\"unsupported\", \"Notifications API is not available in this environment.\"));\n return \"\";\n }\n if (this._permission !== \"granted\") {\n this._setError(this._err(\"not-granted\", \"Notification permission is not granted; call request() first.\"));\n return \"\";\n }\n if (typeof title !== \"string\") {\n this._setError(this._err(\"invalid-title\", \"notify() requires a string title.\"));\n return \"\";\n }\n\n const tag = (typeof options.tag === \"string\" && options.tag !== \"\") ? options.tag : this._nextId();\n const payload = options.data;\n const data: WcsNotifyData = { __wcsId: tag, payload };\n const backendOptions: NotifyOptions = { ...options, tag, data };\n\n this._setError(null);\n this._show(title, backendOptions, tag, payload);\n return tag;\n }\n\n /** Dismiss the notification(s) with `tag` across both backends. */\n close(tag?: string): void {\n if (typeof tag !== \"string\" || tag === \"\") return;\n const n = this._constructed.get(tag);\n if (n) {\n n.close();\n this._constructed.delete(tag);\n }\n if (this._swTags.has(tag)) {\n this._closeSw(tag);\n this._swTags.delete(tag);\n }\n }\n\n /**\n * Dismiss every notification this instance has shown. Scoped to this instance's\n * own tags on both backends — the SW path closes each tracked tag individually\n * rather than enumerating the whole origin, so it never dismisses notifications\n * shown by another `<wcs-notify>` or by an unrelated code path.\n */\n closeAll(): void {\n for (const n of this._constructed.values()) {\n n.close();\n }\n this._constructed.clear();\n for (const tag of this._swTags) {\n this._closeSw(tag);\n }\n this._swTags.clear();\n }\n\n /**\n * Detach permission and click subscriptions. Open notifications are intentionally\n * **left on screen** (a notification outlives the page that posted it — that is\n * the point); use close()/closeAll() to dismiss. Call from the Shell's\n * disconnectedCallback. A later observe() resumes.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n this._clicksSubscribed = false;\n this._gen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n if (this._channel) {\n this._channel.removeEventListener(\"message\", this._onInbound);\n this._channel.close();\n this._channel = null;\n }\n if (this._serviceWorker) {\n this._serviceWorker.removeEventListener(\"message\", this._onInbound);\n this._serviceWorker = null;\n }\n }\n\n // --- Internal: permission ---\n\n private _initPermission(): Promise<void> {\n const api = this._api();\n if (!api) {\n this._setPermission(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no permission\n // listener to tear down, so a reconnect simply re-probes (idempotent — the\n // same-value guard suppresses any redundant dispatch and no listener is ever\n // attached). _subscribeClicks() is re-entered too, but its own\n // _clicksSubscribed guard short-circuits the second pass, so no transport is\n // double-subscribed. Mirrors @wcstack/permission's unsupported path.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n // Prefer the Permissions API: it provides a live `change` event. Fall back to\n // the static `Notification.permission` when it is absent or rejects the\n // `notifications` descriptor.\n if (typeof navigator !== \"undefined\" && navigator.permissions && typeof navigator.permissions.query === \"function\") {\n const gen = ++this._gen;\n return navigator.permissions.query({ name: \"notifications\" }).then(\n (status) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._gen) return;\n // Permissions API rejected the `notifications` descriptor — fall back to\n // the static `Notification.permission` (api is in scope and non-null here).\n this._setPermission(this._normalize(api.permission));\n },\n );\n }\n // No Permissions API: read the static permission once (no live change events).\n this._setPermission(this._normalize(api.permission));\n return Promise.resolve();\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n };\n\n // Normalize the Notifications API's `\"default\"` to `\"prompt\"` so this node shares\n // the four-value surface of @wcstack/permission. The Permissions API already\n // reports `\"prompt\"`, so it passes through unchanged.\n private _normalize(raw: NotificationPermissionRaw | string): PermissionStateOrUnsupported {\n if (raw === \"default\") return \"prompt\";\n if (raw === \"granted\" || raw === \"denied\" || raw === \"prompt\") return raw;\n return \"prompt\";\n }\n\n // --- Internal: showing ---\n\n private _show(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n if (this._mode === \"sw\") {\n this._showViaSw(title, options, tag, payload);\n return;\n }\n const handled = this._showViaConstructor(title, options, tag, payload);\n if (handled) return;\n // Constructor threw TypeError (e.g. mobile, where `new Notification` is illegal).\n if (this._mode === \"auto\") {\n this._showViaSw(title, options, tag, payload);\n } else {\n this._setError(this._err(\"show-failed\", \"new Notification() is not usable here and mode=\\\"constructor\\\" disallows the Service Worker fallback.\"));\n }\n }\n\n // Returns false only when the constructor threw a TypeError (the signal to fall\n // back to the SW backend); true when it showed or surfaced a non-TypeError error.\n private _showViaConstructor(title: string, options: NotifyOptions, tag: string, payload: unknown): boolean {\n const api = this._api()!;\n const gen = this._gen;\n let n: Notification;\n try {\n n = new api(title, options as NotificationOptions);\n } catch (e) {\n if (e instanceof TypeError) return false;\n this._setError(this._err(\"show-failed\", \"Failed to create the notification.\"));\n return true;\n }\n this._constructed.set(tag, n);\n n.onshow = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n };\n n.onclick = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"click\", { tag, data: payload, action: \"\" });\n };\n n.onclose = (): void => {\n this._constructed.delete(tag);\n if (gen !== this._gen) return;\n this._emit(\"close\", { tag, data: payload, action: \"\" });\n };\n n.onerror = (): void => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"The notification failed to display.\"));\n };\n return true;\n }\n\n private _showViaSw(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) {\n this._setError(this._err(\"no-service-worker\", \"Service Worker is required to show this notification but is unavailable.\"));\n return;\n }\n const gen = this._gen;\n this._swTags.add(tag);\n // A notification deliberately outlives the page (see § dispose), so we do NOT\n // bail before showNotification on a stale gen — a notify() issued while\n // connected still shows. The stale-gen guards only suppress dispatching the\n // observable `show` / `error` back onto a torn-down element.\n sw.ready\n .then((registration) => registration.showNotification(title, options as NotificationOptions))\n .then(() => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n })\n .catch(() => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"ServiceWorkerRegistration.showNotification() failed.\"));\n });\n }\n\n // Close the SW notification(s) carrying `tag`. Always scoped to a single tag —\n // both callers (close / closeAll) iterate their own tracked tags, so the whole\n // origin is never enumerated.\n private _closeSw(tag: string): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) return;\n sw.ready.then((registration) => {\n return registration.getNotifications({ tag }).then((list) => {\n for (const n of list) n.close();\n });\n }).catch(() => {\n // Closing is best-effort; a failure to enumerate is not surfaced.\n });\n }\n\n // --- Internal: click relay (SW) ---\n\n private _subscribeClicks(): void {\n if (this._clicksSubscribed) return;\n this._clicksSubscribed = true;\n if (typeof BroadcastChannel === \"function\") {\n this._channel = new BroadcastChannel(\"wcs-notify\");\n this._channel.addEventListener(\"message\", this._onInbound);\n }\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (sw) {\n this._serviceWorker = sw;\n sw.addEventListener(\"message\", this._onInbound);\n }\n }\n\n private _onInbound = (event: Event): void => {\n const msg = (event as MessageEvent).data as WcsNotifyInbound | undefined;\n if (!msg || msg.__wcsNotify !== true) return;\n if (this._isDuplicate(msg.id)) return;\n this._emit(\"click\", { tag: msg.tag, data: this._unwrap(msg.data), action: msg.action });\n };\n\n private _isDuplicate(id: string): boolean {\n if (this._seenIds.includes(id)) return true;\n this._seenIds.push(id);\n if (this._seenIds.length > 50) this._seenIds.shift();\n return false;\n }\n\n private _unwrap(raw: unknown): unknown {\n if (raw !== null && typeof raw === \"object\" && \"__wcsId\" in raw) {\n return (raw as WcsNotifyData).payload;\n }\n return raw;\n }\n\n // --- Internal: misc ---\n\n // Resolve the global `Notification` constructor at call time (not cached) so\n // tests can install/remove it and so unsupported environments report correctly.\n private _api(): (typeof Notification) | undefined {\n const g = globalThis as unknown as { Notification?: typeof Notification };\n return typeof g.Notification === \"function\" ? g.Notification : undefined;\n }\n\n private _nextId(): string {\n return `wcs-${++this._idSeq}`;\n }\n\n private _err(error: string, message: string): WcsNotifyErrorDetail {\n return { error, message };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsNotify } from \"./components/Notify.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n // A misconfigured triggerAttribute (e.g. one with a space) makes the attribute\n // selector invalid and closest() throw SyntaxError; guard so a bad config\n // disables only this shortcut rather than killing every document click handler.\n let triggerElement: Element | null;\n try {\n triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n } catch {\n return;\n }\n if (!triggerElement) return;\n\n const notifyId = triggerElement.getAttribute(config.triggerAttribute);\n if (!notifyId) return;\n\n // Resolve the registered constructor at call time instead of importing Notify as\n // a value, avoiding a components/Notify.ts ⇄ autoTrigger.ts cycle\n // (Notify.connectedCallback() calls registerAutoTrigger()). instanceof against\n // the customElements registry keeps the same identity guarantee.\n const NotifyCtor = customElements.get(config.tagNames.notify);\n const notifyElement = document.getElementById(notifyId);\n if (!NotifyCtor || !(notifyElement instanceof NotifyCtor)) return;\n\n // The title comes from the trigger element: an explicit `data-notifytitle`\n // attribute wins, otherwise the element's trimmed text content. The body is an\n // optional `data-notifybody`. This keeps the click-driven shortcut declarative\n // without inventing a payload channel.\n const explicit = triggerElement.getAttribute(\"data-notifytitle\");\n // `Element.textContent` is spec-guaranteed non-null (only Document / DocumentType\n // nodes return null, never an Element), so the cast is sound and lets us avoid an\n // unreachable `?? \"\"` branch. `triggerElement` is always an Element here.\n const title = explicit !== null ? explicit : (triggerElement.textContent as string).trim();\n const body = triggerElement.getAttribute(\"data-notifybody\");\n\n (notifyElement as WcsNotify).notify(title, body !== null ? { body } : undefined);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, NotifyBackend, NotifyOptions, PermissionStateOrUnsupported,\n WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { NotificationCore } from \"../core/NotificationCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n/**\n * `<wcs-notify>` — declarative desktop notifications. Wraps NotificationCore and\n * exposes both directions in one tag:\n *\n * - **`notice`** (reactive input): writing a *changed* value shows a notification,\n * suppressing same-value writes so it fires only when the bound source actually\n * changes. The imperative `notify` command instead shows on demand (even the\n * same text again). See `docs/notification-tag-design.md` § 2.\n * - **`request` / `notify` / `close` / `closeAll`** commands (state → element).\n * - per-notification options (`body` / `icon` / `badge` / `tag` / `lang` / `dir` /\n * `require-interaction` / `silent` / `renotify`) as mirrored attributes.\n * - `mode` selects the show backend (`auto` / `sw` / `constructor`).\n * - the Core's observable surface (permission / granted / … / error / clicked /\n * closed / shown) via delegated getters; clicked/closed/shown carry the\n * `{ tag, data, action }` payload for event-token wiring.\n */\nexport class WcsNotify extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...NotificationCore.wcBindable,\n // Shell-level settable surface. `notice` is a momentary reactive command-property\n // with no mirrored attribute (it carries dynamic text, not declarative config),\n // mirroring <wcs-speak>'s `say`. The rest mirror their HTML attributes idempotently.\n inputs: [\n { name: \"notice\" },\n { name: \"mode\", attribute: \"mode\" },\n { name: \"body\", attribute: \"body\" },\n { name: \"icon\", attribute: \"icon\" },\n { name: \"badge\", attribute: \"badge\" },\n { name: \"tag\", attribute: \"tag\" },\n { name: \"lang\", attribute: \"lang\" },\n { name: \"dir\", attribute: \"dir\" },\n { name: \"requireInteraction\", attribute: \"require-interaction\" },\n { name: \"silent\", attribute: \"silent\" },\n { name: \"renotify\", attribute: \"renotify\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n commands: NotificationCore.wcBindable.commands,\n };\n\n private _core: NotificationCore;\n private _notice: string = \"\";\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n\n constructor() {\n super();\n this._core = new NotificationCore(this);\n }\n\n // --- Attribute accessors ---\n\n get mode(): NotifyBackend {\n const m = this.getAttribute(\"mode\");\n return (m === \"sw\" || m === \"constructor\") ? m : \"auto\";\n }\n\n set mode(value: NotifyBackend) {\n this.setAttribute(\"mode\", value);\n }\n\n get body(): string {\n return this.getAttribute(\"body\") ?? \"\";\n }\n\n set body(value: string | null) {\n this._reflect(\"body\", value);\n }\n\n get icon(): string {\n return this.getAttribute(\"icon\") ?? \"\";\n }\n\n set icon(value: string | null) {\n this._reflect(\"icon\", value);\n }\n\n get badge(): string {\n return this.getAttribute(\"badge\") ?? \"\";\n }\n\n set badge(value: string | null) {\n this._reflect(\"badge\", value);\n }\n\n get tag(): string {\n return this.getAttribute(\"tag\") ?? \"\";\n }\n\n set tag(value: string | null) {\n this._reflect(\"tag\", value);\n }\n\n // NOTE: `lang` and `dir` intentionally repurpose the standard HTMLElement IDL\n // attributes as per-notification options (forwarded to NotificationOptions).\n // This element is always display:none, so overriding their normal rendering\n // semantics has no visual effect — but be aware the values mean \"the\n // notification's language/direction\", not the host element's.\n get lang(): string {\n return this.getAttribute(\"lang\") ?? \"\";\n }\n\n set lang(value: string | null) {\n this._reflect(\"lang\", value);\n }\n\n get dir(): string {\n return this.getAttribute(\"dir\") ?? \"\";\n }\n\n set dir(value: string | null) {\n this._reflect(\"dir\", value);\n }\n\n get requireInteraction(): boolean {\n return this.hasAttribute(\"require-interaction\");\n }\n\n set requireInteraction(value: boolean) {\n this._reflectBool(\"require-interaction\", value);\n }\n\n get silent(): boolean {\n return this.hasAttribute(\"silent\");\n }\n\n set silent(value: boolean) {\n this._reflectBool(\"silent\", value);\n }\n\n get renotify(): boolean {\n return this.hasAttribute(\"renotify\");\n }\n\n set renotify(value: boolean) {\n this._reflectBool(\"renotify\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n this._reflectBool(\"manual\", value);\n }\n\n // --- Reactive command-property ---\n\n get notice(): string {\n return this._notice;\n }\n\n set notice(value: string | null) {\n // Reactive: writing a new value shows it. `manual` mutes the path entirely\n // (the imperative `notify` command still works). A conforming binder never\n // delivers `undefined` (it skips the write), but a direct assignment can, so\n // normalize null/undefined to a no-op.\n if (value == null) return;\n if (this.manual) return;\n const v = String(value);\n // Same-value guard: only show when the bound source actually changes. To show\n // the same text again on demand, use the `notify` command instead. (This is\n // the only spam guard the package provides — see docs § 2-c; debounce is the\n // caller's job via a filter, e.g. `notice@x|debounce(1000)`.)\n if (v === this._notice) return;\n this._notice = v;\n this.notify(v);\n }\n\n // --- Core delegated getters ---\n\n get permission(): PermissionStateOrUnsupported {\n return this._core.permission;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._core.error;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._core.clicked;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._core.closed;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._core.shown;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<PermissionStateOrUnsupported> {\n return this._core.request();\n }\n\n notify(title: string, options?: NotifyOptions): string {\n // Explicit options (from a command-token emit) win per-key over the attribute\n // defaults, so `notify.emit(title, { body })` still picks up the element's icon.\n return this._core.notify(title, { ...this._options(), ...(options ?? {}) });\n }\n\n close(tag?: string): void {\n this._core.close(tag);\n }\n\n closeAll(): void {\n this._core.closeAll();\n }\n\n // --- Internal ---\n\n private _reflect(name: string, value: string | null): void {\n if (value == null) {\n this.removeAttribute(name);\n } else {\n this.setAttribute(name, String(value));\n }\n }\n\n private _reflectBool(name: string, value: boolean): void {\n if (value) {\n this.setAttribute(name, \"\");\n } else {\n this.removeAttribute(name);\n }\n }\n\n private _options(): NotifyOptions {\n const o: NotifyOptions = {};\n if (this.body !== \"\") o.body = this.body;\n if (this.icon !== \"\") o.icon = this.icon;\n if (this.badge !== \"\") o.badge = this.badge;\n if (this.tag !== \"\") o.tag = this.tag;\n if (this.lang !== \"\") o.lang = this.lang;\n if (this.dir === \"auto\" || this.dir === \"ltr\" || this.dir === \"rtl\") o.dir = this.dir;\n if (this.requireInteraction) o.requireInteraction = true;\n if (this.silent) o.silent = true;\n if (this.renotify) o.renotify = true;\n return o;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Begin observing permission and subscribing to SW click relays (or revive\n // after a reconnect). The returned promise is held as connectedCallbackPromise\n // for SSR.\n this._connectedCallbackPromise = this._core.observe(this.mode);\n }\n\n disconnectedCallback(): void {\n // Detach subscriptions. Open notifications are left on screen (see Core docs);\n // call close()/closeAll() to dismiss.\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNotification(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsNotify } from \"./components/Notify.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.notify)) {\n customElements.define(config.tagNames.notify, WcsNotify);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","notify","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","NotificationCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","commands","async","_target","_mode","_permission","_error","_lastClick","_lastClose","_lastShow","_permissionStatus","_permissionSubscribed","_gen","_ready","Promise","resolve","_idSeq","_constructed","Map","_swTags","Set","_channel","_serviceWorker","_clicksSubscribed","_seenIds","constructor","target","super","this","permission","granted","denied","prompt","unsupported","error","clicked","closed","shown","ready","_setPermission","state","dispatchEvent","CustomEvent","bubbles","_setError","_emit","kind","observe","mode","_initPermission","_subscribeClicks","request","api","_api","requestPermission","result","_normalize","title","options","_err","tag","_nextId","payload","data","__wcsId","backendOptions","_show","close","n","get","delete","has","_closeSw","closeAll","values","clear","dispose","removeEventListener","_onPermissionChange","_onInbound","navigator","permissions","query","gen","then","status","addEventListener","raw","_showViaSw","_showViaConstructor","TypeError","set","onshow","action","onclick","onclose","onerror","sw","serviceWorker","add","registration","showNotification","catch","getNotifications","list","BroadcastChannel","msg","__wcsNotify","_isDuplicate","id","_unwrap","includes","push","length","shift","g","globalThis","Notification","undefined","message","registered","handleClick","Element","triggerElement","closest","notifyId","getAttribute","NotifyCtor","customElements","notifyElement","document","getElementById","explicit","textContent","trim","body","WcsNotify","HTMLElement","wcBindable","inputs","attribute","_core","_notice","_connectedCallbackPromise","m","value","setAttribute","_reflect","icon","badge","lang","dir","requireInteraction","hasAttribute","_reflectBool","silent","renotify","manual","notice","v","String","connectedCallbackPromise","_options","removeAttribute","o","connectedCallback","style","display","disconnectedCallback","bootstrapNotification","userConfig","partialConfig","assign","define"],"mappings":"AAUA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,oBAClBC,SAAU,CACRC,OAAQ,eAIZ,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA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I/CZD,GJgDanM,cACvBD,EAAQC,YAAcoM,EAAcpM,aAEQ,iBAAnCoM,EAAcnM,mBACvBF,EAAQE,iBAAmBmM,EAAcnM,kBAEvCmM,EAAclM,UAChBI,OAAO+L,OAAOtM,EAAQG,SAAUkM,EAAclM,UAEhDU,EAAe,MK3DV6I,eAAe3D,IAAIjF,EAAOX,SAASC,SACtCsJ,eAAe6C,OAAOzL,EAAOX,SAASC,OAAQ8J,EDIlD"}
|
|
1
|
+
{"version":3,"file":"index.esm.min.js","sources":["../src/config.ts","../src/core/NotificationCore.ts","../src/autoTrigger.ts","../src/components/Notify.ts","../src/bootstrapNotification.ts","../src/registerComponents.ts"],"sourcesContent":["import { IConfig, IWritableConfig } from \"./types.js\";\n\ninterface IInternalConfig extends IConfig {\n autoTrigger: boolean;\n triggerAttribute: string;\n tagNames: {\n notify: string;\n };\n}\n\nconst _config: IInternalConfig = {\n autoTrigger: true,\n triggerAttribute: \"data-notifytarget\",\n tagNames: {\n notify: \"wcs-notify\",\n },\n};\n\nfunction deepFreeze<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n Object.freeze(obj);\n for (const key of Object.keys(obj)) {\n deepFreeze((obj as Record<string, unknown>)[key]);\n }\n return obj;\n}\n\nfunction deepClone<T>(obj: T): T {\n if (obj === null || typeof obj !== \"object\") return obj;\n const clone: Record<string, unknown> = {};\n for (const key of Object.keys(obj)) {\n clone[key] = deepClone((obj as Record<string, unknown>)[key]);\n }\n return clone as T;\n}\n\nlet frozenConfig: IConfig | null = null;\n\n// Internal, mutable live config used by the components/autoTrigger (they read it\n// at call time so setConfig() takes effect without re-import). Typed as the\n// readonly IConfig at the export boundary — the `as IConfig` is a compile-time\n// view only and does NOT freeze the object, so this export must stay\n// package-internal (it is not re-exported from exports.ts). Public consumers get\n// the deep-frozen clone from getConfig() instead.\nexport const config: IConfig = _config as IConfig;\n\nexport function getConfig(): IConfig {\n if (!frozenConfig) {\n frozenConfig = deepFreeze(deepClone(_config));\n }\n return frozenConfig;\n}\n\nexport function setConfig(partialConfig: IWritableConfig): void {\n if (typeof partialConfig.autoTrigger === \"boolean\") {\n _config.autoTrigger = partialConfig.autoTrigger;\n }\n if (typeof partialConfig.triggerAttribute === \"string\") {\n _config.triggerAttribute = partialConfig.triggerAttribute;\n }\n if (partialConfig.tagNames) {\n Object.assign(_config.tagNames, partialConfig.tagNames);\n }\n frozenConfig = null;\n}\n","import {\n IWcBindable, NotifyBackend, NotifyOptions, NotificationPermissionRaw,\n PermissionStateOrUnsupported, WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\n\n// Wrapper stored in a notification's `data` so the Service Worker side (a\n// separate global scope with no access to this instance) can recover the\n// identity and the caller's payload. The constructor backend uses the same\n// wrapper for uniformity, and both paths unwrap it before emitting.\ninterface WcsNotifyData {\n __wcsId: string;\n payload: unknown;\n}\n\n// Message shape posted by `wireNotificationClicks()` (src/sw.ts) over both\n// BroadcastChannel and clients.postMessage. `id` is unique per click\n// (`tag#seq`), so the two transports delivering the *same* click de-dup, while\n// two genuine clicks on the same `tag` do not.\ninterface WcsNotifyInbound {\n __wcsNotify: true;\n id: string;\n tag: string;\n data: unknown;\n action: string;\n}\n\n/**\n * Headless desktop-notification primitive. A thin, framework-agnostic wrapper\n * around the Notifications API exposed through the wc-bindable protocol.\n *\n * Unlike `@wcstack/permission` (a read-only monitor — the Permissions API has no\n * `request()`), the Notifications API *does* expose `Notification.requestPermission()`,\n * so this node is self-contained: it both **requests/monitors** the permission and\n * **shows** notifications. It is the first @wcstack node where the command-token\n * (show: `notify`) and event-token (`click` / `close` / `show`) directions both\n * live in one tag.\n *\n * - **request()** asks for the `notifications` permission (`Notification.requestPermission`).\n * - **notify(title, options)** shows a notification and returns its identifying tag\n * (a caller `options.tag`, or a generated `wcs-<n>`). It picks a backend per\n * `mode`: the `Notification` constructor (desktop) or\n * `ServiceWorkerRegistration.showNotification()` (mobile). `\"auto\"` prefers the\n * constructor and falls back to the SW on a `TypeError`.\n * - **close(tag) / closeAll()** dismiss notifications by tag / all.\n * - Clicks flow back as the `wcs-notify:click` event: directly via the\n * Notification's `onclick` (constructor), or via the SW helper's\n * BroadcastChannel/postMessage relay (SW). `permission` mirrors the live grant.\n *\n * Failures never throw: they surface through `error` (and the `unsupported`\n * permission state) so they flow into the declarative state.\n */\nexport class NotificationCore extends EventTarget {\n static wcBindable: IWcBindable = {\n protocol: \"wc-bindable\",\n version: 1,\n properties: [\n { name: \"permission\", event: \"wcs-notify:permission-change\" },\n { name: \"granted\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"granted\" },\n { name: \"denied\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"denied\" },\n { name: \"prompt\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"prompt\" },\n { name: \"unsupported\", event: \"wcs-notify:permission-change\", getter: (e: Event) => (e as CustomEvent).detail === \"unsupported\" },\n { name: \"error\", event: \"wcs-notify:error\" },\n { name: \"clicked\", event: \"wcs-notify:click\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"closed\", event: \"wcs-notify:close\", getter: (e: Event) => (e as CustomEvent).detail },\n { name: \"shown\", event: \"wcs-notify:show\", getter: (e: Event) => (e as CustomEvent).detail },\n ],\n commands: [\n { name: \"request\", async: true },\n { name: \"notify\" },\n { name: \"close\" },\n { name: \"closeAll\" },\n ],\n };\n\n private _target: EventTarget;\n private _mode: NotifyBackend = \"auto\";\n\n private _permission: PermissionStateOrUnsupported = \"prompt\";\n private _error: WcsNotifyErrorDetail | null = null;\n private _lastClick: WcsNotifyClickDetail | null = null;\n private _lastClose: WcsNotifyClickDetail | null = null;\n private _lastShow: WcsNotifyClickDetail | null = null;\n\n // Live PermissionStatus (when the Permissions API can query `notifications`),\n // kept so its `change` listener can be removed on dispose().\n private _permissionStatus: PermissionStatus | null = null;\n // True once a permission subscription has been (or is being) established; reset\n // by dispose(). Guards observe() so a reconnect re-queries while a redundant\n // observe() on a live subscription does not.\n private _permissionSubscribed: boolean = false;\n\n // Monotonic id of the current lifecycle. Bumped by every observe() and by\n // dispose(). In-flight async work (permission query, SW show, inbound click)\n // captures it and bails if stale, so a query/click that resolves after a\n // disconnect — or after a rapid disconnect→reconnect — never mutates state or\n // dispatches on a torn-down element.\n private _gen: number = 0;\n\n // Resolves once the connect-time permission probe settles. The Shell exposes\n // this as connectedCallbackPromise so SSR can await it before snapshotting.\n private _ready: Promise<void> = Promise.resolve();\n\n // Counter for auto-assigned tags when the caller omits one.\n private _idSeq: number = 0;\n\n // Notifications created via the constructor backend, by tag, so close()/closeAll()\n // can dismiss them. The SW backend has no handle (showNotification returns void),\n // so its tags are tracked separately and closed via registration.getNotifications().\n private _constructed: Map<string, Notification> = new Map();\n private _swTags: Set<string> = new Set();\n\n // Click subscription handles (SW relay).\n private _channel: BroadcastChannel | null = null;\n private _serviceWorker: ServiceWorkerContainer | null = null;\n private _clicksSubscribed: boolean = false;\n // Per-click ids already handled, to de-dup the two relay transports. FIFO-capped\n // so a long session does not leak; the two transports always arrive in the same\n // tick, so a small cap is ample.\n private _seenIds: string[] = [];\n\n constructor(target?: EventTarget) {\n super();\n this._target = target ?? this;\n }\n\n get permission(): PermissionStateOrUnsupported {\n return this._permission;\n }\n\n get granted(): boolean {\n return this._permission === \"granted\";\n }\n\n get denied(): boolean {\n return this._permission === \"denied\";\n }\n\n get prompt(): boolean {\n return this._permission === \"prompt\";\n }\n\n get unsupported(): boolean {\n return this._permission === \"unsupported\";\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._error;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._lastClick;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._lastClose;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._lastShow;\n }\n\n /** Resolves once the current (or initial) permission probe settles. */\n get ready(): Promise<void> {\n return this._ready;\n }\n\n // --- State setters with event dispatch ---\n\n private _setPermission(state: PermissionStateOrUnsupported): void {\n if (this._permission === state) return;\n this._permission = state;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:permission-change\", {\n detail: state,\n bubbles: true,\n }));\n }\n\n private _setError(error: WcsNotifyErrorDetail | null): void {\n if (this._error === error) return;\n this._error = error;\n this._target.dispatchEvent(new CustomEvent(\"wcs-notify:error\", {\n detail: error,\n bubbles: true,\n }));\n }\n\n private _emit(kind: \"click\" | \"close\" | \"show\", detail: WcsNotifyClickDetail): void {\n if (kind === \"click\") this._lastClick = detail;\n else if (kind === \"close\") this._lastClose = detail;\n else this._lastShow = detail;\n this._target.dispatchEvent(new CustomEvent(`wcs-notify:${kind}`, {\n detail,\n bubbles: true,\n }));\n }\n\n // --- Public API ---\n\n /**\n * Start observing the `notifications` permission and subscribing to Service\n * Worker click relays. `mode` selects the show backend (default `\"auto\"`).\n * Idempotent while already subscribed: it only updates the stored mode; to\n * restart, dispose() first. Returns a promise that resolves once the first\n * permission probe settles, for SSR.\n *\n * Headless callers must call observe() to begin; the Shell calls it from\n * connectedCallback once the element's attributes resolve.\n */\n observe(mode: NotifyBackend = \"auto\"): Promise<void> {\n this._mode = mode;\n if (!this._permissionSubscribed) {\n this._ready = this._initPermission();\n this._subscribeClicks();\n }\n return this._ready;\n }\n\n /**\n * Ask the user for the `notifications` permission. Resolves to the resulting\n * (normalized) permission state. Never throws: an unavailable API resolves to\n * `\"unsupported\"`.\n */\n async request(): Promise<PermissionStateOrUnsupported> {\n const api = this._api();\n if (!api || typeof api.requestPermission !== \"function\") {\n this._setPermission(\"unsupported\");\n return this._permission;\n }\n try {\n const result = await api.requestPermission();\n this._setPermission(this._normalize(result));\n } catch {\n // Some legacy engines may reject; keep the current state rather than throw.\n }\n return this._permission;\n }\n\n /**\n * Show a notification. Returns the identifying tag (the caller's `options.tag`,\n * or a generated `wcs-<n>` when omitted). Never throws: when the API is\n * unavailable or the permission is not granted it surfaces an `error` and\n * returns an empty string.\n */\n notify(title: string, options: NotifyOptions = {}): string {\n if (!this._api()) {\n this._setError(this._err(\"unsupported\", \"Notifications API is not available in this environment.\"));\n return \"\";\n }\n if (this._permission !== \"granted\") {\n this._setError(this._err(\"not-granted\", \"Notification permission is not granted; call request() first.\"));\n return \"\";\n }\n if (typeof title !== \"string\") {\n this._setError(this._err(\"invalid-title\", \"notify() requires a string title.\"));\n return \"\";\n }\n\n const tag = (typeof options.tag === \"string\" && options.tag !== \"\") ? options.tag : this._nextId();\n const payload = options.data;\n const data: WcsNotifyData = { __wcsId: tag, payload };\n const backendOptions: NotifyOptions = { ...options, tag, data };\n\n this._setError(null);\n this._show(title, backendOptions, tag, payload);\n return tag;\n }\n\n /** Dismiss the notification(s) with `tag` across both backends. */\n close(tag?: string): void {\n if (typeof tag !== \"string\" || tag === \"\") return;\n const n = this._constructed.get(tag);\n if (n) {\n n.close();\n this._constructed.delete(tag);\n }\n if (this._swTags.has(tag)) {\n this._closeSw(tag);\n this._swTags.delete(tag);\n }\n }\n\n /**\n * Dismiss every notification this instance has shown. Scoped to this instance's\n * own tags on both backends — the SW path closes each tracked tag individually\n * rather than enumerating the whole origin, so it never dismisses notifications\n * shown by another `<wcs-notify>` or by an unrelated code path.\n */\n closeAll(): void {\n for (const n of this._constructed.values()) {\n n.close();\n }\n this._constructed.clear();\n for (const tag of this._swTags) {\n this._closeSw(tag);\n }\n this._swTags.clear();\n }\n\n /**\n * Detach permission and click subscriptions. Open notifications are intentionally\n * **left on screen** (a notification outlives the page that posted it — that is\n * the point); use close()/closeAll() to dismiss. Call from the Shell's\n * disconnectedCallback. A later observe() resumes.\n */\n dispose(): void {\n this._permissionSubscribed = false;\n this._clicksSubscribed = false;\n this._gen++;\n if (this._permissionStatus) {\n this._permissionStatus.removeEventListener(\"change\", this._onPermissionChange);\n this._permissionStatus = null;\n }\n if (this._channel) {\n this._channel.removeEventListener(\"message\", this._onInbound);\n this._channel.close();\n this._channel = null;\n }\n if (this._serviceWorker) {\n this._serviceWorker.removeEventListener(\"message\", this._onInbound);\n this._serviceWorker = null;\n }\n }\n\n // --- Internal: permission ---\n\n private _initPermission(): Promise<void> {\n const api = this._api();\n if (!api) {\n this._setPermission(\"unsupported\");\n // Intentionally does NOT set _permissionSubscribed: there is no permission\n // listener to tear down, so a reconnect simply re-probes (idempotent — the\n // same-value guard suppresses any redundant dispatch and no listener is ever\n // attached). _subscribeClicks() is re-entered too, but its own\n // _clicksSubscribed guard short-circuits the second pass, so no transport is\n // double-subscribed. Mirrors @wcstack/permission's unsupported path.\n return Promise.resolve();\n }\n this._permissionSubscribed = true;\n // Prefer the Permissions API: it provides a live `change` event. Fall back to\n // the static `Notification.permission` when it is absent or rejects the\n // `notifications` descriptor.\n if (typeof navigator !== \"undefined\" && navigator.permissions && typeof navigator.permissions.query === \"function\") {\n const gen = ++this._gen;\n return navigator.permissions.query({ name: \"notifications\" }).then(\n (status) => {\n if (gen !== this._gen) return;\n this._permissionStatus = status;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n status.addEventListener(\"change\", this._onPermissionChange);\n },\n () => {\n if (gen !== this._gen) return;\n // Permissions API rejected the `notifications` descriptor — fall back to\n // the static `Notification.permission` (api is in scope and non-null here).\n this._setPermission(this._normalize(api.permission));\n },\n );\n }\n // No Permissions API: read the static permission once (no live change events).\n this._setPermission(this._normalize(api.permission));\n return Promise.resolve();\n }\n\n private _onPermissionChange = (event: Event): void => {\n const status = event.target as PermissionStatus;\n this._setPermission(this._normalize(status.state as NotificationPermissionRaw));\n };\n\n // Normalize the Notifications API's `\"default\"` to `\"prompt\"` so this node shares\n // the four-value surface of @wcstack/permission. The Permissions API already\n // reports `\"prompt\"`, so it passes through unchanged.\n private _normalize(raw: NotificationPermissionRaw | string): PermissionStateOrUnsupported {\n if (raw === \"default\") return \"prompt\";\n if (raw === \"granted\" || raw === \"denied\" || raw === \"prompt\") return raw;\n return \"prompt\";\n }\n\n // --- Internal: showing ---\n\n private _show(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n if (this._mode === \"sw\") {\n this._showViaSw(title, options, tag, payload);\n return;\n }\n const handled = this._showViaConstructor(title, options, tag, payload);\n if (handled) return;\n // Constructor threw TypeError (e.g. mobile, where `new Notification` is illegal).\n if (this._mode === \"auto\") {\n this._showViaSw(title, options, tag, payload);\n } else {\n this._setError(this._err(\"show-failed\", \"new Notification() is not usable here and mode=\\\"constructor\\\" disallows the Service Worker fallback.\"));\n }\n }\n\n // Returns false only when the constructor threw a TypeError (the signal to fall\n // back to the SW backend); true when it showed or surfaced a non-TypeError error.\n private _showViaConstructor(title: string, options: NotifyOptions, tag: string, payload: unknown): boolean {\n const api = this._api()!;\n const gen = this._gen;\n let n: Notification;\n try {\n n = new api(title, options as NotificationOptions);\n } catch (e) {\n if (e instanceof TypeError) return false;\n this._setError(this._err(\"show-failed\", \"Failed to create the notification.\"));\n return true;\n }\n this._constructed.set(tag, n);\n n.onshow = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n };\n n.onclick = (): void => {\n if (gen !== this._gen) return;\n this._emit(\"click\", { tag, data: payload, action: \"\" });\n };\n n.onclose = (): void => {\n this._constructed.delete(tag);\n if (gen !== this._gen) return;\n this._emit(\"close\", { tag, data: payload, action: \"\" });\n };\n n.onerror = (): void => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"The notification failed to display.\"));\n };\n return true;\n }\n\n private _showViaSw(title: string, options: NotifyOptions, tag: string, payload: unknown): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) {\n this._setError(this._err(\"no-service-worker\", \"Service Worker is required to show this notification but is unavailable.\"));\n return;\n }\n const gen = this._gen;\n this._swTags.add(tag);\n // A notification deliberately outlives the page (see § dispose), so we do NOT\n // bail before showNotification on a stale gen — a notify() issued while\n // connected still shows. The stale-gen guards only suppress dispatching the\n // observable `show` / `error` back onto a torn-down element.\n sw.ready\n .then((registration) => registration.showNotification(title, options as NotificationOptions))\n .then(() => {\n if (gen !== this._gen) return;\n this._emit(\"show\", { tag, data: payload, action: \"\" });\n })\n .catch(() => {\n if (gen !== this._gen) return;\n this._setError(this._err(\"show-failed\", \"ServiceWorkerRegistration.showNotification() failed.\"));\n });\n }\n\n // Close the SW notification(s) carrying `tag`. Always scoped to a single tag —\n // both callers (close / closeAll) iterate their own tracked tags, so the whole\n // origin is never enumerated.\n private _closeSw(tag: string): void {\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (!sw) return;\n sw.ready.then((registration) => {\n return registration.getNotifications({ tag }).then((list) => {\n for (const n of list) n.close();\n });\n }).catch(() => {\n // Closing is best-effort; a failure to enumerate is not surfaced.\n });\n }\n\n // --- Internal: click relay (SW) ---\n\n private _subscribeClicks(): void {\n if (this._clicksSubscribed) return;\n this._clicksSubscribed = true;\n if (typeof BroadcastChannel === \"function\") {\n this._channel = new BroadcastChannel(\"wcs-notify\");\n this._channel.addEventListener(\"message\", this._onInbound);\n }\n const sw = navigator.serviceWorker as ServiceWorkerContainer | undefined;\n if (sw) {\n this._serviceWorker = sw;\n sw.addEventListener(\"message\", this._onInbound);\n }\n }\n\n private _onInbound = (event: Event): void => {\n const msg = (event as MessageEvent).data as WcsNotifyInbound | undefined;\n if (!msg || msg.__wcsNotify !== true) return;\n if (this._isDuplicate(msg.id)) return;\n this._emit(\"click\", { tag: msg.tag, data: this._unwrap(msg.data), action: msg.action });\n };\n\n private _isDuplicate(id: string): boolean {\n if (this._seenIds.includes(id)) return true;\n this._seenIds.push(id);\n if (this._seenIds.length > 50) this._seenIds.shift();\n return false;\n }\n\n private _unwrap(raw: unknown): unknown {\n if (raw !== null && typeof raw === \"object\" && \"__wcsId\" in raw) {\n return (raw as WcsNotifyData).payload;\n }\n return raw;\n }\n\n // --- Internal: misc ---\n\n // Resolve the global `Notification` constructor at call time (not cached) so\n // tests can install/remove it and so unsupported environments report correctly.\n private _api(): (typeof Notification) | undefined {\n const g = globalThis as unknown as { Notification?: typeof Notification };\n return typeof g.Notification === \"function\" ? g.Notification : undefined;\n }\n\n private _nextId(): string {\n return `wcs-${++this._idSeq}`;\n }\n\n private _err(error: string, message: string): WcsNotifyErrorDetail {\n return { error, message };\n }\n}\n","import { config } from \"./config.js\";\nimport type { WcsNotify } from \"./components/Notify.js\";\n\nlet registered = false;\n\nfunction handleClick(event: Event): void {\n const target = event.target;\n if (!(target instanceof Element)) return;\n\n // A misconfigured triggerAttribute (e.g. one with a space) makes the attribute\n // selector invalid and closest() throw SyntaxError; guard so a bad config\n // disables only this shortcut rather than killing every document click handler.\n let triggerElement: Element | null;\n try {\n triggerElement = target.closest<Element>(`[${config.triggerAttribute}]`);\n } catch {\n return;\n }\n if (!triggerElement) return;\n\n const notifyId = triggerElement.getAttribute(config.triggerAttribute);\n if (!notifyId) return;\n\n // Resolve the registered constructor at call time instead of importing Notify as\n // a value, avoiding a components/Notify.ts ⇄ autoTrigger.ts cycle\n // (Notify.connectedCallback() calls registerAutoTrigger()). instanceof against\n // the customElements registry keeps the same identity guarantee.\n const NotifyCtor = customElements.get(config.tagNames.notify);\n const notifyElement = document.getElementById(notifyId);\n if (!NotifyCtor || !(notifyElement instanceof NotifyCtor)) return;\n\n // The title comes from the trigger element: an explicit `data-notifytitle`\n // attribute wins, otherwise the element's trimmed text content. The body is an\n // optional `data-notifybody`. This keeps the click-driven shortcut declarative\n // without inventing a payload channel.\n const explicit = triggerElement.getAttribute(\"data-notifytitle\");\n // `Element.textContent` is spec-guaranteed non-null (only Document / DocumentType\n // nodes return null, never an Element), so the cast is sound and lets us avoid an\n // unreachable `?? \"\"` branch. `triggerElement` is always an Element here.\n const title = explicit !== null ? explicit : (triggerElement.textContent as string).trim();\n const body = triggerElement.getAttribute(\"data-notifybody\");\n\n (notifyElement as WcsNotify).notify(title, body !== null ? { body } : undefined);\n}\n\nexport function registerAutoTrigger(): void {\n if (registered) return;\n registered = true;\n document.addEventListener(\"click\", handleClick);\n}\n\nexport function unregisterAutoTrigger(): void {\n if (!registered) return;\n registered = false;\n document.removeEventListener(\"click\", handleClick);\n}\n","import { config } from \"../config.js\";\nimport {\n IWcBindable, NotifyBackend, NotifyOptions, PermissionStateOrUnsupported,\n WcsNotifyClickDetail, WcsNotifyErrorDetail,\n} from \"../types.js\";\nimport { NotificationCore } from \"../core/NotificationCore.js\";\nimport { registerAutoTrigger } from \"../autoTrigger.js\";\n\n/**\n * `<wcs-notify>` — declarative desktop notifications. Wraps NotificationCore and\n * exposes both directions in one tag:\n *\n * - **`notice`** (reactive input): writing a *changed* value shows a notification,\n * suppressing same-value writes so it fires only when the bound source actually\n * changes. The imperative `notify` command instead shows on demand (even the\n * same text again). See `docs/notification-tag-design.md` § 2.\n * - **`request` / `notify` / `close` / `closeAll`** commands (state → element).\n * - per-notification options (`body` / `icon` / `badge` / `tag` / `lang` / `dir` /\n * `require-interaction` / `silent` / `renotify`) as mirrored attributes.\n * - `mode` selects the show backend (`auto` / `sw` / `constructor`).\n * - the Core's observable surface (permission / granted / … / error / clicked /\n * closed / shown) via delegated getters; clicked/closed/shown carry the\n * `{ tag, data, action }` payload for event-token wiring.\n */\nexport class WcsNotify extends HTMLElement {\n static hasConnectedCallbackPromise = true;\n static wcBindable: IWcBindable = {\n ...NotificationCore.wcBindable,\n // Shell-level settable surface. `notice` is a momentary reactive command-property\n // with no mirrored attribute (it carries dynamic text, not declarative config),\n // mirroring <wcs-speak>'s `say`. The rest mirror their HTML attributes idempotently.\n inputs: [\n { name: \"notice\" },\n { name: \"mode\", attribute: \"mode\" },\n { name: \"body\", attribute: \"body\" },\n { name: \"icon\", attribute: \"icon\" },\n { name: \"badge\", attribute: \"badge\" },\n { name: \"tag\", attribute: \"tag\" },\n { name: \"lang\", attribute: \"lang\" },\n { name: \"dir\", attribute: \"dir\" },\n { name: \"requireInteraction\", attribute: \"require-interaction\" },\n { name: \"silent\", attribute: \"silent\" },\n { name: \"renotify\", attribute: \"renotify\" },\n { name: \"manual\", attribute: \"manual\" },\n ],\n commands: NotificationCore.wcBindable.commands,\n };\n\n private _core: NotificationCore;\n private _notice: string = \"\";\n private _connectedCallbackPromise: Promise<void> = Promise.resolve();\n private _internals: ElementInternals | null = null;\n\n constructor() {\n super();\n this._core = new NotificationCore(this);\n this._internals = this._initInternals();\n this._wireStates({\n \"wcs-notify:permission-change\": (d) => ({\n granted: d === \"granted\", denied: d === \"denied\",\n prompt: d === \"prompt\", unsupported: d === \"unsupported\",\n }),\n \"wcs-notify:error\": (d) => ({ error: d != null }),\n });\n }\n\n // CSS state reflection (:state()) — debug-only snapshot getter. NOT part of\n // wc-bindable (not a bind target); see README \"CSS styling with :state()\".\n // MUST NOT return the live CustomStateSet (that would let callers write\n // states from outside, defeating the point of :state() being read-only).\n get debugStates(): string[] {\n return this._internals ? [...this._internals.states] : [];\n }\n\n private _initInternals(): ElementInternals | null {\n // never-throw (async-io-node-guidelines.md §3.6): attachInternals is absent\n // in happy-dom / older environments, and pre-125 Chromium rejects\n // non-dashed state names from states.add() (probed and discarded here).\n // Either case silently disables reflection — the component still works,\n // it just doesn't expose :state() selectors.\n try {\n if (typeof this.attachInternals !== \"function\") return null;\n const internals = this.attachInternals();\n internals.states.add(\"wcs-probe\");\n internals.states.delete(\"wcs-probe\");\n return internals;\n } catch {\n return null;\n }\n }\n\n private _wireStates(map: Record<string, (detail: any) => Record<string, boolean>>): void {\n if (this._internals === null) return;\n const states = this._internals.states;\n for (const [event, toStates] of Object.entries(map)) {\n this.addEventListener(event, (e) => {\n const debug = this.hasAttribute(\"debug-states\");\n for (const [name, on] of Object.entries(toStates((e as CustomEvent).detail))) {\n try {\n if (on) { states.add(name); } else { states.delete(name); }\n } catch { /* never-throw */ }\n if (debug) this.toggleAttribute(`data-wcs-state-${name}`, on);\n }\n });\n }\n }\n\n // --- Attribute accessors ---\n\n get mode(): NotifyBackend {\n const m = this.getAttribute(\"mode\");\n return (m === \"sw\" || m === \"constructor\") ? m : \"auto\";\n }\n\n set mode(value: NotifyBackend) {\n this.setAttribute(\"mode\", value);\n }\n\n get body(): string {\n return this.getAttribute(\"body\") ?? \"\";\n }\n\n set body(value: string | null) {\n this._reflect(\"body\", value);\n }\n\n get icon(): string {\n return this.getAttribute(\"icon\") ?? \"\";\n }\n\n set icon(value: string | null) {\n this._reflect(\"icon\", value);\n }\n\n get badge(): string {\n return this.getAttribute(\"badge\") ?? \"\";\n }\n\n set badge(value: string | null) {\n this._reflect(\"badge\", value);\n }\n\n get tag(): string {\n return this.getAttribute(\"tag\") ?? \"\";\n }\n\n set tag(value: string | null) {\n this._reflect(\"tag\", value);\n }\n\n // NOTE: `lang` and `dir` intentionally repurpose the standard HTMLElement IDL\n // attributes as per-notification options (forwarded to NotificationOptions).\n // This element is always display:none, so overriding their normal rendering\n // semantics has no visual effect — but be aware the values mean \"the\n // notification's language/direction\", not the host element's.\n get lang(): string {\n return this.getAttribute(\"lang\") ?? \"\";\n }\n\n set lang(value: string | null) {\n this._reflect(\"lang\", value);\n }\n\n get dir(): string {\n return this.getAttribute(\"dir\") ?? \"\";\n }\n\n set dir(value: string | null) {\n this._reflect(\"dir\", value);\n }\n\n get requireInteraction(): boolean {\n return this.hasAttribute(\"require-interaction\");\n }\n\n set requireInteraction(value: boolean) {\n this._reflectBool(\"require-interaction\", value);\n }\n\n get silent(): boolean {\n return this.hasAttribute(\"silent\");\n }\n\n set silent(value: boolean) {\n this._reflectBool(\"silent\", value);\n }\n\n get renotify(): boolean {\n return this.hasAttribute(\"renotify\");\n }\n\n set renotify(value: boolean) {\n this._reflectBool(\"renotify\", value);\n }\n\n get manual(): boolean {\n return this.hasAttribute(\"manual\");\n }\n\n set manual(value: boolean) {\n this._reflectBool(\"manual\", value);\n }\n\n // --- Reactive command-property ---\n\n get notice(): string {\n return this._notice;\n }\n\n set notice(value: string | null) {\n // Reactive: writing a new value shows it. `manual` mutes the path entirely\n // (the imperative `notify` command still works). A conforming binder never\n // delivers `undefined` (it skips the write), but a direct assignment can, so\n // normalize null/undefined to a no-op.\n if (value == null) return;\n if (this.manual) return;\n const v = String(value);\n // Same-value guard: only show when the bound source actually changes. To show\n // the same text again on demand, use the `notify` command instead. (This is\n // the only spam guard the package provides — see docs § 2-c; debounce is the\n // caller's job via a filter, e.g. `notice@x|debounce(1000)`.)\n if (v === this._notice) return;\n this._notice = v;\n this.notify(v);\n }\n\n // --- Core delegated getters ---\n\n get permission(): PermissionStateOrUnsupported {\n return this._core.permission;\n }\n\n get granted(): boolean {\n return this._core.granted;\n }\n\n get denied(): boolean {\n return this._core.denied;\n }\n\n get prompt(): boolean {\n return this._core.prompt;\n }\n\n get unsupported(): boolean {\n return this._core.unsupported;\n }\n\n get error(): WcsNotifyErrorDetail | null {\n return this._core.error;\n }\n\n get clicked(): WcsNotifyClickDetail | null {\n return this._core.clicked;\n }\n\n get closed(): WcsNotifyClickDetail | null {\n return this._core.closed;\n }\n\n get shown(): WcsNotifyClickDetail | null {\n return this._core.shown;\n }\n\n get connectedCallbackPromise(): Promise<void> {\n return this._connectedCallbackPromise;\n }\n\n // --- Commands ---\n\n request(): Promise<PermissionStateOrUnsupported> {\n return this._core.request();\n }\n\n notify(title: string, options?: NotifyOptions): string {\n // Explicit options (from a command-token emit) win per-key over the attribute\n // defaults, so `notify.emit(title, { body })` still picks up the element's icon.\n return this._core.notify(title, { ...this._options(), ...(options ?? {}) });\n }\n\n close(tag?: string): void {\n this._core.close(tag);\n }\n\n closeAll(): void {\n this._core.closeAll();\n }\n\n // --- Internal ---\n\n private _reflect(name: string, value: string | null): void {\n if (value == null) {\n this.removeAttribute(name);\n } else {\n this.setAttribute(name, String(value));\n }\n }\n\n private _reflectBool(name: string, value: boolean): void {\n if (value) {\n this.setAttribute(name, \"\");\n } else {\n this.removeAttribute(name);\n }\n }\n\n private _options(): NotifyOptions {\n const o: NotifyOptions = {};\n if (this.body !== \"\") o.body = this.body;\n if (this.icon !== \"\") o.icon = this.icon;\n if (this.badge !== \"\") o.badge = this.badge;\n if (this.tag !== \"\") o.tag = this.tag;\n if (this.lang !== \"\") o.lang = this.lang;\n if (this.dir === \"auto\" || this.dir === \"ltr\" || this.dir === \"rtl\") o.dir = this.dir;\n if (this.requireInteraction) o.requireInteraction = true;\n if (this.silent) o.silent = true;\n if (this.renotify) o.renotify = true;\n return o;\n }\n\n // --- Lifecycle ---\n\n connectedCallback(): void {\n this.style.display = \"none\";\n if (config.autoTrigger) {\n registerAutoTrigger();\n }\n // Begin observing permission and subscribing to SW click relays (or revive\n // after a reconnect). The returned promise is held as connectedCallbackPromise\n // for SSR.\n this._connectedCallbackPromise = this._core.observe(this.mode);\n }\n\n disconnectedCallback(): void {\n // Detach subscriptions. Open notifications are left on screen (see Core docs);\n // call close()/closeAll() to dismiss.\n this._core.dispose();\n }\n}\n","import { setConfig } from \"./config.js\";\nimport { registerComponents } from \"./registerComponents.js\";\nimport { IWritableConfig } from \"./types.js\";\n\nexport function bootstrapNotification(userConfig?: IWritableConfig): void {\n if (userConfig) {\n setConfig(userConfig);\n }\n registerComponents();\n}\n","import { WcsNotify } from \"./components/Notify.js\";\nimport { config } from \"./config.js\";\n\nexport function registerComponents(): void {\n if (!customElements.get(config.tagNames.notify)) {\n customElements.define(config.tagNames.notify, WcsNotify);\n }\n}\n"],"names":["_config","autoTrigger","triggerAttribute","tagNames","notify","deepFreeze","obj","Object","freeze","key","keys","deepClone","clone","frozenConfig","config","getConfig","NotificationCore","EventTarget","static","protocol","version","properties","name","event","getter","e","detail","commands","async","_target","_mode","_permission","_error","_lastClick","_lastClose","_lastShow","_permissionStatus","_permissionSubscribed","_gen","_ready","Promise","resolve","_idSeq","_constructed","Map","_swTags","Set","_channel","_serviceWorker","_clicksSubscribed","_seenIds","constructor","target","super","this","permission","granted","denied","prompt","unsupported","error","clicked","closed","shown","ready","_setPermission","state","dispatchEvent","CustomEvent","bubbles","_setError","_emit","kind","observe","mode","_initPermission","_subscribeClicks","request","api","_api","requestPermission","result","_normalize","title","options","_err","tag","_nextId","payload","data","__wcsId","backendOptions","_show","close","n","get","delete","has","_closeSw","closeAll","values","clear","dispose","removeEventListener","_onPermissionChange","_onInbound","navigator","permissions","query","gen","then","status","addEventListener","raw","_showViaSw","_showViaConstructor","TypeError","set","onshow","action","onclick","onclose","onerror","sw","serviceWorker","add","registration","showNotification","catch","getNotifications","list","BroadcastChannel","msg","__wcsNotify","_isDuplicate","id","_unwrap","includes","push","length","shift","g","globalThis","Notification","undefined","message","registered","handleClick","Element","triggerElement","closest","notifyId","getAttribute","NotifyCtor","customElements","notifyElement","document","getElementById","explicit","textContent","trim","body","WcsNotify","HTMLElement","wcBindable","inputs","attribute","_core","_notice","_connectedCallbackPromise","_internals","_initInternals","_wireStates","d","debugStates","states","attachInternals","internals","map","toStates","entries","debug","hasAttribute","on","toggleAttribute","m","value","setAttribute","_reflect","icon","badge","lang","dir","requireInteraction","_reflectBool","silent","renotify","manual","notice","v","String","connectedCallbackPromise","_options","removeAttribute","o","connectedCallback","style","display","disconnectedCallback","bootstrapNotification","userConfig","partialConfig","assign","define"],"mappings":"AAUA,MAAMA,EAA2B,CAC/BC,aAAa,EACbC,iBAAkB,oBAClBC,SAAU,CACRC,OAAQ,eAIZ,SAASC,EAAcC,GACrB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpDC,OAAOC,OAAOF,GACd,IAAK,MAAMG,KAAOF,OAAOG,KAAKJ,GAC5BD,EAAYC,EAAgCG,IAE9C,OAAOH,CACT,CAEA,SAASK,EAAaL,GACpB,GAAY,OAARA,GAA+B,iBAARA,EAAkB,OAAOA,EACpD,MAAMM,EAAiC,CAAA,EACvC,IAAK,MAAMH,KAAOF,OAAOG,KAAKJ,GAC5BM,EAAMH,GAAOE,EAAWL,EAAgCG,IAE1D,OAAOG,CACT,CAEA,IAAIC,EAA+B,KAQ5B,MAAMC,EAAkBd,WAEfe,IAId,OAHKF,IACHA,EAAeR,EAAWM,EAAUX,KAE/Ba,CACT,CCAM,MAAOG,UAAyBC,YACpCC,kBAAiC,CAC/BC,SAAU,cACVC,QAAS,EACTC,WAAY,CACV,CAAEC,KAAM,aAAcC,MAAO,g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EZ,IAAM1I,KAAK0I,KAC9E1I,KAAK2I,qBAAoBW,EAAEX,oBAAqB,GAChD3I,KAAK6I,SAAQS,EAAET,QAAS,GACxB7I,KAAK8I,WAAUQ,EAAER,UAAW,GACzBQ,CACT,CAIA,iBAAAC,GACEvJ,KAAKwJ,MAAMC,QAAU,OACjBjM,EAAOb,cDtRTiJ,IACJA,GAAa,EACbU,SAAS5C,iBAAiB,QAASmC,KC0RjC7F,KAAKmH,0BAA4BnH,KAAKiH,MAAM9F,QAAQnB,KAAKoB,KAC3D,CAEA,oBAAAsI,GAGE1J,KAAKiH,MAAMjE,SACb,EC7UI,SAAU2G,EAAsBC,GJiDhC,IAAoBC,EIhDpBD,IJiDqC,kBADjBC,EI/CZD,GJgDajN,cACvBD,EAAQC,YAAckN,EAAclN,aAEQ,iBAAnCkN,EAAcjN,mBACvBF,EAAQE,iBAAmBiN,EAAcjN,kBAEvCiN,EAAchN,UAChBI,OAAO6M,OAAOpN,EAAQG,SAAUgN,EAAchN,UAEhDU,EAAe,MK3DV6I,eAAe3D,IAAIjF,EAAOX,SAASC,SACtCsJ,eAAe2D,OAAOvM,EAAOX,SAASC,OAAQ8J,EDIlD"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wcstack/notification",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.17.0",
|
|
4
4
|
"description": "Declarative desktop-notification component for Web Components. Framework-agnostic Notifications API wrapper via wc-bindable-protocol, with Service Worker support.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.esm.js",
|