@itwin/core-backend 4.5.0-dev.3 → 4.5.0-dev.32
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/LICENSE.md +1 -1
- package/lib/cjs/BackendHubAccess.d.ts +1 -1
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts +4 -3
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +37 -28
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +3 -1
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +2 -2
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/Element.d.ts +6 -0
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +7 -1
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +32 -27
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +153 -28
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +0 -2
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +0 -4
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +3 -0
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/Material.js +1 -1
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/TileStorage.d.ts.map +1 -1
- package/lib/cjs/TileStorage.js +9 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/rpc/web/logging.d.ts.map +1 -1
- package/lib/cjs/rpc/web/logging.js +3 -2
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/response.d.ts.map +1 -1
- package/lib/cjs/rpc/web/response.js +16 -0
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js +12 -13
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/package.json +13 -13
package/lib/cjs/IModelHost.d.ts
CHANGED
|
@@ -236,8 +236,6 @@ export declare class IModelHost {
|
|
|
236
236
|
* returned by this method may change over time throughout the course of a session.
|
|
237
237
|
*/
|
|
238
238
|
static getAccessToken(): Promise<AccessToken>;
|
|
239
|
-
/** @internal */
|
|
240
|
-
static flushLog(): void;
|
|
241
239
|
private static syncNativeLogLevels;
|
|
242
240
|
private static loadNative;
|
|
243
241
|
/** @internal */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHost.d.ts","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":"AAIA;;GAEG;AAGH,OAAO,YAAY,CAAC;AAGpB,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAE,cAAc,EAAiB,MAAM,0BAA0B,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAU,OAAO,EAAkB,UAAU,EAAwB,OAAO,EAAmB,MAAM,qBAAqB,CAAC;AAC/I,OAAO,EAAE,mBAAmB,EAA8B,YAAY,EAAE,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAEjH,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAetD,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAkB,SAAS,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AAQjF,gBAAgB;AAChB,MAAM,WAAW,iCAAiC;IAChD,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAA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AY,CAEhD;IAED,8DAA8D;IAC9D,WAAkB,gBAAgB,IAAI,YAAY,CAEjD;IAED,+BAA+B;IAC/B,WAAkB,MAAM,IAAI,YAAY,CAEvC;CACF;AAED;;;;GAIG;AACH,8BAAsB,gBAAgB;IACpC;;;OAGG;IACI,aAAa,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAC1D;;;;OAIG;IACI,UAAU,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;IAO1C;;;OAGG;IACI,kBAAkB,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IACjE;;;;OAIG;IACI,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,MAAM;CAOnD"}
|
package/lib/cjs/IModelHost.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelHost.js","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yFAAyF;AACzF,sBAAoB,CAAC,mCAAmC;AAExD,yBAAyB;AACzB,4BAA0B,CAAC,yJAAyJ;AACpL,8DAAyE;AACzE,oEAAyF;AACzF,sDAA+I;AAC/I,oDAAiH;AACjH,sEAAyE;AACzE,oEAA2D;AAE3D,mEAAgE;AAChE,mDAAgD;AAChD,yDAAsD;AACtD,+CAA4C;AAC5C,iEAA8D;AAC9D,2DAAwD;AACxD,qDAAkD;AAClD,6CAA0C;AAC1C,gEAA6D;AAC7D,oEAAiE;AACjE,oEAAiE;AACjE,4EAAyE;AACzE,sDAAmD;AACnD,6CAAoD;AACpD,+CAA4C;AAC5C,mDAAyF;AACzF,iEAA8D;AAC9D,qDAAiF;AACjF,yCAAsC;AACtC,+BAAuD;AAEvD,MAAM,cAAc,GAAG,6CAAqB,CAAC,UAAU,CAAC;AAkJxD;;GAEG;AACH,MAAa,uBAAuB;IAApC;QAqBE,gBAAgB;QACT,2BAAsB,GAAG,uBAAuB,CAAC,yBAAyB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UAAU,CAAC,OAAe;QAC/B,MAAM,gBAAgB,GAAuB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACzE,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,OAAO,eAAe,CAAC,CAAC;SACzE;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD;;;OAGG;IACI,kBAAkB,CAAC,UAAkB,IAAwB,OAAO,UAAU,CAAC,CAAC,CAAC;IACxF;;;;OAIG;IACI,eAAe,CAAC,UAAkB;QACvC,MAAM,gBAAgB,GAAuB,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjF,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC;SAC5E;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAnCD,4CAmCC","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 IModelHost\r\n */\r\n\r\n// To avoid circular load errors, the \"Element\" classes must be loaded before IModelHost.\r\nimport \"./IModelDb\"; // DO NOT REMOVE OR MOVE THIS LINE!\r\n\r\nimport * as os from \"os\";\r\nimport \"reflect-metadata\"; // this has to be before @itwin/object-storage-* and @itwin/cloud-agnostic-core imports because those packages contain decorators that use this polyfill.\r\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\r\nimport { DependenciesConfig, Types as ExtensionTypes } from \"@itwin/cloud-agnostic-core\";\r\nimport { AccessToken, assert, BeEvent, DbResult, Guid, GuidString, IModelStatus, Logger, Mutable, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient, BentleyStatus, IModelError, LocalDirName, SessionProps } from \"@itwin/core-common\";\r\nimport { AzureServerStorageBindings } from \"@itwin/object-storage-azure\";\r\nimport { ServerStorage } from \"@itwin/object-storage-core\";\r\nimport { BackendHubAccess } from \"./BackendHubAccess\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { BisCoreSchema } from \"./BisCoreSchema\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { FunctionalSchema } from \"./domains/FunctionalSchema\";\r\nimport { GenericSchema } from \"./domains/GenericSchema\";\r\nimport { GeoCoordConfig } from \"./GeoCoordConfig\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { DevToolsRpcImpl } from \"./rpc-impl/DevToolsRpcImpl\";\r\nimport { IModelReadRpcImpl } from \"./rpc-impl/IModelReadRpcImpl\";\r\nimport { IModelTileRpcImpl } from \"./rpc-impl/IModelTileRpcImpl\";\r\nimport { SnapshotIModelRpcImpl } from \"./rpc-impl/SnapshotIModelRpcImpl\";\r\nimport { WipRpcImpl } from \"./rpc-impl/WipRpcImpl\";\r\nimport { initializeRpcBackend } from \"./RpcBackend\";\r\nimport { TileStorage } from \"./TileStorage\";\r\nimport { BaseSettings, SettingDictionary, SettingsPriority } from \"./workspace/Settings\";\r\nimport { SettingsSchemas } from \"./workspace/SettingsSchemas\";\r\nimport { ITwinWorkspace, Workspace, WorkspaceOpts } from \"./workspace/Workspace\";\r\nimport { Container } from \"inversify\";\r\nimport { join, normalize as normalizeDir } from \"path\";\r\n\r\nconst loggerCategory = BackendLoggerCategory.IModelHost;\r\n\r\n// cspell:ignore nodereport fatalerror apicall alicloud rpcs inversify\r\n\r\n/** @internal */\r\nexport interface CrashReportingConfigNameValuePair {\r\n name: string;\r\n value: string;\r\n}\r\n\r\n/** Configuration of the crash-reporting system.\r\n * @internal\r\n */\r\nexport interface CrashReportingConfig {\r\n /** The directory to which *.dmp and/or iModelJsNativeCrash*.properties.txt files are written. This directory will be created if it does not already exist. */\r\n crashDir: string;\r\n /** max # .dmp files that may exist in crashDir. The default is 50. */\r\n maxDumpsInDir?: number;\r\n /** Enable crash-dumps? If so, .dmp and .properties.txt files will be generated and written to crashDir in the event of an unhandled native-code exception. If not, only .properties.txt files will be written. The default is false. */\r\n enableCrashDumps?: boolean;\r\n /** If enableCrashDumps is true, do you want a full-memory dump? Defaults to false. */\r\n wantFullMemoryDumps?: boolean;\r\n /** Enable Node.js crash reporting? If so, report files will be generated in the event of an unhandled exception or fatal error and written to crashDir. The default is false. */\r\n enableNodeReport?: boolean;\r\n /** Additional name, value pairs to write to iModelJsNativeCrash*.properties.txt file in the event of a crash. */\r\n params?: CrashReportingConfigNameValuePair[];\r\n /** Run this .js file to process .dmp and Node.js crash reporting .json files in the event of a crash.\r\n * This script will be executed with a single command-line parameter: the name of the dump or Node.js report file.\r\n * In the case of a dump file, there will be a second file with the same basename and the extension \".properties.txt\".\r\n * Since it runs in a separate process, this script will have no access to the Javascript\r\n * context of the exiting backend. No default.\r\n */\r\n dumpProcessorScriptFileName?: string;\r\n /** Upload crash dump and node-reports to Bentley's crash-reporting service? Defaults to false */\r\n uploadToBentley?: boolean;\r\n}\r\n\r\n/** @beta */\r\nexport interface AzureBlobStorageCredentials {\r\n account: string;\r\n accessKey: string;\r\n baseUrl?: string;\r\n}\r\n\r\n/**\r\n * Options for [[IModelHost.startup]]\r\n * @public\r\n */\r\nexport interface IModelHostOptions {\r\n /**\r\n * The name of the *Profile* subdirectory of [[cacheDir]] for this process. If not present, \"default\" is used.\r\n * @see [[IModelHost.profileName]]\r\n * @beta\r\n */\r\n profileName?: string;\r\n\r\n /**\r\n * Root of the directory holding all the files that iTwin.js caches\r\n * - If not specified at startup a platform specific default is used -\r\n * - Windows: $(HOMEDIR)/AppData/Local/iModelJs/\r\n * - Mac/iOS: $(HOMEDIR)/Library/Caches/iModelJs/\r\n * - Linux: $(HOMEDIR)/.cache/iModelJs/\r\n * where $(HOMEDIR) is documented [here](https://nodejs.org/api/os.html#os_os_homedir)\r\n * - if specified, ensure it is set to a folder with read/write access.\r\n * @see [[IModelHost.cacheDir]] for the value it's set to after startup\r\n */\r\n cacheDir?: LocalDirName;\r\n\r\n /** The directory where application assets are found. */\r\n appAssetsDir?: LocalDirName;\r\n\r\n /**\r\n * Options for creating the [[Workspace]]\r\n * @beta\r\n */\r\n workspace?: WorkspaceOpts;\r\n\r\n /**\r\n * The kind of iModel hub server to use.\r\n * @internal\r\n */\r\n hubAccess?: BackendHubAccess;\r\n\r\n /** The Azure blob storage credentials to use for the tile cache service. If omitted and no external service implementation is provided, a local cache will be used.\r\n * @beta\r\n */\r\n tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n\r\n /**\r\n * @beta\r\n * @note A reference implementation is set for AzureServerStorage from @itwin/object-storage-azure if [[tileCacheAzureCredentials]] property is set. To supply a different implementation for any service provider (such as AWS),\r\n * set this property with a custom ServerStorage.\r\n */\r\n tileCacheStorage?: ServerStorage;\r\n\r\n /** The maximum size in bytes to which a local sqlite database used for caching tiles can grow before it is purged of least-recently-used tiles.\r\n * The local cache is used only if an external cache has not been configured via [[tileCacheStorage]], and [[tileCacheAzureCredentials]].\r\n * Defaults to 1 GB. Must be an unsigned integer. A value of zero disables the local cache entirely.\r\n * @beta\r\n */\r\n maxTileCacheDbSize?: number;\r\n\r\n /** Whether to restrict tile cache URLs by client IP address (if available).\r\n * @beta\r\n */\r\n restrictTileUrlsByClientIp?: boolean;\r\n\r\n /** Whether to enable OpenTelemetry tracing.\r\n * Defaults to `false`.\r\n */\r\n enableOpenTelemetry?: boolean;\r\n\r\n /** Whether to compress cached tiles.\r\n * Defaults to `true`.\r\n */\r\n compressCachedTiles?: boolean;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileTreeProps]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileTreeRequestTimeout?: number;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileContent]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileContentRequestTimeout?: number;\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds.\r\n * @internal\r\n */\r\n logTileLoadTimeThreshold?: number;\r\n\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold.\r\n * @internal\r\n */\r\n logTileSizeThreshold?: number;\r\n\r\n /** Crash-reporting configuration\r\n * @internal\r\n */\r\n crashReportingConfig?: CrashReportingConfig;\r\n\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n authorizationClient?: AuthorizationClient;\r\n}\r\n\r\n/** Configuration of core-backend.\r\n * @public\r\n */\r\nexport class IModelHostConfiguration implements IModelHostOptions {\r\n public static defaultTileRequestTimeout = 20 * 1000;\r\n public static defaultLogTileLoadTimeThreshold = 40;\r\n public static defaultLogTileSizeThreshold = 20 * 1000000;\r\n /** @internal */\r\n public static defaultMaxTileCacheDbSize = 1024 * 1024 * 1024;\r\n\r\n public appAssetsDir?: LocalDirName;\r\n public cacheDir?: LocalDirName;\r\n\r\n /** @beta */\r\n public workspace?: WorkspaceOpts;\r\n /** @internal */\r\n public hubAccess?: BackendHubAccess;\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n public authorizationClient?: AuthorizationClient;\r\n /** @beta */\r\n public restrictTileUrlsByClientIp?: boolean;\r\n public compressCachedTiles?: boolean;\r\n /** @beta */\r\n public tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n /** @internal */\r\n public tileTreeRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public tileContentRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public logTileLoadTimeThreshold = IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\r\n /** @internal */\r\n public logTileSizeThreshold = IModelHostConfiguration.defaultLogTileSizeThreshold;\r\n /** @internal */\r\n public crashReportingConfig?: CrashReportingConfig;\r\n}\r\n\r\n/**\r\n * Settings for `IModelHost.appWorkspace`.\r\n * @note this includes the default dictionary from the SettingsSpecRegistry\r\n */\r\nclass ApplicationSettings extends BaseSettings {\r\n private _remove?: VoidFunction;\r\n protected override verifyPriority(priority: SettingsPriority) {\r\n if (priority >= SettingsPriority.iModel) // iModel settings may not appear in ApplicationSettings\r\n throw new Error(\"Use IModelSettings\");\r\n }\r\n private updateDefaults() {\r\n const defaults: SettingDictionary = {};\r\n for (const [schemaName, val] of SettingsSchemas.allSchemas) {\r\n if (val.default)\r\n defaults[schemaName] = val.default;\r\n }\r\n this.addDictionary(\"_default_\", 0 as SettingsPriority, defaults);\r\n }\r\n\r\n public constructor() {\r\n super();\r\n this._remove = SettingsSchemas.onSchemaChanged.addListener(() => this.updateDefaults());\r\n this.updateDefaults();\r\n }\r\n\r\n public override close() {\r\n if (this._remove) {\r\n this._remove();\r\n this._remove = undefined;\r\n }\r\n }\r\n}\r\n\r\n/** IModelHost initializes ($backend) and captures its configuration. A backend must call [[IModelHost.startup]] before using any backend classes.\r\n * See [the learning article]($docs/learning/backend/IModelHost.md)\r\n * @public\r\n */\r\nexport class IModelHost {\r\n private constructor() { }\r\n\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n public static authorizationClient?: AuthorizationClient;\r\n\r\n public static backendVersion = \"\";\r\n private static _profileName: string;\r\n private static _cacheDir = \"\";\r\n private static _appWorkspace?: Workspace;\r\n\r\n private static _platform?: typeof IModelJsNative;\r\n /** @internal */\r\n public static get platform(): typeof IModelJsNative {\r\n if (this._platform === undefined)\r\n throw new Error(\"IModelHost.startup must be called first\");\r\n return this._platform;\r\n }\r\n\r\n public static configuration?: IModelHostOptions;\r\n\r\n /**\r\n * The name of the *Profile* directory (a subdirectory of \"[[cacheDir]]/profiles/\") for this process.\r\n *\r\n * The *Profile* directory is used to cache data that is specific to a type-of-usage of the iTwin.js library.\r\n * It is important that information in the profile cache be consistent but isolated across sessions (i.e.\r\n * data for a profile is maintained between runs, but each profile is completely independent and\r\n * unaffected by the presence ot use of others.)\r\n * @note **Only one process at a time may be using a given profile**, and an exception will be thrown by [[startup]]\r\n * if a second process attempts to use the same profile.\r\n * @beta\r\n */\r\n public static get profileName(): string {\r\n return this._profileName;\r\n }\r\n\r\n /** The full path of the Profile directory.\r\n * @see [[profileName]]\r\n * @beta\r\n */\r\n public static get profileDir(): LocalDirName {\r\n return join(this._cacheDir, \"profiles\", this._profileName);\r\n }\r\n\r\n /** Event raised during startup to allow loading settings data */\r\n public static readonly onWorkspaceStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just after the backend IModelHost was started */\r\n public static readonly onAfterStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just before the backend IModelHost is to be shut down */\r\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\r\n\r\n /** @internal */\r\n public static readonly session: Mutable<SessionProps> = { applicationId: \"2686\", applicationVersion: \"1.0.0\", sessionId: \"\" };\r\n\r\n /** A uniqueId for this session */\r\n public static get sessionId() { return this.session.sessionId; }\r\n public static set sessionId(id: GuidString) { this.session.sessionId = id; }\r\n\r\n /** The Id of this application - needs to be set only if it is an agent application. The applicationId will otherwise originate at the frontend. */\r\n public static get applicationId() { return this.session.applicationId; }\r\n public static set applicationId(id: string) { this.session.applicationId = id; }\r\n\r\n /** The version of this application - needs to be set if is an agent application. The applicationVersion will otherwise originate at the frontend. */\r\n public static get applicationVersion() { return this.session.applicationVersion; }\r\n public static set applicationVersion(version: string) { this.session.applicationVersion = version; }\r\n\r\n /** A string that can identify the current user to other users when collaborating. */\r\n public static userMoniker = \"unknown\";\r\n\r\n /** Root directory holding files that iTwin.js caches */\r\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\r\n\r\n /** The application [[Workspace]] for this `IModelHost`\r\n * @note this `Workspace` only holds [[WorkspaceContainer]]s and [[Settings]] scoped to the currently loaded application(s).\r\n * All organization, iTwin, and iModel based containers or settings must be accessed through [[IModelDb.workspace]] and\r\n * attempting to add them to this Workspace will fail.\r\n * @beta\r\n */\r\n public static get appWorkspace(): Workspace { return this._appWorkspace!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** The optional [[FileNameResolver]] that resolves keys and partial file names for snapshot iModels. */\r\n public static snapshotFileNameResolver?: FileNameResolver;\r\n\r\n /** Get the current access token for this IModelHost, or a blank string if none is available.\r\n * @note for web backends, this will *always* return a blank string because the backend itself has no token (but never needs one either.)\r\n * For all IpcHosts, where this backend is servicing a single frontend, this will be the user's token. For ElectronHost, the backend\r\n * obtains the token and forwards it to the frontend.\r\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\r\n * returned by this method may change over time throughout the course of a session.\r\n */\r\n public static async getAccessToken(): Promise<AccessToken> {\r\n try {\r\n return (await IModelHost.authorizationClient?.getAccessToken()) ?? \"\";\r\n } catch (e) {\r\n return \"\";\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static flushLog() {\r\n return IModelHost.platform.flushLog();\r\n }\r\n\r\n private static syncNativeLogLevels() {\r\n this.platform.clearLogLevelCache();\r\n }\r\n private static loadNative(options: IModelHostOptions) {\r\n if (undefined !== this._platform)\r\n return;\r\n\r\n this._platform = ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") as typeof IModelJsNative : NativeLibrary.load();\r\n this._platform.logger = Logger;\r\n Logger.logLevelChangedFn = () => IModelHost.syncNativeLogLevels(); // the arrow function exists only so that it can be spied in tests\r\n\r\n if (options.crashReportingConfig && options.crashReportingConfig.crashDir && !ProcessDetector.isElectronAppBackend && !ProcessDetector.isMobileAppBackend) {\r\n this.platform.setCrashReporting(options.crashReportingConfig);\r\n\r\n Logger.logTrace(loggerCategory, \"Configured crash reporting\", {\r\n enableCrashDumps: options.crashReportingConfig?.enableCrashDumps,\r\n wantFullMemoryDumps: options.crashReportingConfig?.wantFullMemoryDumps,\r\n enableNodeReport: options.crashReportingConfig?.enableNodeReport,\r\n uploadToBentley: options.crashReportingConfig?.uploadToBentley,\r\n });\r\n\r\n if (options.crashReportingConfig.enableNodeReport) {\r\n if (process.report !== undefined) {\r\n process.report.reportOnFatalError = true;\r\n process.report.reportOnUncaughtException = true;\r\n process.report.directory = options.crashReportingConfig.crashDir;\r\n Logger.logTrace(loggerCategory, \"Configured Node.js crash reporting\");\r\n } else {\r\n Logger.logWarning(loggerCategory, \"Unable to configure Node.js crash reporting\");\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static tileStorage?: TileStorage;\r\n\r\n private static _hubAccess?: BackendHubAccess;\r\n /** @internal */\r\n public static setHubAccess(hubAccess: BackendHubAccess | undefined) { this._hubAccess = hubAccess; }\r\n\r\n /** get the current hubAccess, if present.\r\n * @internal\r\n */\r\n public static getHubAccess(): BackendHubAccess | undefined { return this._hubAccess; }\r\n\r\n /** Provides access to the IModelHub for this IModelHost\r\n * @internal\r\n * @note If [[IModelHostOptions.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.\r\n * To determine whether one is present, use [[getHubAccess]].\r\n */\r\n public static get hubAccess(): BackendHubAccess {\r\n if (IModelHost._hubAccess === undefined)\r\n throw new IModelError(IModelStatus.BadRequest, \"No BackendHubAccess supplied in IModelHostOptions\");\r\n return IModelHost._hubAccess;\r\n }\r\n\r\n private static initializeWorkspace(configuration: IModelHostOptions) {\r\n const settingAssets = join(KnownLocations.packageAssetsDir, \"Settings\");\r\n SettingsSchemas.addDirectory(join(settingAssets, \"Schemas\"));\r\n this._appWorkspace = new ITwinWorkspace(new ApplicationSettings(), configuration.workspace);\r\n\r\n // Create the CloudCache for Workspaces. This will fail if another process is already using the same profile.\r\n try {\r\n this.appWorkspace.getCloudCache();\r\n } catch (e: any) {\r\n throw (e.errorNumber === DbResult.BE_SQLITE_BUSY) ? new IModelError(DbResult.BE_SQLITE_BUSY, `Profile [${this.profileDir}] is already in use by another process`) : e;\r\n }\r\n\r\n this.appWorkspace.settings.addDirectory(settingAssets, SettingsPriority.defaults);\r\n\r\n GeoCoordConfig.onStartup();\r\n // allow applications to load their default settings\r\n this.onWorkspaceStartup.raiseEvent();\r\n }\r\n\r\n private static _isValid = false;\r\n\r\n /** true between a successful call to [[startup]] and before [[shutdown]] */\r\n public static get isValid() {\r\n return IModelHost._isValid;\r\n }\r\n\r\n /** This method must be called before any iTwin.js services are used.\r\n * @param options Host configuration data.\r\n * Raises [[onAfterStartup]].\r\n * @see [[shutdown]].\r\n */\r\n public static async startup(options?: IModelHostOptions): Promise<void> {\r\n if (this._isValid)\r\n return; // we're already initialized\r\n this._isValid = true;\r\n\r\n options = options ?? {};\r\n if (this.sessionId === \"\")\r\n this.sessionId = Guid.createValue();\r\n\r\n this.authorizationClient = options.authorizationClient;\r\n\r\n this.backendVersion = require(\"../../package.json\").version; // eslint-disable-line @typescript-eslint/no-var-requires\r\n initializeRpcBackend(options.enableOpenTelemetry);\r\n\r\n this.loadNative(options);\r\n this.setupCacheDir(options);\r\n this.initializeWorkspace(options);\r\n\r\n BriefcaseManager.initialize(join(this._cacheDir, \"imodels\"));\r\n\r\n [\r\n IModelReadRpcImpl,\r\n IModelTileRpcImpl,\r\n SnapshotIModelRpcImpl,\r\n WipRpcImpl,\r\n DevToolsRpcImpl,\r\n ].forEach((rpc) => rpc.register()); // register all of the RPC implementations\r\n\r\n [\r\n BisCoreSchema,\r\n GenericSchema,\r\n FunctionalSchema,\r\n ].forEach((schema) => schema.registerSchema()); // register all of the schemas\r\n\r\n if (undefined !== options.hubAccess)\r\n this._hubAccess = options.hubAccess;\r\n\r\n this.configuration = options;\r\n this.setupTileCache();\r\n\r\n process.once(\"beforeExit\", IModelHost.shutdown);\r\n this.onAfterStartup.raiseEvent();\r\n }\r\n\r\n private static setupCacheDir(configuration: IModelHostOptions) {\r\n this._cacheDir = normalizeDir(configuration.cacheDir ?? NativeLibrary.defaultCacheDir);\r\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\r\n\r\n this._profileName = configuration.profileName ?? \"default\";\r\n Logger.logInfo(loggerCategory, `cacheDir: [${this.cacheDir}], profileDir: [${this.profileDir}]`);\r\n }\r\n\r\n /** This method must be called when an iTwin.js host is shut down. Raises [[onBeforeShutdown]] */\r\n public static async shutdown(this: void): Promise<void> {\r\n // Note: This method is set as a node listener where `this` is unbound. Call private method to\r\n // ensure `this` is correct. Don't combine these methods.\r\n return IModelHost.doShutdown();\r\n }\r\n\r\n private static async doShutdown() {\r\n if (!this._isValid)\r\n return;\r\n\r\n this._isValid = false;\r\n this.onBeforeShutdown.raiseEvent();\r\n this.configuration = undefined;\r\n this.tileStorage = undefined;\r\n this._appWorkspace?.close();\r\n this._appWorkspace = undefined;\r\n\r\n CloudSqlite.CloudCaches.destroy();\r\n process.removeListener(\"beforeExit\", IModelHost.shutdown);\r\n }\r\n\r\n /**\r\n * Add or update a property that should be included in a crash report.\r\n * @internal\r\n */\r\n public static setCrashReportProperty(name: string, value: string): void {\r\n this.platform.setCrashReportProperty(name, value);\r\n }\r\n\r\n /**\r\n * Remove a previously defined property so that will not be included in a crash report.\r\n * @internal\r\n */\r\n public static removeCrashReportProperty(name: string): void {\r\n this.platform.setCrashReportProperty(name, undefined);\r\n }\r\n\r\n /**\r\n * Get all properties that will be included in a crash report.\r\n * @internal\r\n */\r\n public static getCrashReportProperties(): CrashReportingConfigNameValuePair[] {\r\n return this.platform.getCrashReportProperties();\r\n }\r\n\r\n /** The directory where application assets may be found */\r\n public static get appAssetsDir(): string | undefined {\r\n return undefined !== IModelHost.configuration ? IModelHost.configuration.appAssetsDir : undefined;\r\n }\r\n\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileTreeProps should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileTreeRequestTimeout(): number {\r\n return IModelHost.configuration?.tileTreeRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileContent should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileContentRequestTimeout(): number {\r\n return IModelHost.configuration?.tileContentRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds. */\r\n public static get logTileLoadTimeThreshold(): number {\r\n return IModelHost.configuration?.logTileLoadTimeThreshold ?? IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\r\n }\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold. */\r\n public static get logTileSizeThreshold(): number {\r\n return IModelHost.configuration?.logTileSizeThreshold ?? IModelHostConfiguration.defaultLogTileSizeThreshold;\r\n }\r\n\r\n /** Whether external tile caching is active.\r\n * @internal\r\n */\r\n public static get usingExternalTileCache(): boolean {\r\n return undefined !== IModelHost.tileStorage;\r\n }\r\n\r\n /** Whether to restrict tile cache URLs by client IP address.\r\n * @internal\r\n */\r\n public static get restrictTileUrlsByClientIp(): boolean {\r\n return undefined !== IModelHost.configuration && (IModelHost.configuration.restrictTileUrlsByClientIp ? true : false);\r\n }\r\n\r\n /** Whether to compress cached tiles.\r\n * @internal\r\n */\r\n public static get compressCachedTiles(): boolean {\r\n return false !== IModelHost.configuration?.compressCachedTiles;\r\n }\r\n\r\n private static setupTileCache() {\r\n assert(undefined !== IModelHost.configuration);\r\n const config = IModelHost.configuration;\r\n const storage = config.tileCacheStorage;\r\n const credentials = config.tileCacheAzureCredentials;\r\n\r\n if (!storage && !credentials) {\r\n this.platform.setMaxTileCacheSize(config.maxTileCacheDbSize ?? IModelHostConfiguration.defaultMaxTileCacheDbSize);\r\n return;\r\n }\r\n\r\n this.platform.setMaxTileCacheSize(0);\r\n if (credentials) {\r\n if (storage)\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot use both Azure and custom cloud storage providers for tile cache.\");\r\n this.setupAzureTileCache(credentials);\r\n }\r\n if (storage)\r\n IModelHost.tileStorage = new TileStorage(storage);\r\n }\r\n\r\n private static setupAzureTileCache(credentials: AzureBlobStorageCredentials) {\r\n const config = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ServerSideStorage: {\r\n dependencyName: \"azure\",\r\n accountName: credentials.account,\r\n accountKey: credentials.accessKey,\r\n baseUrl: credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`,\r\n },\r\n };\r\n const ioc: Container = new Container();\r\n ioc.bind<DependenciesConfig>(ExtensionTypes.dependenciesConfig).toConstantValue(config);\r\n new AzureServerStorageBindings().register(ioc, config.ServerSideStorage);\r\n IModelHost.tileStorage = new TileStorage(ioc.get(ServerStorage));\r\n }\r\n\r\n /** @internal */\r\n public static computeSchemaChecksum(arg: { schemaXmlPath: string, referencePaths: string[], exactMatch?: boolean }): string {\r\n return this.platform.computeSchemaChecksum(arg);\r\n }\r\n}\r\n\r\n/** Information about the platform on which the app is running.\r\n * @public\r\n */\r\nexport class Platform {\r\n /** Get the name of the platform. */\r\n public static get platformName(): \"win32\" | \"linux\" | \"darwin\" | \"ios\" | \"android\" | \"uwp\" {\r\n return process.platform as any;\r\n }\r\n}\r\n\r\n/** Well known directories that may be used by the application.\r\n * @public\r\n */\r\nexport class KnownLocations {\r\n\r\n /** The directory where the imodeljs-native assets are stored. */\r\n public static get nativeAssetsDir(): LocalDirName {\r\n return IModelHost.platform.DgnDb.getAssetsDir();\r\n }\r\n\r\n /** The directory where the core-backend assets are stored. */\r\n public static get packageAssetsDir(): LocalDirName {\r\n return join(__dirname, \"assets\");\r\n }\r\n\r\n /** The temporary directory. */\r\n public static get tmpdir(): LocalDirName {\r\n return os.tmpdir();\r\n }\r\n}\r\n\r\n/** Extend this class to provide custom file name resolution behavior.\r\n * @note Only `tryResolveKey` and/or `tryResolveFileName` need to be overridden as the implementations of `resolveKey` and `resolveFileName` work for most purposes.\r\n * @see [[IModelHost.snapshotFileNameResolver]]\r\n * @public\r\n */\r\nexport abstract class FileNameResolver {\r\n /** Resolve a file name from the specified key.\r\n * @param _fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name or `undefined` if not found.\r\n */\r\n public tryResolveKey(_fileKey: string): string | undefined { return undefined; }\r\n /** Resolve a file name from the specified key.\r\n * @param fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveKey(fileKey: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveKey(fileKey);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${fileKey} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name or `undefined` if not found.\r\n */\r\n public tryResolveFileName(inFileName: string): string | undefined { return inFileName; }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveFileName(inFileName: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveFileName(inFileName);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${inFileName} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"IModelHost.js","sourceRoot":"","sources":["../../src/IModelHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,yFAAyF;AACzF,sBAAoB,CAAC,mCAAmC;AAExD,yBAAyB;AACzB,4BAA0B,CAAC,yJAAyJ;AACpL,8DAAyE;AACzE,oEAAyF;AACzF,sDAA+I;AAC/I,oDAAiH;AACjH,sEAAyE;AACzE,oEAA2D;AAE3D,mEAAgE;AAChE,mDAAgD;AAChD,yDAAsD;AACtD,+CAA4C;AAC5C,iEAA8D;AAC9D,2DAAwD;AACxD,qDAAkD;AAClD,6CAA0C;AAC1C,gEAA6D;AAC7D,oEAAiE;AACjE,oEAAiE;AACjE,4EAAyE;AACzE,sDAAmD;AACnD,6CAAoD;AACpD,+CAA4C;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IG;AACH,MAAsB,gBAAgB;IACpC;;;OAGG;IACI,aAAa,CAAC,QAAgB,IAAwB,OAAO,SAAS,CAAC,CAAC,CAAC;IAChF;;;;OAIG;IACI,UAAU,CAAC,OAAe;QAC/B,MAAM,gBAAgB,GAAuB,IAAI,CAAC,aAAa,CAAC,OAAO,CAAC,CAAC;QACzE,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,OAAO,eAAe,CAAC,CAAC;SACzE;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;IACD;;;OAGG;IACI,kBAAkB,CAAC,UAAkB,IAAwB,OAAO,UAAU,CAAC,CAAC,CAAC;IACxF;;;;OAIG;IACI,eAAe,CAAC,UAAkB;QACvC,MAAM,gBAAgB,GAAuB,IAAI,CAAC,kBAAkB,CAAC,UAAU,CAAC,CAAC;QACjF,IAAI,SAAS,KAAK,gBAAgB,EAAE;YAClC,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,QAAQ,EAAE,GAAG,UAAU,eAAe,CAAC,CAAC;SAC5E;QACD,OAAO,gBAAgB,CAAC;IAC1B,CAAC;CACF;AAnCD,4CAmCC","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 IModelHost\r\n */\r\n\r\n// To avoid circular load errors, the \"Element\" classes must be loaded before IModelHost.\r\nimport \"./IModelDb\"; // DO NOT REMOVE OR MOVE THIS LINE!\r\n\r\nimport * as os from \"os\";\r\nimport \"reflect-metadata\"; // this has to be before @itwin/object-storage-* and @itwin/cloud-agnostic-core imports because those packages contain decorators that use this polyfill.\r\nimport { IModelJsNative, NativeLibrary } from \"@bentley/imodeljs-native\";\r\nimport { DependenciesConfig, Types as ExtensionTypes } from \"@itwin/cloud-agnostic-core\";\r\nimport { AccessToken, assert, BeEvent, DbResult, Guid, GuidString, IModelStatus, Logger, Mutable, ProcessDetector } from \"@itwin/core-bentley\";\r\nimport { AuthorizationClient, BentleyStatus, IModelError, LocalDirName, SessionProps } from \"@itwin/core-common\";\r\nimport { AzureServerStorageBindings } from \"@itwin/object-storage-azure\";\r\nimport { ServerStorage } from \"@itwin/object-storage-core\";\r\nimport { BackendHubAccess } from \"./BackendHubAccess\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { BisCoreSchema } from \"./BisCoreSchema\";\r\nimport { BriefcaseManager } from \"./BriefcaseManager\";\r\nimport { CloudSqlite } from \"./CloudSqlite\";\r\nimport { FunctionalSchema } from \"./domains/FunctionalSchema\";\r\nimport { GenericSchema } from \"./domains/GenericSchema\";\r\nimport { GeoCoordConfig } from \"./GeoCoordConfig\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { DevToolsRpcImpl } from \"./rpc-impl/DevToolsRpcImpl\";\r\nimport { IModelReadRpcImpl } from \"./rpc-impl/IModelReadRpcImpl\";\r\nimport { IModelTileRpcImpl } from \"./rpc-impl/IModelTileRpcImpl\";\r\nimport { SnapshotIModelRpcImpl } from \"./rpc-impl/SnapshotIModelRpcImpl\";\r\nimport { WipRpcImpl } from \"./rpc-impl/WipRpcImpl\";\r\nimport { initializeRpcBackend } from \"./RpcBackend\";\r\nimport { TileStorage } from \"./TileStorage\";\r\nimport { BaseSettings, SettingDictionary, SettingsPriority } from \"./workspace/Settings\";\r\nimport { SettingsSchemas } from \"./workspace/SettingsSchemas\";\r\nimport { ITwinWorkspace, Workspace, WorkspaceOpts } from \"./workspace/Workspace\";\r\nimport { Container } from \"inversify\";\r\nimport { join, normalize as normalizeDir } from \"path\";\r\n\r\nconst loggerCategory = BackendLoggerCategory.IModelHost;\r\n\r\n// cspell:ignore nodereport fatalerror apicall alicloud rpcs inversify\r\n\r\n/** @internal */\r\nexport interface CrashReportingConfigNameValuePair {\r\n name: string;\r\n value: string;\r\n}\r\n\r\n/** Configuration of the crash-reporting system.\r\n * @internal\r\n */\r\nexport interface CrashReportingConfig {\r\n /** The directory to which *.dmp and/or iModelJsNativeCrash*.properties.txt files are written. This directory will be created if it does not already exist. */\r\n crashDir: string;\r\n /** max # .dmp files that may exist in crashDir. The default is 50. */\r\n maxDumpsInDir?: number;\r\n /** Enable crash-dumps? If so, .dmp and .properties.txt files will be generated and written to crashDir in the event of an unhandled native-code exception. If not, only .properties.txt files will be written. The default is false. */\r\n enableCrashDumps?: boolean;\r\n /** If enableCrashDumps is true, do you want a full-memory dump? Defaults to false. */\r\n wantFullMemoryDumps?: boolean;\r\n /** Enable Node.js crash reporting? If so, report files will be generated in the event of an unhandled exception or fatal error and written to crashDir. The default is false. */\r\n enableNodeReport?: boolean;\r\n /** Additional name, value pairs to write to iModelJsNativeCrash*.properties.txt file in the event of a crash. */\r\n params?: CrashReportingConfigNameValuePair[];\r\n /** Run this .js file to process .dmp and Node.js crash reporting .json files in the event of a crash.\r\n * This script will be executed with a single command-line parameter: the name of the dump or Node.js report file.\r\n * In the case of a dump file, there will be a second file with the same basename and the extension \".properties.txt\".\r\n * Since it runs in a separate process, this script will have no access to the Javascript\r\n * context of the exiting backend. No default.\r\n */\r\n dumpProcessorScriptFileName?: string;\r\n /** Upload crash dump and node-reports to Bentley's crash-reporting service? Defaults to false */\r\n uploadToBentley?: boolean;\r\n}\r\n\r\n/** @beta */\r\nexport interface AzureBlobStorageCredentials {\r\n account: string;\r\n accessKey: string;\r\n baseUrl?: string;\r\n}\r\n\r\n/**\r\n * Options for [[IModelHost.startup]]\r\n * @public\r\n */\r\nexport interface IModelHostOptions {\r\n /**\r\n * The name of the *Profile* subdirectory of [[cacheDir]] for this process. If not present, \"default\" is used.\r\n * @see [[IModelHost.profileName]]\r\n * @beta\r\n */\r\n profileName?: string;\r\n\r\n /**\r\n * Root of the directory holding all the files that iTwin.js caches\r\n * - If not specified at startup a platform specific default is used -\r\n * - Windows: $(HOMEDIR)/AppData/Local/iModelJs/\r\n * - Mac/iOS: $(HOMEDIR)/Library/Caches/iModelJs/\r\n * - Linux: $(HOMEDIR)/.cache/iModelJs/\r\n * where $(HOMEDIR) is documented [here](https://nodejs.org/api/os.html#os_os_homedir)\r\n * - if specified, ensure it is set to a folder with read/write access.\r\n * @see [[IModelHost.cacheDir]] for the value it's set to after startup\r\n */\r\n cacheDir?: LocalDirName;\r\n\r\n /** The directory where application assets are found. */\r\n appAssetsDir?: LocalDirName;\r\n\r\n /**\r\n * Options for creating the [[Workspace]]\r\n * @beta\r\n */\r\n workspace?: WorkspaceOpts;\r\n\r\n /**\r\n * The kind of iModel hub server to use.\r\n * @internal\r\n */\r\n hubAccess?: BackendHubAccess;\r\n\r\n /** The Azure blob storage credentials to use for the tile cache service. If omitted and no external service implementation is provided, a local cache will be used.\r\n * @beta\r\n */\r\n tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n\r\n /**\r\n * @beta\r\n * @note A reference implementation is set for AzureServerStorage from @itwin/object-storage-azure if [[tileCacheAzureCredentials]] property is set. To supply a different implementation for any service provider (such as AWS),\r\n * set this property with a custom ServerStorage.\r\n */\r\n tileCacheStorage?: ServerStorage;\r\n\r\n /** The maximum size in bytes to which a local sqlite database used for caching tiles can grow before it is purged of least-recently-used tiles.\r\n * The local cache is used only if an external cache has not been configured via [[tileCacheStorage]], and [[tileCacheAzureCredentials]].\r\n * Defaults to 1 GB. Must be an unsigned integer. A value of zero disables the local cache entirely.\r\n * @beta\r\n */\r\n maxTileCacheDbSize?: number;\r\n\r\n /** Whether to restrict tile cache URLs by client IP address (if available).\r\n * @beta\r\n */\r\n restrictTileUrlsByClientIp?: boolean;\r\n\r\n /** Whether to enable OpenTelemetry tracing.\r\n * Defaults to `false`.\r\n */\r\n enableOpenTelemetry?: boolean;\r\n\r\n /** Whether to compress cached tiles.\r\n * Defaults to `true`.\r\n */\r\n compressCachedTiles?: boolean;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileTreeProps]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileTreeRequestTimeout?: number;\r\n\r\n /** The time, in milliseconds, for which [IModelTileRpcInterface.requestTileContent]($common) should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n tileContentRequestTimeout?: number;\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds.\r\n * @internal\r\n */\r\n logTileLoadTimeThreshold?: number;\r\n\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold.\r\n * @internal\r\n */\r\n logTileSizeThreshold?: number;\r\n\r\n /** Crash-reporting configuration\r\n * @internal\r\n */\r\n crashReportingConfig?: CrashReportingConfig;\r\n\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n authorizationClient?: AuthorizationClient;\r\n}\r\n\r\n/** Configuration of core-backend.\r\n * @public\r\n */\r\nexport class IModelHostConfiguration implements IModelHostOptions {\r\n public static defaultTileRequestTimeout = 20 * 1000;\r\n public static defaultLogTileLoadTimeThreshold = 40;\r\n public static defaultLogTileSizeThreshold = 20 * 1000000;\r\n /** @internal */\r\n public static defaultMaxTileCacheDbSize = 1024 * 1024 * 1024;\r\n\r\n public appAssetsDir?: LocalDirName;\r\n public cacheDir?: LocalDirName;\r\n\r\n /** @beta */\r\n public workspace?: WorkspaceOpts;\r\n /** @internal */\r\n public hubAccess?: BackendHubAccess;\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n public authorizationClient?: AuthorizationClient;\r\n /** @beta */\r\n public restrictTileUrlsByClientIp?: boolean;\r\n public compressCachedTiles?: boolean;\r\n /** @beta */\r\n public tileCacheAzureCredentials?: AzureBlobStorageCredentials;\r\n /** @internal */\r\n public tileTreeRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public tileContentRequestTimeout = IModelHostConfiguration.defaultTileRequestTimeout;\r\n /** @internal */\r\n public logTileLoadTimeThreshold = IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\r\n /** @internal */\r\n public logTileSizeThreshold = IModelHostConfiguration.defaultLogTileSizeThreshold;\r\n /** @internal */\r\n public crashReportingConfig?: CrashReportingConfig;\r\n}\r\n\r\n/**\r\n * Settings for `IModelHost.appWorkspace`.\r\n * @note this includes the default dictionary from the SettingsSpecRegistry\r\n */\r\nclass ApplicationSettings extends BaseSettings {\r\n private _remove?: VoidFunction;\r\n protected override verifyPriority(priority: SettingsPriority) {\r\n if (priority >= SettingsPriority.iModel) // iModel settings may not appear in ApplicationSettings\r\n throw new Error(\"Use IModelSettings\");\r\n }\r\n private updateDefaults() {\r\n const defaults: SettingDictionary = {};\r\n for (const [schemaName, val] of SettingsSchemas.allSchemas) {\r\n if (val.default)\r\n defaults[schemaName] = val.default;\r\n }\r\n this.addDictionary(\"_default_\", 0 as SettingsPriority, defaults);\r\n }\r\n\r\n public constructor() {\r\n super();\r\n this._remove = SettingsSchemas.onSchemaChanged.addListener(() => this.updateDefaults());\r\n this.updateDefaults();\r\n }\r\n\r\n public override close() {\r\n if (this._remove) {\r\n this._remove();\r\n this._remove = undefined;\r\n }\r\n }\r\n}\r\n\r\n/** IModelHost initializes ($backend) and captures its configuration. A backend must call [[IModelHost.startup]] before using any backend classes.\r\n * See [the learning article]($docs/learning/backend/IModelHost.md)\r\n * @public\r\n */\r\nexport class IModelHost {\r\n private constructor() { }\r\n\r\n /** The AuthorizationClient used to obtain [AccessToken]($bentley)s. */\r\n public static authorizationClient?: AuthorizationClient;\r\n\r\n public static backendVersion = \"\";\r\n private static _profileName: string;\r\n private static _cacheDir = \"\";\r\n private static _appWorkspace?: Workspace;\r\n\r\n private static _platform?: typeof IModelJsNative;\r\n /** @internal */\r\n public static get platform(): typeof IModelJsNative {\r\n if (this._platform === undefined)\r\n throw new Error(\"IModelHost.startup must be called first\");\r\n return this._platform;\r\n }\r\n\r\n public static configuration?: IModelHostOptions;\r\n\r\n /**\r\n * The name of the *Profile* directory (a subdirectory of \"[[cacheDir]]/profiles/\") for this process.\r\n *\r\n * The *Profile* directory is used to cache data that is specific to a type-of-usage of the iTwin.js library.\r\n * It is important that information in the profile cache be consistent but isolated across sessions (i.e.\r\n * data for a profile is maintained between runs, but each profile is completely independent and\r\n * unaffected by the presence ot use of others.)\r\n * @note **Only one process at a time may be using a given profile**, and an exception will be thrown by [[startup]]\r\n * if a second process attempts to use the same profile.\r\n * @beta\r\n */\r\n public static get profileName(): string {\r\n return this._profileName;\r\n }\r\n\r\n /** The full path of the Profile directory.\r\n * @see [[profileName]]\r\n * @beta\r\n */\r\n public static get profileDir(): LocalDirName {\r\n return join(this._cacheDir, \"profiles\", this._profileName);\r\n }\r\n\r\n /** Event raised during startup to allow loading settings data */\r\n public static readonly onWorkspaceStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just after the backend IModelHost was started */\r\n public static readonly onAfterStartup = new BeEvent<() => void>();\r\n\r\n /** Event raised just before the backend IModelHost is to be shut down */\r\n public static readonly onBeforeShutdown = new BeEvent<() => void>();\r\n\r\n /** @internal */\r\n public static readonly session: Mutable<SessionProps> = { applicationId: \"2686\", applicationVersion: \"1.0.0\", sessionId: \"\" };\r\n\r\n /** A uniqueId for this session */\r\n public static get sessionId() { return this.session.sessionId; }\r\n public static set sessionId(id: GuidString) { this.session.sessionId = id; }\r\n\r\n /** The Id of this application - needs to be set only if it is an agent application. The applicationId will otherwise originate at the frontend. */\r\n public static get applicationId() { return this.session.applicationId; }\r\n public static set applicationId(id: string) { this.session.applicationId = id; }\r\n\r\n /** The version of this application - needs to be set if is an agent application. The applicationVersion will otherwise originate at the frontend. */\r\n public static get applicationVersion() { return this.session.applicationVersion; }\r\n public static set applicationVersion(version: string) { this.session.applicationVersion = version; }\r\n\r\n /** A string that can identify the current user to other users when collaborating. */\r\n public static userMoniker = \"unknown\";\r\n\r\n /** Root directory holding files that iTwin.js caches */\r\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\r\n\r\n /** The application [[Workspace]] for this `IModelHost`\r\n * @note this `Workspace` only holds [[WorkspaceContainer]]s and [[Settings]] scoped to the currently loaded application(s).\r\n * All organization, iTwin, and iModel based containers or settings must be accessed through [[IModelDb.workspace]] and\r\n * attempting to add them to this Workspace will fail.\r\n * @beta\r\n */\r\n public static get appWorkspace(): Workspace { return this._appWorkspace!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n\r\n /** The optional [[FileNameResolver]] that resolves keys and partial file names for snapshot iModels. */\r\n public static snapshotFileNameResolver?: FileNameResolver;\r\n\r\n /** Get the current access token for this IModelHost, or a blank string if none is available.\r\n * @note for web backends, this will *always* return a blank string because the backend itself has no token (but never needs one either.)\r\n * For all IpcHosts, where this backend is servicing a single frontend, this will be the user's token. For ElectronHost, the backend\r\n * obtains the token and forwards it to the frontend.\r\n * @note accessTokens expire periodically and are automatically refreshed, if possible. Therefore tokens should not be saved, and the value\r\n * returned by this method may change over time throughout the course of a session.\r\n */\r\n public static async getAccessToken(): Promise<AccessToken> {\r\n try {\r\n return (await IModelHost.authorizationClient?.getAccessToken()) ?? \"\";\r\n } catch (e) {\r\n return \"\";\r\n }\r\n }\r\n\r\n private static syncNativeLogLevels() {\r\n this.platform.clearLogLevelCache();\r\n }\r\n private static loadNative(options: IModelHostOptions) {\r\n if (undefined !== this._platform)\r\n return;\r\n\r\n this._platform = ProcessDetector.isMobileAppBackend ? (process as any)._linkedBinding(\"iModelJsNative\") as typeof IModelJsNative : NativeLibrary.load();\r\n this._platform.logger = Logger;\r\n Logger.logLevelChangedFn = () => IModelHost.syncNativeLogLevels(); // the arrow function exists only so that it can be spied in tests\r\n\r\n if (options.crashReportingConfig && options.crashReportingConfig.crashDir && !ProcessDetector.isElectronAppBackend && !ProcessDetector.isMobileAppBackend) {\r\n this.platform.setCrashReporting(options.crashReportingConfig);\r\n\r\n Logger.logTrace(loggerCategory, \"Configured crash reporting\", {\r\n enableCrashDumps: options.crashReportingConfig?.enableCrashDumps,\r\n wantFullMemoryDumps: options.crashReportingConfig?.wantFullMemoryDumps,\r\n enableNodeReport: options.crashReportingConfig?.enableNodeReport,\r\n uploadToBentley: options.crashReportingConfig?.uploadToBentley,\r\n });\r\n\r\n if (options.crashReportingConfig.enableNodeReport) {\r\n if (process.report !== undefined) {\r\n process.report.reportOnFatalError = true;\r\n process.report.reportOnUncaughtException = true;\r\n process.report.directory = options.crashReportingConfig.crashDir;\r\n Logger.logTrace(loggerCategory, \"Configured Node.js crash reporting\");\r\n } else {\r\n Logger.logWarning(loggerCategory, \"Unable to configure Node.js crash reporting\");\r\n }\r\n }\r\n }\r\n }\r\n\r\n /** @internal */\r\n public static tileStorage?: TileStorage;\r\n\r\n private static _hubAccess?: BackendHubAccess;\r\n /** @internal */\r\n public static setHubAccess(hubAccess: BackendHubAccess | undefined) { this._hubAccess = hubAccess; }\r\n\r\n /** get the current hubAccess, if present.\r\n * @internal\r\n */\r\n public static getHubAccess(): BackendHubAccess | undefined { return this._hubAccess; }\r\n\r\n /** Provides access to the IModelHub for this IModelHost\r\n * @internal\r\n * @note If [[IModelHostOptions.hubAccess]] was undefined when initializing this class, accessing this property will throw an error.\r\n * To determine whether one is present, use [[getHubAccess]].\r\n */\r\n public static get hubAccess(): BackendHubAccess {\r\n if (IModelHost._hubAccess === undefined)\r\n throw new IModelError(IModelStatus.BadRequest, \"No BackendHubAccess supplied in IModelHostOptions\");\r\n return IModelHost._hubAccess;\r\n }\r\n\r\n private static initializeWorkspace(configuration: IModelHostOptions) {\r\n const settingAssets = join(KnownLocations.packageAssetsDir, \"Settings\");\r\n SettingsSchemas.addDirectory(join(settingAssets, \"Schemas\"));\r\n this._appWorkspace = new ITwinWorkspace(new ApplicationSettings(), configuration.workspace);\r\n\r\n // Create the CloudCache for Workspaces. This will fail if another process is already using the same profile.\r\n try {\r\n this.appWorkspace.getCloudCache();\r\n } catch (e: any) {\r\n throw (e.errorNumber === DbResult.BE_SQLITE_BUSY) ? new IModelError(DbResult.BE_SQLITE_BUSY, `Profile [${this.profileDir}] is already in use by another process`) : e;\r\n }\r\n\r\n this.appWorkspace.settings.addDirectory(settingAssets, SettingsPriority.defaults);\r\n\r\n GeoCoordConfig.onStartup();\r\n // allow applications to load their default settings\r\n this.onWorkspaceStartup.raiseEvent();\r\n }\r\n\r\n private static _isValid = false;\r\n\r\n /** true between a successful call to [[startup]] and before [[shutdown]] */\r\n public static get isValid() {\r\n return IModelHost._isValid;\r\n }\r\n\r\n /** This method must be called before any iTwin.js services are used.\r\n * @param options Host configuration data.\r\n * Raises [[onAfterStartup]].\r\n * @see [[shutdown]].\r\n */\r\n public static async startup(options?: IModelHostOptions): Promise<void> {\r\n if (this._isValid)\r\n return; // we're already initialized\r\n this._isValid = true;\r\n\r\n options = options ?? {};\r\n if (this.sessionId === \"\")\r\n this.sessionId = Guid.createValue();\r\n\r\n this.authorizationClient = options.authorizationClient;\r\n\r\n this.backendVersion = require(\"../../package.json\").version; // eslint-disable-line @typescript-eslint/no-var-requires\r\n initializeRpcBackend(options.enableOpenTelemetry);\r\n\r\n this.loadNative(options);\r\n this.setupCacheDir(options);\r\n this.initializeWorkspace(options);\r\n\r\n BriefcaseManager.initialize(join(this._cacheDir, \"imodels\"));\r\n\r\n [\r\n IModelReadRpcImpl,\r\n IModelTileRpcImpl,\r\n SnapshotIModelRpcImpl,\r\n WipRpcImpl,\r\n DevToolsRpcImpl,\r\n ].forEach((rpc) => rpc.register()); // register all of the RPC implementations\r\n\r\n [\r\n BisCoreSchema,\r\n GenericSchema,\r\n FunctionalSchema,\r\n ].forEach((schema) => schema.registerSchema()); // register all of the schemas\r\n\r\n if (undefined !== options.hubAccess)\r\n this._hubAccess = options.hubAccess;\r\n\r\n this.configuration = options;\r\n this.setupTileCache();\r\n\r\n process.once(\"beforeExit\", IModelHost.shutdown);\r\n this.onAfterStartup.raiseEvent();\r\n }\r\n\r\n private static setupCacheDir(configuration: IModelHostOptions) {\r\n this._cacheDir = normalizeDir(configuration.cacheDir ?? NativeLibrary.defaultCacheDir);\r\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\r\n\r\n this._profileName = configuration.profileName ?? \"default\";\r\n Logger.logInfo(loggerCategory, `cacheDir: [${this.cacheDir}], profileDir: [${this.profileDir}]`);\r\n }\r\n\r\n /** This method must be called when an iTwin.js host is shut down. Raises [[onBeforeShutdown]] */\r\n public static async shutdown(this: void): Promise<void> {\r\n // Note: This method is set as a node listener where `this` is unbound. Call private method to\r\n // ensure `this` is correct. Don't combine these methods.\r\n return IModelHost.doShutdown();\r\n }\r\n\r\n private static async doShutdown() {\r\n if (!this._isValid)\r\n return;\r\n\r\n this._isValid = false;\r\n this.onBeforeShutdown.raiseEvent();\r\n this.configuration = undefined;\r\n this.tileStorage = undefined;\r\n this._appWorkspace?.close();\r\n this._appWorkspace = undefined;\r\n\r\n CloudSqlite.CloudCaches.destroy();\r\n process.removeListener(\"beforeExit\", IModelHost.shutdown);\r\n }\r\n\r\n /**\r\n * Add or update a property that should be included in a crash report.\r\n * @internal\r\n */\r\n public static setCrashReportProperty(name: string, value: string): void {\r\n this.platform.setCrashReportProperty(name, value);\r\n }\r\n\r\n /**\r\n * Remove a previously defined property so that will not be included in a crash report.\r\n * @internal\r\n */\r\n public static removeCrashReportProperty(name: string): void {\r\n this.platform.setCrashReportProperty(name, undefined);\r\n }\r\n\r\n /**\r\n * Get all properties that will be included in a crash report.\r\n * @internal\r\n */\r\n public static getCrashReportProperties(): CrashReportingConfigNameValuePair[] {\r\n return this.platform.getCrashReportProperties();\r\n }\r\n\r\n /** The directory where application assets may be found */\r\n public static get appAssetsDir(): string | undefined {\r\n return undefined !== IModelHost.configuration ? IModelHost.configuration.appAssetsDir : undefined;\r\n }\r\n\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileTreeProps should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileTreeRequestTimeout(): number {\r\n return IModelHost.configuration?.tileTreeRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n /** The time, in milliseconds, for which IModelTileRpcInterface.requestTileContent should wait before returning a \"pending\" status.\r\n * @internal\r\n */\r\n public static get tileContentRequestTimeout(): number {\r\n return IModelHost.configuration?.tileContentRequestTimeout ?? IModelHostConfiguration.defaultTileRequestTimeout;\r\n }\r\n\r\n /** The backend will log when a tile took longer to load than this threshold in seconds. */\r\n public static get logTileLoadTimeThreshold(): number {\r\n return IModelHost.configuration?.logTileLoadTimeThreshold ?? IModelHostConfiguration.defaultLogTileLoadTimeThreshold;\r\n }\r\n /** The backend will log when a tile is loaded with a size in bytes above this threshold. */\r\n public static get logTileSizeThreshold(): number {\r\n return IModelHost.configuration?.logTileSizeThreshold ?? IModelHostConfiguration.defaultLogTileSizeThreshold;\r\n }\r\n\r\n /** Whether external tile caching is active.\r\n * @internal\r\n */\r\n public static get usingExternalTileCache(): boolean {\r\n return undefined !== IModelHost.tileStorage;\r\n }\r\n\r\n /** Whether to restrict tile cache URLs by client IP address.\r\n * @internal\r\n */\r\n public static get restrictTileUrlsByClientIp(): boolean {\r\n return undefined !== IModelHost.configuration && (IModelHost.configuration.restrictTileUrlsByClientIp ? true : false);\r\n }\r\n\r\n /** Whether to compress cached tiles.\r\n * @internal\r\n */\r\n public static get compressCachedTiles(): boolean {\r\n return false !== IModelHost.configuration?.compressCachedTiles;\r\n }\r\n\r\n private static setupTileCache() {\r\n assert(undefined !== IModelHost.configuration);\r\n const config = IModelHost.configuration;\r\n const storage = config.tileCacheStorage;\r\n const credentials = config.tileCacheAzureCredentials;\r\n\r\n if (!storage && !credentials) {\r\n this.platform.setMaxTileCacheSize(config.maxTileCacheDbSize ?? IModelHostConfiguration.defaultMaxTileCacheDbSize);\r\n return;\r\n }\r\n\r\n this.platform.setMaxTileCacheSize(0);\r\n if (credentials) {\r\n if (storage)\r\n throw new IModelError(BentleyStatus.ERROR, \"Cannot use both Azure and custom cloud storage providers for tile cache.\");\r\n this.setupAzureTileCache(credentials);\r\n }\r\n if (storage)\r\n IModelHost.tileStorage = new TileStorage(storage);\r\n }\r\n\r\n private static setupAzureTileCache(credentials: AzureBlobStorageCredentials) {\r\n const config = {\r\n // eslint-disable-next-line @typescript-eslint/naming-convention\r\n ServerSideStorage: {\r\n dependencyName: \"azure\",\r\n accountName: credentials.account,\r\n accountKey: credentials.accessKey,\r\n baseUrl: credentials.baseUrl ?? `https://${credentials.account}.blob.core.windows.net`,\r\n },\r\n };\r\n const ioc: Container = new Container();\r\n ioc.bind<DependenciesConfig>(ExtensionTypes.dependenciesConfig).toConstantValue(config);\r\n new AzureServerStorageBindings().register(ioc, config.ServerSideStorage);\r\n IModelHost.tileStorage = new TileStorage(ioc.get(ServerStorage));\r\n }\r\n\r\n /** @internal */\r\n public static computeSchemaChecksum(arg: { schemaXmlPath: string, referencePaths: string[], exactMatch?: boolean }): string {\r\n return this.platform.computeSchemaChecksum(arg);\r\n }\r\n}\r\n\r\n/** Information about the platform on which the app is running.\r\n * @public\r\n */\r\nexport class Platform {\r\n /** Get the name of the platform. */\r\n public static get platformName(): \"win32\" | \"linux\" | \"darwin\" | \"ios\" | \"android\" | \"uwp\" {\r\n return process.platform as any;\r\n }\r\n}\r\n\r\n/** Well known directories that may be used by the application.\r\n * @public\r\n */\r\nexport class KnownLocations {\r\n\r\n /** The directory where the imodeljs-native assets are stored. */\r\n public static get nativeAssetsDir(): LocalDirName {\r\n return IModelHost.platform.DgnDb.getAssetsDir();\r\n }\r\n\r\n /** The directory where the core-backend assets are stored. */\r\n public static get packageAssetsDir(): LocalDirName {\r\n return join(__dirname, \"assets\");\r\n }\r\n\r\n /** The temporary directory. */\r\n public static get tmpdir(): LocalDirName {\r\n return os.tmpdir();\r\n }\r\n}\r\n\r\n/** Extend this class to provide custom file name resolution behavior.\r\n * @note Only `tryResolveKey` and/or `tryResolveFileName` need to be overridden as the implementations of `resolveKey` and `resolveFileName` work for most purposes.\r\n * @see [[IModelHost.snapshotFileNameResolver]]\r\n * @public\r\n */\r\nexport abstract class FileNameResolver {\r\n /** Resolve a file name from the specified key.\r\n * @param _fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name or `undefined` if not found.\r\n */\r\n public tryResolveKey(_fileKey: string): string | undefined { return undefined; }\r\n /** Resolve a file name from the specified key.\r\n * @param fileKey The key that identifies the file name in a `Map` or other similar data structure.\r\n * @returns The resolved file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveKey(fileKey: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveKey(fileKey);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${fileKey} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name or `undefined` if not found.\r\n */\r\n public tryResolveFileName(inFileName: string): string | undefined { return inFileName; }\r\n /** Resolve the input file name, which may be a partial name, into a full path file name.\r\n * @param inFileName The partial file name.\r\n * @returns The resolved full path file name.\r\n * @throws [[IModelError]] if not found.\r\n */\r\n public resolveFileName(inFileName: string): string {\r\n const resolvedFileName: string | undefined = this.tryResolveFileName(inFileName);\r\n if (undefined === resolvedFileName) {\r\n throw new IModelError(IModelStatus.NotFound, `${inFileName} not resolved`);\r\n }\r\n return resolvedFileName;\r\n }\r\n}\r\n"]}
|
package/lib/cjs/IpcHost.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IpcHost.d.ts","sourceRoot":"","sources":["../../src/IpcHost.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EACgC,yBAAyB,EAC7B,mBAAmB,EAAmB,WAAW,EAAE,gBAAgB,
|
|
1
|
+
{"version":3,"file":"IpcHost.d.ts","sourceRoot":"","sources":["../../src/IpcHost.ts"],"names":[],"mappings":"AAIA;;GAEG;AAIH,OAAO,EACgC,yBAAyB,EAC7B,mBAAmB,EAAmB,WAAW,EAAE,gBAAgB,EACxC,cAAc,EAA6C,gBAAgB,EACxI,MAAM,oBAAoB,CAAC;AAC5B,O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AmB,CAAC,CAAC,CAAC,CAAC;IAI/H,gBAAgB;WACF,UAAU,CAAC,CAAC,SAAS,MAAM,gBAAgB,EAAE,SAAS,EAAE,WAAW,GAAG,YAAY,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IAIzJ,gBAAgB;WACF,kBAAkB,CAAC,CAAC,SAAS,MAAM,yBAAyB,EAAE,SAAS,EAAE,WAAW,GAAG,YAAY,EAAE,UAAU,EAAE,CAAC,EAAE,GAAG,IAAI,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAInL;;;;OAIG;WACiB,OAAO,CAAC,GAAG,CAAC,EAAE,WAAW,GAAG,OAAO,CAAC,IAAI,CAAC;IAY7D,mEAAmE;WAC/C,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC;CAI9C;AAED;;;;;;;;;;;GAWG;AACH,8BAAsB,UAAU;IAC9B;;;;;;OAMG;IACH,aAAoB,WAAW,IAAI,MAAM,CAAC;IAE1C;;;;;OAKG;WACW,QAAQ,IAAI,cAAc;CAuBzC;AAkID;;;GAGG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,EAAE,gBAAgB,EAAE,UAAU,EAAE,MAAM,cAAc,EAAE,gBAAgB,CAAC,EAAE,MAAM,GAAG,gBAAgB,CAa9I"}
|
package/lib/cjs/IpcHost.js
CHANGED
|
@@ -175,6 +175,9 @@ class IpcAppHandler extends IpcHandler {
|
|
|
175
175
|
const db = await IModelDb_1.BriefcaseDb.open(args);
|
|
176
176
|
return db.toJSON();
|
|
177
177
|
}
|
|
178
|
+
async openCheckpoint(checkpoint) {
|
|
179
|
+
return (await IModelDb_1.SnapshotDb.openCheckpoint(checkpoint)).getConnectionProps();
|
|
180
|
+
}
|
|
178
181
|
async openStandalone(filePath, openMode, opts) {
|
|
179
182
|
return IModelDb_1.StandaloneDb.openFile(filePath, openMode, opts).getConnectionProps();
|
|
180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AC;IACzD,CAAC;IACM,KAAK,CAAC,iBAAiB,CAAC,GAAW;QACxC,OAAO,mBAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC9D,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,IAAkB;QAC9C,OAAO,uBAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;CACF;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,IAAsB,EAAE,UAAgC,EAAE,gBAAyB;IAC1H,MAAM,QAAQ,GAAG,gBAAgB,IAAI,GAAG,CAAC,CAAC,+DAA+D;IACzG,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC;IACrC,MAAM,gBAAgB,GAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,MAAM,IAAI,KAAK,IAAI,GAAG,IAAI,QAAQ,EAAE;YACtC,QAAQ,GAAG,GAAG,GAAG,QAAQ,CAAC;YAC1B,OAAO,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SAC5B;QACD,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAbD,4DAaC","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 NativeApp\r\n */\r\n\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { assert, BentleyError, IModelStatus, Logger, LogLevel, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n ChangesetIndex, ChangesetIndexAndId, EditingScopeNotifications, getPullChangesIpcChannel, IModelConnectionProps, IModelError, IModelRpcProps,\r\n ipcAppChannels, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketBackend, iTwinChannel,\r\n OpenBriefcaseProps, PullChangesOptions, RemoveFunction, StandaloneOpenOptions, TileTreeContentIds, TxnNotifications,\r\n} from \"@itwin/core-common\";\r\nimport { ProgressFunction, ProgressStatus } from \"./CheckpointManager\";\r\nimport { BriefcaseDb, IModelDb, StandaloneDb } from \"./IModelDb\";\r\nimport { IModelHost, IModelHostOptions } from \"./IModelHost\";\r\nimport { cancelTileContentRequests } from \"./rpc-impl/IModelTileRpcImpl\";\r\n\r\n/**\r\n * Options for [[IpcHost.startup]]\r\n * @public\r\n */\r\nexport interface IpcHostOpts {\r\n iModelHost?: IModelHostOptions;\r\n ipcHost?: {\r\n /** The Ipc socket to use for communications with frontend. Allows undefined only for headless tests. */\r\n socket?: IpcSocketBackend;\r\n\r\n /** don't send stack information on exceptions */\r\n exceptions?: {\r\n noStack?: boolean;\r\n };\r\n };\r\n}\r\n\r\n/**\r\n * Used by applications that have a dedicated backend. IpcHosts may send messages to their corresponding IpcApp.\r\n * @note if either end terminates, the other must too.\r\n * @public\r\n */\r\nexport class IpcHost {\r\n public static noStack = false;\r\n private static _ipc: IpcSocketBackend | undefined;\r\n /** Get the implementation of the [IpcSocketBackend]($common) interface. */\r\n private static get ipc(): IpcSocketBackend { return this._ipc!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n /** Determine whether Ipc is available for this backend. This will only be true if [[startup]] has been called on this class. */\r\n public static get isValid(): boolean { return undefined !== this._ipc; }\r\n\r\n /**\r\n * Send a message to the frontend over an Ipc channel.\r\n * @param channel the name of the channel matching the name registered with [[IpcApp.addListener]].\r\n * @param data The content of the message.\r\n */\r\n public static send(channel: string, ...data: any[]): void {\r\n this.ipc.send(iTwinChannel(channel), ...data);\r\n }\r\n\r\n /**\r\n * Establish a handler for an Ipc channel to receive [[Frontend.invoke]] calls\r\n * @param channel The name of the channel for this handler.\r\n * @param handler A function that supplies the implementation for `channel`\r\n * @note returns A function to call to remove the handler.\r\n */\r\n public static handle(channel: string, handler: (...args: any[]) => Promise<any>): RemoveFunction {\r\n return this.ipc.handle(iTwinChannel(channel), handler);\r\n }\r\n /**\r\n * Establish a handler to receive messages sent via [[IpcApp.send]].\r\n * @param channel The name of the channel for the messages.\r\n * @param listener A function called when messages are sent over `channel`\r\n * @note returns A function to call to remove the listener.\r\n */\r\n public static addListener(channel: string, listener: IpcListener): RemoveFunction {\r\n return this.ipc.addListener(iTwinChannel(channel), listener);\r\n }\r\n /**\r\n * Remove a previously registered listener\r\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\r\n * @param listener The function passed to [[addListener]]\r\n */\r\n public static removeListener(channel: string, listener: IpcListener): void {\r\n this.ipc.removeListener(iTwinChannel(channel), listener);\r\n }\r\n\r\n private static notify(channel: string, briefcase: BriefcaseDb | StandaloneDb, methodName: string, ...args: any[]) {\r\n if (this.isValid)\r\n return this.send(`${channel}/${briefcase.key}`, methodName, ...args);\r\n }\r\n\r\n /** @internal */\r\n public static notifyIpcFrontend<T extends keyof IpcAppNotifications>(methodName: T, ...args: Parameters<IpcAppNotifications[T]>) {\r\n return IpcHost.send(ipcAppChannels.appNotify, methodName, ...args);\r\n }\r\n\r\n /** @internal */\r\n public static notifyTxns<T extends keyof TxnNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<TxnNotifications[T]>) {\r\n this.notify(ipcAppChannels.txns, briefcase, methodName, ...args);\r\n }\r\n\r\n /** @internal */\r\n public static notifyEditingScope<T extends keyof EditingScopeNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<EditingScopeNotifications[T]>) {\r\n this.notify(ipcAppChannels.editingScope, briefcase, methodName, ...args);\r\n }\r\n\r\n /**\r\n * Start the backend of an Ipc app.\r\n * @param opt\r\n * @note this method calls [[IModelHost.startup]] internally.\r\n */\r\n public static async startup(opt?: IpcHostOpts): Promise<void> {\r\n this._ipc = opt?.ipcHost?.socket;\r\n if (opt?.ipcHost?.exceptions?.noStack)\r\n this.noStack = true;\r\n\r\n if (this.isValid) { // for tests, we use IpcHost but don't have a frontend\r\n IpcAppHandler.register();\r\n }\r\n\r\n await IModelHost.startup(opt?.iModelHost);\r\n }\r\n\r\n /** Shutdown IpcHost backend. Also calls [[IModelHost.shutdown]] */\r\n public static async shutdown(): Promise<void> {\r\n this._ipc = undefined;\r\n await IModelHost.shutdown();\r\n }\r\n}\r\n\r\n/**\r\n * Base class for all implementations of an Ipc interface.\r\n *\r\n * Create a subclass to implement your Ipc interface. Your class should be declared like this:\r\n * ```ts\r\n * class MyHandler extends IpcHandler implements MyInterface\r\n * ```\r\n * to ensure all methods and signatures are correct.\r\n *\r\n * Then, call `MyClass.register` at startup to connect your class to your channel.\r\n * @public\r\n */\r\nexport abstract class IpcHandler {\r\n /**\r\n * All subclasses *must* implement this method to specify their channel name.\r\n *\r\n * Channel names are the key that connects Handlers and senders. The channel name of IpcHandlers must exactly match the name used by senders.\r\n * By convention, channel names should be prefixed by a *namespace* (e.g. `${appName}/`)\r\n * unique enough to disambiguate them from channels for other apps that may be running in the same processes.\r\n */\r\n public abstract get channelName(): string;\r\n\r\n /**\r\n * Register this class as the handler for methods on its channel. This static method creates a new instance\r\n * that becomes the handler and is `this` when its methods are called.\r\n * @returns A function that can be called to remove the handler.\r\n * @note this method should only be called once per channel. If it is called multiple times, subsequent calls replace the previous ones.\r\n */\r\n public static register(): RemoveFunction {\r\n const impl = new (this as any)() as IpcHandler; // create an instance of subclass. \"as any\" is necessary because base class is abstract\r\n return IpcHost.handle(impl.channelName, async (_evt: Event, funcName: string, ...args: any[]): Promise<IpcInvokeReturn> => {\r\n try {\r\n const func = (impl as any)[funcName];\r\n if (typeof func !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${impl.constructor.name}.${funcName}\" not found on IpcHandler registered for channel: ${impl.channelName}`);\r\n\r\n return { result: await func.call(impl, ...args) };\r\n } catch (err: any) {\r\n const ret: IpcInvokeReturn = {\r\n error: {\r\n name: err.hasOwnProperty(\"name\") ? err.name : err.constructor?.name ?? \"Unknown Error\",\r\n message: err.message ?? BentleyError.getErrorMessage(err),\r\n errorNumber: err.errorNumber ?? 0,\r\n },\r\n };\r\n if (!IpcHost.noStack)\r\n ret.error.stack = BentleyError.getErrorStack(err);\r\n return ret;\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Implementation of IpcAppFunctions\r\n */\r\nclass IpcAppHandler extends IpcHandler implements IpcAppFunctions {\r\n public get channelName() { return ipcAppChannels.functions; }\r\n\r\n private _iModelKeyToPullStatus = new Map<string, ProgressStatus>();\r\n\r\n public async log(_timestamp: number, level: LogLevel, category: string, message: string, metaData?: any): Promise<void> {\r\n switch (level) {\r\n case LogLevel.Error:\r\n Logger.logError(category, message, metaData);\r\n break;\r\n case LogLevel.Info:\r\n Logger.logInfo(category, message, metaData);\r\n break;\r\n case LogLevel.Trace:\r\n Logger.logTrace(category, message, metaData);\r\n break;\r\n case LogLevel.Warning:\r\n Logger.logWarning(category, message, metaData);\r\n break;\r\n }\r\n }\r\n\r\n public async cancelTileContentRequests(tokenProps: IModelRpcProps, contentIds: TileTreeContentIds[]): Promise<void> {\r\n return cancelTileContentRequests(tokenProps, contentIds);\r\n }\r\n public async cancelElementGraphicsRequests(key: string, requestIds: string[]): Promise<void> {\r\n return IModelDb.findByKey(key).nativeDb.cancelElementGraphicsRequests(requestIds);\r\n }\r\n public async openBriefcase(args: OpenBriefcaseProps): Promise<IModelConnectionProps> {\r\n const db = await BriefcaseDb.open(args);\r\n return db.toJSON();\r\n }\r\n public async openStandalone(filePath: string, openMode: OpenMode, opts?: StandaloneOpenOptions): Promise<IModelConnectionProps> {\r\n return StandaloneDb.openFile(filePath, openMode, opts).getConnectionProps();\r\n }\r\n public async closeIModel(key: string): Promise<void> {\r\n IModelDb.findByKey(key).close();\r\n }\r\n public async saveChanges(key: string, description?: string): Promise<void> {\r\n IModelDb.findByKey(key).saveChanges(description);\r\n }\r\n public async hasPendingTxns(key: string): Promise<boolean> {\r\n return IModelDb.findByKey(key).nativeDb.hasPendingTxns();\r\n }\r\n\r\n public async isUndoPossible(key: string): Promise<boolean> {\r\n return IModelDb.findByKey(key).nativeDb.isUndoPossible();\r\n }\r\n public async isRedoPossible(key: string): Promise<boolean> {\r\n return IModelDb.findByKey(key).nativeDb.isRedoPossible();\r\n }\r\n public async getUndoString(key: string): Promise<string> {\r\n return IModelDb.findByKey(key).nativeDb.getUndoString();\r\n }\r\n public async getRedoString(key: string): Promise<string> {\r\n return IModelDb.findByKey(key).nativeDb.getUndoString();\r\n }\r\n\r\n public async pullChanges(key: string, toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<ChangesetIndexAndId> {\r\n const iModelDb = BriefcaseDb.findByKey(key);\r\n\r\n this._iModelKeyToPullStatus.set(key, ProgressStatus.Continue);\r\n const checkAbort = () => this._iModelKeyToPullStatus.get(key) ?? ProgressStatus.Continue;\r\n\r\n let onProgress: ProgressFunction | undefined;\r\n if (options?.reportProgress) {\r\n const progressCallback: ProgressFunction = (loaded, total) => {\r\n IpcHost.send(getPullChangesIpcChannel(iModelDb.iModelId), { loaded, total });\r\n return checkAbort();\r\n };\r\n onProgress = throttleProgressCallback(progressCallback, checkAbort, options?.progressInterval);\r\n } else if (options?.enableCancellation) {\r\n onProgress = checkAbort;\r\n }\r\n\r\n try {\r\n await iModelDb.pullChanges({ toIndex, onProgress });\r\n } finally {\r\n this._iModelKeyToPullStatus.delete(key);\r\n }\r\n\r\n return iModelDb.changeset as ChangesetIndexAndId;\r\n }\r\n public async cancelPullChangesRequest(key: string): Promise<void> {\r\n this._iModelKeyToPullStatus.set(key, ProgressStatus.Abort);\r\n }\r\n\r\n public async pushChanges(key: string, description: string): Promise<ChangesetIndexAndId> {\r\n const iModelDb = BriefcaseDb.findByKey(key);\r\n await iModelDb.pushChanges({ description });\r\n return iModelDb.changeset as ChangesetIndexAndId;\r\n }\r\n\r\n public async toggleGraphicalEditingScope(key: string, startSession: boolean): Promise<boolean> {\r\n const val: IModelJsNative.ErrorStatusOrResult<any, boolean> = IModelDb.findByKey(key).nativeDb.setGeometricModelTrackingEnabled(startSession);\r\n if (val.error)\r\n throw new IModelError(val.error.status, \"Failed to toggle graphical editing scope\");\r\n assert(undefined !== val.result);\r\n return val.result;\r\n }\r\n public async isGraphicalEditingSupported(key: string): Promise<boolean> {\r\n return IModelDb.findByKey(key).nativeDb.isGeometricModelTrackingSupported();\r\n }\r\n\r\n public async reverseTxns(key: string, numOperations: number): Promise<IModelStatus> {\r\n return IModelDb.findByKey(key).nativeDb.reverseTxns(numOperations);\r\n }\r\n public async reverseAllTxn(key: string): Promise<IModelStatus> {\r\n return IModelDb.findByKey(key).nativeDb.reverseAll();\r\n }\r\n public async reinstateTxn(key: string): Promise<IModelStatus> {\r\n return IModelDb.findByKey(key).nativeDb.reinstateTxn();\r\n }\r\n public async restartTxnSession(key: string): Promise<void> {\r\n return IModelDb.findByKey(key).nativeDb.restartTxnSession();\r\n }\r\n\r\n public async queryConcurrency(pool: \"io\" | \"cpu\"): Promise<number> {\r\n return IModelHost.platform.queryConcurrency(pool);\r\n }\r\n}\r\n\r\n/**\r\n * Prevents progress callback being called more frequently when provided interval.\r\n * @internal\r\n */\r\nexport function throttleProgressCallback(func: ProgressFunction, checkAbort: () => ProgressStatus, progressInterval?: number): ProgressFunction {\r\n const interval = progressInterval ?? 250; // by default, only send progress events every 250 milliseconds\r\n let nextTime = Date.now() + interval;\r\n const progressCallback: ProgressFunction = (loaded, total) => {\r\n const now = Date.now();\r\n if (loaded >= total || now >= nextTime) {\r\n nextTime = now + interval;\r\n return func(loaded, total);\r\n }\r\n return checkAbort();\r\n };\r\n\r\n return progressCallback;\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"IpcHost.js","sourceRoot":"","sources":["../../src/IpcHost.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/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ACM,KAAK,CAAC,iBAAiB,CAAC,GAAW;QACxC,OAAO,mBAAQ,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,CAAC,iBAAiB,EAAE,CAAC;IAC9D,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,IAAkB;QAC9C,OAAO,uBAAU,CAAC,QAAQ,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;IACpD,CAAC;CACF;AAED;;;GAGG;AACH,SAAgB,wBAAwB,CAAC,IAAsB,EAAE,UAAgC,EAAE,gBAAyB;IAC1H,MAAM,QAAQ,GAAG,gBAAgB,IAAI,GAAG,CAAC,CAAC,+DAA+D;IACzG,IAAI,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,QAAQ,CAAC;IACrC,MAAM,gBAAgB,GAAqB,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE;QAC3D,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;QACvB,IAAI,MAAM,IAAI,KAAK,IAAI,GAAG,IAAI,QAAQ,EAAE;YACtC,QAAQ,GAAG,GAAG,GAAG,QAAQ,CAAC;YAC1B,OAAO,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC;SAC5B;QACD,OAAO,UAAU,EAAE,CAAC;IACtB,CAAC,CAAC;IAEF,OAAO,gBAAgB,CAAC;AAC1B,CAAC;AAbD,4DAaC","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 NativeApp\r\n */\r\n\r\nimport { IModelJsNative } from \"@bentley/imodeljs-native\";\r\nimport { assert, BentleyError, IModelStatus, Logger, LogLevel, OpenMode } from \"@itwin/core-bentley\";\r\nimport {\r\n ChangesetIndex, ChangesetIndexAndId, EditingScopeNotifications, getPullChangesIpcChannel, IModelConnectionProps, IModelError, IModelRpcProps,\r\n ipcAppChannels, IpcAppFunctions, IpcAppNotifications, IpcInvokeReturn, IpcListener, IpcSocketBackend, iTwinChannel,\r\n OpenBriefcaseProps, OpenCheckpointArgs, PullChangesOptions, RemoveFunction, StandaloneOpenOptions, TileTreeContentIds, TxnNotifications,\r\n} from \"@itwin/core-common\";\r\nimport { ProgressFunction, ProgressStatus } from \"./CheckpointManager\";\r\nimport { BriefcaseDb, IModelDb, SnapshotDb, StandaloneDb } from \"./IModelDb\";\r\nimport { IModelHost, IModelHostOptions } from \"./IModelHost\";\r\nimport { cancelTileContentRequests } from \"./rpc-impl/IModelTileRpcImpl\";\r\n\r\n/**\r\n * Options for [[IpcHost.startup]]\r\n * @public\r\n */\r\nexport interface IpcHostOpts {\r\n iModelHost?: IModelHostOptions;\r\n ipcHost?: {\r\n /** The Ipc socket to use for communications with frontend. Allows undefined only for headless tests. */\r\n socket?: IpcSocketBackend;\r\n\r\n /** don't send stack information on exceptions */\r\n exceptions?: {\r\n noStack?: boolean;\r\n };\r\n };\r\n}\r\n\r\n/**\r\n * Used by applications that have a dedicated backend. IpcHosts may send messages to their corresponding IpcApp.\r\n * @note if either end terminates, the other must too.\r\n * @public\r\n */\r\nexport class IpcHost {\r\n public static noStack = false;\r\n private static _ipc: IpcSocketBackend | undefined;\r\n /** Get the implementation of the [IpcSocketBackend]($common) interface. */\r\n private static get ipc(): IpcSocketBackend { return this._ipc!; } // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n /** Determine whether Ipc is available for this backend. This will only be true if [[startup]] has been called on this class. */\r\n public static get isValid(): boolean { return undefined !== this._ipc; }\r\n\r\n /**\r\n * Send a message to the frontend over an Ipc channel.\r\n * @param channel the name of the channel matching the name registered with [[IpcApp.addListener]].\r\n * @param data The content of the message.\r\n */\r\n public static send(channel: string, ...data: any[]): void {\r\n this.ipc.send(iTwinChannel(channel), ...data);\r\n }\r\n\r\n /**\r\n * Establish a handler for an Ipc channel to receive [[Frontend.invoke]] calls\r\n * @param channel The name of the channel for this handler.\r\n * @param handler A function that supplies the implementation for `channel`\r\n * @note returns A function to call to remove the handler.\r\n */\r\n public static handle(channel: string, handler: (...args: any[]) => Promise<any>): RemoveFunction {\r\n return this.ipc.handle(iTwinChannel(channel), handler);\r\n }\r\n /**\r\n * Establish a handler to receive messages sent via [[IpcApp.send]].\r\n * @param channel The name of the channel for the messages.\r\n * @param listener A function called when messages are sent over `channel`\r\n * @note returns A function to call to remove the listener.\r\n */\r\n public static addListener(channel: string, listener: IpcListener): RemoveFunction {\r\n return this.ipc.addListener(iTwinChannel(channel), listener);\r\n }\r\n /**\r\n * Remove a previously registered listener\r\n * @param channel The name of the channel for the listener previously registered with [[addListener]]\r\n * @param listener The function passed to [[addListener]]\r\n */\r\n public static removeListener(channel: string, listener: IpcListener): void {\r\n this.ipc.removeListener(iTwinChannel(channel), listener);\r\n }\r\n\r\n private static notify(channel: string, briefcase: BriefcaseDb | StandaloneDb, methodName: string, ...args: any[]) {\r\n if (this.isValid)\r\n return this.send(`${channel}/${briefcase.key}`, methodName, ...args);\r\n }\r\n\r\n /** @internal */\r\n public static notifyIpcFrontend<T extends keyof IpcAppNotifications>(methodName: T, ...args: Parameters<IpcAppNotifications[T]>) {\r\n return IpcHost.send(ipcAppChannels.appNotify, methodName, ...args);\r\n }\r\n\r\n /** @internal */\r\n public static notifyTxns<T extends keyof TxnNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<TxnNotifications[T]>) {\r\n this.notify(ipcAppChannels.txns, briefcase, methodName, ...args);\r\n }\r\n\r\n /** @internal */\r\n public static notifyEditingScope<T extends keyof EditingScopeNotifications>(briefcase: BriefcaseDb | StandaloneDb, methodName: T, ...args: Parameters<EditingScopeNotifications[T]>) {\r\n this.notify(ipcAppChannels.editingScope, briefcase, methodName, ...args);\r\n }\r\n\r\n /**\r\n * Start the backend of an Ipc app.\r\n * @param opt\r\n * @note this method calls [[IModelHost.startup]] internally.\r\n */\r\n public static async startup(opt?: IpcHostOpts): Promise<void> {\r\n this._ipc = opt?.ipcHost?.socket;\r\n if (opt?.ipcHost?.exceptions?.noStack)\r\n this.noStack = true;\r\n\r\n if (this.isValid) { // for tests, we use IpcHost but don't have a frontend\r\n IpcAppHandler.register();\r\n }\r\n\r\n await IModelHost.startup(opt?.iModelHost);\r\n }\r\n\r\n /** Shutdown IpcHost backend. Also calls [[IModelHost.shutdown]] */\r\n public static async shutdown(): Promise<void> {\r\n this._ipc = undefined;\r\n await IModelHost.shutdown();\r\n }\r\n}\r\n\r\n/**\r\n * Base class for all implementations of an Ipc interface.\r\n *\r\n * Create a subclass to implement your Ipc interface. Your class should be declared like this:\r\n * ```ts\r\n * class MyHandler extends IpcHandler implements MyInterface\r\n * ```\r\n * to ensure all methods and signatures are correct.\r\n *\r\n * Then, call `MyClass.register` at startup to connect your class to your channel.\r\n * @public\r\n */\r\nexport abstract class IpcHandler {\r\n /**\r\n * All subclasses *must* implement this method to specify their channel name.\r\n *\r\n * Channel names are the key that connects Handlers and senders. The channel name of IpcHandlers must exactly match the name used by senders.\r\n * By convention, channel names should be prefixed by a *namespace* (e.g. `${appName}/`)\r\n * unique enough to disambiguate them from channels for other apps that may be running in the same processes.\r\n */\r\n public abstract get channelName(): string;\r\n\r\n /**\r\n * Register this class as the handler for methods on its channel. This static method creates a new instance\r\n * that becomes the handler and is `this` when its methods are called.\r\n * @returns A function that can be called to remove the handler.\r\n * @note this method should only be called once per channel. If it is called multiple times, subsequent calls replace the previous ones.\r\n */\r\n public static register(): RemoveFunction {\r\n const impl = new (this as any)() as IpcHandler; // create an instance of subclass. \"as any\" is necessary because base class is abstract\r\n return IpcHost.handle(impl.channelName, async (_evt: Event, funcName: string, ...args: any[]): Promise<IpcInvokeReturn> => {\r\n try {\r\n const func = (impl as any)[funcName];\r\n if (typeof func !== \"function\")\r\n throw new IModelError(IModelStatus.FunctionNotFound, `Method \"${impl.constructor.name}.${funcName}\" not found on IpcHandler registered for channel: ${impl.channelName}`);\r\n\r\n return { result: await func.call(impl, ...args) };\r\n } catch (err: any) {\r\n const ret: IpcInvokeReturn = {\r\n error: {\r\n name: err.hasOwnProperty(\"name\") ? err.name : err.constructor?.name ?? \"Unknown Error\",\r\n message: err.message ?? BentleyError.getErrorMessage(err),\r\n errorNumber: err.errorNumber ?? 0,\r\n },\r\n };\r\n if (!IpcHost.noStack)\r\n ret.error.stack = BentleyError.getErrorStack(err);\r\n return ret;\r\n }\r\n });\r\n }\r\n}\r\n\r\n/**\r\n * Implementation of IpcAppFunctions\r\n */\r\nclass IpcAppHandler extends IpcHandler implements IpcAppFunctions {\r\n public get channelName() { return ipcAppChannels.functions; }\r\n\r\n private _iModelKeyToPullStatus = new Map<string, ProgressStatus>();\r\n\r\n public async log(_timestamp: number, level: LogLevel, category: string, message: string, metaData?: any): Promise<void> {\r\n switch (level) {\r\n case LogLevel.Error:\r\n Logger.logError(category, message, metaData);\r\n break;\r\n case LogLevel.Info:\r\n Logger.logInfo(category, message, metaData);\r\n break;\r\n case LogLevel.Trace:\r\n Logger.logTrace(category, message, metaData);\r\n break;\r\n case LogLevel.Warning:\r\n Logger.logWarning(category, message, metaData);\r\n break;\r\n }\r\n }\r\n\r\n public async cancelTileContentRequests(tokenProps: IModelRpcProps, contentIds: TileTreeContentIds[]): Promise<void> {\r\n return cancelTileContentRequests(tokenProps, contentIds);\r\n }\r\n public async cancelElementGraphicsRequests(key: string, requestIds: string[]): Promise<void> {\r\n return IModelDb.findByKey(key).nativeDb.cancelElementGraphicsRequests(requestIds);\r\n }\r\n public async openBriefcase(args: OpenBriefcaseProps): Promise<IModelConnectionProps> {\r\n const db = await BriefcaseDb.open(args);\r\n return db.toJSON();\r\n }\r\n public async openCheckpoint(checkpoint: OpenCheckpointArgs): Promise<IModelConnectionProps> {\r\n return (await SnapshotDb.openCheckpoint(checkpoint)).getConnectionProps();\r\n }\r\n public async openStandalone(filePath: string, openMode: OpenMode, opts?: StandaloneOpenOptions): Promise<IModelConnectionProps> {\r\n return StandaloneDb.openFile(filePath, openMode, opts).getConnectionProps();\r\n }\r\n public async closeIModel(key: string): Promise<void> {\r\n IModelDb.findByKey(key).close();\r\n }\r\n public async saveChanges(key: string, description?: string): Promise<void> {\r\n IModelDb.findByKey(key).saveChanges(description);\r\n }\r\n public async hasPendingTxns(key: string): Promise<boolean> {\r\n return IModelDb.findByKey(key).nativeDb.hasPendingTxns();\r\n }\r\n\r\n public async isUndoPossible(key: string): Promise<boolean> {\r\n return IModelDb.findByKey(key).nativeDb.isUndoPossible();\r\n }\r\n public async isRedoPossible(key: string): Promise<boolean> {\r\n return IModelDb.findByKey(key).nativeDb.isRedoPossible();\r\n }\r\n public async getUndoString(key: string): Promise<string> {\r\n return IModelDb.findByKey(key).nativeDb.getUndoString();\r\n }\r\n public async getRedoString(key: string): Promise<string> {\r\n return IModelDb.findByKey(key).nativeDb.getUndoString();\r\n }\r\n\r\n public async pullChanges(key: string, toIndex?: ChangesetIndex, options?: PullChangesOptions): Promise<ChangesetIndexAndId> {\r\n const iModelDb = BriefcaseDb.findByKey(key);\r\n\r\n this._iModelKeyToPullStatus.set(key, ProgressStatus.Continue);\r\n const checkAbort = () => this._iModelKeyToPullStatus.get(key) ?? ProgressStatus.Continue;\r\n\r\n let onProgress: ProgressFunction | undefined;\r\n if (options?.reportProgress) {\r\n const progressCallback: ProgressFunction = (loaded, total) => {\r\n IpcHost.send(getPullChangesIpcChannel(iModelDb.iModelId), { loaded, total });\r\n return checkAbort();\r\n };\r\n onProgress = throttleProgressCallback(progressCallback, checkAbort, options?.progressInterval);\r\n } else if (options?.enableCancellation) {\r\n onProgress = checkAbort;\r\n }\r\n\r\n try {\r\n await iModelDb.pullChanges({ toIndex, onProgress });\r\n } finally {\r\n this._iModelKeyToPullStatus.delete(key);\r\n }\r\n\r\n return iModelDb.changeset as ChangesetIndexAndId;\r\n }\r\n public async cancelPullChangesRequest(key: string): Promise<void> {\r\n this._iModelKeyToPullStatus.set(key, ProgressStatus.Abort);\r\n }\r\n\r\n public async pushChanges(key: string, description: string): Promise<ChangesetIndexAndId> {\r\n const iModelDb = BriefcaseDb.findByKey(key);\r\n await iModelDb.pushChanges({ description });\r\n return iModelDb.changeset as ChangesetIndexAndId;\r\n }\r\n\r\n public async toggleGraphicalEditingScope(key: string, startSession: boolean): Promise<boolean> {\r\n const val: IModelJsNative.ErrorStatusOrResult<any, boolean> = IModelDb.findByKey(key).nativeDb.setGeometricModelTrackingEnabled(startSession);\r\n if (val.error)\r\n throw new IModelError(val.error.status, \"Failed to toggle graphical editing scope\");\r\n assert(undefined !== val.result);\r\n return val.result;\r\n }\r\n public async isGraphicalEditingSupported(key: string): Promise<boolean> {\r\n return IModelDb.findByKey(key).nativeDb.isGeometricModelTrackingSupported();\r\n }\r\n\r\n public async reverseTxns(key: string, numOperations: number): Promise<IModelStatus> {\r\n return IModelDb.findByKey(key).nativeDb.reverseTxns(numOperations);\r\n }\r\n public async reverseAllTxn(key: string): Promise<IModelStatus> {\r\n return IModelDb.findByKey(key).nativeDb.reverseAll();\r\n }\r\n public async reinstateTxn(key: string): Promise<IModelStatus> {\r\n return IModelDb.findByKey(key).nativeDb.reinstateTxn();\r\n }\r\n public async restartTxnSession(key: string): Promise<void> {\r\n return IModelDb.findByKey(key).nativeDb.restartTxnSession();\r\n }\r\n\r\n public async queryConcurrency(pool: \"io\" | \"cpu\"): Promise<number> {\r\n return IModelHost.platform.queryConcurrency(pool);\r\n }\r\n}\r\n\r\n/**\r\n * Prevents progress callback being called more frequently when provided interval.\r\n * @internal\r\n */\r\nexport function throttleProgressCallback(func: ProgressFunction, checkAbort: () => ProgressStatus, progressInterval?: number): ProgressFunction {\r\n const interval = progressInterval ?? 250; // by default, only send progress events every 250 milliseconds\r\n let nextTime = Date.now() + interval;\r\n const progressCallback: ProgressFunction = (loaded, total) => {\r\n const now = Date.now();\r\n if (loaded >= total || now >= nextTime) {\r\n nextTime = now + interval;\r\n return func(loaded, total);\r\n }\r\n return checkAbort();\r\n };\r\n\r\n return progressCallback;\r\n}\r\n"]}
|
package/lib/cjs/Material.js
CHANGED
|
@@ -102,7 +102,7 @@ class RenderMaterialElement extends Element_1.DefinitionElement {
|
|
|
102
102
|
choose(baseProps, "pattern_scalemode");
|
|
103
103
|
choose(baseProps, "pattern_mapping");
|
|
104
104
|
choose(baseProps, "pattern_weight");
|
|
105
|
-
choose(baseProps, "
|
|
105
|
+
choose(baseProps, "pattern_useconstantlod");
|
|
106
106
|
choose(baseProps, "pattern_constantlod_repetitions");
|
|
107
107
|
choose(baseProps, "pattern_constantlod_offset");
|
|
108
108
|
choose(baseProps, "pattern_constantlod_mindistanceclamp");
|
package/lib/cjs/Material.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Material.js","sourceRoot":"","sources":["../../src/Material.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuD;AACvD,oDAE4B;AAC5B,uCAA8C;AAI9C,yDAAyD;AAEzD;;;GAGG;AACH,MAAsB,gBAAiB,SAAQ,2BAAiB;IAC9D,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,kBAAkB,CAAC,CAAC,CAAC;IAC7E;;;;OAIG;IACI,MAAM,CAAC,UAAU,CAAC,MAAgB,EAAE,iBAAiC,EAAE,IAAY;QACxF,MAAM,QAAQ,GAAa,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,yBAAW,CAAC,gBAAgB,CAAC,CAAC;QACpF,OAAO,IAAI,kBAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,KAAK,EAAE,iBAAiB,EAAE,KAAK,EAAE,IAAI,EAAE,CAAC,CAAC;IAChF,CAAC;IACD;;;;;;OAMG;IACI,MAAM,CAAC,MAAM,CAA6B,QAAkB,EAAE,iBAAiC,EAAE,IAAY;QAClH,MAAM,YAAY,GAA2B;YAC3C,aAAa,EAAE,IAAI,CAAC,aAAa;YACjC,KAAK,EAAE,iBAAiB;YACxB,IAAI,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AAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,SAAS,IAAI,mBAAI,CAAC,OAAO,CAAC,CAAC;SACpJ;IACH,CAAC;CACF;AAjJD,sDAiJC;AAED,cAAc;AACd,WAAiB,qBAAqB;IACpC;;;;OAIG;IACH,MAAa,MAAM;QA2CjB,gJAAgJ;QAChJ,YAAmB,WAAmB;YACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QACjC,CAAC;KACF;IA/CY,4BAAM,SA+ClB,CAAA;AACH,CAAC,EAtDgB,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAsDrC","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 Elements\r\n */\r\n\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n BisCodeSpec, Code, CodeScopeProps, CodeSpec, DefinitionElementProps, ElementProps, NormalMapProps, RenderMaterialAssetMapsProps, RenderMaterialProps, RgbFactorProps, TextureMapProps,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { IModelElementCloneContext } from \"./IModelElementCloneContext\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n\r\n/** A PhysicalMaterial defines the matter that makes up physical elements.\r\n * @note See [[RenderMaterialElement]] for the DefinitionElement used to define rendering characteristics.\r\n * @public\r\n */\r\nexport abstract class PhysicalMaterial extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"PhysicalMaterial\"; }\r\n /** Create a Code for a PhysicalMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.\r\n * @param name The name (codeValue) of the PhysicalMaterial\r\n */\r\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.physicalMaterial);\r\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\r\n }\r\n /** Create a PhysicalMaterial\r\n * @param iModelDb The IModelDb\r\n * @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.\r\n * @param name The name (codeValue) of the PhysicalMaterial\r\n * @returns The newly constructed PhysicalMaterial\r\n * @throws [[IModelError]] if there is a problem creating the PhysicalMaterial\r\n */\r\n public static create<T extends PhysicalMaterial>(iModelDb: IModelDb, definitionModelId: CodeScopeProps, name: string): T {\r\n const elementProps: DefinitionElementProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n };\r\n return iModelDb.elements.createElement(elementProps);\r\n }\r\n}\r\n\r\n/** Defines a rendering material.\r\n * @note See [[PhysicalMaterial]] for the DefinitionElement used to define the matter that makes up physical elements.\r\n * @public\r\n */\r\nexport class RenderMaterialElement extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"RenderMaterial\"; }\r\n\r\n /** The name of a palette that can be used to categorize multiple materials. */\r\n public paletteName: string;\r\n /** An optional description of the material. */\r\n public description?: string;\r\n /** @internal */\r\n constructor(props: RenderMaterialProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.paletteName = props.paletteName;\r\n this.description = props.description;\r\n }\r\n\r\n public override toJSON(): RenderMaterialProps {\r\n const val = super.toJSON() as RenderMaterialProps;\r\n val.paletteName = this.paletteName;\r\n val.description = this.description;\r\n return val;\r\n }\r\n /** Create a Code for a RenderMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param scopeModelId The Id of the DefinitionModel that contains the RenderMaterial and provides the scope for its name.\r\n * @param name The RenderMaterial name\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.renderMaterial);\r\n return 0 === name.length ? Code.createEmpty() : new Code({ spec: codeSpec.id, scope: scopeModelId, value: name });\r\n }\r\n /**\r\n * Create a RenderMaterial with given parameters.\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param materialName The name/CodeValue of the RenderMaterial\r\n * @param params Parameters object which describes how to construct the RenderMaterial\r\n * @returns The newly constructed RenderMaterial element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElementParams): RenderMaterialElement {\r\n let maps: RenderMaterialAssetMapsProps | undefined;\r\n const pbr_normal = params.normalMap?.scale;\r\n if (params.patternMap || params.normalMap) {\r\n // If both normal and pattern map are present, their texture mapping modes, angles, scales, etc are expected to match.\r\n type TexMap = Omit<TextureMapProps, \"TextureId\">;\r\n function choose<K extends keyof TexMap>(obj: TexMap, key: K): void {\r\n const pat = params.patternMap;\r\n if (pat && undefined !== pat[key])\r\n obj[key] = pat[key];\r\n else if (params.normalMap && undefined !== params.normalMap[key])\r\n obj[key] = params.normalMap[key];\r\n }\r\n\r\n const baseProps: TexMap = {};\r\n choose(baseProps, \"pattern_angle\");\r\n choose(baseProps, \"pattern_u_flip\");\r\n choose(baseProps, \"pattern_flip\");\r\n choose(baseProps, \"pattern_scale\");\r\n choose(baseProps, \"pattern_offset\");\r\n choose(baseProps, \"pattern_scalemode\");\r\n choose(baseProps, \"pattern_mapping\");\r\n choose(baseProps, \"pattern_weight\");\r\n choose(baseProps, \"pattern_useConstantLod\");\r\n choose(baseProps, \"pattern_constantlod_repetitions\");\r\n choose(baseProps, \"pattern_constantlod_offset\");\r\n choose(baseProps, \"pattern_constantlod_mindistanceclamp\");\r\n choose(baseProps, \"pattern_constantlod_maxdistanceclamp\");\r\n\r\n maps = {};\r\n if (params.patternMap)\r\n maps.Pattern = { ...params.patternMap, ...baseProps };\r\n\r\n if (params.normalMap) {\r\n maps.Normal = {\r\n ...params.normalMap,\r\n ...baseProps,\r\n };\r\n\r\n delete (maps.Normal as any).scale;\r\n }\r\n }\r\n\r\n // const map = undefined !== params.patternMap ? { Pattern: params.patternMap } : undefined;\r\n const renderMaterialProps: RenderMaterialProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, definitionModelId, materialName),\r\n paletteName: params.paletteName,\r\n description: params.description,\r\n jsonProperties: {\r\n materialAssets: {\r\n renderMaterial: {\r\n HasBaseColor: params.color !== undefined,\r\n color: params.color,\r\n HasSpecularColor: params.specularColor !== undefined,\r\n specular_color: params.specularColor,\r\n HasFinish: params.finish !== undefined,\r\n finish: params.finish,\r\n HasTransmit: params.transmit !== undefined,\r\n transmit: params.transmit,\r\n HasDiffuse: params.diffuse !== undefined,\r\n diffuse: params.diffuse,\r\n HasSpecular: params.specular !== undefined,\r\n specular: params.specular,\r\n HasReflect: params.reflect !== undefined,\r\n reflect: params.reflect,\r\n HasReflectColor: params.reflectColor !== undefined,\r\n reflect_color: params.reflectColor,\r\n Map: maps,\r\n pbr_normal,\r\n },\r\n },\r\n },\r\n model: definitionModelId,\r\n isPrivate: false,\r\n };\r\n\r\n return new RenderMaterialElement(renderMaterialProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Insert a new RenderMaterial into a model.\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new Texture into this DefinitionModel\r\n * @param materialName The name/CodeValue of the RenderMaterial\r\n * @param params Parameters object which describes how to construct the RenderMaterial\r\n * @returns The Id of the newly inserted RenderMaterial element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElementParams): Id64String {\r\n const renderMaterial = this.create(iModelDb, definitionModelId, materialName, params);\r\n return iModelDb.elements.insertElement(renderMaterial.toJSON());\r\n }\r\n\r\n /** @internal */\r\n protected static override onCloned(context: IModelElementCloneContext, sourceProps: ElementProps, targetProps: ElementProps) {\r\n super.onCloned(context, sourceProps, targetProps);\r\n for (const mapName in sourceProps.jsonProperties?.materialAssets?.renderMaterial?.Map ?? {}) {\r\n if (typeof mapName !== \"string\")\r\n continue;\r\n const sourceMap = sourceProps.jsonProperties.materialAssets.renderMaterial.Map[mapName];\r\n if (!Id64.isValid(sourceMap.TextureId) || sourceMap.TextureId === undefined)\r\n continue;\r\n targetProps.jsonProperties.materialAssets.renderMaterial.Map[mapName].TextureId = context.findTargetElementId(sourceMap.TextureId ?? Id64.invalid);\r\n }\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace RenderMaterialElement { // eslint-disable-line no-redeclare\r\n /** Parameters used to construct a [[RenderMaterial]].\r\n * The persistent JSON representation - [RenderMaterialAssetProps]($common) - is quite verbose and unwieldy. This representation simplifies it somewhat.\r\n * @see [[RenderMaterialElement.create]] and [[RenderMaterialElement.insert]] to create a [[RenderMaterial]] from parameters of this type.\r\n * @deprecated in 3.6 because it is not useful to use a `class` - just use [[RenderMaterialElementParams]] directly instead.\r\n */\r\n export class Params {\r\n /** A required palette name that categorizes this RenderMaterial */\r\n public paletteName: string;\r\n /** An optional description of this RenderMaterial */\r\n public description?: string;\r\n /** If defined, the color to use for surface fill or diffuse illumination, overriding the surface's own color. */\r\n public color?: RgbFactorProps;\r\n /** The color to use for specular illumination. Default: black. */\r\n public specularColor?: RgbFactorProps;\r\n /** The specular exponent describing the surface's shininess, in the range 0 through 128.\r\n * Default: 0.\r\n */\r\n public finish?: number;\r\n /** A transparency to be applied to the surface, ranging from 0 (fully opaque) to 1 (fully transparent).\r\n * The surface's own transparency will be multiplied by `(1 - transmit)`. permitting the material to increase but not decrease the surface transparency.\r\n * Default: 13.5.\r\n */\r\n public transmit?: number;\r\n /** The surface's diffuse reflectivity from 0.0 to 1.0. Default: 0.6. */\r\n public diffuse?: number;\r\n /** The surface's specular reflectivity from 0.0 to 1.0. Default: 0.0. */\r\n public specular?: number;\r\n /** Currently unused. */\r\n public reflect?: number;\r\n /** Currently unused. */\r\n public reflectColor?: number[];\r\n /** Specifies a texture image to map onto the surface, replacing or mixing with the surface's own color and transparency.\r\n * @note With the exception of `TextureId`, the [TextureMapProps]($common) of [[patternMap]] and [[normalMap]] are expected to be identical. If a property is defined in both\r\n * [[patternMap]]] and [[normalMap]], the value in [[patternMap]] takes precedence.\r\n */\r\n public patternMap?: TextureMapProps;\r\n /** Specifies a [normal map](https://en.wikipedia.org/wiki/Normal_mapping) to apply to the surface to simulate more surface detail than is present in the\r\n * surface's geometry.\r\n * @note With the exception of `TextureId`, the [TextureMapProps]($common) of [[patternMap]] and [[normalMap]] are expected to be identical. If a property is defined in both\r\n * [[patternMap]]] and [[normalMap]], the value in [[patternMap]] takes precedence.\r\n */\r\n public normalMap?: NormalMapProps & {\r\n /** A factor by which to multiply the components of the normal vectors read from the texture.\r\n * Default: 1.\r\n */\r\n scale?: number;\r\n };\r\n\r\n /** Construct a new RenderMaterial.Params object with the specified paletteName. Alter the public members on that object to specify settings. */\r\n public constructor(paletteName: string) {\r\n this.paletteName = paletteName;\r\n }\r\n }\r\n}\r\n\r\n/** Parameters used to create a [[RenderMaterial]] element.\r\n * The persistent JSON representation - [RenderMaterialAssetProps]($common) - is quite verbose and unwieldy. This representation simplifies it somewhat.\r\n * @see [[RenderMaterialElement.create]] and [[RenderMaterialElement.insert]] to create a [[RenderMaterial]] from parameters of this type.\r\n * @public\r\n */\r\nexport interface RenderMaterialElementParams extends RenderMaterialElement.Params { // eslint-disable-line deprecation/deprecation, @typescript-eslint/no-empty-interface\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"Material.js","sourceRoot":"","sources":["../../src/Material.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuD;AACvD,oDAE4B;AAC5B,uCAA8C;AAI9C,yDAAyD;AAEzD;;;GAGG;AACH,MAAsB,gBAAiB,SAAQ,2BAAiB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,CAAC,OAAkC,EAAE,WAAyB,EAAE,WAAyB;QACzH,KAAK,CAAC,QAAQ,CAAC,OAAO,EAAE,WAAW,EAAE,WAAW,CAAC,CAAC;QAClD,KAAK,MAAM,OAAO,IAAI,WAAW,CAAC,cAAc,EAAE,cAAc,EAAE,cAAc,EAAE,GAAG,IAAI,EAAE,EAAE;YAC3F,IAAI,OAAO,OAAO,KAAK,QAAQ;gBAC7B,SAAS;YACX,MAAM,SAAS,GAAG,WAAW,CAAC,cAAc,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACxF,IAAI,CAAC,mBAAI,CAAC,OAAO,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,SAAS,CAAC,SAAS,KAAK,SAAS;gBACzE,SAAS;YACX,WAAW,CAAC,cAAc,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,SAAS,GAAG,OAAO,CAAC,mBAAmB,CAAC,SAAS,CAAC,SAAS,IAAI,mBAAI,CAAC,OAAO,CAAC,CAAC;SACpJ;IACH,CAAC;CACF;AAjJD,sDAiJC;AAED,cAAc;AACd,WAAiB,qBAAqB;IACpC;;;;OAIG;IACH,MAAa,MAAM;QA2CjB,gJAAgJ;QAChJ,YAAmB,WAAmB;YACpC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;QACjC,CAAC;KACF;IA/CY,4BAAM,SA+ClB,CAAA;AACH,CAAC,EAtDgB,qBAAqB,GAArB,6BAAqB,KAArB,6BAAqB,QAsDrC","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 Elements\r\n */\r\n\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport {\r\n BisCodeSpec, Code, CodeScopeProps, CodeSpec, DefinitionElementProps, ElementProps, NormalMapProps, RenderMaterialAssetMapsProps, RenderMaterialProps, RgbFactorProps, TextureMapProps,\r\n} from \"@itwin/core-common\";\r\nimport { DefinitionElement } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { IModelElementCloneContext } from \"./IModelElementCloneContext\";\r\n\r\n/* eslint-disable @typescript-eslint/naming-convention */\r\n\r\n/** A PhysicalMaterial defines the matter that makes up physical elements.\r\n * @note See [[RenderMaterialElement]] for the DefinitionElement used to define rendering characteristics.\r\n * @public\r\n */\r\nexport abstract class PhysicalMaterial extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"PhysicalMaterial\"; }\r\n /** Create a Code for a PhysicalMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.\r\n * @param name The name (codeValue) of the PhysicalMaterial\r\n */\r\n public static createCode(iModel: IModelDb, definitionModelId: CodeScopeProps, name: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.physicalMaterial);\r\n return new Code({ spec: codeSpec.id, scope: definitionModelId, value: name });\r\n }\r\n /** Create a PhysicalMaterial\r\n * @param iModelDb The IModelDb\r\n * @param definitionModelId The Id of the DefinitionModel that will contain the PhysicalMaterial and provide the scope for its name.\r\n * @param name The name (codeValue) of the PhysicalMaterial\r\n * @returns The newly constructed PhysicalMaterial\r\n * @throws [[IModelError]] if there is a problem creating the PhysicalMaterial\r\n */\r\n public static create<T extends PhysicalMaterial>(iModelDb: IModelDb, definitionModelId: CodeScopeProps, name: string): T {\r\n const elementProps: DefinitionElementProps = {\r\n classFullName: this.classFullName,\r\n model: definitionModelId,\r\n code: this.createCode(iModelDb, definitionModelId, name),\r\n };\r\n return iModelDb.elements.createElement(elementProps);\r\n }\r\n}\r\n\r\n/** Defines a rendering material.\r\n * @note See [[PhysicalMaterial]] for the DefinitionElement used to define the matter that makes up physical elements.\r\n * @public\r\n */\r\nexport class RenderMaterialElement extends DefinitionElement {\r\n /** @internal */\r\n public static override get className(): string { return \"RenderMaterial\"; }\r\n\r\n /** The name of a palette that can be used to categorize multiple materials. */\r\n public paletteName: string;\r\n /** An optional description of the material. */\r\n public description?: string;\r\n /** @internal */\r\n constructor(props: RenderMaterialProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.paletteName = props.paletteName;\r\n this.description = props.description;\r\n }\r\n\r\n public override toJSON(): RenderMaterialProps {\r\n const val = super.toJSON() as RenderMaterialProps;\r\n val.paletteName = this.paletteName;\r\n val.description = this.description;\r\n return val;\r\n }\r\n /** Create a Code for a RenderMaterial given a name that is meant to be unique within the scope of the specified DefinitionModel.\r\n * @param iModel The IModelDb\r\n * @param scopeModelId The Id of the DefinitionModel that contains the RenderMaterial and provides the scope for its name.\r\n * @param name The RenderMaterial name\r\n */\r\n public static createCode(iModel: IModelDb, scopeModelId: CodeScopeProps, name: string): Code {\r\n const codeSpec: CodeSpec = iModel.codeSpecs.getByName(BisCodeSpec.renderMaterial);\r\n return 0 === name.length ? Code.createEmpty() : new Code({ spec: codeSpec.id, scope: scopeModelId, value: name });\r\n }\r\n /**\r\n * Create a RenderMaterial with given parameters.\r\n * @param iModelDb The iModel\r\n * @param definitionModelId The [[DefinitionModel]]\r\n * @param materialName The name/CodeValue of the RenderMaterial\r\n * @param params Parameters object which describes how to construct the RenderMaterial\r\n * @returns The newly constructed RenderMaterial element.\r\n * @throws [[IModelError]] if unable to create the element.\r\n */\r\n public static create(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElementParams): RenderMaterialElement {\r\n let maps: RenderMaterialAssetMapsProps | undefined;\r\n const pbr_normal = params.normalMap?.scale;\r\n if (params.patternMap || params.normalMap) {\r\n // If both normal and pattern map are present, their texture mapping modes, angles, scales, etc are expected to match.\r\n type TexMap = Omit<TextureMapProps, \"TextureId\">;\r\n function choose<K extends keyof TexMap>(obj: TexMap, key: K): void {\r\n const pat = params.patternMap;\r\n if (pat && undefined !== pat[key])\r\n obj[key] = pat[key];\r\n else if (params.normalMap && undefined !== params.normalMap[key])\r\n obj[key] = params.normalMap[key];\r\n }\r\n\r\n const baseProps: TexMap = {};\r\n choose(baseProps, \"pattern_angle\");\r\n choose(baseProps, \"pattern_u_flip\");\r\n choose(baseProps, \"pattern_flip\");\r\n choose(baseProps, \"pattern_scale\");\r\n choose(baseProps, \"pattern_offset\");\r\n choose(baseProps, \"pattern_scalemode\");\r\n choose(baseProps, \"pattern_mapping\");\r\n choose(baseProps, \"pattern_weight\");\r\n choose(baseProps, \"pattern_useconstantlod\");\r\n choose(baseProps, \"pattern_constantlod_repetitions\");\r\n choose(baseProps, \"pattern_constantlod_offset\");\r\n choose(baseProps, \"pattern_constantlod_mindistanceclamp\");\r\n choose(baseProps, \"pattern_constantlod_maxdistanceclamp\");\r\n\r\n maps = {};\r\n if (params.patternMap)\r\n maps.Pattern = { ...params.patternMap, ...baseProps };\r\n\r\n if (params.normalMap) {\r\n maps.Normal = {\r\n ...params.normalMap,\r\n ...baseProps,\r\n };\r\n\r\n delete (maps.Normal as any).scale;\r\n }\r\n }\r\n\r\n // const map = undefined !== params.patternMap ? { Pattern: params.patternMap } : undefined;\r\n const renderMaterialProps: RenderMaterialProps = {\r\n classFullName: this.classFullName,\r\n code: this.createCode(iModelDb, definitionModelId, materialName),\r\n paletteName: params.paletteName,\r\n description: params.description,\r\n jsonProperties: {\r\n materialAssets: {\r\n renderMaterial: {\r\n HasBaseColor: params.color !== undefined,\r\n color: params.color,\r\n HasSpecularColor: params.specularColor !== undefined,\r\n specular_color: params.specularColor,\r\n HasFinish: params.finish !== undefined,\r\n finish: params.finish,\r\n HasTransmit: params.transmit !== undefined,\r\n transmit: params.transmit,\r\n HasDiffuse: params.diffuse !== undefined,\r\n diffuse: params.diffuse,\r\n HasSpecular: params.specular !== undefined,\r\n specular: params.specular,\r\n HasReflect: params.reflect !== undefined,\r\n reflect: params.reflect,\r\n HasReflectColor: params.reflectColor !== undefined,\r\n reflect_color: params.reflectColor,\r\n Map: maps,\r\n pbr_normal,\r\n },\r\n },\r\n },\r\n model: definitionModelId,\r\n isPrivate: false,\r\n };\r\n\r\n return new RenderMaterialElement(renderMaterialProps, iModelDb);\r\n }\r\n\r\n /**\r\n * Insert a new RenderMaterial into a model.\r\n * @param iModelDb Insert into this iModel\r\n * @param definitionModelId Insert the new Texture into this DefinitionModel\r\n * @param materialName The name/CodeValue of the RenderMaterial\r\n * @param params Parameters object which describes how to construct the RenderMaterial\r\n * @returns The Id of the newly inserted RenderMaterial element.\r\n * @throws [[IModelError]] if unable to insert the element.\r\n */\r\n public static insert(iModelDb: IModelDb, definitionModelId: Id64String, materialName: string, params: RenderMaterialElementParams): Id64String {\r\n const renderMaterial = this.create(iModelDb, definitionModelId, materialName, params);\r\n return iModelDb.elements.insertElement(renderMaterial.toJSON());\r\n }\r\n\r\n /** @internal */\r\n protected static override onCloned(context: IModelElementCloneContext, sourceProps: ElementProps, targetProps: ElementProps) {\r\n super.onCloned(context, sourceProps, targetProps);\r\n for (const mapName in sourceProps.jsonProperties?.materialAssets?.renderMaterial?.Map ?? {}) {\r\n if (typeof mapName !== \"string\")\r\n continue;\r\n const sourceMap = sourceProps.jsonProperties.materialAssets.renderMaterial.Map[mapName];\r\n if (!Id64.isValid(sourceMap.TextureId) || sourceMap.TextureId === undefined)\r\n continue;\r\n targetProps.jsonProperties.materialAssets.renderMaterial.Map[mapName].TextureId = context.findTargetElementId(sourceMap.TextureId ?? Id64.invalid);\r\n }\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace RenderMaterialElement { // eslint-disable-line no-redeclare\r\n /** Parameters used to construct a [[RenderMaterial]].\r\n * The persistent JSON representation - [RenderMaterialAssetProps]($common) - is quite verbose and unwieldy. This representation simplifies it somewhat.\r\n * @see [[RenderMaterialElement.create]] and [[RenderMaterialElement.insert]] to create a [[RenderMaterial]] from parameters of this type.\r\n * @deprecated in 3.6 because it is not useful to use a `class` - just use [[RenderMaterialElementParams]] directly instead.\r\n */\r\n export class Params {\r\n /** A required palette name that categorizes this RenderMaterial */\r\n public paletteName: string;\r\n /** An optional description of this RenderMaterial */\r\n public description?: string;\r\n /** If defined, the color to use for surface fill or diffuse illumination, overriding the surface's own color. */\r\n public color?: RgbFactorProps;\r\n /** The color to use for specular illumination. Default: black. */\r\n public specularColor?: RgbFactorProps;\r\n /** The specular exponent describing the surface's shininess, in the range 0 through 128.\r\n * Default: 0.\r\n */\r\n public finish?: number;\r\n /** A transparency to be applied to the surface, ranging from 0 (fully opaque) to 1 (fully transparent).\r\n * The surface's own transparency will be multiplied by `(1 - transmit)`. permitting the material to increase but not decrease the surface transparency.\r\n * Default: 13.5.\r\n */\r\n public transmit?: number;\r\n /** The surface's diffuse reflectivity from 0.0 to 1.0. Default: 0.6. */\r\n public diffuse?: number;\r\n /** The surface's specular reflectivity from 0.0 to 1.0. Default: 0.0. */\r\n public specular?: number;\r\n /** Currently unused. */\r\n public reflect?: number;\r\n /** Currently unused. */\r\n public reflectColor?: number[];\r\n /** Specifies a texture image to map onto the surface, replacing or mixing with the surface's own color and transparency.\r\n * @note With the exception of `TextureId`, the [TextureMapProps]($common) of [[patternMap]] and [[normalMap]] are expected to be identical. If a property is defined in both\r\n * [[patternMap]]] and [[normalMap]], the value in [[patternMap]] takes precedence.\r\n */\r\n public patternMap?: TextureMapProps;\r\n /** Specifies a [normal map](https://en.wikipedia.org/wiki/Normal_mapping) to apply to the surface to simulate more surface detail than is present in the\r\n * surface's geometry.\r\n * @note With the exception of `TextureId`, the [TextureMapProps]($common) of [[patternMap]] and [[normalMap]] are expected to be identical. If a property is defined in both\r\n * [[patternMap]]] and [[normalMap]], the value in [[patternMap]] takes precedence.\r\n */\r\n public normalMap?: NormalMapProps & {\r\n /** A factor by which to multiply the components of the normal vectors read from the texture.\r\n * Default: 1.\r\n */\r\n scale?: number;\r\n };\r\n\r\n /** Construct a new RenderMaterial.Params object with the specified paletteName. Alter the public members on that object to specify settings. */\r\n public constructor(paletteName: string) {\r\n this.paletteName = paletteName;\r\n }\r\n }\r\n}\r\n\r\n/** Parameters used to create a [[RenderMaterial]] element.\r\n * The persistent JSON representation - [RenderMaterialAssetProps]($common) - is quite verbose and unwieldy. This representation simplifies it somewhat.\r\n * @see [[RenderMaterialElement.create]] and [[RenderMaterialElement.insert]] to create a [[RenderMaterial]] from parameters of this type.\r\n * @public\r\n */\r\nexport interface RenderMaterialElementParams extends RenderMaterialElement.Params { // eslint-disable-line deprecation/deprecation, @typescript-eslint/no-empty-interface\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileStorage.d.ts","sourceRoot":"","sources":["../../src/TileStorage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAmB,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAMtG;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,qBAAa,WAAW;IACtB;;;OAGG;IACH,SAAgB,OAAO,EAAE,aAAa,CAAC;gBAEpB,OAAO,EAAE,aAAa;IAIzC,OAAO,CAAC,mBAAmB,CAA0B;IAErD;;OAEG;IACU,UAAU,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"TileStorage.d.ts","sourceRoot":"","sources":["../../src/TileStorage.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,QAAQ,EAAmB,aAAa,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAMtG;;;GAGG;AACH,MAAM,WAAW,MAAM;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED;;;GAGG;AACH,qBAAa,WAAW;IACt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
if (this._initializedIModels.has(iModelId))
|
|
28
28
|
return;
|
|
29
29
|
if (!(await this.storage.baseDirectoryExists({ baseDirectory: iModelId }))) {
|
|
30
|
-
|
|
30
|
+
try {
|
|
31
|
+
await this.storage.createBaseDirectory({ baseDirectory: iModelId });
|
|
32
|
+
}
|
|
33
|
+
catch (e) {
|
|
34
|
+
// Ignore 409 errors. This is what Azure blob storage returns when the container already exists.
|
|
35
|
+
// Usually this means multiple backends tried to initialize tile storage at the same time.
|
|
36
|
+
if (e.statusCode !== 409)
|
|
37
|
+
throw e;
|
|
38
|
+
}
|
|
31
39
|
}
|
|
32
40
|
this._initializedIModels.add(iModelId);
|
|
33
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TileStorage.js","sourceRoot":"","sources":["../../src/TileStorage.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAAoC;AACpC,+BAAiC;AAEjC,oDAA4D;AAC5D,sDAA6C;AAC7C,mEAAgE;AAChE,6CAA0C;AAY1C;;;GAGG;AACH,MAAa,WAAW;IAOtB,YAAmB,OAAsB;QAIjC,wBAAmB,GAAgB,IAAI,GAAG,EAAE,CAAC;QAHnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;IACzB,CAAC;IAID;;OAEG;IACI,KAAK,CAAC,UAAU,CAAC,QAAgB;QACtC,IAAI,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC;YACxC,OAAO;QACT,IAAI,CAAC,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC,EAAE;YAC1E,MAAM,IAAI,CAAC,OAAO,CAAC,mBAAmB,CAAC,EAAE,aAAa,EAAE,QAAQ,EAAE,CAAC,CAAC;SACrE;QACD,IAAI,CAAC,mBAAmB,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IACzC,CAAC;IAED;;;;;;OAMG;IACI,KAA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C;IACP,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,cAAc,CAAC,QAAgB;QAC1C,MAAM,OAAO,GAAa,EAAE,CAAC;QAC7B,IAAI,KAAK,EAAE,MAAM,IAAI,IAAI,IAAI,CAAC,kBAAkB,CAAC,QAAQ,CAAC,EAAE;YAC1D,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;SACvB;QACD,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,WAAmB,EAAE,MAAc,EAAE,SAAiB,EAAE,IAAa;QAC/G,OAAO,IAAI,CAAC,OAAO,CAAC,YAAY,CAAC,IAAA,oCAAsB,EAAC,QAAQ,EAAE,WAAW,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC,CAAC;IAC3G,CAAC;IAEO,YAAY,CAAC,OAAe,EAAE,GAAY;QAChD,qBAAM,CAAC,YAAY,CACjB,6CAAqB,CAAC,iBAAiB,EACvC,GAAG,EACH,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,qBAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,OAAO,kBAAkB,EAAE,EAAE,GAAG,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CACnI,CAAC;IACJ,CAAC;CACF;AA3JD,kCA2JC","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\nimport { gunzip, gzip } from \"zlib\";\r\nimport { promisify } from \"util\";\r\nimport { Metadata, ObjectReference, ServerStorage, TransferConfig } from \"@itwin/object-storage-core\";\r\nimport { getTileObjectReference } from \"@itwin/core-common\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/**\r\n * Identifies a tile in cloud tile cache.\r\n * @beta\r\n */\r\nexport interface TileId {\r\n treeId: string;\r\n contentId: string;\r\n guid: string;\r\n}\r\n\r\n/**\r\n * Facilitates interaction with cloud tile cache.\r\n * @beta\r\n */\r\nexport class TileStorage {\r\n /**\r\n * Allows using the underlying `ServerStorage` API directly.\r\n * @see https://github.com/iTwin/object-storage/\r\n */\r\n public readonly storage: ServerStorage;\r\n\r\n public constructor(storage: ServerStorage) {\r\n this.storage = storage;\r\n }\r\n\r\n private _initializedIModels: Set<string> = new Set();\r\n\r\n /**\r\n * Ensures any required cloud storage resources for a specific iModel are ready to use.\r\n */\r\n public async initialize(iModelId: string): Promise<void> {\r\n if (this._initializedIModels.has(iModelId))\r\n return;\r\n if (!(await this.storage.baseDirectoryExists({ baseDirectory: iModelId }))) {\r\n await this.storage.createBaseDirectory({ baseDirectory: iModelId });\r\n }\r\n this._initializedIModels.add(iModelId);\r\n }\r\n\r\n /**\r\n * Returns config that can be used by frontends to download tiles\r\n * @param iModelId Id of the iModel\r\n * @param expiresInSeconds Optional number of seconds until the download URL expires. Defaults to expiring exactly at midnight of next Sunday to enable persistent client-side caching.\r\n * It is recommended to set this to a shorter period when using S3-compatible storage - an exact expiry date cannot be ensured due to limitations in their API.\r\n * @see [TileStorage]($frontend)\r\n */\r\n public async getDownloadConfig(iModelId: string, expiresInSeconds?: number): Promise<TransferConfig> {\r\n try {\r\n if (expiresInSeconds !== undefined)\r\n return await this.storage.getDownloadConfig({ baseDirectory: iModelId }, { expiresInSeconds });\r\n const expiresOn = new Date();\r\n expiresOn.setDate(expiresOn.getDate() + (7 - expiresOn.getDay())); // next Sunday\r\n expiresOn.setHours(0, 0, 0, 0); // exactly at midnight\r\n return await this.storage.getDownloadConfig({ baseDirectory: iModelId }, { expiresOn });\r\n } catch (err) {\r\n this.logException(\"Failed to get download config\", err);\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Uploads a tile to the cloud cache.\r\n */\r\n public async uploadTile(iModelId: string, changesetId: string, treeId: string, contentId: string, content: Uint8Array, guid?: string, metadata?: Metadata): Promise<void> {\r\n try {\r\n await this.storage.upload(\r\n getTileObjectReference(iModelId, changesetId, treeId, contentId, guid),\r\n Buffer.from(IModelHost.compressCachedTiles ? await promisify(gzip)(content.buffer) : content.buffer),\r\n metadata,\r\n IModelHost.compressCachedTiles ? { contentEncoding: \"gzip\" } : undefined,\r\n );\r\n } catch (err) {\r\n this.logException(\"Failed to upload tile\", err);\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Downloads a tile from the cloud cache.\r\n */\r\n public async downloadTile(iModelId: string, changesetId: string, treeId: string, contentId: string, guid?: string): Promise<Uint8Array> {\r\n try {\r\n const buffer = await this.storage.download(\r\n getTileObjectReference(iModelId, changesetId, treeId, contentId, guid),\r\n \"buffer\",\r\n );\r\n return IModelHost.compressCachedTiles ? await promisify(gunzip)(buffer) : buffer;\r\n } catch (err) {\r\n this.logException(\"Failed to download tile\", err);\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Returns an async iterator of all tiles that are found in the cloud cache.\r\n */\r\n public async *getCachedTilesGenerator(iModelId: string): AsyncGenerator<TileId> {\r\n const iterator = this.getCachedTilePages(iModelId);\r\n for await (const page of iterator) {\r\n for (const tile of page) {\r\n yield tile;\r\n }\r\n }\r\n }\r\n\r\n private async *getCachedTilePages(iModelId: string): AsyncGenerator<TileId[]> {\r\n const iterator = this.storage.getListObjectsPagedIterator({ baseDirectory: iModelId }, 500);\r\n let prevPage: IteratorResult<ObjectReference[], any> | undefined;\r\n do {\r\n // initiate loading the next page\r\n const page = iterator.next();\r\n // process results from the previous page\r\n if (prevPage)\r\n yield this.convertPage(prevPage.value);\r\n // finish loading the next page\r\n prevPage = await page;\r\n } while (!prevPage.done);\r\n }\r\n\r\n private convertPage(page: ObjectReference[]): TileId[] {\r\n return page\r\n .map((objectReference) => ({\r\n parts: objectReference.relativeDirectory?.split(\"/\") ?? [\"\"],\r\n objectName: objectReference.objectName,\r\n }))\r\n .filter(({ parts, objectName }) => {\r\n if (parts[0] !== \"tiles\")\r\n return false;\r\n if (parts.length !== 3) {\r\n Logger.logWarning(BackendLoggerCategory.IModelTileStorage, \"Malformed tile id found in tile cache: {tileId}\", { tileId: [...parts, objectName].join(\"/\") });\r\n return false;\r\n }\r\n return true;\r\n }).map(({ parts, objectName }) => {\r\n // relativeDirectory = tiles/<treeId>/<guid>\r\n // objectName = <contentId>\r\n return {\r\n treeId: parts[1],\r\n contentId: objectName,\r\n guid: parts[2],\r\n };\r\n });\r\n }\r\n\r\n /**\r\n * Returns a list of all tiles that are found in the cloud cache.\r\n */\r\n public async getCachedTiles(iModelId: string): Promise<TileId[]> {\r\n const results: TileId[] = [];\r\n for await (const page of this.getCachedTilePages(iModelId)) {\r\n results.push(...page);\r\n }\r\n return results;\r\n }\r\n\r\n /**\r\n * Returns a boolean indicating whether a tile exists in the cloud cache\r\n */\r\n public async isTileCached(iModelId: string, changesetId: string, treeId: string, contentId: string, guid?: string): Promise<boolean> {\r\n return this.storage.objectExists(getTileObjectReference(iModelId, changesetId, treeId, contentId, guid));\r\n }\r\n\r\n private logException(message: string, err: unknown): void {\r\n Logger.logException(\r\n BackendLoggerCategory.IModelTileStorage,\r\n err,\r\n (category, msg, errorMetadata) => Logger.logError(category, `${message}: {errorMessage}`, { ...errorMetadata, errorMessage: msg }),\r\n );\r\n }\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TileStorage.js","sourceRoot":"","sources":["../../src/TileStorage.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,+BAAoC;AACpC,+BAAiC;AAEjC,oDAA4D;AAC5D,sDAA6C;AAC7C,mEAAgE;AAChE,6CAA0C;AAY1C;;;GAGG;AACH,MAAa,WAAW;IAOtB,YAAmB,OAAsB;QAIjC,wBAAmB,GAAgB,IAAI,GAAG,EAAE,CAAC;QAHnD,IAAI,CAAC,OAAO,GAAG,OAAO,CAA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ACvC,GAAG,EACH,CAAC,QAAQ,EAAE,GAAG,EAAE,aAAa,EAAE,EAAE,CAAC,qBAAM,CAAC,QAAQ,CAAC,QAAQ,EAAE,GAAG,OAAO,kBAAkB,EAAE,EAAE,GAAG,aAAa,EAAE,YAAY,EAAE,GAAG,EAAE,CAAC,CACnI,CAAC;IACJ,CAAC;CACF;AAlKD,kCAkKC","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\nimport { gunzip, gzip } from \"zlib\";\r\nimport { promisify } from \"util\";\r\nimport { Metadata, ObjectReference, ServerStorage, TransferConfig } from \"@itwin/object-storage-core\";\r\nimport { getTileObjectReference } from \"@itwin/core-common\";\r\nimport { Logger } from \"@itwin/core-bentley\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { IModelHost } from \"./IModelHost\";\r\n\r\n/**\r\n * Identifies a tile in cloud tile cache.\r\n * @beta\r\n */\r\nexport interface TileId {\r\n treeId: string;\r\n contentId: string;\r\n guid: string;\r\n}\r\n\r\n/**\r\n * Facilitates interaction with cloud tile cache.\r\n * @beta\r\n */\r\nexport class TileStorage {\r\n /**\r\n * Allows using the underlying `ServerStorage` API directly.\r\n * @see https://github.com/iTwin/object-storage/\r\n */\r\n public readonly storage: ServerStorage;\r\n\r\n public constructor(storage: ServerStorage) {\r\n this.storage = storage;\r\n }\r\n\r\n private _initializedIModels: Set<string> = new Set();\r\n\r\n /**\r\n * Ensures any required cloud storage resources for a specific iModel are ready to use.\r\n */\r\n public async initialize(iModelId: string): Promise<void> {\r\n if (this._initializedIModels.has(iModelId))\r\n return;\r\n if (!(await this.storage.baseDirectoryExists({ baseDirectory: iModelId }))) {\r\n try {\r\n await this.storage.createBaseDirectory({ baseDirectory: iModelId });\r\n } catch (e: any) {\r\n // Ignore 409 errors. This is what Azure blob storage returns when the container already exists.\r\n // Usually this means multiple backends tried to initialize tile storage at the same time.\r\n if(e.statusCode !== 409)\r\n throw e;\r\n }\r\n }\r\n this._initializedIModels.add(iModelId);\r\n }\r\n\r\n /**\r\n * Returns config that can be used by frontends to download tiles\r\n * @param iModelId Id of the iModel\r\n * @param expiresInSeconds Optional number of seconds until the download URL expires. Defaults to expiring exactly at midnight of next Sunday to enable persistent client-side caching.\r\n * It is recommended to set this to a shorter period when using S3-compatible storage - an exact expiry date cannot be ensured due to limitations in their API.\r\n * @see [TileStorage]($frontend)\r\n */\r\n public async getDownloadConfig(iModelId: string, expiresInSeconds?: number): Promise<TransferConfig> {\r\n try {\r\n if (expiresInSeconds !== undefined)\r\n return await this.storage.getDownloadConfig({ baseDirectory: iModelId }, { expiresInSeconds });\r\n const expiresOn = new Date();\r\n expiresOn.setDate(expiresOn.getDate() + (7 - expiresOn.getDay())); // next Sunday\r\n expiresOn.setHours(0, 0, 0, 0); // exactly at midnight\r\n return await this.storage.getDownloadConfig({ baseDirectory: iModelId }, { expiresOn });\r\n } catch (err) {\r\n this.logException(\"Failed to get download config\", err);\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Uploads a tile to the cloud cache.\r\n */\r\n public async uploadTile(iModelId: string, changesetId: string, treeId: string, contentId: string, content: Uint8Array, guid?: string, metadata?: Metadata): Promise<void> {\r\n try {\r\n await this.storage.upload(\r\n getTileObjectReference(iModelId, changesetId, treeId, contentId, guid),\r\n Buffer.from(IModelHost.compressCachedTiles ? await promisify(gzip)(content.buffer) : content.buffer),\r\n metadata,\r\n IModelHost.compressCachedTiles ? { contentEncoding: \"gzip\" } : undefined,\r\n );\r\n } catch (err) {\r\n this.logException(\"Failed to upload tile\", err);\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Downloads a tile from the cloud cache.\r\n */\r\n public async downloadTile(iModelId: string, changesetId: string, treeId: string, contentId: string, guid?: string): Promise<Uint8Array> {\r\n try {\r\n const buffer = await this.storage.download(\r\n getTileObjectReference(iModelId, changesetId, treeId, contentId, guid),\r\n \"buffer\",\r\n );\r\n return IModelHost.compressCachedTiles ? await promisify(gunzip)(buffer) : buffer;\r\n } catch (err) {\r\n this.logException(\"Failed to download tile\", err);\r\n throw err;\r\n }\r\n }\r\n\r\n /**\r\n * Returns an async iterator of all tiles that are found in the cloud cache.\r\n */\r\n public async *getCachedTilesGenerator(iModelId: string): AsyncGenerator<TileId> {\r\n const iterator = this.getCachedTilePages(iModelId);\r\n for await (const page of iterator) {\r\n for (const tile of page) {\r\n yield tile;\r\n }\r\n }\r\n }\r\n\r\n private async *getCachedTilePages(iModelId: string): AsyncGenerator<TileId[]> {\r\n const iterator = this.storage.getListObjectsPagedIterator({ baseDirectory: iModelId }, 500);\r\n let prevPage: IteratorResult<ObjectReference[], any> | undefined;\r\n do {\r\n // initiate loading the next page\r\n const page = iterator.next();\r\n // process results from the previous page\r\n if (prevPage)\r\n yield this.convertPage(prevPage.value);\r\n // finish loading the next page\r\n prevPage = await page;\r\n } while (!prevPage.done);\r\n }\r\n\r\n private convertPage(page: ObjectReference[]): TileId[] {\r\n return page\r\n .map((objectReference) => ({\r\n parts: objectReference.relativeDirectory?.split(\"/\") ?? [\"\"],\r\n objectName: objectReference.objectName,\r\n }))\r\n .filter(({ parts, objectName }) => {\r\n if (parts[0] !== \"tiles\")\r\n return false;\r\n if (parts.length !== 3) {\r\n Logger.logWarning(BackendLoggerCategory.IModelTileStorage, \"Malformed tile id found in tile cache: {tileId}\", { tileId: [...parts, objectName].join(\"/\") });\r\n return false;\r\n }\r\n return true;\r\n }).map(({ parts, objectName }) => {\r\n // relativeDirectory = tiles/<treeId>/<guid>\r\n // objectName = <contentId>\r\n return {\r\n treeId: parts[1],\r\n contentId: objectName,\r\n guid: parts[2],\r\n };\r\n });\r\n }\r\n\r\n /**\r\n * Returns a list of all tiles that are found in the cloud cache.\r\n */\r\n public async getCachedTiles(iModelId: string): Promise<TileId[]> {\r\n const results: TileId[] = [];\r\n for await (const page of this.getCachedTilePages(iModelId)) {\r\n results.push(...page);\r\n }\r\n return results;\r\n }\r\n\r\n /**\r\n * Returns a boolean indicating whether a tile exists in the cloud cache\r\n */\r\n public async isTileCached(iModelId: string, changesetId: string, treeId: string, contentId: string, guid?: string): Promise<boolean> {\r\n return this.storage.objectExists(getTileObjectReference(iModelId, changesetId, treeId, contentId, guid));\r\n }\r\n\r\n private logException(message: string, err: unknown): void {\r\n Logger.logException(\r\n BackendLoggerCategory.IModelTileStorage,\r\n err,\r\n (category, msg, errorMetadata) => Logger.logError(category, `${message}: {errorMessage}`, { ...errorMetadata, errorMessage: msg }),\r\n );\r\n }\r\n}\r\n"]}
|