@itwin/core-bentley 5.0.0-dev.1 → 5.0.0-dev.100

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.
Files changed (142) hide show
  1. package/CHANGELOG.md +74 -1
  2. package/lib/cjs/BeEvent.js +3 -7
  3. package/lib/cjs/BeEvent.js.map +1 -1
  4. package/lib/cjs/BentleyError.d.ts +84 -1
  5. package/lib/cjs/BentleyError.d.ts.map +1 -1
  6. package/lib/cjs/BentleyError.js +72 -11
  7. package/lib/cjs/BentleyError.js.map +1 -1
  8. package/lib/cjs/ByteStream.d.ts +3 -22
  9. package/lib/cjs/ByteStream.d.ts.map +1 -1
  10. package/lib/cjs/ByteStream.js +7 -21
  11. package/lib/cjs/ByteStream.js.map +1 -1
  12. package/lib/cjs/Compare.d.ts +15 -0
  13. package/lib/cjs/Compare.d.ts.map +1 -1
  14. package/lib/cjs/Compare.js +48 -0
  15. package/lib/cjs/Compare.js.map +1 -1
  16. package/lib/cjs/CompressedId64Set.js +6 -3
  17. package/lib/cjs/CompressedId64Set.js.map +1 -1
  18. package/lib/cjs/Dictionary.js +8 -3
  19. package/lib/cjs/Dictionary.js.map +1 -1
  20. package/lib/cjs/Disposable.d.ts +18 -0
  21. package/lib/cjs/Disposable.d.ts.map +1 -1
  22. package/lib/cjs/Disposable.js +25 -25
  23. package/lib/cjs/Disposable.js.map +1 -1
  24. package/lib/cjs/Id.d.ts +0 -4
  25. package/lib/cjs/Id.d.ts.map +1 -1
  26. package/lib/cjs/Id.js +9 -11
  27. package/lib/cjs/Id.js.map +1 -1
  28. package/lib/cjs/IndexMap.js +6 -1
  29. package/lib/cjs/IndexMap.js.map +1 -1
  30. package/lib/cjs/JsonUtils.d.ts +4 -0
  31. package/lib/cjs/JsonUtils.d.ts.map +1 -1
  32. package/lib/cjs/JsonUtils.js +6 -1
  33. package/lib/cjs/JsonUtils.js.map +1 -1
  34. package/lib/cjs/LRUMap.js +16 -0
  35. package/lib/cjs/LRUMap.js.map +1 -1
  36. package/lib/cjs/Logger.d.ts +26 -3
  37. package/lib/cjs/Logger.d.ts.map +1 -1
  38. package/lib/cjs/Logger.js +33 -9
  39. package/lib/cjs/Logger.js.map +1 -1
  40. package/lib/cjs/ObservableSet.js +6 -6
  41. package/lib/cjs/ObservableSet.js.map +1 -1
  42. package/lib/cjs/OneAtATimeAction.js +9 -0
  43. package/lib/cjs/OneAtATimeAction.js.map +1 -1
  44. package/lib/cjs/OrderedSet.js +1 -0
  45. package/lib/cjs/OrderedSet.js.map +1 -1
  46. package/lib/cjs/PriorityQueue.js +3 -1
  47. package/lib/cjs/PriorityQueue.js.map +1 -1
  48. package/lib/cjs/SortedArray.js +4 -1
  49. package/lib/cjs/SortedArray.js.map +1 -1
  50. package/lib/cjs/StatusCategory.js +42 -105
  51. package/lib/cjs/StatusCategory.js.map +1 -1
  52. package/lib/cjs/Time.js +5 -0
  53. package/lib/cjs/Time.js.map +1 -1
  54. package/lib/cjs/Tracing.js +2 -0
  55. package/lib/cjs/Tracing.js.map +1 -1
  56. package/lib/cjs/TupleKeyedMap.js +2 -2
  57. package/lib/cjs/TupleKeyedMap.js.map +1 -1
  58. package/lib/cjs/TypedArrayBuilder.js +8 -0
  59. package/lib/cjs/TypedArrayBuilder.js.map +1 -1
  60. package/lib/cjs/UnexpectedErrors.js +10 -12
  61. package/lib/cjs/UnexpectedErrors.js.map +1 -1
  62. package/lib/cjs/YieldManager.js +3 -1
  63. package/lib/cjs/YieldManager.js.map +1 -1
  64. package/lib/cjs/internal/cross-package.d.ts +0 -1
  65. package/lib/cjs/internal/cross-package.d.ts.map +1 -1
  66. package/lib/cjs/internal/cross-package.js +1 -3
  67. package/lib/cjs/internal/cross-package.js.map +1 -1
  68. package/lib/esm/BeEvent.js +3 -7
  69. package/lib/esm/BeEvent.js.map +1 -1
  70. package/lib/esm/BentleyError.d.ts +84 -1
  71. package/lib/esm/BentleyError.d.ts.map +1 -1
  72. package/lib/esm/BentleyError.js +71 -10
  73. package/lib/esm/BentleyError.js.map +1 -1
  74. package/lib/esm/ByteStream.d.ts +3 -22
  75. package/lib/esm/ByteStream.d.ts.map +1 -1
  76. package/lib/esm/ByteStream.js +7 -21
  77. package/lib/esm/ByteStream.js.map +1 -1
  78. package/lib/esm/Compare.d.ts +15 -0
  79. package/lib/esm/Compare.d.ts.map +1 -1
  80. package/lib/esm/Compare.js +46 -0
  81. package/lib/esm/Compare.js.map +1 -1
  82. package/lib/esm/CompressedId64Set.js +6 -3
  83. package/lib/esm/CompressedId64Set.js.map +1 -1
  84. package/lib/esm/Dictionary.js +8 -3
  85. package/lib/esm/Dictionary.js.map +1 -1
  86. package/lib/esm/Disposable.d.ts +18 -0
  87. package/lib/esm/Disposable.d.ts.map +1 -1
  88. package/lib/esm/Disposable.js +24 -25
  89. package/lib/esm/Disposable.js.map +1 -1
  90. package/lib/esm/Id.d.ts +0 -4
  91. package/lib/esm/Id.d.ts.map +1 -1
  92. package/lib/esm/Id.js +9 -11
  93. package/lib/esm/Id.js.map +1 -1
  94. package/lib/esm/IndexMap.js +6 -1
  95. package/lib/esm/IndexMap.js.map +1 -1
  96. package/lib/esm/JsonUtils.d.ts +4 -0
  97. package/lib/esm/JsonUtils.d.ts.map +1 -1
  98. package/lib/esm/JsonUtils.js +6 -1
  99. package/lib/esm/JsonUtils.js.map +1 -1
  100. package/lib/esm/LRUMap.js +16 -0
  101. package/lib/esm/LRUMap.js.map +1 -1
  102. package/lib/esm/Logger.d.ts +26 -3
  103. package/lib/esm/Logger.d.ts.map +1 -1
  104. package/lib/esm/Logger.js +33 -9
  105. package/lib/esm/Logger.js.map +1 -1
  106. package/lib/esm/ObservableSet.js +6 -6
  107. package/lib/esm/ObservableSet.js.map +1 -1
  108. package/lib/esm/OneAtATimeAction.js +9 -0
  109. package/lib/esm/OneAtATimeAction.js.map +1 -1
  110. package/lib/esm/OrderedSet.js +1 -0
  111. package/lib/esm/OrderedSet.js.map +1 -1
  112. package/lib/esm/PriorityQueue.js +3 -1
  113. package/lib/esm/PriorityQueue.js.map +1 -1
  114. package/lib/esm/SortedArray.js +4 -1
  115. package/lib/esm/SortedArray.js.map +1 -1
  116. package/lib/esm/StatusCategory.js +42 -105
  117. package/lib/esm/StatusCategory.js.map +1 -1
  118. package/lib/esm/Time.js +5 -0
  119. package/lib/esm/Time.js.map +1 -1
  120. package/lib/esm/Tracing.js +2 -0
  121. package/lib/esm/Tracing.js.map +1 -1
  122. package/lib/esm/TupleKeyedMap.js +2 -2
  123. package/lib/esm/TupleKeyedMap.js.map +1 -1
  124. package/lib/esm/TypedArrayBuilder.js +8 -0
  125. package/lib/esm/TypedArrayBuilder.js.map +1 -1
  126. package/lib/esm/UnexpectedErrors.js +10 -12
  127. package/lib/esm/UnexpectedErrors.js.map +1 -1
  128. package/lib/esm/YieldManager.js +3 -1
  129. package/lib/esm/YieldManager.js.map +1 -1
  130. package/lib/esm/internal/cross-package.d.ts +0 -1
  131. package/lib/esm/internal/cross-package.d.ts.map +1 -1
  132. package/lib/esm/internal/cross-package.js +0 -1
  133. package/lib/esm/internal/cross-package.js.map +1 -1
  134. package/package.json +8 -8
  135. package/lib/cjs/internal/staticLoggerMetadata.d.ts +0 -11
  136. package/lib/cjs/internal/staticLoggerMetadata.d.ts.map +0 -1
  137. package/lib/cjs/internal/staticLoggerMetadata.js +0 -17
  138. package/lib/cjs/internal/staticLoggerMetadata.js.map +0 -1
  139. package/lib/esm/internal/staticLoggerMetadata.d.ts +0 -11
  140. package/lib/esm/internal/staticLoggerMetadata.d.ts.map +0 -1
  141. package/lib/esm/internal/staticLoggerMetadata.js +0 -14
  142. package/lib/esm/internal/staticLoggerMetadata.js.map +0 -1
