@open-pioneer/notifier 2.2.0 → 2.4.0-dev.20241120085048

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 CHANGED
@@ -1,5 +1,45 @@
1
1
  # @open-pioneer/notifier
2
2
 
3
+ ## 2.4.0-dev.20241120085048
4
+
5
+ ### Minor Changes
6
+
7
+ - e4ba048: Introduce new convenience methods on the `NotificationService` in addition to the existing `notify()` method:
8
+
9
+ ```js
10
+ const notifier = ...; // injected
11
+ notifier.success(/* ... */)
12
+ notifier.info(/* ... */)
13
+ notifier.warning(/* ... */)
14
+ notifier.error(/* ... */)
15
+ ```
16
+
17
+ ### Patch Changes
18
+
19
+ - 1b63ebe: Update dependencies
20
+ - Updated dependencies [1b63ebe]
21
+ - Updated dependencies [e3802fb]
22
+ - Updated dependencies [ac39468]
23
+ - Updated dependencies [e3802fb]
24
+ - @open-pioneer/chakra-integration@2.4.0-dev.20241120085048
25
+ - @open-pioneer/react-utils@2.4.0-dev.20241120085048
26
+ - @open-pioneer/core@2.4.0-dev.20241120085048
27
+ - @open-pioneer/runtime@2.4.0-dev.20241120085048
28
+
29
+ ## 2.3.0
30
+
31
+ ### Minor Changes
32
+
33
+ - 2fbaaa0: Use normal `dependencies` instead of `peerDependencies`. Peer dependencies have some usability issues (and bugs) when used at scale.
34
+
35
+ ### Patch Changes
36
+
37
+ - Updated dependencies [2fbaaa0]
38
+ - @open-pioneer/chakra-integration@2.3.0
39
+ - @open-pioneer/react-utils@2.3.0
40
+ - @open-pioneer/runtime@2.3.0
41
+ - @open-pioneer/core@2.3.0
42
+
3
43
  ## 2.2.0
4
44
 
5
45
  ### Patch Changes
@@ -1,4 +1,4 @@
1
- import type { NotificationLevel, NotificationOptions, NotificationService } from "./api";
1
+ import type { NotificationLevel, NotificationOptions, NotificationService, SimpleNotificationOptions } from "./api";
2
2
  import { Resource } from "@open-pioneer/core";
3
3
  import type { ReactNode } from "react";
4
4
  export interface Notification {
@@ -31,6 +31,10 @@ export declare class NotificationServiceImpl implements InternalNotificationAPI
31
31
  constructor();
32
32
  destroy(): void;
33
33
  notify(options: NotificationOptions): void;
34
+ success(options: SimpleNotificationOptions): void;
35
+ info(options: SimpleNotificationOptions): void;
36
+ warning(options: SimpleNotificationOptions): void;
37
+ error(options: SimpleNotificationOptions): void;
34
38
  closeAll(): void;
35
39
  registerHandler(handler: NotificationHandler): Resource;
36
40
  }
@@ -26,6 +26,24 @@ class NotificationServiceImpl {
26
26
  displayDuration: options.displayDuration
27
27
  });
28
28
  }
29
+ success(options) {
30
+ this.#sendSimpleNotification("success", options);
31
+ }
32
+ info(options) {
33
+ this.#sendSimpleNotification("info", options);
34
+ }
35
+ warning(options) {
36
+ this.#sendSimpleNotification("warning", options);
37
+ }
38
+ error(options) {
39
+ this.#sendSimpleNotification("error", options);
40
+ }
41
+ #sendSimpleNotification(level, options) {
42
+ if (typeof options === "string") {
43
+ options = { message: options };
44
+ }
45
+ this.notify({ ...options, level });
46
+ }
29
47
  closeAll() {
30
48
  this.#dispatchHandlerMethod("closeAll");
31
49
  }
