@symfony/ux-notify 2.23.0 → 2.24.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -3
- package/dist/controller.d.ts +1 -1
- package/dist/controller.js +8 -5
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,10 +1,18 @@
|
|
|
1
1
|
# @symfony/ux-notify
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
JavaScript assets of the [symfony/ux-notify](https://packagist.org/packages/symfony/ux-notify) PHP package.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
This npm package is **reserved for advanced users** who want to decouple their JavaScript dependencies from their PHP dependencies (e.g., when building Docker images, running JavaScript-only pipelines, etc.).
|
|
8
|
+
|
|
9
|
+
We **strongly recommend not installing this package directly**, but instead install the PHP package [symfony/ux-notify](https://packagist.org/packages/symfony/ux-notify) in your Symfony application with [Flex](https://github.com/symfony/flex) enabled.
|
|
10
|
+
|
|
11
|
+
If you still want to install this package directly, please make sure its version exactly matches [symfony/ux-notify](https://packagist.org/packages/symfony/ux-notify) PHP package version:
|
|
12
|
+
```shell
|
|
13
|
+
composer require symfony/ux-notify:2.23.0
|
|
14
|
+
npm add @symfony/ux-notify@2.23.0
|
|
15
|
+
```
|
|
8
16
|
|
|
9
17
|
## Resources
|
|
10
18
|
|
package/dist/controller.d.ts
CHANGED
|
@@ -13,6 +13,6 @@ export default class extends Controller {
|
|
|
13
13
|
initialize(): void;
|
|
14
14
|
connect(): void;
|
|
15
15
|
disconnect(): void;
|
|
16
|
-
_notify(
|
|
16
|
+
_notify(title: string | undefined, options: NotificationOptions | undefined): void;
|
|
17
17
|
private dispatchEvent;
|
|
18
18
|
}
|
package/dist/controller.js
CHANGED
|
@@ -26,7 +26,10 @@ class default_1 extends Controller {
|
|
|
26
26
|
return;
|
|
27
27
|
}
|
|
28
28
|
this.eventSources.forEach((eventSource) => {
|
|
29
|
-
const listener = (event) =>
|
|
29
|
+
const listener = (event) => {
|
|
30
|
+
const { summary, content } = JSON.parse(event.data);
|
|
31
|
+
this._notify(summary, content);
|
|
32
|
+
};
|
|
30
33
|
eventSource.addEventListener('message', listener);
|
|
31
34
|
this.listeners.set(eventSource, listener);
|
|
32
35
|
});
|
|
@@ -42,17 +45,17 @@ class default_1 extends Controller {
|
|
|
42
45
|
});
|
|
43
46
|
this.eventSources = [];
|
|
44
47
|
}
|
|
45
|
-
_notify(
|
|
46
|
-
if (!
|
|
48
|
+
_notify(title, options) {
|
|
49
|
+
if (!title)
|
|
47
50
|
return;
|
|
48
51
|
if ('granted' === Notification.permission) {
|
|
49
|
-
new Notification(
|
|
52
|
+
new Notification(title, options);
|
|
50
53
|
return;
|
|
51
54
|
}
|
|
52
55
|
if ('denied' !== Notification.permission) {
|
|
53
56
|
Notification.requestPermission().then((permission) => {
|
|
54
57
|
if ('granted' === permission) {
|
|
55
|
-
new Notification(
|
|
58
|
+
new Notification(title, options);
|
|
56
59
|
}
|
|
57
60
|
});
|
|
58
61
|
}
|