package/CHANGELOG.md CHANGED
@@ -1,6 +1,79 @@
1
1
  # Change Log - @itwin/core-bentley
2
2
 
3
- This log was last generated on Tue, 05 Nov 2024 15:24:11 GMT and should not be manually modified.
3
+ This log was last generated on Wed, 02 Apr 2025 19:38:36 GMT and should not be manually modified.
4
+
5
+ ## 4.10.12
6
+ Wed, 02 Apr 2025 19:35:47 GMT
7
+
8
+ _Version update only_
9
+
10
+ ## 4.10.11
11
+ Wed, 19 Mar 2025 15:30:39 GMT
12
+
13
+ _Version update only_
14
+
15
+ ## 4.10.10
16
+ Tue, 11 Mar 2025 15:25:11 GMT
17
+
18
+ _Version update only_
19
+
20
+ ## 4.10.9
21
+ Tue, 11 Mar 2025 05:17:33 GMT
22
+
23
+ _Version update only_
24
+
25
+ ## 4.10.8
26
+ Thu, 06 Mar 2025 14:13:37 GMT
27
+
28
+ _Version update only_
29
+
30
+ ## 4.10.7
31
+ Tue, 18 Feb 2025 17:27:03 GMT
32
+
33
+ _Version update only_
34
+
35
+ ## 4.10.6
36
+ Fri, 24 Jan 2025 08:02:40 GMT
37
+
38
+ _Version update only_
39
+
40
+ ## 4.10.5
41
+ Tue, 21 Jan 2025 21:56:45 GMT
42
+
43
+ _Version update only_
44
+
45
+ ## 4.10.4
46
+ Mon, 13 Jan 2025 14:06:43 GMT
47
+
48
+ _Version update only_
49
+
50
+ ## 4.10.3
51
+ Mon, 06 Jan 2025 14:00:13 GMT
52
+
53
+ _Version update only_
54
+
55
+ ## 4.10.2
56
+ Thu, 21 Nov 2024 15:22:20 GMT
57
+
58
+ _Version update only_
59
+
60
+ ## 4.10.1
61
+ Thu, 14 Nov 2024 18:11:00 GMT
62
+
63
+ _Version update only_
64
+
65
+ ## 4.10.0
66
+ Wed, 13 Nov 2024 15:23:38 GMT
67
+
68
+ ### Updates
69
+
70
+ - Add MaybePromise utility type.
71
+ - Add Id64.Uint32Set.equals().
72
+
73
+ ## 4.9.7
74
+ Wed, 06 Nov 2024 19:23:04 GMT
75
+
76
+ _Version update only_
4
77
 
