@open-pioneer/notifier 2.4.0-dev.20241120092632 → 3.0.0-dev.20250221111321
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/CHANGELOG.md +88 -66
- package/NotificationServiceImpl.js.map +1 -1
- package/Notifier.js.map +1 -1
- package/package.json +6 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,10 +1,32 @@
|
|
|
1
1
|
# @open-pioneer/notifier
|
|
2
2
|
|
|
3
|
-
##
|
|
3
|
+
## 3.0.0-dev.20250221111321
|
|
4
|
+
|
|
5
|
+
### Major Changes
|
|
6
|
+
|
|
7
|
+
- 9477e54: Update dependencies
|
|
8
|
+
|
|
9
|
+
- React 19
|
|
10
|
+
- Vite 6
|
|
11
|
+
- FormatJS 3
|
|
12
|
+
- Open Pioneer Build Tools
|
|
13
|
+
- ...
|
|
14
|
+
|
|
15
|
+
For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- Updated dependencies [9477e54]
|
|
20
|
+
- @open-pioneer/chakra-integration@3.0.0-dev.20250221111321
|
|
21
|
+
- @open-pioneer/core@3.0.0-dev.20250221111321
|
|
22
|
+
- @open-pioneer/react-utils@3.0.0-dev.20250221111321
|
|
23
|
+
- @open-pioneer/runtime@3.0.0-dev.20250221111321
|
|
24
|
+
|
|
25
|
+
## 2.4.0
|
|
4
26
|
|
|
5
27
|
### Minor Changes
|
|
6
28
|
|
|
7
|
-
-
|
|
29
|
+
- e4ba048: Introduce new convenience methods on the `NotificationService` in addition to the existing `notify()` method:
|
|
8
30
|
|
|
9
31
|
```js
|
|
10
32
|
const notifier = ...; // injected
|
|
@@ -16,134 +38,134 @@
|
|
|
16
38
|
|
|
17
39
|
### Patch Changes
|
|
18
40
|
|
|
19
|
-
-
|
|
20
|
-
-
|
|
21
|
-
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
-
|
|
25
|
-
-
|
|
26
|
-
-
|
|
27
|
-
-
|
|
41
|
+
- 1b63ebe: Update dependencies
|
|
42
|
+
- Updated dependencies [1b63ebe]
|
|
43
|
+
- Updated dependencies [e3802fb]
|
|
44
|
+
- Updated dependencies [ac39468]
|
|
45
|
+
- Updated dependencies [e3802fb]
|
|
46
|
+
- @open-pioneer/chakra-integration@2.4.0
|
|
47
|
+
- @open-pioneer/react-utils@2.4.0
|
|
48
|
+
- @open-pioneer/core@2.4.0
|
|
49
|
+
- @open-pioneer/runtime@2.4.0
|
|
28
50
|
|
|
29
51
|
## 2.3.0
|
|
30
52
|
|
|
31
53
|
### Minor Changes
|
|
32
54
|
|
|
33
|
-
-
|
|
55
|
+
- 2fbaaa0: Use normal `dependencies` instead of `peerDependencies`. Peer dependencies have some usability issues (and bugs) when used at scale.
|
|
34
56
|
|
|
35
57
|
### Patch Changes
|
|
36
58
|
|
|
37
|
-
-
|
|
38
|
-
-
|
|
39
|
-
-
|
|
40
|
-
-
|
|
41
|
-
-
|
|
59
|
+
- Updated dependencies [2fbaaa0]
|
|
60
|
+
- @open-pioneer/chakra-integration@2.3.0
|
|
61
|
+
- @open-pioneer/react-utils@2.3.0
|
|
62
|
+
- @open-pioneer/runtime@2.3.0
|
|
63
|
+
- @open-pioneer/core@2.3.0
|
|
42
64
|
|
|
43
65
|
## 2.2.0
|
|
44
66
|
|
|
45
67
|
### Patch Changes
|
|
46
68
|
|
|
47
|
-
-
|
|
48
|
-
|
|
49
|
-
-
|
|
50
|
-
-
|
|
51
|
-
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
69
|
+
- 39dad46: Switch to a new versioning strategy.
|
|
70
|
+
From now on, packages released by this repository share a common version number.
|
|
71
|
+
- Updated dependencies [39dad46]
|
|
72
|
+
- @open-pioneer/chakra-integration@2.2.0
|
|
73
|
+
- @open-pioneer/core@2.2.0
|
|
74
|
+
- @open-pioneer/react-utils@2.2.0
|
|
75
|
+
- @open-pioneer/runtime@2.2.0
|
|
54
76
|
|
|
55
77
|
## 0.3.6
|
|
56
78
|
|
|
57
79
|
### Patch Changes
|
|
58
80
|
|
|
59
|
-
-
|
|
60
|
-
-
|
|
61
|
-
-
|
|
62
|
-
-
|
|
63
|
-
-
|
|
64
|
-
-
|
|
65
|
-
-
|
|
66
|
-
-
|
|
67
|
-
-
|
|
68
|
-
-
|
|
81
|
+
- 5c62522: Update wording and harmonize structure
|
|
82
|
+
- Updated dependencies [5c62522]
|
|
83
|
+
- Updated dependencies [58ce24f]
|
|
84
|
+
- Updated dependencies [50550d3]
|
|
85
|
+
- Updated dependencies [e0b2fae]
|
|
86
|
+
- Updated dependencies [6cc7fcd]
|
|
87
|
+
- @open-pioneer/chakra-integration@1.1.4
|
|
88
|
+
- @open-pioneer/react-utils@1.0.1
|
|
89
|
+
- @open-pioneer/core@1.3.0
|
|
90
|
+
- @open-pioneer/runtime@2.1.7
|
|
69
91
|
|
|
70
92
|
## 0.3.5
|
|
71
93
|
|
|
72
94
|
### Patch Changes
|
|
73
95
|
|
|
74
|
-
-
|
|
75
|
-
-
|
|
76
|
-
-
|
|
77
|
-
-
|
|
78
|
-
-
|
|
96
|
+
- Updated dependencies [a208b32]
|
|
97
|
+
- Updated dependencies [a208b32]
|
|
98
|
+
- Updated dependencies [e945264]
|
|
99
|
+
- @open-pioneer/react-utils@1.0.0
|
|
100
|
+
- @open-pioneer/runtime@2.1.6
|
|
79
101
|
|
|
80
102
|
## 0.3.4
|
|
81
103
|
|
|
82
104
|
### Patch Changes
|
|
83
105
|
|
|
84
|
-
-
|
|
85
|
-
-
|
|
86
|
-
-
|
|
106
|
+
- Updated dependencies [90d0cce]
|
|
107
|
+
- Updated dependencies [90d0cce]
|
|
108
|
+
- @open-pioneer/runtime@2.1.5
|
|
87
109
|
|
|
88
110
|
## 0.3.3
|
|
89
111
|
|
|
90
112
|
### Patch Changes
|
|
91
113
|
|
|
92
|
-
-
|
|
93
|
-
-
|
|
94
|
-
-
|
|
95
|
-
-
|
|
96
|
-
-
|
|
97
|
-
-
|
|
98
|
-
-
|
|
99
|
-
-
|
|
114
|
+
- 64645aa: Update to react 18.3
|
|
115
|
+
- Updated dependencies [5d3aafd]
|
|
116
|
+
- Updated dependencies [64645aa]
|
|
117
|
+
- Updated dependencies [64645aa]
|
|
118
|
+
- Updated dependencies [b3c60f2]
|
|
119
|
+
- @open-pioneer/core@1.2.3
|
|
120
|
+
- @open-pioneer/chakra-integration@1.1.3
|
|
121
|
+
- @open-pioneer/runtime@2.1.4
|
|
100
122
|
|
|
101
123
|
## 0.3.2
|
|
102
124
|
|
|
103
125
|
### Patch Changes
|
|
104
126
|
|
|
105
|
-
-
|
|
106
|
-
-
|
|
107
|
-
-
|
|
108
|
-
-
|
|
109
|
-
-
|
|
127
|
+
- 5ff8f30: Update package.json metadata.
|
|
128
|
+
- Updated dependencies [5ff8f30]
|
|
129
|
+
- @open-pioneer/chakra-integration@1.1.2
|
|
130
|
+
- @open-pioneer/runtime@2.1.3
|
|
131
|
+
- @open-pioneer/core@1.2.2
|
|
110
132
|
|
|
111
133
|
## 0.3.1
|
|
112
134
|
|
|
113
135
|
### Patch Changes
|
|
114
136
|
|
|
115
|
-
-
|
|
116
|
-
-
|
|
137
|
+
- 4eac7c7: Move packages into core-packages repository.
|
|
138
|
+
- @open-pioneer/runtime@2.1.2
|
|
117
139
|
|
|
118
140
|
## 0.3.0
|
|
119
141
|
|
|
120
142
|
### Minor Changes
|
|
121
143
|
|
|
122
|
-
-
|
|
144
|
+
- ee7c2d4: Update runtime version.
|
|
123
145
|
|
|
124
146
|
### Patch Changes
|
|
125
147
|
|
|
126
|
-
-
|
|
127
|
-
-
|
|
148
|
+
- Updated dependencies [762e7b9]
|
|
149
|
+
- @open-pioneer/react-utils@0.2.1
|
|
128
150
|
|
|
129
151
|
## 0.2.0
|
|
130
152
|
|
|
131
153
|
### Minor Changes
|
|
132
154
|
|
|
133
|
-
-
|
|
155
|
+
- 70349a8: Update to new core packages major versions
|
|
134
156
|
|
|
135
157
|
### Patch Changes
|
|
136
158
|
|
|
137
|
-
-
|
|
138
|
-
-
|
|
159
|
+
- Updated dependencies [70349a8]
|
|
160
|
+
- @open-pioneer/react-utils@0.2.0
|
|
139
161
|
|
|
140
162
|
## 0.1.0
|
|
141
163
|
|
|
142
164
|
### Minor Changes
|
|
143
165
|
|
|
144
|
-
-
|
|
166
|
+
- 182da1c: Initial release.
|
|
145
167
|
|
|
146
168
|
### Patch Changes
|
|
147
169
|
|
|
148
|
-
-
|
|
149
|
-
-
|
|
170
|
+
- Updated dependencies [182da1c]
|
|
171
|
+
- @open-pioneer/react-utils@0.1.0
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"NotificationServiceImpl.js","sources":["NotificationServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n NotificationLevel,\n NotificationOptions,\n NotificationService,\n SimpleNotificationOptions\n} from \"./api\";\nimport { Resource, createLogger } from \"@open-pioneer/core\";\nimport type { ReactNode } from \"react\";\nconst LOG = createLogger(\"notifier:NotificationService\");\n\nexport interface Notification {\n title: ReactNode;\n message: ReactNode;\n level: NotificationLevel;\n displayDuration: number | undefined;\n}\n\n/**\n * The notification handler is implemented by the UI in order to receive events.\n * There can only be one handler at a time.\n *\n * Calls to the handler may be buffered to allow for notifications before the UI has become ready.\n */\nexport interface NotificationHandler {\n /** Called by the service to emit the notification. */\n showNotification(notification: Notification): void;\n\n /** Removes all active notifications. */\n closeAll(): void;\n}\n\nexport interface InternalNotificationAPI extends NotificationService {\n /**\n * Registers the notification handler.\n * The returned resource can be used to unregister it again.\n */\n registerHandler(handler: NotificationHandler): Resource;\n}\n\nexport class NotificationServiceImpl implements InternalNotificationAPI {\n #handler: NotificationHandler | undefined;\n #buffered: [keyof NotificationHandler, ...unknown[]][] | undefined;\n #checkTimeoutId: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n constructor() {\n if (import.meta.env.DEV) {\n this.#checkTimeoutId = setTimeout(() => {\n this.#checkHandlerRegistration();\n this.#checkTimeoutId = undefined;\n }, 5000);\n }\n }\n\n destroy() {\n clearTimeout(this.#checkTimeoutId);\n this.#checkTimeoutId = undefined;\n }\n\n notify(options: NotificationOptions): void {\n this.#dispatchHandlerMethod(\"showNotification\", {\n title: options.title ?? undefined,\n message: options.message ?? undefined,\n level: options.level ?? \"info\",\n displayDuration: options.displayDuration\n });\n }\n\n success(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"success\", options);\n }\n\n info(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"info\", options);\n }\n\n warning(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"warning\", options);\n }\n\n error(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"error\", options);\n }\n\n #sendSimpleNotification(level: NotificationLevel, options: SimpleNotificationOptions): void {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n this.notify({ ...options, level });\n }\n\n closeAll(): void {\n this.#dispatchHandlerMethod(\"closeAll\");\n }\n\n registerHandler(handler: NotificationHandler): Resource {\n // We only support exactly one handler.\n if (this.#handler) {\n LOG.warn(\n \"A notification handler has already been registered; this new handler will be ignored.\\n\" +\n \"The <Notifier /> component has likely been used twice in your application.\"\n );\n return {\n destroy() {\n return undefined;\n }\n };\n }\n\n // Dispatch buffered calls (if any).\n // These happened during the time no handler was registered.\n this.#handler = handler;\n const buffered = this.#buffered;\n this.#buffered = undefined;\n if (buffered) {\n for (const [name, ...args] of buffered) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (handler[name] as any)(...args);\n }\n }\n\n // Return a resource to undo the registration\n let destroyed = false;\n return {\n destroy: () => {\n if (destroyed) {\n return;\n }\n\n destroyed = true;\n if (this.#handler === handler) {\n this.#handler = undefined;\n }\n }\n };\n }\n\n /**\n * Calls a method on the handler (if present) or buffers the method call for later once the handler\n * has arrived.\n */\n #dispatchHandlerMethod<Method extends keyof NotificationHandler>(\n method: Method,\n ...args: Parameters<NotificationHandler[Method]>\n ): void;\n #dispatchHandlerMethod(method: keyof NotificationHandler, ...args: unknown[]): void {\n if (this.#handler) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this.#handler[method] as any)(...args);\n } else {\n const buffered = (this.#buffered ??= []);\n if (buffered.length >= 1024) {\n LOG.error(\n \"Internal notification buffer overflow: this event will be dropped to prevent a memory leak.\\n\" +\n \"Make sure that the UI is configured to display notifications (use <Notifier />).\",\n { method, args }\n );\n return;\n }\n buffered.push([method, ...args]);\n }\n }\n\n #checkHandlerRegistration() {\n if (!this.#handler) {\n LOG.warn(\n `No notification handler has been registered: notifications will not be visible.\\n` +\n `Make sure that your app contains the <Notifier /> component.`\n );\n }\n }\n}\n"],"names":[],"mappings":";;AAUA,MAAM,GAAA,GAAM,aAAa,8BAA8B,CAAA
|
|
1
|
+
{"version":3,"file":"NotificationServiceImpl.js","sources":["NotificationServiceImpl.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport type {\n NotificationLevel,\n NotificationOptions,\n NotificationService,\n SimpleNotificationOptions\n} from \"./api\";\nimport { Resource, createLogger } from \"@open-pioneer/core\";\nimport type { ReactNode } from \"react\";\nconst LOG = createLogger(\"notifier:NotificationService\");\n\nexport interface Notification {\n title: ReactNode;\n message: ReactNode;\n level: NotificationLevel;\n displayDuration: number | undefined;\n}\n\n/**\n * The notification handler is implemented by the UI in order to receive events.\n * There can only be one handler at a time.\n *\n * Calls to the handler may be buffered to allow for notifications before the UI has become ready.\n */\nexport interface NotificationHandler {\n /** Called by the service to emit the notification. */\n showNotification(notification: Notification): void;\n\n /** Removes all active notifications. */\n closeAll(): void;\n}\n\nexport interface InternalNotificationAPI extends NotificationService {\n /**\n * Registers the notification handler.\n * The returned resource can be used to unregister it again.\n */\n registerHandler(handler: NotificationHandler): Resource;\n}\n\nexport class NotificationServiceImpl implements InternalNotificationAPI {\n #handler: NotificationHandler | undefined;\n #buffered: [keyof NotificationHandler, ...unknown[]][] | undefined;\n #checkTimeoutId: any; // eslint-disable-line @typescript-eslint/no-explicit-any\n\n constructor() {\n if (import.meta.env.DEV) {\n this.#checkTimeoutId = setTimeout(() => {\n this.#checkHandlerRegistration();\n this.#checkTimeoutId = undefined;\n }, 5000);\n }\n }\n\n destroy() {\n clearTimeout(this.#checkTimeoutId);\n this.#checkTimeoutId = undefined;\n }\n\n notify(options: NotificationOptions): void {\n this.#dispatchHandlerMethod(\"showNotification\", {\n title: options.title ?? undefined,\n message: options.message ?? undefined,\n level: options.level ?? \"info\",\n displayDuration: options.displayDuration\n });\n }\n\n success(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"success\", options);\n }\n\n info(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"info\", options);\n }\n\n warning(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"warning\", options);\n }\n\n error(options: SimpleNotificationOptions): void {\n this.#sendSimpleNotification(\"error\", options);\n }\n\n #sendSimpleNotification(level: NotificationLevel, options: SimpleNotificationOptions): void {\n if (typeof options === \"string\") {\n options = { message: options };\n }\n this.notify({ ...options, level });\n }\n\n closeAll(): void {\n this.#dispatchHandlerMethod(\"closeAll\");\n }\n\n registerHandler(handler: NotificationHandler): Resource {\n // We only support exactly one handler.\n if (this.#handler) {\n LOG.warn(\n \"A notification handler has already been registered; this new handler will be ignored.\\n\" +\n \"The <Notifier /> component has likely been used twice in your application.\"\n );\n return {\n destroy() {\n return undefined;\n }\n };\n }\n\n // Dispatch buffered calls (if any).\n // These happened during the time no handler was registered.\n this.#handler = handler;\n const buffered = this.#buffered;\n this.#buffered = undefined;\n if (buffered) {\n for (const [name, ...args] of buffered) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (handler[name] as any)(...args);\n }\n }\n\n // Return a resource to undo the registration\n let destroyed = false;\n return {\n destroy: () => {\n if (destroyed) {\n return;\n }\n\n destroyed = true;\n if (this.#handler === handler) {\n this.#handler = undefined;\n }\n }\n };\n }\n\n /**\n * Calls a method on the handler (if present) or buffers the method call for later once the handler\n * has arrived.\n */\n #dispatchHandlerMethod<Method extends keyof NotificationHandler>(\n method: Method,\n ...args: Parameters<NotificationHandler[Method]>\n ): void;\n #dispatchHandlerMethod(method: keyof NotificationHandler, ...args: unknown[]): void {\n if (this.#handler) {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (this.#handler[method] as any)(...args);\n } else {\n const buffered = (this.#buffered ??= []);\n if (buffered.length >= 1024) {\n LOG.error(\n \"Internal notification buffer overflow: this event will be dropped to prevent a memory leak.\\n\" +\n \"Make sure that the UI is configured to display notifications (use <Notifier />).\",\n { method, args }\n );\n return;\n }\n buffered.push([method, ...args]);\n }\n }\n\n #checkHandlerRegistration() {\n if (!this.#handler) {\n LOG.warn(\n `No notification handler has been registered: notifications will not be visible.\\n` +\n `Make sure that your app contains the <Notifier /> component.`\n );\n }\n }\n}\n"],"names":[],"mappings":";;AAUA,MAAM,GAAA,GAAM,aAAa,8BAA8B,CAAA;AA+BhD,MAAM,uBAA2D,CAAA;AAAA,EACpE,QAAA;AAAA,EACA,SAAA;AAAA,EACA,eAAA;AAAA;AAAA,EAEA,WAAc,GAAA;AACV,IAAI,IAAA,MAAA,CAAA,IAAA,CAAY,IAAI,GAAK,EAAA;AACrB,MAAK,IAAA,CAAA,eAAA,GAAkB,WAAW,MAAM;AACpC,QAAA,IAAA,CAAK,yBAA0B,EAAA;AAC/B,QAAA,IAAA,CAAK,eAAkB,GAAA,MAAA;AAAA,SACxB,GAAI,CAAA;AAAA;AACX;AACJ,EAEA,OAAU,GAAA;AACN,IAAA,YAAA,CAAa,KAAK,eAAe,CAAA;AACjC,IAAA,IAAA,CAAK,eAAkB,GAAA,MAAA;AAAA;AAC3B,EAEA,OAAO,OAAoC,EAAA;AACvC,IAAA,IAAA,CAAK,uBAAuB,kBAA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Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useToast } from \"@open-pioneer/chakra-integration\";\nimport { useEvent } from \"@open-pioneer/react-utils\";\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { ReactElement, useEffect, useState } from \"react\";\nimport { InternalNotificationAPI, Notification } from \"./NotificationServiceImpl\";\nimport { WarningTwoIcon } from \"@chakra-ui/icons\";\n\n/** Props supported by the {@link Notifier} component. */\nexport interface NotifierProps {\n /**\n * The position for new notifications.\n *\n * @default \"top-right\"\n */\n position?: \"top\" | \"top-left\" | \"top-right\" | \"bottom\" | \"bottom-left\" | \"bottom-right\";\n}\n\nconst isDev = import.meta.env.DEV;\n\n/**\n * Shows notifications sent via the `NotificationService`.\n *\n * Only one instance of `<Notifier />` should be present in the application.\n * It currently does not matter where the Notifier is located in the react tree.\n *\n * ```ts\n * import { Notifier } from \"@open-pioneer/notifier\";\n *\n * export function AppUI() {\n * return (\n * <>\n * <Notifier position=\"top-right\" />\n * <h1>Your application</h1>\n * </>\n * );\n * }\n * ```\n */\nexport function Notifier(props: NotifierProps): ReactElement {\n const { position = \"top-right\" } = props;\n const toast = useToast();\n const notifications = useService(\"notifier.NotificationService\") as InternalNotificationAPI;\n const [ready, setReady] = useState(!isDev);\n\n const showNotification = useEvent((notification: Notification) => {\n // use different icons for warning and error\n const icon =\n notification.level === \"error\" ? <WarningTwoIcon h=\"100%\" w=\"100%\" /> : undefined;\n toast({\n position,\n title: notification.title,\n description: notification.message || null,\n status: notification.level,\n isClosable: true,\n duration: notification.displayDuration ?? null, // Null: does not auto-close\n icon\n });\n });\n const closeAll = useEvent(() => {\n toast.closeAll();\n });\n\n useEffect(() => {\n /*\n * Delay registering the notification handler a bit during development.\n * Chakra's toast implementation clears its store when it gets unmounted.\n * During development, that may also happen during initialization because of React's\n * StrictMode (https://react.dev/reference/react/StrictMode).\n *\n * Unfortunately, that means that toasts that were emitted very early (such as in service constructors)\n * will be deleted. Waiting for a few milliseconds prevents this issue and has no effect on production.\n */\n if (isDev && !ready) {\n const id = setTimeout(() => setReady(true), 100);\n return () => clearTimeout(id);\n }\n\n const handle = notifications.registerHandler({\n showNotification,\n closeAll\n });\n return () => handle.destroy();\n }, [ready, notifications, showNotification, closeAll]);\n\n // No actual UI representation right now\n return <></>;\n}\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,KAAA,GAAQ,YAAY,GAAI,CAAA,GAAA
|
|
1
|
+
{"version":3,"file":"Notifier.js","sources":["Notifier.tsx"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\nimport { useToast } from \"@open-pioneer/chakra-integration\";\nimport { useEvent } from \"@open-pioneer/react-utils\";\nimport { useService } from \"open-pioneer:react-hooks\";\nimport { ReactElement, useEffect, useState } from \"react\";\nimport { InternalNotificationAPI, Notification } from \"./NotificationServiceImpl\";\nimport { WarningTwoIcon } from \"@chakra-ui/icons\";\n\n/** Props supported by the {@link Notifier} component. */\nexport interface NotifierProps {\n /**\n * The position for new notifications.\n *\n * @default \"top-right\"\n */\n position?: \"top\" | \"top-left\" | \"top-right\" | \"bottom\" | \"bottom-left\" | \"bottom-right\";\n}\n\nconst isDev = import.meta.env.DEV;\n\n/**\n * Shows notifications sent via the `NotificationService`.\n *\n * Only one instance of `<Notifier />` should be present in the application.\n * It currently does not matter where the Notifier is located in the react tree.\n *\n * ```ts\n * import { Notifier } from \"@open-pioneer/notifier\";\n *\n * export function AppUI() {\n * return (\n * <>\n * <Notifier position=\"top-right\" />\n * <h1>Your application</h1>\n * </>\n * );\n * }\n * ```\n */\nexport function Notifier(props: NotifierProps): ReactElement {\n const { position = \"top-right\" } = props;\n const toast = useToast();\n const notifications = useService(\"notifier.NotificationService\") as InternalNotificationAPI;\n const [ready, setReady] = useState(!isDev);\n\n const showNotification = useEvent((notification: Notification) => {\n // use different icons for warning and error\n const icon =\n notification.level === \"error\" ? <WarningTwoIcon h=\"100%\" w=\"100%\" /> : undefined;\n toast({\n position,\n title: notification.title,\n description: notification.message || null,\n status: notification.level,\n isClosable: true,\n duration: notification.displayDuration ?? null, // Null: does not auto-close\n icon\n });\n });\n const closeAll = useEvent(() => {\n toast.closeAll();\n });\n\n useEffect(() => {\n /*\n * Delay registering the notification handler a bit during development.\n * Chakra's toast implementation clears its store when it gets unmounted.\n * During development, that may also happen during initialization because of React's\n * StrictMode (https://react.dev/reference/react/StrictMode).\n *\n * Unfortunately, that means that toasts that were emitted very early (such as in service constructors)\n * will be deleted. Waiting for a few milliseconds prevents this issue and has no effect on production.\n */\n if (isDev && !ready) {\n const id = setTimeout(() => setReady(true), 100);\n return () => clearTimeout(id);\n }\n\n const handle = notifications.registerHandler({\n showNotification,\n closeAll\n });\n return () => handle.destroy();\n }, [ready, notifications, showNotification, closeAll]);\n\n // No actual UI representation right now\n return <></>;\n}\n"],"names":[],"mappings":";;;;;;;AAmBA,MAAM,KAAA,GAAQ,YAAY,GAAI,CAAA,GAAA;AAqBvB,SAAS,SAAS,KAAoC,EAAA;AACzD,EAAM,MAAA,EAAE,QAAW,GAAA,WAAA,EAAgB,GAAA,KAAA;AACnC,EAAA,MAAM,QAAQ,QAAS,EAAA;AACvB,EAAM,MAAA,aAAA,GAAgB,WAAW,8BAA8B,CAAA;AAC/D,EAAA,MAAM,CAAC,KAAO,EAAA,QAAQ,CAAI,GAAA,QAAA,CAAS,CAAC,KAAK,CAAA;AAEzC,EAAM,MAAA,gBAAA,GAAmB,QAAS,CAAA,CAAC,YAA+B,KAAA;AAE9D,IAAM,MAAA,IAAA,GACF,YAAa,CAAA,KAAA,KAAU,OAAU,mBAAA,GAAA,CAAC,kBAAe,CAAE,EAAA,MAAA,EAAO,CAAE,EAAA,MAAA,EAAO,CAAK,GAAA,MAAA;AAC5E,IAAM,KAAA,CAAA;AAAA,MACF,QAAA;AAAA,MACA,OAAO,YAAa,CAAA,KAAA;AAAA,MACpB,WAAA,EAAa,aAAa,OAAW,IAAA,IAAA;AAAA,MACrC,QAAQ,YAAa,CAAA,KAAA;AAAA,MACrB,UAAY,EAAA,IAAA;AAAA,MACZ,QAAA,EAAU,aAAa,eAAmB,IAAA,IAAA;AAAA;AAAA,MAC1C;AAAA,KACH,CAAA;AAAA,GACJ,CAAA;AACD,EAAM,MAAA,QAAA,GAAW,SAAS,MAAM;AAC5B,IAAA,KAAA,CAAM,QAAS,EAAA;AAAA,GAClB,CAAA;AAED,EAAA,SAAA,CAAU,MAAM;AAUZ,IAAI,IAAA,KAAA,IAAS,CAAC,KAAO,EAAA;AACjB,MAAA,MAAM,KAAK,UAAW,CAAA,MAAM,QAAS,CAAA,IAAI,GAAG,GAAG,CAAA;AAC/C,MAAO,OAAA,MAAM,aAAa,EAAE,CAAA;AAAA;AAGhC,IAAM,MAAA,MAAA,GAAS,cAAc,eAAgB,CAAA;AAAA,MACzC,gBAAA;AAAA,MACA;AAAA,KACH,CAAA;AACD,IAAO,OAAA,MAAM,OAAO,OAAQ,EAAA;AAAA,KAC7B,CAAC,KAAA,EAAO,aAAe,EAAA,gBAAA,EAAkB,QAAQ,CAAC,CAAA;AAGrD,EAAA,uBAAS,GAAA,CAAA,QAAA,EAAA,EAAA,CAAA;AACb;;;;"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"type": "module",
|
|
3
3
|
"name": "@open-pioneer/notifier",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "3.0.0-dev.20250221111321",
|
|
5
5
|
"description": "Provides support for application-wide notifications.",
|
|
6
6
|
"keywords": [
|
|
7
7
|
"open-pioneer-trails"
|
|
@@ -15,11 +15,11 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@chakra-ui/icons": "^2.2.4",
|
|
18
|
-
"react": "^
|
|
19
|
-
"@open-pioneer/core": "^
|
|
20
|
-
"@open-pioneer/chakra-integration": "^
|
|
21
|
-
"@open-pioneer/runtime": "^
|
|
22
|
-
"@open-pioneer/react-utils": "^
|
|
18
|
+
"react": "^19.0.0",
|
|
19
|
+
"@open-pioneer/core": "^3.0.0-dev.20250221111321",
|
|
20
|
+
"@open-pioneer/chakra-integration": "^3.0.0-dev.20250221111321",
|
|
21
|
+
"@open-pioneer/runtime": "^3.0.0-dev.20250221111321",
|
|
22
|
+
"@open-pioneer/react-utils": "^3.0.0-dev.20250221111321"
|
|
23
23
|
},
|
|
24
24
|
"exports": {
|
|
25
25
|
"./package.json": "./package.json",
|