@itwin/presentation-backend 5.0.0-dev.40 → 5.0.0-dev.49
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 +11 -1
- package/lib/cjs/presentation-backend/NativePlatform.d.ts +2 -2
- package/lib/cjs/presentation-backend/NativePlatform.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js +1 -1
- package/lib/cjs/presentation-backend/NativePlatform.js.map +1 -1
- package/lib/cjs/presentation-backend/Presentation.js +3 -3
- package/lib/cjs/presentation-backend/Presentation.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.d.ts +2 -0
- package/lib/cjs/presentation-backend/PresentationManager.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManager.js +6 -1
- package/lib/cjs/presentation-backend/PresentationManager.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts +3 -3
- package/lib/cjs/presentation-backend/PresentationManagerDetail.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js +3 -3
- package/lib/cjs/presentation-backend/PresentationManagerDetail.js.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts +3 -3
- package/lib/cjs/presentation-backend/PresentationRpcImpl.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js +26 -27
- package/lib/cjs/presentation-backend/PresentationRpcImpl.js.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts +2 -3
- package/lib/cjs/presentation-backend/TemporaryStorage.d.ts.map +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.js +1 -1
- package/lib/cjs/presentation-backend/TemporaryStorage.js.map +1 -1
- package/package.json +15 -15
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TemporaryStorage.js","sourceRoot":"","sources":["../../../src/presentation-backend/TemporaryStorage.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAE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QACf,MAAM,MAAM,GAAG,IAAI,KAAK,EAAK,CAAC;QAC9B,KAAK,MAAM,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;YACtC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACvB,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AAzHD,4CAyHC;AAWD;;;;;GAKG;AACH,MAAa,4BAAgC,SAAQ,gBAAmB;IAGtE;;OAEG;IACH,YAAY,KAA2C;QACrD,KAAK,CAAC,KAAK,CAAC,CAAC;QACb,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED;;;;;OAKG;IACa,QAAQ,CAAC,EAAU;QACjC,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,aAAa,CAAC;QACvB,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA3BD,oEA2BC","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 Core\n */\n\nimport { assert, IDisposable } from \"@itwin/core-bentley\";\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\n\n/**\n * Configuration properties for [[TemporaryStorage]].\n * @internal\n */\nexport interface TemporaryStorageProps<T> {\n /** A method that's called for every value before it's removed from storage */\n cleanupHandler?: (id: string, value: T, reason: \"timeout\" | \"dispose\" | \"request\") => void;\n\n onDisposedSingle?: (id: string) => void;\n onDisposedAll?: () => void;\n\n /**\n * An interval at which the storage attempts to clean up its values.\n * When `0` or `undefined` is specified, values are not cleaned up\n * automatically and cleanup has to be initiated manually by calling\n * [[TemporaryStorage.disposeOutdatedValues]].\n */\n cleanupInterval?: number;\n\n /**\n * Shortest period of time which the value should be kept in storage\n * unused before it's cleaned up.\n *\n * `undefined` means the values may be kept unused in the storage indefinitely.\n * `0` means the values are removed from the storage on every cleanup (either manual\n * call to [[TemporaryStorage.disposeOutdatedValues]] or scheduled (controlled\n * by [[cleanupInterval]])).\n */\n unusedValueLifetime?: number;\n\n /**\n * The maximum period of time which the value should be kept in storage\n * before it's cleaned up. The time is measured from the moment the value is added\n * to the storage.\n *\n * `undefined` means the values may be kept indefinitely. `0` means they're removed\n * up on every cleanup (either manual call to [[TemporaryStorage.disposeOutdatedValues]]\n * or scheduled (controlled by [[cleanupInterval]])).\n */\n maxValueLifetime?: number;\n}\n\n/** Value with know last used time */\ninterface TemporaryValue<T> {\n created: Date;\n lastUsed: Date;\n value: T;\n}\n\n/**\n * Storage for values that get removed from it after being unused (not-requested\n * for a specified amount of time).\n *\n * @internal\n */\nexport class TemporaryStorage<T> implements IDisposable {\n private _timer?: NodeJS.Timeout;\n protected _values: Map<string, TemporaryValue<T>>;\n public readonly props: TemporaryStorageProps<T>;\n\n /**\n * Constructor. Creates the storage using supplied params.\n */\n constructor(props: TemporaryStorageProps<T>) {\n this.props = props;\n this._values = new Map<string, TemporaryValue<T>>();\n if (this.props.cleanupInterval) {\n this._timer = setInterval(this.disposeOutdatedValues, this.props.cleanupInterval);\n }\n }\n\n /**\n * Destructor. Must be called to clean up the stored values\n * and other resources\n */\n public dispose() {\n if (this._timer) {\n clearInterval(this._timer);\n }\n\n if (this.props.cleanupHandler) {\n this._values.forEach((v, id) => {\n this.props.cleanupHandler!(id, v.value, \"dispose\");\n });\n }\n this._values.clear();\n this.props.onDisposedAll && this.props.onDisposedAll();\n }\n\n /**\n * Cleans up values that are currently outdated (based\n * on their max and unused value lifetimes specified through [[Props]]).\n */\n public disposeOutdatedValues = () => {\n const now = new Date().getTime();\n const valuesToDispose: string[] = [];\n for (const [key, entry] of this._values.entries()) {\n if (this.props.maxValueLifetime !== undefined) {\n if (this.props.maxValueLifetime === 0 || now - entry.created.getTime() > this.props.maxValueLifetime) {\n valuesToDispose.push(key);\n continue;\n }\n }\n if (this.props.unusedValueLifetime !== undefined) {\n if (this.props.unusedValueLifetime === 0 || now - entry.lastUsed.getTime() > this.props.unusedValueLifetime) {\n valuesToDispose.push(key);\n continue;\n }\n }\n }\n for (const id of valuesToDispose) {\n this.deleteExistingEntry(id, true);\n }\n };\n\n private deleteExistingEntry(id: string, isTimeout: boolean) {\n assert(this._values.has(id));\n this.props.cleanupHandler && this.props.cleanupHandler(id, this._values.get(id)!.value, isTimeout ? \"timeout\" : \"request\");\n this._values.delete(id);\n this.props.onDisposedSingle && this.props.onDisposedSingle(id);\n }\n\n /**\n * Get a value from the storage.\n *\n * **Note:** requesting a value with this method updates it's last used time.\n */\n public getValue(id: string): T | undefined {\n if (this._values.has(id)) {\n const v = this._values.get(id)!;\n v.lastUsed = new Date();\n return v.value;\n }\n return undefined;\n }\n\n public notifyValueUsed(id: string) {\n const entry = this._values.get(id);\n // istanbul ignore else\n if (entry) {\n entry.lastUsed = new Date();\n }\n }\n\n /**\n * Adds a value into the storage.\n * @throws An error when trying to add a value with ID that's already stored in the storage.\n */\n public addValue(id: string, value: T) {\n if (this._values.has(id)) {\n throw new PresentationError(PresentationStatus.InvalidArgument, `A value with given ID \"${id}\" already exists in this storage.`);\n }\n this._values.set(id, { value, created: new Date(), lastUsed: new Date() });\n }\n\n /** Deletes a value with given id. */\n public deleteValue(id: string) {\n // istanbul ignore else\n if (this._values.has(id)) {\n this.deleteExistingEntry(id, false);\n }\n }\n\n /**\n * Get all values currently in this storage.\n *\n * **Note:** requesting values with this method **doesn't**\n * update their last used times.\n */\n public get values(): T[] {\n const values = new Array<T>();\n for (const v of this._values.values()) {\n values.push(v.value);\n }\n return values;\n }\n}\n\n/**\n * Configuration properties for [[FactoryBasedTemporaryStorage]].\n * @internal\n */\nexport interface FactoryBasedTemporaryStorageProps<T> extends TemporaryStorageProps<T> {\n /** A factory method that creates a stored value given it's identifier */\n factory: (id: string, onValueUsed: () => void) => T;\n}\n\n/**\n * Storage for values that get removed from it after being unused (not-requested\n * for a specified amount of time).\n *\n * @internal\n */\nexport class FactoryBasedTemporaryStorage<T> extends TemporaryStorage<T> {\n public override readonly props: FactoryBasedTemporaryStorageProps<T>;\n\n /**\n * Constructor. Creates the storage using supplied params.\n */\n constructor(props: FactoryBasedTemporaryStorageProps<T>) {\n super(props);\n this.props = props;\n }\n\n /**\n * Get a value from the storage. If the value with the specified id\n * doesn't exist, it gets created.\n *\n * **Note:** requesting a value with this method updates it's last used time.\n */\n public override getValue(id: string): T {\n const existingValue = super.getValue(id);\n if (existingValue) {\n return existingValue;\n }\n\n const value = this.props.factory(id, () => this.notifyValueUsed(id));\n this.addValue(id, value);\n return value;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"TemporaryStorage.js","sourceRoot":"","sources":["../../../src/presentation-backend/TemporaryStorage.ts"],"names":[],"mappings":";AAAA;;;gGAGgG;AAChG;;GAEG;;;AAEH,sDAA6C;AAC7C,oEAAmF;AAmDnF;;;;;GAKG;AACH,MAAa,gBAAgB;IAK3B;;OAEG;IACH,YAAY,KAA+B;QA0B3C;;;WAGG;QACI,0BAAqB,GAAG,GAAG,EAAE;YAClC,MAAM,GAAG,GAAG,IAAI,IAAI,EAAE,CAAC,OAAO,EAAE,CAAC;YACjC,MAAM,eAAe,GAAa,EAAE,CAAC;YACrC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC;gBAClD,IAAI,IAAI,CAAC,KAAK,CAAC,gBAAgB,KAAK,SAAS,EAAE,CAAC;oBAC9C,I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;IACrB,CAAC;IAED;;;;;OAKG;IACa,QAAQ,CAAC,EAAU;QACjC,MAAM,aAAa,GAAG,KAAK,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,aAAa,EAAE,CAAC;YAClB,OAAO,aAAa,CAAC;QACvB,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;QACrE,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,KAAK,CAAC,CAAC;QACzB,OAAO,KAAK,CAAC;IACf,CAAC;CACF;AA3BD,oEA2BC","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 Core\n */\n\nimport { assert } from \"@itwin/core-bentley\";\nimport { PresentationError, PresentationStatus } from \"@itwin/presentation-common\";\n\n/**\n * Configuration properties for [[TemporaryStorage]].\n * @internal\n */\nexport interface TemporaryStorageProps<T> {\n /** A method that's called for every value before it's removed from storage */\n cleanupHandler?: (id: string, value: T, reason: \"timeout\" | \"dispose\" | \"request\") => void;\n\n onDisposedSingle?: (id: string) => void;\n onDisposedAll?: () => void;\n\n /**\n * An interval at which the storage attempts to clean up its values.\n * When `0` or `undefined` is specified, values are not cleaned up\n * automatically and cleanup has to be initiated manually by calling\n * [[TemporaryStorage.disposeOutdatedValues]].\n */\n cleanupInterval?: number;\n\n /**\n * Shortest period of time which the value should be kept in storage\n * unused before it's cleaned up.\n *\n * `undefined` means the values may be kept unused in the storage indefinitely.\n * `0` means the values are removed from the storage on every cleanup (either manual\n * call to [[TemporaryStorage.disposeOutdatedValues]] or scheduled (controlled\n * by [[cleanupInterval]])).\n */\n unusedValueLifetime?: number;\n\n /**\n * The maximum period of time which the value should be kept in storage\n * before it's cleaned up. The time is measured from the moment the value is added\n * to the storage.\n *\n * `undefined` means the values may be kept indefinitely. `0` means they're removed\n * up on every cleanup (either manual call to [[TemporaryStorage.disposeOutdatedValues]]\n * or scheduled (controlled by [[cleanupInterval]])).\n */\n maxValueLifetime?: number;\n}\n\n/** Value with know last used time */\ninterface TemporaryValue<T> {\n created: Date;\n lastUsed: Date;\n value: T;\n}\n\n/**\n * Storage for values that get removed from it after being unused (not-requested\n * for a specified amount of time).\n *\n * @internal\n */\nexport class TemporaryStorage<T> implements Disposable {\n private _timer?: NodeJS.Timeout;\n protected _values: Map<string, TemporaryValue<T>>;\n public readonly props: TemporaryStorageProps<T>;\n\n /**\n * Constructor. Creates the storage using supplied params.\n */\n constructor(props: TemporaryStorageProps<T>) {\n this.props = props;\n this._values = new Map<string, TemporaryValue<T>>();\n if (this.props.cleanupInterval) {\n this._timer = setInterval(this.disposeOutdatedValues, this.props.cleanupInterval);\n }\n }\n\n /**\n * Destructor. Must be called to clean up the stored values\n * and other resources\n */\n public [Symbol.dispose]() {\n if (this._timer) {\n clearInterval(this._timer);\n }\n\n if (this.props.cleanupHandler) {\n this._values.forEach((v, id) => {\n this.props.cleanupHandler!(id, v.value, \"dispose\");\n });\n }\n this._values.clear();\n this.props.onDisposedAll && this.props.onDisposedAll();\n }\n\n /**\n * Cleans up values that are currently outdated (based\n * on their max and unused value lifetimes specified through [[Props]]).\n */\n public disposeOutdatedValues = () => {\n const now = new Date().getTime();\n const valuesToDispose: string[] = [];\n for (const [key, entry] of this._values.entries()) {\n if (this.props.maxValueLifetime !== undefined) {\n if (this.props.maxValueLifetime === 0 || now - entry.created.getTime() > this.props.maxValueLifetime) {\n valuesToDispose.push(key);\n continue;\n }\n }\n if (this.props.unusedValueLifetime !== undefined) {\n if (this.props.unusedValueLifetime === 0 || now - entry.lastUsed.getTime() > this.props.unusedValueLifetime) {\n valuesToDispose.push(key);\n continue;\n }\n }\n }\n for (const id of valuesToDispose) {\n this.deleteExistingEntry(id, true);\n }\n };\n\n private deleteExistingEntry(id: string, isTimeout: boolean) {\n assert(this._values.has(id));\n this.props.cleanupHandler && this.props.cleanupHandler(id, this._values.get(id)!.value, isTimeout ? \"timeout\" : \"request\");\n this._values.delete(id);\n this.props.onDisposedSingle && this.props.onDisposedSingle(id);\n }\n\n /**\n * Get a value from the storage.\n *\n * **Note:** requesting a value with this method updates it's last used time.\n */\n public getValue(id: string): T | undefined {\n if (this._values.has(id)) {\n const v = this._values.get(id)!;\n v.lastUsed = new Date();\n return v.value;\n }\n return undefined;\n }\n\n public notifyValueUsed(id: string) {\n const entry = this._values.get(id);\n // istanbul ignore else\n if (entry) {\n entry.lastUsed = new Date();\n }\n }\n\n /**\n * Adds a value into the storage.\n * @throws An error when trying to add a value with ID that's already stored in the storage.\n */\n public addValue(id: string, value: T) {\n if (this._values.has(id)) {\n throw new PresentationError(PresentationStatus.InvalidArgument, `A value with given ID \"${id}\" already exists in this storage.`);\n }\n this._values.set(id, { value, created: new Date(), lastUsed: new Date() });\n }\n\n /** Deletes a value with given id. */\n public deleteValue(id: string) {\n // istanbul ignore else\n if (this._values.has(id)) {\n this.deleteExistingEntry(id, false);\n }\n }\n\n /**\n * Get all values currently in this storage.\n *\n * **Note:** requesting values with this method **doesn't**\n * update their last used times.\n */\n public get values(): T[] {\n const values = new Array<T>();\n for (const v of this._values.values()) {\n values.push(v.value);\n }\n return values;\n }\n}\n\n/**\n * Configuration properties for [[FactoryBasedTemporaryStorage]].\n * @internal\n */\nexport interface FactoryBasedTemporaryStorageProps<T> extends TemporaryStorageProps<T> {\n /** A factory method that creates a stored value given it's identifier */\n factory: (id: string, onValueUsed: () => void) => T;\n}\n\n/**\n * Storage for values that get removed from it after being unused (not-requested\n * for a specified amount of time).\n *\n * @internal\n */\nexport class FactoryBasedTemporaryStorage<T> extends TemporaryStorage<T> {\n public override readonly props: FactoryBasedTemporaryStorageProps<T>;\n\n /**\n * Constructor. Creates the storage using supplied params.\n */\n constructor(props: FactoryBasedTemporaryStorageProps<T>) {\n super(props);\n this.props = props;\n }\n\n /**\n * Get a value from the storage. If the value with the specified id\n * doesn't exist, it gets created.\n *\n * **Note:** requesting a value with this method updates it's last used time.\n */\n public override getValue(id: string): T {\n const existingValue = super.getValue(id);\n if (existingValue) {\n return existingValue;\n }\n\n const value = this.props.factory(id, () => this.notifyValueUsed(id));\n this.addValue(id, value);\n return value;\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/presentation-backend",
|
|
3
|
-
"version": "5.0.0-dev.
|
|
3
|
+
"version": "5.0.0-dev.49",
|
|
4
4
|
"description": "Backend of iTwin.js Presentation library",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"repository": {
|
|
@@ -23,12 +23,12 @@
|
|
|
23
23
|
"main": "lib/cjs/presentation-backend.js",
|
|
24
24
|
"typings": "lib/cjs/presentation-backend",
|
|
25
25
|
"peerDependencies": {
|
|
26
|
-
"@itwin/core-
|
|
27
|
-
"@itwin/core-
|
|
28
|
-
"@itwin/core-common": "5.0.0-dev.
|
|
29
|
-
"@itwin/core-
|
|
30
|
-
"@itwin/ecschema-metadata": "5.0.0-dev.
|
|
31
|
-
"@itwin/presentation-common": "5.0.0-dev.
|
|
26
|
+
"@itwin/core-quantity": "5.0.0-dev.49",
|
|
27
|
+
"@itwin/core-backend": "5.0.0-dev.49",
|
|
28
|
+
"@itwin/core-common": "5.0.0-dev.49",
|
|
29
|
+
"@itwin/core-bentley": "5.0.0-dev.49",
|
|
30
|
+
"@itwin/ecschema-metadata": "5.0.0-dev.49",
|
|
31
|
+
"@itwin/presentation-common": "5.0.0-dev.49"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@itwin/eslint-plugin": "5.0.0-dev.1",
|
|
@@ -41,7 +41,7 @@
|
|
|
41
41
|
"@types/faker": "^4.1.0",
|
|
42
42
|
"@types/lolex": "^2.1.2",
|
|
43
43
|
"@types/mocha": "^10.0.6",
|
|
44
|
-
"@types/node": "~20.
|
|
44
|
+
"@types/node": "~20.17.0",
|
|
45
45
|
"@types/object-hash": "^1.3.0",
|
|
46
46
|
"@types/semver": "7.3.10",
|
|
47
47
|
"@types/sinon": "^17.0.2",
|
|
@@ -66,13 +66,13 @@
|
|
|
66
66
|
"source-map-support": "^0.5.6",
|
|
67
67
|
"typemoq": "^2.1.0",
|
|
68
68
|
"typescript": "~5.6.2",
|
|
69
|
-
"@itwin/build-tools": "5.0.0-dev.
|
|
70
|
-
"@itwin/core-backend": "5.0.0-dev.
|
|
71
|
-
"@itwin/core-
|
|
72
|
-
"@itwin/
|
|
73
|
-
"@itwin/core-quantity": "5.0.0-dev.
|
|
74
|
-
"@itwin/
|
|
75
|
-
"@itwin/presentation-common": "5.0.0-dev.
|
|
69
|
+
"@itwin/build-tools": "5.0.0-dev.49",
|
|
70
|
+
"@itwin/core-backend": "5.0.0-dev.49",
|
|
71
|
+
"@itwin/core-common": "5.0.0-dev.49",
|
|
72
|
+
"@itwin/ecschema-metadata": "5.0.0-dev.49",
|
|
73
|
+
"@itwin/core-quantity": "5.0.0-dev.49",
|
|
74
|
+
"@itwin/core-bentley": "5.0.0-dev.49",
|
|
75
|
+
"@itwin/presentation-common": "5.0.0-dev.49"
|
|
76
76
|
},
|
|
77
77
|
"dependencies": {
|
|
78
78
|
"object-hash": "^1.3.1",
|