5
78
  ## 4.9.6
6
79
  Tue, 05 Nov 2024 15:22:45 GMT
@@ -16,10 +16,8 @@ const UnexpectedErrors_1 = require("./UnexpectedErrors");
16
16
  * @public
17
17
  */
18
18
  class BeEvent {
19
- constructor() {
20
- this._listeners = [];
21
- this._insideRaiseEvent = false;
22
- }
19
+ _listeners = [];
20
+ _insideRaiseEvent = false;
23
21
  /** The number of listeners currently subscribed to the event. */
24
22
  get numberOfListeners() { return this._listeners.length; }
25
23
  /**
@@ -130,9 +128,7 @@ exports.BeUiEvent = BeUiEvent;
130
128
  * @public
131
129
  */
132
130
  class BeEventList {
133
- constructor() {
134
- this._events = {};
135
- }
131
+ _events = {};
136
132
  /**
137
133
  * Gets the event associated with the specified name, creating the event if it does not already exist.
138
134
  * @param name The name of the event.
@@ -1 +1 @@
1
- {"version":3,"file":"BeEvent.js","sourceRoot":"","sources":["../../src/BeEvent.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yDAAsD;AAatD;;;;;GAKG;AACH,MAAa,OAAO;IAApB;QACU,eAAU,GAAmB,EAAE,CAAC;QAChC,sBAAiB,GAAY,KAAK,CAAC;IAwG7C,CAAC;IAtGC,iEAAiE;IACjE,IAAW,iBAAiB,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjE;;;;;;OAMG;IACI,WAAW,CAAC,QAAW,EAAE,KAAW;QACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACI,OAAO,CAAC,QAAW,EAAE,KAAW;QACrC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC;QACtD,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IAED;;;;;;OAMG;IACI,cAAc,CAAC,QAAW,EAAE,KAAW;QAC5C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,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAY;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IACjC,CAAC;CACF;AAxBD,kCAwBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Events\n */\n\nimport { UnexpectedErrors } from \"./UnexpectedErrors\";\n\n/** A function invoked when a BeEvent is raised.\n * @public\n */\nexport type Listener = (...arg: any[]) => void;\n\ninterface EventContext {\n listener: Listener | undefined;\n scope: any;\n once: boolean;\n}\n\n/**\n * Manages a set of *listeners* for a particular event and notifies them when the event is raised.\n * This class is usually instantiated inside of a container class and\n * exposed as a property for others to *subscribe* via [[BeEvent.addListener]].\n * @public\n */\nexport class BeEvent<T extends Listener> {\n private _listeners: EventContext[] = [];\n private _insideRaiseEvent: boolean = false;\n\n /** The number of listeners currently subscribed to the event. */\n public get numberOfListeners() { return this._listeners.length; }\n\n /**\n * Registers a Listener to be executed whenever this event is raised.\n * @param listener The function to be executed when the event is raised.\n * @param scope An optional object scope to serve as the 'this' pointer when listener is invoked.\n * @returns A function that will remove this event listener.\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\n */\n public addListener(listener: T, scope?: any): () => void {\n this._listeners.push({ listener, scope, once: false });\n return () => this.removeListener(listener, scope);\n }\n\n /**\n * Registers a callback function to be executed *only once* when the event is raised.\n * @param listener The function to be executed once when the event is raised.\n * @param scope An optional object scope to serve as the `this` pointer in which the listener function will execute.\n * @returns A function that will remove this event listener.\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\n */\n public addOnce(listener: T, scope?: any): () => void {\n this._listeners.push({ listener, scope, once: true });\n return () => this.removeListener(listener, scope);\n }\n\n /**\n * Un-register a previously registered listener.\n * @param listener The listener to be unregistered.\n * @param scope The scope that was originally passed to addListener.\n * @returns 'true' if the listener was removed; 'false' if the listener and scope are not registered with the event.\n * @see [[BeEvent.raiseEvent]], [[BeEvent.addListener]]\n */\n public removeListener(listener: T, scope?: any): boolean {\n const listeners = this._listeners;\n\n for (let i = 0; i < listeners.length; ++i) {\n const context = listeners[i];\n if (context.listener === listener && context.scope === scope) {\n if (this._insideRaiseEvent) {\n context.listener = undefined;\n } else {\n listeners.splice(i, 1);\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Raises the event by calling each registered listener with the supplied arguments.\n * @param args This method takes any number of parameters and passes them through to the listeners.\n * @see [[BeEvent.removeListener]], [[BeEvent.addListener]]\n */\n public raiseEvent(...args: Parameters<T>) {\n this._insideRaiseEvent = true;\n\n const listeners = this._listeners;\n const length = listeners.length;\n let dropped = false;\n\n for (let i = 0; i < length; ++i) {\n const context = listeners[i];\n if (!context.listener) {\n dropped = true;\n } else {\n try {\n context.listener.apply(context.scope, args);\n } catch (e) {\n UnexpectedErrors.handle(e);\n }\n if (context.once) {\n context.listener = undefined;\n dropped = true;\n }\n }\n }\n\n // if we had dropped listeners, remove them now\n if (dropped)\n this._listeners = this._listeners.filter((ctx) => ctx.listener !== undefined);\n\n this._insideRaiseEvent = false;\n }\n\n /** Determine whether this BeEvent has a specified listener registered.\n * @param listener The listener to check.\n * @param scope optional scope argument to match call to addListener\n */\n public has(listener: T, scope?: any): boolean {\n for (const ctx of this._listeners) {\n if (ctx.listener === listener && ctx.scope === scope) {\n return true;\n }\n }\n return false;\n }\n\n /** Clear all Listeners from this BeEvent. */\n public clear(): void { this._listeners.length = 0; }\n}\n\n/** Specialization of BeEvent for events that take a single strongly typed argument, primarily used for UI events.\n * @public\n */\nexport class BeUiEvent<TEventArgs> extends BeEvent<(args: TEventArgs) => void> {\n /** Raises event with single strongly typed argument. */\n public emit(args: TEventArgs): void { this.raiseEvent(args); }\n}\n\n/**\n * A list of BeEvent objects, accessible by an event name.\n * This class may be used instead of explicitly declaring each BeEvent as a member of a containing class.\n * @public\n */\nexport class BeEventList<T extends Listener> {\n private _events: { [name: string]: BeEvent<T> | undefined } = {};\n\n /**\n * Gets the event associated with the specified name, creating the event if it does not already exist.\n * @param name The name of the event.\n */\n public get(name: string): BeEvent<T> {\n let event = this._events[name];\n if (event)\n return event;\n\n event = new BeEvent();\n this._events[name] = event;\n return event;\n }\n\n /**\n * Removes the event associated with a name.\n * @param name The name of the event.\n */\n public remove(name: string): void {\n this._events[name] = undefined;\n }\n}\n\n/**\n * Retrieves the type of the callback function for an event type like [[BeEvent]].\n * For example:\n * ```ts\n * const event = new BeEvent<(x: number, y: string) => void>();\n * const callback: ListenerType<typeof event> = (x, y) => {\n * console.log(`${x}, ${y}`);\n * };\n * ```\n *\n * @public\n */\nexport type ListenerType<TEvent extends {\n addListener(listener: Listener): () => void;\n}> =\n TEvent extends {\n addListener(listener: infer TListener): () => void;\n } ? TListener : never;\n"]}
1
+ {"version":3,"file":"BeEvent.js","sourceRoot":"","sources":["../../src/BeEvent.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yDAAsD;AAatD;;;;;GAKG;AACH,MAAa,OAAO;IACV,UAAU,GAAmB,EAAE,CAAC;IAChC,iBAAiB,GAAY,KAAK,CAAC;IAE3C,iEAAiE;IACjE,IAAW,iBAAiB,KAAK,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;IAEjE;;;;;;OAMG;IACI,WAAW,CAAC,QAAW,EAAE,KAAW;QACzC,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,EAAE,QAAQ,EAAE,KAAK,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;QACvD,OAAO,GAAG,EAAE,CAAC,IAAI,CAAC,cAAc,CAAC,QAAQ,EAAE,KAAK,CAAC,CAAC;IACpD,CAAC;IA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IAAI,CAAC,CAAC,CAAC,CAAC;CAC/D;AAHD,8BAGC;AAED;;;;GAIG;AACH,MAAa,WAAW;IACd,OAAO,GAA+C,EAAE,CAAC;IAEjE;;;OAGG;IACI,GAAG,CAAC,IAAY;QACrB,IAAI,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,KAAK;YACP,OAAO,KAAK,CAAC;QAEf,KAAK,GAAG,IAAI,OAAO,EAAE,CAAC;QACtB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,KAAK,CAAC;QAC3B,OAAO,KAAK,CAAC;IACf,CAAC;IAED;;;OAGG;IACI,MAAM,CAAC,IAAY;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,GAAG,SAAS,CAAC;IACjC,CAAC;CACF;AAxBD,kCAwBC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Events\n */\n\nimport { UnexpectedErrors } from \"./UnexpectedErrors\";\n\n/** A function invoked when a BeEvent is raised.\n * @public\n */\nexport type Listener = (...arg: any[]) => void;\n\ninterface EventContext {\n listener: Listener | undefined;\n scope: any;\n once: boolean;\n}\n\n/**\n * Manages a set of *listeners* for a particular event and notifies them when the event is raised.\n * This class is usually instantiated inside of a container class and\n * exposed as a property for others to *subscribe* via [[BeEvent.addListener]].\n * @public\n */\nexport class BeEvent<T extends Listener> {\n private _listeners: EventContext[] = [];\n private _insideRaiseEvent: boolean = false;\n\n /** The number of listeners currently subscribed to the event. */\n public get numberOfListeners() { return this._listeners.length; }\n\n /**\n * Registers a Listener to be executed whenever this event is raised.\n * @param listener The function to be executed when the event is raised.\n * @param scope An optional object scope to serve as the 'this' pointer when listener is invoked.\n * @returns A function that will remove this event listener.\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\n */\n public addListener(listener: T, scope?: any): () => void {\n this._listeners.push({ listener, scope, once: false });\n return () => this.removeListener(listener, scope);\n }\n\n /**\n * Registers a callback function to be executed *only once* when the event is raised.\n * @param listener The function to be executed once when the event is raised.\n * @param scope An optional object scope to serve as the `this` pointer in which the listener function will execute.\n * @returns A function that will remove this event listener.\n * @see [[BeEvent.raiseEvent]], [[BeEvent.removeListener]]\n */\n public addOnce(listener: T, scope?: any): () => void {\n this._listeners.push({ listener, scope, once: true });\n return () => this.removeListener(listener, scope);\n }\n\n /**\n * Un-register a previously registered listener.\n * @param listener The listener to be unregistered.\n * @param scope The scope that was originally passed to addListener.\n * @returns 'true' if the listener was removed; 'false' if the listener and scope are not registered with the event.\n * @see [[BeEvent.raiseEvent]], [[BeEvent.addListener]]\n */\n public removeListener(listener: T, scope?: any): boolean {\n const listeners = this._listeners;\n\n for (let i = 0; i < listeners.length; ++i) {\n const context = listeners[i];\n if (context.listener === listener && context.scope === scope) {\n if (this._insideRaiseEvent) {\n context.listener = undefined;\n } else {\n listeners.splice(i, 1);\n }\n return true;\n }\n }\n return false;\n }\n\n /**\n * Raises the event by calling each registered listener with the supplied arguments.\n * @param args This method takes any number of parameters and passes them through to the listeners.\n * @see [[BeEvent.removeListener]], [[BeEvent.addListener]]\n */\n public raiseEvent(...args: Parameters<T>) {\n this._insideRaiseEvent = true;\n\n const listeners = this._listeners;\n const length = listeners.length;\n let dropped = false;\n\n for (let i = 0; i < length; ++i) {\n const context = listeners[i];\n if (!context.listener) {\n dropped = true;\n } else {\n try {\n context.listener.apply(context.scope, args);\n } catch (e) {\n UnexpectedErrors.handle(e);\n }\n if (context.once) {\n context.listener = undefined;\n dropped = true;\n }\n }\n }\n\n // if we had dropped listeners, remove them now\n if (dropped)\n this._listeners = this._listeners.filter((ctx) => ctx.listener !== undefined);\n\n this._insideRaiseEvent = false;\n }\n\n /** Determine whether this BeEvent has a specified listener registered.\n * @param listener The listener to check.\n * @param scope optional scope argument to match call to addListener\n */\n public has(listener: T, scope?: any): boolean {\n for (const ctx of this._listeners) {\n if (ctx.listener === listener && ctx.scope === scope) {\n return true;\n }\n }\n return false;\n }\n\n /** Clear all Listeners from this BeEvent. */\n public clear(): void { this._listeners.length = 0; }\n}\n\n/** Specialization of BeEvent for events that take a single strongly typed argument, primarily used for UI events.\n * @public\n */\nexport class BeUiEvent<TEventArgs> extends BeEvent<(args: TEventArgs) => void> {\n /** Raises event with single strongly typed argument. */\n public emit(args: TEventArgs): void { this.raiseEvent(args); }\n}\n\n/**\n * A list of BeEvent objects, accessible by an event name.\n * This class may be used instead of explicitly declaring each BeEvent as a member of a containing class.\n * @public\n */\nexport class BeEventList<T extends Listener> {\n private _events: { [name: string]: BeEvent<T> | undefined } = {};\n\n /**\n * Gets the event associated with the specified name, creating the event if it does not already exist.\n * @param name The name of the event.\n */\n public get(name: string): BeEvent<T> {\n let event = this._events[name];\n if (event)\n return event;\n\n event = new BeEvent();\n this._events[name] = event;\n return event;\n }\n\n /**\n * Removes the event associated with a name.\n * @param name The name of the event.\n */\n public remove(name: string): void {\n this._events[name] = undefined;\n }\n}\n\n/**\n * Retrieves the type of the callback function for an event type like [[BeEvent]].\n * For example:\n * ```ts\n * const event = new BeEvent<(x: number, y: string) => void>();\n * const callback: ListenerType<typeof event> = (x, y) => {\n * console.log(`${x}, ${y}`);\n * };\n * ```\n *\n * @public\n */\nexport type ListenerType<TEvent extends {\n addListener(listener: Listener): () => void;\n}> =\n TEvent extends {\n addListener(listener: infer TListener): () => void;\n } ? TListener : never;\n"]}
@@ -1,6 +1,51 @@
1
1
  /** @packageDocumentation
2
2
  * @module Errors
3
3
  */
