@open-pioneer/core 4.8.0 → 4.9.0-dev.20261002130116

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,11 @@
1
1
  # @open-pioneer/core
2
2
 
3
+ ## 4.9.0-dev.20261002130116
4
+
5
+ ### Patch Changes
6
+
7
+ - 6b160f3: Mark the `EventNames` type as `@deprecated` together with `EventEmitter`.
8
+
3
9
  ## 4.8.0
4
10
 
5
11
  ### Minor Changes
@@ -16,16 +22,16 @@
16
22
 
17
23
  - 7c7e6d1: Add shallowEqual and deepEqual helper function to compare two objects.
18
24
 
19
- Examples:
25
+ Examples:
20
26
 
21
- ```ts
22
- import { shallowEqual, deepEqual } from "@open-pioneer/core";
27
+ ```ts
28
+ import { shallowEqual, deepEqual } from "@open-pioneer/core";
23
29
 
24
- shallowEqual({ a: 1 }, { a: 1 }); // true
25
- shallowEqual({ a: { x: 1 } }, { a: { x: 1 } }); // false
26
- deepEqual({ a: { x: 1 } }, { a: { x: 1 } }); // true
27
- deepEqual([1, [2, 3]], [1, [2, 3]]); // true
28
- ```
30
+ shallowEqual({ a: 1 }, { a: 1 }); // true
31
+ shallowEqual({ a: { x: 1 } }, { a: { x: 1 } }); // false
32
+ deepEqual({ a: { x: 1 } }, { a: { x: 1 } }); // true
33
+ deepEqual([1, [2, 3]], [1, [2, 3]]); // true
34
+ ```
29
35
 
30
36
  - e433296: Update Chakra UI to 3.36.1
31
37
 
@@ -95,13 +101,13 @@
95
101
  ### Major Changes
96
102
 
97
103
  - 9477e54: Update dependencies
98
- - React 19
99
- - Vite 6
100
- - FormatJS 3
101
- - Open Pioneer Build Tools
102
- - ...
104
+ - React 19
105
+ - Vite 6
106
+ - FormatJS 3
107
+ - Open Pioneer Build Tools
108
+ - ...
103
109
 
104
- For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
110
+ For more details, see https://github.com/open-pioneer/trails-core-packages/pull/81
105
111
 
106
112
  ## 2.4.0
107
113
 
@@ -109,12 +115,12 @@
109
115
 
110
116
  - e3802fb: Introduce the `NumberParser` class for parsing strings in a specified locale.
111
117
 
112
- ```js
113
- import { NumberParser } from "@open-pioneer/core";
118
+ ```js
119
+ import { NumberParser } from "@open-pioneer/core";
114
120
 
115
- const parser = new NumberParser("de-DE");
116
- const number = parser.parse("1.234,56");
117
- ```
121
+ const parser = new NumberParser("de-DE");
122
+ const number = parser.parse("1.234,56");
123
+ ```
118
124
 
119
125
  ### Patch Changes
120
126
 
