@itwin/core-bentley 5.0.0-dev.9 → 5.0.0-dev.92
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 +51 -1
- package/lib/cjs/AccessToken.js.map +1 -1
- package/lib/cjs/Assert.js.map +1 -1
- package/lib/cjs/BeEvent.js +3 -7
- package/lib/cjs/BeEvent.js.map +1 -1
- package/lib/cjs/BeSQLite.js.map +1 -1
- package/lib/cjs/BentleyError.d.ts +3 -0
- package/lib/cjs/BentleyError.d.ts.map +1 -1
- package/lib/cjs/BentleyError.js +6 -1
- package/lib/cjs/BentleyError.js.map +1 -1
- package/lib/cjs/BentleyLoggerCategory.js.map +1 -1
- package/lib/cjs/ByteStream.d.ts +3 -22
- package/lib/cjs/ByteStream.d.ts.map +1 -1
- package/lib/cjs/ByteStream.js +7 -21
- package/lib/cjs/ByteStream.js.map +1 -1
- package/lib/cjs/ClassUtils.js.map +1 -1
- package/lib/cjs/Compare.d.ts +15 -0
- package/lib/cjs/Compare.d.ts.map +1 -1
- package/lib/cjs/Compare.js +48 -0
- package/lib/cjs/Compare.js.map +1 -1
- package/lib/cjs/CompressedId64Set.js +6 -3
- package/lib/cjs/CompressedId64Set.js.map +1 -1
- package/lib/cjs/Dictionary.js +8 -3
- package/lib/cjs/Dictionary.js.map +1 -1
- package/lib/cjs/Disposable.d.ts +18 -0
- package/lib/cjs/Disposable.d.ts.map +1 -1
- package/lib/cjs/Disposable.js +25 -25
- package/lib/cjs/Disposable.js.map +1 -1
- package/lib/cjs/Id.d.ts +0 -4
- package/lib/cjs/Id.d.ts.map +1 -1
- package/lib/cjs/Id.js +9 -11
- package/lib/cjs/Id.js.map +1 -1
- package/lib/cjs/IndexMap.js +6 -1
- package/lib/cjs/IndexMap.js.map +1 -1
- package/lib/cjs/JsonSchema.js.map +1 -1
- package/lib/cjs/JsonUtils.js.map +1 -1
- package/lib/cjs/LRUMap.js +16 -0
- package/lib/cjs/LRUMap.js.map +1 -1
- package/lib/cjs/Logger.d.ts +24 -2
- package/lib/cjs/Logger.d.ts.map +1 -1
- package/lib/cjs/Logger.js +26 -7
- package/lib/cjs/Logger.js.map +1 -1
- package/lib/cjs/ObservableSet.js +6 -6
- package/lib/cjs/ObservableSet.js.map +1 -1
- package/lib/cjs/OneAtATimeAction.js +9 -0
- package/lib/cjs/OneAtATimeAction.js.map +1 -1
- package/lib/cjs/OrderedId64Iterable.js.map +1 -1
- package/lib/cjs/OrderedSet.js +1 -0
- package/lib/cjs/OrderedSet.js.map +1 -1
- package/lib/cjs/PriorityQueue.js +3 -1
- package/lib/cjs/PriorityQueue.js.map +1 -1
- package/lib/cjs/ProcessDetector.js.map +1 -1
- package/lib/cjs/SortedArray.js +4 -1
- package/lib/cjs/SortedArray.js.map +1 -1
- package/lib/cjs/StatusCategory.js +42 -105
- package/lib/cjs/StatusCategory.js.map +1 -1
- package/lib/cjs/StringUtils.js.map +1 -1
- package/lib/cjs/Time.js +5 -0
- package/lib/cjs/Time.js.map +1 -1
- package/lib/cjs/Tracing.js +2 -0
- package/lib/cjs/Tracing.js.map +1 -1
- package/lib/cjs/TupleKeyedMap.js +2 -2
- package/lib/cjs/TupleKeyedMap.js.map +1 -1
- package/lib/cjs/TypedArrayBuilder.js +8 -0
- package/lib/cjs/TypedArrayBuilder.js.map +1 -1
- package/lib/cjs/UnexpectedErrors.js +10 -12
- package/lib/cjs/UnexpectedErrors.js.map +1 -1
- package/lib/cjs/UtilityTypes.js.map +1 -1
- package/lib/cjs/YieldManager.js +3 -1
- package/lib/cjs/YieldManager.js.map +1 -1
- package/lib/cjs/core-bentley.js.map +1 -1
- package/lib/cjs/internal/BeSQLiteInternal.js.map +1 -1
- package/lib/cjs/internal/RepositoryStatus.js.map +1 -1
- package/lib/cjs/internal/cross-package.d.ts +0 -1
- package/lib/cjs/internal/cross-package.d.ts.map +1 -1
- package/lib/cjs/internal/cross-package.js +1 -3
- package/lib/cjs/internal/cross-package.js.map +1 -1
- package/lib/cjs/partitionArray.js.map +1 -1
- package/lib/esm/AccessToken.js.map +1 -1
- package/lib/esm/Assert.js.map +1 -1
- package/lib/esm/BeEvent.js +3 -7
- package/lib/esm/BeEvent.js.map +1 -1
- package/lib/esm/BeSQLite.js.map +1 -1
- package/lib/esm/BentleyError.d.ts +3 -0
- package/lib/esm/BentleyError.d.ts.map +1 -1
- package/lib/esm/BentleyError.js +6 -1
- package/lib/esm/BentleyError.js.map +1 -1
- package/lib/esm/BentleyLoggerCategory.js.map +1 -1
- package/lib/esm/ByteStream.d.ts +3 -22
- package/lib/esm/ByteStream.d.ts.map +1 -1
- package/lib/esm/ByteStream.js +7 -21
- package/lib/esm/ByteStream.js.map +1 -1
- package/lib/esm/ClassUtils.js.map +1 -1
- package/lib/esm/Compare.d.ts +15 -0
- package/lib/esm/Compare.d.ts.map +1 -1
- package/lib/esm/Compare.js +46 -0
- package/lib/esm/Compare.js.map +1 -1
- package/lib/esm/CompressedId64Set.js +6 -3
- package/lib/esm/CompressedId64Set.js.map +1 -1
- package/lib/esm/Dictionary.js +8 -3
- package/lib/esm/Dictionary.js.map +1 -1
- package/lib/esm/Disposable.d.ts +18 -0
- package/lib/esm/Disposable.d.ts.map +1 -1
- package/lib/esm/Disposable.js +24 -25
- package/lib/esm/Disposable.js.map +1 -1
- package/lib/esm/Id.d.ts +0 -4
- package/lib/esm/Id.d.ts.map +1 -1
- package/lib/esm/Id.js +9 -11
- package/lib/esm/Id.js.map +1 -1
- package/lib/esm/IndexMap.js +6 -1
- package/lib/esm/IndexMap.js.map +1 -1
- package/lib/esm/JsonSchema.js.map +1 -1
- package/lib/esm/JsonUtils.js.map +1 -1
- package/lib/esm/LRUMap.js +16 -0
- package/lib/esm/LRUMap.js.map +1 -1
- package/lib/esm/Logger.d.ts +24 -2
- package/lib/esm/Logger.d.ts.map +1 -1
- package/lib/esm/Logger.js +26 -7
- package/lib/esm/Logger.js.map +1 -1
- package/lib/esm/ObservableSet.js +6 -6
- package/lib/esm/ObservableSet.js.map +1 -1
- package/lib/esm/OneAtATimeAction.js +9 -0
- package/lib/esm/OneAtATimeAction.js.map +1 -1
- package/lib/esm/OrderedId64Iterable.js.map +1 -1
- package/lib/esm/OrderedSet.js +1 -0
- package/lib/esm/OrderedSet.js.map +1 -1
- package/lib/esm/PriorityQueue.js +3 -1
- package/lib/esm/PriorityQueue.js.map +1 -1
- package/lib/esm/ProcessDetector.js.map +1 -1
- package/lib/esm/SortedArray.js +4 -1
- package/lib/esm/SortedArray.js.map +1 -1
- package/lib/esm/StatusCategory.js +42 -105
- package/lib/esm/StatusCategory.js.map +1 -1
- package/lib/esm/StringUtils.js.map +1 -1
- package/lib/esm/Time.js +5 -0
- package/lib/esm/Time.js.map +1 -1
- package/lib/esm/Tracing.js +2 -0
- package/lib/esm/Tracing.js.map +1 -1
- package/lib/esm/TupleKeyedMap.js +2 -2
- package/lib/esm/TupleKeyedMap.js.map +1 -1
- package/lib/esm/TypedArrayBuilder.js +8 -0
- package/lib/esm/TypedArrayBuilder.js.map +1 -1
- package/lib/esm/UnexpectedErrors.js +10 -12
- package/lib/esm/UnexpectedErrors.js.map +1 -1
- package/lib/esm/UtilityTypes.js.map +1 -1
- package/lib/esm/YieldManager.js +3 -1
- package/lib/esm/YieldManager.js.map +1 -1
- package/lib/esm/core-bentley.js.map +1 -1
- package/lib/esm/internal/BeSQLiteInternal.js.map +1 -1
- package/lib/esm/internal/RepositoryStatus.js.map +1 -1
- package/lib/esm/internal/cross-package.d.ts +0 -1
- package/lib/esm/internal/cross-package.d.ts.map +1 -1
- package/lib/esm/internal/cross-package.js +0 -1
- package/lib/esm/internal/cross-package.js.map +1 -1
- package/lib/esm/partitionArray.js.map +1 -1
- package/package.json +8 -8
- package/lib/cjs/internal/staticLoggerMetadata.d.ts +0 -11
- package/lib/cjs/internal/staticLoggerMetadata.d.ts.map +0 -1
- package/lib/cjs/internal/staticLoggerMetadata.js +0 -17
- package/lib/cjs/internal/staticLoggerMetadata.js.map +0 -1
- package/lib/esm/internal/staticLoggerMetadata.d.ts +0 -11
- package/lib/esm/internal/staticLoggerMetadata.d.ts.map +0 -1
- package/lib/esm/internal/staticLoggerMetadata.js +0 -14
- package/lib/esm/internal/staticLoggerMetadata.js.map +0 -1
package/lib/cjs/Logger.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAA8B,eAAe,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"Logger.d.ts","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACpC,OAAO,EAA8B,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAG7E;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,eAAe,KAAK,IAAI,CAAC;AAEjG;;GAEG;AACH,oBAAY,QAAQ;IAClB,wCAAwC;IACxC,KAAK,IAAA;IACL,8BAA8B;IAC9B,IAAI,IAAA;IACJ,4BAA4B;IAC5B,OAAO,IAAA;IACP,6BAA6B;IAC7B,KAAK,IAAA;IACL,+EAA+E;IAC/E,IAAI,IAAA;CACL;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,QAAQ,EAAE,MAAM,CAAC;IACjB,QAAQ,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,kBAAkB;IACjC,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,cAAc,CAAC,EAAE,sBAAsB,EAAE,CAAC;CAC3C;AAED;;;;;;;;;GASG;AACH,MAAM,WAAW,oBAAoB;IACnC,4EAA4E;IAC5E,GA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AK1F;;;;OAIG;WACW,QAAQ,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe,GAAG,IAAI;CAI5F;AAED;;;;;;;;GAQG;AACH,qBAAa,UAAW,YAAW,UAAU;IAC3C,OAAO,CAAC,MAAM,CAAC,SAAS,CAA2B;IAEnD,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS,CAAC,CAAkB;IACpC,OAAO,CAAC,eAAe,CAAS;gBAEb,SAAS,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,eAAe;IAahE,OAAO,CAAC,UAAU;IAaX,CAAC,MAAM,CAAC,OAAO,CAAC,IAAI,IAAI;IAI/B,uDAAuD;IAChD,OAAO,IAAI,IAAI;CAGvB"}
|
package/lib/cjs/Logger.js
CHANGED
|
@@ -11,7 +11,6 @@ exports.PerfLogger = exports.Logger = exports.LogLevel = void 0;
|
|
|
11
11
|
const BeEvent_1 = require("./BeEvent");
|
|
12
12
|
const BentleyError_1 = require("./BentleyError");
|
|
13
13
|
const BentleyLoggerCategory_1 = require("./BentleyLoggerCategory");
|
|
14
|
-
const staticLoggerMetadata_1 = require("./internal/staticLoggerMetadata");
|
|
15
14
|
/** Use to categorize logging messages by severity.
|
|
16
15
|
* @public
|
|
17
16
|
*/
|
|
@@ -33,6 +32,12 @@ var LogLevel;
|
|
|
33
32
|
* @public
|
|
34
33
|
*/
|
|
35
34
|
class Logger {
|
|
35
|
+
static _logError;
|
|
36
|
+
static _logWarning;
|
|
37
|
+
static _logInfo;
|
|
38
|
+
static _logTrace;
|
|
39
|
+
static _onLogLevelChanged;
|
|
40
|
+
static _staticMetaData = new Map();
|
|
36
41
|
/** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */
|
|
37
42
|
static get onLogLevelChanged() {
|
|
38
43
|
// We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.
|
|
@@ -41,6 +46,7 @@ class Logger {
|
|
|
41
46
|
}
|
|
42
47
|
return Logger._onLogLevelChanged;
|
|
43
48
|
}
|
|
49
|
+
static _categoryFilter = {};
|
|
44
50
|
/** Maps category names to the least severe level at which messages in that category should be displayed,
|
|
45
51
|
* or `undefined` if a minimum has not been defined.
|
|
46
52
|
* @see [[setLevel]] to change the minimum logging level for a category.
|
|
@@ -49,6 +55,7 @@ class Logger {
|
|
|
49
55
|
// NOTE: this property is accessed by native code.
|
|
50
56
|
return this._categoryFilter;
|
|
51
57
|
}
|
|
58
|
+
static _minLevel;
|
|
52
59
|
/** The least severe level at which messages should be displayed by default.
|
|
53
60
|
* @see [[setLevelDefault]] to change this default.
|
|
54
61
|
* @see [[setLevel]] to override this default for specific categories.
|
|
@@ -57,6 +64,14 @@ class Logger {
|
|
|
57
64
|
// NOTE: this property is accessed by native code. */
|
|
58
65
|
return this._minLevel;
|
|
59
66
|
}
|
|
67
|
+
/** Should the call stack be included when an exception is logged? */
|
|
68
|
+
static logExceptionCallstacks = false;
|
|
69
|
+
/** Contains metadata that should be included with every logged message.
|
|
70
|
+
* @beta
|
|
71
|
+
*/
|
|
72
|
+
static get staticMetaData() {
|
|
73
|
+
return this._staticMetaData;
|
|
74
|
+
}
|
|
60
75
|
/** Initialize the logger streams. Should be called at application initialization time. */
|
|
61
76
|
static initialize(logError, logWarning, logInfo, logTrace) {
|
|
62
77
|
Logger._logError = logError;
|
|
@@ -74,7 +89,7 @@ class Logger {
|
|
|
74
89
|
/** merge the supplied metadata with all static metadata into one object */
|
|
75
90
|
static getMetaData(metaData) {
|
|
76
91
|
const metaObj = {};
|
|
77
|
-
for (const meta of
|
|
92
|
+
for (const meta of this._staticMetaData) {
|
|
78
93
|
const val = BentleyError_1.BentleyError.getMetaData(meta[1]);
|
|
79
94
|
if (val)
|
|
80
95
|
Object.assign(metaObj, val);
|
|
@@ -237,9 +252,6 @@ class Logger {
|
|
|
237
252
|
}
|
|
238
253
|
}
|
|
239
254
|
exports.Logger = Logger;
|
|
240
|
-
Logger._categoryFilter = {};
|
|
241
|
-
/** Should the call stack be included when an exception is logged? */
|
|
242
|
-
Logger.logExceptionCallstacks = false;
|
|
243
255
|
/** Simple performance diagnostics utility.
|
|
244
256
|
* It measures the time from construction to disposal. On disposal it logs the routine name along with
|
|
245
257
|
* the duration in milliseconds.
|
|
@@ -250,6 +262,10 @@ Logger.logExceptionCallstacks = false;
|
|
|
250
262
|
* @public
|
|
251
263
|
*/
|
|
252
264
|
class PerfLogger {
|
|
265
|
+
static _severity = LogLevel.Info;
|
|
266
|
+
_operation;
|
|
267
|
+
_metaData;
|
|
268
|
+
_startTimeStamp;
|
|
253
269
|
constructor(operation, metaData) {
|
|
254
270
|
this._operation = operation;
|
|
255
271
|
this._metaData = metaData;
|
|
@@ -271,10 +287,13 @@ class PerfLogger {
|
|
|
271
287
|
};
|
|
272
288
|
});
|
|
273
289
|
}
|
|
274
|
-
dispose() {
|
|
290
|
+
[Symbol.dispose]() {
|
|
275
291
|
this.logMessage();
|
|
276
292
|
}
|
|
293
|
+
/** @deprecated in 5.0 Use [Symbol.dispose] instead. */
|
|
294
|
+
dispose() {
|
|
295
|
+
this[Symbol.dispose]();
|
|
296
|
+
}
|
|
277
297
|
}
|
|
278
298
|
exports.PerfLogger = PerfLogger;
|
|
279
|
-
PerfLogger._severity = LogLevel.Info;
|
|
280
299
|
//# sourceMappingURL=Logger.js.map
|
package/lib/cjs/Logger.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AACpC,iDAA6E;AAC7E,mEAAgE;AAEhE,0EAAuE;AAOvE;;GAEG;AACH,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,wCAAwC;IACxC,yCAAK,CAAA;IACL,8BAA8B;IAC9B,uCAAI,CAAA;IACJ,4BAA4B;IAC5B,6CAAO,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UAAU;QAChB,MAAM,YAAY,GAAW,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;QAClD,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,6CAAqB,CAAC,WAAW,EAAE,UAAU,CAAC,SAAS,CAAC;YAC5E,OAAO;QAET,MAAM,CAAC,OAAO,CAAC,6CAAqB,CAAC,WAAW,EAAE,GAAG,IAAI,CAAC,UAAU,MAAM,EAAE,GAAG,EAAE;YAC/E,MAAM,KAAK,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,2BAAY,CAAC,WAAW,CAAC,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YAC7E,OAAO;gBACL,GAAG,KAAK,EAAE,WAAW,EAAE,YAAY,GAAG,IAAI,CAAC,eAAe,EAAE,2DAA2D;aACxH,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;IAEM,OAAO;QACZ,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;;AAnCH,gCAoCC;AAnCgB,oBAAS,GAAa,QAAQ,CAAC,IAAI,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Logging\r\n */\r\n\r\nimport { BeEvent } from \"./BeEvent\";\r\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\r\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\r\nimport { IDisposable } from \"./Disposable\";\r\nimport { staticLoggerMetadata } from \"./internal/staticLoggerMetadata\";\r\n\r\n/** Defines the *signature* for a log function.\r\n * @public\r\n */\r\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\r\n\r\n/** Use to categorize logging messages by severity.\r\n * @public\r\n */\r\nexport enum LogLevel {\r\n /** Tracing and debugging - low level */\r\n Trace,\r\n /** Information - mid level */\r\n Info,\r\n /** Warnings - high level */\r\n Warning,\r\n /** Errors - highest level */\r\n Error,\r\n /** Higher than any real logging level. This is used to turn a category off. */\r\n None,\r\n}\r\n\r\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\r\n * @public\r\n */\r\nexport interface LoggerCategoryAndLevel {\r\n category: string;\r\n logLevel: string;\r\n}\r\n\r\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\r\n * @public\r\n */\r\nexport interface LoggerLevelsConfig {\r\n defaultLevel?: string;\r\n categoryLevels?: LoggerCategoryAndLevel[];\r\n}\r\n\r\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\r\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\r\n * @public\r\n */\r\nexport class Logger {\r\n protected static _logError: LogFunction | undefined;\r\n protected static _logWarning: LogFunction | undefined;\r\n protected static _logInfo: LogFunction | undefined;\r\n protected static _logTrace: LogFunction | undefined;\r\n\r\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\r\n\r\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\r\n public static get onLogLevelChanged(): BeEvent<() => void> {\r\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\r\n if (undefined === Logger._onLogLevelChanged) {\r\n Logger._onLogLevelChanged = new BeEvent<() => void>();\r\n }\r\n\r\n return Logger._onLogLevelChanged;\r\n }\r\n\r\n private static _categoryFilter: {[categoryName: string]: LogLevel | undefined} = {};\r\n\r\n /** Maps category names to the least severe level at which messages in that category should be displayed,\r\n * or `undefined` if a minimum has not been defined.\r\n * @see [[setLevel]] to change the minimum logging level for a category.\r\n */\r\n public static get categoryFilter(): Readonly<{[categoryName: string]: LogLevel | undefined}> {\r\n // NOTE: this property is accessed by native code.\r\n return this._categoryFilter;\r\n }\r\n\r\n private static _minLevel: LogLevel | undefined;\r\n\r\n /** The least severe level at which messages should be displayed by default.\r\n * @see [[setLevelDefault]] to change this default.\r\n * @see [[setLevel]] to override this default for specific categories.\r\n */\r\n public static get minLevel(): LogLevel | undefined {\r\n // NOTE: this property is accessed by native code. */\r\n return this._minLevel;\r\n }\r\n\r\n /** Should the call stack be included when an exception is logged? */\r\n public static logExceptionCallstacks = false;\r\n\r\n /** Initialize the logger streams. Should be called at application initialization time. */\r\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\r\n Logger._logError = logError;\r\n Logger._logWarning = logWarning;\r\n Logger._logInfo = logInfo;\r\n Logger._logTrace = logTrace;\r\n Logger.turnOffLevelDefault();\r\n Logger.turnOffCategories();\r\n }\r\n\r\n /** Initialize the logger to output to the console. */\r\n public static initializeToConsole(): void {\r\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\r\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\r\n\r\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\r\n }\r\n\r\n /** merge the supplied metadata with all static metadata into one object */\r\n public static getMetaData(metaData?: LoggingMetaData): object {\r\n const metaObj = {};\r\n for (const meta of staticLoggerMetadata) {\r\n const val = BentleyError.getMetaData(meta[1]);\r\n if (val)\r\n Object.assign(metaObj, val);\r\n }\r\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\r\n return metaObj;\r\n }\r\n\r\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\r\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\r\n const metaObj = this.getMetaData(metaData);\r\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\r\n }\r\n\r\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\r\n public static setLevelDefault(minLevel: LogLevel): void {\r\n this._minLevel = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\r\n * specified category should be displayed.\r\n */\r\n public static setLevel(category: string, minLevel: LogLevel) {\r\n Logger._categoryFilter[category] = minLevel;\r\n this.onLogLevelChanged.raiseEvent();\r\n }\r\n\r\n /** Interpret a string as the name of a LogLevel */\r\n public static parseLogLevel(str: string): LogLevel {\r\n switch (str.toUpperCase()) {\r\n case \"EXCEPTION\": return LogLevel.Error;\r\n case \"FATAL\": return LogLevel.Error;\r\n case \"ERROR\": return LogLevel.Error;\r\n case \"WARNING\": return LogLevel.Warning;\r\n case \"INFO\": return LogLevel.Info;\r\n case \"TRACE\": return LogLevel.Trace;\r\n case \"DEBUG\": return LogLevel.Trace;\r\n }\r\n return LogLevel.None;\r\n }\r\n\r\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\r\n public static configureLevels(cfg: LoggerLevelsConfig) {\r\n Logger.validateProps(cfg);\r\n if (cfg.defaultLevel !== undefined) {\r\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\r\n }\r\n if (cfg.categoryLevels !== undefined) {\r\n for (const cl of cfg.categoryLevels) {\r\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\r\n }\r\n }\r\n }\r\n\r\n private static isLogLevel(v: string) {\r\n return LogLevel.hasOwnProperty(v);\r\n }\r\n\r\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\r\n public static validateProps(config: any) {\r\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\r\n for (const prop of Object.keys(config)) {\r\n if (!validProps.includes(prop))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\r\n if (prop === \"defaultLevel\") {\r\n if (!Logger.isLogLevel(config.defaultLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\r\n } else if (prop === \"categoryLevels\") {\r\n const value = config[prop];\r\n if (!Array.isArray(value))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\r\n for (const item of config[prop]) {\r\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\r\n if (!Logger.isLogLevel(item.logLevel))\r\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** Get the minimum logging level for the specified category. */\r\n public static getLevel(category: string): LogLevel | undefined {\r\n // Prefer the level set for this category specifically\r\n const minLevelForThisCategory = Logger.categoryFilter[category];\r\n if (minLevelForThisCategory !== undefined)\r\n return minLevelForThisCategory;\r\n\r\n // Fall back on the level set for the parent of this category.\r\n const parent = category.lastIndexOf(\".\");\r\n if (parent !== -1)\r\n return Logger.getLevel(category.slice(0, parent));\r\n\r\n // Fall back on the default level.\r\n return Logger.minLevel;\r\n }\r\n\r\n /** Turns off the least severe level at which messages should be displayed by default.\r\n * This turns off logging for all messages for which no category minimum level is defined.\r\n */\r\n public static turnOffLevelDefault(): void {\r\n Logger._minLevel = undefined;\r\n }\r\n\r\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\r\n */\r\n public static turnOffCategories(): void {\r\n Logger._categoryFilter = {};\r\n }\r\n\r\n /** Check if messages in the specified category should be displayed at this level of severity. */\r\n public static isEnabled(category: string, level: LogLevel): boolean {\r\n const minLevel = Logger.getLevel(category);\r\n return (minLevel !== undefined) && (level >= minLevel);\r\n }\r\n\r\n /** Log the specified message to the **error** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\r\n Logger._logError(category, message, metaData);\r\n }\r\n\r\n private static getExceptionMessage(err: unknown): string {\r\n if (err === undefined) {\r\n return \"Error: err is undefined.\";\r\n }\r\n if (err === null) {\r\n return \"Error: err is null.\";\r\n }\r\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\r\n return BentleyError.getErrorMessage(err) + stack;\r\n }\r\n\r\n /** Log the specified exception. The special \"ExceptionType\" property will be added as metadata.\r\n * @param category The category of the message.\r\n * @param err The exception object.\r\n * @param log The logger output function to use - defaults to Logger.logError\r\n */\r\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\r\n log(category, Logger.getExceptionMessage(err), () => {\r\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? \"<Unknown>\"};\r\n });\r\n }\r\n\r\n /** Log the specified message to the **warning** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\r\n Logger._logWarning(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **info** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\r\n Logger._logInfo(category, message, metaData);\r\n }\r\n\r\n /** Log the specified message to the **trace** stream.\r\n * @param category The category of the message.\r\n * @param message The message.\r\n * @param metaData Optional data for the message\r\n */\r\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\r\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\r\n Logger._logTrace(category, message, metaData);\r\n }\r\n}\r\n\r\n/** Simple performance diagnostics utility.\r\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\r\n * the duration in milliseconds.\r\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\r\n *\r\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\r\n * Enable those, if you want to capture timings.\r\n * @public\r\n */\r\nexport class PerfLogger implements IDisposable {\r\n private static _severity: LogLevel = LogLevel.Info;\r\n\r\n private _operation: string;\r\n private _metaData?: LoggingMetaData;\r\n private _startTimeStamp: number;\r\n\r\n public constructor(operation: string, metaData?: LoggingMetaData) {\r\n this._operation = operation;\r\n this._metaData = metaData;\r\n\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\r\n this._startTimeStamp = 0;\r\n return;\r\n }\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\r\n this._startTimeStamp = new Date().getTime(); // take timestamp\r\n }\r\n\r\n private logMessage(): void {\r\n const endTimeStamp: number = new Date().getTime();\r\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\r\n return;\r\n\r\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\r\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\r\n return {\r\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\r\n };\r\n });\r\n }\r\n\r\n public dispose(): void {\r\n this.logMessage();\r\n }\r\n}\r\n\r\n"]}
|
|
1
|
+
{"version":3,"file":"Logger.js","sourceRoot":"","sources":["../../src/Logger.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AACpC,iDAA6E;AAC7E,mEAAgE;AAOhE;;GAEG;AACH,IAAY,QAWX;AAXD,WAAY,QAAQ;IAClB,wCAAwC;IACxC,yCAAK,CAAA;IACL,8BAA8B;IAC9B,u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,EAAE,CAAC;IACzB,CAAC;;AAxCH,gCAyCC","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 Logging\n */\n\nimport { BeEvent } from \"./BeEvent\";\nimport { BentleyError, IModelStatus, LoggingMetaData } from \"./BentleyError\";\nimport { BentleyLoggerCategory } from \"./BentleyLoggerCategory\";\n\n/** Defines the *signature* for a log function.\n * @public\n */\nexport type LogFunction = (category: string, message: string, metaData: LoggingMetaData) => void;\n\n/** Use to categorize logging messages by severity.\n * @public\n */\nexport enum LogLevel {\n /** Tracing and debugging - low level */\n Trace,\n /** Information - mid level */\n Info,\n /** Warnings - high level */\n Warning,\n /** Errors - highest level */\n Error,\n /** Higher than any real logging level. This is used to turn a category off. */\n None,\n}\n\n/** Identifies a logging category and the LogLevel that should be used for it. The LogLevel is specified by its string name.\n * @public\n */\nexport interface LoggerCategoryAndLevel {\n category: string;\n logLevel: string;\n}\n\n/** Specifies logging levels, including the default logging level and a set of categories and levels for them.\n * @public\n */\nexport interface LoggerLevelsConfig {\n defaultLevel?: string;\n categoryLevels?: LoggerCategoryAndLevel[];\n}\n\n/** A global set of metadata that should be included with every log message.\n * You can provide an object representing the metadata, or a function to be invoked to obtain the metadata object each\n * time a message is logged.\n * Each key-value pair of the object will be stringified and combined with the log message's per-call metadata.\n * The keys you provide to each method is used solely to identify your entries so that you can later update or delete them - these keys\n * are **not** included in log messages. Don't modify or remove metadata associated with keys that belong to someone else.\n * @note Each extra bit of metadata adds cost and overhead to the logging system. Avoid adding unnecessary or unnecessarily verbose metadata.\n * @see [[Logger.staticMetaData]] to access the global metadata.\n * @beta\n */\nexport interface StaticLoggerMetaData {\n /** Add or update some metadata to be included with every logged message. */\n set(key: string, metadata: LoggingMetaData): void;\n /** Remove metadata previously [[set]] using the specified `key`, so it will no longer be included with every logged message. */\n delete(key: string): void;\n}\n\n/** Logger allows libraries and apps to report potentially useful information about operations, and it allows apps and users to control\n * how or if the logged information is displayed or collected. See [Learning about Logging]($docs/learning/common/Logging.md).\n * @public\n */\nexport class Logger {\n protected static _logError: LogFunction | undefined;\n protected static _logWarning: LogFunction | undefined;\n protected static _logInfo: LogFunction | undefined;\n protected static _logTrace: LogFunction | undefined;\n\n private static _onLogLevelChanged: BeEvent<() => void> | undefined;\n private static _staticMetaData = new Map<string, LoggingMetaData>();\n\n /** An event raised whenever [[setLevel]] or [[setLevelDefault]] is called. */\n public static get onLogLevelChanged(): BeEvent<() => void> {\n // We have to lazily initialize because it's static and BeEvent imports UnexpectedErrors which imports Logger which wants to instantiate BeEvent.\n if (undefined === Logger._onLogLevelChanged) {\n Logger._onLogLevelChanged = new BeEvent<() => void>();\n }\n\n return Logger._onLogLevelChanged;\n }\n\n private static _categoryFilter: { [categoryName: string]: LogLevel | undefined } = {};\n\n /** Maps category names to the least severe level at which messages in that category should be displayed,\n * or `undefined` if a minimum has not been defined.\n * @see [[setLevel]] to change the minimum logging level for a category.\n */\n public static get categoryFilter(): Readonly<{ [categoryName: string]: LogLevel | undefined }> {\n // NOTE: this property is accessed by native code.\n return this._categoryFilter;\n }\n\n private static _minLevel: LogLevel | undefined;\n\n /** The least severe level at which messages should be displayed by default.\n * @see [[setLevelDefault]] to change this default.\n * @see [[setLevel]] to override this default for specific categories.\n */\n public static get minLevel(): LogLevel | undefined {\n // NOTE: this property is accessed by native code. */\n return this._minLevel;\n }\n\n /** Should the call stack be included when an exception is logged? */\n public static logExceptionCallstacks = false;\n\n /** Contains metadata that should be included with every logged message.\n * @beta\n */\n public static get staticMetaData(): StaticLoggerMetaData {\n return this._staticMetaData;\n }\n\n /** Initialize the logger streams. Should be called at application initialization time. */\n public static initialize(logError?: LogFunction, logWarning?: LogFunction, logInfo?: LogFunction, logTrace?: LogFunction): void {\n Logger._logError = logError;\n Logger._logWarning = logWarning;\n Logger._logInfo = logInfo;\n Logger._logTrace = logTrace;\n Logger.turnOffLevelDefault();\n Logger.turnOffCategories();\n }\n\n /** Initialize the logger to output to the console. */\n public static initializeToConsole(): void {\n const logConsole = (level: string) => (category: string, message: string, metaData: LoggingMetaData) =>\n console.log(`${level} | ${category} | ${message} ${Logger.stringifyMetaData(metaData)}`); // eslint-disable-line no-console\n\n Logger.initialize(logConsole(\"Error\"), logConsole(\"Warning\"), logConsole(\"Info\"), logConsole(\"Trace\"));\n }\n\n /** merge the supplied metadata with all static metadata into one object */\n public static getMetaData(metaData?: LoggingMetaData): object {\n const metaObj = {};\n for (const meta of this._staticMetaData) {\n const val = BentleyError.getMetaData(meta[1]);\n if (val)\n Object.assign(metaObj, val);\n }\n Object.assign(metaObj, BentleyError.getMetaData(metaData)); // do this last so user supplied values take precedence\n return metaObj;\n }\n\n /** stringify the metadata for a log message by merging the supplied metadata with all static metadata into one object that is then `JSON.stringify`ed. */\n public static stringifyMetaData(metaData?: LoggingMetaData): string {\n const metaObj = this.getMetaData(metaData);\n return Object.keys(metaObj).length > 0 ? JSON.stringify(metaObj) : \"\";\n }\n\n /** Set the least severe level at which messages should be displayed by default. Call setLevel to override this default setting for specific categories. */\n public static setLevelDefault(minLevel: LogLevel): void {\n this._minLevel = minLevel;\n this.onLogLevelChanged.raiseEvent();\n }\n\n /** Set the minimum logging level for the specified category. The minimum level is least severe level at which messages in the\n * specified category should be displayed.\n */\n public static setLevel(category: string, minLevel: LogLevel) {\n Logger._categoryFilter[category] = minLevel;\n this.onLogLevelChanged.raiseEvent();\n }\n\n /** Interpret a string as the name of a LogLevel */\n public static parseLogLevel(str: string): LogLevel {\n switch (str.toUpperCase()) {\n case \"EXCEPTION\": return LogLevel.Error;\n case \"FATAL\": return LogLevel.Error;\n case \"ERROR\": return LogLevel.Error;\n case \"WARNING\": return LogLevel.Warning;\n case \"INFO\": return LogLevel.Info;\n case \"TRACE\": return LogLevel.Trace;\n case \"DEBUG\": return LogLevel.Trace;\n }\n return LogLevel.None;\n }\n\n /** Set the log level for multiple categories at once. Also see [[validateProps]] */\n public static configureLevels(cfg: LoggerLevelsConfig) {\n Logger.validateProps(cfg);\n if (cfg.defaultLevel !== undefined) {\n this.setLevelDefault(Logger.parseLogLevel(cfg.defaultLevel));\n }\n if (cfg.categoryLevels !== undefined) {\n for (const cl of cfg.categoryLevels) {\n this.setLevel(cl.category, Logger.parseLogLevel(cl.logLevel));\n }\n }\n }\n\n private static isLogLevel(v: string) {\n return LogLevel.hasOwnProperty(v);\n }\n\n /** Check that the specified object is a valid LoggerLevelsConfig. This is useful when reading a config from a .json file. */\n public static validateProps(config: any) {\n const validProps = [\"defaultLevel\", \"categoryLevels\"];\n for (const prop of Object.keys(config)) {\n if (!validProps.includes(prop))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig - unrecognized property: ${prop}`);\n if (prop === \"defaultLevel\") {\n if (!Logger.isLogLevel(config.defaultLevel))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.defaultLevel must be a LogLevel. Invalid value: ${JSON.stringify(config.defaultLevel)}`);\n } else if (prop === \"categoryLevels\") {\n const value = config[prop];\n if (!Array.isArray(value))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels must be an array. Invalid value: ${JSON.stringify(value)}`);\n for (const item of config[prop]) {\n if (!item.hasOwnProperty(\"category\") || !item.hasOwnProperty(\"logLevel\"))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item must be a LoggerCategoryAndLevel {category: logLevel:}. Invalid value: ${JSON.stringify(item)}`);\n if (!Logger.isLogLevel(item.logLevel))\n throw new BentleyError(IModelStatus.BadArg, `LoggerLevelsConfig.categoryLevels - each item's logLevel property must be a LogLevel. Invalid value: ${JSON.stringify(item.logLevel)}`);\n }\n }\n }\n }\n\n /** Get the minimum logging level for the specified category. */\n public static getLevel(category: string): LogLevel | undefined {\n // Prefer the level set for this category specifically\n const minLevelForThisCategory = Logger.categoryFilter[category];\n if (minLevelForThisCategory !== undefined)\n return minLevelForThisCategory;\n\n // Fall back on the level set for the parent of this category.\n const parent = category.lastIndexOf(\".\");\n if (parent !== -1)\n return Logger.getLevel(category.slice(0, parent));\n\n // Fall back on the default level.\n return Logger.minLevel;\n }\n\n /** Turns off the least severe level at which messages should be displayed by default.\n * This turns off logging for all messages for which no category minimum level is defined.\n */\n public static turnOffLevelDefault(): void {\n Logger._minLevel = undefined;\n }\n\n /** Turns off all category level filters previously defined with [[Logger.setLevel]].\n */\n public static turnOffCategories(): void {\n Logger._categoryFilter = {};\n }\n\n /** Check if messages in the specified category should be displayed at this level of severity. */\n public static isEnabled(category: string, level: LogLevel): boolean {\n const minLevel = Logger.getLevel(category);\n return (minLevel !== undefined) && (level >= minLevel);\n }\n\n /** Log the specified message to the **error** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logError(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logError && Logger.isEnabled(category, LogLevel.Error))\n Logger._logError(category, message, metaData);\n }\n\n private static getExceptionMessage(err: unknown): string {\n if (err === undefined) {\n return \"Error: err is undefined.\";\n }\n if (err === null) {\n return \"Error: err is null.\";\n }\n const stack = Logger.logExceptionCallstacks ? `\\n${BentleyError.getErrorStack(err)}` : \"\";\n return BentleyError.getErrorMessage(err) + stack;\n }\n\n /** Log the specified exception. The special \"ExceptionType\" property will be added as metadata.\n * @param category The category of the message.\n * @param err The exception object.\n * @param log The logger output function to use - defaults to Logger.logError\n */\n public static logException(category: string, err: any, log: LogFunction = (_category, message, metaData) => Logger.logError(_category, message, metaData)): void {\n log(category, Logger.getExceptionMessage(err), () => {\n return { ...BentleyError.getErrorMetadata(err), exceptionType: err?.constructor?.name ?? \"<Unknown>\" };\n });\n }\n\n /** Log the specified message to the **warning** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logWarning(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logWarning && Logger.isEnabled(category, LogLevel.Warning))\n Logger._logWarning(category, message, metaData);\n }\n\n /** Log the specified message to the **info** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logInfo(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logInfo && Logger.isEnabled(category, LogLevel.Info))\n Logger._logInfo(category, message, metaData);\n }\n\n /** Log the specified message to the **trace** stream.\n * @param category The category of the message.\n * @param message The message.\n * @param metaData Optional data for the message\n */\n public static logTrace(category: string, message: string, metaData?: LoggingMetaData): void {\n if (Logger._logTrace && Logger.isEnabled(category, LogLevel.Trace))\n Logger._logTrace(category, message, metaData);\n }\n}\n\n/** Simple performance diagnostics utility.\n * It measures the time from construction to disposal. On disposal it logs the routine name along with\n * the duration in milliseconds.\n * It also logs the routine name at construction time so that nested calls can be disambiguated.\n *\n * The timings are logged using the log category **Performance** and log severity [[LogLevel.INFO]].\n * Enable those, if you want to capture timings.\n * @public\n */\nexport class PerfLogger implements Disposable {\n private static _severity: LogLevel = LogLevel.Info;\n\n private _operation: string;\n private _metaData?: LoggingMetaData;\n private _startTimeStamp: number;\n\n public constructor(operation: string, metaData?: LoggingMetaData) {\n this._operation = operation;\n this._metaData = metaData;\n\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity)) {\n this._startTimeStamp = 0;\n return;\n }\n\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},START`, this._metaData);\n this._startTimeStamp = new Date().getTime(); // take timestamp\n }\n\n private logMessage(): void {\n const endTimeStamp: number = new Date().getTime();\n if (!Logger.isEnabled(BentleyLoggerCategory.Performance, PerfLogger._severity))\n return;\n\n Logger.logInfo(BentleyLoggerCategory.Performance, `${this._operation},END`, () => {\n const mdata = this._metaData ? BentleyError.getMetaData(this._metaData) : {};\n return {\n ...mdata, TimeElapsed: endTimeStamp - this._startTimeStamp, // eslint-disable-line @typescript-eslint/naming-convention\n };\n });\n }\n\n public [Symbol.dispose](): void {\n this.logMessage();\n }\n\n /** @deprecated in 5.0 Use [Symbol.dispose] instead. */\n public dispose(): void {\n this[Symbol.dispose]();\n }\n}\n\n"]}
|
package/lib/cjs/ObservableSet.js
CHANGED
|
@@ -13,18 +13,18 @@ const BeEvent_1 = require("./BeEvent");
|
|
|
13
13
|
* @public
|
|
14
14
|
*/
|
|
15
15
|
class ObservableSet extends Set {
|
|
16
|
+
/** Emitted after `item` is added to this set. */
|
|
17
|
+
onAdded = new BeEvent_1.BeEvent();
|
|
18
|
+
/** Emitted after `item` is deleted from this set. */
|
|
19
|
+
onDeleted = new BeEvent_1.BeEvent();
|
|
20
|
+
/** Emitted after this set's contents are cleared. */
|
|
21
|
+
onCleared = new BeEvent_1.BeEvent();
|
|
16
22
|
/** Construct a new ObservableSet.
|
|
17
23
|
* @param elements Optional elements with which to populate the new set.
|
|
18
24
|
*/
|
|
19
25
|
constructor(elements) {
|
|
20
26
|
// NB: Set constructor will invoke add(). Do not override until initialized.
|
|
21
27
|
super(elements);
|
|
22
|
-
/** Emitted after `item` is added to this set. */
|
|
23
|
-
this.onAdded = new BeEvent_1.BeEvent();
|
|
24
|
-
/** Emitted after `item` is deleted from this set. */
|
|
25
|
-
this.onDeleted = new BeEvent_1.BeEvent();
|
|
26
|
-
/** Emitted after this set's contents are cleared. */
|
|
27
|
-
this.onCleared = new BeEvent_1.BeEvent();
|
|
28
28
|
this.add = (item) => {
|
|
29
29
|
const prevSize = this.size;
|
|
30
30
|
const ret = super.add(item);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AAEpC;;GAEG;AACH,MAAa,aAAiB,SAAQ,GAAM;
|
|
1
|
+
{"version":3,"file":"ObservableSet.js","sourceRoot":"","sources":["../../src/ObservableSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,uCAAoC;AAEpC;;GAEG;AACH,MAAa,aAAiB,SAAQ,GAAM;IAC1C,iDAAiD;IACjC,OAAO,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC3D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,EAAqB,CAAC;IAC7D,qDAAqD;IACrC,SAAS,GAAG,IAAI,iBAAO,EAAc,CAAC;IAEtD;;OAEG;IACH,YAAmB,QAAkC;QACnD,4EAA4E;QAC5E,KAAK,CAAC,QAAQ,CAAC,CAAC;QAEhB,IAAI,CAAC,GAAG,GAAG,CAAC,IAAO,EAAE,EAAE;YACrB,MAAM,QAAQ,GAAG,IAAI,CAAC,IAAI,CAAC;YAC3B,MAAM,GAAG,GAAG,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;YAC5B,IAAI,IAAI,CAAC,IAAI,KAAK,QAAQ;gBACxB,IAAI,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;YAEhC,OAAO,GAAG,CAAC;QACb,CAAC,CAAC;IACJ,CAAC;IAED;;OAEG;IACa,MAAM,CAAC,IAAO;QAC5B,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC/B,IAAI,GAAG;YACL,IAAI,CAAC,SAAS,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAElC,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;OAEG;IACa,KAAK;QACnB,IAAI,CAAC,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;YACpB,KAAK,CAAC,KAAK,EAAE,CAAC;YACd,IAAI,CAAC,SAAS,CAAC,UAAU,EAAE,CAAC;QAC9B,CAAC;IACH,CAAC;CACF;AA7CD,sCA6CC","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 Collections\n */\n\nimport { BeEvent } from \"./BeEvent\";\n\n/** A standard [Set<T>](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set) that emits events when its contents change.\n * @public\n */\nexport class ObservableSet<T> extends Set<T> {\n /** Emitted after `item` is added to this set. */\n public readonly onAdded = new BeEvent<(item: T) => void>();\n /** Emitted after `item` is deleted from this set. */\n public readonly onDeleted = new BeEvent<(item: T) => void>();\n /** Emitted after this set's contents are cleared. */\n public readonly onCleared = new BeEvent<() => void>();\n\n /** Construct a new ObservableSet.\n * @param elements Optional elements with which to populate the new set.\n */\n public constructor(elements?: Iterable<T> | undefined) {\n // NB: Set constructor will invoke add(). Do not override until initialized.\n super(elements);\n\n this.add = (item: T) => {\n const prevSize = this.size;\n const ret = super.add(item);\n if (this.size !== prevSize)\n this.onAdded.raiseEvent(item);\n\n return ret;\n };\n }\n\n /** Invokes [Set.delete](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/delete), raising\n * the [[onDeleted]] event if the item was removed from the set.\n */\n public override delete(item: T): boolean {\n const ret = super.delete(item);\n if (ret)\n this.onDeleted.raiseEvent(item);\n\n return ret;\n }\n\n /** If this set is not already empty, invokes [Set.clear](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Set/clear)\n * and raises the [[onCleared]] event.\n */\n public override clear(): void {\n if (0 !== this.size) {\n super.clear();\n this.onCleared.raiseEvent();\n }\n }\n}\n"]}
|
|
@@ -20,6 +20,11 @@ exports.AbandonedError = AbandonedError;
|
|
|
20
20
|
* Promises involved that are chained together. That makes this class less efficient than just using a Promise directly.
|
|
21
21
|
*/
|
|
22
22
|
class PromiseWithAbandon {
|
|
23
|
+
_run;
|
|
24
|
+
_args;
|
|
25
|
+
/** Method to abandon the Promise created by [[init]] while it is outstanding. The promise will be rejected. */
|
|
26
|
+
abandon;
|
|
27
|
+
_resolve;
|
|
23
28
|
/** Create a PromiseWithAbandon. After this call you must call [[init]] to create the underlying Promise.
|
|
24
29
|
* @param _run The method that creates the underlying Promise.
|
|
25
30
|
* @param _args An array of args to be passed to run when [[start]] is called.
|
|
@@ -57,6 +62,10 @@ class PromiseWithAbandon {
|
|
|
57
62
|
* @beta
|
|
58
63
|
*/
|
|
59
64
|
class OneAtATimeAction {
|
|
65
|
+
_active;
|
|
66
|
+
_pending;
|
|
67
|
+
_run;
|
|
68
|
+
msg;
|
|
60
69
|
/** Ctor for OneAtATimePromise.
|
|
61
70
|
* @param run The method that performs an action that creates the Promise.
|
|
62
71
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OneAtATimeAction.js","sourceRoot":"","sources":["../../src/OneAtATimeAction.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iDAA8C;AAE9C,YAAY;AACZ,MAAa,cAAe,SAAQ,KAAK;CAAI;AAA7C,wCAA6C;AAE7C;;;;;GAKG;AACH,MAAM,kBAAkB;
|
|
1
|
+
{"version":3,"file":"OneAtATimeAction.js","sourceRoot":"","sources":["../../src/OneAtATimeAction.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,iDAA8C;AAE9C,YAAY;AACZ,MAAa,cAAe,SAAQ,KAAK;CAAI;AAA7C,wCAA6C;AAE7C;;;;;GAKG;AACH,MAAM,kBAAkB;IASF;IAA8C;IARlE,+GAA+G;IACxG,OAAO,CAA0B;IAChC,QAAQ,CAAsB;IAEtC;;;OAGG;IACH,YAAoB,IAAoC,EAAU,KAAY;QAA1D,SAAI,GAAJ,IAAI,CAAgC;QAAU,UAAK,GAAL,KAAK,CAAO;IAAI,CAAC;IAEnF,0GAA0G;IACnG,KAAK,CAAC,IAAI,CAAC,GAAW;QAC3B,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACxC,IAAI,CAAC,OAAO,GAAG,CAAC,OAAgB,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,cAAc,CAAC,OAAO,IAA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AAC,CAAC,uCAAuC;YAC7D,KAAK,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;QAC/E,CAAC;QAED,IAAI,CAAC;YACH,OAAO,MAAM,OAAO,CAAC;QACvB,CAAC;gBAAS,CAAC;YACT,2DAA2D;YAC3D,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,QAAQ,CAAC,CAAC,2CAA2C;YACzE,IAAI,CAAC,QAAQ,GAAG,SAAS,CAAC,CAAC,gBAAgB;YAC3C,IAAI,IAAI,CAAC,OAAO;gBACd,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,CAAC,CAAC,8DAA8D;QACxF,CAAC;IACH,CAAC;CACF;AAxCD,4CAwCC","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 Utils\n */\n\nimport { BentleyError } from \"./BentleyError\";\n\n/** @beta */\nexport class AbandonedError extends Error { }\n\n/**\n * An object that returns a Promise when you call [[init]], but supplies a way to abandon the promise if it is no longer relevant.\n * When you call abandon, the promise will be rejected. You must supply a [[run]] method to the constructor that\n * creates the real Promise for the underlying action. Notice that to use this class there are really two\n * Promises involved that are chained together. That makes this class less efficient than just using a Promise directly.\n */\nclass PromiseWithAbandon<T> {\n /** Method to abandon the Promise created by [[init]] while it is outstanding. The promise will be rejected. */\n public abandon!: (msg?: string) => void;\n private _resolve!: (val: any) => void;\n\n /** Create a PromiseWithAbandon. After this call you must call [[init]] to create the underlying Promise.\n * @param _run The method that creates the underlying Promise.\n * @param _args An array of args to be passed to run when [[start]] is called.\n */\n constructor(private _run: (...args: any[]) => Promise<T>, private _args: any[]) { }\n\n /** Create a Promise that is chained to the underlying Promise, but is connected to the abandon method. */\n public async init(msg: string): Promise<T> {\n return new Promise<T>((resolve, reject) => {\n this.abandon = (message?: string) => reject(new AbandonedError(message ?? msg));\n this._resolve = resolve;\n });\n }\n\n /** Call the [[run]] method supplied to the ctor to start the underlying Promise. */\n public async start() {\n try {\n this._resolve(await this._run(...this._args));\n } catch (err) {\n this.abandon(BentleyError.getErrorMessage(err)); // turn all errors from execution into abandoned errors, but keep the message\n }\n }\n}\n\n/**\n * Orchestrator of a one-at-a-time activity. This concept is useful only for *replaceable* operations (that is, operations where subsequent requests replace and obviate\n * the need for previous requests. E.g. over slow HTTP connections, without this class, the stream of requests can overwhelm the connection, and cause the HTTP\n * request queue to grow such that the delay to service new requests is unbounded.\n *\n * With this class, we issue the initial request immediately. When the second request arrives before the first one completes, it becomes *pending*. If subsequent\n * requests arrive with a pending request, the current pending request is *abandoned* (its Promise is rejected) and the new request becomes pending.\n * When the active request completes, the pending request (if present) is started. In this manner there will only ever be one outstanding HTTP request for this type\n * of operation, but the first and last request will always eventually complete.\n * @beta\n */\nexport class OneAtATimeAction<T> {\n private _active?: PromiseWithAbandon<T>;\n private _pending?: PromiseWithAbandon<T>;\n private _run: (...args: any[]) => Promise<T>;\n public msg: string;\n\n /** Ctor for OneAtATimePromise.\n * @param run The method that performs an action that creates the Promise.\n */\n constructor(run: (...args: any[]) => Promise<T>, msg = \"abandoned\") {\n this._run = run;\n this.msg = msg;\n }\n\n /** Add a new request to this OneAtATimePromise. The request will only run when no other outstanding requests are active.\n * @note Callers of this method *must* handle AbandonedError rejections.\n */\n public async request(...args: any[]): Promise<T> {\n const entry = new PromiseWithAbandon<T>(this._run, args); // create an \"abandon-able promise\" object\n const promise = entry.init(this.msg); // create the Promise from PromiseWithAbandon. Note: this must be called before we call start.\n\n if (this._active !== undefined) { // is there an active request?\n if (this._pending) // yes. If there is also a pending request, this one replaces it and previous one is abandoned\n this._pending.abandon(); // rejects previous call to this method, throwing AbandonedError.\n this._pending = entry;\n } else {\n this._active = entry; // this is the first request, start it.\n entry.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n\n try {\n return await promise;\n } finally {\n // do all of this whether promise was fulfilled or rejected\n this._active = this._pending; // see if there's a pending request waiting\n this._pending = undefined; // clear pending\n if (this._active)\n this._active.start(); // eslint-disable-line @typescript-eslint/no-floating-promises\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderedId64Iterable.js","sourceRoot":"","sources":["../../src/OrderedId64Iterable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAkC;AAOlC;;;;;;;GAOG;AACH,IAAiB,mBAAmB,CAwOnC;AAxOD,WAAiB,mBAAmB;IAClC;;;;;;OAMG;IACH,SAAgB,OAAO,CAAC,GAAe,EAAE,GAAe;QACtD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;YAC3B,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,+GAA+G;QAC/G,0BAA0B;QAC1B,IAAI,GAAG,KAAK,GAAG;YACb,OAAO,GAAG,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE5B,OAAO,CAAC,CAAC;IACX,CAAC;IAVe,2BAAO,UAUtB,CAAA;IAED;;;;;;OAMG;IACH,SAAgB,SAAS,CAAC,GAAc;QACtC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QAClC,OAAO,GAAG,CAAC;IACb,CAAC;IAHe,6BAAS,YAGxB,CAAA;IAED;;OAEG;IACH,SAAgB,YAAY,CAAC,IAAyB,EAAE,IAAyB;QAC/E,MAAM,QAAQ,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QACtC,MAAM,SAAS,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;QACvC,IAAI,SAAS,GAAG,QAAQ,CAAC,IAAI,EAAE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,CAAC;QACtB,CAAC;IACH,CAAC;IAjCgB,sCAAkB,qBAiClC,CAAA;AACH,CAAC,EAxOgB,mBAAmB,mCAAnB,mBAAmB,QAwOnC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Ids\r\n */\r\n\r\nimport { assert } from \"./Assert\";\r\nimport { CompressedId64Set } from \"./CompressedId64Set\";\r\nimport { Id64Array, Id64String } from \"./Id\";\r\n\r\n/** @public */\r\nexport type OrderedId64Iterable = Iterable<Id64String>;\r\n\r\n/** A collection of **valid** [[Id64String]]s sorted in ascending order by the unsigned 64-bit integer value of the Ids.\r\n * This ordering is a requirement for several groups of APIs including [[CompressedId64Set]].\r\n * When used as input to a function, duplicate Ids are ignored; when returned as a function output, no duplicates are present.\r\n * @see [[CompressedId64Set]] for a compact string representation of such an ordered collection.\r\n * @see [[OrderedId64Iterable.compare]] for a function that compares Ids based on this criterion.\r\n * @see [[OrderedId64Array]] for a mutable implementation.\r\n * @public\r\n */\r\nexport namespace OrderedId64Iterable { // eslint-disable-line @typescript-eslint/no-redeclare\r\n /** An ordered comparison of [[Id64String]]s suitable for use with sorting routines like\r\n * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and sorted containers\r\n * like [[SortedArray]] and [[Dictionary]]. The comparison compares the 64-bit numerical values of the two Ids, returning a negative number if lhs < rhs,\r\n * a positive number if lhs > rhs, or zero if lhs == rhs.\r\n * The default string comparison is fine (and more efficient) when numerical ordering is not required; use this instead if you want e.g., \"0x100\" to be greater than \"0xf\".\r\n * @see [[OrderedId64Iterable.sortArray]] for a convenient way to sort an array of Id64Strings.\r\n */\r\n export function compare(lhs: Id64String, rhs: Id64String): number {\r\n if (lhs.length !== rhs.length)\r\n return lhs.length < rhs.length ? -1 : 1;\r\n\r\n // This is faster than localeCompare(). Unclear why there is no string.compare() - would be generally useful in\r\n // array sort functions...\r\n if (lhs !== rhs)\r\n return lhs < rhs ? -1 : 1;\r\n\r\n return 0;\r\n }\r\n\r\n /** Sort an array of [[Id64String]]s **in-place** in ascending order by their 64-bit numerical values.\r\n * @see [[OrderedId64Iterable.compare]] for the comparison routine used.\r\n * @returns the input array.\r\n * @note This function returns its input for consistency with Javascript's\r\n * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) method.\r\n * It **does not** create a **new** array.\r\n */\r\n export function sortArray(ids: Id64Array): Id64Array {\r\n ids.sort((x, y) => compare(x, y));\r\n return ids;\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, determine whether they are identical sets. Duplicate Ids are ignored.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function areEqualSets(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): boolean {\r\n const leftIter = uniqueIterator(ids1);\r\n const rightIter = uniqueIterator(ids2);\r\n let leftState = leftIter.next();\r\n let rightState = rightIter.next();\r\n\r\n while (!leftState.done && !rightState.done) {\r\n const left = leftState.value;\r\n const right = rightState.value;\r\n if (0 !== compare(left, right))\r\n return false;\r\n\r\n leftState = leftIter.next();\r\n rightState = rightIter.next();\r\n }\r\n\r\n if (leftState.done && rightState.done)\r\n return true;\r\n\r\n return false;\r\n }\r\n\r\n /** Given an ordered collection of [[Id64String]]s, determine if it contains any Ids.\r\n * @param ids A well-formed, ordered collection of zero or more valid Ids.\r\n * @returns true if the input represents an empty set of Ids. The result is unspecified if the input does not meet the criteria for the input type.\r\n */\r\n export function isEmptySet(ids: OrderedId64Iterable | CompressedId64Set): boolean {\r\n if (typeof ids === \"string\")\r\n return \"\" === ids;\r\n\r\n return true === ids[Symbol.iterator]().next().done;\r\n }\r\n\r\n /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered collection containing no duplicates.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function unique(ids: OrderedId64Iterable): OrderedId64Iterable {\r\n return { [Symbol.iterator]: () => uniqueIterator(ids) };\r\n }\r\n\r\n /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered iterator over the distinct Ids, eliminating duplicates.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function* uniqueIterator(ids: OrderedId64Iterable) {\r\n const iter = ids[Symbol.iterator]();\r\n let state = iter.next();\r\n let prev: Id64String | undefined;\r\n\r\n while (!state.done) {\r\n const id = state.value;\r\n state = iter.next();\r\n if (id !== prev) {\r\n prev = id;\r\n yield id;\r\n }\r\n }\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce a collection representing their union - i.e., the Ids that are present in either or both collections.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function union(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\r\n return { [Symbol.iterator]: () => unionIterator(ids1, ids2) };\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function intersection(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\r\n return { [Symbol.iterator]: () => intersectionIterator(ids1, ids2) };\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function difference(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\r\n return { [Symbol.iterator]: () => differenceIterator(ids1, ids2) };\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their union - i.e., the Ids that are present in either or both collections.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function* unionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\r\n const leftIter = ids1[Symbol.iterator]();\r\n const rightIter = ids2[Symbol.iterator]();\r\n let leftState = leftIter.next();\r\n let rightState = rightIter.next();\r\n\r\n let prev: string | undefined;\r\n while (!leftState.done || !rightState.done) {\r\n const left = leftState.done ? undefined : leftState.value;\r\n const right = rightState.done ? undefined : rightState.value;\r\n\r\n assert(undefined !== left || undefined !== right);\r\n if (undefined === left && undefined === right)\r\n break;\r\n\r\n let next: Id64String;\r\n if (undefined === left) {\r\n assert(undefined !== right);\r\n next = right;\r\n rightState = rightIter.next();\r\n } else if (undefined === right) {\r\n next = left;\r\n leftState = leftIter.next();\r\n } else {\r\n const cmp = compare(left, right);\r\n if (cmp <= 0) {\r\n next = left;\r\n leftState = leftIter.next();\r\n if (0 === cmp)\r\n rightState = rightIter.next();\r\n } else {\r\n next = right;\r\n rightState = rightIter.next();\r\n }\r\n }\r\n\r\n if (prev === next)\r\n continue;\r\n\r\n prev = next;\r\n yield next;\r\n }\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function* intersectionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\r\n const leftIter = ids1[Symbol.iterator]();\r\n const rightIter = ids2[Symbol.iterator]();\r\n let leftState = leftIter.next();\r\n let rightState = rightIter.next();\r\n\r\n let prev: string | undefined;\r\n while (!leftState.done && !rightState.done) {\r\n const left = leftState.value;\r\n leftState = leftIter.next();\r\n if (left === prev)\r\n continue;\r\n\r\n prev = left;\r\n\r\n let right = rightState.value;\r\n let cmp = compare(left, right);\r\n while (cmp > 0) {\r\n rightState = rightIter.next();\r\n if (rightState.done)\r\n return;\r\n\r\n right = rightState.value;\r\n cmp = compare(left, right);\r\n }\r\n\r\n if (0 === cmp)\r\n yield left;\r\n }\r\n }\r\n\r\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.\r\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\r\n */\r\n export function* differenceIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\r\n const leftIter = ids1[Symbol.iterator]();\r\n const rightIter = ids2[Symbol.iterator]();\r\n let leftState = leftIter.next();\r\n let rightState = rightIter.next();\r\n\r\n let prev: string | undefined;\r\n while (!leftState.done) {\r\n const left = leftState.value;\r\n leftState = leftIter.next();\r\n if (left === prev)\r\n continue;\r\n else if (rightState.done) {\r\n yield prev = left;\r\n continue;\r\n }\r\n\r\n let right = rightState.value;\r\n let cmp = compare(left, right);\r\n while (cmp > 0 && !rightState.done) {\r\n rightState = rightIter.next();\r\n if (rightState.done) {\r\n yield prev = left;\r\n continue;\r\n }\r\n\r\n right = rightState.value;\r\n cmp = compare(left, right);\r\n }\r\n\r\n if (cmp < 0)\r\n yield prev = left;\r\n }\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"OrderedId64Iterable.js","sourceRoot":"","sources":["../../src/OrderedId64Iterable.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAkC;AAOlC;;;;;;;GAOG;AACH,IAAiB,mBAAmB,CAwOnC;AAxOD,WAAiB,mBAAmB;IAClC;;;;;;OAMG;IACH,SAAgB,OAAO,CAAC,GAAe,EAAE,GAAe;QACtD,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,CAAC,MAAM;YAC3B,OAAO,GAAG,CAAC,MAAM,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QAE1C,+GAA+G;QAC/G,0BAA0B;QAC1B,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ACN,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;gBACzB,MAAM,IAAI,GAAG,IAAI,CAAC;gBAClB,SAAS;YACX,CAAC;YAED,IAAI,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;YAC7B,IAAI,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC/B,OAAO,GAAG,GAAG,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC;gBACnC,UAAU,GAAG,SAAS,CAAC,IAAI,EAAE,CAAC;gBAC9B,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC;oBACpB,MAAM,IAAI,GAAG,IAAI,CAAC;oBAClB,SAAS;gBACX,CAAC;gBAED,KAAK,GAAG,UAAU,CAAC,KAAK,CAAC;gBACzB,GAAG,GAAG,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;YAC7B,CAAC;YAED,IAAI,GAAG,GAAG,CAAC;gBACT,MAAM,IAAI,GAAG,IAAI,CAAC;QACtB,CAAC;IACH,CAAC;IAjCgB,sCAAkB,qBAiClC,CAAA;AACH,CAAC,EAxOgB,mBAAmB,mCAAnB,mBAAmB,QAwOnC","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 Ids\n */\n\nimport { assert } from \"./Assert\";\nimport { CompressedId64Set } from \"./CompressedId64Set\";\nimport { Id64Array, Id64String } from \"./Id\";\n\n/** @public */\nexport type OrderedId64Iterable = Iterable<Id64String>;\n\n/** A collection of **valid** [[Id64String]]s sorted in ascending order by the unsigned 64-bit integer value of the Ids.\n * This ordering is a requirement for several groups of APIs including [[CompressedId64Set]].\n * When used as input to a function, duplicate Ids are ignored; when returned as a function output, no duplicates are present.\n * @see [[CompressedId64Set]] for a compact string representation of such an ordered collection.\n * @see [[OrderedId64Iterable.compare]] for a function that compares Ids based on this criterion.\n * @see [[OrderedId64Array]] for a mutable implementation.\n * @public\n */\nexport namespace OrderedId64Iterable { // eslint-disable-line @typescript-eslint/no-redeclare\n /** An ordered comparison of [[Id64String]]s suitable for use with sorting routines like\n * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) and sorted containers\n * like [[SortedArray]] and [[Dictionary]]. The comparison compares the 64-bit numerical values of the two Ids, returning a negative number if lhs < rhs,\n * a positive number if lhs > rhs, or zero if lhs == rhs.\n * The default string comparison is fine (and more efficient) when numerical ordering is not required; use this instead if you want e.g., \"0x100\" to be greater than \"0xf\".\n * @see [[OrderedId64Iterable.sortArray]] for a convenient way to sort an array of Id64Strings.\n */\n export function compare(lhs: Id64String, rhs: Id64String): number {\n if (lhs.length !== rhs.length)\n return lhs.length < rhs.length ? -1 : 1;\n\n // This is faster than localeCompare(). Unclear why there is no string.compare() - would be generally useful in\n // array sort functions...\n if (lhs !== rhs)\n return lhs < rhs ? -1 : 1;\n\n return 0;\n }\n\n /** Sort an array of [[Id64String]]s **in-place** in ascending order by their 64-bit numerical values.\n * @see [[OrderedId64Iterable.compare]] for the comparison routine used.\n * @returns the input array.\n * @note This function returns its input for consistency with Javascript's\n * [Array.sort](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort) method.\n * It **does not** create a **new** array.\n */\n export function sortArray(ids: Id64Array): Id64Array {\n ids.sort((x, y) => compare(x, y));\n return ids;\n }\n\n /** Given two ordered collections of [[Id64String]]s, determine whether they are identical sets. Duplicate Ids are ignored.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function areEqualSets(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): boolean {\n const leftIter = uniqueIterator(ids1);\n const rightIter = uniqueIterator(ids2);\n let leftState = leftIter.next();\n let rightState = rightIter.next();\n\n while (!leftState.done && !rightState.done) {\n const left = leftState.value;\n const right = rightState.value;\n if (0 !== compare(left, right))\n return false;\n\n leftState = leftIter.next();\n rightState = rightIter.next();\n }\n\n if (leftState.done && rightState.done)\n return true;\n\n return false;\n }\n\n /** Given an ordered collection of [[Id64String]]s, determine if it contains any Ids.\n * @param ids A well-formed, ordered collection of zero or more valid Ids.\n * @returns true if the input represents an empty set of Ids. The result is unspecified if the input does not meet the criteria for the input type.\n */\n export function isEmptySet(ids: OrderedId64Iterable | CompressedId64Set): boolean {\n if (typeof ids === \"string\")\n return \"\" === ids;\n\n return true === ids[Symbol.iterator]().next().done;\n }\n\n /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered collection containing no duplicates.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function unique(ids: OrderedId64Iterable): OrderedId64Iterable {\n return { [Symbol.iterator]: () => uniqueIterator(ids) };\n }\n\n /** Given an ordered collection of [[Id64String]]s possibly containing duplicates, produce an ordered iterator over the distinct Ids, eliminating duplicates.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function* uniqueIterator(ids: OrderedId64Iterable) {\n const iter = ids[Symbol.iterator]();\n let state = iter.next();\n let prev: Id64String | undefined;\n\n while (!state.done) {\n const id = state.value;\n state = iter.next();\n if (id !== prev) {\n prev = id;\n yield id;\n }\n }\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce a collection representing their union - i.e., the Ids that are present in either or both collections.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function union(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\n return { [Symbol.iterator]: () => unionIterator(ids1, ids2) };\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function intersection(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\n return { [Symbol.iterator]: () => intersectionIterator(ids1, ids2) };\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function difference(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable): OrderedId64Iterable {\n return { [Symbol.iterator]: () => differenceIterator(ids1, ids2) };\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their union - i.e., the Ids that are present in either or both collections.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function* unionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\n const leftIter = ids1[Symbol.iterator]();\n const rightIter = ids2[Symbol.iterator]();\n let leftState = leftIter.next();\n let rightState = rightIter.next();\n\n let prev: string | undefined;\n while (!leftState.done || !rightState.done) {\n const left = leftState.done ? undefined : leftState.value;\n const right = rightState.done ? undefined : rightState.value;\n\n assert(undefined !== left || undefined !== right);\n if (undefined === left && undefined === right)\n break;\n\n let next: Id64String;\n if (undefined === left) {\n assert(undefined !== right);\n next = right;\n rightState = rightIter.next();\n } else if (undefined === right) {\n next = left;\n leftState = leftIter.next();\n } else {\n const cmp = compare(left, right);\n if (cmp <= 0) {\n next = left;\n leftState = leftIter.next();\n if (0 === cmp)\n rightState = rightIter.next();\n } else {\n next = right;\n rightState = rightIter.next();\n }\n }\n\n if (prev === next)\n continue;\n\n prev = next;\n yield next;\n }\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their intersection - i.e., the Ids that are present in both collections.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function* intersectionIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\n const leftIter = ids1[Symbol.iterator]();\n const rightIter = ids2[Symbol.iterator]();\n let leftState = leftIter.next();\n let rightState = rightIter.next();\n\n let prev: string | undefined;\n while (!leftState.done && !rightState.done) {\n const left = leftState.value;\n leftState = leftIter.next();\n if (left === prev)\n continue;\n\n prev = left;\n\n let right = rightState.value;\n let cmp = compare(left, right);\n while (cmp > 0) {\n rightState = rightIter.next();\n if (rightState.done)\n return;\n\n right = rightState.value;\n cmp = compare(left, right);\n }\n\n if (0 === cmp)\n yield left;\n }\n }\n\n /** Given two ordered collections of [[Id64String]]s, produce an iterator representing their difference - i.e., the Ids that are present in `ids1` but not present in `ids2`.\n * @note If the inputs are not ordered as required by [[OrderedId64Iterable]], the results are unpredictable.\n */\n export function* differenceIterator(ids1: OrderedId64Iterable, ids2: OrderedId64Iterable) {\n const leftIter = ids1[Symbol.iterator]();\n const rightIter = ids2[Symbol.iterator]();\n let leftState = leftIter.next();\n let rightState = rightIter.next();\n\n let prev: string | undefined;\n while (!leftState.done) {\n const left = leftState.value;\n leftState = leftIter.next();\n if (left === prev)\n continue;\n else if (rightState.done) {\n yield prev = left;\n continue;\n }\n\n let right = rightState.value;\n let cmp = compare(left, right);\n while (cmp > 0 && !rightState.done) {\n rightState = rightIter.next();\n if (rightState.done) {\n yield prev = left;\n continue;\n }\n\n right = rightState.value;\n cmp = compare(left, right);\n }\n\n if (cmp < 0)\n yield prev = left;\n }\n }\n}\n"]}
|
package/lib/cjs/OrderedSet.js
CHANGED
|
@@ -15,6 +15,7 @@ const SortedArray_1 = require("./SortedArray");
|
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
class ReadonlyOrderedSet {
|
|
18
|
+
_array;
|
|
18
19
|
/** Construct a new ReadonlyOrderedSet<T>.
|
|
19
20
|
* @param compare The function used to compare elements within the set, determining their ordering.
|
|
20
21
|
* @param clone The function invoked to clone a new element for insertion into the set. The default implementation simply returns its input.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OrderedSet.js","sourceRoot":"","sources":["../../src/OrderedSet.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAAyE;AAEzE;;;;GAIG;AACH,MAAa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C,CAAC;IAC1C,CAAC;CACF;AAxBD,gCAwBC","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 Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\nimport { CloneFunction, shallowClone, SortedArray } from \"./SortedArray\";\n\n/** A read-only equivalent of `Set<T>` that maintains its elements in sorted order as specified by a comparison function.\n * Iteration returns elements in the order specified by the comparison function, as opposed to `Set` which returns elements in insertion order.\n * Implemented in terms of [[SortedArray]].\n * @public\n */\nexport class ReadonlyOrderedSet<T> implements Iterable<T> {\n protected readonly _array: SortedArray<T>;\n\n /** Construct a new ReadonlyOrderedSet<T>.\n * @param compare The function used to compare elements within the set, determining their ordering.\n * @param clone The function invoked to clone a new element for insertion into the set. The default implementation simply returns its input.\n */\n public constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone) {\n this._array = new SortedArray<T>(compare, false, clone);\n }\n\n /** The number of elements in the set. */\n public get size(): number {\n return this._array.length;\n }\n\n /** Returns true if `value` is present in the set. */\n public has(value: T): boolean {\n return -1 !== this._array.indexOf(value);\n }\n\n /** Iterate over the elements in sorted order (as opposed to `Set`'s iterator, which returns elements in insertion order). */\n public [Symbol.iterator](): Iterator<T> {\n return this._array[Symbol.iterator]();\n }\n}\n\n/** A mutable [[ReadonlyOrderedSet]].\n * @public\n */\nexport class OrderedSet<T> extends ReadonlyOrderedSet<T> {\n /** Construct a new OrderedSet<T>.\n * @param compare The function used to compare elements within the set, determining their ordering.\n * @param clone The function invoked to clone a new element for insertion into the set. The default implementation simply returns its input.\n */\n public constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone) {\n super(compare, clone);\n }\n\n /** Remove all elements from the set. */\n public clear(): void {\n this._array.clear();\n }\n\n /** Add the specified element to the set. Returns this set. */\n public add(value: T): this {\n this._array.insert(value);\n return this;\n }\n\n /** Removes the specified element from the set. Returns `true` if the element was present. */\n public delete(value: T): boolean {\n return -1 !== this._array.remove(value);\n }\n}\n"]}
|
package/lib/cjs/PriorityQueue.js
CHANGED
|
@@ -15,6 +15,9 @@ const SortedArray_1 = require("./SortedArray");
|
|
|
15
15
|
* @public
|
|
16
16
|
*/
|
|
17
17
|
class PriorityQueue {
|
|
18
|
+
_array = [];
|
|
19
|
+
_compare;
|
|
20
|
+
_clone;
|
|
18
21
|
/**
|
|
19
22
|
* Constructor
|
|
20
23
|
* @param compare The function used to compare values in the queue. If `compare(x, y)` returns a negative value, then x is placed before y in the queue.
|
|
@@ -22,7 +25,6 @@ class PriorityQueue {
|
|
|
22
25
|
* @note If the criterion which control the result of the `compare` function changes, then [[PriorityQueue.sort]] should be used to reorder the queue according to the new criterion.
|
|
23
26
|
*/
|
|
24
27
|
constructor(compare, clone = SortedArray_1.shallowClone) {
|
|
25
|
-
this._array = [];
|
|
26
28
|
this._compare = compare;
|
|
27
29
|
this._clone = clone;
|
|
28
30
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PriorityQueue.js","sourceRoot":"","sources":["../../src/PriorityQueue.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAA4D;AAK5D;;;;GAIG;AACH,MAAa,aAAa;
|
|
1
|
+
{"version":3,"file":"PriorityQueue.js","sourceRoot":"","sources":["../../src/PriorityQueue.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAGH,+CAA4D;AAK5D;;;;GAIG;AACH,MAAa,aAAa;IACd,MAAM,GAAQ,EAAE,CAAC;IACR,QAAQ,CAAuB;IAC/B,MAAM,CAAmB;IAE5C;;;;;OAKG;IACH,YAAmB,OAA6B,EAAE,QAA0B,0BAAY;QACtF,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,KAAK,CAAC;IACtB,CAAC;IAED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QACjC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QACxB,OAAO,KAAK,CAAC;IACf,CAAC;IAED,2FAA2F;IAC3F,IAAW,KAAK;QACd,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACvB,CAAC;IAED;;;OAGG;IACI,GAAG;QACR,OAAO,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IACtB,CAAC;IAED,yCAAyC;IAClC,KAAK;QACV,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,CAAC,CAAC;IACzB,CAAC;IAED;;;;OAIG;IACO,IAAI,CAAC,KAAa;QAC1B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM;YACnC,OAAO,SAAS,CAAC;QAEnB,MAAM,IAAI,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAChC,IAAI,CAAC,KAAK,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;QACnC,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,CAAC;QAErB,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QACrB,OAAO,IAAI,CAAC;IACd,CAAC;IAED;;;;OAIG;IACO,KAAK,CAAC,KAAa;QAC3B,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,IAAI,IAAI,CAAC,MAAM;YACnC,OAAO,SAAS,CAAC;;YAEjB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC;CACF;AA/ID,sCA+IC","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 Collections\n */\n\nimport { OrderedComparator } from \"./Compare\";\nimport { CloneFunction, shallowClone } from \"./SortedArray\";\n\n/** @public */\nexport type ComputePriorityFunction<T> = (value: T) => number;\n\n/**\n * A [priority queue](https://en.wikipedia.org/wiki/Priority_queue) implemented as a heap array.\n * The queue is ordered by an [[OrderedComparator]] function supplied by the user such that the value in the queue that compares less than all other values is always located at the front of the queue.\n * @public\n */\nexport class PriorityQueue<T> implements Iterable<T> {\n protected _array: T[] = [];\n protected readonly _compare: OrderedComparator<T>;\n protected readonly _clone: CloneFunction<T>;\n\n /**\n * Constructor\n * @param compare The function used to compare values in the queue. If `compare(x, y)` returns a negative value, then x is placed before y in the queue.\n * @param clone The function used to clone a value for insertion onto the queue. The default implementation simply returns its input.\n * @note If the criterion which control the result of the `compare` function changes, then [[PriorityQueue.sort]] should be used to reorder the queue according to the new criterion.\n */\n public constructor(compare: OrderedComparator<T>, clone: CloneFunction<T> = shallowClone) {\n this._compare = compare;\n this._clone = clone;\n }\n\n /** The number of values in the queue. */\n public get length(): number { return this._array.length; }\n\n /** Returns true if the queue contains no values. */\n public get isEmpty(): boolean { return 0 === this.length; }\n\n /** Returns an iterator over the contents of the heap suitable for use in `for-of` loops. */\n public [Symbol.iterator](): Iterator<T> { return this._array[Symbol.iterator](); }\n\n protected _swap(a: number, b: number) {\n const temp = this._array[a];\n this._array[a] = this._array[b];\n this._array[b] = temp;\n }\n\n protected _heapify(index: number): void {\n let candidate = -1;\n while (true) {\n const right = 2 * (index + 1);\n const left = right - 1;\n if (left < this.length && this._compare(this._array[left], this._array[index]) < 0)\n candidate = left;\n else\n candidate = index;\n\n if (right < this.length && this._compare(this._array[right], this._array[candidate]) < 0)\n candidate = right;\n\n if (candidate !== index) {\n this._swap(candidate, index);\n index = candidate;\n } else {\n break;\n }\n }\n }\n\n /**\n * Reorders the queue. This function should only (and *always*) be called when the criteria governing the ordering of items on the queue have changed.\n * For example, a priority queue containing graphics sorted by their distance from the camera would need to be reordered when the position of the camera changes.\n */\n public sort(): void {\n for (let i = Math.ceil(this.length / 2); i >= 0; i--)\n this._heapify(i);\n }\n\n /**\n * Pushes a value onto the queue according to the sorting criterion.\n * @param value The value to insert\n * @returns The inserted value, cloned according to the [[CloneFunction]] supplied to this queue's constructor.\n */\n public push(value: T): T {\n const clone = this._clone(value);\n\n let index = this.length;\n this._array.push(clone);\n\n while (index !== 0) {\n const parent = Math.floor((index - 1) / 2);\n if (this._compare(this._array[index], this._array[parent]) < 0) {\n this._swap(index, parent);\n index = parent;\n } else {\n break;\n }\n }\n\n return clone;\n }\n\n /** Pushes a value onto the back of the queue without making any attempt to enforce ordering.\n * After using this function, you must manually invoke sort() to ensure the queue is sorted again.\n * @param value The value to append\n * @returns The appended value, cloned according to the [[CloneFunction]] supplied to this queue's constructor.\n */\n public append(value: T): T {\n const clone = this._clone(value);\n this._array.push(clone);\n return clone;\n }\n\n /** Returns the element at the front of the queue, or `undefined` if the queue is empty. */\n public get front(): T | undefined {\n return this._peek(0);\n }\n\n /**\n * Removes the front-most element off of the queue and returns it.\n * @returns The front-most element, or undefined if the queue is empty.\n */\n public pop(): T | undefined {\n return this._pop(0);\n }\n\n /** Removes all values from the queue. */\n public clear(): void {\n this._array.length = 0;\n }\n\n /**\n * Removes the value at the specified index from the queue and reorders the queue.\n * @param index The index of the value to remove\n * @returns the value at the specified index, or undefined if the index is out of range.\n */\n protected _pop(index: number): T | undefined {\n if (index < 0 || index >= this.length)\n return undefined;\n\n const root = this._array[index];\n this._swap(index, this.length - 1);\n this._array.length--;\n\n this._heapify(index);\n return root;\n }\n\n /**\n * Returns the value at the specified index in the queue.\n * @param index The index of the value to retrieve\n * @returns the value at the specified index, or undefined if the index is out of range.\n */\n protected _peek(index: number): T | undefined {\n if (index < 0 || index >= this.length)\n return undefined;\n else\n return this._array[index];\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProcessDetector.js","sourceRoot":"","sources":["../../src/ProcessDetector.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;GAEG;AACH,MAAa,eAAe;IAE1B;;O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C,CAAC;IAEjH,6CAA6C;IACtC,MAAM,KAAK,kBAAkB,KAAK,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAEnG,yEAAyE;IAClE,MAAM,KAAK,mBAAmB,KAAK,OAAO,IAAI,CAAC,qBAAqB,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAC3G;AAzED,0CAyEC","sourcesContent":["/*---------------------------------------------------------------------------------------------\
|
|
1
|
+
{"version":3,"file":"ProcessDetector.js","sourceRoot":"","sources":["../../src/ProcessDetector.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH;;GAEG;AACH,MAAa,eAAe;IAE1B;;OAEG;IACI,MAAM,KAAK,gBAAgB,KAAK,OAAO,OAAO,MAAM,KAAK,QAAQ,IAAI,OAAO,MAAM,CAAC,SAAS,KAAK,QAAQ,CAAC,CAAC,CAAC;IAEnH;;MAEE;IACK,MAAM,KAAK,aAAa,KAAK,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,SAAS,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE3G,uDAAuD;IAChD,MAAM,KAAK,qBAAqB,KAAK,OAAO,OAAO,SAAS,KAAK,QAAQ,IAAI,SAAS,CAAC,SAAS,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAEjJ,sDAAsD;IAC/C,MAAM,KAAK,oBAAoB,KAAK,OAAO,OAAO,OAAO,KAAK,QAAQ,IAAI,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IAE/H;;OAEG;IACI,MAAM,KAAK,aAAa;QAC7B,OAAO,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,MAAM,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,QAAQ,KAAK,UAAU,IAA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,CAAC,CAAC,CAAC,CAAC,CAAC;IAE7H,qEAAqE;IAC9D,MAAM,KAAK,oBAAoB,KAAK,OAAO,IAAI,CAAC,gBAAgB,IAAI,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,kBAAkB,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAErI,gEAAgE;IACzD,MAAM,KAAK,eAAe,KAAK,OAAO,IAAI,CAAC,aAAa,IAAK,OAAO,CAAC,QAAgB,KAAK,KAAK,CAAC,CAAC,CAAC;IAEzG,oEAAoE;IAC7D,MAAM,KAAK,mBAAmB,KAAK,OAAO,IAAI,CAAC,aAAa,IAAK,OAAO,CAAC,QAAgB,KAAK,SAAS,CAAC,CAAC,CAAC;IAEjH,6CAA6C;IACtC,MAAM,KAAK,kBAAkB,KAAK,OAAO,IAAI,CAAC,eAAe,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;IAEnG,yEAAyE;IAClE,MAAM,KAAK,mBAAmB,KAAK,OAAO,IAAI,CAAC,qBAAqB,IAAI,IAAI,CAAC,mBAAmB,CAAC,CAAC,CAAC;CAC3G;AAzED,0CAyEC","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 ProcessDetector\n */\n\n/** Functions to determine the type of JavaScript process currently executing.\n * @public\n */\nexport class ProcessDetector {\n\n /** Is this a browser process?\n * @note this method will also return `true` for the frontend of Electron or Mobile apps. They *are* browser processes.\n */\n public static get isBrowserProcess() { return typeof window === \"object\" && typeof window.navigator === \"object\"; }\n\n /** Is this a Node process?\n * @note this means \"is this a backend process\"? It will return `true` for all backend process, including Electron and mobile apps.\n */\n public static get isNodeProcess() { return typeof process === \"object\" && undefined !== process.platform; }\n\n /** Is this process the frontend of an Electron app? */\n public static get isElectronAppFrontend() { return typeof navigator === \"object\" && navigator.userAgent.toLowerCase().indexOf(\"electron\") >= 0; }\n\n /** Is this process the backend of an Electron app? */\n public static get isElectronAppBackend() { return typeof process === \"object\" && process.versions.hasOwnProperty(\"electron\"); }\n\n /** Is this process running in a browser on an iPad?\n * @note This method will return `true` for any frontend running on an iPad, whether it is a user-launched web browser (e.g. Safari) or the frontend of a mobile app.\n */\n public static get isIPadBrowser() {\n return this.isBrowserProcess && window.navigator.platform === \"iPad\" || (window.navigator.platform === \"MacIntel\" && window.navigator.maxTouchPoints > 0 && !(\"MSStream\" in window)); /* eslint-disable-line @typescript-eslint/no-deprecated */\n }\n\n /** Is this process running in a browser on an iPhone?\n * @note This method will return `true` for any frontend running on an iPhone, whether it is a user-launched web browser (e.g. Safari) or the frontend of a mobile app.\n */\n public static get isIPhoneBrowser() { return this.isBrowserProcess && (/(iphone|ipod)/i.test(window.navigator.userAgent)); }\n\n /** Is this process running in a browser on an iOS device?\n * @note This method will return `true` for any frontend running on an iOS device, whether it is a user-launched web browser (e.g. Safari) or the frontend of a mobile app.\n */\n public static get isIOSBrowser() { return this.isIPadBrowser || this.isIPhoneBrowser; }\n\n /** Is this process running in a browser on an Android device?\n * @note This method will return `true` for any frontend running on an Android device, whether it is a user-launched web browser (e.g. Chrome) or the frontend of a mobile app.\n */\n public static get isAndroidBrowser() { return this.isBrowserProcess && /android/i.test(window.navigator.userAgent); }\n\n /** Is this process running in a browser on a mobile device?\n * @note This method will return `true` for any frontend running on a mobile device, whether it is a user-launched web browser or the frontend of a mobile app.\n */\n public static get isMobileBrowser() { return this.isIOSBrowser || this.isAndroidBrowser; }\n\n /** Is this process running in a Chromium based browser (Chrome / new Edge / Electron front end)? */\n public static get isChromium() {\n return (this.isBrowserProcess && window.navigator.userAgent.indexOf(\"Chrome\") > -1 && window.navigator.userAgent.indexOf(\"OP\") === -1) || this.isElectronAppFrontend;\n }\n\n /** Is this process the frontend of an iTwin mobile application?\n * @note this indicates that this is a browser process started by an iTwin mobile application.\n * It will return `false` when running user-launched web browsers on a mobile device.\n */\n public static get isMobileAppFrontend() { return this.isAndroidAppFrontend || this.isIOSAppFrontend; }\n\n /** Is this process the frontend of an iOS mobile application? */\n public static get isIOSAppFrontend() { return this.isBrowserProcess && window.location.hash.indexOf(\"platform=ios\") !== -1; }\n\n /** Is this process the frontend of an Android mobile application? */\n public static get isAndroidAppFrontend() { return this.isBrowserProcess && window.location.hash.indexOf(\"platform=android\") !== -1; }\n\n /** Is this process the backend of an iOS mobile application? */\n public static get isIOSAppBackend() { return this.isNodeProcess && (process.platform as any) === \"ios\"; }\n\n /** Is this process the backend of an Android mobile application? */\n public static get isAndroidAppBackend() { return this.isNodeProcess && (process.platform as any) === \"android\"; }\n\n /** Is this process a mobile app backend? */\n public static get isMobileAppBackend() { return this.isIOSAppBackend || this.isAndroidAppBackend; }\n\n /** Is this process the frontend of a native (Electron or Mobile) app? */\n public static get isNativeAppFrontend() { return this.isElectronAppFrontend || this.isMobileAppFrontend; }\n}\n"]}
|
package/lib/cjs/SortedArray.js
CHANGED
|
@@ -85,6 +85,10 @@ var DuplicatePolicy;
|
|
|
85
85
|
* @public
|
|
86
86
|
*/
|
|
87
87
|
class ReadonlySortedArray {
|
|
88
|
+
_array = [];
|
|
89
|
+
_compare;
|
|
90
|
+
_clone;
|
|
91
|
+
_duplicatePolicy;
|
|
88
92
|
/**
|
|
89
93
|
* Construct a new ReadonlySortedArray<T>.
|
|
90
94
|
* @param compare The function used to compare elements within the array.
|
|
@@ -92,7 +96,6 @@ class ReadonlySortedArray {
|
|
|
92
96
|
* @param clone The function invoked to clone a new element for insertion into the array. The default implementation simply returns its input.
|
|
93
97
|
*/
|
|
94
98
|
constructor(compare, duplicatePolicy = false, clone = shallowClone) {
|
|
95
|
-
this._array = [];
|
|
96
99
|
this._compare = compare;
|
|
97
100
|
this._clone = clone;
|
|
98
101
|
if (typeof duplicatePolicy === "boolean")
|