4
+ import { Optional } from "./UtilityTypes";
5
+ /** Uniquely identifies a specific kind of [[ITwinError]].
6
+ * @beta
7
+ */
8
+ export interface ITwinErrorId {
9
+ /** A "namespace" serving as a qualifier for the [[key]]. It should be specific enough to ensure uniqueness across all applications.
10
+ * For example, all errors originating from a given package should use that package's full name as their scope.
11
+ */
12
+ readonly scope: string;
13
+ /** Uniquely identifies a specific kind of [[ITwinError]] within the [[scope]]. */
14
+ readonly key: string;
15
+ }
16
+ /** The interface that all exceptions thrown by iTwin.js libraries and applications should implement.
17
+ * Specific kinds of `ITwinError`s are identified by an [[ITwinErrorId]] that allows programmers to identify errors when they are caught without relying
18
+ * on specific class hierarchies, which is especially important when errors are marshalled across process boundaries.
19
+ * You can extend `ITwinError` to add properties that provide programmers with additional context for a particular kind of error.
20
+ * When catching errors, programmers can use [[isError]] to determine if the error is of a specific sub-type, and if so access the
21
+ * additional properties.
22
+ * Those additional properties will also be logged as metadata by [[Logger.logException]].
23
+ * @beta
24
+ */
25
+ export interface ITwinError extends Error {
26
+ /** Uniquely identifies the kind of error. */
27
+ readonly iTwinErrorId: ITwinErrorId;
28
+ }
29
+ /** @beta */
30
+ export declare namespace ITwinError {
31
+ /** Instantiate a new `ITwinError` or subtype thereof.
32
+ * @see [[ITwinError.throwError]] to conveniently instantiate and throw the error.
33
+ */
34
+ function create<T extends ITwinError>(args: Optional<T, "name">): T;
35
+ /** Instantiate and immediately throw an `ITwinError`.
36
+ * @see [[ITwinError.create]] to instantiate an error without throwing it.
37
+ */
38
+ function throwError<T extends ITwinError>(args: Optional<T, "name">): never;
39
+ /**
40
+ * Determine whether an error object was thrown by iTwin.js and has a specific scope and key.
41
+ *
42
+ * If the test succeeds, the type of `error` is coerced to `T`
43
+ * @param error The error to ve verified.
44
+ * @param scope value for `error.iTwinErrorId.scope`
45
+ * @param key value for `error.iTwinErrorId.key`
46
+ */
47
+ function isError<T extends ITwinError>(error: unknown, scope: string, key?: string): error is T;
48
+ }
4
49
  /** Standard status code.
5
50
  * This status code should be rarely used.
6
51
  * Prefer to throw an exception to indicate an error, rather than returning a special status code.
@@ -265,6 +310,9 @@ export declare enum GeoServiceStatus {
265
310
  NoDatumConverter = 147459,
266
311
  VerticalDatumConvertError = 147460,
267
312
  CSMapError = 147461,
313
+ /**
314
+ * @deprecated in 5.0. This status is never returned.
315
+ */
268
316
  Pending = 147462
