@symfony/ux-notify 2.32.0 → 2.33.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 CHANGED
@@ -6,9 +6,10 @@ JavaScript assets of the [symfony/ux-notify](https://packagist.org/packages/symf
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
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.
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
10
 
11
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
+
12
13
  ```shell
13
14
  composer require symfony/ux-notify:2.23.0
14
15
  npm add @symfony/ux-notify@2.23.0
@@ -18,7 +19,7 @@ npm add @symfony/ux-notify@2.23.0
18
19
 
19
20
  ## Resources
20
21
 
21
- - [Documentation](https://symfony.com/bundles/ux-notify/current/index.html)
22
- - [Report issues](https://github.com/symfony/ux/issues) and
23
- [send Pull Requests](https://github.com/symfony/ux/pulls)
24
- in the [main Symfony UX repository](https://github.com/symfony/ux)
22
+ - [Documentation](https://symfony.com/bundles/ux-notify/current/index.html)
23
+ - [Report issues](https://github.com/symfony/ux/issues) and
24
+ [send Pull Requests](https://github.com/symfony/ux/pulls)
25
+ in the [main Symfony UX repository](https://github.com/symfony/ux)
@@ -1,21 +1,19 @@
1
- import { Controller } from '@hotwired/stimulus';
2
-
1
+ import { Controller } from "@hotwired/stimulus";
3
2
  declare class export_default extends Controller {
4
- static values: {
5
- hub: StringConstructor;
6
- topics: ArrayConstructor;
7
- };
8
- hubValue: string;
9
- topicsValue: Array<string>;
10
- readonly hasHubValue: boolean;
11
- readonly hasTopicsValue: boolean;
12
- eventSources: Array<EventSource>;
13
- listeners: WeakMap<EventSource, (event: MessageEvent) => void>;
14
- initialize(): void;
15
- connect(): void;
16
- disconnect(): void;
17
- _notify(title: string | undefined, options: NotificationOptions | undefined): void;
18
- private dispatchEvent;
3
+ static values: {
4
+ hub: StringConstructor;
5
+ topics: ArrayConstructor;
6
+ };
7
+ hubValue: string;
8
+ topicsValue: Array<string>;
9
+ readonly hasHubValue: boolean;
10
+ readonly hasTopicsValue: boolean;
11
+ eventSources: Array<EventSource>;
12
+ listeners: WeakMap<EventSource, (event: MessageEvent) => void>;
13
+ initialize(): void;
14
+ connect(): void;
15
+ disconnect(): void;
16
+ _notify(title: string | undefined, options: NotificationOptions | undefined): void;
17
+ private dispatchEvent;
19
18
  }
20
-
21
- export { export_default as default };
19
+ export { export_default as default };
@@ -1,69 +1,63 @@
1
- // src/controller.ts
2
1
  import { Controller } from "@hotwired/stimulus";
3
- var controller_default = class extends Controller {
4
- constructor() {
5
- super(...arguments);
6
- this.eventSources = [];
7
- this.listeners = /* @__PURE__ */ new WeakMap();
8
- }
9
- initialize() {
10
- const errorMessages = [];
11
- if (!this.hasHubValue) errorMessages.push('A "hub" value pointing to the Mercure hub must be provided.');
12
- if (!this.hasTopicsValue) errorMessages.push('A "topics" value must be provided.');
13
- if (errorMessages.length) throw new Error(errorMessages.join(" "));
14
- this.eventSources = this.topicsValue.map((topic) => {
15
- const u = new URL(this.hubValue);
16
- u.searchParams.append("topic", topic);
17
- return new EventSource(u);
18
- });
19
- }
20
- connect() {
21
- if (!("Notification" in window)) {
22
- console.warn("This browser does not support desktop notifications.");
23
- return;
24
- }
25
- this.eventSources.forEach((eventSource) => {
26
- const listener = (event) => {
27
- const { summary, content } = JSON.parse(event.data);
28
- this._notify(summary, content);
29
- };
30
- eventSource.addEventListener("message", listener);
31
- this.listeners.set(eventSource, listener);
32
- });
33
- this.dispatchEvent("connect", { eventSources: this.eventSources });
34
- }
35
- disconnect() {
36
- this.eventSources.forEach((eventSource) => {
37
- const listener = this.listeners.get(eventSource);
38
- if (listener) {
39
- eventSource.removeEventListener("message", listener);
40
- }
41
- eventSource.close();
42
- });
43
- this.eventSources = [];
44
- }
45
- _notify(title, options) {
46
- if (!title) return;
47
- if ("granted" === Notification.permission) {
48
- new Notification(title, options);
49
- return;
50
- }
51
- if ("denied" !== Notification.permission) {
52
- Notification.requestPermission().then((permission) => {
53
- if ("granted" === permission) {
54
- new Notification(title, options);
55
- }
56
- });
57
- }
58
- }
59
- dispatchEvent(name, payload) {
60
- this.dispatch(name, { detail: payload, prefix: "notify" });
61
- }
2
+ var _Class = class extends Controller {
3
+ constructor(..._args) {
4
+ super(..._args);
5
+ this.eventSources = [];
6
+ this.listeners = /* @__PURE__ */ new WeakMap();
7
+ }
8
+ initialize() {
9
+ const errorMessages = [];
10
+ if (!this.hasHubValue) errorMessages.push("A \"hub\" value pointing to the Mercure hub must be provided.");
11
+ if (!this.hasTopicsValue) errorMessages.push("A \"topics\" value must be provided.");
12
+ if (errorMessages.length) throw new Error(errorMessages.join(" "));
13
+ this.eventSources = this.topicsValue.map((topic) => {
14
+ const u = new URL(this.hubValue);
15
+ u.searchParams.append("topic", topic);
16
+ return new EventSource(u);
17
+ });
18
+ }
19
+ connect() {
20
+ if (!("Notification" in window)) {
21
+ console.warn("This browser does not support desktop notifications.");
22
+ return;
23
+ }
24
+ this.eventSources.forEach((eventSource) => {
25
+ const listener = (event) => {
26
+ const { summary, content } = JSON.parse(event.data);
27
+ this._notify(summary, content);
28
+ };
29
+ eventSource.addEventListener("message", listener);
30
+ this.listeners.set(eventSource, listener);
31
+ });
32
+ this.dispatchEvent("connect", { eventSources: this.eventSources });
33
+ }
34
+ disconnect() {
35
+ this.eventSources.forEach((eventSource) => {
36
+ const listener = this.listeners.get(eventSource);
37
+ if (listener) eventSource.removeEventListener("message", listener);
38
+ eventSource.close();
39
+ });
40
+ this.eventSources = [];
41
+ }
42
+ _notify(title, options) {
43
+ if (!title) return;
44
+ if ("granted" === Notification.permission) {
45
+ new Notification(title, options);
46
+ return;
47
+ }
48
+ if ("denied" !== Notification.permission) Notification.requestPermission().then((permission) => {
49
+ if ("granted" === permission) new Notification(title, options);
50
+ });
51
+ }
52
+ dispatchEvent(name, payload) {
53
+ this.dispatch(name, {
54
+ detail: payload,
55
+ prefix: "notify"
56
+ });
57
+ }
62
58
  };
63
- controller_default.values = {
64
- hub: String,
65
- topics: Array
66
- };
67
- export {
68
- controller_default as default
59
+ _Class.values = {
60
+ hub: String,
61
+ topics: Array
69
62
  };
63
+ export { _Class as default };
package/package.json CHANGED
@@ -2,12 +2,12 @@
2
2
  "name": "@symfony/ux-notify",
3
3
  "description": "Native notification integration for Symfony using Mercure",
4
4
  "license": "MIT",
5
- "version": "2.32.0",
5
+ "version": "2.33.0",
6
6
  "keywords": [
7
7
  "symfony-ux"
8
8
  ],
9
9
  "homepage": "https://ux.symfony.com/notify",
10
- "repository": "https://github.com/symfony/ux-notify",
10
+ "repository": "https://github.com/symfony/ux",
11
11
  "type": "module",
12
12
  "files": [
13
13
  "dist"
@@ -37,18 +37,15 @@
37
37
  "@testing-library/user-event": "^14.6.1",
38
38
  "jsdom": "^26.1.0",
39
39
  "tslib": "^2.8.1",
40
- "tsx": "^4.20.3",
41
40
  "typescript": "^5.8.3",
42
- "vitest": "^3.2.4"
41
+ "vitest": "^4.1.0"
43
42
  },
44
43
  "scripts": {
45
- "build": "tsx ../../../bin/build_package.ts .",
46
- "watch": "tsx ../../../bin/build_package.ts . --watch",
44
+ "build": "node ../../../bin/build_package.ts .",
45
+ "watch": "node ../../../bin/build_package.ts . --watch",
47
46
  "test": "pnpm run test:unit && pnpm run test:browser",
48
47
  "test:unit": "../../../bin/unit_test_package.sh .",
49
48
  "test:browser": "playwright test",
50
- "test:browser:ui": "playwright test --ui",
51
- "check": "biome check",
52
- "ci": "biome ci"
49
+ "test:browser:ui": "playwright test --ui"
53
50
  }
54
51
  }