package/Logger.d.ts CHANGED
@@ -70,7 +70,7 @@ export interface Logger {
70
70
  */
71
71
  warn: LogMethod;
72
72
  /**
73
- * Logging method for debug error level.
73
+ * Logging method for error log level.
74
74
  * Follows normal log method structure but logs in error level.
75
75
  */
76
76
  error: LogMethod;
@@ -80,31 +80,15 @@ export interface Logger {
80
80
  */
81
81
  export declare class LoggerImpl implements Logger {
82
82
  #private;
83
- prefix: string;
83
+ readonly prefix: string;
84
84
  constructor(prefix: string, logLevel: LogLevel);
85
85
  isDebug(): boolean;
86
- /**
87
- * Performs a debug log with the given message and values if DEBUG level is enabled.
88
- * @param message
89
- * @param values
90
- */
86
+ /** Performs a debug log with the given message and values if DEBUG level is enabled. */
91
87
  debug(message: string | Error | unknown, ...values: unknown[]): void;
92
- /**
93
- * Performs an info log with the given message and values if INFO level is enabled.
94
- * @param message
95
- * @param values
96
- */
88
+ /** Performs an info log with the given message and values if INFO level is enabled. */
97
89
  info(message: string | Error | unknown, ...values: unknown[]): void;
98
- /**
99
- * Performs a warning log with the given message and values if WARN level is enabled.
100
- * @param message
101
- * @param values
102
- */
90
+ /** Performs a warning log with the given message and values if WARN level is enabled. */
103
91
  warn(message: string | Error | unknown, ...values: unknown[]): void;
104
- /**
105
- * Performs an error log with the given message and values if ERROR level is enabled.
106
- * @param message
107
- * @param values
108
- */
92
+ /** Performs an error log with the given message and values if ERROR level is enabled. */
109
93
  error(message: string | Error | unknown, ...values: unknown[]): void;
110
94
  }
package/Logger.js CHANGED
@@ -18,45 +18,22 @@ class LoggerImpl {
18
18
  isDebug() {
19
19
  return this.#isLogLevelEnabled("DEBUG");
20
20
  }
21
- /**
22
- * Performs a debug log with the given message and values if DEBUG level is enabled.
23
- * @param message
24
- * @param values
25
- */
21
+ /** Performs a debug log with the given message and values if DEBUG level is enabled. */
26
22
  debug(message, ...values) {
27
23
  this.#doLog("DEBUG", message, values);
28
24
  }
29
- /**
30
- * Performs an info log with the given message and values if INFO level is enabled.
31
- * @param message
32
- * @param values
33
- */
25
+ /** Performs an info log with the given message and values if INFO level is enabled. */
34
26
  info(message, ...values) {
35
27
  this.#doLog("INFO", message, values);
36
28
  }
37
- /**
38
- * Performs a warning log with the given message and values if WARN level is enabled.
39
- * @param message
40
- * @param values
41
- */
29
+ /** Performs a warning log with the given message and values if WARN level is enabled. */
42
30
  warn(message, ...values) {
43
31
  this.#doLog("WARN", message, values);
44
32
  }
45
- /**
46
- * Performs an error log with the given message and values if ERROR level is enabled.
47
- * @param message
48
- * @param values
49
- */
33
+ /** Performs an error log with the given message and values if ERROR level is enabled. */
50
34
  error(message, ...values) {
51
35
  this.#doLog("ERROR", message, values);
52
36
  }
53
- /**
54
- * Internal method for performing the log if the specified level is enabled.
55
- * @param level
56
- * @param messageOrError
57
- * @param values
58
- * @private
59
- */
60
37
  #doLog(level, messageOrError, values) {
61
38
  if (this.#isLogLevelEnabled(level)) {
62
39
  let message = `[${level}] ${this.prefix}:`;
package/Logger.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Logger.js","sources":["Logger.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nconst LOG_LEVEL = typeof __LOG_LEVEL__ !== \"undefined\" ? validateLogLevel(__LOG_LEVEL__) : \"INFO\";\n\n/**\n * Creates and returns a new logger instance for an application wide standardized logging.\n * For available log methods see {@link Logger} interface.\n * The log level is globally configured (see vite.config.ts).\n *\n * You can create a logger with an arbitrary-prefix:\n *\n * ```ts\n * const logger = createLogger(\"some-prefix\");\n * logger.debug(\"...\");\n * ```\n *\n * With recent version of the trails vite plugin, you can also use this convenient way to create a logger:\n *\n * ```ts\n * import { sourceId } from \"open-pioneer:source-info\";\n *\n * // sourceId is an automatic identifier based on the current file.\n * const LOG = createLogger(sourceId);\n * ```\n *\n * @param prefix Prefix used to prefix all log messages invoked by the created logger instance.\n */\nexport function createLogger(prefix: string): Logger {\n return new LoggerImpl(prefix, LOG_LEVEL);\n}\n\n/**\n * Allowed log levels.\n * Order: DEBUG < INFO < WARN < ERROR\n */\nexport type LogLevel = \"DEBUG\" | \"INFO\" | \"WARN\" | \"ERROR\";\n\n// internal representation of log levels as numbers for log level comparison.\nconst logLevelNumbers: Record<LogLevel, number> = {\n DEBUG: 0,\n INFO: 1,\n WARN: 2,\n ERROR: 3\n};\n\nexport interface LogMethod {\n /**\n * Logger's log method signature\n *\n * @param message\n * Log message to be logged (attached to the prefix). This can be an arbitrary value.\n * Errors will be logged as-is, and other values are formatted as strings.\n * @param values Arbitrary amount of additional values to be logged (attached to message).\n */\n (message: string | Error | unknown, ...values: unknown[]): void;\n}\n\n/**\n * Provides a logger for a standardized application wide logging.\n *\n * The logger's log level is configured globally.\n *\n * Use the `createLogger` function to receive a new logger instance for logging.\n */\nexport interface Logger {\n /**\n * Prefix prepended to all logging messages\n */\n readonly prefix: string;\n\n /**\n * Returns true if debug log level is enabled.\n */\n isDebug(): boolean;\n\n /**\n * Logging method for debug log level.\n * Follows normal LogMethod structure but logs in debug level.\n */\n debug: LogMethod;\n\n /**\n * Logging method for info log level.\n * Follows normal log method structure but logs in info level.\n */\n info: LogMethod;\n\n /**\n * Logging method for warn log level.\n * Follows normal log method structure but logs in warn level.\n */\n warn: LogMethod;\n\n /**\n * Logging method for debug error level.\n * Follows normal log method structure but logs in error level.\n */\n error: LogMethod;\n}\n\n/**\n * A class implementing a logger with a global log level.\n */\nexport class LoggerImpl implements Logger {\n prefix: string;\n readonly #enabledLogLevelNumber: number;\n\n constructor(prefix: string, logLevel: LogLevel) {\n this.prefix = prefix;\n this.#enabledLogLevelNumber = logLevelToLogLevelNumber(logLevel);\n }\n\n isDebug() {\n return this.#isLogLevelEnabled(\"DEBUG\");\n }\n\n /**\n * Performs a debug log with the given message and values if DEBUG level is enabled.\n * @param message\n * @param values\n */\n debug(message: string | Error | unknown, ...values: unknown[]) {\n this.#doLog(\"DEBUG\", message, values);\n }\n\n /**\n * Performs an info log with the given message and values if INFO level is enabled.\n * @param message\n * @param values\n */\n info(message: string | Error | unknown, ...values: unknown[]) {\n this.#doLog(\"INFO\", message, values);\n }\n\n /**\n * Performs a warning log with the given message and values if WARN level is enabled.\n * @param message\n * @param values\n */\n warn(message: string | Error | unknown, ...values: unknown[]) {\n this.#doLog(\"WARN\", message, values);\n }\n\n /**\n * Performs an error log with the given message and values if ERROR level is enabled.\n * @param message\n * @param values\n */\n error(message: string | Error | unknown, ...values: unknown[]) {\n this.#doLog(\"ERROR\", message, values);\n }\n\n /**\n * Internal method for performing the log if the specified level is enabled.\n * @param level\n * @param messageOrError\n * @param values\n * @private\n */\n #doLog(level: LogLevel, messageOrError: string | Error | unknown, values: unknown[]) {\n if (this.#isLogLevelEnabled(level)) {\n let message = `[${level}] ${this.prefix}:`;\n if (!isError(messageOrError)) {\n message += \" \" + String(messageOrError);\n } else {\n values.unshift(messageOrError);\n }\n const consoleMethodName = logLevelToConsoleMethodName(level);\n console[consoleMethodName](message, ...values);\n }\n }\n\n #isLogLevelEnabled(logLevel: LogLevel) {\n const logLevelNumber = logLevelToLogLevelNumber(logLevel);\n return logLevelNumber >= this.#enabledLogLevelNumber;\n }\n}\n\n/**\n * Converts a LogLevel to a browser's debugging console method name.\n * @param logLevel\n */\nfunction logLevelToConsoleMethodName(logLevel: LogLevel): \"debug\" | \"info\" | \"warn\" | \"error\" {\n switch (logLevel) {\n case \"DEBUG\":\n return \"debug\";\n case \"INFO\":\n return \"info\";\n case \"WARN\":\n return \"warn\";\n case \"ERROR\":\n return \"error\";\n }\n}\n\nfunction logLevelToLogLevelNumber(logLevel: LogLevel) {\n return logLevelNumbers[logLevel];\n}\n\nfunction validateLogLevel(logLevelString: string): LogLevel {\n if (!logLevelString) {\n return \"INFO\";\n }\n\n switch (logLevelString) {\n case \"DEBUG\":\n case \"INFO\":\n case \"WARN\":\n case \"ERROR\":\n return logLevelString;\n default:\n throw new Error(\n `invalid log level '${logLevelString}'; allowed levels are: DEBUG, INFO, WARN, ERROR`\n );\n }\n}\n\nfunction isError(value: unknown): value is Error {\n if (value instanceof Error) {\n return true;\n }\n return !!(\n value &&\n typeof value === \"object\" &&\n typeof (value as Partial<Error>).name === \"string\" &&\n typeof (value as Partial<Error>).message === \"string\"\n );\n}\n"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"Logger.js","sources":["Logger.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nconst LOG_LEVEL = typeof __LOG_LEVEL__ !== \"undefined\" ? validateLogLevel(__LOG_LEVEL__) : \"INFO\";\n\n/**\n * Creates and returns a new logger instance for an application wide standardized logging.\n * For available log methods see {@link Logger} interface.\n * The log level is globally configured (see vite.config.ts).\n *\n * You can create a logger with an arbitrary-prefix:\n *\n * ```ts\n * const logger = createLogger(\"some-prefix\");\n * logger.debug(\"...\");\n * ```\n *\n * With recent version of the trails vite plugin, you can also use this convenient way to create a logger:\n *\n * ```ts\n * import { sourceId } from \"open-pioneer:source-info\";\n *\n * // sourceId is an automatic identifier based on the current file.\n * const LOG = createLogger(sourceId);\n * ```\n *\n * @param prefix Prefix used to prefix all log messages invoked by the created logger instance.\n */\nexport function createLogger(prefix: string): Logger {\n return new LoggerImpl(prefix, LOG_LEVEL);\n}\n\n/**\n * Allowed log levels.\n * Order: DEBUG < INFO < WARN < ERROR\n */\nexport type LogLevel = \"DEBUG\" | \"INFO\" | \"WARN\" | \"ERROR\";\n\n// internal representation of log levels as numbers for log level comparison.\nconst logLevelNumbers: Record<LogLevel, number> = {\n DEBUG: 0,\n INFO: 1,\n WARN: 2,\n ERROR: 3\n};\n\nexport interface LogMethod {\n /**\n * Logger's log method signature\n *\n * @param message\n * Log message to be logged (attached to the prefix). This can be an arbitrary value.\n * Errors will be logged as-is, and other values are formatted as strings.\n * @param values Arbitrary amount of additional values to be logged (attached to message).\n */\n (message: string | Error | unknown, ...values: unknown[]): void;\n}\n\n/**\n * Provides a logger for a standardized application wide logging.\n *\n * The logger's log level is configured globally.\n *\n * Use the `createLogger` function to receive a new logger instance for logging.\n */\nexport interface Logger {\n /**\n * Prefix prepended to all logging messages\n */\n readonly prefix: string;\n\n /**\n * Returns true if debug log level is enabled.\n */\n isDebug(): boolean;\n\n /**\n * Logging method for debug log level.\n * Follows normal LogMethod structure but logs in debug level.\n */\n debug: LogMethod;\n\n /**\n * Logging method for info log level.\n * Follows normal log method structure but logs in info level.\n */\n info: LogMethod;\n\n /**\n * Logging method for warn log level.\n * Follows normal log method structure but logs in warn level.\n */\n warn: LogMethod;\n\n /**\n * Logging method for error log level.\n * Follows normal log method structure but logs in error level.\n */\n error: LogMethod;\n}\n\n/**\n * A class implementing a logger with a global log level.\n */\nexport class LoggerImpl implements Logger {\n readonly prefix: string;\n readonly #enabledLogLevelNumber: number;\n\n constructor(prefix: string, logLevel: LogLevel) {\n this.prefix = prefix;\n this.#enabledLogLevelNumber = logLevelToLogLevelNumber(logLevel);\n }\n\n isDebug() {\n return this.#isLogLevelEnabled(\"DEBUG\");\n }\n\n /** Performs a debug log with the given message and values if DEBUG level is enabled. */\n debug(message: string | Error | unknown, ...values: unknown[]) {\n this.#doLog(\"DEBUG\", message, values);\n }\n\n /** Performs an info log with the given message and values if INFO level is enabled. */\n info(message: string | Error | unknown, ...values: unknown[]) {\n this.#doLog(\"INFO\", message, values);\n }\n\n /** Performs a warning log with the given message and values if WARN level is enabled. */\n warn(message: string | Error | unknown, ...values: unknown[]) {\n this.#doLog(\"WARN\", message, values);\n }\n\n /** Performs an error log with the given message and values if ERROR level is enabled. */\n error(message: string | Error | unknown, ...values: unknown[]) {\n this.#doLog(\"ERROR\", message, values);\n }\n\n #doLog(level: LogLevel, messageOrError: string | Error | unknown, values: unknown[]) {\n if (this.#isLogLevelEnabled(level)) {\n let message = `[${level}] ${this.prefix}:`;\n if (!isError(messageOrError)) {\n message += \" \" + String(messageOrError);\n } else {\n values.unshift(messageOrError);\n }\n const consoleMethodName = logLevelToConsoleMethodName(level);\n console[consoleMethodName](message, ...values);\n }\n }\n\n #isLogLevelEnabled(logLevel: LogLevel) {\n const logLevelNumber = logLevelToLogLevelNumber(logLevel);\n return logLevelNumber >= this.#enabledLogLevelNumber;\n }\n}\n\n/**\n * Converts a LogLevel to a browser's debugging console method name.\n * @param logLevel\n */\nfunction logLevelToConsoleMethodName(logLevel: LogLevel): \"debug\" | \"info\" | \"warn\" | \"error\" {\n switch (logLevel) {\n case \"DEBUG\":\n return \"debug\";\n case \"INFO\":\n return \"info\";\n case \"WARN\":\n return \"warn\";\n case \"ERROR\":\n return \"error\";\n }\n}\n\nfunction logLevelToLogLevelNumber(logLevel: LogLevel) {\n return logLevelNumbers[logLevel];\n}\n\nfunction validateLogLevel(logLevelString: string): LogLevel {\n if (!logLevelString) {\n return \"INFO\";\n }\n\n switch (logLevelString) {\n case \"DEBUG\":\n case \"INFO\":\n case \"WARN\":\n case \"ERROR\":\n return logLevelString;\n default:\n throw new Error(\n `invalid log level '${logLevelString}'; allowed levels are: DEBUG, INFO, WARN, ERROR`\n );\n }\n}\n\nfunction isError(value: unknown): value is Error {\n if (value instanceof Error) {\n return true;\n }\n return !!(\n value &&\n typeof value === \"object\" &&\n typeof (value as Partial<Error>).name === \"string\" &&\n typeof (value as Partial<Error>).message === \"string\"\n );\n}\n"],"names":[],"mappings":"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"}
package/README.md CHANGED
@@ -14,8 +14,7 @@ import { Error } from "@open-pioneer/core";
14
14
  throw new Error("my-error:identifier", "This is the error message");
15
15
  ```
16
16
 
17
- `Error` also exposes the optional `cause` attribute that allows nesting of error instances.
18
- Note that browser support for that property is still required:
17
+ `Error` also exposes the optional `cause` attribute that allows nesting of error instances:
19
18
 
20
19
  ```js
21
20
  import { Error, getErrorChain } from "@open-pioneer/core";
@@ -37,11 +36,11 @@ All object needing some cleanup action to be called should use the `destroy` met
37
36
 
38
37
  ### Logger
39
38
 
40
- The `Logger` class provides a logger for standardized application wide logging.
39
+ The `Logger` interface provides a logger for standardized application wide logging.
41
40
  The log level is configured globally in the file `vite.config.ts`: to change the application's log level,
42
41
  define the `__LOG_LEVEL__` constant to a custom value.
43
42
 
44
- To create a logger instance, call the `createLogger` method.
43
+ To create a logger instance, call the `createLogger` function.
45
44
  It takes a prefix (string) to prepend to each message.
46
45
  To encode hierarchical names, use `:` as a separator (for example `"some-package:SomeClass"`).
47
46
 
package/deprecated.d.ts CHANGED
@@ -54,7 +54,7 @@ export declare function setDeprecationWarningsEnabled(newEnabled: boolean): void
54
54
  * function someFunctionName() {
55
55
  * printDeprecation();
56
56
  * // ...
57
- * } *
57
+ * }
58
58
  * ```
59
59
  */
60
60
  export declare function deprecated(options: DeprecatedOptions): () => void;
package/deprecated.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"deprecated.js","sources":["deprecated.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nlet enabled = typeof __PRINT_DEPRECATIONS__ !== \"undefined\" ? __PRINT_DEPRECATIONS__ : true;\n\n/**\n * Options supported by {@link deprecated}.\n */\nexport interface DeprecatedOptions {\n /**\n * The package that contains the deprecated entity.\n */\n packageName?: string;\n\n /**\n * The entity name (class name, function name, option, ...) that was deprecated.\n */\n name: string;\n\n /**\n * The version or date in which the entity was deprecated.\n */\n since: string;\n\n /**\n * Available alternatives, if any.\n * Should be a succinct message like `use xyz instead`.\n */\n alternative?: string;\n}\n\n/**\n * To dynamically enable/disable deprecations at runtime.\n *\n * Currently only used for other tests in this project.\n *\n * @internal\n */\nexport function setDeprecationWarningsEnabled(newEnabled: boolean) {\n enabled = newEnabled;\n}\n\n/**\n * Creates a deprecation helper for a deprecated entity.\n *\n * This helper is used to print a deprecation warning to the browser console\n * when the deprecated functionality is being used.\n *\n * Returns a _function_ that should be called when the deprecated entity is being used.\n * The function will print a deprecation warning when usage is detected for the first time.\n * Any further calls will have no effect to prevent spamming the console.\n *\n * > NOTE: Deprecation warnings are only printed in development builds.\n *\n * Example:\n *\n * ```js\n * const printDeprecation = deprecated({\n * name: \"someFunctionName\",\n * packageName: \"some-package\",\n * since: \"v1.2.3\",\n * alternative: \"use xyz instead\"\n * });\n *\n * // Later, when the deprecated function is actually being used:\n * function someFunctionName() {\n * printDeprecation();\n * // ...\n * } *\n * ```\n */\nexport function deprecated(options: DeprecatedOptions): () => void {\n if (!enabled || !import.meta.env.DEV) {\n return () => {}; // do nothing\n }\n\n let called = false;\n return function deprecationHelper() {\n if (!enabled || called) {\n return;\n }\n\n called = true;\n // oxlint-disable-next-line no-console\n console.warn(buildDeprecationWarning(options));\n };\n}\n\nfunction buildDeprecationWarning(options: DeprecatedOptions): string {\n const { packageName, name, since, alternative } = options;\n const packageInfo = packageName ? ` in ${packageName}` : \"\";\n const alternativeInfo = alternative ? `, ${alternative}` : \"\";\n const message = `⚠️ DEPRECATED: ${name}${packageInfo} (since ${since}${alternativeInfo}) - Please update your code as this may be removed in future versions.`;\n return message;\n}\n"],"names":[],"mappings":"AAGA,IAAI,OAAA,GAAU,OAAO,sBAAA,KAA2B,WAAA,GAAc,sBAAA,GAAyB,IAAA;AAoEhF,SAAS,WAAW,OAAA,EAAwC;AAC/D,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,MAAA,CAAA,IAAA,CAAY,IAAI,GAAA,EAAK;AAClC,IAAA,OAAO,MAAM;AAAA,IAAC,CAAA;AAAA,EAClB;AAEA,EAAA,IAAI,MAAA,GAAS,KAAA;AACb,EAAA,OAAO,SAAS,iBAAA,GAAoB;AAChC,IAAA,IAAI,CAAC,WAAW,MAAA,EAAQ;AACpB,MAAA;AAAA,IACJ;AAEA,IAAA,MAAA,GAAS,IAAA;AAET,IAAA,OAAA,CAAQ,IAAA,CAAK,uBAAA,CAAwB,OAAO,CAAC,CAAA;AAAA,EACjD,CAAA;AACJ;AAEA,SAAS,wBAAwB,OAAA,EAAoC;AACjE,EAAA,MAAM,EAAE,WAAA,EAAa,IAAA,EAAM,KAAA,EAAO,aAAY,GAAI,OAAA;AAClD,EAAA,MAAM,WAAA,GAAc,WAAA,GAAc,CAAA,IAAA,EAAO,WAAW,CAAA,CAAA,GAAK,EAAA;AACzD,EAAA,MAAM,eAAA,GAAkB,WAAA,GAAc,CAAA,EAAA,EAAK,WAAW,CAAA,CAAA,GAAK,EAAA;AAC3D,EAAA,MAAM,OAAA,GAAU,4BAAkB,IAAI,CAAA,EAAG,WAAW,CAAA,QAAA,EAAW,KAAK,GAAG,eAAe,CAAA,sEAAA,CAAA;AACtF,EAAA,OAAO,OAAA;AACX;;"}
1
+ {"version":3,"file":"deprecated.js","sources":["deprecated.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nlet enabled = typeof __PRINT_DEPRECATIONS__ !== \"undefined\" ? __PRINT_DEPRECATIONS__ : true;\n\n/**\n * Options supported by {@link deprecated}.\n */\nexport interface DeprecatedOptions {\n /**\n * The package that contains the deprecated entity.\n */\n packageName?: string;\n\n /**\n * The entity name (class name, function name, option, ...) that was deprecated.\n */\n name: string;\n\n /**\n * The version or date in which the entity was deprecated.\n */\n since: string;\n\n /**\n * Available alternatives, if any.\n * Should be a succinct message like `use xyz instead`.\n */\n alternative?: string;\n}\n\n/**\n * To dynamically enable/disable deprecations at runtime.\n *\n * Currently only used for other tests in this project.\n *\n * @internal\n */\nexport function setDeprecationWarningsEnabled(newEnabled: boolean) {\n enabled = newEnabled;\n}\n\n/**\n * Creates a deprecation helper for a deprecated entity.\n *\n * This helper is used to print a deprecation warning to the browser console\n * when the deprecated functionality is being used.\n *\n * Returns a _function_ that should be called when the deprecated entity is being used.\n * The function will print a deprecation warning when usage is detected for the first time.\n * Any further calls will have no effect to prevent spamming the console.\n *\n * > NOTE: Deprecation warnings are only printed in development builds.\n *\n * Example:\n *\n * ```js\n * const printDeprecation = deprecated({\n * name: \"someFunctionName\",\n * packageName: \"some-package\",\n * since: \"v1.2.3\",\n * alternative: \"use xyz instead\"\n * });\n *\n * // Later, when the deprecated function is actually being used:\n * function someFunctionName() {\n * printDeprecation();\n * // ...\n * }\n * ```\n */\nexport function deprecated(options: DeprecatedOptions): () => void {\n if (!enabled || !import.meta.env.DEV) {\n return () => {}; // do nothing\n }\n\n let called = false;\n return function deprecationHelper() {\n if (!enabled || called) {\n return;\n }\n\n called = true;\n // oxlint-disable-next-line no-console\n console.warn(buildDeprecationWarning(options));\n };\n}\n\nfunction buildDeprecationWarning(options: DeprecatedOptions): string {\n const { packageName, name, since, alternative } = options;\n const packageInfo = packageName ? ` in ${packageName}` : \"\";\n const alternativeInfo = alternative ? `, ${alternative}` : \"\";\n const message = `⚠️ DEPRECATED: ${name}${packageInfo} (since ${since}${alternativeInfo}) - Please update your code as this may be removed in future versions.`;\n return message;\n}\n"],"names":[],"mappings":"AAGA,IAAI,OAAA,GAAU,OAAO,sBAAA,KAA2B,WAAA,GAAc,sBAAA,GAAyB,IAAA;AAoEhF,SAAS,WAAW,OAAA,EAAwC;AAC/D,EAAA,IAAI,CAAC,OAAA,IAAW,CAAC,MAAA,CAAA,IAAA,CAAY,IAAI,GAAA,EAAK;AAClC,IAAA,OAAO,MAAM;AAAA,IAAC,CAAA;AAAA,EAClB;AAEA,EAAA,IAAI,MAAA,GAAS,KAAA;AACb,EAAA,OAAO,SAAS,iBAAA,GAAoB;AAChC,IAAA,IAAI,CAAC,WAAW,MAAA,EAAQ;AACpB,MAAA;AAAA,IACJ;AAEA,IAAA,MAAA,GAAS,IAAA;AAET,IAAA,OAAA,CAAQ,IAAA,CAAK,uBAAA,CAAwB,OAAO,CAAC,CAAA;AAAA,EACjD,CAAA;AACJ;AAEA,SAAS,wBAAwB,OAAA,EAAoC;AACjE,EAAA,MAAM,EAAE,WAAA,EAAa,IAAA,EAAM,KAAA,EAAO,aAAY,GAAI,OAAA;AAClD,EAAA,MAAM,WAAA,GAAc,WAAA,GAAc,CAAA,IAAA,EAAO,WAAW,CAAA,CAAA,GAAK,EAAA;AACzD,EAAA,MAAM,eAAA,GAAkB,WAAA,GAAc,CAAA,EAAA,EAAK,WAAW,CAAA,CAAA,GAAK,EAAA;AAC3D,EAAA,MAAM,OAAA,GAAU,4BAAkB,IAAI,CAAA,EAAG,WAAW,CAAA,QAAA,EAAW,KAAK,GAAG,eAAe,CAAA,sEAAA,CAAA;AACtF,EAAA,OAAO,OAAA;AACX;;"}
package/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sources":["error.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nconst GlobalError = globalThis.Error;\n\n/**\n * A custom error class that enforces the use of error ids.\n *\n * An error must be constructed from a (computer-readable) id and a human readable informational text.\n * An optional `cause` option can be passed to indicate the nested reason for an error.\n *\n * # Conventions\n *\n * Error ids should be scoped to a package to avoid conflicts.\n * Each package should pick a sensible namespace prefix.\n *\n * An example for a good error id is `runtime:dependency-cycle`.\n */\nexport class Error extends GlobalError {\n /** Unique error id */\n public readonly id: string;\n\n /** Human readable error message */\n public readonly text: string;\n\n constructor(id: string, text: string, options?: { cause?: unknown }) {\n super(`${id}: ${text}`, options);\n this.id = id;\n this.text = text;\n }\n}\n\n/**\n * Returns the error chain for the given `err`, starting with this error.\n * The error chain contains the error itself and all its causes.\n * The first entry is `err` itself.\n */\nexport function getErrorChain(err: globalThis.Error): globalThis.Error[] {\n const chain: globalThis.Error[] = [];\n do {\n chain.push(err);\n\n // oxlint-disable-next-line @typescript-eslint/no-explicit-any\n const cause = (err as any).cause as unknown;\n if (!(cause instanceof GlobalError)) {\n break;\n }\n err = cause;\n } while (1); // oxlint-disable-line no-constant-condition\n return chain;\n}\n\n/**\n * Returns true if the error represents an abort error.\n */\nexport function isAbortError(err: unknown): boolean {\n return !!(err && typeof err === \"object\" && \"name\" in err && err.name === \"AbortError\");\n}\n\n/**\n * Throws an abort error (`.name` === `\"AbortError\"`).\n */\nexport function throwAbortError(): never {\n throw createAbortError();\n}\n\n/**\n * Throws `err` if it is an abort error. Does nothing otherwise.\n */\nexport function rethrowAbortError(err: unknown): void {\n if (isAbortError(err)) {\n throw err;\n }\n}\n\n/**\n * Returns an abort error (`.name` === `\"AbortError\"`).\n */\nexport function createAbortError(): globalThis.Error {\n const err = new globalThis.Error(\"Aborted\");\n err.name = \"AbortError\";\n return err;\n}\n"],"names":[],"mappings":"AAGA,MAAM,cAAc,UAAA,CAAW,KAAA;AAexB,MAAM,cAAc,WAAA,CAAY;AAAA;AAAA,EAEnB,EAAA;AAAA;AAAA,EAGA,IAAA;AAAA,EAEhB,WAAA,CAAY,EAAA,EAAY,IAAA,EAAc,OAAA,EAA+B;AACjE,IAAA,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,EAAA,EAAK,IAAI,IAAI,OAAO,CAAA;AAC/B,IAAA,IAAA,CAAK,EAAA,GAAK,EAAA;AACV,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EAChB;AACJ;AAOO,SAAS,cAAc,GAAA,EAA2C;AACrE,EAAA,MAAM,QAA4B,EAAC;AACnC,EAAA,GAAG;AACC,IAAA,KAAA,CAAM,KAAK,GAAG,CAAA;AAGd,IAAA,MAAM,QAAS,GAAA,CAAY,KAAA;AAC3B,IAAA,IAAI,EAAE,iBAAiB,WAAA,CAAA,EAAc;AACjC,MAAA;AAAA,IACJ;AACA,IAAA,GAAA,GAAM,KAAA;AAAA,EACV,CAAA,QAAS,CAAA;AACT,EAAA,OAAO,KAAA;AACX;AAKO,SAAS,aAAa,GAAA,EAAuB;AAChD,EAAA,OAAO,CAAC,EAAE,GAAA,IAAO,OAAO,QAAQ,QAAA,IAAY,MAAA,IAAU,GAAA,IAAO,GAAA,CAAI,IAAA,KAAS,YAAA,CAAA;AAC9E;AAKO,SAAS,eAAA,GAAyB;AACrC,EAAA,MAAM,gBAAA,EAAiB;AAC3B;AAKO,SAAS,kBAAkB,GAAA,EAAoB;AAClD,EAAA,IAAI,YAAA,CAAa,GAAG,CAAA,EAAG;AACnB,IAAA,MAAM,GAAA;AAAA,EACV;AACJ;AAKO,SAAS,gBAAA,GAAqC;AACjD,EAAA,MAAM,GAAA,GAAM,IAAI,UAAA,CAAW,KAAA,CAAM,SAAS,CAAA;AAC1C,EAAA,GAAA,CAAI,IAAA,GAAO,YAAA;AACX,EAAA,OAAO,GAAA;AACX;;"}
1
+ {"version":3,"file":"error.js","sources":["error.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nconst GlobalError = globalThis.Error;\n\n/**\n * A custom error class that enforces the use of error ids.\n *\n * An error must be constructed from a (computer-readable) id and a human readable informational text.\n * An optional `cause` option can be passed to indicate the nested reason for an error.\n *\n * # Conventions\n *\n * Error ids should be scoped to a package to avoid conflicts.\n * Each package should pick a sensible namespace prefix.\n *\n * An example for a good error id is `runtime:dependency-cycle`.\n */\nexport class Error extends GlobalError {\n /** Unique error id */\n public readonly id: string;\n\n /** Human readable error message */\n public readonly text: string;\n\n constructor(id: string, text: string, options?: { cause?: unknown }) {\n super(`${id}: ${text}`, options);\n this.id = id;\n this.text = text;\n }\n}\n\n/**\n * Returns the error chain for the given `err`, starting with this error.\n * The error chain contains the error itself and all its causes.\n * The first entry is `err` itself.\n */\nexport function getErrorChain(err: globalThis.Error): globalThis.Error[] {\n const chain: globalThis.Error[] = [];\n do {\n chain.push(err);\n\n const cause = err.cause;\n if (!(cause instanceof GlobalError)) {\n break;\n }\n err = cause;\n } while (1); // oxlint-disable-line no-constant-condition\n return chain;\n}\n\n/**\n * Returns true if the error represents an abort error.\n */\nexport function isAbortError(err: unknown): boolean {\n return !!(err && typeof err === \"object\" && \"name\" in err && err.name === \"AbortError\");\n}\n\n/**\n * Throws an abort error (`.name` === `\"AbortError\"`).\n */\nexport function throwAbortError(): never {\n throw createAbortError();\n}\n\n/**\n * Throws `err` if it is an abort error. Does nothing otherwise.\n */\nexport function rethrowAbortError(err: unknown): void {\n if (isAbortError(err)) {\n throw err;\n }\n}\n\n/**\n * Returns an abort error (`.name` === `\"AbortError\"`).\n */\nexport function createAbortError(): globalThis.Error {\n const err = new globalThis.Error(\"Aborted\");\n err.name = \"AbortError\";\n return err;\n}\n"],"names":[],"mappings":"AAGA,MAAM,cAAc,UAAA,CAAW,KAAA;AAexB,MAAM,cAAc,WAAA,CAAY;AAAA;AAAA,EAEnB,EAAA;AAAA;AAAA,EAGA,IAAA;AAAA,EAEhB,WAAA,CAAY,EAAA,EAAY,IAAA,EAAc,OAAA,EAA+B;AACjE,IAAA,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA,EAAA,EAAK,IAAI,IAAI,OAAO,CAAA;AAC/B,IAAA,IAAA,CAAK,EAAA,GAAK,EAAA;AACV,IAAA,IAAA,CAAK,IAAA,GAAO,IAAA;AAAA,EAChB;AACJ;AAOO,SAAS,cAAc,GAAA,EAA2C;AACrE,EAAA,MAAM,QAA4B,EAAC;AACnC,EAAA,GAAG;AACC,IAAA,KAAA,CAAM,KAAK,GAAG,CAAA;AAEd,IAAA,MAAM,QAAQ,GAAA,CAAI,KAAA;AAClB,IAAA,IAAI,EAAE,iBAAiB,WAAA,CAAA,EAAc;AACjC,MAAA;AAAA,IACJ;AACA,IAAA,GAAA,GAAM,KAAA;AAAA,EACV,CAAA,QAAS,CAAA;AACT,EAAA,OAAO,KAAA;AACX;AAKO,SAAS,aAAa,GAAA,EAAuB;AAChD,EAAA,OAAO,CAAC,EAAE,GAAA,IAAO,OAAO,QAAQ,QAAA,IAAY,MAAA,IAAU,GAAA,IAAO,GAAA,CAAI,IAAA,KAAS,YAAA,CAAA;AAC9E;AAKO,SAAS,eAAA,GAAyB;AACrC,EAAA,MAAM,gBAAA,EAAiB;AAC3B;AAKO,SAAS,kBAAkB,GAAA,EAAoB;AAClD,EAAA,IAAI,YAAA,CAAa,GAAG,CAAA,EAAG;AACnB,IAAA,MAAM,GAAA;AAAA,EACV;AACJ;AAKO,SAAS,gBAAA,GAAqC;AACjD,EAAA,MAAM,GAAA,GAAM,IAAI,UAAA,CAAW,KAAA,CAAM,SAAS,CAAA;AAC1C,EAAA,GAAA,CAAI,IAAA,GAAO,YAAA;AACX,EAAA,OAAO,GAAA;AACX;;"}
package/events.d.ts CHANGED
@@ -1,4 +1,9 @@
1
1
  import { Resource } from "./resources";
2
+ /**
3
+ * The event names of an `Events` interface used with {@link EventEmitter}.
4
+ *
5
+ * @deprecated Use the package [@conterra/reactivity-events](https://www.npmjs.com/package/@conterra/reactivity-events) instead.
6
+ */
2
7
  export type EventNames<Events extends {}> = keyof Events & string;
3
8
  type ArgType<T> = [T] extends [void] ? [] : [event: T];
4
9
  type EventType<Events extends {}, Name extends keyof Events> = ArgType<Events[Name]>;
package/events.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"events.js","sources":["events.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n emit,\n emitter,\n on,\n EventEmitter as ReactivityEmitter,\n SubscribeOptions\n} from \"@conterra/reactivity-events\";\nimport { deprecated } from \"./deprecated\";\nimport { Resource } from \"./resources\";\n\nexport type EventNames<Events extends {}> = keyof Events & string;\n\ntype ArgType<T> = [T] extends [void] ? [] : [event: T];\n\ntype EventType<Events extends {}, Name extends keyof Events> = ArgType<Events[Name]>;\n\nconst deprecatedHelper = deprecated({\n name: \"EventEmitter\",\n packageName: \"@open-pioneer/core\",\n since: \"v4.2.0\",\n alternative: \"use @conterra/reactivity-events instead\"\n});\n\nconst SYNC_OPT = { dispatch: \"sync\" } as const satisfies SubscribeOptions;\nconst ONCE_OPT = { dispatch: \"sync\", once: true } as const satisfies SubscribeOptions;\n\n/**\n * A support class that implements emitting and listening for events.\n *\n * This class supports inheritance or direct use:\n *\n * ```js\n * const emitter = new EventEmitter();\n * class MyClass extends EventEmitter {};\n * ```\n *\n * When using this class from TypeScript, declare your supported event\n * types using an interface first:\n *\n * ```ts\n * interface Events {\n * // key: event name, value: event type\n * \"mouse-clicked\": MouseEvent;\n * }\n *\n * const emitter = new EventEmitter<Events>();\n * emitter.on(\"mouse-clicked\", (event) => {\n * // event is a MouseEvent\n * });\n * emitter.emit(\"mouse-clicked\", new MouseEvent(...));\n * ```\n *\n * @deprecated Use the package [@conterra/reactivity-events](https://www.npmjs.com/package/@conterra/reactivity-events) instead.\n */\nexport class EventEmitter<Events extends {}> {\n #state = new EventEmitterState();\n\n constructor() {\n deprecatedHelper();\n }\n\n /**\n * Registers the given listener function as an event handler for `eventName`.\n *\n * The listener function should be unregistered by destroying the returned {@link Resource}\n * when it is no longer needed.\n */\n on<Name extends EventNames<Events>>(\n eventName: Name,\n listener: (...args: EventType<Events, Name>) => void\n ): Resource {\n const e = this.#state.getEmitter(eventName, true);\n return on(e, listener as InternalListener, SYNC_OPT);\n }\n\n /**\n * Registers the given listener function to listen for `eventName` events _once_.\n * The listener function will automatically be unregistered after it has been called.\n *\n * The listener function should be unregistered by destroying the returned {@link Resource}.\n */\n once<Name extends EventNames<Events>>(\n eventName: Name,\n listener: (...args: EventType<Events, Name>) => void\n ): Resource {\n const e = this.#state.getEmitter(eventName, true);\n return on(e, listener as InternalListener, ONCE_OPT);\n }\n\n /**\n * Emits an event of the given name and calls the registered event handlers.\n *\n * _Note:_ event handlers run synchronously.\n * After `emit()` has completed, all listeners will already have been invoked.\n */\n emit<Name extends EventNames<Events>>(eventName: Name, ...args: EventType<Events, Name>): void {\n const e = this.#state.getEmitter(eventName);\n if (e) {\n emit(e, args[0]);\n }\n }\n}\n\n/**\n * Read-only version of the {@link EventEmitter} interface that only allows listening for events.\n *\n * @deprecated Use the package [@conterra/reactivity-events](https://www.npmjs.com/package/@conterra/reactivity-events) instead.\n */\nexport type EventSource<Events extends {}> = Pick<EventEmitter<Events>, \"on\" | \"once\">;\n\ntype InternalListener = (event: unknown) => void;\n\nclass EventEmitterState {\n #emitters = new Map<string, ReactivityEmitter<unknown>>();\n\n getEmitter(name: string): ReactivityEmitter<unknown> | undefined;\n getEmitter(name: string, init: true): ReactivityEmitter<unknown>;\n getEmitter(name: string, init = false) {\n let e = this.#emitters.get(name);\n if (!e && init) {\n e = emitter();\n this.#emitters.set(name, e);\n }\n return e;\n }\n}\n"],"names":[],"mappings":";;;AAmBA,MAAM,mBAAmB,UAAA,CAAW;AAAA,EAChC,IAAA,EAAM,cAAA;AAAA,EACN,WAAA,EAAa,oBAAA;AAAA,EACb,KAAA,EAAO,QAAA;AAAA,EACP,WAAA,EAAa;AACjB,CAAC,CAAA;AAED,MAAM,QAAA,GAAW,EAAE,QAAA,EAAU,MAAA,EAAO;AACpC,MAAM,QAAA,GAAW,EAAE,QAAA,EAAU,MAAA,EAAQ,MAAM,IAAA,EAAK;AA8BzC,MAAM,YAAA,CAAgC;AAAA,EACzC,MAAA,GAAS,IAAI,iBAAA,EAAkB;AAAA,EAE/B,WAAA,GAAc;AACV,IAAA,gBAAA,EAAiB;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,EAAA,CACI,WACA,QAAA,EACQ;AACR,IAAA,MAAM,CAAA,GAAI,IAAA,CAAK,MAAA,CAAO,UAAA,CAAW,WAAW,IAAI,CAAA;AAChD,IAAA,OAAO,EAAA,CAAG,CAAA,EAAG,QAAA,EAA8B,QAAQ,CAAA;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAA,CACI,WACA,QAAA,EACQ;AACR,IAAA,MAAM,CAAA,GAAI,IAAA,CAAK,MAAA,CAAO,UAAA,CAAW,WAAW,IAAI,CAAA;AAChD,IAAA,OAAO,EAAA,CAAG,CAAA,EAAG,QAAA,EAA8B,QAAQ,CAAA;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAA,CAAsC,cAAoB,IAAA,EAAqC;AAC3F,IAAA,MAAM,CAAA,GAAI,IAAA,CAAK,MAAA,CAAO,UAAA,CAAW,SAAS,CAAA;AAC1C,IAAA,IAAI,CAAA,EAAG;AACH,MAAA,IAAA,CAAK,CAAA,EAAG,IAAA,CAAK,CAAC,CAAC,CAAA;AAAA,IACnB;AAAA,EACJ;AACJ;AAWA,MAAM,iBAAA,CAAkB;AAAA,EACpB,SAAA,uBAAgB,GAAA,EAAwC;AAAA,EAIxD,UAAA,CAAW,IAAA,EAAc,IAAA,GAAO,KAAA,EAAO;AACnC,IAAA,IAAI,CAAA,GAAI,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,IAAI,CAAA;AAC/B,IAAA,IAAI,CAAC,KAAK,IAAA,EAAM;AACZ,MAAA,CAAA,GAAI,OAAA,EAAQ;AACZ,MAAA,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,IAAA,EAAM,CAAC,CAAA;AAAA,IAC9B;AACA,IAAA,OAAO,CAAA;AAAA,EACX;AACJ;;"}
1
+ {"version":3,"file":"events.js","sources":["events.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\nimport {\n emit,\n emitter,\n on,\n EventEmitter as ReactivityEmitter,\n SubscribeOptions\n} from \"@conterra/reactivity-events\";\nimport { deprecated } from \"./deprecated\";\nimport { Resource } from \"./resources\";\n\n/**\n * The event names of an `Events` interface used with {@link EventEmitter}.\n *\n * @deprecated Use the package [@conterra/reactivity-events](https://www.npmjs.com/package/@conterra/reactivity-events) instead.\n */\nexport type EventNames<Events extends {}> = keyof Events & string;\n\ntype ArgType<T> = [T] extends [void] ? [] : [event: T];\n\ntype EventType<Events extends {}, Name extends keyof Events> = ArgType<Events[Name]>;\n\nconst deprecatedHelper = deprecated({\n name: \"EventEmitter\",\n packageName: \"@open-pioneer/core\",\n since: \"v4.2.0\",\n alternative: \"use @conterra/reactivity-events instead\"\n});\n\nconst SYNC_OPT = { dispatch: \"sync\" } as const satisfies SubscribeOptions;\nconst ONCE_OPT = { dispatch: \"sync\", once: true } as const satisfies SubscribeOptions;\n\n/**\n * A support class that implements emitting and listening for events.\n *\n * This class supports inheritance or direct use:\n *\n * ```js\n * const emitter = new EventEmitter();\n * class MyClass extends EventEmitter {};\n * ```\n *\n * When using this class from TypeScript, declare your supported event\n * types using an interface first:\n *\n * ```ts\n * interface Events {\n * // key: event name, value: event type\n * \"mouse-clicked\": MouseEvent;\n * }\n *\n * const emitter = new EventEmitter<Events>();\n * emitter.on(\"mouse-clicked\", (event) => {\n * // event is a MouseEvent\n * });\n * emitter.emit(\"mouse-clicked\", new MouseEvent(...));\n * ```\n *\n * @deprecated Use the package [@conterra/reactivity-events](https://www.npmjs.com/package/@conterra/reactivity-events) instead.\n */\nexport class EventEmitter<Events extends {}> {\n #state = new EventEmitterState();\n\n constructor() {\n deprecatedHelper();\n }\n\n /**\n * Registers the given listener function as an event handler for `eventName`.\n *\n * The listener function should be unregistered by destroying the returned {@link Resource}\n * when it is no longer needed.\n */\n on<Name extends EventNames<Events>>(\n eventName: Name,\n listener: (...args: EventType<Events, Name>) => void\n ): Resource {\n const e = this.#state.getEmitter(eventName, true);\n return on(e, listener as InternalListener, SYNC_OPT);\n }\n\n /**\n * Registers the given listener function to listen for `eventName` events _once_.\n * The listener function will automatically be unregistered after it has been called.\n *\n * The listener function should be unregistered by destroying the returned {@link Resource}.\n */\n once<Name extends EventNames<Events>>(\n eventName: Name,\n listener: (...args: EventType<Events, Name>) => void\n ): Resource {\n const e = this.#state.getEmitter(eventName, true);\n return on(e, listener as InternalListener, ONCE_OPT);\n }\n\n /**\n * Emits an event of the given name and calls the registered event handlers.\n *\n * _Note:_ event handlers run synchronously.\n * After `emit()` has completed, all listeners will already have been invoked.\n */\n emit<Name extends EventNames<Events>>(eventName: Name, ...args: EventType<Events, Name>): void {\n const e = this.#state.getEmitter(eventName);\n if (e) {\n emit(e, args[0]);\n }\n }\n}\n\n/**\n * Read-only version of the {@link EventEmitter} interface that only allows listening for events.\n *\n * @deprecated Use the package [@conterra/reactivity-events](https://www.npmjs.com/package/@conterra/reactivity-events) instead.\n */\nexport type EventSource<Events extends {}> = Pick<EventEmitter<Events>, \"on\" | \"once\">;\n\ntype InternalListener = (event: unknown) => void;\n\nclass EventEmitterState {\n #emitters = new Map<string, ReactivityEmitter<unknown>>();\n\n getEmitter(name: string): ReactivityEmitter<unknown> | undefined;\n getEmitter(name: string, init: true): ReactivityEmitter<unknown>;\n getEmitter(name: string, init = false) {\n let e = this.#emitters.get(name);\n if (!e && init) {\n e = emitter();\n this.#emitters.set(name, e);\n }\n return e;\n }\n}\n"],"names":[],"mappings":";;;AAwBA,MAAM,mBAAmB,UAAA,CAAW;AAAA,EAChC,IAAA,EAAM,cAAA;AAAA,EACN,WAAA,EAAa,oBAAA;AAAA,EACb,KAAA,EAAO,QAAA;AAAA,EACP,WAAA,EAAa;AACjB,CAAC,CAAA;AAED,MAAM,QAAA,GAAW,EAAE,QAAA,EAAU,MAAA,EAAO;AACpC,MAAM,QAAA,GAAW,EAAE,QAAA,EAAU,MAAA,EAAQ,MAAM,IAAA,EAAK;AA8BzC,MAAM,YAAA,CAAgC;AAAA,EACzC,MAAA,GAAS,IAAI,iBAAA,EAAkB;AAAA,EAE/B,WAAA,GAAc;AACV,IAAA,gBAAA,EAAiB;AAAA,EACrB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,EAAA,CACI,WACA,QAAA,EACQ;AACR,IAAA,MAAM,CAAA,GAAI,IAAA,CAAK,MAAA,CAAO,UAAA,CAAW,WAAW,IAAI,CAAA;AAChD,IAAA,OAAO,EAAA,CAAG,CAAA,EAAG,QAAA,EAA8B,QAAQ,CAAA;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAA,CACI,WACA,QAAA,EACQ;AACR,IAAA,MAAM,CAAA,GAAI,IAAA,CAAK,MAAA,CAAO,UAAA,CAAW,WAAW,IAAI,CAAA;AAChD,IAAA,OAAO,EAAA,CAAG,CAAA,EAAG,QAAA,EAA8B,QAAQ,CAAA;AAAA,EACvD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,IAAA,CAAsC,cAAoB,IAAA,EAAqC;AAC3F,IAAA,MAAM,CAAA,GAAI,IAAA,CAAK,MAAA,CAAO,UAAA,CAAW,SAAS,CAAA;AAC1C,IAAA,IAAI,CAAA,EAAG;AACH,MAAA,IAAA,CAAK,CAAA,EAAG,IAAA,CAAK,CAAC,CAAC,CAAA;AAAA,IACnB;AAAA,EACJ;AACJ;AAWA,MAAM,iBAAA,CAAkB;AAAA,EACpB,SAAA,uBAAgB,GAAA,EAAwC;AAAA,EAIxD,UAAA,CAAW,IAAA,EAAc,IAAA,GAAO,KAAA,EAAO;AACnC,IAAA,IAAI,CAAA,GAAI,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,IAAI,CAAA;AAC/B,IAAA,IAAI,CAAC,KAAK,IAAA,EAAM;AACZ,MAAA,CAAA,GAAI,OAAA,EAAQ;AACZ,MAAA,IAAA,CAAK,SAAA,CAAU,GAAA,CAAI,IAAA,EAAM,CAAC,CAAA;AAAA,IAC9B;AACA,IAAA,OAAO,CAAA;AAAA,EACX;AACJ;;"}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "type": "module",
3
3
  "name": "@open-pioneer/core",
4
- "version": "4.8.0",
4
+ "version": "4.9.0-dev.20261002130116",
5
5
  "description": "Contains basic utility functions and classes used by the @open-pioneer project.",
6
6
  "keywords": [
7
7
  "open-pioneer-trails"
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@conterra/reactivity-events": "^0.8.8",
18
- "fast-equals": "^6.0.3"
18
+ "fast-equals": "^6.0.4"
19
19
  },
20
20
  "publishConfig": {
21
21
  "directory": "dist",
package/utils.d.ts CHANGED
@@ -9,4 +9,5 @@ export interface ManualPromise<T> {
9
9
  resolve(value: T): void;
10
10
  reject(error: unknown): void;
11
11
  }
12
+ /** Creates a new {@link ManualPromise}. */
12
13
  export declare function createManualPromise<T>(): ManualPromise<T>;
package/utils.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"utils.js","sources":["utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * A manual promise that also exposes its `resolve` and `reject` functions.\n *\n * The user must take care to always call either `resolve` or `reject` at least once,\n * otherwise clients waiting for the `promise` may wait forever.\n */\nexport interface ManualPromise<T> {\n promise: Promise<T>;\n resolve(value: T): void;\n reject(error: unknown): void;\n}\n\nexport function createManualPromise<T>(): ManualPromise<T> {\n let resolve!: (value: T) => void;\n let reject!: (error: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return {\n promise,\n resolve,\n reject\n };\n}\n"],"names":[],"mappings":"AAeO,SAAS,mBAAA,GAA2C;AACvD,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI,MAAA;AACJ,EAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAW,CAAC,KAAK,GAAA,KAAQ;AACzC,IAAA,OAAA,GAAU,GAAA;AACV,IAAA,MAAA,GAAS,GAAA;AAAA,EACb,CAAC,CAAA;AACD,EAAA,OAAO;AAAA,IACH,OAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACJ;AACJ;;"}
1
+ {"version":3,"file":"utils.js","sources":["utils.ts"],"sourcesContent":["// SPDX-FileCopyrightText: 2023-2025 Open Pioneer project (https://github.com/open-pioneer)\n// SPDX-License-Identifier: Apache-2.0\n\n/**\n * A manual promise that also exposes its `resolve` and `reject` functions.\n *\n * The user must take care to always call either `resolve` or `reject` at least once,\n * otherwise clients waiting for the `promise` may wait forever.\n */\nexport interface ManualPromise<T> {\n promise: Promise<T>;\n resolve(value: T): void;\n reject(error: unknown): void;\n}\n\n/** Creates a new {@link ManualPromise}. */\nexport function createManualPromise<T>(): ManualPromise<T> {\n let resolve!: (value: T) => void;\n let reject!: (error: unknown) => void;\n const promise = new Promise<T>((res, rej) => {\n resolve = res;\n reject = rej;\n });\n return {\n promise,\n resolve,\n reject\n };\n}\n"],"names":[],"mappings":"AAgBO,SAAS,mBAAA,GAA2C;AACvD,EAAA,IAAI,OAAA;AACJ,EAAA,IAAI,MAAA;AACJ,EAAA,MAAM,OAAA,GAAU,IAAI,OAAA,CAAW,CAAC,KAAK,GAAA,KAAQ;AACzC,IAAA,OAAA,GAAU,GAAA;AACV,IAAA,MAAA,GAAS,GAAA;AAAA,EACb,CAAC,CAAA;AACD,EAAA,OAAO;AAAA,IACH,OAAA;AAAA,IACA,OAAA;AAAA,IACA;AAAA,GACJ;AACJ;;"}