269
317
  }
270
318
  /** Error status from various reality data operations
@@ -290,11 +338,29 @@ interface ErrorProps {
290
338
  stack?: string;
291
339
  metadata?: object;
292
340
  }
293
- /** Base exception class for iTwin.js exceptions.
341
+ /**
342
+ * An [[ITwinError]] that also supplies an `errorNumber`.
343
+ * @note this interface exists *only* for legacy errors derived from `BentleyError`. The concept of "error number" is
344
+ * problematic since it is impossible to enforce across the iTwin.js library, let alone across applications. New code should
345
+ * use `ITwinError` and identify errors with strings instead.
346
+ * @beta */
347
+ export interface LegacyITwinErrorWithNumber extends ITwinError {
348
+ /** a number to identify the error. */
349
+ readonly errorNumber: number;
350
+ /** Logging metadata
351
+ * @note exceptions should *not* include logging data. Logging should be done where exceptions are caught. This member exists
352
+ * only for backwards compatibility.
353
+ */
354
+ loggingMetadata?: object;
355
+ }
356
+ /**
357
+ * Base exception class for legacy iTwin.js errors.
358
+ * For backwards compatibility only. Do not create new subclasses of BentleyError. Instead use [[ITwinError]].
294
359
  * @public
295
360
  */
296
361
  export declare class BentleyError extends Error {
297
362
  errorNumber: number;
363
+ static readonly iTwinErrorScope = "bentley-error";
298
364
  private readonly _metaData;
299
365
  /**
300
366
  * @param errorNumber The a number that identifies of the problem.
@@ -302,6 +368,21 @@ export declare class BentleyError extends Error {
302
368
  * @param metaData metaData about the exception.
303
369
  */
304
370
  constructor(errorNumber: number, message?: string, metaData?: LoggingMetaData);
371
+ /** supply the value for iTwinErrorId */
372
+ get iTwinErrorId(): {
373
+ scope: string;
374
+ key: string;
375
+ };
376
+ /** value for logging metadata */
377
+ get loggingMetadata(): object | undefined;
378
+ /**
379
+ * Determine if an error object implements the `LegacyITwinErrorWithNumber` interface.
380
+ *
381
+ * If the test succeeds, the type of `error` is coerced to `T`
382
+ * @note this method does *not* test that the object is an `instanceOf BentleyError`.
383
+ * @beta
384
+ */
385
+ static isError<T extends LegacyITwinErrorWithNumber>(error: unknown, errorNumber?: number): error is T;
305
386
  /** Returns true if this BentleyError includes (optional) metadata. */
306
387
  get hasMetaData(): boolean;
307
388
  /** get the meta data associated with this BentleyError, if any. */
@@ -310,6 +391,8 @@ export declare class BentleyError extends Error {
310
391
  static getMetaData(metaData: LoggingMetaData): object | undefined;
311
392
  /** This function returns the name of each error status. Override this method to handle more error status codes. */
312
393
  protected _initName(): string;
394
+ /** This function returns the name of each error status. */
395
+ static getErrorKey(errorNumber: number): string;
313
396
  /** Use run-time type checking to safely get a useful string summary of an unknown error value, or `""` if none exists.
314
397
  * @note It's recommended to use this function in `catch` clauses, where a caught value cannot be assumed to be `instanceof Error`
315
398
  * @public
@@ -1 +1 @@
1
- {"version":3,"file":"BentleyError.d.ts","sourceRoot":"","sources":["../../src/BentleyError.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH;;;;;GAKG;AACH,oBAAY,aAAa;IACvB,OAAO,IAAS;IAChB,KAAK,QAAS;CACf;AAED;;;GAGG;AACH,oBAAY,YAAY;IACtB,iBAAiB,QAAU;IAC3B,OAAO,IAAI;IACX,aAAa,QAAwB;IACrC,WAAW,QAAwB;IACnC,MAAM,QAAwB;IAC9B,UAAU,QAAwB;IAClC,QAAQ,QAAwB;IAChC,UAAU,QAAwB;IAClC,SAAS,QAAwB;IACjC,UAAU,QAAwB;IAClC,eAAe,QAAwB;IACvC,kBAAkB,QAAyB;IAC3C,aAAa,QAAyB;IACtC,aAAa,QAAyB;IACtC,oBAAoB,QAAyB;IAC7C,iBAAiB,QAAyB;IAC1C,YAAY,QAAyB;IACrC,aAAa,QAAyB;IACtC,oBAAoB,QAAyB;IAC7C,QAAQ,QAAyB;IACjC,oBAAoB,QAAyB;IAC7C,eAAe,QAAyB;IACxC,WAAW,QAAyB;IACpC,eAAe,QAAyB;IACxC,SAAS,QAAyB;IAClC,WAAW,QAAyB;IACpC,aAAa,QAAyB;IACtC,qBAAqB,QAAyB;IAC9C,mBAAmB,QAAyB;IAC5C,WAAW,QAAyB;IACpC,YAAY,QAAyB;IACrC,WAAW,QAAyB;IACpC,aAAa,QAAyB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ty(exports, "__esModule", { value: true });
10
- exports.BentleyError = exports.RealityDataStatus = exports.GeoServiceStatus = exports.IModelHubStatus = exports.HttpStatus = exports.ChangeSetStatus = exports.RpcInterfaceStatus = exports.BriefcaseStatus = exports.IModelStatus = exports.BentleyStatus = void 0;
10
+ exports.BentleyError = exports.RealityDataStatus = exports.GeoServiceStatus = exports.IModelHubStatus = exports.HttpStatus = exports.ChangeSetStatus = exports.RpcInterfaceStatus = exports.BriefcaseStatus = exports.IModelStatus = exports.BentleyStatus = exports.ITwinError = void 0;
11
11
  const BeSQLite_1 = require("./BeSQLite");
12
12
  const RepositoryStatus_1 = require("./internal/RepositoryStatus");
13
+ const JsonUtils_1 = require("./JsonUtils");
14
+ /** @beta */
15
+ var ITwinError;
16
+ (function (ITwinError) {
17
+ /** Instantiate a new `ITwinError` or subtype thereof.
18
+ * @see [[ITwinError.throwError]] to conveniently instantiate and throw the error.
19
+ */
20
+ function create(args) {
21
+ const err = new Error(args.message);
22
+ Object.assign(err, args);
23
+ err.name = args.iTwinErrorId.key; // helpful because this is used by `toString` for Error class
24
+ return err;
25
+ }
26
+ ITwinError.create = create;
27
+ /** Instantiate and immediately throw an `ITwinError`.
28
+ * @see [[ITwinError.create]] to instantiate an error without throwing it.
29
+ */
30
+ function throwError(args) {
31
+ throw create(args);
32
+ }
33
+ ITwinError.throwError = throwError;
34
+ /**
35
+ * Determine whether an error object was thrown by iTwin.js and has a specific scope and key.
36
+ *
37
+ * If the test succeeds, the type of `error` is coerced to `T`
38
+ * @param error The error to ve verified.
39
+ * @param scope value for `error.iTwinErrorId.scope`
40
+ * @param key value for `error.iTwinErrorId.key`
41
+ */
42
+ function isError(error, scope, key) {
43
+ return JsonUtils_1.JsonUtils.isObject(error) && "iTwinErrorId" in error && JsonUtils_1.JsonUtils.isObject(error.iTwinErrorId)
44
+ && error.iTwinErrorId.scope === scope && (undefined === key || error.iTwinErrorId.key === key);
45
+ }
46
+ ITwinError.isError = isError;
47
+ })(ITwinError || (exports.ITwinError = ITwinError = {}));
13
48
  /** Standard status code.
14
49
  * This status code should be rarely used.
15
50
  * Prefer to throw an exception to indicate an error, rather than returning a special status code.
@@ -285,6 +320,9 @@ var GeoServiceStatus;
285
320
  GeoServiceStatus[GeoServiceStatus["NoDatumConverter"] = 147459] = "NoDatumConverter";
286
321
  GeoServiceStatus[GeoServiceStatus["VerticalDatumConvertError"] = 147460] = "VerticalDatumConvertError";
287
322
  GeoServiceStatus[GeoServiceStatus["CSMapError"] = 147461] = "CSMapError";
323
+ /**
324
+ * @deprecated in 5.0. This status is never returned.
325
+ */
288
326
  GeoServiceStatus[GeoServiceStatus["Pending"] = 147462] = "Pending";
289
327
  })(GeoServiceStatus || (exports.GeoServiceStatus = GeoServiceStatus = {}));