@@ -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 { NotificationLevel, NotificationOptions, NotificationService } 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 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":";;AAKA,MAAM,GAAA,GAAM,aAAa,8BAA8B,CAAA,CAAA;AA+BhD,MAAM,uBAA2D,CAAA;AAAA,EACpE,QAAA,CAAA;AAAA,EACA,SAAA,CAAA;AAAA,EACA,eAAA,CAAA;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,CAAA;AAC/B,QAAA,IAAA,CAAK,eAAkB,GAAA,KAAA,CAAA,CAAA;AAAA,SACxB,GAAI,CAAA,CAAA;AAAA,KACX;AAAA,GACJ;AAAA,EAEA,OAAU,GAAA;AACN,IAAA,YAAA,CAAa,KAAK,eAAe,CAAA,CAAA;AACjC,IAAA,IAAA,CAAK,eAAkB,GAAA,KAAA,CAAA,CAAA;AAAA,GAC3B;AAAA,EAEA,OAAO,OAAoC,EAAA;AACvC,IAAA,IAAA,CAAK,uBAAuB,kBAAoB,EAAA;AAAA,MAC5C,KAAA,EAAO,QAAQ,KAAS,IAAA,KAAA,CAAA;AAAA,MACxB,OAAA,EAAS,QAAQ,OAAW,IAAA,KAAA,CAAA;AAAA,MAC5B,KAAA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A,QAAA,CAAS,MAAM,CAAA,CAAU,GAAG,IAAI,CAAA,CAAA;AAAA,KACnC,MAAA;AACH,MAAM,MAAA,QAAA,GAAY,IAAK,CAAA,SAAA,KAAc,EAAC,CAAA;AACtC,MAAI,IAAA,QAAA,CAAS,UAAU,IAAM,EAAA;AACzB,QAAI,GAAA,CAAA,KAAA;AAAA,UACA,+KAAA;AAAA,UAEA,EAAE,QAAQ,IAAK,EAAA;AAAA,SACnB,CAAA;AACA,QAAA,OAAA;AAAA,OACJ;AACA,MAAA,QAAA,CAAS,IAAK,CAAA,CAAC,MAAQ,EAAA,GAAG,IAAI,CAAC,CAAA,CAAA;AAAA,KACnC;AAAA,GACJ;AAAA,EAEA,yBAA4B,GAAA;AACxB,IAAI,IAAA,CAAC,KAAK,QAAU,EAAA;AAChB,MAAI,GAAA,CAAA,IAAA;AAAA,QACA,CAAA;AAAA,4DAAA,CAAA;AAAA,OAEJ,CAAA;AAAA,KACJ;AAAA,GACJ;AACJ;;;;"}
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,CAAA;AA+BhD,MAAM,uBAA2D,CAAA;AAAA,EACpE,QAAA,CAAA;AAAA,EACA,SAAA,CAAA;AAAA,EACA,eAAA,CAAA;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,CAAA;AAC/B,QAAA,IAAA,CAAK,eAAkB,GAAA,KAAA,CAAA,CAAA;AAAA,SACxB,GAAI,CAAA,CAAA;AAAA,KACX;AAAA,GACJ;AAAA,EAEA,OAAU,GAAA;AACN,IAAA,YAAA,CAAa,KAAK,eAAe,CAAA,CAAA;AACjC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nB,CAAA;AACA,QAAA,OAAA;AAAA,OACJ;AACA,MAAA,QAAA,CAAS,IAAK,CAAA,CAAC,MAAQ,EAAA,GAAG,IAAI,CAAC,CAAA,CAAA;AAAA,KACnC;AAAA,GACJ;AAAA,EAEA,yBAA4B,GAAA;AACxB,IAAI,IAAA,CAAC,KAAK,QAAU,EAAA;AAChB,MAAI,GAAA,CAAA,IAAA;AAAA,QACA,CAAA;AAAA,4DAAA,CAAA;AAAA,OAEJ,CAAA;AAAA,KACJ;AAAA,GACJ;AACJ;;;;"}
package/api.d.ts CHANGED
@@ -23,6 +23,14 @@ export interface NotificationOptions {
23
23
  */
24
24
  displayDuration?: number | undefined;
25
25
  }
26
+ /**
27
+ * Options used when emitting a new notification via {@link NotificationService}
28
+ * using convenience methods like `warning` and `error`.
29
+ *
30
+ * Options can either be an object that is the same as {@link NotificationOptions}, but without the `level` property
31
+ * or a string, which will be used as the `message` of the Notification.
32
+ */
33
+ export type SimpleNotificationOptions = Omit<NotificationOptions, "level"> | string;
26
34
  /**
27
35
  * The `NotificationService` allows any part of the application to emit
28
36
  * notifications to the user.
@@ -39,6 +47,14 @@ export interface NotificationService extends DeclaredService<"notifier.Notificat
39
47
  * @param options Options for the new notification.
40
48
  */
41
49
  notify(options: NotificationOptions): void;
50
+ /** Emits a success notification. Same as {@link notify} with `type: "success"`. */
51
+ success(options: SimpleNotificationOptions): void;
52
+ /** Emits an info notification. Same as {@link notify} with `type: "info"`. */
53
+ info(options: SimpleNotificationOptions): void;
54
+ /** Emits a warning notification. Same as {@link notify} with `type: "warning"`. */
55
+ warning(options: SimpleNotificationOptions): void;
56
+ /** Emits an error notification. Same as {@link notify} with `type: "error"`. */
57
+ error(options: SimpleNotificationOptions): void;
42
58
  /** Closes all active notifications. */
43
59
  closeAll(): void;
44
60
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/notifier",
4
- "version": "2.2.0",
4
+ "version": "2.4.0-dev.20241120085048",
5
5
  "description": "Provides support for application-wide notifications.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -13,13 +13,13 @@
13
13
  "url": "https://github.com/open-pioneer/trails-core-packages",
14
14
  "directory": "src/packages/notifier"
15
15
  },
16
- "peerDependencies": {
17
- "@chakra-ui/icons": "^2.1.1",
16
+ "dependencies": {
17
+ "@chakra-ui/icons": "^2.2.4",
18
18
  "react": "^18.3.1",
19
- "@open-pioneer/core": "^2.2.0",
20
- "@open-pioneer/chakra-integration": "^2.2.0",
21
- "@open-pioneer/react-utils": "^2.2.0",
22
- "@open-pioneer/runtime": "^2.2.0"
19
+ "@open-pioneer/core": "^2.4.0-dev.20241120085048",
20
+ "@open-pioneer/runtime": "^2.4.0-dev.20241120085048",
21
+ "@open-pioneer/react-utils": "^2.4.0-dev.20241120085048",
22
+ "@open-pioneer/chakra-integration": "^2.4.0-dev.20241120085048"
23
23
  },
24
24
  "exports": {
25
25
  "./package.json": "./package.json",