@itwin/core-backend 5.1.0-dev.47 → 5.1.0-dev.51
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/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +4 -0
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/annotations/TextAnnotationGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/TextAnnotationGeometry.js +49 -0
- package/lib/cjs/annotations/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextBlockGeometry.d.ts.map +1 -1
- package/lib/cjs/annotations/TextBlockGeometry.js +2 -1
- package/lib/cjs/annotations/TextBlockGeometry.js.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.d.ts +3 -1
- package/lib/cjs/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/cjs/annotations/TextBlockLayout.js +32 -2
- package/lib/cjs/annotations/TextBlockLayout.js.map +1 -1
- package/lib/esm/BriefcaseManager.d.ts.map +1 -1
- package/lib/esm/BriefcaseManager.js +5 -1
- package/lib/esm/BriefcaseManager.js.map +1 -1
- package/lib/esm/annotations/TextAnnotationGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/TextAnnotationGeometry.js +50 -1
- package/lib/esm/annotations/TextAnnotationGeometry.js.map +1 -1
- package/lib/esm/annotations/TextBlockGeometry.d.ts.map +1 -1
- package/lib/esm/annotations/TextBlockGeometry.js +2 -1
- package/lib/esm/annotations/TextBlockGeometry.js.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.d.ts +3 -1
- package/lib/esm/annotations/TextBlockLayout.d.ts.map +1 -1
- package/lib/esm/annotations/TextBlockLayout.js +32 -2
- package/lib/esm/annotations/TextBlockLayout.js.map +1 -1
- package/lib/esm/test/annotations/TextBlock.test.js +570 -434
- package/lib/esm/test/annotations/TextBlock.test.js.map +1 -1
- package/package.json +13 -13
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BriefcaseManager.d.ts","sourceRoot":"","sources":["../../src/BriefcaseManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EACL,WAAW,EAAE,UAAU,
|
|
1
|
+
{"version":3,"file":"BriefcaseManager.d.ts","sourceRoot":"","sources":["../../src/BriefcaseManager.ts"],"names":[],"mappings":"AAIA;;GAEG;AAKH,OAAO,EACL,WAAW,EAAE,UAAU,EAA6B,UAAU,EAAmD,QAAQ,EAC1H,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EAAoB,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,kBAAkB,EAAE,cAAc,EAAE,cAAc,EAA6C,mBAAmB,EACrM,YAAY,EAAE,aAAa,EAAE,wBAAwB,EACtD,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,wBAAwB,EAAE,oBAAoB,EAAE,yBAAyB,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AAE9H,OAAO,EAAsC,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAC3F,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAS7D;;EAEE;AACF,MAAM,WAAW,sBAAuB,SAAQ,QAAQ,EAAE,wBAAwB;IAChF;;OAEG;IACH,UAAU,CAAC,EAAE,gBAAgB,CAAC;CAC/B;AAED;;;GAGG;AACH,MAAM,WAAW,eAAgB,SAAQ,QAAQ;IAC/C,8EAA8E;IAC9E,WAAW,EAAE,MAAM,CAAC;IACpB,8IAA8I;IAC9I,WAAW,CAAC,EAAE,IAAI,CAAC;IACnB,oGAAoG;IACpG,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,4EAA4E;IAC5E,eAAe,CAAC,EAAE,UAAU,CAAC;IAC7B,8FAA8F;IAC9F,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,uFAAuF;IACvF,cAAc,CAAC,EAAE,UAAU,CAAC;IAC5B;;;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;QAAE,QAAQ,EAAE,UAAU,CAAC;QAAC,KAAK,EAAE,cAAc,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAIpH,wEAAwE;WACpD,kBAAkB,CAAC,GAAG,EAAE;QAAE,QAAQ,EAAE,UAAU,CAAA;KAAE,GAAG,OAAO,CAAC,cAAc,CAAC;IAI9F;;;OAGG;WACiB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC;IAI1F;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;mBAajB,oBAAoB;IAWzC,gBAAgB;WACI,qBAAqB,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,iBAAiB,GAAG,OAAO,CAAC,IAAI,CAAC;IAoD9F,gBAAgB;WACI,sBAAsB,CAAC,EAAE,EAAE,QAAQ,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;IA8E7F,4EAA4E;mBACvD,WAAW;IAgDhC;;OAEG;WACiB,aAAa,CAAC,EAAE,EAAE,WAAW,EAAE,GAAG,EAAE,eAAe,GAAG,OAAO,CAAC,IAAI,CAAC;CAgBxF"}
|
|
@@ -479,6 +479,10 @@ class BriefcaseManager {
|
|
|
479
479
|
if (!fileSize) // either undefined or 0 means error
|
|
480
480
|
throw new core_common_1.IModelError(core_bentley_1.IModelStatus.NoContent, "error creating changeset");
|
|
481
481
|
changesetProps.size = fileSize;
|
|
482
|
+
const id = NativePlatform_1.IModelNative.platform.DgnDb.computeChangesetId(changesetProps);
|
|
483
|
+
if (id !== changesetProps.id) {
|
|
484
|
+
throw new core_common_1.IModelError(core_bentley_1.DbResult.BE_SQLITE_ERROR_InvalidChangeSetVersion, `Changeset id ${changesetProps.id} does not match computed id ${id}.`);
|
|
485
|
+
}
|
|
482
486
|
let retryCount = arg.pushRetryCount ?? 3;
|
|
483
487
|
while (true) {
|
|
484
488
|
try {
|
|
@@ -1 +1 @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ClC,OAAO,IAAI,CAAC;oBAChB,CAAC;oBACD,OAAO,KAAK,CAAC;gBACf,CAAC,CAAC;gBAEF,IAAI,CAAC,WAAW,EAAE,EAAE,CAAC;oBACnB,EAAE,CAAC,mBAAS,CAAC,CAAC,sBAAsB,EAAE,CAAC;oBACvC,MAAM,GAAG,CAAC;gBACZ,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,uBAAU,CAAC,UAAU,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YACjD,CAAC;QACH,CAAC;IACH,CAAC;IAED;;OAEG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAAC,EAAe,EAAE,GAAoB;QACrE,IAAI,UAAU,GAAG,GAAG,CAAC,eAAe,IAAI,CAAC,CAAC;QAC1C,OAAO,IAAI,EAAE,CAAC;YACZ,IAAI,CAAC;gBACH,MAAM,gBAAgB,CAAC,sBAAsB,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;gBACvD,IAAI,CAAC,EAAE,CAAC,4BAA4B;oBAClC,MAAM,uBAAU,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;gBAC5B,OAAO,MAAM,gBAAgB,CAAC,WAAW,CAAC,EAAE,EAAE,GAAG,CAAC,CAAC;YACrD,CAAC;YAAC,OAAO,GAAQ,EAAE,CAAC;gBAClB,IAAI,UAAU,EAAE,IAAI,CAAC,IAAI,GAAG,CAAC,WAAW,KAAK,8BAAe,CAAC,cAAc;oBACzE,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,MAAM,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC;;AA9iBH,4CAgjBC","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 iModels\r\n */\r\n\r\n// cspell:ignore cset csets ecchanges\r\n\r\nimport * as path from \"path\";\r\nimport {\r\n AccessToken, BeDuration, ChangeSetStatus, GuidString, IModelHubStatus, IModelStatus, Logger, OpenMode, Optional, StopWatch,\r\n} from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseId, BriefcaseIdValue, BriefcaseProps, ChangesetFileProps, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange, ChangesetType, IModelError, IModelVersion, LocalBriefcaseProps,\r\n LocalDirName, LocalFileName, RequestNewBriefcaseProps,\r\n} from \"@itwin/core-common\";\r\nimport { AcquireNewBriefcaseIdArg, DownloadChangesetArg, DownloadChangesetRangeArg, IModelNameArg } from \"./BackendHubAccess\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { CheckpointManager, CheckpointProps, ProgressFunction } from \"./CheckpointManager\";\r\nimport { BriefcaseDb, IModelDb, TokenArg } from \"./IModelDb\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { SchemaSync } from \"./SchemaSync\";\r\nimport { _hubAccess, _nativeDb, _releaseAllLocks } from \"./internal/Symbols\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\n\r\nconst loggerCategory = BackendLoggerCategory.IModelDb;\r\n\r\n/** The argument for [[BriefcaseManager.downloadBriefcase]]\r\n * @public\r\n*/\r\nexport interface RequestNewBriefcaseArg extends TokenArg, RequestNewBriefcaseProps {\r\n /** If present, a function called periodically during the download to indicate progress.\r\n * @note return non-zero from this function to abort the download.\r\n */\r\n onProgress?: ProgressFunction;\r\n}\r\n\r\n/**\r\n * Parameters for pushing changesets to iModelHub\r\n * @public\r\n */\r\nexport interface PushChangesArgs extends TokenArg {\r\n /** A description of the changes. This is visible on the iModel's timeline. */\r\n description: string;\r\n /** if present, the locks are retained after the operation. Otherwise, *all* locks are released after the changeset is successfully pushed. */\r\n retainLocks?: true;\r\n /** number of times to retry pull/merge if other users are pushing at the same time. Default is 5 */\r\n mergeRetryCount?: number;\r\n /** delay to wait between pull/merge retry attempts. Default is 3 seconds */\r\n mergeRetryDelay?: BeDuration;\r\n /** the number of time to attempt to retry to push the changeset upon failure. Default is 3 */\r\n pushRetryCount?: number;\r\n /** The delay to wait between retry attempts on failed pushes. Default is 3 seconds. */\r\n pushRetryDelay?: BeDuration;\r\n /**\r\n * For testing purpose\r\n * @internal\r\n */\r\n noFastForward?: true;\r\n}\r\n\r\n/**\r\n * Specifies a specific index for pulling changes.\r\n * @public\r\n */\r\nexport interface ToChangesetArgs extends TokenArg {\r\n /** The last ChangesetIndex to pull. If not present, pull *all* newer changesets. */\r\n toIndex?: ChangesetIndex;\r\n}\r\n\r\n/** Arguments for [[BriefcaseManager.pullAndApplyChangesets]]\r\n * @public\r\n */\r\nexport type PullChangesArgs = ToChangesetArgs & {\r\n /** If present, a function called periodically during the download to indicate progress.\r\n * @note return non-zero from this function to abort the download.\r\n */\r\n onProgress?: ProgressFunction;\r\n /**\r\n * For testing purpose\r\n * @internal\r\n */\r\n noFastForward?: true;\r\n};\r\n\r\n/** Arguments for [[BriefcaseManager.revertTimelineChanges]]\r\n * @public\r\n */\r\nexport type RevertChangesArgs = Optional<PushChangesArgs, \"description\"> & {\r\n /** If present, a function called periodically during the download to indicate progress.\r\n * @note return non-zero from this function to abort the download.\r\n */\r\n onProgress?: ProgressFunction;\r\n /** The index of the changeset to revert to */\r\n toIndex: ChangesetIndex;\r\n /** If present, schema changes are skipped during the revert operation. */\r\n skipSchemaChanges?: true;\r\n};\r\n\r\n/** Manages downloading Briefcases and downloading and uploading changesets.\r\n * @public\r\n */\r\nexport class BriefcaseManager {\r\n /** Get the local path of the folder storing files that are associated with an imodel */\r\n public static getIModelPath(iModelId: GuidString): LocalDirName { return path.join(this._cacheDir, iModelId); }\r\n\r\n /** @internal */\r\n public static getChangeSetsPath(iModelId: GuidString): LocalDirName { return path.join(this.getIModelPath(iModelId), \"changesets\"); }\r\n\r\n /** @internal */\r\n public static getChangeCachePathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.ecchanges\")); }\r\n\r\n /** @internal */\r\n public static getChangedElementsPathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.elems\")); }\r\n\r\n private static _briefcaseSubDir = \"briefcases\";\r\n /** Get the local path of the folder storing briefcases associated with the specified iModel. */\r\n public static getBriefcaseBasePath(iModelId: GuidString): LocalDirName {\r\n return path.join(this.getIModelPath(iModelId), this._briefcaseSubDir);\r\n }\r\n\r\n /** Get the name of the local file that holds, or will hold, a local briefcase in the briefcase cache.\r\n * @note The briefcase cache is a local directory established in the call to [[BriefcaseManager.initialize]].\r\n * @param briefcase the iModelId and BriefcaseId for the filename\r\n * @see getIModelPath\r\n */\r\n public static getFileName(briefcase: BriefcaseProps): LocalFileName {\r\n return path.join(this.getBriefcaseBasePath(briefcase.iModelId), `${briefcase.briefcaseId}.bim`);\r\n }\r\n\r\n private static setupCacheDir(cacheRootDir: LocalDirName) {\r\n this._cacheDir = cacheRootDir;\r\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\r\n }\r\n\r\n private static _initialized?: boolean;\r\n /** Initialize BriefcaseManager\r\n * @param cacheRootDir The root directory for storing a cache of downloaded briefcase files on the local computer.\r\n * Briefcases are stored relative to this path in sub-folders organized by IModelId.\r\n * @note It is perfectly valid for applications to store briefcases in locations they manage, outside of `cacheRootDir`.\r\n */\r\n public static initialize(cacheRootDir: LocalDirName) {\r\n if (this._initialized)\r\n return;\r\n this.setupCacheDir(cacheRootDir);\r\n IModelHost.onBeforeShutdown.addOnce(() => this.finalize());\r\n this._initialized = true;\r\n }\r\n\r\n private static finalize() {\r\n this._initialized = false;\r\n }\r\n\r\n /** Get a list of the local briefcase held in the briefcase cache, optionally for a single iModelId\r\n * @param iModelId if present, only briefcases for this iModelId are returned, otherwise all briefcases for all\r\n * iModels in the briefcase cache are returned.\r\n * @note usually there should only be one briefcase per iModel.\r\n */\r\n public static getCachedBriefcases(iModelId?: GuidString): LocalBriefcaseProps[] {\r\n const briefcaseList: LocalBriefcaseProps[] = [];\r\n const iModelDirs = IModelJsFs.readdirSync(this._cacheDir);\r\n for (const iModelDir of iModelDirs) {\r\n if (iModelId && iModelId !== iModelDir)\r\n continue;\r\n const bcPath = path.join(this._cacheDir, iModelDir, this._briefcaseSubDir);\r\n try {\r\n if (!IModelJsFs.lstatSync(bcPath)?.isDirectory)\r\n continue;\r\n } catch {\r\n continue;\r\n }\r\n\r\n const briefcases = IModelJsFs.readdirSync(bcPath);\r\n for (const briefcaseName of briefcases) {\r\n if (briefcaseName.endsWith(\".bim\")) {\r\n try {\r\n const fileName = path.join(bcPath, briefcaseName);\r\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\r\n const db = IModelDb.openDgnDb({ path: fileName }, OpenMode.Readonly);\r\n briefcaseList.push({ fileName, iTwinId: db.getITwinId(), iModelId: db.getIModelId(), briefcaseId: db.getBriefcaseId(), changeset: db.getCurrentChangeset(), fileSize });\r\n db.closeFile();\r\n } catch { }\r\n }\r\n }\r\n }\r\n return briefcaseList;\r\n }\r\n\r\n private static _cacheDir: LocalDirName;\r\n /** Get the root directory for the briefcase cache */\r\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\r\n\r\n /** Determine whether the supplied briefcaseId is in the range of assigned BriefcaseIds issued by iModelHub\r\n * @note this does check whether the id was actually acquired by the caller.\r\n */\r\n public static isValidBriefcaseId(id: BriefcaseId) {\r\n return id >= BriefcaseIdValue.FirstValid && id <= BriefcaseIdValue.LastValid;\r\n }\r\n\r\n /** Acquire a new briefcaseId from iModelHub for the supplied iModelId\r\n * @note usually there should only be one briefcase per iModel per user. If a single user acquires more than one briefcaseId,\r\n * it's a good idea to supply different aliases for each of them.\r\n */\r\n public static async acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<BriefcaseId> {\r\n return IModelHost[_hubAccess].acquireNewBriefcaseId(arg);\r\n }\r\n\r\n /**\r\n * Download a new briefcase from iModelHub for the supplied iModelId.\r\n *\r\n * Briefcases are local files holding a copy of an iModel.\r\n * Briefcases may either be specific to an individual user (so that it can be modified to create changesets), or it can be readonly so it can accept but not create changesets.\r\n * Every briefcase internally holds its [[BriefcaseId]]. Writeable briefcases have a `BriefcaseId` \"assigned\" to them by iModelHub. No two users will ever have the same BriefcaseId.\r\n * Readonly briefcases are \"unassigned\" with the special value [[BriefcaseId.Unassigned]].\r\n *\r\n * Typically a given user will have only one briefcase on their machine for a given iModelId. Rarely, it may be necessary to use more than one\r\n * briefcase to make isolated independent sets of changes, but that is exceedingly complicated and rare.\r\n *\r\n * Callers of this method may supply a BriefcaseId, or if none is supplied, a new one is acquired from iModelHub.\r\n *\r\n * @param arg The arguments that specify the briefcase file to be downloaded.\r\n * @returns The properties of the local briefcase in a Promise that is resolved after the briefcase is fully downloaded and the briefcase file is ready for use via [BriefcaseDb.open]($backend).\r\n * @note The location of the local file to hold the briefcase is arbitrary and may be any valid *local* path on your machine. If you don't supply\r\n * a filename, the local briefcase cache is used by creating a file with the briefcaseId as its name in the `briefcases` folder below the folder named\r\n * for the IModelId.\r\n * @note *It is invalid to edit briefcases on a shared network drive* and that is a sure way to corrupt your briefcase (see https://www.sqlite.org/howtocorrupt.html)\r\n */\r\n public static async downloadBriefcase(arg: RequestNewBriefcaseArg): Promise<LocalBriefcaseProps> {\r\n const briefcaseId = arg.briefcaseId ?? await this.acquireNewBriefcaseId(arg);\r\n const fileName = arg.fileName ?? this.getFileName({ ...arg, briefcaseId });\r\n\r\n if (IModelJsFs.existsSync(fileName))\r\n throw new IModelError(IModelStatus.FileAlreadyExists, `Briefcase \"${fileName}\" already exists`);\r\n\r\n const asOf = arg.asOf ?? IModelVersion.latest().toJSON();\r\n const changeset = await IModelHost[_hubAccess].getChangesetFromVersion({ ...arg, version: IModelVersion.fromJSON(asOf) });\r\n const checkpoint: CheckpointProps = { ...arg, changeset };\r\n\r\n try {\r\n await CheckpointManager.downloadCheckpoint({ localFile: fileName, checkpoint, onProgress: arg.onProgress });\r\n } catch (error: unknown) {\r\n const errorMessage = `Failed to download briefcase to ${fileName}, errorMessage: ${(error as Error).message}`;\r\n if (arg.accessToken && arg.briefcaseId === undefined) {\r\n Logger.logInfo(loggerCategory, `${errorMessage}, releasing the briefcaseId...`);\r\n await this.releaseBriefcase(arg.accessToken, { briefcaseId, iModelId: arg.iModelId });\r\n }\r\n if (IModelJsFs.existsSync(fileName)) {\r\n if (arg.accessToken && arg.briefcaseId === undefined)\r\n Logger.logTrace(loggerCategory, `Deleting the file: ${fileName}...`);\r\n else\r\n Logger.logInfo(loggerCategory, `${errorMessage}, deleting the file...`);\r\n try {\r\n IModelJsFs.unlinkSync(fileName);\r\n Logger.logInfo(loggerCategory, `Deleted ${fileName}`);\r\n } catch (deleteError: unknown) {\r\n Logger.logWarning(loggerCategory, `Failed to delete ${fileName}. errorMessage: ${(deleteError as Error).message}`);\r\n }\r\n }\r\n throw error;\r\n }\r\n\r\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\r\n const response: LocalBriefcaseProps = {\r\n fileName,\r\n briefcaseId,\r\n iModelId: arg.iModelId,\r\n iTwinId: arg.iTwinId,\r\n changeset: checkpoint.changeset,\r\n fileSize,\r\n };\r\n\r\n // now open the downloaded checkpoint and reset its BriefcaseId\r\n const nativeDb = new IModelNative.platform.DgnDb();\r\n try {\r\n nativeDb.openIModel(fileName, OpenMode.ReadWrite);\r\n } catch (err: any) {\r\n throw new IModelError(err.errorNumber, `Could not open downloaded briefcase for write access: ${fileName}, err=${err.message}`);\r\n }\r\n try {\r\n nativeDb.enableWalMode(); // local briefcases should use WAL journal mode\r\n nativeDb.resetBriefcaseId(briefcaseId);\r\n if (nativeDb.getCurrentChangeset().id !== checkpoint.changeset.id)\r\n throw new IModelError(IModelStatus.InvalidId, `Downloaded briefcase has wrong changesetId: ${fileName}`);\r\n } finally {\r\n nativeDb.saveChanges();\r\n nativeDb.closeFile();\r\n }\r\n return response;\r\n }\r\n\r\n /** Deletes change sets of an iModel from local disk\r\n * @internal\r\n */\r\n public static deleteChangeSetsFromLocalDisk(iModelId: string) {\r\n const changesetsPath = BriefcaseManager.getChangeSetsPath(iModelId);\r\n BriefcaseManager.deleteFolderAndContents(changesetsPath);\r\n }\r\n\r\n /** Releases a briefcaseId from iModelHub. After this call it is illegal to generate changesets for the released briefcaseId.\r\n * @note generally, this method should not be called directly. Instead use [[deleteBriefcaseFiles]].\r\n * @see deleteBriefcaseFiles\r\n */\r\n public static async releaseBriefcase(accessToken: AccessToken, briefcase: BriefcaseProps): Promise<void> {\r\n if (this.isValidBriefcaseId(briefcase.briefcaseId))\r\n return IModelHost[_hubAccess].releaseBriefcase({ accessToken, iModelId: briefcase.iModelId, briefcaseId: briefcase.briefcaseId });\r\n }\r\n\r\n /**\r\n * Delete and clean up a briefcase and all of its associated files. First, this method opens the supplied filename to determine its briefcaseId.\r\n * Then, if a requestContext is supplied, it releases a BriefcaseId from iModelHub. Finally it deletes the local briefcase file and\r\n * associated files (that is, all files in the same directory that start with the briefcase name).\r\n * @param filePath the full file name of the Briefcase to delete\r\n * @param accessToken for releasing the briefcaseId\r\n */\r\n public static async deleteBriefcaseFiles(filePath: LocalFileName, accessToken?: AccessToken): Promise<void> {\r\n try {\r\n const db = IModelDb.openDgnDb({ path: filePath }, OpenMode.Readonly);\r\n const briefcase: BriefcaseProps = {\r\n iModelId: db.getIModelId(),\r\n briefcaseId: db.getBriefcaseId(),\r\n };\r\n db.closeFile();\r\n\r\n if (accessToken) {\r\n if (this.isValidBriefcaseId(briefcase.briefcaseId)) {\r\n await BriefcaseManager.releaseBriefcase(accessToken, briefcase);\r\n }\r\n }\r\n } catch { }\r\n\r\n // first try to delete the briefcase file\r\n try {\r\n if (IModelJsFs.existsSync(filePath))\r\n IModelJsFs.unlinkSync(filePath);\r\n } catch (err) {\r\n throw new IModelError(IModelStatus.BadRequest, `cannot delete briefcase file ${err}`);\r\n }\r\n\r\n // next, delete all files that start with the briefcase's filePath (e.g. \"a.bim-locks\", \"a.bim-journal\", etc.)\r\n try {\r\n const dirName = path.dirname(filePath);\r\n const fileName = path.basename(filePath);\r\n const files = IModelJsFs.readdirSync(dirName);\r\n for (const file of files) {\r\n if (file.startsWith(fileName))\r\n this.deleteFile(path.join(dirName, file)); // don't throw on error\r\n }\r\n } catch { }\r\n }\r\n\r\n /** Deletes a file\r\n * - Does not throw any error, but logs it instead\r\n * - Returns true if the delete was successful\r\n */\r\n private static deleteFile(pathname: LocalFileName): boolean {\r\n try {\r\n IModelJsFs.unlinkSync(pathname);\r\n } catch (error) {\r\n Logger.logError(loggerCategory, `Cannot delete file ${pathname}, ${error}`);\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Deletes a folder, checking if it's empty\r\n * - Does not throw any error, but logs it instead\r\n * - Returns true if the delete was successful\r\n */\r\n private static deleteFolderIfEmpty(folderPathname: LocalDirName): boolean {\r\n try {\r\n const files = IModelJsFs.readdirSync(folderPathname);\r\n if (files.length > 0)\r\n return false;\r\n\r\n IModelJsFs.rmdirSync(folderPathname);\r\n } catch {\r\n Logger.logError(loggerCategory, `Cannot delete folder: ${folderPathname}`);\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Deletes the contents of a folder, but not the folder itself\r\n * - Does not throw any errors, but logs them.\r\n * - returns true if the delete was successful.\r\n */\r\n private static deleteFolderContents(folderPathname: LocalDirName): boolean {\r\n if (!IModelJsFs.existsSync(folderPathname))\r\n return false;\r\n\r\n let status = true;\r\n const files = IModelJsFs.readdirSync(folderPathname);\r\n for (const file of files) {\r\n const curPath = path.join(folderPathname, file);\r\n const locStatus = (IModelJsFs.lstatSync(curPath)?.isDirectory) ? BriefcaseManager.deleteFolderAndContents(curPath) : BriefcaseManager.deleteFile(curPath);\r\n if (!locStatus)\r\n status = false;\r\n }\r\n return status;\r\n }\r\n\r\n /** Download all the changesets in the specified range.\r\n * @beta\r\n */\r\n public static async downloadChangesets(arg: DownloadChangesetRangeArg): Promise<ChangesetFileProps[]> {\r\n return IModelHost[_hubAccess].downloadChangesets(arg);\r\n }\r\n\r\n /** Download a single changeset.\r\n * @beta\r\n */\r\n public static async downloadChangeset(arg: DownloadChangesetArg): Promise<ChangesetFileProps> {\r\n return IModelHost[_hubAccess].downloadChangeset(arg);\r\n }\r\n\r\n /** Query the hub for the properties for a ChangesetIndex or ChangesetId */\r\n public static async queryChangeset(arg: { iModelId: GuidString, changeset: ChangesetIndexOrId }): Promise<ChangesetProps> {\r\n return IModelHost[_hubAccess].queryChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\r\n }\r\n\r\n /** Query the hub for an array of changeset properties given a ChangesetRange */\r\n public static async queryChangesets(arg: { iModelId: GuidString, range: ChangesetRange }): Promise<ChangesetProps[]> {\r\n return IModelHost[_hubAccess].queryChangesets({ ...arg, accessToken: await IModelHost.getAccessToken() });\r\n }\r\n\r\n /** Query the hub for the ChangesetProps of the most recent changeset */\r\n public static async getLatestChangeset(arg: { iModelId: GuidString }): Promise<ChangesetProps> {\r\n return IModelHost[_hubAccess].getLatestChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\r\n }\r\n\r\n /** Query the Id of an iModel by name.\r\n * @param arg Identifies the iModel of interest\r\n * @returns the Id of the corresponding iModel, or `undefined` if no such iModel exists.\r\n */\r\n public static async queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined> {\r\n return IModelHost[_hubAccess].queryIModelByName(arg);\r\n }\r\n\r\n /** Deletes a folder and all it's contents.\r\n * - Does not throw any errors, but logs them.\r\n * - returns true if the delete was successful.\r\n */\r\n private static deleteFolderAndContents(folderPathname: LocalDirName): boolean {\r\n if (!IModelJsFs.existsSync(folderPathname))\r\n return true;\r\n\r\n let status = false;\r\n status = BriefcaseManager.deleteFolderContents(folderPathname);\r\n if (!status)\r\n return false;\r\n\r\n status = BriefcaseManager.deleteFolderIfEmpty(folderPathname);\r\n return status;\r\n }\r\n\r\n private static async applySingleChangeset(db: IModelDb, changesetFile: ChangesetFileProps, fastForward: boolean) {\r\n if (changesetFile.changesType === ChangesetType.Schema || changesetFile.changesType === ChangesetType.SchemaSync)\r\n db.clearCaches(); // for schema changesets, statement caches may become invalid. Do this *before* applying, in case db needs to be closed (open statements hold db open.)\r\n\r\n db[_nativeDb].applyChangeset(changesetFile, fastForward);\r\n db.changeset = db[_nativeDb].getCurrentChangeset();\r\n\r\n // we're done with this changeset, delete it\r\n IModelJsFs.removeSync(changesetFile.pathname);\r\n }\r\n\r\n /** @internal */\r\n public static async revertTimelineChanges(db: IModelDb, arg: RevertChangesArgs): Promise<void> {\r\n if (!db.isOpen || db[_nativeDb].isReadonly())\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to revert timeline changes\");\r\n\r\n let currentIndex = db.changeset.index;\r\n if (currentIndex === undefined)\r\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\r\n\r\n if (!arg.toIndex) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be specified to revert changesets\");\r\n }\r\n if (arg.toIndex > currentIndex) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be less than or equal to the current index\");\r\n }\r\n if (!db.holdsSchemaLock) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot revert timeline changesets without holding a schema lock\");\r\n }\r\n\r\n // Download change sets\r\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\r\n accessToken: arg.accessToken,\r\n iModelId: db.iModelId,\r\n range: { first: arg.toIndex, end: currentIndex },\r\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\r\n progressCallback: arg.onProgress,\r\n });\r\n\r\n if (changesets.length === 0)\r\n return;\r\n\r\n changesets.reverse();\r\n db.clearCaches();\r\n\r\n const stopwatch = new StopWatch(`Reverting changes`, true);\r\n Logger.logInfo(loggerCategory, `Starting reverting timeline changes from ${arg.toIndex} to ${currentIndex}`);\r\n\r\n /**\r\n * Revert timeline changes from the current index to the specified index.\r\n * It does not change parent of the current changeset.\r\n * All changes during revert operation are stored in a new changeset.\r\n * Revert operation require schema lock as we do not acquire individual locks for each element.\r\n * Optionally schema changes can be skipped (required for schema sync case).\r\n */\r\n db[_nativeDb].revertTimelineChanges(changesets, arg.skipSchemaChanges ?? false);\r\n Logger.logInfo(loggerCategory, `Reverted timeline changes from ${arg.toIndex} to ${currentIndex} (${stopwatch.elapsedSeconds} seconds)`);\r\n\r\n changesets.forEach((changeset) => {\r\n IModelJsFs.removeSync(changeset.pathname);\r\n });\r\n db.notifyChangesetApplied();\r\n }\r\n\r\n /** @internal */\r\n public static async pullAndApplyChangesets(db: IModelDb, arg: PullChangesArgs): Promise<void> {\r\n if (!db.isOpen || db[_nativeDb].isReadonly()) // don't use db.isReadonly - we reopen the file writable just for this operation but db.isReadonly is still true\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to process change sets\");\r\n\r\n let currentIndex = db.changeset.index;\r\n if (currentIndex === undefined)\r\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\r\n\r\n const reverse = (arg.toIndex && arg.toIndex < currentIndex) ? true : false;\r\n\r\n if (db[_nativeDb].hasPendingTxns() && reverse) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot reverse changesets when there are pending changes\");\r\n }\r\n\r\n // Download change sets\r\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\r\n accessToken: arg.accessToken,\r\n iModelId: db.iModelId,\r\n range: { first: reverse ? arg.toIndex! + 1 : currentIndex + 1, end: reverse ? currentIndex : arg.toIndex }, // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\r\n progressCallback: arg.onProgress,\r\n });\r\n\r\n if (changesets.length === 0)\r\n return; // nothing to apply\r\n\r\n if (reverse)\r\n changesets.reverse();\r\n\r\n\r\n let appliedChangesets = -1;\r\n if (db[_nativeDb].hasPendingTxns() && !reverse && !arg.noFastForward) {\r\n // attempt to perform fast forward\r\n for (const changeset of changesets) {\r\n // do not waste time on schema changesets. They cannot be fastforwarded.\r\n if (changeset.changesType === ChangesetType.Schema || changeset.changesType === ChangesetType.SchemaSync)\r\n break;\r\n\r\n try {\r\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\r\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description} using fast forward method`);\r\n await this.applySingleChangeset(db, changeset, true);\r\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\r\n appliedChangesets++;\r\n db.saveChanges();\r\n } catch {\r\n db.abandonChanges();\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (appliedChangesets < changesets.length - 1) {\r\n db[_nativeDb].pullMergeBegin();\r\n for (const changeset of changesets.filter((_, index) => index > appliedChangesets)) {\r\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\r\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description}`);\r\n try {\r\n await this.applySingleChangeset(db, changeset, false);\r\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\r\n } catch (err: any) {\r\n if (err instanceof Error) {\r\n Logger.logError(loggerCategory, `Error applying changeset with id ${stopwatch.description}: ${err.message}`);\r\n }\r\n db.abandonChanges();\r\n db[_nativeDb].pullMergeEnd();\r\n throw err;\r\n }\r\n }\r\n db[_nativeDb].pullMergeEnd();\r\n if (!db.isReadonly) {\r\n db.saveChanges(\"Merge.\");\r\n }\r\n }\r\n\r\n // notify listeners\r\n db.notifyChangesetApplied();\r\n }\r\n /** create a changeset from the current changes, and push it to iModelHub */\r\n private static async pushChanges(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\r\n const changesetProps = db[_nativeDb].startCreateChangeset() as ChangesetFileProps;\r\n changesetProps.briefcaseId = db.briefcaseId;\r\n changesetProps.description = arg.description;\r\n const fileSize = IModelJsFs.lstatSync(changesetProps.pathname)?.size;\r\n if (!fileSize) // either undefined or 0 means error\r\n throw new IModelError(IModelStatus.NoContent, \"error creating changeset\");\r\n\r\n changesetProps.size = fileSize;\r\n\r\n let retryCount = arg.pushRetryCount ?? 3;\r\n while (true) {\r\n try {\r\n const accessToken = await IModelHost.getAccessToken();\r\n const index = await IModelHost[_hubAccess].pushChangeset({ accessToken, iModelId: db.iModelId, changesetProps });\r\n db[_nativeDb].completeCreateChangeset({ index });\r\n db.changeset = db[_nativeDb].getCurrentChangeset();\r\n if (!arg.retainLocks)\r\n await db.locks[_releaseAllLocks]();\r\n\r\n return;\r\n } catch (err: any) {\r\n const shouldRetry = () => {\r\n if (retryCount-- <= 0)\r\n return false;\r\n switch (err.errorNumber) {\r\n case IModelHubStatus.AnotherUserPushing:\r\n case IModelHubStatus.DatabaseTemporarilyLocked:\r\n case IModelHubStatus.OperationFailed:\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n if (!shouldRetry()) {\r\n db[_nativeDb].abandonCreateChangeset();\r\n throw err;\r\n }\r\n } finally {\r\n IModelJsFs.removeSync(changesetProps.pathname);\r\n }\r\n }\r\n }\r\n\r\n /** Pull/merge (if necessary), then push all local changes as a changeset. Called by [[BriefcaseDb.pushChanges]]\r\n * @internal\r\n */\r\n public static async pullMergePush(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\r\n let retryCount = arg.mergeRetryCount ?? 5;\r\n while (true) {\r\n try {\r\n await BriefcaseManager.pullAndApplyChangesets(db, arg);\r\n if (!db.skipSyncSchemasOnPullAndPush)\r\n await SchemaSync.pull(db);\r\n return await BriefcaseManager.pushChanges(db, arg);\r\n } catch (err: any) {\r\n if (retryCount-- <= 0 || err.errorNumber !== IModelHubStatus.PullIsRequired)\r\n throw (err);\r\n await (arg.mergeRetryDelay ?? BeDuration.fromSeconds(3)).wait();\r\n }\r\n }\r\n }\r\n\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"BriefcaseManager.js","sourceRoot":"","sources":["../../src/BriefcaseManager.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,qCAAqC;AAErC,6BAA6B;AAC7B,sDAE6B;AAC7B,oDAG4B;AAE5B,mEAAgE;AAChE,2DAA2F;AAC3F,yCAA6D;AAC7D,6CAA0C;AAC1C,6CAA0C;AAC1C,6CAA0C;AAC1C,gDAA6E;AAC7E,8DAAyD;AAEzD,MAAM,cAAc,GAAG,6CAAqB,CAAC,QAAQ,CAAC;AA0EtD;;GAEG;AACH,MAAa,gBAAgB;IAC3B,wFAAwF;IACjF,MAAM,CAAC,aAAa,CAAC,QAAoB,IAAkB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,SAAS,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;IAE/G,gBAAgB;IACT,MAAM,CAAC,iBAAiB,CAAC,QAAoB,IAAkB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,CAAC;IAErI,gBAAgB;IACT,MAAM,CAAC,sBAAsB,CAAC,QAAoB,IAAmB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC,CAAC;IAEhK,gBAAgB;IACT,MAAM,CAAC,0BAA0B,CAAC,QAAoB,IAAmB,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,aAAa,CAAC,QAAQ,CAAC,EAAE,QAAQ,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAC;IAExJ,MAAM,CAAC,gBAAgB,GAAG,YAA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,CAAC,WAAW,KAAK,8BAAe,CAAC,cAAc;oBACzE,MAAM,CAAC,GAAG,CAAC,CAAC;gBACd,MAAM,CAAC,GAAG,CAAC,eAAe,IAAI,yBAAU,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;YAClE,CAAC;QACH,CAAC;IACH,CAAC;;AAljBH,4CAojBC","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 iModels\r\n */\r\n\r\n// cspell:ignore cset csets ecchanges\r\n\r\nimport * as path from \"path\";\r\nimport {\r\n AccessToken, BeDuration, ChangeSetStatus, DbResult, GuidString, IModelHubStatus, IModelStatus, Logger, OpenMode, Optional, StopWatch\r\n} from \"@itwin/core-bentley\";\r\nimport {\r\n BriefcaseId, BriefcaseIdValue, BriefcaseProps, ChangesetFileProps, ChangesetIndex, ChangesetIndexOrId, ChangesetProps, ChangesetRange, ChangesetType, IModelError, IModelVersion, LocalBriefcaseProps,\r\n LocalDirName, LocalFileName, RequestNewBriefcaseProps,\r\n} from \"@itwin/core-common\";\r\nimport { AcquireNewBriefcaseIdArg, DownloadChangesetArg, DownloadChangesetRangeArg, IModelNameArg } from \"./BackendHubAccess\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { CheckpointManager, CheckpointProps, ProgressFunction } from \"./CheckpointManager\";\r\nimport { BriefcaseDb, IModelDb, TokenArg } from \"./IModelDb\";\r\nimport { IModelHost } from \"./IModelHost\";\r\nimport { IModelJsFs } from \"./IModelJsFs\";\r\nimport { SchemaSync } from \"./SchemaSync\";\r\nimport { _hubAccess, _nativeDb, _releaseAllLocks } from \"./internal/Symbols\";\r\nimport { IModelNative } from \"./internal/NativePlatform\";\r\n\r\nconst loggerCategory = BackendLoggerCategory.IModelDb;\r\n\r\n/** The argument for [[BriefcaseManager.downloadBriefcase]]\r\n * @public\r\n*/\r\nexport interface RequestNewBriefcaseArg extends TokenArg, RequestNewBriefcaseProps {\r\n /** If present, a function called periodically during the download to indicate progress.\r\n * @note return non-zero from this function to abort the download.\r\n */\r\n onProgress?: ProgressFunction;\r\n}\r\n\r\n/**\r\n * Parameters for pushing changesets to iModelHub\r\n * @public\r\n */\r\nexport interface PushChangesArgs extends TokenArg {\r\n /** A description of the changes. This is visible on the iModel's timeline. */\r\n description: string;\r\n /** if present, the locks are retained after the operation. Otherwise, *all* locks are released after the changeset is successfully pushed. */\r\n retainLocks?: true;\r\n /** number of times to retry pull/merge if other users are pushing at the same time. Default is 5 */\r\n mergeRetryCount?: number;\r\n /** delay to wait between pull/merge retry attempts. Default is 3 seconds */\r\n mergeRetryDelay?: BeDuration;\r\n /** the number of time to attempt to retry to push the changeset upon failure. Default is 3 */\r\n pushRetryCount?: number;\r\n /** The delay to wait between retry attempts on failed pushes. Default is 3 seconds. */\r\n pushRetryDelay?: BeDuration;\r\n /**\r\n * For testing purpose\r\n * @internal\r\n */\r\n noFastForward?: true;\r\n}\r\n\r\n/**\r\n * Specifies a specific index for pulling changes.\r\n * @public\r\n */\r\nexport interface ToChangesetArgs extends TokenArg {\r\n /** The last ChangesetIndex to pull. If not present, pull *all* newer changesets. */\r\n toIndex?: ChangesetIndex;\r\n}\r\n\r\n/** Arguments for [[BriefcaseManager.pullAndApplyChangesets]]\r\n * @public\r\n */\r\nexport type PullChangesArgs = ToChangesetArgs & {\r\n /** If present, a function called periodically during the download to indicate progress.\r\n * @note return non-zero from this function to abort the download.\r\n */\r\n onProgress?: ProgressFunction;\r\n /**\r\n * For testing purpose\r\n * @internal\r\n */\r\n noFastForward?: true;\r\n};\r\n\r\n/** Arguments for [[BriefcaseManager.revertTimelineChanges]]\r\n * @public\r\n */\r\nexport type RevertChangesArgs = Optional<PushChangesArgs, \"description\"> & {\r\n /** If present, a function called periodically during the download to indicate progress.\r\n * @note return non-zero from this function to abort the download.\r\n */\r\n onProgress?: ProgressFunction;\r\n /** The index of the changeset to revert to */\r\n toIndex: ChangesetIndex;\r\n /** If present, schema changes are skipped during the revert operation. */\r\n skipSchemaChanges?: true;\r\n};\r\n\r\n/** Manages downloading Briefcases and downloading and uploading changesets.\r\n * @public\r\n */\r\nexport class BriefcaseManager {\r\n /** Get the local path of the folder storing files that are associated with an imodel */\r\n public static getIModelPath(iModelId: GuidString): LocalDirName { return path.join(this._cacheDir, iModelId); }\r\n\r\n /** @internal */\r\n public static getChangeSetsPath(iModelId: GuidString): LocalDirName { return path.join(this.getIModelPath(iModelId), \"changesets\"); }\r\n\r\n /** @internal */\r\n public static getChangeCachePathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.ecchanges\")); }\r\n\r\n /** @internal */\r\n public static getChangedElementsPathName(iModelId: GuidString): LocalFileName { return path.join(this.getIModelPath(iModelId), iModelId.concat(\".bim.elems\")); }\r\n\r\n private static _briefcaseSubDir = \"briefcases\";\r\n /** Get the local path of the folder storing briefcases associated with the specified iModel. */\r\n public static getBriefcaseBasePath(iModelId: GuidString): LocalDirName {\r\n return path.join(this.getIModelPath(iModelId), this._briefcaseSubDir);\r\n }\r\n\r\n /** Get the name of the local file that holds, or will hold, a local briefcase in the briefcase cache.\r\n * @note The briefcase cache is a local directory established in the call to [[BriefcaseManager.initialize]].\r\n * @param briefcase the iModelId and BriefcaseId for the filename\r\n * @see getIModelPath\r\n */\r\n public static getFileName(briefcase: BriefcaseProps): LocalFileName {\r\n return path.join(this.getBriefcaseBasePath(briefcase.iModelId), `${briefcase.briefcaseId}.bim`);\r\n }\r\n\r\n private static setupCacheDir(cacheRootDir: LocalDirName) {\r\n this._cacheDir = cacheRootDir;\r\n IModelJsFs.recursiveMkDirSync(this._cacheDir);\r\n }\r\n\r\n private static _initialized?: boolean;\r\n /** Initialize BriefcaseManager\r\n * @param cacheRootDir The root directory for storing a cache of downloaded briefcase files on the local computer.\r\n * Briefcases are stored relative to this path in sub-folders organized by IModelId.\r\n * @note It is perfectly valid for applications to store briefcases in locations they manage, outside of `cacheRootDir`.\r\n */\r\n public static initialize(cacheRootDir: LocalDirName) {\r\n if (this._initialized)\r\n return;\r\n this.setupCacheDir(cacheRootDir);\r\n IModelHost.onBeforeShutdown.addOnce(() => this.finalize());\r\n this._initialized = true;\r\n }\r\n\r\n private static finalize() {\r\n this._initialized = false;\r\n }\r\n\r\n /** Get a list of the local briefcase held in the briefcase cache, optionally for a single iModelId\r\n * @param iModelId if present, only briefcases for this iModelId are returned, otherwise all briefcases for all\r\n * iModels in the briefcase cache are returned.\r\n * @note usually there should only be one briefcase per iModel.\r\n */\r\n public static getCachedBriefcases(iModelId?: GuidString): LocalBriefcaseProps[] {\r\n const briefcaseList: LocalBriefcaseProps[] = [];\r\n const iModelDirs = IModelJsFs.readdirSync(this._cacheDir);\r\n for (const iModelDir of iModelDirs) {\r\n if (iModelId && iModelId !== iModelDir)\r\n continue;\r\n const bcPath = path.join(this._cacheDir, iModelDir, this._briefcaseSubDir);\r\n try {\r\n if (!IModelJsFs.lstatSync(bcPath)?.isDirectory)\r\n continue;\r\n } catch {\r\n continue;\r\n }\r\n\r\n const briefcases = IModelJsFs.readdirSync(bcPath);\r\n for (const briefcaseName of briefcases) {\r\n if (briefcaseName.endsWith(\".bim\")) {\r\n try {\r\n const fileName = path.join(bcPath, briefcaseName);\r\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\r\n const db = IModelDb.openDgnDb({ path: fileName }, OpenMode.Readonly);\r\n briefcaseList.push({ fileName, iTwinId: db.getITwinId(), iModelId: db.getIModelId(), briefcaseId: db.getBriefcaseId(), changeset: db.getCurrentChangeset(), fileSize });\r\n db.closeFile();\r\n } catch { }\r\n }\r\n }\r\n }\r\n return briefcaseList;\r\n }\r\n\r\n private static _cacheDir: LocalDirName;\r\n /** Get the root directory for the briefcase cache */\r\n public static get cacheDir(): LocalDirName { return this._cacheDir; }\r\n\r\n /** Determine whether the supplied briefcaseId is in the range of assigned BriefcaseIds issued by iModelHub\r\n * @note this does check whether the id was actually acquired by the caller.\r\n */\r\n public static isValidBriefcaseId(id: BriefcaseId) {\r\n return id >= BriefcaseIdValue.FirstValid && id <= BriefcaseIdValue.LastValid;\r\n }\r\n\r\n /** Acquire a new briefcaseId from iModelHub for the supplied iModelId\r\n * @note usually there should only be one briefcase per iModel per user. If a single user acquires more than one briefcaseId,\r\n * it's a good idea to supply different aliases for each of them.\r\n */\r\n public static async acquireNewBriefcaseId(arg: AcquireNewBriefcaseIdArg): Promise<BriefcaseId> {\r\n return IModelHost[_hubAccess].acquireNewBriefcaseId(arg);\r\n }\r\n\r\n /**\r\n * Download a new briefcase from iModelHub for the supplied iModelId.\r\n *\r\n * Briefcases are local files holding a copy of an iModel.\r\n * Briefcases may either be specific to an individual user (so that it can be modified to create changesets), or it can be readonly so it can accept but not create changesets.\r\n * Every briefcase internally holds its [[BriefcaseId]]. Writeable briefcases have a `BriefcaseId` \"assigned\" to them by iModelHub. No two users will ever have the same BriefcaseId.\r\n * Readonly briefcases are \"unassigned\" with the special value [[BriefcaseId.Unassigned]].\r\n *\r\n * Typically a given user will have only one briefcase on their machine for a given iModelId. Rarely, it may be necessary to use more than one\r\n * briefcase to make isolated independent sets of changes, but that is exceedingly complicated and rare.\r\n *\r\n * Callers of this method may supply a BriefcaseId, or if none is supplied, a new one is acquired from iModelHub.\r\n *\r\n * @param arg The arguments that specify the briefcase file to be downloaded.\r\n * @returns The properties of the local briefcase in a Promise that is resolved after the briefcase is fully downloaded and the briefcase file is ready for use via [BriefcaseDb.open]($backend).\r\n * @note The location of the local file to hold the briefcase is arbitrary and may be any valid *local* path on your machine. If you don't supply\r\n * a filename, the local briefcase cache is used by creating a file with the briefcaseId as its name in the `briefcases` folder below the folder named\r\n * for the IModelId.\r\n * @note *It is invalid to edit briefcases on a shared network drive* and that is a sure way to corrupt your briefcase (see https://www.sqlite.org/howtocorrupt.html)\r\n */\r\n public static async downloadBriefcase(arg: RequestNewBriefcaseArg): Promise<LocalBriefcaseProps> {\r\n const briefcaseId = arg.briefcaseId ?? await this.acquireNewBriefcaseId(arg);\r\n const fileName = arg.fileName ?? this.getFileName({ ...arg, briefcaseId });\r\n\r\n if (IModelJsFs.existsSync(fileName))\r\n throw new IModelError(IModelStatus.FileAlreadyExists, `Briefcase \"${fileName}\" already exists`);\r\n\r\n const asOf = arg.asOf ?? IModelVersion.latest().toJSON();\r\n const changeset = await IModelHost[_hubAccess].getChangesetFromVersion({ ...arg, version: IModelVersion.fromJSON(asOf) });\r\n const checkpoint: CheckpointProps = { ...arg, changeset };\r\n\r\n try {\r\n await CheckpointManager.downloadCheckpoint({ localFile: fileName, checkpoint, onProgress: arg.onProgress });\r\n } catch (error: unknown) {\r\n const errorMessage = `Failed to download briefcase to ${fileName}, errorMessage: ${(error as Error).message}`;\r\n if (arg.accessToken && arg.briefcaseId === undefined) {\r\n Logger.logInfo(loggerCategory, `${errorMessage}, releasing the briefcaseId...`);\r\n await this.releaseBriefcase(arg.accessToken, { briefcaseId, iModelId: arg.iModelId });\r\n }\r\n if (IModelJsFs.existsSync(fileName)) {\r\n if (arg.accessToken && arg.briefcaseId === undefined)\r\n Logger.logTrace(loggerCategory, `Deleting the file: ${fileName}...`);\r\n else\r\n Logger.logInfo(loggerCategory, `${errorMessage}, deleting the file...`);\r\n try {\r\n IModelJsFs.unlinkSync(fileName);\r\n Logger.logInfo(loggerCategory, `Deleted ${fileName}`);\r\n } catch (deleteError: unknown) {\r\n Logger.logWarning(loggerCategory, `Failed to delete ${fileName}. errorMessage: ${(deleteError as Error).message}`);\r\n }\r\n }\r\n throw error;\r\n }\r\n\r\n const fileSize = IModelJsFs.lstatSync(fileName)?.size ?? 0;\r\n const response: LocalBriefcaseProps = {\r\n fileName,\r\n briefcaseId,\r\n iModelId: arg.iModelId,\r\n iTwinId: arg.iTwinId,\r\n changeset: checkpoint.changeset,\r\n fileSize,\r\n };\r\n\r\n // now open the downloaded checkpoint and reset its BriefcaseId\r\n const nativeDb = new IModelNative.platform.DgnDb();\r\n try {\r\n nativeDb.openIModel(fileName, OpenMode.ReadWrite);\r\n } catch (err: any) {\r\n throw new IModelError(err.errorNumber, `Could not open downloaded briefcase for write access: ${fileName}, err=${err.message}`);\r\n }\r\n try {\r\n nativeDb.enableWalMode(); // local briefcases should use WAL journal mode\r\n nativeDb.resetBriefcaseId(briefcaseId);\r\n if (nativeDb.getCurrentChangeset().id !== checkpoint.changeset.id)\r\n throw new IModelError(IModelStatus.InvalidId, `Downloaded briefcase has wrong changesetId: ${fileName}`);\r\n } finally {\r\n nativeDb.saveChanges();\r\n nativeDb.closeFile();\r\n }\r\n return response;\r\n }\r\n\r\n /** Deletes change sets of an iModel from local disk\r\n * @internal\r\n */\r\n public static deleteChangeSetsFromLocalDisk(iModelId: string) {\r\n const changesetsPath = BriefcaseManager.getChangeSetsPath(iModelId);\r\n BriefcaseManager.deleteFolderAndContents(changesetsPath);\r\n }\r\n\r\n /** Releases a briefcaseId from iModelHub. After this call it is illegal to generate changesets for the released briefcaseId.\r\n * @note generally, this method should not be called directly. Instead use [[deleteBriefcaseFiles]].\r\n * @see deleteBriefcaseFiles\r\n */\r\n public static async releaseBriefcase(accessToken: AccessToken, briefcase: BriefcaseProps): Promise<void> {\r\n if (this.isValidBriefcaseId(briefcase.briefcaseId))\r\n return IModelHost[_hubAccess].releaseBriefcase({ accessToken, iModelId: briefcase.iModelId, briefcaseId: briefcase.briefcaseId });\r\n }\r\n\r\n /**\r\n * Delete and clean up a briefcase and all of its associated files. First, this method opens the supplied filename to determine its briefcaseId.\r\n * Then, if a requestContext is supplied, it releases a BriefcaseId from iModelHub. Finally it deletes the local briefcase file and\r\n * associated files (that is, all files in the same directory that start with the briefcase name).\r\n * @param filePath the full file name of the Briefcase to delete\r\n * @param accessToken for releasing the briefcaseId\r\n */\r\n public static async deleteBriefcaseFiles(filePath: LocalFileName, accessToken?: AccessToken): Promise<void> {\r\n try {\r\n const db = IModelDb.openDgnDb({ path: filePath }, OpenMode.Readonly);\r\n const briefcase: BriefcaseProps = {\r\n iModelId: db.getIModelId(),\r\n briefcaseId: db.getBriefcaseId(),\r\n };\r\n db.closeFile();\r\n\r\n if (accessToken) {\r\n if (this.isValidBriefcaseId(briefcase.briefcaseId)) {\r\n await BriefcaseManager.releaseBriefcase(accessToken, briefcase);\r\n }\r\n }\r\n } catch { }\r\n\r\n // first try to delete the briefcase file\r\n try {\r\n if (IModelJsFs.existsSync(filePath))\r\n IModelJsFs.unlinkSync(filePath);\r\n } catch (err) {\r\n throw new IModelError(IModelStatus.BadRequest, `cannot delete briefcase file ${err}`);\r\n }\r\n\r\n // next, delete all files that start with the briefcase's filePath (e.g. \"a.bim-locks\", \"a.bim-journal\", etc.)\r\n try {\r\n const dirName = path.dirname(filePath);\r\n const fileName = path.basename(filePath);\r\n const files = IModelJsFs.readdirSync(dirName);\r\n for (const file of files) {\r\n if (file.startsWith(fileName))\r\n this.deleteFile(path.join(dirName, file)); // don't throw on error\r\n }\r\n } catch { }\r\n }\r\n\r\n /** Deletes a file\r\n * - Does not throw any error, but logs it instead\r\n * - Returns true if the delete was successful\r\n */\r\n private static deleteFile(pathname: LocalFileName): boolean {\r\n try {\r\n IModelJsFs.unlinkSync(pathname);\r\n } catch (error) {\r\n Logger.logError(loggerCategory, `Cannot delete file ${pathname}, ${error}`);\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Deletes a folder, checking if it's empty\r\n * - Does not throw any error, but logs it instead\r\n * - Returns true if the delete was successful\r\n */\r\n private static deleteFolderIfEmpty(folderPathname: LocalDirName): boolean {\r\n try {\r\n const files = IModelJsFs.readdirSync(folderPathname);\r\n if (files.length > 0)\r\n return false;\r\n\r\n IModelJsFs.rmdirSync(folderPathname);\r\n } catch {\r\n Logger.logError(loggerCategory, `Cannot delete folder: ${folderPathname}`);\r\n return false;\r\n }\r\n return true;\r\n }\r\n\r\n /** Deletes the contents of a folder, but not the folder itself\r\n * - Does not throw any errors, but logs them.\r\n * - returns true if the delete was successful.\r\n */\r\n private static deleteFolderContents(folderPathname: LocalDirName): boolean {\r\n if (!IModelJsFs.existsSync(folderPathname))\r\n return false;\r\n\r\n let status = true;\r\n const files = IModelJsFs.readdirSync(folderPathname);\r\n for (const file of files) {\r\n const curPath = path.join(folderPathname, file);\r\n const locStatus = (IModelJsFs.lstatSync(curPath)?.isDirectory) ? BriefcaseManager.deleteFolderAndContents(curPath) : BriefcaseManager.deleteFile(curPath);\r\n if (!locStatus)\r\n status = false;\r\n }\r\n return status;\r\n }\r\n\r\n /** Download all the changesets in the specified range.\r\n * @beta\r\n */\r\n public static async downloadChangesets(arg: DownloadChangesetRangeArg): Promise<ChangesetFileProps[]> {\r\n return IModelHost[_hubAccess].downloadChangesets(arg);\r\n }\r\n\r\n /** Download a single changeset.\r\n * @beta\r\n */\r\n public static async downloadChangeset(arg: DownloadChangesetArg): Promise<ChangesetFileProps> {\r\n return IModelHost[_hubAccess].downloadChangeset(arg);\r\n }\r\n\r\n /** Query the hub for the properties for a ChangesetIndex or ChangesetId */\r\n public static async queryChangeset(arg: { iModelId: GuidString, changeset: ChangesetIndexOrId }): Promise<ChangesetProps> {\r\n return IModelHost[_hubAccess].queryChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\r\n }\r\n\r\n /** Query the hub for an array of changeset properties given a ChangesetRange */\r\n public static async queryChangesets(arg: { iModelId: GuidString, range: ChangesetRange }): Promise<ChangesetProps[]> {\r\n return IModelHost[_hubAccess].queryChangesets({ ...arg, accessToken: await IModelHost.getAccessToken() });\r\n }\r\n\r\n /** Query the hub for the ChangesetProps of the most recent changeset */\r\n public static async getLatestChangeset(arg: { iModelId: GuidString }): Promise<ChangesetProps> {\r\n return IModelHost[_hubAccess].getLatestChangeset({ ...arg, accessToken: await IModelHost.getAccessToken() });\r\n }\r\n\r\n /** Query the Id of an iModel by name.\r\n * @param arg Identifies the iModel of interest\r\n * @returns the Id of the corresponding iModel, or `undefined` if no such iModel exists.\r\n */\r\n public static async queryIModelByName(arg: IModelNameArg): Promise<GuidString | undefined> {\r\n return IModelHost[_hubAccess].queryIModelByName(arg);\r\n }\r\n\r\n /** Deletes a folder and all it's contents.\r\n * - Does not throw any errors, but logs them.\r\n * - returns true if the delete was successful.\r\n */\r\n private static deleteFolderAndContents(folderPathname: LocalDirName): boolean {\r\n if (!IModelJsFs.existsSync(folderPathname))\r\n return true;\r\n\r\n let status = false;\r\n status = BriefcaseManager.deleteFolderContents(folderPathname);\r\n if (!status)\r\n return false;\r\n\r\n status = BriefcaseManager.deleteFolderIfEmpty(folderPathname);\r\n return status;\r\n }\r\n\r\n private static async applySingleChangeset(db: IModelDb, changesetFile: ChangesetFileProps, fastForward: boolean) {\r\n if (changesetFile.changesType === ChangesetType.Schema || changesetFile.changesType === ChangesetType.SchemaSync)\r\n db.clearCaches(); // for schema changesets, statement caches may become invalid. Do this *before* applying, in case db needs to be closed (open statements hold db open.)\r\n\r\n db[_nativeDb].applyChangeset(changesetFile, fastForward);\r\n db.changeset = db[_nativeDb].getCurrentChangeset();\r\n\r\n // we're done with this changeset, delete it\r\n IModelJsFs.removeSync(changesetFile.pathname);\r\n }\r\n\r\n /** @internal */\r\n public static async revertTimelineChanges(db: IModelDb, arg: RevertChangesArgs): Promise<void> {\r\n if (!db.isOpen || db[_nativeDb].isReadonly())\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to revert timeline changes\");\r\n\r\n let currentIndex = db.changeset.index;\r\n if (currentIndex === undefined)\r\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\r\n\r\n if (!arg.toIndex) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be specified to revert changesets\");\r\n }\r\n if (arg.toIndex > currentIndex) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"toIndex must be less than or equal to the current index\");\r\n }\r\n if (!db.holdsSchemaLock) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot revert timeline changesets without holding a schema lock\");\r\n }\r\n\r\n // Download change sets\r\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\r\n accessToken: arg.accessToken,\r\n iModelId: db.iModelId,\r\n range: { first: arg.toIndex, end: currentIndex },\r\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\r\n progressCallback: arg.onProgress,\r\n });\r\n\r\n if (changesets.length === 0)\r\n return;\r\n\r\n changesets.reverse();\r\n db.clearCaches();\r\n\r\n const stopwatch = new StopWatch(`Reverting changes`, true);\r\n Logger.logInfo(loggerCategory, `Starting reverting timeline changes from ${arg.toIndex} to ${currentIndex}`);\r\n\r\n /**\r\n * Revert timeline changes from the current index to the specified index.\r\n * It does not change parent of the current changeset.\r\n * All changes during revert operation are stored in a new changeset.\r\n * Revert operation require schema lock as we do not acquire individual locks for each element.\r\n * Optionally schema changes can be skipped (required for schema sync case).\r\n */\r\n db[_nativeDb].revertTimelineChanges(changesets, arg.skipSchemaChanges ?? false);\r\n Logger.logInfo(loggerCategory, `Reverted timeline changes from ${arg.toIndex} to ${currentIndex} (${stopwatch.elapsedSeconds} seconds)`);\r\n\r\n changesets.forEach((changeset) => {\r\n IModelJsFs.removeSync(changeset.pathname);\r\n });\r\n db.notifyChangesetApplied();\r\n }\r\n\r\n /** @internal */\r\n public static async pullAndApplyChangesets(db: IModelDb, arg: PullChangesArgs): Promise<void> {\r\n if (!db.isOpen || db[_nativeDb].isReadonly()) // don't use db.isReadonly - we reopen the file writable just for this operation but db.isReadonly is still true\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Briefcase must be open ReadWrite to process change sets\");\r\n\r\n let currentIndex = db.changeset.index;\r\n if (currentIndex === undefined)\r\n currentIndex = (await IModelHost[_hubAccess].queryChangeset({ accessToken: arg.accessToken, iModelId: db.iModelId, changeset: { id: db.changeset.id } })).index;\r\n\r\n const reverse = (arg.toIndex && arg.toIndex < currentIndex) ? true : false;\r\n\r\n if (db[_nativeDb].hasPendingTxns() && reverse) {\r\n throw new IModelError(ChangeSetStatus.ApplyError, \"Cannot reverse changesets when there are pending changes\");\r\n }\r\n\r\n // Download change sets\r\n const changesets = await IModelHost[_hubAccess].downloadChangesets({\r\n accessToken: arg.accessToken,\r\n iModelId: db.iModelId,\r\n range: { first: reverse ? arg.toIndex! + 1 : currentIndex + 1, end: reverse ? currentIndex : arg.toIndex }, // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n targetDir: BriefcaseManager.getChangeSetsPath(db.iModelId),\r\n progressCallback: arg.onProgress,\r\n });\r\n\r\n if (changesets.length === 0)\r\n return; // nothing to apply\r\n\r\n if (reverse)\r\n changesets.reverse();\r\n\r\n\r\n let appliedChangesets = -1;\r\n if (db[_nativeDb].hasPendingTxns() && !reverse && !arg.noFastForward) {\r\n // attempt to perform fast forward\r\n for (const changeset of changesets) {\r\n // do not waste time on schema changesets. They cannot be fastforwarded.\r\n if (changeset.changesType === ChangesetType.Schema || changeset.changesType === ChangesetType.SchemaSync)\r\n break;\r\n\r\n try {\r\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\r\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description} using fast forward method`);\r\n await this.applySingleChangeset(db, changeset, true);\r\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\r\n appliedChangesets++;\r\n db.saveChanges();\r\n } catch {\r\n db.abandonChanges();\r\n break;\r\n }\r\n }\r\n }\r\n\r\n if (appliedChangesets < changesets.length - 1) {\r\n db[_nativeDb].pullMergeBegin();\r\n for (const changeset of changesets.filter((_, index) => index > appliedChangesets)) {\r\n const stopwatch = new StopWatch(`[${changeset.id}]`, true);\r\n Logger.logInfo(loggerCategory, `Starting application of changeset with id ${stopwatch.description}`);\r\n try {\r\n await this.applySingleChangeset(db, changeset, false);\r\n Logger.logInfo(loggerCategory, `Applied changeset with id ${stopwatch.description} (${stopwatch.elapsedSeconds} seconds)`);\r\n } catch (err: any) {\r\n if (err instanceof Error) {\r\n Logger.logError(loggerCategory, `Error applying changeset with id ${stopwatch.description}: ${err.message}`);\r\n }\r\n db.abandonChanges();\r\n db[_nativeDb].pullMergeEnd();\r\n throw err;\r\n }\r\n }\r\n db[_nativeDb].pullMergeEnd();\r\n if (!db.isReadonly) {\r\n db.saveChanges(\"Merge.\");\r\n }\r\n }\r\n\r\n // notify listeners\r\n db.notifyChangesetApplied();\r\n }\r\n /** create a changeset from the current changes, and push it to iModelHub */\r\n private static async pushChanges(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\r\n const changesetProps = db[_nativeDb].startCreateChangeset() as ChangesetFileProps;\r\n changesetProps.briefcaseId = db.briefcaseId;\r\n changesetProps.description = arg.description;\r\n const fileSize = IModelJsFs.lstatSync(changesetProps.pathname)?.size;\r\n if (!fileSize) // either undefined or 0 means error\r\n throw new IModelError(IModelStatus.NoContent, \"error creating changeset\");\r\n\r\n changesetProps.size = fileSize;\r\n const id = IModelNative.platform.DgnDb.computeChangesetId(changesetProps);\r\n if (id !== changesetProps.id) {\r\n throw new IModelError(DbResult.BE_SQLITE_ERROR_InvalidChangeSetVersion, `Changeset id ${changesetProps.id} does not match computed id ${id}.`);\r\n }\r\n\r\n let retryCount = arg.pushRetryCount ?? 3;\r\n while (true) {\r\n try {\r\n const accessToken = await IModelHost.getAccessToken();\r\n const index = await IModelHost[_hubAccess].pushChangeset({ accessToken, iModelId: db.iModelId, changesetProps });\r\n db[_nativeDb].completeCreateChangeset({ index });\r\n db.changeset = db[_nativeDb].getCurrentChangeset();\r\n if (!arg.retainLocks)\r\n await db.locks[_releaseAllLocks]();\r\n\r\n return;\r\n } catch (err: any) {\r\n const shouldRetry = () => {\r\n if (retryCount-- <= 0)\r\n return false;\r\n switch (err.errorNumber) {\r\n case IModelHubStatus.AnotherUserPushing:\r\n case IModelHubStatus.DatabaseTemporarilyLocked:\r\n case IModelHubStatus.OperationFailed:\r\n return true;\r\n }\r\n return false;\r\n };\r\n\r\n if (!shouldRetry()) {\r\n db[_nativeDb].abandonCreateChangeset();\r\n throw err;\r\n }\r\n } finally {\r\n IModelJsFs.removeSync(changesetProps.pathname);\r\n }\r\n }\r\n }\r\n\r\n /** Pull/merge (if necessary), then push all local changes as a changeset. Called by [[BriefcaseDb.pushChanges]]\r\n * @internal\r\n */\r\n public static async pullMergePush(db: BriefcaseDb, arg: PushChangesArgs): Promise<void> {\r\n let retryCount = arg.mergeRetryCount ?? 5;\r\n while (true) {\r\n try {\r\n await BriefcaseManager.pullAndApplyChangesets(db, arg);\r\n if (!db.skipSyncSchemasOnPullAndPush)\r\n await SchemaSync.pull(db);\r\n return await BriefcaseManager.pushChanges(db, arg);\r\n } catch (err: any) {\r\n if (retryCount-- <= 0 || err.errorNumber !== IModelHubStatus.PullIsRequired)\r\n throw (err);\r\n await (arg.mergeRetryDelay ?? BeDuration.fromSeconds(3)).wait();\r\n }\r\n }\r\n }\r\n\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotationGeometry.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,eAAe,EAA+C,mBAAmB,EAAuB,MAAM,oBAAoB,CAAC;AACtJ,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIvD;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAC/C,4GAA4G;IAC5G,eAAe,EAAE,mBAAmB,CAAC;IACrC,qDAAqD;IACrD,MAAM,EAAE,eAAe,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IACjC,4FAA4F;IAC5F,UAAU,EAAE,UAAU,CAAA;IACtB,yGAAyG;IACzG,aAAa,CAAC,EAAE,UAAU,CAAA;IAC1B,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,gCAAgC,GAAG,OAAO,
|
|
1
|
+
{"version":3,"file":"TextAnnotationGeometry.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAY,eAAe,EAA+C,mBAAmB,EAAuB,MAAM,oBAAoB,CAAC;AACtJ,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,OAAO,EAAQ,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAIvD;;;;GAIG;AACH,MAAM,WAAW,gCAAgC;IAC/C,4GAA4G;IAC5G,eAAe,EAAE,mBAAmB,CAAC;IACrC,qDAAqD;IACrD,MAAM,EAAE,eAAe,CAAC;IACxB,6CAA6C;IAC7C,OAAO,EAAE,eAAe,CAAC,OAAO,CAAC;IACjC,4FAA4F;IAC5F,UAAU,EAAE,UAAU,CAAA;IACtB,yGAAyG;IACzG,aAAa,CAAC,EAAE,UAAU,CAAA;IAC1B,+FAA+F;IAC/F,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED;;;GAGG;AACH,wBAAgB,4BAA4B,CAAC,KAAK,EAAE,gCAAgC,GAAG,OAAO,CAwB7F"}
|
|
@@ -33,6 +33,7 @@ function appendTextAnnotationGeometry(props) {
|
|
|
33
33
|
// Construct the debug geometry
|
|
34
34
|
if (props.wantDebugGeometry) {
|
|
35
35
|
result = result && debugAnchorPoint(props.builder, annotation, props.layout, annotation.computeTransform(props.layout.range));
|
|
36
|
+
result = result && debugRunLayout(props.builder, props.layout, annotation.computeTransform(props.layout.range));
|
|
36
37
|
if (annotation.frame)
|
|
37
38
|
result = result && debugSnapPoints(props.builder, annotation.frame, props.layout.range, annotation.computeTransform(props.layout.range));
|
|
38
39
|
}
|
|
@@ -80,4 +81,52 @@ function debugSnapPoints(builder, frame, range, transform) {
|
|
|
80
81
|
const result = builder.appendGeometryParamsChange(params) && builder.appendGeometryQuery(core_geometry_1.PointString3d.create(points));
|
|
81
82
|
return result;
|
|
82
83
|
}
|
|
84
|
+
/**
|
|
85
|
+
* Draws debug geometry for each line and run in a TextBlockLayout.
|
|
86
|
+
*
|
|
87
|
+
* For each line and run, this function draws boxes to visualize their layout and boundaries.
|
|
88
|
+
* Different run types (e.g., text, linebreak, fraction, tab) are assigned distinct colors for clarity.
|
|
89
|
+
* This is useful for debugging text layout and alignment issues.
|
|
90
|
+
*
|
|
91
|
+
* @param builder - The geometry builder to append debug geometry to.
|
|
92
|
+
* @param layout - The text block layout containing lines and runs to visualize.
|
|
93
|
+
* @param documentTransform - The transform to apply to the entire document.
|
|
94
|
+
* @returns True if all debug geometry was successfully appended.
|
|
95
|
+
*/
|
|
96
|
+
function debugRunLayout(builder, layout, documentTransform) {
|
|
97
|
+
let result = true; // Tracks if all geometry was appended successfully
|
|
98
|
+
let color = core_common_1.ColorDef.black; // Current color for the run type
|
|
99
|
+
let lastColor = color; // Last color used, to minimize param changes
|
|
100
|
+
// Map run types to debug colors
|
|
101
|
+
const colors = {
|
|
102
|
+
"text": core_common_1.ColorDef.fromString("orange"),
|
|
103
|
+
"linebreak": core_common_1.ColorDef.fromString("yellow"),
|
|
104
|
+
"fraction": core_common_1.ColorDef.fromString("green"),
|
|
105
|
+
"tab": core_common_1.ColorDef.fromString("aquamarine"),
|
|
106
|
+
};
|
|
107
|
+
layout.lines.forEach(line => {
|
|
108
|
+
// Apply the line's offset transform
|
|
109
|
+
const lineTrans = core_geometry_1.Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);
|
|
110
|
+
documentTransform.multiplyTransformTransform(lineTrans, lineTrans);
|
|
111
|
+
line.runs.forEach(run => {
|
|
112
|
+
// Determine color for this run type
|
|
113
|
+
color = colors[run.source.type] ?? core_common_1.ColorDef.black;
|
|
114
|
+
// Only change geometry params if the color changes
|
|
115
|
+
if (!lastColor.equals(color)) {
|
|
116
|
+
const colorParams = new core_common_1.GeometryParams(core_bentley_1.Id64.invalid);
|
|
117
|
+
colorParams.lineColor = color;
|
|
118
|
+
result = result && builder.appendGeometryParamsChange(colorParams);
|
|
119
|
+
lastColor = color;
|
|
120
|
+
}
|
|
121
|
+
// Apply the line's offset to the run's offset
|
|
122
|
+
const runTrans = core_geometry_1.Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);
|
|
123
|
+
lineTrans.multiplyTransformTransform(runTrans, runTrans);
|
|
124
|
+
// Draw the enclosing range for the run
|
|
125
|
+
const runCorners = run.range.corners3d(true);
|
|
126
|
+
runTrans.multiplyPoint3dArrayInPlace(runCorners);
|
|
127
|
+
result = result && builder.appendGeometryQuery(core_geometry_1.LineString3d.create(runCorners));
|
|
128
|
+
});
|
|
129
|
+
});
|
|
130
|
+
return result;
|
|
131
|
+
}
|
|
83
132
|
//# sourceMappingURL=TextAnnotationGeometry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextAnnotationGeometry.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAiCH,oEAuBC;AAtDD,oDAAsJ;AAEtJ,wDAAuF;AACvF,sDAAuD;AACvD,2DAA+D;AAC/D,mDAA8E;AAsB9E;;;GAGG;AACH,SAAgB,4BAA4B,CAAC,KAAuC;IAClF,MAAM,UAAU,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,uBAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACrD,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,kCAAkC;IAClC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,OAAO,CAAC,0BAA0B,CAAC,aAAa,CAAC,CAAC;IAErE,MAAM,YAAY,GAAG,MAAM,CAAC,SAAS,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;IACtD,SAAS,CAAC,2BAA2B,CAAC,YAAY,CAAC,CAAC;IACpD,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC,4BAAY,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC,CAAC;IAElF,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,iJAAiJ;AACjJ,SAAS,eAAe,CAAC,OAAgC,EAAE,KAA0B,EAAE,KAAc,EAAE,SAAoB;IACzH,IAAI,SAAS,KAAK,KAAK,CAAC,KAAK,IAAI,KAAK,CAAC,KAAK,KAAK,MAAM;QACrD,OAAO,KAAK,CAAC;IACf,MAAM,MAAM,GAAG,IAAA,qCAAqB,EAAC,EAAE,KAAK,EAAE,KAAK,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,kBAAkB,EAAE,GAAG,EAAE,iBAAiB,EAAE,IAAI,EAAE,CAAC,CAAC;IAEjI,MAAM,MAAM,GAAG,IAAI,4BAAc,CAAC,mBAAI,CAAC,OAAO,CAAC,CAAC;IAChD,MAAM,CAAC,SAAS,GAAG,sBAAQ,CAAC,KAAK,CAAC;IAClC,MAAM,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,YAAY,IAAI,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,mEAAmE;IAClH,MAAM,CAAC,WAAW,GAAG,yBAAW,CAAC,MAAM,CAAC;IAExC,MAAM,MAAM,GAAG,OAAO,CAAC,0BAA0B,CAAC,MAAM,CAAC,IAAI,OAAO,CAAC,mBAAmB,CAAC,6BAAa,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACvH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\nimport { ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotation, TextAnnotationProps, TextFrameStyleProps } from \"@itwin/core-common\";\r\nimport { TextBlockLayout } from \"./TextBlockLayout\";\r\nimport { LineString3d, PointString3d, Range2d, Transform } from \"@itwin/core-geometry\";\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { produceTextBlockGeometry } from \"./TextBlockGeometry\";\r\nimport { appendFrameToBuilder, computeIntervalPoints } from \"./FrameGeometry\";\r\n\r\n/**\r\n * Properties required to compute the geometry of a text annotation.\r\n * @beta\r\n * @see [[appendTextAnnotationGeometry]] to append the geometry to an [[ElementGeometry.Builder]].\r\n */\r\nexport interface AppendTextAnnotationGeometryArgs {\r\n /** The annotation to be drawn. Be sure to include a TextBlock with runs or no geometry will be produced. */\r\n annotationProps: TextAnnotationProps;\r\n /** Layout provided by calling [[layoutTextBlock]] */\r\n layout: TextBlockLayout;\r\n /** Builder that will be added to in place */\r\n builder: ElementGeometry.Builder;\r\n /** The category the element will belong to. This will passed into the [[GeometryParams]] */\r\n categoryId: Id64String\r\n /** The optional sub-category the element will belong to. This will passed into the [[GeometryParams]] */\r\n subCategoryId?: Id64String\r\n /** Whether or not to draw geometry for things like the snap points, range, and anchor point */\r\n wantDebugGeometry?: boolean;\r\n}\r\n\r\n/** Constructs the TextBlockGeometry and frame geometry and appends the geometry to the provided builder.\r\n * @returns true if the geometry was successfully appended.\r\n * @beta\r\n */\r\nexport function appendTextAnnotationGeometry(props: AppendTextAnnotationGeometryArgs): boolean {\r\n const annotation = TextAnnotation.fromJSON(props.annotationProps);\r\n const range = Range2d.fromJSON(props.layout.range);\r\n const transform = annotation.computeTransform(range);\r\n let result = true;\r\n\r\n // Construct the TextBlockGeometry\r\n const params = new GeometryParams(props.categoryId, props.subCategoryId);\r\n const entries = produceTextBlockGeometry(props.layout, annotation.computeTransform(props.layout.range));\r\n result = result && props.builder.appendTextBlock(entries, params);\r\n\r\n // Construct the frame geometry\r\n if (annotation.frame && annotation.frame.shape !== \"none\") {\r\n result = result && appendFrameToBuilder(props.builder, annotation.frame, range, transform, params);\r\n }\r\n\r\n // Construct the debug geometry\r\n if (props.wantDebugGeometry) {\r\n result = result && debugAnchorPoint(props.builder, annotation, props.layout, annotation.computeTransform(props.layout.range));\r\n if (annotation.frame) result = result && debugSnapPoints(props.builder, annotation.frame, props.layout.range, annotation.computeTransform(props.layout.range));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * Draws the anchor point and margins of the text annotation.\r\n * The anchor point is the point around which the text rotates and is drawn as a blue x (1m by 1m).\r\n * The margins are drawn as a blue box.\r\n * The text range is drawn as a red box.\r\n */\r\nfunction debugAnchorPoint(builder: ElementGeometry.Builder, annotation: TextAnnotation, layout: TextBlockLayout, transform: Transform): boolean {\r\n const range = Range2d.fromJSON(layout.range);\r\n const debugAnchorPt = transform.multiplyPoint3d(annotation.computeAnchorPoint(range));\r\n\r\n // Make it blue\r\n const blueLineParams = new GeometryParams(Id64.invalid);\r\n blueLineParams.lineColor = ColorDef.blue;\r\n let result = builder.appendGeometryParamsChange(blueLineParams);\r\n\r\n // Draw a blue box to show the element's margin\r\n const marginCorners = range.corners3d(true);\r\n transform.multiplyPoint3dArrayInPlace(marginCorners);\r\n result = result && builder.appendGeometryQuery(LineString3d.create(marginCorners));\r\n\r\n // Draw a blue x to show the anchor point - Rotation occurs around this point. The x will be 1 m by 1 m.\r\n result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(-1, -1), debugAnchorPt.plusXYZ(1, 1)));\r\n result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(1, -1), debugAnchorPt.plusXYZ(-1, 1)));\r\n\r\n // Draw a red box to show the text range\r\n const redLineParams = new GeometryParams(Id64.invalid);\r\n redLineParams.lineColor = ColorDef.red;\r\n result = result && builder.appendGeometryParamsChange(redLineParams);\r\n\r\n const rangeCorners = layout.textRange.corners3d(true);\r\n transform.multiplyPoint3dArrayInPlace(rangeCorners);\r\n result = result && builder.appendGeometryQuery(LineString3d.create(rangeCorners));\r\n\r\n return result;\r\n}\r\n\r\n/** Draws the interval points defined by calling [[computeIntervalPoints]]. The points are shown as black dots 5x larger than the borderWeight */\r\nfunction debugSnapPoints(builder: ElementGeometry.Builder, frame: TextFrameStyleProps, range: Range2d, transform: Transform): boolean {\r\n if (undefined === frame.shape || frame.shape === \"none\")\r\n return false;\r\n const points = computeIntervalPoints({ frame: frame.shape, range, transform, lineIntervalFactor: 0.5, arcIntervalFactor: 0.25 });\r\n\r\n const params = new GeometryParams(Id64.invalid);\r\n params.lineColor = ColorDef.black;\r\n params.weight = (frame.borderWeight ?? 1) * 5; // We want the dots to be bigger than the frame so we can see them.\r\n params.fillDisplay = FillDisplay.Always;\r\n\r\n const result = builder.appendGeometryParamsChange(params) && builder.appendGeometryQuery(PointString3d.create(points));\r\n return result;\r\n}"]}
|
|
1
|
+
{"version":3,"file":"TextAnnotationGeometry.js","sourceRoot":"","sources":["../../../src/annotations/TextAnnotationGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAiCH,oEAwBC;AAvDD,oDAAsJ;AAEtJ,wDAAuF;AACvF,sDAAuD;AACvD,2DAA+D;AAC/D,mDAA8E;AAsB9E;;;GAGG;AACH,SAAgB,4BAA4B,CAAC,KAAuC;IAClF,MAAM,UAAU,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,eAAe,CAAC,CAAC;IAClE,MAAM,KAAK,GAAG,uBAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;IACnD,MAAM,SAAS,GAAG,UAAU,CAAC,gBAAgB,CAAC,KAAK,CAAC,CAAC;IACrD,IAAI,MAAM,GAAG,IAAI,CAAC;IAElB,kCAAkC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,CAAC;gBACrD,WAAW,CAAC,SAAS,GAAG,KAAK,CAAC;gBAC9B,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,0BAA0B,CAAC,WAAW,CAAC,CAAC;gBACnE,SAAS,GAAG,KAAK,CAAC;YACpB,CAAC;YAED,8CAA8C;YAC9C,MAAM,QAAQ,GAAG,yBAAS,CAAC,oBAAoB,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,EAAE,GAAG,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/F,SAAS,CAAC,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YAEzD,uCAAuC;YACvC,MAAM,UAAU,GAAG,GAAG,CAAC,KAAK,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;YAC7C,QAAQ,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;YACjD,MAAM,GAAG,MAAM,IAAI,OAAO,CAAC,mBAAmB,CAAC,4BAAY,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC;QAClF,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,OAAO,MAAM,CAAC;AAChB,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\nimport { ColorDef, ElementGeometry, FillDisplay, GeometryParams, TextAnnotation, TextAnnotationProps, TextFrameStyleProps } from \"@itwin/core-common\";\r\nimport { TextBlockLayout } from \"./TextBlockLayout\";\r\nimport { LineString3d, PointString3d, Range2d, Transform } from \"@itwin/core-geometry\";\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { produceTextBlockGeometry } from \"./TextBlockGeometry\";\r\nimport { appendFrameToBuilder, computeIntervalPoints } from \"./FrameGeometry\";\r\n\r\n/**\r\n * Properties required to compute the geometry of a text annotation.\r\n * @beta\r\n * @see [[appendTextAnnotationGeometry]] to append the geometry to an [[ElementGeometry.Builder]].\r\n */\r\nexport interface AppendTextAnnotationGeometryArgs {\r\n /** The annotation to be drawn. Be sure to include a TextBlock with runs or no geometry will be produced. */\r\n annotationProps: TextAnnotationProps;\r\n /** Layout provided by calling [[layoutTextBlock]] */\r\n layout: TextBlockLayout;\r\n /** Builder that will be added to in place */\r\n builder: ElementGeometry.Builder;\r\n /** The category the element will belong to. This will passed into the [[GeometryParams]] */\r\n categoryId: Id64String\r\n /** The optional sub-category the element will belong to. This will passed into the [[GeometryParams]] */\r\n subCategoryId?: Id64String\r\n /** Whether or not to draw geometry for things like the snap points, range, and anchor point */\r\n wantDebugGeometry?: boolean;\r\n}\r\n\r\n/** Constructs the TextBlockGeometry and frame geometry and appends the geometry to the provided builder.\r\n * @returns true if the geometry was successfully appended.\r\n * @beta\r\n */\r\nexport function appendTextAnnotationGeometry(props: AppendTextAnnotationGeometryArgs): boolean {\r\n const annotation = TextAnnotation.fromJSON(props.annotationProps);\r\n const range = Range2d.fromJSON(props.layout.range);\r\n const transform = annotation.computeTransform(range);\r\n let result = true;\r\n\r\n // Construct the TextBlockGeometry\r\n const params = new GeometryParams(props.categoryId, props.subCategoryId);\r\n const entries = produceTextBlockGeometry(props.layout, annotation.computeTransform(props.layout.range));\r\n result = result && props.builder.appendTextBlock(entries, params);\r\n\r\n // Construct the frame geometry\r\n if (annotation.frame && annotation.frame.shape !== \"none\") {\r\n result = result && appendFrameToBuilder(props.builder, annotation.frame, range, transform, params);\r\n }\r\n\r\n // Construct the debug geometry\r\n if (props.wantDebugGeometry) {\r\n result = result && debugAnchorPoint(props.builder, annotation, props.layout, annotation.computeTransform(props.layout.range));\r\n result = result && debugRunLayout(props.builder, props.layout, annotation.computeTransform(props.layout.range));\r\n if (annotation.frame) result = result && debugSnapPoints(props.builder, annotation.frame, props.layout.range, annotation.computeTransform(props.layout.range));\r\n }\r\n\r\n return result;\r\n};\r\n\r\n/**\r\n * Draws the anchor point and margins of the text annotation.\r\n * The anchor point is the point around which the text rotates and is drawn as a blue x (1m by 1m).\r\n * The margins are drawn as a blue box.\r\n * The text range is drawn as a red box.\r\n */\r\nfunction debugAnchorPoint(builder: ElementGeometry.Builder, annotation: TextAnnotation, layout: TextBlockLayout, transform: Transform): boolean {\r\n const range = Range2d.fromJSON(layout.range);\r\n const debugAnchorPt = transform.multiplyPoint3d(annotation.computeAnchorPoint(range));\r\n\r\n // Make it blue\r\n const blueLineParams = new GeometryParams(Id64.invalid);\r\n blueLineParams.lineColor = ColorDef.blue;\r\n let result = builder.appendGeometryParamsChange(blueLineParams);\r\n\r\n // Draw a blue box to show the element's margin\r\n const marginCorners = range.corners3d(true);\r\n transform.multiplyPoint3dArrayInPlace(marginCorners);\r\n result = result && builder.appendGeometryQuery(LineString3d.create(marginCorners));\r\n\r\n // Draw a blue x to show the anchor point - Rotation occurs around this point. The x will be 1 m by 1 m.\r\n result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(-1, -1), debugAnchorPt.plusXYZ(1, 1)));\r\n result = result && builder.appendGeometryQuery(LineString3d.create(debugAnchorPt.plusXYZ(1, -1), debugAnchorPt.plusXYZ(-1, 1)));\r\n\r\n // Draw a red box to show the text range\r\n const redLineParams = new GeometryParams(Id64.invalid);\r\n redLineParams.lineColor = ColorDef.red;\r\n result = result && builder.appendGeometryParamsChange(redLineParams);\r\n\r\n const rangeCorners = layout.textRange.corners3d(true);\r\n transform.multiplyPoint3dArrayInPlace(rangeCorners);\r\n result = result && builder.appendGeometryQuery(LineString3d.create(rangeCorners));\r\n\r\n return result;\r\n}\r\n\r\n/** Draws the interval points defined by calling [[computeIntervalPoints]]. The points are shown as black dots 5x larger than the borderWeight */\r\nfunction debugSnapPoints(builder: ElementGeometry.Builder, frame: TextFrameStyleProps, range: Range2d, transform: Transform): boolean {\r\n if (undefined === frame.shape || frame.shape === \"none\")\r\n return false;\r\n const points = computeIntervalPoints({ frame: frame.shape, range, transform, lineIntervalFactor: 0.5, arcIntervalFactor: 0.25 });\r\n\r\n const params = new GeometryParams(Id64.invalid);\r\n params.lineColor = ColorDef.black;\r\n params.weight = (frame.borderWeight ?? 1) * 5; // We want the dots to be bigger than the frame so we can see them.\r\n params.fillDisplay = FillDisplay.Always;\r\n\r\n const result = builder.appendGeometryParamsChange(params) && builder.appendGeometryQuery(PointString3d.create(points));\r\n return result;\r\n}\r\n\r\n/**\r\n * Draws debug geometry for each line and run in a TextBlockLayout.\r\n *\r\n * For each line and run, this function draws boxes to visualize their layout and boundaries.\r\n * Different run types (e.g., text, linebreak, fraction, tab) are assigned distinct colors for clarity.\r\n * This is useful for debugging text layout and alignment issues.\r\n *\r\n * @param builder - The geometry builder to append debug geometry to.\r\n * @param layout - The text block layout containing lines and runs to visualize.\r\n * @param documentTransform - The transform to apply to the entire document.\r\n * @returns True if all debug geometry was successfully appended.\r\n */\r\nfunction debugRunLayout(builder: ElementGeometry.Builder, layout: TextBlockLayout, documentTransform: Transform): boolean {\r\n let result = true; // Tracks if all geometry was appended successfully\r\n let color = ColorDef.black; // Current color for the run type\r\n let lastColor = color; // Last color used, to minimize param changes\r\n\r\n // Map run types to debug colors\r\n const colors = {\r\n \"text\": ColorDef.fromString(\"orange\"),\r\n \"linebreak\": ColorDef.fromString(\"yellow\"),\r\n \"fraction\": ColorDef.fromString(\"green\"),\r\n \"tab\": ColorDef.fromString(\"aquamarine\"),\r\n }\r\n\r\n layout.lines.forEach(line => {\r\n // Apply the line's offset transform\r\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\r\n documentTransform.multiplyTransformTransform(lineTrans, lineTrans);\r\n\r\n line.runs.forEach(run => {\r\n // Determine color for this run type\r\n color = colors[run.source.type] ?? ColorDef.black;\r\n\r\n // Only change geometry params if the color changes\r\n if (!lastColor.equals(color)) {\r\n const colorParams = new GeometryParams(Id64.invalid);\r\n colorParams.lineColor = color;\r\n result = result && builder.appendGeometryParamsChange(colorParams);\r\n lastColor = color;\r\n }\r\n\r\n // Apply the line's offset to the run's offset\r\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\r\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\r\n\r\n // Draw the enclosing range for the run\r\n const runCorners = run.range.corners3d(true);\r\n runTrans.multiplyPoint3dArrayInPlace(runCorners);\r\n result = result && builder.appendGeometryQuery(LineString3d.create(runCorners));\r\n });\r\n });\r\n\r\n return result;\r\n}"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlockGeometry.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextBlockGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAA2D,MAAM,oBAAoB,CAAC;AACrH,OAAO,EAAa,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAmC,SAAS,EAAY,MAAM,sBAAsB,CAAC;AAoH5F;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,GAAG,sBAAsB,
|
|
1
|
+
{"version":3,"file":"TextBlockGeometry.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextBlockGeometry.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,sBAAsB,EAA2D,MAAM,oBAAoB,CAAC;AACrH,OAAO,EAAa,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAC/D,OAAO,EAAmC,SAAS,EAAY,MAAM,sBAAsB,CAAC;AAoH5F;;;;;;;GAOG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,eAAe,EAAE,iBAAiB,EAAE,SAAS,GAAG,sBAAsB,CAsBtH"}
|
|
@@ -108,7 +108,8 @@ function produceTextBlockGeometry(layout, documentTransform) {
|
|
|
108
108
|
for (const line of layout.lines) {
|
|
109
109
|
const lineTrans = core_geometry_1.Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);
|
|
110
110
|
for (const run of line.runs) {
|
|
111
|
-
|
|
111
|
+
// Skip runs that are solely whitespace
|
|
112
|
+
if (run.source.isWhitespace) {
|
|
112
113
|
continue;
|
|
113
114
|
}
|
|
114
115
|
const runTrans = core_geometry_1.Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlockGeometry.js","sourceRoot":"","sources":["../../../src/annotations/TextBlockGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAgIH,4DAqBC;AAnJD,oDAAqH;AAErH,wDAA4F;AAC5F,sDAA6C;AAO7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAE9E,OAAO,IAAI,wBAAU,CAAC;QACpB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,MAAM;QAChB,MAAM,EAAE,UAAU;QAClB,WAAW;QACX,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,YAAY;QACvB,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,GAAc,EAAE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AE,GAAG,CAAC,cAAc,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;YAC/F,SAAS,CAAC,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACzD,iBAAiB,CAAC,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACjE,IAAI,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC/B,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\nimport { TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\r\nimport { RunLayout, TextBlockLayout } from \"./TextBlockLayout\";\r\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\n\r\ninterface GeometryContext {\r\n curColor?: TextStyleColor;\r\n entries: TextBlockGeometryPropsEntry[];\r\n}\r\n\r\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\r\n if (color !== context.curColor) {\r\n context.curColor = color;\r\n context.entries.push({ color });\r\n }\r\n}\r\n\r\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\r\n assert(text.length > 0);\r\n\r\n const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\r\n\r\n return new TextString({\r\n text,\r\n font: run.fontId,\r\n height: lineHeight,\r\n widthFactor,\r\n bold: isBold,\r\n italic: isItalic,\r\n underline: isUnderlined,\r\n origin,\r\n });\r\n}\r\n\r\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n assert(run.source.type === \"text\");\r\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\r\n if (text.length === 0) {\r\n return;\r\n }\r\n\r\n const ts = createTextString(text, run);\r\n if (\"none\" !== run.source.baselineShift) {\r\n const isSub = \"subscript\" === run.source.baselineShift;\r\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\r\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\r\n\r\n ts.origin.y += offsetFactor * ts.height;\r\n ts.height *= scale;\r\n }\r\n\r\n ts.transformInPlace(transform);\r\n\r\n setColor(run.style.color, context);\r\n context.entries.push({ text: ts });\r\n}\r\n\r\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\r\n const ts = createTextString(text, run, origin);\r\n assert(undefined !== ts.widthFactor);\r\n\r\n ts.height *= run.style.stackedFractionScale;\r\n\r\n ts.transformInPlace(transform);\r\n\r\n return ts;\r\n}\r\n\r\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n const source = run.source;\r\n assert(source.type === \"fraction\");\r\n\r\n if (source.numerator.length === 0 && source.denominator.length === 0) {\r\n return;\r\n }\r\n\r\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\r\n\r\n const fontSize = new Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);\r\n fontSize.scale(run.style.stackedFractionScale, fontSize);\r\n\r\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\r\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\r\n\r\n setColor(run.style.color, context);\r\n\r\n if (source.numerator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\r\n }\r\n\r\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\r\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\r\n\r\n let separator: LineSegment3d;\r\n if (run.style.stackedFractionType === \"horizontal\") {\r\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\r\n const y = 1.25 * denominatorRange.yLength();\r\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\r\n } else {\r\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\r\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\r\n separator = LineSegment3d.createCapture(p0, p1);\r\n }\r\n\r\n separator.tryTransformInPlace(transform);\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: separator.point0Ref.toJSON(),\r\n endPoint: separator.point1Ref.toJSON(),\r\n },\r\n });\r\n\r\n if (source.denominator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.denominator, run, denominatorOffset, transform) });\r\n }\r\n}\r\n\r\n/**\r\n * Produces the geometry for a text block in a way that can be interpreted by a [[GeometryStreamBuilder]] or [[ElementBuilder.Geometry]].\r\n * To build the geometry for a whole [[TextAnnotation]], use [[appendTextAnnotationGeometry]] instead.\r\n * @param layout of the text block as computed by [[layoutTextBlock]].\r\n * @param documentTransform that positions the text block in world coordinates.\r\n * @returns TextBlockGeometryProps.\r\n * @beta\r\n */\r\nexport function produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform): TextBlockGeometryProps {\r\n const context: GeometryContext = { entries: [] };\r\n for (const line of layout.lines) {\r\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\r\n for (const run of line.runs) {\r\n if (\"linebreak\" === run.source.type) {\r\n continue;\r\n }\r\n\r\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\r\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\r\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\r\n if (\"text\" === run.source.type) {\r\n processTextRun(run, runTrans, context);\r\n } else {\r\n processFractionRun(run, runTrans, context);\r\n }\r\n }\r\n }\r\n\r\n return { entries: context.entries };\r\n}\r\n"]}
|
|
1
|
+
{"version":3,"file":"TextBlockGeometry.js","sourceRoot":"","sources":["../../../src/annotations/TextBlockGeometry.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;AAgIH,4DAsBC;AApJD,oDAAqH;AAErH,wDAA4F;AAC5F,sDAA6C;AAO7C,SAAS,QAAQ,CAAC,KAAqB,EAAE,OAAwB;IAC/D,IAAI,KAAK,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC;QAC/B,OAAO,CAAC,QAAQ,GAAG,KAAK,CAAC;QACzB,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC;IAClC,CAAC;AACH,CAAC;AAED,SAAS,gBAAgB,CAAC,IAAY,EAAE,GAAc,EAAE,MAAgB;IACtE,IAAA,qBAAM,EAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IAExB,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,YAAY,EAAE,GAAG,GAAG,CAAC,KAAK,CAAC;IAE9E,OAAO,IAAI,wBAAU,CAAC;QACpB,IAAI;QACJ,IAAI,EAAE,GAAG,CAAC,MAAM;QAChB,MAAM,EAAE,UAAU;QAClB,WAAW;QACX,IAAI,EAAE,MAAM;QACZ,MAAM,EAAE,QAAQ;QAChB,SAAS,EAAE,YAAY;QACvB,MAAM;KACP,CAAC,CAAC;AACL,CAAC;AAED,SAAS,cAAc,CAAC,GAAc,EAAE,SAAoB,EAAE,OAAwB;IACpF,IAAA,qBAAM,EAAC,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,MAAM,CA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AC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACzD,iBAAiB,CAAC,0BAA0B,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;YACjE,IAAI,MAAM,KAAK,GAAG,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;gBAC/B,cAAc,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YACzC,CAAC;iBAAM,CAAC;gBACN,kBAAkB,CAAC,GAAG,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;YAC7C,CAAC;QACH,CAAC;IACH,CAAC;IAED,OAAO,EAAE,OAAO,EAAE,OAAO,CAAC,OAAO,EAAE,CAAC;AACtC,CAAC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementGeometry\r\n */\r\n\r\nimport { TextBlockGeometryProps, TextBlockGeometryPropsEntry, TextString, TextStyleColor } from \"@itwin/core-common\";\r\nimport { RunLayout, TextBlockLayout } from \"./TextBlockLayout\";\r\nimport { LineSegment3d, Point3d, Range2d, Transform, Vector2d } from \"@itwin/core-geometry\";\r\nimport { assert } from \"@itwin/core-bentley\";\r\n\r\ninterface GeometryContext {\r\n curColor?: TextStyleColor;\r\n entries: TextBlockGeometryPropsEntry[];\r\n}\r\n\r\nfunction setColor(color: TextStyleColor, context: GeometryContext): void {\r\n if (color !== context.curColor) {\r\n context.curColor = color;\r\n context.entries.push({ color });\r\n }\r\n}\r\n\r\nfunction createTextString(text: string, run: RunLayout, origin?: Point3d): TextString {\r\n assert(text.length > 0);\r\n\r\n const { lineHeight, widthFactor, isBold, isItalic, isUnderlined } = run.style;\r\n\r\n return new TextString({\r\n text,\r\n font: run.fontId,\r\n height: lineHeight,\r\n widthFactor,\r\n bold: isBold,\r\n italic: isItalic,\r\n underline: isUnderlined,\r\n origin,\r\n });\r\n}\r\n\r\nfunction processTextRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n assert(run.source.type === \"text\");\r\n const text = run.source.content.substring(run.charOffset, run.charOffset + run.numChars);\r\n if (text.length === 0) {\r\n return;\r\n }\r\n\r\n const ts = createTextString(text, run);\r\n if (\"none\" !== run.source.baselineShift) {\r\n const isSub = \"subscript\" === run.source.baselineShift;\r\n const offsetFactor = run.style[isSub ? \"subScriptOffsetFactor\" : \"superScriptOffsetFactor\"];\r\n const scale = run.style[isSub ? \"subScriptScale\" : \"superScriptScale\"];\r\n\r\n ts.origin.y += offsetFactor * ts.height;\r\n ts.height *= scale;\r\n }\r\n\r\n ts.transformInPlace(transform);\r\n\r\n setColor(run.style.color, context);\r\n context.entries.push({ text: ts });\r\n}\r\n\r\nfunction createFractionTextString(text: string, run: RunLayout, origin: Point3d, transform: Transform): TextString {\r\n const ts = createTextString(text, run, origin);\r\n assert(undefined !== ts.widthFactor);\r\n\r\n ts.height *= run.style.stackedFractionScale;\r\n\r\n ts.transformInPlace(transform);\r\n\r\n return ts;\r\n}\r\n\r\nfunction processFractionRun(run: RunLayout, transform: Transform, context: GeometryContext): void {\r\n const source = run.source;\r\n assert(source.type === \"fraction\");\r\n\r\n if (source.numerator.length === 0 && source.denominator.length === 0) {\r\n return;\r\n }\r\n\r\n assert(undefined !== run.numeratorRange && undefined !== run.denominatorRange);\r\n\r\n const fontSize = new Vector2d(run.style.lineHeight * run.style.widthFactor, run.style.lineHeight);\r\n fontSize.scale(run.style.stackedFractionScale, fontSize);\r\n\r\n const numeratorOffset = new Point3d(run.numeratorRange.low.x, run.numeratorRange.low.y, 0);\r\n const denominatorOffset = new Point3d(run.denominatorRange.low.x, run.denominatorRange.low.y, 0);\r\n\r\n setColor(run.style.color, context);\r\n\r\n if (source.numerator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.numerator, run, numeratorOffset, transform) });\r\n }\r\n\r\n const numeratorRange = Range2d.fromJSON(run.numeratorRange);\r\n const denominatorRange = Range2d.fromJSON(run.denominatorRange);\r\n\r\n let separator: LineSegment3d;\r\n if (run.style.stackedFractionType === \"horizontal\") {\r\n const fractionWidth = Math.max(numeratorRange.xLength(), denominatorRange.xLength());\r\n const y = 1.25 * denominatorRange.yLength();\r\n separator = LineSegment3d.createXYXY(0, y, fractionWidth, y);\r\n } else {\r\n const p0 = new Point3d(denominatorRange.low.x - fontSize.x / 2, denominatorRange.low.y + fontSize.y * (1 / 3), 0);\r\n const p1 = new Point3d(p0.x + fontSize.x, p0.y + fontSize.y * 1.5, 0);\r\n separator = LineSegment3d.createCapture(p0, p1);\r\n }\r\n\r\n separator.tryTransformInPlace(transform);\r\n\r\n context.entries.push({\r\n separator: {\r\n startPoint: separator.point0Ref.toJSON(),\r\n endPoint: separator.point1Ref.toJSON(),\r\n },\r\n });\r\n\r\n if (source.denominator.length > 0) {\r\n context.entries.push({ text: createFractionTextString(source.denominator, run, denominatorOffset, transform) });\r\n }\r\n}\r\n\r\n/**\r\n * Produces the geometry for a text block in a way that can be interpreted by a [[GeometryStreamBuilder]] or [[ElementBuilder.Geometry]].\r\n * To build the geometry for a whole [[TextAnnotation]], use [[appendTextAnnotationGeometry]] instead.\r\n * @param layout of the text block as computed by [[layoutTextBlock]].\r\n * @param documentTransform that positions the text block in world coordinates.\r\n * @returns TextBlockGeometryProps.\r\n * @beta\r\n */\r\nexport function produceTextBlockGeometry(layout: TextBlockLayout, documentTransform: Transform): TextBlockGeometryProps {\r\n const context: GeometryContext = { entries: [] };\r\n for (const line of layout.lines) {\r\n const lineTrans = Transform.createTranslationXYZ(line.offsetFromDocument.x, line.offsetFromDocument.y, 0);\r\n for (const run of line.runs) {\r\n // Skip runs that are solely whitespace\r\n if (run.source.isWhitespace) {\r\n continue;\r\n }\r\n\r\n const runTrans = Transform.createTranslationXYZ(run.offsetFromLine.x, run.offsetFromLine.y, 0);\r\n lineTrans.multiplyTransformTransform(runTrans, runTrans);\r\n documentTransform.multiplyTransformTransform(runTrans, runTrans);\r\n if (\"text\" === run.source.type) {\r\n processTextRun(run, runTrans, context);\r\n } else {\r\n processFractionRun(run, runTrans, context);\r\n }\r\n }\r\n }\r\n\r\n return { entries: context.entries };\r\n}\r\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/** @packageDocumentation
|
|
2
2
|
* @module ElementGeometry
|
|
3
3
|
*/
|
|
4
|
-
import { BaselineShift, FontId, FontType, FractionRun, LineLayoutResult, Paragraph, Run, RunLayoutResult, TextBlock, TextBlockLayoutResult, TextRun, TextStyleSettings } from "@itwin/core-common";
|
|
4
|
+
import { BaselineShift, FontId, FontType, FractionRun, LineLayoutResult, Paragraph, Run, RunLayoutResult, TabRun, TextBlock, TextBlockLayoutResult, TextRun, TextStyleSettings } from "@itwin/core-common";
|
|
5
5
|
import { Range2d } from "@itwin/core-geometry";
|
|
6
6
|
import { IModelDb } from "../IModelDb";
|
|
7
7
|
/** @internal */
|
|
@@ -103,6 +103,7 @@ declare class LayoutContext {
|
|
|
103
103
|
numerator: Range2d;
|
|
104
104
|
denominator: Range2d;
|
|
105
105
|
};
|
|
106
|
+
computeRangeForTabRun(style: TextStyleSettings, source: TabRun, length: number): Range2d;
|
|
106
107
|
}
|
|
107
108
|
/**
|
|
108
109
|
* Represents the layout of a single run (text, fraction, or line break) within a line of text.
|
|
@@ -149,6 +150,7 @@ export declare class LineLayout {
|
|
|
149
150
|
x: number;
|
|
150
151
|
y: number;
|
|
151
152
|
};
|
|
153
|
+
lengthFromLastTab: number;
|
|
152
154
|
private _runs;
|
|
153
155
|
constructor(source: Paragraph);
|
|
154
156
|
/** Compute a string representation, primarily for debugging purposes. */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TextBlockLayout.d.ts","sourceRoot":"","sources":["../../../src/annotations/TextBlockLayout.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,gBAAgB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