290
328
  /** Error status from various reality data operations
@@ -296,13 +334,15 @@ var RealityDataStatus;
296
334
  RealityDataStatus[RealityDataStatus["REALITYDATA_ERROR_BASE"] = 151552] = "REALITYDATA_ERROR_BASE";
297
335
  RealityDataStatus[RealityDataStatus["InvalidData"] = 151553] = "InvalidData";
298
336
  })(RealityDataStatus || (exports.RealityDataStatus = RealityDataStatus = {}));
299
- function isObject(obj) {
300
- return typeof obj === "object" && obj !== null;
301
- }
302
- /** Base exception class for iTwin.js exceptions.
337
+ /**
338
+ * Base exception class for legacy iTwin.js errors.
339
+ * For backwards compatibility only. Do not create new subclasses of BentleyError. Instead use [[ITwinError]].
303
340
  * @public
304
341
  */
305
342
  class BentleyError extends Error {
343
+ errorNumber;
344
+ static iTwinErrorScope = "bentley-error";
345
+ _metaData;
306
346
  /**
307
347
  * @param errorNumber The a number that identifies of the problem.
308
348
  * @param message message that describes the problem (should not be localized).
@@ -315,6 +355,23 @@ class BentleyError extends Error {
315
355
  this._metaData = metaData;
316
356
  this.name = this._initName();
317
357
  }
358
+ /** supply the value for iTwinErrorId */
359
+ get iTwinErrorId() {
360
+ return { scope: BentleyError.iTwinErrorScope, key: this.name };
361
+ }
362
+ /** value for logging metadata */
363
+ get loggingMetadata() { return this.getMetaData(); }
364
+ /**
365
+ * Determine if an error object implements the `LegacyITwinErrorWithNumber` interface.
366
+ *
367
+ * If the test succeeds, the type of `error` is coerced to `T`
368
+ * @note this method does *not* test that the object is an `instanceOf BentleyError`.
369
+ * @beta
370
+ */
371
+ static isError(error, errorNumber) {
372
+ return ITwinError.isError(error, BentleyError.iTwinErrorScope) &&
373
+ typeof error.errorNumber === "number" && (errorNumber === undefined || error.errorNumber === errorNumber);
374
+ }
318
375
  /** Returns true if this BentleyError includes (optional) metadata. */
319
376
  get hasMetaData() { return undefined !== this._metaData; }
320
377
  /** get the meta data associated with this BentleyError, if any. */
@@ -327,7 +384,11 @@ class BentleyError extends Error {
327
384
  }
328
385
  /** This function returns the name of each error status. Override this method to handle more error status codes. */
329
386
  _initName() {
330
- switch (this.errorNumber) {
387
+ return BentleyError.getErrorKey(this.errorNumber);
388
+ }
389
+ /** This function returns the name of each error status. */
390
+ static getErrorKey(errorNumber) {
391
+ switch (errorNumber) {
331
392
  case IModelStatus.AlreadyLoaded: return "Already Loaded";
332
393
  case IModelStatus.AlreadyOpen: return "Already Open";
333
394
  case IModelStatus.BadArg: return "Bad Arg";
@@ -594,7 +655,7 @@ class BentleyError extends Error {
594
655
  case GeoServiceStatus.NoDatumConverter: return "No datum converter";
595
656
  case GeoServiceStatus.VerticalDatumConvertError: return "Vertical datum convert error";
596
657
  case GeoServiceStatus.CSMapError: return "CSMap error";
597
- case GeoServiceStatus.Pending: return "Pending";
658
+ case GeoServiceStatus.Pending: return "Pending"; // eslint-disable-line @typescript-eslint/no-deprecated
598
659
  case RealityDataStatus.InvalidData: return "Invalid or unknown data";
599
660
  case BeSQLite_1.DbResult.BE_SQLITE_OK:
600
661
  case BeSQLite_1.DbResult.BE_SQLITE_ROW:
@@ -602,7 +663,7 @@ class BentleyError extends Error {
602
663
  case BentleyStatus.SUCCESS:
603
664
  return "Success";
604
665
  default:
605
- return `Error (${this.errorNumber})`;
666
+ return `Error (${errorNumber})`;
606
667
  }
607
668
  }
608
669
  /** Use run-time type checking to safely get a useful string summary of an unknown error value, or `""` if none exists.
@@ -614,7 +675,7 @@ class BentleyError extends Error {
614
675
  return error;
615
676
  if (error instanceof Error)
616
677
  return error.toString();
617
- if (isObject(error)) {
678
+ if (JsonUtils_1.JsonUtils.isObject(error)) {
618
679
  if (typeof error.message === "string")
619
680
  return error.message;
620
681
  if (typeof error.msg === "string")
@@ -630,7 +691,7 @@ class BentleyError extends Error {
630
691
  * @public
631
692
  */
632
693
  static getErrorStack(error) {
633
- if (isObject(error) && typeof error.stack === "string")
694
+ if (JsonUtils_1.JsonUtils.isObject(error) && typeof error.stack === "string")
634
695
  return error.stack;
635
696
  return undefined;
636
697
  }
@@ -640,7 +701,7 @@ class BentleyError extends Error {
640
701
  * @public
641
702
  */
642
703
  static getErrorMetadata(error) {
643
- if (isObject(error) && typeof error.getMetaData === "function") {
704
+ if (JsonUtils_1.JsonUtils.isObject(error) && typeof error.getMetaData === "function") {
644
705
  const metadata = error.getMetaData();
645
706
  if (typeof metadata === "object" && metadata !== null)
646
707
  return metadata;